|
Nuxeo ECM Projects 5.4.3-SNAPSHOT | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.nuxeo.common.xmap.XMap
public class XMap
XMap maps an XML file to a java object.
The mapping is described by annotations on java objects.
The following annotations are supported:
XObject
Mark the object as being mappable to an XML node
XNode
Map an XML node to a field of a mappable object
XNodeList
Map an list of XML nodes to a field of a mappable object
XNodeMap
Map an map of XML nodes to a field of a mappable object
XContent
Map an XML node content to a field of a mappable object
XParent
Map a field of the current mappable object to the parent object if any exists
The parent object is the mappable object containing the current object as a field
Constructor Summary | |
---|---|
XMap()
Creates a new XMap object. |
Method Summary | |
---|---|
XAnnotatedMember |
createFieldMember(Field field,
Annotation annotation)
|
XAnnotatedMember |
createMethodMember(Method method,
Annotation annotation,
Class klass)
|
Collection<XAnnotatedObject> |
getRootObjects()
Gets the root objects. |
Collection<XAnnotatedObject> |
getScannedObjects()
Gets a list of scanned objects. |
XValueFactory |
getValueFactory(Class type)
Gets the value factory used for objects of the given class. |
Object |
load(Context ctx,
Element root)
Processes the given DOM element and return the first mappable object found in the element. |
Object |
load(Context ctx,
InputStream in)
Processes the XML content from the given input stream using the given context. |
Object |
load(Context ctx,
URL url)
Processes the XML file at the given URL and using the given contexts. |
Object |
load(Element root)
Processes the given DOM element and return the first mappable object found in the element. |
Object |
load(InputStream in)
Processes the XML content from the given input stream using a default context. |
Object |
load(URL url)
Processes the XML file at the given URL using a default context. |
Object[] |
loadAll(Context ctx,
Element root)
Processes the given DOM element and return a list with all top-level mappable objects found in the element. |
void |
loadAll(Context ctx,
Element root,
Collection<Object> result)
Same as loadAll(Context, Element) but put collected objects in the
given collection. |
Object[] |
loadAll(Context ctx,
InputStream in)
Processes the XML from the given input stream using the given context. |
Object[] |
loadAll(Context ctx,
URL url)
Processes the XML file at the given URL using the given context |
Object[] |
loadAll(Element root)
Processes the given DOM element and return a list with all top-level mappable objects found in the element. |
void |
loadAll(Element root,
Collection<Object> result)
Same as loadAll(Element) but put collected objects in the
given collection. |
Object[] |
loadAll(InputStream in)
Processes the XML from the given input stream using the given context. |
Object[] |
loadAll(URL url)
Processes the XML file at the given URL using a default context. |
XAnnotatedObject |
register(Class klass)
Registers a mappable object class. |
void |
setValueFactory(Class type,
XValueFactory factory)
Sets a custom value factory for the given class. |
String |
toXML(Object object)
|
void |
toXML(Object object,
Element root)
|
void |
toXML(Object object,
File file)
|
void |
toXML(Object object,
OutputStream os)
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public XMap()
Method Detail |
---|
public XValueFactory getValueFactory(Class type)
Value factories are used to decode values from XML strings.
type
- the object type
public void setValueFactory(Class type, XValueFactory factory)
Value factories are used to decode values from XML strings.
type
- the object typefactory
- the value factory to use for the given typepublic Collection<XAnnotatedObject> getScannedObjects()
Scanned objects are annotated objects that were registered by this XMap instance.
public Collection<XAnnotatedObject> getRootObjects()
Root objects are scanned objects that can be mapped to XML elements that are not part from other objects.
public XAnnotatedObject register(Class klass)
The class will be scanned for XMap annotations and a mapping description is created.
klass
- the object class
public Object load(URL url) throws Exception
url
- the XML file url
Exception
public Object load(Context ctx, URL url) throws Exception
ctx
- the context to useurl
- the XML file url
Exception
public Object load(InputStream in) throws Exception
in
- the XML input source
Exception
public Object load(Context ctx, InputStream in) throws Exception
ctx
- the context to usein
- the input stream
Exception
public Object[] loadAll(URL url) throws Exception
Returns a list with all registered top level objects that are found in the file.
If not objects are found, an empty list is returned.
url
- the XML file url
Exception
public Object[] loadAll(Context ctx, URL url) throws Exception
Return a list with all registered top level objects that are found in the file.
If not objects are found an empty list is retoruned.
ctx
- the context to useurl
- the XML file url
Exception
public Object[] loadAll(InputStream in) throws Exception
Returns a list with all registered top level objects that are found in the file.
If not objects are found, an empty list is returned.
in
- the XML input stream
Exception
public Object[] loadAll(Context ctx, InputStream in) throws Exception
Returns a list with all registered top level objects that are found in the file.
If not objects are found, an empty list is returned.
ctx
- the context to usein
- the XML input stream
Exception
public Object load(Element root) throws Exception
A default context is used.
root
- the element to process
Exception
public Object load(Context ctx, Element root) throws Exception
The given context is used.
ctx
- the context to useroot
- the element to process
Exception
public Object[] loadAll(Context ctx, Element root) throws Exception
The given context is used.
ctx
- the context to useroot
- the element to process
Exception
public Object[] loadAll(Element root) throws Exception
The default context is used.
root
- the element to process
Exception
public void loadAll(Element root, Collection<Object> result) throws Exception
loadAll(Element)
but put collected objects in the
given collection.
root
- the element to processresult
- the collection where to collect objects
Exception
public void loadAll(Context ctx, Element root, Collection<Object> result) throws Exception
loadAll(Context, Element)
but put collected objects in the
given collection.
ctx
- the context to useroot
- the element to processresult
- the collection where to collect objects
Exception
public final XAnnotatedMember createFieldMember(Field field, Annotation annotation)
public final XAnnotatedMember createMethodMember(Method method, Annotation annotation, Class klass)
public String toXML(Object object) throws ParserConfigurationException, IOException
ParserConfigurationException
IOException
public void toXML(Object object, OutputStream os) throws Exception
Exception
public void toXML(Object object, File file) throws Exception
Exception
public void toXML(Object object, Element root)
|
Nuxeo ECM Projects 5.4.3-SNAPSHOT | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |