org.openadaptor.dmx.converter
Class DMXTagHandler

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by org.openadaptor.util.sax.AbstractHierarchicalElementHandler
          extended by org.openadaptor.dmx.converter.DMXTagHandler
All Implemented Interfaces:
HierarchicalElementHandler, org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler
Direct Known Subclasses:
DMXAttributeHandler, DMXCardinalityHandler, DMXClassHandler, DMXClassResultingTagHandler, DMXContentHandler, DMXDatatypeHandler, DMXDocumentationHandler, DMXEnumerationHandler, DMXHeaderHandler, DMXMetamodelHandler, DMXMethodHandler, DMXModelHandler, DMXModuleHandler, DMXParameterHandler, DMXRelationshipHandler, DMXRelationshipPartHandler, DMXTypeHandler, DMXValueHandler, DMXValueResultHandler

public abstract class DMXTagHandler
extends AbstractHierarchicalElementHandler

This class is the abstract superclass for all DMX element handlers.

It provides common behavior and initializes the link to the DMX handler factory.

It also gives a single access point to the class registry and standard exception raising for unknown or misplaced tags.

Version:
1.0
Author:
Manfred Duchrow

Constructor Summary
DMXTagHandler()
           
 
Method Summary
 MOTypeRegistry getTypeRegistry()
          Returns the class registry, where all known classes are stored.
 void handleSubResult(java.lang.String subTagName, java.lang.Object resultObject)
          This method throws an exception for any sub result.
 MOAttribute newAttribute()
          Creates and returns a new empty attribute object.
 MOClass newClass()
          Creates and returns a new empty class object.
 MOType newType(java.lang.String type)
          Creates a new empty type object.
protected  long stringToInteger(java.lang.String aString)
          Convert a given string to an integer.
 void tagViolationException(java.lang.String mainTag, java.lang.String subTag)
          Throws the exception for invalid tags iside onother tag.
 
Methods inherited from class org.openadaptor.util.sax.AbstractHierarchicalElementHandler
activate, endElement, getController, getResult, reactivate, setController, startElement, tagName
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
characters, endDocument, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.xml.sax.ContentHandler
characters, endDocument, endPrefixMapping, ignorableWhitespace, processingInstruction, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping
 

Constructor Detail

DMXTagHandler

public DMXTagHandler()
Method Detail

getTypeRegistry

public MOTypeRegistry getTypeRegistry()
Returns the class registry, where all known classes are stored.
New classes that are created by reading in a new DMX source should be added to this registry to accomplish class identity.

Returns:
The pre-initialized registry for all classes.
See Also:
MOTypeRegistry

tagViolationException

public void tagViolationException(java.lang.String mainTag,
                                  java.lang.String subTag)
                           throws DMXViolationException
Throws the exception for invalid tags iside onother tag. This is a standard exception, that should be used by all subclasses, if they detect a sub tag which they don't know.

Parameters:
mainTag - The tag of the tag handler, where the error occured
subTag - The tag which is not valid inside the mainTag
Throws:
DMXViolationException

handleSubResult

public void handleSubResult(java.lang.String subTagName,
                            java.lang.Object resultObject)
                     throws DMXException
This method throws an exception for any sub result.
This is a convenient implementation for subclasses which handle empty tags. Tag handler subclasses that allow any sub elements, have to override this method !

Specified by:
handleSubResult in class AbstractHierarchicalElementHandler
Parameters:
subTagName - The tag name of the sub element
resultObject - The result of the interpretation of the sub element
Throws:
DMXViolationException - An element was found inside another element, where it is not valid.
DMXException
See Also:
AbstractHierarchicalElementHandler.getResult()

stringToInteger

protected long stringToInteger(java.lang.String aString)
Convert a given string to an integer.
Returns the integer value of the string or 0, if an exception occured. Trailing decimal digits are cut !

Parameters:
aString - The string representation of the integer value.
Returns:
The integer value of the given string or 0
See Also:
Long.parseLong(java.lang.String, int)

newClass

public MOClass newClass()
Creates and returns a new empty class object.

Returns:
A new empty class object.

newAttribute

public MOAttribute newAttribute()
Creates and returns a new empty attribute object.

Returns:
A new empty attribute object.

newType

public MOType newType(java.lang.String type)
Creates a new empty type object.
Depending on the given parameter the result object can be either a MOAtomic, MOAlias or MOCollection.

Parameters:
type - The type of the new type ( atomic | alias | collection )
Returns:
A new empty type object.
See Also:
newClass()