|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbiz.c24.io.api.presentation.Source
biz.c24.io.api.presentation.XMLSource
public class XMLSource
A source for generating data objects from XML.
A common usage of this class would be:
FileInputStream in = new FileInputStream("myfile.xml"); // note: stream clean up code has been ommited for clarity XMLSource src = new XMLSource(in); ComplexDataObject myObj = src.readObject(myElement); // where my element is the element you are expecting to parse
Note that this implementation is not synchronized. If multiple threads use an instance concurrently, it must be synchronized externally.
todo Revise this and possible super class for sypport the SYSTEM_ID!!!!
,
Serialized FormField Summary | |
---|---|
static String |
DEFAULT_LOG_NAME
Deprecated. Use SAXSource.DEFAULT_LOG_NAME instead. |
Constructor Summary | |
---|---|
XMLSource()
Constructs a new instance. |
|
XMLSource(InputStream stream)
Constructs a new instance which will read from stream . |
|
XMLSource(Reader reader)
Constructs a new instance which will read from reader . |
|
XMLSource(XMLSource clone)
Constructs a new instance cloned from clone . |
Method Summary | |
---|---|
void |
addAnyMapping(Element element)
Deprecated. Use getWrappedSource() .SAXSource.registerRemoteComponent(biz.c24.io.api.data.DataComponent) instead. |
Object |
clone()
|
File |
getRootDir()
Deprecated. Use equivalent method on getWrappedSource() instead. |
SAXSource |
getWrappedSource()
Returns the wrapped SAX source on which this source is based. |
String |
getXmlReaderClassName()
Returns the class name of the XMLReader that should be used. |
boolean |
isContinueAfterFatalError()
Returns whether the parser will continue processing after encountering a fatal error. |
boolean |
isDynamicValidationEnabled()
Returns whether the parser will validate the document only if a grammar is specified. |
boolean |
isExternalGeneralEntities()
Returns whether the parser will include external general (text) entities. |
boolean |
isExternalParameterEntities()
Returns whether the parser will include external parameter entities and the external DTD subset. |
boolean |
isLoadDTDGrammer()
Returns whether the parser will load the DTD and use it to add default attributes and set attribute types when parsing. |
boolean |
isLoadExternalDTD()
Returns whether the parser will load the DTD and use it to add default attributes and set attribute types when parsing. |
boolean |
isSchemaFullCheckingEnabled()
Gets whether the parser will carry out full schema grammar constraint checking, including checking which may be time-consuming or memory intensive. |
boolean |
isSchemaValidationEnabled()
Gets whether the parser will validate the schema as well as the instance document. |
boolean |
isStrictNamespaces()
Deprecated. Use equivalent method on getWrappedSource() instead. |
boolean |
isValidationEnabled()
Returns whether the parser is reporting all validity errors; if true, all external entities will be read. |
boolean |
isWarnOnDuplicateAttDef()
Returns whether the parser will warn on duplicate attribute declarations. |
boolean |
isWarnOnUndeclaredElemDef()
Returns whether the parser will warn if elements referenced in a content model are not declared. |
void |
readObject(ComplexDataObject object)
Unsupported operation, use readObject(Element) instead. |
ComplexDataObject |
readObject(Element element)
Reads an object from the the reader or input stream that has been set. |
void |
removeAnyMapping(Element element)
Deprecated. Use getWrappedSource() .SAXSource.unregisterRemoteComponent(biz.c24.io.api.data.DataComponent) instead. |
void |
setContinueAfterFatalError(boolean continueAfterFatalError)
Sets whether the parser will continue processing after encountering a fatal error. |
void |
setDynamicValidationEnabled(boolean dynamicValidationEnabled)
Sets whether the parser will validate the document only if a grammar is specified. |
void |
setExternalGeneralEntities(boolean externalGeneralEntities)
Sets whether the parser will include external general (text) entities. |
void |
setExternalParameterEntities(boolean externalParameterEntities)
Sets whether the parser will include external parameter entities and the external DTD subset. |
void |
setInputStream(InputStream stream,
URI systemId)
Sets the input stream and system ID (optional operation). |
void |
setLoadDTDGrammer(boolean loadDTDGrammer)
Sets whether the parser will load the DTD and use it to add default attributes and set attribute types when parsing. |
void |
setLoadExternalDTD(boolean loadExternalDTD)
Sets whether the parser will load the external DTD. |
void |
setReader(Reader reader,
URI systemId)
Sets the reader (optional operation). |
void |
setRootDir(File rootDir)
Deprecated. Use equivalent method on getWrappedSource() instead. |
void |
setSchemaFullCheckingEnabled(boolean schemaFullCheckingEnabled)
Sets whether the parser will carry out full schema grammar constraint checking, including checking which may be time-consuming or memory intensive. |
void |
setSchemaValidationEnabled(boolean schemaValidationEnabled)
Sets whether the parser will validate the schema as well as the instance document. |
void |
setStrictNamespaces(boolean strictNamespaces)
Deprecated. Use equivalent method on getWrappedSource() instead. |
void |
setValidationEnabled(boolean validationEnabled)
Sets whether the parser is reporting all validity errors; if true, all external entities will be read. |
void |
setWarnOnDuplicateAttDef(boolean warnOnDuplicateAttDef)
Sets whether the parser will warn on duplicate attribute declarations. |
void |
setWarnOnUndeclaredElemDef(boolean warnOnUndeclaredElemDef)
Sets whether the parser will warn if elements referenced in a content model are not declared. |
void |
setXmlReaderClassName(String xmlReaderClassName)
Sets the class name of the XMLReader that should be used. |
Methods inherited from class biz.c24.io.api.presentation.Source |
---|
checkInit, getEncoding, getInputStream, getMarkableInputStream, getParseListener, getReader, getSystemId, reader, ready, setEncoding, setInputStream, setParseListener, setReader, setSystemId, stream |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String DEFAULT_LOG_NAME
SAXSource.DEFAULT_LOG_NAME
instead.
Constructor Detail |
---|
public XMLSource()
public XMLSource(XMLSource clone)
clone
.
clone
- The instance to clone.public XMLSource(Reader reader)
reader
.
reader
- The reader to read the XML data from.public XMLSource(InputStream stream)
stream
.
stream
- The stream to read the XML data from.Method Detail |
---|
public void readObject(ComplexDataObject object) throws IOException
readObject(Element)
instead.
XML instance documents often consist of a root element whose name is different from it's type or which use the
xsi:type attribute. In both these cases the object which is to be produced by the parse process may not be
compatible with that which is passed in. A pointer to the root element is required so that the correct instance
can be created, populated and returned, it is therefore neccesary to use the alternative readObject
method.
readObject
in class Source
object
- The object into which the input data should be parsed.
IOException
- If the complete object could not be read for any reason.public ComplexDataObject readObject(Element element) throws IOException
If element == null
, a new object will be created on the fly from the XML data, in a similar fashion to a DOM.
In this case, logging output will be sent to SAXSource.DEFAULT_LOG_NAME
.
readObject
in class Source
element
- The element declaration to which the input data is expected to adhere.
IOException
- If the complete object could not be read for any reason.
IllegalArgumentException
- If neither a reader nor an input stream has been set.public SAXSource getWrappedSource()
The wrapped source provides access to additional configuration properties.
public File getRootDir()
getWrappedSource()
instead.
public void setRootDir(File rootDir)
getWrappedSource()
instead.
rootDir
- The new value.public String getXmlReaderClassName()
XMLReader
that should be used.
public void setXmlReaderClassName(String xmlReaderClassName)
XMLReader
that should be used.
xmlReaderClassName
- The new value.public boolean isValidationEnabled()
public void setValidationEnabled(boolean validationEnabled)
validationEnabled
- The new value.public boolean isSchemaValidationEnabled()
public void setSchemaValidationEnabled(boolean schemaValidationEnabled)
schemaValidationEnabled
- The new value.public boolean isSchemaFullCheckingEnabled()
public void setSchemaFullCheckingEnabled(boolean schemaFullCheckingEnabled)
schemaFullCheckingEnabled
- The new value.public boolean isDynamicValidationEnabled()
public void setDynamicValidationEnabled(boolean dynamicValidationEnabled)
dynamicValidationEnabled
- The new value.public boolean isExternalGeneralEntities()
public void setExternalGeneralEntities(boolean externalGeneralEntities)
externalGeneralEntities
- The new value.public boolean isExternalParameterEntities()
public void setExternalParameterEntities(boolean externalParameterEntities)
externalParameterEntities
- The new value.public boolean isWarnOnDuplicateAttDef()
public void setWarnOnDuplicateAttDef(boolean warnOnDuplicateAttDef)
warnOnDuplicateAttDef
- The new value.public boolean isWarnOnUndeclaredElemDef()
public void setWarnOnUndeclaredElemDef(boolean warnOnUndeclaredElemDef)
warnOnUndeclaredElemDef
- The new value.public boolean isContinueAfterFatalError()
public void setContinueAfterFatalError(boolean continueAfterFatalError)
continueAfterFatalError
- The new value.public boolean isLoadDTDGrammer()
public void setLoadDTDGrammer(boolean loadDTDGrammer)
loadDTDGrammer
- The new value.public boolean isLoadExternalDTD()
public void setLoadExternalDTD(boolean loadExternalDTD)
loadExternalDTD
- The new value.public boolean isStrictNamespaces()
getWrappedSource()
instead.
readObject(biz.c24.io.api.data.Element)
method will be accepted.
public void setStrictNamespaces(boolean strictNamespaces)
getWrappedSource()
instead.
readObject(biz.c24.io.api.data.Element)
method will be accepted.
strictNamespaces
- The new value.public void addAnyMapping(Element element)
getWrappedSource()
.SAXSource.registerRemoteComponent(biz.c24.io.api.data.DataComponent)
instead.
This method provides the parser with possible elements which can be parsed against e.g. those that might appear in place of an 'any'
or as part of a model which is loaded without a defining element declaration, i.e. as a result of a call to
readObject(biz.c24.io.api.data.Element)
with a null
argument.
element
- The element to register.public void removeAnyMapping(Element element)
getWrappedSource()
.SAXSource.unregisterRemoteComponent(biz.c24.io.api.data.DataComponent)
instead.
element
- The element to unregister.public void setReader(Reader reader, URI systemId)
Source
setReader
in class Source
reader
- The new value.systemId
- The system ID identifying the reader.public void setInputStream(InputStream stream, URI systemId)
Source
setInputStream
in class Source
stream
- The new value.systemId
- The system ID identifying the stream.public Object clone()
clone
in class Source
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |