public class XMap extends Object
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
| Modifier and Type | Field and Description |
|---|---|
protected Map<Class,XValueFactory> |
factories |
protected Map<Class,XAnnotatedObject> |
objects |
protected Map<String,XAnnotatedObject> |
roots |
| Constructor and Description |
|---|
XMap()
Creates a new XMap object.
|
| Modifier and Type | Method and Description |
|---|---|
Document |
asXml(Object contribution,
List<String> filters) |
String |
asXmlString(Object contribution,
String encoding,
List<String> filters) |
String |
asXmlString(Object contribution,
String encoding,
List<String> filters,
boolean pretty) |
protected static Annotation |
checkMemberAnnotation(AnnotatedElement ae) |
protected static XObject |
checkObjectAnnotation(AnnotatedElement ae,
ClassLoader classLoader) |
XAnnotatedMember |
createFieldMember(Field field,
Annotation annotation) |
XAnnotatedMember |
createMethodMember(Method method,
Class<?> clazz,
Annotation annotation) |
Method |
getGetterMethod(Class<?> clazz,
String name) |
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.
|
<T> T |
load(Map<String,Object> map,
String keyPrefix,
Class<T> klass) |
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
Return a list with all registered top level objects that are found in the file.
|
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.
|
XAnnotatedObject |
register(Class klass,
boolean isParent)
Registers a mappable object class.
|
void |
setValueFactory(Class type,
XValueFactory factory)
Sets a custom value factory for the given class.
|
protected final Map<String,XAnnotatedObject> roots
protected final Map<Class,XAnnotatedObject> objects
protected final Map<Class,XValueFactory> factories
public XValueFactory getValueFactory(Class type)
type - the object typepublic void setValueFactory(Class type, XValueFactory factory)
type - the object typefactory - the value factory to use for the given typepublic Collection<XAnnotatedObject> getScannedObjects()
public Collection<XAnnotatedObject> getRootObjects()
public XAnnotatedObject register(Class klass)
klass - the object classpublic XAnnotatedObject register(Class klass, boolean isParent)
klass - the object classpublic Object load(URL url) throws Exception
url - the XML file urlExceptionpublic Object load(Context ctx, URL url) throws Exception
ctx - the context to useurl - the XML file urlException - any exceptionpublic Object load(InputStream in) throws Exception
in - the XML input sourceExceptionpublic Object load(Context ctx, InputStream in) throws Exception
ctx - the context to usein - the input streamException - any exceptionpublic Object[] loadAll(URL url) throws Exception
url - the XML file urlExceptionpublic Object[] loadAll(Context ctx, URL url) throws Exception
ctx - the context to useurl - the XML file urlException - any exceptionpublic Object[] loadAll(InputStream in) throws Exception
in - the XML input streamException - any exceptionpublic Object[] loadAll(Context ctx, InputStream in) throws Exception
ctx - the context to usein - the XML input streamExceptionpublic Object load(Element root) throws Exception
root - the element to processExceptionpublic Object load(Context ctx, Element root) throws Exception
ctx - the context to useroot - the element to processExceptionpublic <T> T load(Map<String,Object> map, String keyPrefix, Class<T> klass) throws Exception
Exceptionpublic Object[] loadAll(Context ctx, Element root) throws Exception
ctx - the context to useroot - the element to processExceptionpublic Object[] loadAll(Element root) throws Exception
root - the element to processExceptionpublic 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 objectsExceptionpublic Document asXml(Object contribution, List<String> filters) throws Exception
Exceptionpublic String asXmlString(Object contribution, String encoding, List<String> filters) throws Exception
Exceptionpublic String asXmlString(Object contribution, String encoding, List<String> filters, boolean pretty) throws Exception
Exceptionpublic 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 objectsExceptionprotected static Annotation checkMemberAnnotation(AnnotatedElement ae)
protected static XObject checkObjectAnnotation(AnnotatedElement ae, ClassLoader classLoader)
public final XAnnotatedMember createFieldMember(Field field, Annotation annotation)
public final XAnnotatedMember createMethodMember(Method method, Class<?> clazz, Annotation annotation)
Copyright © 2021. All rights reserved.