com.openexchange.mail
Class Protocol

java.lang.Object
  extended by com.openexchange.mail.Protocol
All Implemented Interfaces:
com.openexchange.groupware.Component, java.io.Serializable

public class Protocol
extends java.lang.Object
implements com.openexchange.groupware.Component, java.io.Serializable

Protocol - Represents both a mail and transport protocol

Author:
Thorben Betten
See Also:
Serialized Form

Field Summary
static java.lang.String ALL
          The all identifier.
static Protocol PROTOCOL_ALL
          All protocols supported.
 
Constructor Summary
Protocol(java.lang.String name)
          Initializes a new Protocol
Protocol(java.lang.String name, java.lang.String secureName)
          Initializes a new Protocol
Protocol(java.lang.String name, java.lang.String[] aliases)
          Initializes a new Protocol
 
Method Summary
 boolean equals(java.lang.Object obj)
           
 java.lang.String getAbbreviation()
           
 java.lang.String[] getAliases()
          Gets the aliases
 java.lang.String getName()
          Gets the name
 int hashCode()
           
 boolean isSupported(java.lang.String protocolName)
          Checks if given protocol name is supported by this protocol
static Protocol parseProtocol(java.lang.String protocol)
          Parses specified protocol string whose syntax match pattern:
([a-z]+)(?
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ALL

public static final java.lang.String ALL
The all identifier.

See Also:
Constant Field Values

PROTOCOL_ALL

public static final Protocol PROTOCOL_ALL
All protocols supported.

Constructor Detail

Protocol

public Protocol(java.lang.String name)
Initializes a new Protocol

Parameters:
name - The protocol's name in lower case
Throws:
java.lang.IllegalArgumentException - If name is null

Protocol

public Protocol(java.lang.String name,
                java.lang.String secureName)
Initializes a new Protocol

Parameters:
name - The protocol's name in lower case
secureName - The protocol's secure name in lower case
Throws:
java.lang.IllegalArgumentException - If name is null

Protocol

public Protocol(java.lang.String name,
                java.lang.String[] aliases)
Initializes a new Protocol

Parameters:
name - The protocol's name in lower case
aliases - The protocol's aliases in lower case
Throws:
java.lang.IllegalArgumentException - If name is null
Method Detail

parseProtocol

public static Protocol parseProtocol(java.lang.String protocol)
                              throws MailException
Parses specified protocol string whose syntax match pattern:
([a-z]+)(?:((?:_[a-z]+)*))?
E.g.: http or http_https.

Parameters:
protocol - The protocol string to parse
Returns:
Corresponding instance of Protocol
Throws:
MailException - If parsing the specified protocol string fails

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

getAliases

public java.lang.String[] getAliases()
Gets the aliases

Returns:
the aliases

getName

public java.lang.String getName()
Gets the name

Returns:
the name

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

isSupported

public boolean isSupported(java.lang.String protocolName)
Checks if given protocol name is supported by this protocol

Parameters:
protocolName - The protocol name to check
Returns:
true if supported; otherwise false

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getAbbreviation

public java.lang.String getAbbreviation()
Specified by:
getAbbreviation in interface com.openexchange.groupware.Component