public class ElementTools extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
ATTR_CLASS |
static String |
ATTR_FACTORY |
static String |
ATTR_NAME |
static String |
ATTR_REF |
static String |
ATTR_TYPE |
static String |
ELEMENT_ACCESSOR |
static String |
ELEMENT_ARGS |
static String |
ELEMENT_GET |
static String |
ELEMENT_IMPLEMENTATION |
static String |
ELEMENT_METHOD |
static String |
ELEMENT_NULL |
static String |
ELEMENT_OBJECT |
static String |
ELEMENT_PERFORM |
static String |
ELEMENT_SET |
static String |
ELEMENT_VALUE |
static String |
PROPERTY_INSERT |
static String |
PROPERTY_REMOVE |
static String |
PROPERTY_SET |
| Constructor and Description |
|---|
ElementTools() |
| Modifier and Type | Method and Description |
|---|---|
static void |
copy(IElement to,
IElement from) |
static void |
copyAttributes(IElement to,
IElement from) |
static void |
copyElements(IElement to,
IElement from) |
static void |
copyText(IElement to,
IElement from) |
static <T> Class<T> |
createClass(IElement element,
String classAttribute,
Class<T> expectedClass,
Object context) |
static IFunctor |
createFunctor(Object owner,
IElement element,
String role,
Object context)
This is a tool method to create an
IFunctor. |
static <T> T |
createObject(IElement element,
Class<T> expectedClass,
Object context) |
static <T> T |
createObject(IElement element,
String role,
Class<T> expectedClass,
Object context)
Create an object of type expectedClass as described in element.
|
static <T> T |
createObjectChild(Object owner,
IElement element,
Class<T> expectedClass,
Object context) |
static <T> T |
createPropertyValue(Object owner,
IElement element,
Class<T> expectedClass,
Object context) |
static boolean |
getBool(IElement element,
String attributeName,
boolean defaultValue) |
static boolean |
getBoolean(IElement element,
String attributeName,
boolean defaultValue) |
static char[] |
getCharArray(IElement element,
String attributeName,
char[] defaultValue) |
static Color |
getColor(IElement element,
String name,
Color defaultValue)
The argument value at
name as a Color. |
static double |
getDouble(IElement element,
String attributeName,
double defaultValue) |
static <T extends EnumItem> |
getEnumItem(IElement element,
String attributeName,
EnumMeta<T> meta) |
static <T extends EnumItem> |
getEnumItem(IElement element,
String attributeName,
EnumMeta<T> meta,
T defaultValue) |
static float |
getFloat(IElement element,
String attributeName,
float defaultValue) |
static int |
getInt(IElement element,
String attributeName,
int defaultValue) |
static long |
getLong(IElement element,
String attributeName,
long defaultValue) |
static boolean |
getPathBoolean(IElement element,
String path,
boolean defaultValue) |
static double |
getPathDouble(IElement element,
String path,
double defaultValue) |
static float |
getPathFloat(IElement element,
String path,
float defaultValue) |
static int |
getPathInt(IElement element,
String path,
int defaultValue) |
static String |
getPathString(IElement element,
String path,
String defaultValue) |
static String |
getString(IElement element,
String attributeName,
String defaultValue) |
static IElement |
parseElement(String value) |
static void |
serialize(Object value,
IElement element,
String role) |
static void |
setCDATA(IElement element,
String value) |
static void |
setProperties(Object object,
IElement element,
Object context)
Set properties in object based on the list of property information
contained in element.
|
static void |
setProperty(Object object,
IElement element,
Object context)
Set a property in object based on the property information contained in
element.
|
static IElement |
toElement(IArgs args)
Create an
Element from args. |
static void |
write(ContentHandler handler,
IElement element) |
public static final String PROPERTY_REMOVE
public static final String PROPERTY_INSERT
public static final String ELEMENT_SET
public static final String PROPERTY_SET
public static final String ELEMENT_GET
public static final String ATTR_REF
public static final String ELEMENT_ACCESSOR
public static final String ELEMENT_NULL
public static final String ELEMENT_ARGS
public static final String ELEMENT_VALUE
public static final String ELEMENT_OBJECT
public static final String ATTR_TYPE
public static final String ELEMENT_PERFORM
public static final String ATTR_CLASS
public static final String ATTR_FACTORY
public static final String ATTR_NAME
public static final String ELEMENT_IMPLEMENTATION
public static final String ELEMENT_METHOD
public static <T> Class<T> createClass(IElement element, String classAttribute, Class<T> expectedClass, Object context) throws ObjectCreationException
ObjectCreationExceptionpublic static IFunctor createFunctor(Object owner, IElement element, String role, Object context) throws ObjectCreationException
IFunctor. We use this because
of a small deviation from the standard XML syntax. The functor can be
either created "normally" or via an embedded "perform" element.owner - element - role - TODOcontext - ObjectCreationExceptionpublic static <T> T createObject(IElement element, Class<T> expectedClass, Object context) throws ObjectCreationException
ObjectCreationExceptionpublic static <T> T createObject(IElement element, String role, Class<T> expectedClass, Object context) throws ObjectCreationException
IFactory
element - role - expectedClass - context - TODOObjectCreationExceptionpublic static <T> T createObjectChild(Object owner, IElement element, Class<T> expectedClass, Object context) throws ObjectCreationException
ObjectCreationExceptionpublic static <T> T createPropertyValue(Object owner, IElement element, Class<T> expectedClass, Object context) throws ObjectCreationException
ObjectCreationExceptionpublic static boolean getBoolean(IElement element, String attributeName, boolean defaultValue)
public static char[] getCharArray(IElement element, String attributeName, char[] defaultValue)
public static Color getColor(IElement element, String name, Color defaultValue)
name as a Color. If the
argument value is not provided or not convertible,
defaultValueis returned.args - name - defaultValue - name as a Color.public static double getDouble(IElement element, String attributeName, double defaultValue)
public static <T extends EnumItem> T getEnumItem(IElement element, String attributeName, EnumMeta<T> meta)
public static <T extends EnumItem> T getEnumItem(IElement element, String attributeName, EnumMeta<T> meta, T defaultValue)
public static boolean getPathBoolean(IElement element, String path, boolean defaultValue)
public static double getPathDouble(IElement element, String path, double defaultValue)
public static String getPathString(IElement element, String path, String defaultValue)
public static String getString(IElement element, String attributeName, String defaultValue)
public static IElement parseElement(String value) throws IOException
IOExceptionpublic static void serialize(Object value, IElement element, String role) throws ElementSerializationException
ElementSerializationExceptionpublic static void setProperties(Object object, IElement element, Object context) throws FieldException, ObjectCreationException, FunctorInvocationException
...
object - element - classLoader - FieldExceptionObjectCreationExceptionFunctorInvocationExceptionpublic static void setProperty(Object object, IElement element, Object context) throws FieldException, ObjectCreationException, FunctorInvocationException
Long form
...
Short form
...
object - element - classLoader - FieldExceptionObjectCreationExceptionFunctorInvocationExceptionpublic static IElement toElement(IArgs args)
Element from args. This is useful for bridging
arguments to the configuration utility IElementConfigurable.
IArgs are converted using the following rules:
1) If "args" contains named bindings, an Element is created for
the "args" structure and all named bindings are stored in the element
where a non-IArgs binding is serialized as an attribute value and
an IArgs binding is added to the element recursively.
2) If "args" contains indexed bindings, an Element is created for
each binding and added to the current parent.
{
a -> "b"
x -> "y"
}
{
a -> "b"
x -> {
foo = "bar"
}
y -> {
gnu = "gnat"
}
}
args - public static void write(ContentHandler handler, IElement element) throws SAXException
SAXExceptionCopyright © 2013 intarsys consulting GmbH. All Rights Reserved.