KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > mail > Provider


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the "License"). You may not use this file except
5  * in compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * glassfish/bootstrap/legal/CDDLv1.0.txt or
9  * https://glassfish.dev.java.net/public/CDDLv1.0.html.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * HEADER in each file and include the License file at
15  * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable,
16  * add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your
18  * own identifying information: Portions Copyright [yyyy]
19  * [name of copyright owner]
20  */

21
22 /*
23  * @(#)Provider.java 1.10 05/08/29
24  *
25  * Copyright 1997-2005 Sun Microsystems, Inc. All Rights Reserved.
26  */

27
28 package javax.mail;
29
30 /**
31  * The Provider is a class that describes a protocol
32  * implementation. The values typically come from the
33  * javamail.providers and javamail.default.providers
34  * resource files. An application may also create and
35  * register a Provider object to dynamically add support
36  * for a new provider.
37  *
38  * @version 1.10, 05/08/29
39  * @author Max Spivak
40  * @author Bill Shannon
41  */

42 public class Provider {
43
44     /**
45      * This inner class defines the Provider type.
46      * Currently, STORE and TRANSPORT are the only two provider types
47      * supported.
48      */

49
50     public static class Type {
51     public static final Type STORE = new Type("STORE");
52     public static final Type TRANSPORT = new Type("TRANSPORT");
53
54     private String JavaDoc type;
55
56     private Type(String JavaDoc type) {
57         this.type = type;
58     }
59
60     public String JavaDoc toString() {
61         return type;
62     }
63     }
64
65     private Type type;
66     private String JavaDoc protocol, className, vendor, version;
67
68     /**
69      * Create a new provider of the specified type for the specified
70      * protocol. The specified class implements the provider.
71      *
72      * @param type Type.STORE or Type.TRANSPORT
73      * @param protocol valid protocol for the type
74      * @param classname class name that implements this protocol
75      * @param vendor optional string identifying the vendor (may be null)
76      * @param version optional implementation version string (may be null)
77      * @since JavaMail 1.4
78      */

79     public Provider(Type type, String JavaDoc protocol, String JavaDoc classname,
80          String JavaDoc vendor, String JavaDoc version) {
81     this.type = type;
82     this.protocol = protocol;
83     this.className = classname;
84     this.vendor = vendor;
85     this.version = version;
86     }
87
88     /** Returns the type of this Provider */
89     public Type getType() {
90     return type;
91     }
92
93     /** Returns the protocol supported by this Provider */
94     public String JavaDoc getProtocol() {
95     return protocol;
96     }
97
98     /** Returns name of the class that implements the protocol */
99     public String JavaDoc getClassName() {
100     return className;
101     }
102
103     /** Returns name of vendor associated with this implementation or null */
104     public String JavaDoc getVendor() {
105     return vendor;
106     }
107
108     /** Returns version of this implementation or null if no version */
109     public String JavaDoc getVersion() {
110     return version;
111     }
112
113     /** Overrides Object.toString() */
114     public String JavaDoc toString() {
115     String JavaDoc s = "javax.mail.Provider[" + type + "," +
116             protocol + "," + className;
117
118     if (vendor != null)
119         s += "," + vendor;
120
121     if (version != null)
122         s += "," + version;
123
124     s += "]";
125     return s;
126     }
127 }
128
Popular Tags