org.openeai.layouts
Class EnterpriseLayoutManagerImpl


java.lang.Object

  |

  +--org.openeai.OpenEaiObject

        |

        +--org.openeai.layouts.EnterpriseLayoutManagerImpl

Direct Known Subclasses:
ComplexResultSetLayout, ExtractLayout, ResultSetLayout, SpCallsLayout, XmlLayout, XpathLayout

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 beta2 - 28 January 2003
Author:
Tod Jackson (tod@openeai.org), Steve Wheat (steve@openeai.org)

Field Summary
 
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
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

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.

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.


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.


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.


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.


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.

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.


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.

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.

Returns:
Element the Element that corresponds to the object definition in the EO document.
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.

All XmlEnterpriseObject objects have a "getLength" method associated to each field that is repeating. This is how this method determines if the field is repeating. By looking for that method on the object passed in.

For example, the Address child object in the BasicPerson object is repeating. Therefore, the BasicPerson object has a "getAddressLength" method that returns the number of Address object that exist in that BasicPerson. This method looks for that method and if it exists it knows the Address is a repeating child on the BasicPerson. This will work for any XmlEnterpriseObject.

Returns:
boolean true if the field is a repeating field, false if not.
Throws:
EnterpriseLayoutException - if an error occurs determining if the field is a repeating field.

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.

All XmlEnterpriseObject objects have a "getLength" method associated to each field that is repeating. This is how this method determines how many instances of the field exist. By executing that method on the object passed in.

For example, the Address child object in the BasicPerson object is repeating. Therefore, the BasicPerson object has a "getAddressLength" method that returns the number of Address object that exist in that BasicPerson. This method executes that getAddressLength method on the BasicPerson object passed in to determine how many Addresses exist in the BasicPerson object. This will work for any XmlEnterpriseObject.

Returns:
int the number of child objects
Throws:
EnterpriseLayoutException - if an error occurs executing the getLength method for the particular field on the parent object passed in.

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.

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.

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.

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.

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.

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.

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, OpenEAI Software Foundation