Copyright @ 2002 SAP. All Rights Reserved.

com.sap.tc.complib.xml
Class Initializable

java.lang.Object
  |
  +--com.sap.tc.complib.xml.Initializable
Direct Known Subclasses:
com.sap.tc.complib.impl.ImportedEntityImpl

public abstract class Initializable
extends java.lang.Object

Abstract base class for classes that are able to initialize from a XML input stream. Provides some useful helper methods.


Field Summary
protected  java.lang.String _apiVersion
           
protected  java.util.List _attributes
           
protected  java.util.List _extensions
           
protected  boolean _initialized
           
protected  java.lang.String _schemaVersion
           
protected  java.lang.StringBuffer buffer
           
protected  boolean clearBuffer
          string buffer for collection of tag value parts
protected static int INIT
           
protected  boolean isEmpty
           
protected  int recoverMode
           
protected  java.lang.String recoverTagName
           
protected static int RECOVERY_MODE
           
protected static int ROOT
           
protected  int state
           
 
Constructor Summary
Initializable()
           
 
Method Summary
 java.lang.String _getAPIVersion()
           
 java.lang.String _getSchemaVersion()
           
 boolean _isInitialized()
           
 boolean _isSchemaAllowed()
           
 boolean _isSchemaAllowed(java.lang.String schemaVersion)
           
 void _setSchemaVersion(java.lang.String schemaVersion)
           
protected  void checkMandatoryAttribute(java.lang.String attrValue, java.lang.String attrName, java.lang.String parentTag)
          utility checking if an mandatory attribute is null
protected  void checkMandatoryAttributeNotEmpty(java.lang.String attrValue, java.lang.String attrName, java.lang.String parentTag)
          utility checking if an mandatory attribute is null or empty
protected  void checkPropertyNotEmptyOrNull(java.util.Collection propertyValue, java.lang.String propertyName, java.lang.String owner)
          utility method checking if a property is empty (Map) or null
protected  void checkPropertyNotEmptyOrNull(java.util.Map propertyValue, java.lang.String propertyName, java.lang.String owner)
          utility method checking if a property is empty (Collection) or null
protected  void checkPropertyNotEmptyOrNull(java.lang.String propertyValue, java.lang.String propertyName, java.lang.String owner)
          utility method checking if a property is empty (String) or null
protected  void checkPropertyNotNull(java.lang.Object propertyValue, java.lang.String propertyName, java.lang.String owner)
          utility method checking if a property is null
protected  boolean doSerialize(java.lang.String schemaVersion, java.lang.String minSchemaVersion)
           
protected  void dropTagValue()
          Reject the value of the tag.
protected  void endDocument()
           
protected abstract  boolean endTag(java.lang.String name)
           
protected  Attribute[] getAttributes()
           
protected  java.util.List getAttributes(org.xml.sax.Attributes attributes)
          Converts SAX attributes to an attribute array
protected  boolean getBooleanValue()
          Returns the boolean values of a tag.
protected  boolean getBooleanValue(java.lang.String stringValue, java.lang.String attrName, java.lang.String element)
          utility function converting a string false/true or yes/no into a boolean
protected  double getDoubleValue()
          getter for double values of tags. to be called in endTag event
protected  float getFloatValue()
          getter for float values of tags. to be called in endTag event
protected  java.lang.String getIllegalAttributeMessage(java.lang.String attrName, java.lang.String attrValue, java.lang.String tagName)
          utility returning message for exception for illegal atributes of XML tag
protected  int getIntegerValue()
          getter for integer values of tags. to be called in endTag event
protected  long getLongValue()
          getter for long values of tags. to be called in endTag event
protected  java.lang.String getMissingTagMessage(java.lang.String missingTag, java.lang.String parentTag)
          utility returning Exception message for missing mandatory tags
protected  java.lang.String getStringValue()
          getter for string values of tags. to be called in endTag event
protected  java.lang.String getStringValue(boolean trim)
          getter for string values of tags. parameter trim allows to determine, whether leading and trailing whitespace should be stripped. to be called in endTag event
protected  boolean isEmptyTag()
          returns true if the tag value is empty
protected  void removeAttribute(java.lang.String name)
           
protected  org.xml.sax.InputSource resolveEntity(java.lang.String publicId, java.lang.String systemId)
           
protected  void setAttribute(java.lang.String name, java.lang.String value)
           
protected  void startDocument()
           
protected abstract  void startTag(java.lang.String name, org.xml.sax.Attributes attributes)
           
protected  void tagValue(char[] chars, int start, int length)
          tag value event wrapper. since SAX splits consecutive lines of character input in multiple events, this method collect the parts. use one of the getter methods below (getString, getBoolean...) to access the content of a tag.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INIT

protected static final int INIT

RECOVERY_MODE

protected static final int RECOVERY_MODE

ROOT

protected static final int ROOT

state

protected int state

recoverTagName

protected java.lang.String recoverTagName

recoverMode

protected int recoverMode

_extensions

protected java.util.List _extensions

_attributes

protected java.util.List _attributes

_schemaVersion

protected java.lang.String _schemaVersion

_apiVersion

protected java.lang.String _apiVersion

_initialized

protected boolean _initialized

clearBuffer

protected boolean clearBuffer
string buffer for collection of tag value parts

isEmpty

protected boolean isEmpty

buffer

protected java.lang.StringBuffer buffer
Constructor Detail

Initializable

public Initializable()
Method Detail

tagValue

protected void tagValue(char[] chars,
                        int start,
                        int length)
tag value event wrapper. since SAX splits consecutive lines of character input in multiple events, this method collect the parts. use one of the getter methods below (getString, getBoolean...) to access the content of a tag.

isEmptyTag

protected boolean isEmptyTag()
returns true if the tag value is empty
Returns:
 

getStringValue

protected java.lang.String getStringValue()
getter for string values of tags. to be called in endTag event

getStringValue

protected java.lang.String getStringValue(boolean trim)
getter for string values of tags. parameter trim allows to determine, whether leading and trailing whitespace should be stripped. to be called in endTag event

getIntegerValue

protected int getIntegerValue()
getter for integer values of tags. to be called in endTag event

getLongValue

protected long getLongValue()
getter for long values of tags. to be called in endTag event

getFloatValue

protected float getFloatValue()
getter for float values of tags. to be called in endTag event

getDoubleValue

protected double getDoubleValue()
getter for double values of tags. to be called in endTag event

getBooleanValue

protected boolean getBooleanValue()
Returns the boolean values of a tag.

getAttributes

protected java.util.List getAttributes(org.xml.sax.Attributes attributes)
Converts SAX attributes to an attribute array
Parameters:
attributes - a list of SAX attributes
Returns:
an array of attributes

setAttribute

protected void setAttribute(java.lang.String name,
                            java.lang.String value)

removeAttribute

protected void removeAttribute(java.lang.String name)

getAttributes

protected Attribute[] getAttributes()

dropTagValue

protected void dropTagValue()
Reject the value of the tag.

getBooleanValue

protected boolean getBooleanValue(java.lang.String stringValue,
                                  java.lang.String attrName,
                                  java.lang.String element)
                           throws org.xml.sax.SAXException
utility function converting a string false/true or yes/no into a boolean
Throws:
org.xml.sax.SAXException - if conversion is not possible

checkMandatoryAttribute

protected void checkMandatoryAttribute(java.lang.String attrValue,
                                       java.lang.String attrName,
                                       java.lang.String parentTag)
                                throws org.xml.sax.SAXException
utility checking if an mandatory attribute is null
Throws:
org.xml.sax.SAXException - if null

checkMandatoryAttributeNotEmpty

protected void checkMandatoryAttributeNotEmpty(java.lang.String attrValue,
                                               java.lang.String attrName,
                                               java.lang.String parentTag)
                                        throws org.xml.sax.SAXException
utility checking if an mandatory attribute is null or empty
Throws:
org.xml.sax.SAXException - if conversion is not possible

getMissingTagMessage

protected java.lang.String getMissingTagMessage(java.lang.String missingTag,
                                                java.lang.String parentTag)
utility returning Exception message for missing mandatory tags

getIllegalAttributeMessage

protected java.lang.String getIllegalAttributeMessage(java.lang.String attrName,
                                                      java.lang.String attrValue,
                                                      java.lang.String tagName)
utility returning message for exception for illegal atributes of XML tag

checkPropertyNotEmptyOrNull

protected void checkPropertyNotEmptyOrNull(java.lang.String propertyValue,
                                           java.lang.String propertyName,
                                           java.lang.String owner)
                                    throws MissingElementException
utility method checking if a property is empty (String) or null
Throws:
ValidationException - if conversion is not possible

checkPropertyNotNull

protected void checkPropertyNotNull(java.lang.Object propertyValue,
                                    java.lang.String propertyName,
                                    java.lang.String owner)
                             throws MissingElementException
utility method checking if a property is null
Throws:
ValidationException - if conversion is not possible

checkPropertyNotEmptyOrNull

protected void checkPropertyNotEmptyOrNull(java.util.Map propertyValue,
                                           java.lang.String propertyName,
                                           java.lang.String owner)
                                    throws ValidationException
utility method checking if a property is empty (Collection) or null
Throws:
ValidationException - if conversion is not possible

checkPropertyNotEmptyOrNull

protected void checkPropertyNotEmptyOrNull(java.util.Collection propertyValue,
                                           java.lang.String propertyName,
                                           java.lang.String owner)
                                    throws ValidationException
utility method checking if a property is empty (Map) or null
Throws:
ValidationException - if conversion is not possible

doSerialize

protected boolean doSerialize(java.lang.String schemaVersion,
                              java.lang.String minSchemaVersion)

_isSchemaAllowed

public boolean _isSchemaAllowed()
Returns:
 

_isSchemaAllowed

public boolean _isSchemaAllowed(java.lang.String schemaVersion)
Parameters:
formatVersion -  
Throws:
InvalidFileFormatException -  

_getSchemaVersion

public java.lang.String _getSchemaVersion()
Returns:
 

_setSchemaVersion

public void _setSchemaVersion(java.lang.String schemaVersion)

_getAPIVersion

public java.lang.String _getAPIVersion()

_isInitialized

public boolean _isInitialized()

startDocument

protected void startDocument()

endDocument

protected void endDocument()

startTag

protected abstract void startTag(java.lang.String name,
                                 org.xml.sax.Attributes attributes)
                          throws org.xml.sax.SAXException

endTag

protected abstract boolean endTag(java.lang.String name)
                           throws org.xml.sax.SAXException

resolveEntity

protected org.xml.sax.InputSource resolveEntity(java.lang.String publicId,
                                                java.lang.String systemId)
                                         throws org.xml.sax.SAXException

Copyright @ 2002 SAP. All Rights Reserved.