Email Answering System
Version 1.0

com.ninecode.email.util
Class EmailProperties

java.lang.Object
  |
  +--java.util.Dictionary
        |
        +--java.util.Hashtable
              |
              +--java.util.Properties
                    |
                    +--com.ninecode.email.util.EmailProperties
All Implemented Interfaces:
Cloneable, Map, Serializable

public class EmailProperties
extends Properties

Basket for mail.XXXX properties. This class reads and writes it's properties as a single delimited string.

Author:
Derrick Oswald
See Also:
Serialized Form

Field Summary
protected static String mDelims
          Possible delimiter characters (on output).
protected static char[] mHexDigits
          A table of hex digits.
protected static String mSpecialSaveChars
          Characters receiving unicode escape handling on output.
 
Fields inherited from class java.util.Properties
defaults
 
Constructor Summary
EmailProperties()
          Creates an empty instance of EmailProperties.
EmailProperties(Properties properties)
          Creates an instance of EmailProperties backed by the given properties.
EmailProperties(String properties)
          Creates an instance of EmailProperties containing the given properties.
 
Method Summary
protected  String convert(String theString, boolean escapeSpace)
          Reformats a property value for saving in a string.
 boolean equals(Object other)
          Check for equality.
protected static char hex(int nibble)
          Convert a nibble to a hex character
 void parseString(String string)
          Adds the properties provided in the string to this email properties.
 String toString()
          Converts the current values of all the properties to a string.
 
Methods inherited from class java.util.Properties
getProperty, getProperty, list, list, load, propertyNames, save, setProperty, store
 
Methods inherited from class java.util.Hashtable
clear, clone, contains, containsKey, containsValue, elements, entrySet, get, hashCode, isEmpty, keys, keySet, put, putAll, rehash, remove, size, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

mDelims

protected static final String mDelims
Possible delimiter characters (on output).

See Also:
Constant Field Values

mSpecialSaveChars

protected static final String mSpecialSaveChars
Characters receiving unicode escape handling on output.

See Also:
Constant Field Values

mHexDigits

protected static final char[] mHexDigits
A table of hex digits.

Constructor Detail

EmailProperties

public EmailProperties()
Creates an empty instance of EmailProperties.


EmailProperties

public EmailProperties(Properties properties)
Creates an instance of EmailProperties backed by the given properties.


EmailProperties

public EmailProperties(String properties)
Creates an instance of EmailProperties containing the given properties.

See Also:
parseString(java.lang.String)
Method Detail

parseString

public void parseString(String string)
Adds the properties provided in the string to this email properties. Convert the given string to a valid set of properties. The string must be of the form dXX=YYdJJ=KKd where the d is a delimiter that leads, trails and separates individual settings, i.e.

|mail.from=tobias@linkone.com|mail.smtp.auth=true|

Parameters:
string - The value to parse.
Throws:
IllegalArgumentException - if the string does not start and end with the same character or after converting the delimiter to newlines, the properties cannot be loaded.

toString

public String toString()
Converts the current values of all the properties to a string. A delimiter is chosen from the set "|/~*%^?&+',." which does not conflict with the values in the properties, and a string of the form dXX=YYdJJ=KKd is created, where d is the delimiter chosen.

Overrides:
toString in class Hashtable
Returns:
The stringized set of properties.
Throws:
IllegalStateException - If a delimiter cannot be chosen that doesn't conflict with the contents of the properties.

convert

protected String convert(String theString,
                         boolean escapeSpace)
Reformats a property value for saving in a string. Converts unicodes to encoded \uxxxx and writes out any of the characters in specialSaveChars with a preceding slash

This and hex() are copied from java.util.Properties and are only repeated here because some neophyte at Sun thought a utility function like this should be private, what a dolt. Never thought someone might subclass properties? Idiot.


hex

protected static char hex(int nibble)
Convert a nibble to a hex character

Parameters:
nibble - The nibble to convert.
Returns:
The hex character equivalent.

equals

public boolean equals(Object other)
Check for equality.

Specified by:
equals in interface Map
Overrides:
equals in class Hashtable
Parameters:
other - The other object to compare against.

Email Answering System
Version 1.0

Copyright © 2003 Derrick Oswald. All rights reserved.