org.openeai.config
Class EnterpriseFormatter


java.lang.Object

  |

  +--org.openeai.OpenEaiObject

        |

        +--org.openeai.config.EnterpriseFormatter


public class EnterpriseFormatter
extends OpenEaiObject

This class is used to store and verify the expected format of a particular field. It's an instance variable in the Field object and contains formatting rules specific to that field as specified in the EnterpriseObjects document.

For the purpose of this object, formatting includes the following which is all specified in the EnterpriseObjects document for all objects:

These "formatting rules" are applied when the setter method of an Enterprise Object is called. For example, when the BasicPerson.setGender("M"); method is called, the BasicPerson object uses its EnterpriseFields object to turn that supplied value into an "Enterprise Value". The EnterpriseFields object uses a Field's Formatter to perform that logic.

Another example would be a situtation where an application calls the Name.setLastName("JACKSON"); method When that method is called, it too uses its EnterpriseFields object to format that data. Since that field doesn't have any Translations associated with it, the Formatter will verify that the data is of an appropriate length (maximum or exact), verify that it's of the appropriate type (char, numeric etc.) and run any scrubbers that may be associated to that field on the data. Consequently, the application value of "JACKSON" may be converted to the Enterprise Value of "Jackson" in the end.

Version:
3.0 beta2 - 28 January 2003
Author:
Tod Jackson (tod@openeai.org), Steve Wheat (steve@openeai.org)
See Also:
EnterpriseFields, Field, EnterpriseTranslator, EnterpriseScrubber

Field Summary
 
Fields inherited from class org.openeai.OpenEaiObject
logger
 
Constructor Summary
EnterpriseFormatter()
          Constructor
 
Method Summary
 void addScrubber(EnterpriseScrubber scrubber)
          This method is used as the EnterprsieFields object builds a Field's EnterpriseFormatter to add an EnterpriseScrubber implmentation that's specified in the EnterpriseObjects document to the Field's Formatter.
 java.lang.String format(java.lang.String value)
          This method is called by the EnterpriseFields object when a Field's data is being converted to the Enterprise Value.
 java.lang.String getDatatype()
          Returns the allowable datatype for the Field.
 int getLength()
          Returns the allowable length for the Field as specified in the EnterpriseObject document.
 java.lang.String getLengthType()
          Returns the length type associated to the Field as specified in the EnterpriseObjects document.
 java.lang.String getMask()
           
 boolean getRequired()
          Returns the boolean flag indicating whether or not this Field is required.
 EnterpriseScrubber getScrubber(int index)
          This method returns a scrubber from a specified location in the list of scrubbers associated to the Field.
 java.util.Vector getScrubbers()
          Returns the list of all scrubbers associated to the field.
 EnterpriseTranslator getTranslator()
          Returns the EnterpriseTranslator object associated to the Formatter for the Field.
 void insertScrubber(int index, EnterpriseScrubber scrubber)
          This method is also used as the EnterprsieFields object builds a Field's EnterpriseFormatter to add an EnterpriseScrubber implmentation that's specified in the EnterpriseObjects document to the Field's Formatter.
 void setDatatype(java.lang.String type)
          Sets the allowable datatype for the Field.
 void setLength(int length)
          Sets the allowable length for the Field as specified in the EnterpriseObject document.
 void setLengthType(java.lang.String type)
          Sets the length type associated to the Field as specified in the EnterpriseObjects document.
 void setMask(java.lang.String mask)
           
 void setRequired(boolean required)
          Sets the boolean flag indicating whether or not this Field is required.
 void setScrubbers(java.util.Vector scrubber)
          Sets the list of scrubber implementations to that of the Vector passed in.
 void setTranslator(EnterpriseTranslator translator)
          Sets the EnterpriseTranslator object associated to the Formatter for the Field if one should exist.
 
Methods inherited from class org.openeai.OpenEaiObject
addLog4jProperty, getAppName, getDebug, getFromAddr, getLog4jProperties, getMailHost, getMailService, getProperties, getToAddr, initializeLog4j, initializeLog4j, initializeLog4j, setAppName, setDebug, setFromAddr, setMailHost, setMailService, setProperties, setToAddr
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EnterpriseFormatter


public EnterpriseFormatter()
Constructor

Method Detail

setTranslator


public void setTranslator(EnterpriseTranslator translator)
Sets the EnterpriseTranslator object associated to the Formatter for the Field if one should exist.

See Also:
EnterpriseTranslator, Field

getTranslator


public EnterpriseTranslator getTranslator()
Returns the EnterpriseTranslator object associated to the Formatter for the Field. If a field doesn't have any translations associated to it, this will be null.

Returns:
EnterpriseTranslator the translator associated to the Field or null if none exists
See Also:
EnterpriseTranslator, Field

setScrubbers


public void setScrubbers(java.util.Vector scrubber)
Sets the list of scrubber implementations to that of the Vector passed in.


getScrubbers


public java.util.Vector getScrubbers()
Returns the list of all scrubbers associated to the field.

Returns:
Vector

getScrubber


public EnterpriseScrubber getScrubber(int index)
This method returns a scrubber from a specified location in the list of scrubbers associated to the Field. This is called by the EnterpriseFields object when an application value passed to a field's setter method is converted to an enterprise value.

Returns:
the scrubber implementation found at the index passed in.

addScrubber


public void addScrubber(EnterpriseScrubber scrubber)
This method is used as the EnterprsieFields object builds a Field's EnterpriseFormatter to add an EnterpriseScrubber implmentation that's specified in the EnterpriseObjects document to the Field's Formatter.


insertScrubber


public void insertScrubber(int index,
                           EnterpriseScrubber scrubber)
This method is also used as the EnterprsieFields object builds a Field's EnterpriseFormatter to add an EnterpriseScrubber implmentation that's specified in the EnterpriseObjects document to the Field's Formatter. The difference between this and the addScrubber method is that this method inserts the scrubber implementation at a specified location in the list of scrubbers for the field. This scrubber order is specified in the EnterpiseObjects document.


setMask


public void setMask(java.lang.String mask)

getMask


public java.lang.String getMask()

setDatatype


public void setDatatype(java.lang.String type)
Sets the allowable datatype for the Field. Allowable datatypes are:

getDatatype


public java.lang.String getDatatype()
Returns the allowable datatype for the Field. Allowable datatypes are:

setRequired


public void setRequired(boolean required)
Sets the boolean flag indicating whether or not this Field is required. Note, 'required' means there must be data in the field for it to be valid.


getRequired


public boolean getRequired()
Returns the boolean flag indicating whether or not this Field is required. Note, 'required' means there must be data in the field for it to be valid.


setLength


public void setLength(int length)
Sets the allowable length for the Field as specified in the EnterpriseObject document. Note, there are two types of lengths that can be associated to a Field (exact or maximum).

See Also:
setLengthType

getLength


public int getLength()
Returns the allowable length for the Field as specified in the EnterpriseObject document. Note, there are two types of lengths that can be associated to a Field (exact or maximum).

See Also:
setLengthType

setLengthType


public void setLengthType(java.lang.String type)
Sets the length type associated to the Field as specified in the EnterpriseObjects document. Allowable length types are: exact and maximum.

A length type of "exact" means the data supplied for the Field being populated must be EXACTLY n bytes long. A length type of "maximum" means the data supplied for the Field being populated may be UP-TO n bytes long.


getLengthType


public java.lang.String getLengthType()
Returns the length type associated to the Field as specified in the EnterpriseObjects document. Allowable length types are: "exact" and "maximum".

A length type of "exact" means the data supplied for the Field being populated must be EXACTLY n bytes long. A length type of "maximum" means the data supplied for the Field being populated may be UP-TO n bytes long.

Returns:
String the length type ("exact" or "maximum").

format


public java.lang.String format(java.lang.String value)
                        throws InvalidFormatException
This method is called by the EnterpriseFields object when a Field's data is being converted to the Enterprise Value. This method applies all the rules as specified in the description of this class to the data supplied for the field. If any rule is broken and the value cannot be translated to an enterprise value, an exception is thrown indicating the formatting rule that was broken.

Returns:
String the value after it has been formatted. This may be the same value as was passed in or it may be different depending on how the Field's formatting rules are specified. For example, if there are scrubbers associated to the Field, the value will most likely be changed. Additionally, if the field has a translator associated to it, the supplied value may be translated from an application value (code) to that value's corresponding enterprise value.
Throws:
InvalidFormatException - if errors occur while applying the fomrmatting rules.


Copyright © 2002, OpenEAI Software Foundation