superwaba.ext.xplat.io.pimal
Class VersitField

java.lang.Object
  |
  +--superwaba.ext.xplat.io.pimal.VersitField
Direct Known Subclasses:
MemoField, VCalField, VCardField

public abstract class VersitField
extends java.lang.Object

Abstract superclass for Field-classes that use the vCard or vCalendar standard. Contains methods for handling key-option-value triples Please refer to vCard and vCalendar specification for more information


Field Summary
protected  int key
           
protected  Hashtable options
           
protected  java.lang.String[] optionsAsArray
           
protected  java.lang.String[] values
           
static int X
           
 
Constructor Summary
VersitField(int key, java.lang.String[] options, java.lang.String[] values)
          Saves the key and the values in arrays and the options in a hashtable
 
Method Summary
 void addOption(java.lang.String key, java.lang.String value)
          Adds an option to this field.
protected  java.lang.String[] cloneOptions()
          Clones the options
protected  java.lang.String[] cloneValues()
          Clones the values
 int getKey()
          Getter for the key
 Vector getOption(java.lang.String key)
          Returns option-values for a specific option-key
 Hashtable getOptions()
          Returns this field's options.
 java.lang.String[] getValues()
          Getter for the values
 boolean hasOption(java.lang.String key, java.lang.String value)
          Checks of a spcific option is set
 int match(VersitField fieldToMatch)
          Calculates a score, how similar to VersitFields are
 void removeOption(java.lang.String key, java.lang.String value)
          Removes a specific option.
 void setValues(java.lang.String[] values)
          Setter for the values
 java.lang.String toString()
          This method returns the String representative of this Object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

X

public static final int X

key

protected int key

values

protected java.lang.String[] values

options

protected Hashtable options

optionsAsArray

protected java.lang.String[] optionsAsArray
Constructor Detail

VersitField

public VersitField(int key,
                   java.lang.String[] options,
                   java.lang.String[] values)
Saves the key and the values in arrays and the options in a hashtable
Parameters:
key - a field's key
options - options to store
values - values to store
Method Detail

getKey

public int getKey()
Getter for the key
Returns:
int this field's key

getOptions

public Hashtable getOptions()
Returns this field's options. You can manipulate this Hashtable, but it is recommended to use the methods addOption() and removeOption() instead. * The data structure of the options is as follows: There's a Hashtable of options. The hashtable's keys consist of the option's keys. The hashtables value is a Vector of Strings of the option's value(s). If you have a one-value-option the option is still saved in a one-element-Vector.
Returns:
Hashtable options

getOption

public Vector getOption(java.lang.String key)
Returns option-values for a specific option-key
Parameters:
key - the option-key for which options should be returned
Returns:
a Vector of option-values found for this option-key

getValues

public java.lang.String[] getValues()
Getter for the values
Returns:
A String[] of values

addOption

public void addOption(java.lang.String key,
                      java.lang.String value)
Adds an option to this field. Options have the format "OPTION-KEY=OPTION-VALUE".
Parameters:
key - the option's key
value - the option's value

removeOption

public void removeOption(java.lang.String key,
                         java.lang.String value)
Removes a specific option.
Parameters:
key - the key, whose given value should be removed
value - the value that should be removed

setValues

public void setValues(java.lang.String[] values)
Setter for the values
Parameters:
values - values to set

toString

public java.lang.String toString()
This method returns the String representative of this Object. If you use this method of VersitField the key is missing in the String representative. So please use the toString()-method of VCalField respective VCardField.
Overrides:
toString in class java.lang.Object
See Also:
Object.toString()

cloneOptions

protected java.lang.String[] cloneOptions()
Clones the options
Returns:
the options' clone

cloneValues

protected java.lang.String[] cloneValues()
Clones the values
Returns:
the values' clone

hasOption

public boolean hasOption(java.lang.String key,
                         java.lang.String value)
Checks of a spcific option is set
Parameters:
key - the key of the option to check
value - the value, that has to be set
Returns:
true, if the value is found for the given option, otherwise false

match

public int match(VersitField fieldToMatch)
Calculates a score, how similar to VersitFields are
Parameters:
fieldToMatch - VersitField to compare this field to
Returns:
the score