Package org.jfree.xml.util
Class AbstractModelReader
- java.lang.Object
-
- org.jfree.xml.util.AbstractModelReader
-
- Direct Known Subclasses:
DefaultModelReader,ObjectFactoryLoader
public abstract class AbstractModelReader extends java.lang.ObjectLoads the class model from an previously written xml file set. This class provides abstract methods which get called during the parsing (similiar to the SAX parsing, but slightly easier to code). This will need a rewrite in the future, when the structure is finished.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classAbstractModelReader.SAXModelHandlerThe SAX2 callback implementation used for parsing the model xml files.
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String[]closeCommentThe close comments.private CommentHandlercommentHandlerThe comment handler.private static intCONSTRUCTOR_STATEThe 'CONSTRUCTOR' state.private static intIGNORE_OBJECTThe 'IGNORE_OBJECT' state.private static intIN_OBJECTThe 'IN_OBJECT' state.private static intMAPPING_STATEThe 'MAPPING' state.private java.lang.String[]openCommentThe open comments.private static intSTATE_STARTThe 'START' state.
-
Constructor Summary
Constructors Constructor Description AbstractModelReader()Default Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidendIncludeHandling()End handling an include.protected abstract voidendMultiplexMapping()Finializes the multiplexer mapping.protected abstract voidendObjectDefinition()Finializes the object definition.protected voidendRootDocument()End the root document.protected java.lang.String[]getCloseComment()Returns the close comment.protected CommentHandlergetCommentHandler()Returns the comment handler.protected java.lang.String[]getOpenComment()Returns the open comment.protected abstract voidhandleAttributeDefinition(java.lang.String name, java.lang.String attribName, java.lang.String handlerClass)Handles an attribute definition.protected abstract voidhandleConstructorDefinition(java.lang.String propertyName, java.lang.String parameterClass)Handles a constructor definition.protected abstract voidhandleElementDefinition(java.lang.String name, java.lang.String element)Handles an element definition.protected voidhandleIgnoredProperty(java.lang.String name)Callback method for ignored properties.protected abstract voidhandleLookupDefinition(java.lang.String name, java.lang.String lookupKey)Handles an lookup definition.protected abstract booleanhandleManualMapping(java.lang.String className, java.lang.String readHandler, java.lang.String writeHandler)Handles a manual mapping definition.protected abstract voidhandleMultiplexMapping(java.lang.String typeName, java.lang.String className)Defines an entry for the multiplex mapping.protected java.lang.ClassloadClass(java.lang.String className)Loads the given class, and ignores all exceptions which may occur during the loading.protected voidparseXml(java.net.URL resource)Parses an XML document at the given URL.protected voidparseXmlDocument(java.net.URL resource, boolean isInclude)Parses the given specification and loads all includes specified in the files.protected voidsetCloseComment(java.lang.String[] closeComment)Sets the close comment.protected voidsetOpenComment(java.lang.String[] openComment)Sets the open comment.protected voidstartIncludeHandling(java.net.URL resource)Start handling an include.protected abstract voidstartMultiplexMapping(java.lang.String className, java.lang.String typeAttr)Starts a multiplex mapping.protected abstract booleanstartObjectDefinition(java.lang.String className, java.lang.String register, boolean ignored)Starts a object definition.protected voidstartRootDocument()Start the root document.
-
-
-
Field Detail
-
STATE_START
private static final int STATE_START
The 'START' state.- See Also:
- Constant Field Values
-
IN_OBJECT
private static final int IN_OBJECT
The 'IN_OBJECT' state.- See Also:
- Constant Field Values
-
IGNORE_OBJECT
private static final int IGNORE_OBJECT
The 'IGNORE_OBJECT' state.- See Also:
- Constant Field Values
-
MAPPING_STATE
private static final int MAPPING_STATE
The 'MAPPING' state.- See Also:
- Constant Field Values
-
CONSTRUCTOR_STATE
private static final int CONSTRUCTOR_STATE
The 'CONSTRUCTOR' state.- See Also:
- Constant Field Values
-
commentHandler
private CommentHandler commentHandler
The comment handler.
-
closeComment
private java.lang.String[] closeComment
The close comments.
-
openComment
private java.lang.String[] openComment
The open comments.
-
-
Method Detail
-
getCommentHandler
protected CommentHandler getCommentHandler()
Returns the comment handler.- Returns:
- The comment handler.
-
getCloseComment
protected java.lang.String[] getCloseComment()
Returns the close comment.- Returns:
- The close comment.
-
getOpenComment
protected java.lang.String[] getOpenComment()
Returns the open comment.- Returns:
- The open comment.
-
setCloseComment
protected void setCloseComment(java.lang.String[] closeComment)
Sets the close comment.- Parameters:
closeComment- the close comment.
-
setOpenComment
protected void setOpenComment(java.lang.String[] openComment)
Sets the open comment.- Parameters:
openComment- the open comment.
-
parseXml
protected void parseXml(java.net.URL resource) throws ObjectDescriptionExceptionParses an XML document at the given URL.- Parameters:
resource- the document URL.- Throws:
ObjectDescriptionException- ??
-
parseXmlDocument
protected void parseXmlDocument(java.net.URL resource, boolean isInclude) throws ObjectDescriptionExceptionParses the given specification and loads all includes specified in the files. This implementation does not check for loops in the include files.- Parameters:
resource- the url of the xml specification.isInclude- an include?- Throws:
ObjectDescriptionException- if an error occured which prevented the loading of the specifications.
-
startRootDocument
protected void startRootDocument()
Start the root document.
-
endRootDocument
protected void endRootDocument()
End the root document.
-
startIncludeHandling
protected void startIncludeHandling(java.net.URL resource)
Start handling an include.- Parameters:
resource- the URL.
-
endIncludeHandling
protected void endIncludeHandling()
End handling an include.
-
handleIgnoredProperty
protected void handleIgnoredProperty(java.lang.String name)
Callback method for ignored properties. Such properties get marked so that the information regarding these properties won't get lost.- Parameters:
name- the name of the ignored property.
-
handleManualMapping
protected abstract boolean handleManualMapping(java.lang.String className, java.lang.String readHandler, java.lang.String writeHandler) throws ObjectDescriptionExceptionHandles a manual mapping definition. The manual mapping maps specific read and write handlers to a given base class. Manual mappings always override any other definition.- Parameters:
className- the base class namereadHandler- the class name of the read handlerwriteHandler- the class name of the write handler- Returns:
- true, if the mapping was accepted, false otherwise.
- Throws:
ObjectDescriptionException- if an unexpected error occured.
-
startObjectDefinition
protected abstract boolean startObjectDefinition(java.lang.String className, java.lang.String register, boolean ignored) throws ObjectDescriptionExceptionStarts a object definition. The object definition collects all properties of an bean-class and defines, which constructor should be used when creating the class.- Parameters:
className- the class name of the defined objectregister- the (optional) register name, to lookup and reference the object later.ignored- ??.- Returns:
- true, if the definition was accepted, false otherwise.
- Throws:
ObjectDescriptionException- if an unexpected error occured.
-
handleAttributeDefinition
protected abstract void handleAttributeDefinition(java.lang.String name, java.lang.String attribName, java.lang.String handlerClass) throws ObjectDescriptionExceptionHandles an attribute definition. This method gets called after the object definition was started. The method will be called for every defined attribute property.- Parameters:
name- the name of the propertyattribName- the xml-attribute name to use later.handlerClass- the attribute handler class.- Throws:
ObjectDescriptionException- if an error occured.
-
handleElementDefinition
protected abstract void handleElementDefinition(java.lang.String name, java.lang.String element) throws ObjectDescriptionExceptionHandles an element definition. This method gets called after the object definition was started. The method will be called for every defined element property. Element properties are used to describe complex objects.- Parameters:
name- the name of the propertyelement- the xml-tag name for the child element.- Throws:
ObjectDescriptionException- if an error occurs.
-
handleLookupDefinition
protected abstract void handleLookupDefinition(java.lang.String name, java.lang.String lookupKey) throws ObjectDescriptionExceptionHandles an lookup definition. This method gets called after the object definition was started. The method will be called for every defined lookup property. Lookup properties reference previously created object using the object's registry name.- Parameters:
name- the property name of the base objectlookupKey- the register key of the referenced object- Throws:
ObjectDescriptionException- if an error occured.
-
endObjectDefinition
protected abstract void endObjectDefinition() throws ObjectDescriptionExceptionFinializes the object definition.- Throws:
ObjectDescriptionException- if an error occures.
-
startMultiplexMapping
protected abstract void startMultiplexMapping(java.lang.String className, java.lang.String typeAttr)Starts a multiplex mapping. Multiplex mappings are used to define polymorphic argument handlers. The mapper will collect all derived classes of the given base class and will select the corresponding mapping based on the given type attribute.- Parameters:
className- the base class nametypeAttr- the xml-attribute name containing the mapping key
-
handleMultiplexMapping
protected abstract void handleMultiplexMapping(java.lang.String typeName, java.lang.String className) throws ObjectDescriptionExceptionDefines an entry for the multiplex mapping. The new entry will be activated when the base mappers type attribute contains thistypenameand will resolve to the handler for the given classname.- Parameters:
typeName- the type value for this mapping.className- the class name to which this mapping resolves.- Throws:
ObjectDescriptionException- if an error occurs.
-
endMultiplexMapping
protected abstract void endMultiplexMapping() throws ObjectDescriptionExceptionFinializes the multiplexer mapping.- Throws:
ObjectDescriptionException- if an error occurs.
-
handleConstructorDefinition
protected abstract void handleConstructorDefinition(java.lang.String propertyName, java.lang.String parameterClass) throws ObjectDescriptionExceptionHandles a constructor definition. Only one constructor can be defined for a certain object type. The constructor will be filled using the given properties.- Parameters:
propertyName- the property name of the referenced local propertyparameterClass- the parameter class for the parameter.- Throws:
ObjectDescriptionException- if an error occured.
-
loadClass
protected java.lang.Class loadClass(java.lang.String className)
Loads the given class, and ignores all exceptions which may occur during the loading. If the class was invalid, null is returned instead.- Parameters:
className- the name of the class to be loaded.- Returns:
- the class or null.
-
-