|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.deduced.xml.XmlModelEncoder
public class XmlModelEncoder
XmlPropertyEncoder
extract the list of instances and the list of types used to fetch them, link those instances to the actual data
The readability enhanced flag can be used to include additional information in the created XML document to make it more human readable ( includes the collection type names and the property instance names ).
This encoder supports internal references, external references and object inheritance
Nested Class Summary | |
---|---|
private static class |
XmlModelEncoder.PackageSubObjectList
Object that holds a package and all its types and sub packages |
private static class |
XmlModelEncoder.ReferenceCollection
Object representing a referenced collection |
private static class |
XmlModelEncoder.TypeInstanceList
Object holding a property type and its instance list |
Field Summary | |
---|---|
private java.util.Map<java.lang.Object,PropertyCollection<?,?>> |
collectionByReferenceMap
map of all the properties that reference other collections |
private java.util.Map<java.lang.Object,PropertyCollection<?,?>> |
collectionByValueMap
map of all the properties that are contained by value |
private java.util.Map<java.lang.Object,PropertyCollection<?,?>> |
collectionMap
map of all the property collections decoded in the XML file by their unique ID |
private org.w3c.dom.Document |
document
XML document used to generate the XML Structure |
private java.util.Map<java.lang.Object,PropertyCollection<?,?>> |
instanceMap
map of all the instances encoded in the XML file by their unique ID |
private boolean |
isReadabilityEnhanced
flag used to enhance readability in the generated XML by adding names in instances and types |
private static java.util.logging.Logger |
LOGGER
Logger |
private PropertyCollection<?,?> |
modelLayer
model layer used to create references |
private NameReferenceFinder |
nameReferenceFinder
name reference finder used to find external references names |
private java.io.OutputStream |
outStream
the output stream that will receive the XML content |
private org.w3c.dom.Element |
referenceListElement
root reference list XML element |
private PropertyCollection<?,?> |
rootCollection
root collection that will be read from the XML file |
private org.w3c.dom.Element |
rootElement
root XML element |
private java.util.IdentityHashMap<PropertyCollection<?,?>,XmlModelEncoder.PackageSubObjectList> |
schemaRootPackageMap
root package read in the XML file |
private org.w3c.dom.Element |
typeListElement
root type list XML element |
private java.util.Map<java.lang.Object,XmlModelEncoder.TypeInstanceList> |
typeMap
map of all the types encoded in the XML file by their unique ID |
private org.w3c.dom.Element |
valueListElement
root value list XML element |
Constructor Summary | |
---|---|
XmlModelEncoder()
constructor |
Method Summary | |
---|---|
private void |
addAllInstances(PropertyCollection<?,?> collection)
add All Instances of a property collection to the object maps |
private void |
addInstance(PropertyCollection<?,?> instance)
add Instance to the object map |
private void |
addObjectToReferenceMap(PropertyCollection<?,?> collection,
java.lang.Object uniqueID)
add Object To Value Map |
private void |
addObjectToRootMap(PropertyCollection<?,?> collection,
java.lang.Object uniqueID)
add Object To Value Map |
private void |
addObjectToValueMap(PropertyCollection<?,?> collection,
java.lang.Object uniqueID)
add Object To Value Map |
private XmlModelEncoder.TypeInstanceList |
addPropertyType(PropertyCollection<?,?> ownerType)
add Property Type to the object map |
private void |
addReferenceMap(java.util.Map<java.lang.String,XmlModelEncoder.ReferenceCollection> rootMap,
PropertyCollection<?,?> collection)
add a Reference to the reference Map |
private void |
buildObjectMap(PropertyCollection<?,?> collection)
build a map of all the property collections linked to the specified collection. |
private static PropertyCollection<?,?> |
buildPackageList(java.util.List<PropertyCollection<?,?>> packageList,
PropertyCollection<?,?> ownerType)
build a list that contains all the packages in the hierarchy of the specified type |
private void |
cleanupTemporaryObjects()
cleanup Temporary Objects |
private void |
createCollectionDocument(org.w3c.dom.Element parentElement,
PropertyCollection<?,?> collection,
java.lang.Object uniqueID)
create Collection DOM element |
protected static org.w3c.dom.Document |
createDocument()
create the XML Document. |
protected static org.w3c.dom.Document |
createDocumentFromFactory(javax.xml.parsers.DocumentBuilderFactory factory)
create Document From Factory |
private XmlModelEncoder.ReferenceCollection |
createReferenceCollection(PropertyCollection<?,?> child,
java.lang.String name,
java.util.Map<java.lang.String,XmlModelEncoder.ReferenceCollection> mapToSearch)
create Reference Collection |
private void |
createRootElements()
create Root Elements in the DOM |
private void |
extractModel()
extract the model layer from the collection to encode |
private void |
extractNamedReferenceFinder(PropertyCollection<?,?> applicationModel)
extract Name Reference Finder |
private XmlModelEncoder.PackageSubObjectList |
fetchSubPackageObjectList(XmlModelEncoder.PackageSubObjectList currentPackageObjectList,
PropertyCollection<?,?> currentPackage)
fetch or add the package holder object in the object map |
private void |
fillParentList(PropertyCollection<?,?> collection,
java.util.List<PropertyCollection<?,?>> collectionTree)
fill a list with all the Parents of a collection |
java.io.OutputStream |
getOutStream()
|
private boolean |
isChildOfRoots(PropertyCollection<?,?> collection)
test to see if the specified collection is a child of the root collection being encoded |
private boolean |
isParentOf(PropertyCollection<?,?> collection,
PropertyCollection<?,?> possibleParent)
test to see if a collection is a parent of another one |
boolean |
isReadabilityEnhanced()
|
void |
setOutStream(java.io.OutputStream setOutStream)
|
void |
setReadabilityEnhanced(boolean setIsReadabilityEnhanced)
|
private boolean |
skipProperty(PropertyCollection<?,?> collection,
PropertyCollection<?,?> instance)
check to see if the property should be skipped while writing the document |
protected static void |
writeDocumentToStream(org.w3c.dom.Document document,
java.io.OutputStream stream)
write Document To Stream |
private void |
writeDomStructure()
write Dom Structure |
private void |
writeInstanceAttributes(org.w3c.dom.Element instanceElement,
PropertyCollection<?,?> instance)
write Instance Attributes to the DOM |
private void |
writePackageToDom(org.w3c.dom.Element parentElement,
XmlModelEncoder.PackageSubObjectList packageObjects)
write a package to the DOM |
private void |
writeProperty(Property<?> value,
org.w3c.dom.Element domElement)
write a property to the DOM |
void |
writePropertyCollection(PropertyCollection<?,?> collection)
write Property Collection in the configured encoder |
void |
writePropertyCollection(PropertyCollection<?,?> collection,
PropertyCollection<?,?> applicationModel)
write a property collection to a XML stream |
private void |
writeReferenceElements(org.w3c.dom.Element parentElement,
java.util.Map<java.lang.String,XmlModelEncoder.ReferenceCollection> rootMap)
write Reference Elements |
private void |
writeReferencesToDom()
write References To DOM |
private void |
writeSchemaToDom(org.w3c.dom.Element parentElement,
PropertyCollection<?,?> schema,
XmlModelEncoder.PackageSubObjectList rootPackage,
java.util.List<java.lang.String> usedSchemaNames)
write Schema To document object model |
private void |
writeTypeAttributes(org.w3c.dom.Element domElement,
PropertyCollection<?,?> type,
java.lang.Object uniqueID)
write Type Attributes |
private void |
writeTypeDataToDom(org.w3c.dom.Element parentElement,
XmlModelEncoder.TypeInstanceList typeData)
write Type Data To the document object model |
private void |
writeTypesToDom()
write Types To DOM |
private void |
writeValue(java.lang.Object currentValue,
org.w3c.dom.Element propertyElement,
PropertyCollection<?,?> instance)
write a value to the DOM |
private void |
writeValuesToDom()
write Values To DOM |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final java.util.logging.Logger LOGGER
private NameReferenceFinder nameReferenceFinder
private java.util.Map<java.lang.Object,XmlModelEncoder.TypeInstanceList> typeMap
private java.util.Map<java.lang.Object,PropertyCollection<?,?>> instanceMap
private java.util.Map<java.lang.Object,PropertyCollection<?,?>> collectionByReferenceMap
private java.util.Map<java.lang.Object,PropertyCollection<?,?>> collectionByValueMap
private java.util.Map<java.lang.Object,PropertyCollection<?,?>> collectionMap
private java.util.IdentityHashMap<PropertyCollection<?,?>,XmlModelEncoder.PackageSubObjectList> schemaRootPackageMap
private PropertyCollection<?,?> rootCollection
private PropertyCollection<?,?> modelLayer
private java.io.OutputStream outStream
private org.w3c.dom.Document document
private org.w3c.dom.Element rootElement
private org.w3c.dom.Element typeListElement
private org.w3c.dom.Element referenceListElement
private org.w3c.dom.Element valueListElement
private boolean isReadabilityEnhanced
Constructor Detail |
---|
public XmlModelEncoder()
Method Detail |
---|
public void writePropertyCollection(PropertyCollection<?,?> collection) throws EncodeException
collection
- the collection to write
EncodeException
- any error that occurred during encodingpublic void writePropertyCollection(PropertyCollection<?,?> collection, PropertyCollection<?,?> applicationModel) throws EncodeException
collection
- the collection to encodeapplicationModel
- the application model used to extract references.
If null is specified, then the owning model layer is used to
extract references.
EncodeException
- any error encountered while encoding the documentprivate void extractNamedReferenceFinder(PropertyCollection<?,?> applicationModel) throws EncodeException
applicationModel
- the application model to use to create the name
reference finder
EncodeException
- any error encountered while encoding the documentprivate void extractModel()
private void cleanupTemporaryObjects()
private boolean isChildOfRoots(PropertyCollection<?,?> collection)
collection
- the collection to test
private boolean isParentOf(PropertyCollection<?,?> collection, PropertyCollection<?,?> possibleParent)
collection
- the collection to testpossibleParent
- the possible parent
private void writeDomStructure() throws EncodeException
EncodeException
- any encoding errorprivate void writeReferencesToDom() throws EncodeException
EncodeException
- any encoding errorsprivate void writeReferenceElements(org.w3c.dom.Element parentElement, java.util.Map<java.lang.String,XmlModelEncoder.ReferenceCollection> rootMap)
parentElement
- the parent elementrootMap
- the map of all the referencesprivate void addReferenceMap(java.util.Map<java.lang.String,XmlModelEncoder.ReferenceCollection> rootMap, PropertyCollection<?,?> collection) throws EncodeException
rootMap
- the map that receives the referencecollection
- the collection to add to the map
EncodeException
- any encoding errorprivate XmlModelEncoder.ReferenceCollection createReferenceCollection(PropertyCollection<?,?> child, java.lang.String name, java.util.Map<java.lang.String,XmlModelEncoder.ReferenceCollection> mapToSearch) throws EncodeException
child
- the child collectionname
- the name of this childmapToSearch
- the map to search for the name
EncodeException
- any encoding errorprivate void fillParentList(PropertyCollection<?,?> collection, java.util.List<PropertyCollection<?,?>> collectionTree)
collection
- the collection to fetch the hierarchycollectionTree
- the list that receives the list of parentsprivate void writeTypesToDom() throws EncodeException
EncodeException
- any error encountered while encoding the documentprivate void writeSchemaToDom(org.w3c.dom.Element parentElement, PropertyCollection<?,?> schema, XmlModelEncoder.PackageSubObjectList rootPackage, java.util.List<java.lang.String> usedSchemaNames) throws EncodeException
parentElement
- the xml element to get the schemaschema
- the schema to writerootPackage
- the root package of the schemausedSchemaNames
- the list of schema names already used
EncodeException
- any error encountered while encoding the documentprivate void writePackageToDom(org.w3c.dom.Element parentElement, XmlModelEncoder.PackageSubObjectList packageObjects)
parentElement
- the parent DOM elementpackageObjects
- the package object holderprivate void writeTypeDataToDom(org.w3c.dom.Element parentElement, XmlModelEncoder.TypeInstanceList typeData)
parentElement
- the parent DOM elementtypeData
- the type data holderprivate void writeInstanceAttributes(org.w3c.dom.Element instanceElement, PropertyCollection<?,?> instance)
instanceElement
- the DOM element that receives the attributesinstance
- the instance to writeprivate void writeTypeAttributes(org.w3c.dom.Element domElement, PropertyCollection<?,?> type, java.lang.Object uniqueID)
domElement
- the DOM element to receive the attributestype
- the type tow riteuniqueID
- the unique ID of the typeprivate void writeValuesToDom() throws EncodeException
EncodeException
- when encoding failsprivate void createRootElements()
protected static org.w3c.dom.Document createDocument() throws EncodeException
EncodeException
- if creating the document causes a problemprotected static org.w3c.dom.Document createDocumentFromFactory(javax.xml.parsers.DocumentBuilderFactory factory) throws EncodeException
factory
- the factory to use during creation
EncodeException
- if creating the document causes a problemprotected static void writeDocumentToStream(org.w3c.dom.Document document, java.io.OutputStream stream) throws EncodeException
document
- the document to writestream
- the stream to use
EncodeException
- any encoding errorprivate void createCollectionDocument(org.w3c.dom.Element parentElement, PropertyCollection<?,?> collection, java.lang.Object uniqueID) throws EncodeException
parentElement
- the parent DOM elementcollection
- the collection to writeuniqueID
- the unique ID of the collection
EncodeException
- when encoding failsprivate void writeProperty(Property<?> value, org.w3c.dom.Element domElement) throws EncodeException
value
- they property valuedomElement
- the parent DOM element
EncodeException
- when encoding failsprivate void writeValue(java.lang.Object currentValue, org.w3c.dom.Element propertyElement, PropertyCollection<?,?> instance) throws EncodeException
currentValue
- the value to writepropertyElement
- the DOM element that receives the valueinstance
- the instance of the value
EncodeException
- when encoding failsprivate void buildObjectMap(PropertyCollection<?,?> collection) throws EncodeException
collection
- the collection that will be written in the XML document
EncodeException
- any encoding errorprivate void addObjectToValueMap(PropertyCollection<?,?> collection, java.lang.Object uniqueID)
collection
- the collection to adduniqueID
- the unique ID of the collectionprivate void addObjectToRootMap(PropertyCollection<?,?> collection, java.lang.Object uniqueID)
collection
- the collection to adduniqueID
- the unique ID of the collectionprivate void addObjectToReferenceMap(PropertyCollection<?,?> collection, java.lang.Object uniqueID)
collection
- the collection to adduniqueID
- the unique ID of the collectionprivate void addAllInstances(PropertyCollection<?,?> collection) throws EncodeException
collection
- the collection to add to the object map
EncodeException
- any encoding errorprivate boolean skipProperty(PropertyCollection<?,?> collection, PropertyCollection<?,?> instance)
collection
- the collection to writeinstance
- the instance to write
private void addInstance(PropertyCollection<?,?> instance) throws EncodeException
instance
- the instance to add
EncodeException
- any encoding errorprivate XmlModelEncoder.TypeInstanceList addPropertyType(PropertyCollection<?,?> ownerType) throws EncodeException
ownerType
- the property type to add
EncodeException
- any encoding errorprivate XmlModelEncoder.PackageSubObjectList fetchSubPackageObjectList(XmlModelEncoder.PackageSubObjectList currentPackageObjectList, PropertyCollection<?,?> currentPackage)
currentPackageObjectList
- the package to searchcurrentPackage
- the sub package to add or fetch
private static PropertyCollection<?,?> buildPackageList(java.util.List<PropertyCollection<?,?>> packageList, PropertyCollection<?,?> ownerType) throws EncodeException
packageList
- the package list that receives all the packagesownerType
- the type to fetch the package list from
EncodeException
- any encoding errorpublic java.io.OutputStream getOutStream()
public void setOutStream(java.io.OutputStream setOutStream)
setOutStream
- The outStream to set.public boolean isReadabilityEnhanced()
public void setReadabilityEnhanced(boolean setIsReadabilityEnhanced)
setIsReadabilityEnhanced
- The isReadabilityEnhanced to set.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |