1. /*
  2. * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
  3. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  4. */
  5. package javax.mail;
  6. /**
  7. * The Provider is a class that describes a protocol
  8. * implementation. The values come from the
  9. * javamail.providers & javamail.default.providers
  10. * resource files.
  11. *
  12. * @version 1.7, 99/12/06
  13. * @author Max Spivak
  14. */
  15. public class Provider {
  16. /**
  17. * This inner class defines the Provider type.
  18. * Currently, STORE and TRANSPORT are the only two provider types
  19. * supported.
  20. */
  21. public static class Type {
  22. public static final Type STORE = new Type("Store");
  23. public static final Type TRANSPORT = new Type("Transport");
  24. private String type;
  25. private Type(String type) {
  26. this.type = type;
  27. }
  28. }
  29. private Type type;
  30. private String protocol, className, vendor, version;
  31. /**
  32. * Package-private constructor for the Provider class.
  33. *
  34. * @param type Type.STORE or Type.TRANSPORT
  35. * @param protocol valid protocol for the type
  36. * @param classname class name that implements this protocol
  37. * @param vendor optional string identifying the vendor (may be null)
  38. * @param version optional implementation version string (may be null)
  39. */
  40. Provider(Type type, String protocol, String classname,
  41. String vendor, String version) {
  42. this.type = type;
  43. this.protocol = protocol;
  44. this.className = classname;
  45. this.vendor = vendor;
  46. this.version = version;
  47. }
  48. /** Returns the type of this Provider */
  49. public Type getType() {
  50. return type;
  51. }
  52. /** Returns the protocol supported by this Provider */
  53. public String getProtocol() {
  54. return protocol;
  55. }
  56. /** Returns name of the class that implements the protocol */
  57. public String getClassName() {
  58. return className;
  59. }
  60. /** Returns name of vendor associated with this implementation or null */
  61. public String getVendor() {
  62. return vendor;
  63. }
  64. /** Returns version of this implementation or null if no version */
  65. public String getVersion() {
  66. return version;
  67. }
  68. /** Overrides Object.toString() */
  69. public String toString() {
  70. String s = "javax.mail.Provider[";
  71. if (type == Type.STORE) {
  72. s += "STORE,";
  73. } else if (type == Type.TRANSPORT) {
  74. s += "TRANSPORT,";
  75. }
  76. s += protocol + "," + className;
  77. if (vendor != null)
  78. s += "," + vendor;
  79. if (version != null)
  80. s += "," + version;
  81. s += "]";
  82. return s;
  83. }
  84. }