Save This Page
Home » glassfish-v2ur2-b04-src » javax » mail » [javadoc | source]
    1   /*
    2    * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    3    *
    4    * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
    5    *
    6    * The contents of this file are subject to the terms of either the GNU
    7    * General Public License Version 2 only ("GPL") or the Common Development
    8    * and Distribution License("CDDL") (collectively, the "License").  You
    9    * may not use this file except in compliance with the License. You can obtain
   10    * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
   11    * or glassfish/bootstrap/legal/LICENSE.txt.  See the License for the specific
   12    * language governing permissions and limitations under the License.
   13    *
   14    * When distributing the software, include this License Header Notice in each
   15    * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
   16    * Sun designates this particular file as subject to the "Classpath" exception
   17    * as provided by Sun in the GPL Version 2 section of the License file that
   18    * accompanied this code.  If applicable, add the following below the License
   19    * Header, with the fields enclosed by brackets [] replaced by your own
   20    * identifying information: "Portions Copyrighted [year]
   21    * [name of copyright owner]"
   22    *
   23    * Contributor(s):
   24    *
   25    * If you wish your version of this file to be governed by only the CDDL or
   26    * only the GPL Version 2, indicate your decision by adding "[Contributor]
   27    * elects to include this software in this distribution under the [CDDL or GPL
   28    * Version 2] license."  If you don't indicate a single choice of license, a
   29    * recipient has the option to distribute your version of this file under
   30    * either the CDDL, the GPL Version 2 or to extend the choice of license to
   31    * its licensees as provided above.  However, if you add GPL Version 2 code
   32    * and therefore, elected the GPL Version 2 license, then the option applies
   33    * only if the new code is made subject to such option by the copyright
   34    * holder.
   35    */
   36   
   37   /*
   38    * @(#)Provider.java	1.11 07/05/04
   39    */
   40   
   41   package javax.mail;
   42   
   43   /**
   44    * The Provider is a class that describes a protocol 
   45    * implementation.  The values typically come from the
   46    * javamail.providers and javamail.default.providers
   47    * resource files.  An application may also create and
   48    * register a Provider object to dynamically add support
   49    * for a new provider.
   50    *
   51    * @version 1.11, 07/05/04
   52    * @author Max Spivak
   53    * @author Bill Shannon
   54    */
   55   public class Provider {
   56   
   57       /**
   58        * This inner class defines the Provider type.
   59        * Currently, STORE and TRANSPORT are the only two provider types 
   60        * supported.
   61        */
   62   
   63       public static class Type {
   64   	public static final Type STORE     = new Type("STORE");
   65   	public static final Type TRANSPORT = new Type("TRANSPORT");
   66   
   67   	private String type;
   68   
   69   	private Type(String type) {
   70   	    this.type = type;
   71   	}
   72   
   73   	public String toString() {
   74   	    return type;
   75   	}
   76       }
   77   
   78       private Type type;
   79       private String protocol, className, vendor, version;
   80   
   81       /**
   82        * Create a new provider of the specified type for the specified
   83        * protocol.  The specified class implements the provider.
   84        *
   85        * @param type      Type.STORE or Type.TRANSPORT
   86        * @param protocol  valid protocol for the type
   87        * @param classname class name that implements this protocol
   88        * @param vendor    optional string identifying the vendor (may be null)
   89        * @param version   optional implementation version string (may be null)
   90        * @since JavaMail 1.4
   91        */
   92       public Provider(Type type, String protocol, String classname, 
   93   	     String vendor, String version) {
   94   	this.type = type;
   95   	this.protocol = protocol;
   96   	this.className = classname;
   97   	this.vendor = vendor;
   98   	this.version = version;
   99       }
  100   
  101       /** Returns the type of this Provider */
  102       public Type getType() {
  103   	return type;
  104       }
  105   
  106       /** Returns the protocol supported by this Provider */
  107       public String getProtocol() {
  108   	return protocol;
  109       }
  110   
  111       /** Returns name of the class that implements the protocol */
  112       public String getClassName() {
  113   	return className;
  114       }
  115   
  116       /** Returns name of vendor associated with this implementation or null */
  117       public String getVendor() {
  118   	return vendor;
  119       }
  120   
  121       /** Returns version of this implementation or null if no version */
  122       public String getVersion() {
  123   	return version;
  124       }
  125   
  126       /** Overrides Object.toString() */
  127       public String toString() {
  128   	String s = "javax.mail.Provider[" + type + "," +
  129   		    protocol + "," + className;
  130   
  131   	if (vendor != null)
  132   	    s += "," + vendor;
  133   
  134   	if (version != null)
  135   	    s += "," + version;
  136   
  137   	s += "]";
  138   	return s;
  139       }
  140   }

Save This Page
Home » glassfish-v2ur2-b04-src » javax » mail » [javadoc | source]