org.openeai.layouts
Class EnterpriseLayoutManagerImpl

java.lang.Object
  extended by org.openeai.OpenEaiObject
      extended by org.openeai.layouts.EnterpriseLayoutManagerImpl
Direct Known Subclasses:
XmlLayout

public abstract class EnterpriseLayoutManagerImpl
extends OpenEaiObject

The parent class of all EnterpriseLayoutManagers created by the OpenEAI software foundation. Provides convenience methods to the decendant objects.

Version:
3.0 - 28 January 2003
Author:
Tod Jackson (tod@openeai.org), Steve Wheat (steve@openeai.org)

Field Summary
protected static java.lang.String LIST
           
 
Fields inherited from class org.openeai.OpenEaiObject
logger
 
Constructor Summary
EnterpriseLayoutManagerImpl()
          Constructor
 
Method Summary
 java.lang.String getEnterpriseObjectsUri()
          Returns the EnterpriseObjects document uri associated to this EnterpriseFields object.
protected  org.jdom.Element getFieldLayout(org.jdom.Element eField, java.lang.String name)
          Returns the Layout Element associated to a particular field as specified in an application's deployment document.
protected  org.jdom.Element getLayout()
          This method returns the actual layout element associated with this layout manager.
protected  org.jdom.Element getLayout(org.jdom.Element startingElement, java.lang.String name)
          This method searches for and returns the field definition which is part of the layout for an object that matches the name passed in.
 java.lang.String getLayoutManagerName()
          This method returns the name of the layout manager.
 org.jdom.Element getLayoutRoot()
          Returns the layout manager's root element.
protected  int getLength(XmlEnterpriseObject xeo, java.lang.String fieldName)
          Convenience method that tells the layout manager implementation how many instances of a given repeatable field exist on the parent object.
protected  java.lang.String getTargetAppName()
          Returns the target application name associated to this layout manager.
protected  java.lang.Object getValueFromObject(XmlEnterpriseObject xeo, java.lang.String fieldName)
          Returns the value currently held in the parent object for the field passed in.
protected  java.lang.Object getValueFromObject(XmlEnterpriseObject xeo, java.lang.String fieldName, java.lang.Object[] parms, java.lang.Class[] parmTypes)
          Convenience method used by layout manager implementations to retrieve data from a repeating field (of any type) on a parent object.
protected  java.lang.Object getValueFromObject(XmlEnterpriseObject xeo, java.lang.String appName, java.lang.String fieldName)
          Convenience method used by layout manager implementations to retrieve data from a parent object for a particular application.
protected  java.lang.Object getValueFromObject(XmlEnterpriseObject xeo, java.lang.String appName, java.lang.String fieldName, java.lang.Object[] parms, java.lang.Class[] parmTypes)
          Convenience method used by layout manager implementations to retrieve data from a repeating field (of type Element or Attribute) on a parent object for a particular application.
 void init(java.lang.String layoutManagerName, org.jdom.Document layoutDoc)
          This is the default initialization method that can be used by child layout managers.
protected  java.lang.Object instantiate(java.lang.String className)
          Convenience method used by layout manager implementations to instantiate child objects that need to be built from the input passed to them and added to the parent object being built.
protected  boolean isDate(java.lang.String className)
          Determines if the class name passed in is one of the OpenEAI Date objects (Date or Datetime).
protected  boolean isRepeating(java.lang.Object xeo, java.lang.String fieldName)
          Convenience method that tells the layout manager implementation if the field specified is a repeating field on the object passed in.
protected  boolean isRequired(org.jdom.Element eField)
          Uses the field definition passed in to determine if a field is required.
 void setEnterpriseObjectsUri(java.lang.String uri)
          Sets the EnterpriseObjects document uri associated to this EnterpriseFields object.
protected  void setLayout(org.jdom.Element layout)
          This method sets the actual layout element associated with this layout manager.
 void setLayoutManagerName(java.lang.String name)
          This method sets the name associated to the layout manager.
protected  void setLayoutRoot(org.jdom.Element layout)
          This method sets the layout manager's root element.
protected  void setTargetAppName(java.lang.String appName)
          Sets the name of the target application for which an output is being built.
protected  void setVariableValue(java.lang.Object mObj, java.lang.String variableName, java.lang.Object value, java.lang.Class classType)
          Convenience method that sets a field on an object passed in to the value passed in by finding the appropriate setter method (by field name) on the object and invoking that method.
protected  void setVariableValue(java.lang.Object mObj, java.lang.String variableName, java.lang.Object value, java.lang.Class classType, int index)
          This method replaces the repeatable child object at a particular index with the value passed in.
 
Methods inherited from class org.openeai.OpenEaiObject
getAppName, getDebug, getFromAddr, 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
 

Field Detail

LIST

protected static final java.lang.String LIST
See Also:
Constant Field Values
Constructor Detail

EnterpriseLayoutManagerImpl

public EnterpriseLayoutManagerImpl()
Constructor

Method Detail

setTargetAppName

protected void setTargetAppName(java.lang.String appName)
Sets the name of the target application for which an output is being built. Since outputs can be built in two ways (using enterprise values and or using application specific values) this method sets the name of that target application if the method of serializing the object to an output is for a specific application.

This application name will be used to "reverse-translate" data from enterprise values to application values if translations/mappings exist.

Parameters:
appName - String the name of the application.
See Also:
EnterpriseTranslator, EnterpriseMapping

getTargetAppName

protected java.lang.String getTargetAppName()
Returns the target application name associated to this layout manager. This will be use to reverse-translate enterprise values to application specific values if translations/mappings exist.

Returns:
String the target application name
See Also:
EnterpriseTranslator, EnterpriseMapping

setLayoutRoot

protected final void setLayoutRoot(org.jdom.Element layout)
This method sets the layout manager's root element. This is the starting point for all other activity that is performed using the layout document. Generally, this is the EnterpriseObjects documents associated to an object.

Parameters:
layout - Element the root element of the XML document

getLayoutRoot

public final org.jdom.Element getLayoutRoot()
Returns the layout manager's root element.

Returns:
Element

setEnterpriseObjectsUri

public final void setEnterpriseObjectsUri(java.lang.String uri)
Sets the EnterpriseObjects document uri associated to this EnterpriseFields object. This document contains the rules that will be use to build the EnterpriseFields object.

Parameters:
uri - String URI to the EnterpriseObjects document. Can be file system or web uri.

getEnterpriseObjectsUri

public final java.lang.String getEnterpriseObjectsUri()
Returns the EnterpriseObjects document uri associated to this EnterpriseFields object. This document contains the rules that will be use to build the EnterpriseFields object.

Returns:
String URI to the EnterpriseObjects document. Can be file system or web uri.

setLayout

protected final void setLayout(org.jdom.Element layout)
This method sets the actual layout element associated with this layout manager. Generally, this is found in the EnterpriseObjects documents but it is up to the layout manager implementation to determine exactly where this is. It doesn't have to be in the EnterpriseObjects documents.

This is the element that provides the details regarding what the layout being used really is. It's the layout's definition.

Parameters:
layout - Element the layout element.

getLayout

protected final org.jdom.Element getLayout()
This method returns the actual layout element associated with this layout manager. Generally, this is found in the EnterpriseObjects documents but it is up to the layout manager implementation to determine exactly where this is. It doesn't have to be in the EnterpriseObjects documents.

This is the element that provides the details regarding what the layout being used really is. It's the layout's definition.

Returns:
Element the layout element.

getFieldLayout

protected final org.jdom.Element getFieldLayout(org.jdom.Element eField,
                                                java.lang.String name)
Returns the Layout Element associated to a particular field as specified in an application's deployment document. Note, this method assumes the layout is part of the Deployment document and is specified by the OpenEAI Deployment.dtd definition. It is not required that a layout be specified through this file but this method assumes that it is. It's is completely acceptable for layout manager implementations use some other layout document altogether to specify the exact details of a particular layout. The EnterpriseObject documents are still used though to provied the Object and Field Defintions.

Parameters:
eField - Element the Field XML Element contained within the EnterpriseObjects documents
name - String the layout name contained within the Layout Element in the EnterpriseObjects document
Returns:
Element the layout element associate to the field passed in.

setLayoutManagerName

public final void setLayoutManagerName(java.lang.String name)
This method sets the name associated to the layout manager.

Parameters:
name - String the layout manager name.

getLayoutManagerName

public final java.lang.String getLayoutManagerName()
This method returns the name of the layout manager.

Returns:
String the name of the layout manager.

init

public void init(java.lang.String layoutManagerName,
                 org.jdom.Document layoutDoc)
          throws EnterpriseLayoutException
This is the default initialization method that can be used by child layout managers. It basically goes through the EnterpriseObjects document and pulls all object definitions. Additionally, it recursively includes any external references to other EO documents that are included in the "IncludeList" element for the document passed to this method.

Parameters:
layoutManagerName - String the layout manager's name
layoutDoc - Document the layout document. Typically, this is the EnterpriseObjects document associated to the object that this layout manager is being configured for.
Throws:
EnterpriseLayoutException

getLayout

protected org.jdom.Element getLayout(org.jdom.Element startingElement,
                                     java.lang.String name)
                              throws EnterpriseLayoutException
This method searches for and returns the field definition which is part of the layout for an object that matches the name passed in.

Parameters:
startingElement - Element the element that is the starting point for the search. Typically, this is the root element of the EO document
name - String the name of the layout manager we're looking for. Typically, this will be the name of the object.
Returns:
Element the Element that corresponds to the object definition in the EO document.
Throws:
EnterpriseLayoutException

isRequired

protected boolean isRequired(org.jdom.Element eField)
                      throws EnterpriseLayoutException
Uses the field definition passed in to determine if a field is required. This information is part of the Format element associated to a field in the EnterpriseObjects documents.

Returns:
boolean true if the field is required, false if not.
Throws:
EnterpriseLayoutException - if the Field's Format element can't be found.

isRepeating

protected boolean isRepeating(java.lang.Object xeo,
                              java.lang.String fieldName)
                       throws EnterpriseLayoutException
Convenience method that tells the layout manager implementation if the field specified is a repeating field on the object passed in.

If a child object is a repeating object within a parent object, the "getter" method for that child object will return a java.util.List. This method inspects the return type of that getter method and checks to see if it's a java.util.List.

For example, the Address child object in the BasicPerson object is repeating. Therefore, the BasicPerson object has a "getAddress" method that returns a java.util.List of Address objects that exist in that BasicPerson. This method invokes that method and checks the class type (instanceof) the returned object. If it's a java.util.List it knows the Address is a repeating child on the BasicPerson. This will work for any XmlEnterpriseObject.

Parameters:
xeo - Object the object that's being queried
fieldName - String the name of the field being tested.
Returns:
boolean true if the field is a repeating field, false if not.
Throws:
EnterpriseLayoutException - if an error occurs executing the child object's getter method.

getLength

protected int getLength(XmlEnterpriseObject xeo,
                        java.lang.String fieldName)
                 throws EnterpriseLayoutException
Convenience method that tells the layout manager implementation how many instances of a given repeatable field exist on the parent object. This is useful in determining how many child objects need to be serialized when building an output from an object.

If a child object is a repeating object within a parent object, the "getter" method for that child object will return a java.util.List. This method invokes the getter method for the child object and returns the size of that List. If the List returned is null, zero will be returned.

For example, the Address child object in the BasicPerson object is repeating. Therefore, the BasicPerson object has a "getAddress" method that returns a java.util.List of Address objects that exist in that BasicPerson. This method invokes that method and returns the size of the returned object.

Parameters:
xeo - XmlEnterpriseObject the parent object being queried
fieldName - String the name of the child object being tested
Returns:
int the number of child objects
Throws:
EnterpriseLayoutException - if an error occurs executing the getter method for the particular field on the parent object passed in. An exception will also be thrown if the object being checked is not a repeating field (the object returned by the getter method is not a java.util.List.

instantiate

protected java.lang.Object instantiate(java.lang.String className)
Convenience method used by layout manager implementations to instantiate child objects that need to be built from the input passed to them and added to the parent object being built.

String class name of the object to instantiate.


getValueFromObject

protected java.lang.Object getValueFromObject(XmlEnterpriseObject xeo,
                                              java.lang.String appName,
                                              java.lang.String fieldName)
                                       throws EnterpriseLayoutException
Convenience method used by layout manager implementations to retrieve data from a parent object for a particular application. It uses the field namd passed in to build a "getter" method call on the Parent object passed in. If the field has translations/mappings associated to it, the value currently contained in the parent object will be converted to the application specific value associated to the application name passed in.

Parameters:
xeo - XmlEnterpriseObject the parent object being queried.
appName - String the name of the application used for the "reverse-translation" from enterprise value to application specific value.
Returns:
Object the value returned from the "getter" method call.
Throws:
EnterpriseLayoutException - if errors occur reverse-translating the enterprise value to an application specific value.

getValueFromObject

protected java.lang.Object getValueFromObject(XmlEnterpriseObject xeo,
                                              java.lang.String fieldName)
                                       throws EnterpriseLayoutException
Returns the value currently held in the parent object for the field passed in.

Parameters:
xeo - XmlEnterpriseObject the parent object
fieldName - String the name of the field that the getter method should be called for
Returns:
Object the value currently contained in the field
Throws:
EnterpriseLayoutException - if errors occur invoking the getter method on the field

getValueFromObject

protected java.lang.Object getValueFromObject(XmlEnterpriseObject xeo,
                                              java.lang.String appName,
                                              java.lang.String fieldName,
                                              java.lang.Object[] parms,
                                              java.lang.Class[] parmTypes)
                                       throws EnterpriseLayoutException
Convenience method used by layout manager implementations to retrieve data from a repeating field (of type Element or Attribute) on a parent object for a particular application. It uses the field namd passed in to build a "getter" method call on the Parent object passed in. It uses the "parms" passed in to determine which index to use when retrieving the data from the repeatable field. If the field has translations/mappings associated to it, the value currently contained in the repeatable field at the specified index in parent object will be converted to the application specific value associated to the application name passed in.

Parameters:
xeo - XmlEnterpriseObject the parent object being queried.
appName - String the name of the application used for the "reverse-translation" from enterprise value to application specific value.
fieldName - String the name of the repeatable field (of type Attribute or Element) from which to get the data
parms - Object[] the index from which to pull the repeatable child field
parmTypes - Class[] the data type of the index (Integer.TYPE)
Returns:
Object the value returned from the "getter" method call.
Throws:
EnterpriseLayoutException - if errors occur reverse-translating the enterprise value to an application specific value.

getValueFromObject

protected java.lang.Object getValueFromObject(XmlEnterpriseObject xeo,
                                              java.lang.String fieldName,
                                              java.lang.Object[] parms,
                                              java.lang.Class[] parmTypes)
                                       throws EnterpriseLayoutException
Convenience method used by layout manager implementations to retrieve data from a repeating field (of any type) on a parent object. It uses the field namd passed in to build a "getter" method call on the Parent object passed in. It uses the "parms" passed in to determine which index to use when retrieving the data from the repeatable field. If the field has translations/mappings associated to it, the value currently contained in the repeatable field at the specified index in parent object will be converted to the application specific value associated to the application name passed in.

Parameters:
xeo - XmlEnterpriseObject the parent object being queried.
fieldName - String the name of the repeatable field (of any type) from which to get the data
parms - Object[] the index from which to pull the repeatable child field
parmTypes - Class[] the data type of the index (Integer.TYPE)
Returns:
Object the value returned from the "getter" method call. This could be a String or an XmlEnterpriseObject depending on the type of child object.
Throws:
EnterpriseLayoutException - if errors occur reverse-translating the enterprise value to an application specific value.

setVariableValue

protected void setVariableValue(java.lang.Object mObj,
                                java.lang.String variableName,
                                java.lang.Object value,
                                java.lang.Class classType)
                         throws EnterpriseFieldException
Convenience method that sets a field on an object passed in to the value passed in by finding the appropriate setter method (by field name) on the object and invoking that method.

By invoking the setter method on the object passed in, all the rules that are specified in the EnterpriseFields object are invoked when that setter method is called.

Parameters:
mObj - Object the object on which the setter method is being invoked.
variableName - String the name of the field for which the setter method should be called
value - Object the value to pass to the setter method.
classType - Class the class type of variable being set
Throws:
EnterpriseFieldException
See Also:
EnterpriseFields, EnterpriseFormatter

setVariableValue

protected void setVariableValue(java.lang.Object mObj,
                                java.lang.String variableName,
                                java.lang.Object value,
                                java.lang.Class classType,
                                int index)
                         throws EnterpriseFieldException
This method replaces the repeatable child object at a particular index with the value passed in.

Parameters:
mObj - Object the object on which to call the setter method (the parent object).
variableName - String the name of the child object that's being set.
value - Object value the object being passed to the setter method.
classType - Class the type of class being passed to the setter (String or XmlEnterpriseObject)
index - int the index at which to replace the data
Throws:
EnterpriseFieldException - if errors occur calling the setter method.

isDate

protected boolean isDate(java.lang.String className)
Determines if the class name passed in is one of the OpenEAI Date objects (Date or Datetime).

Returns:
boolean


Copyright © 2002,2003 OpenEAI Software Foundation