|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object wyvern.kernel.properties.PropertyParser
This class provides methods for parsing properties. It's used primarily by the Archetype.parseProperties() for obtaining the properties and values to set on an object.
Constructor Summary | |
PropertyParser()
|
Method Summary | |
java.lang.Object |
createBeanValue(java.lang.String classname)
Attempts to load and instantiate the specified class. |
static java.lang.Object |
createPythonBeanValue(java.lang.String path,
java.lang.Class type)
Attempts to load and instantiate the specified python class. |
static java.beans.BeanInfo |
getBeanvalInfo(java.lang.Object value)
Gets a BeanInfo object that will stop looking when it reaches the top of the wyvern class heirarchy. |
static PropertyParser |
getInstance()
|
static int |
getIntAttribute(org.w3c.dom.Element node,
java.lang.String name)
Retrieves an attribute whose value is an int. |
static java.util.HashMap |
getPropNames(java.lang.Object value)
Returns a list of the sub-properties that this value possesses. |
java.lang.Object |
instantiateObject(java.lang.Class c)
Creates an instance of the passed class. |
static Property |
parseAppearance(org.w3c.dom.Element node)
Creates an Appearance bean from the shorthand wyvern-XML "image" element. |
java.lang.Object |
parseBeanProperty(org.w3c.dom.Element node)
Initializes a Bean property from its externalized representation. |
void |
parseBeanSubProps(org.w3c.dom.Element node,
java.lang.Object bean)
Parses an externalized bean property value (a "bean"). |
static Property |
parseMusic(org.w3c.dom.Element node)
Creates an Soundtrack bean from the shorthand wyvern-XML "music" element. |
static Property |
parsePoint(java.lang.String name,
org.w3c.dom.Element node)
Shortcut for properties whose value is a Point. |
Property |
parseProperty(org.w3c.dom.Node node)
Parses a single property from an element list. |
java.util.List |
parsePropertyList(org.w3c.dom.Element node)
Parses a list of externalized properties. |
Property |
parsePropertyNode(org.w3c.dom.Element child)
Exact same thing as parseProperty(), except it doesn't get the first child element of the node and parse that. |
static Property |
parseSize(java.lang.String size)
This allows the user to specify a (rectangular) size for an object, rather than a location list. |
void |
readBeanProp(java.lang.Object bean,
java.beans.PropertyDescriptor desc,
org.w3c.dom.Element node,
java.lang.String name)
Reads the value of a sub-property and initializes that sub-property on the passed object. |
void |
setContinueOnError(boolean continueOnError)
Tells this PropertyParser to keep going if we encounter an error, such as a property that can't be instantiated. |
static void |
setSubProperty(java.lang.Object beanval,
java.beans.PropertyDescriptor desc,
java.lang.Object pval)
Sets a sub-property on a bean-value object. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public PropertyParser()
Method Detail |
public static PropertyParser getInstance()
public void setContinueOnError(boolean continueOnError)
public java.util.List parsePropertyList(org.w3c.dom.Element node) throws java.lang.Exception
node
- a DOM tree containing the properties
ParseException
- if there was a parse error in the list,
unless continueOnError() was set.
java.lang.Exception
public Property parseProperty(org.w3c.dom.Node node) throws java.lang.Exception
The parser has a number of special-cased properties (such as "size" and "weight") that occur so frequently that we felt justified in having special syntax available for them.
node
- a DOM Node object containing at least one
child node. The child node needn't necessarily be a property
element - this method will strip childen from the node until
it finds an element or the node is empty.
a
- ParseException if we found a malformed property
element definition.
java.lang.Exception
public Property parsePropertyNode(org.w3c.dom.Element child) throws java.lang.Exception
java.lang.Exception
public static Property parseSize(java.lang.String size) throws java.lang.Exception
size
- a size specifier, such as 1x2
java.lang.Exception
public static Property parsePoint(java.lang.String name, org.w3c.dom.Element node) throws java.lang.Exception
name
- the property namenode
- an Element of of type "point"; requires x, y attrs
java.lang.Exception
public static Property parseAppearance(org.w3c.dom.Element node) throws java.lang.Exception
node
- an Element of type "image"
java.lang.Exception
public static int getIntAttribute(org.w3c.dom.Element node, java.lang.String name)
node
- the Element node to get the attribute fromname
- the name of the attribute to get
public static Property parseMusic(org.w3c.dom.Element node) throws java.lang.Exception
node
- an Element of type "music"
java.lang.Exception
public java.lang.Object parseBeanProperty(org.w3c.dom.Element node) throws java.lang.Exception
node
- the DOM Element representing the bean property
ParseException
- if it couldn't parse the bean value
java.lang.Exception
public java.lang.Object createBeanValue(java.lang.String classname) throws java.lang.Exception
classname
- the name of the class to instantiate
a
- ParseException if the class couldn't be loaded
or instantiated, with an appropriate detail message. If
setContinueOnError() was called first, then no Exception
will be thrown - it'l; return null instead.
java.lang.Exception
public static java.lang.Object createPythonBeanValue(java.lang.String path, java.lang.Class type) throws java.lang.Exception
path
- the (relative) path of the python file to instantiate,
such as "wiz/wyvern/moonquest/moon_crystal".
an
- InstantiationException if we couldn't create it
java.lang.Exception
public java.lang.Object instantiateObject(java.lang.Class c) throws java.lang.Exception
c
- the class to check
any
- Exception, unless setContinueOnError() is set.
Don't count on it throwing an exception, though - it may
simply log an error on the PropertyParser logger.
java.lang.Exception
public void parseBeanSubProps(org.w3c.dom.Element node, java.lang.Object bean) throws java.lang.Exception
node
- the DOM Element representing the beanbean
- the Bean object to add the properties to
ParseException
- if the Bean couldn't be parsed,
with an appropriate detail message.
java.lang.Exception
public void readBeanProp(java.lang.Object bean, java.beans.PropertyDescriptor desc, org.w3c.dom.Element node, java.lang.String name)
bean
- the bean to add the property todesc
- a PropertyDescriptor for the sub-property we're parsingnode
- the Element containing the property to add to the beanname
- the name of the property to set on the bean. E.g. if
the name is "layer", we'll look for a "setLayer" bean method.public static void setSubProperty(java.lang.Object beanval, java.beans.PropertyDescriptor desc, java.lang.Object pval) throws java.lang.Exception
beanval
- the bean-value object to operate ondesc
- the PropertyDescriptor for the sub-property we're settingpval
- the actual value for the sub-property we're setting
java.lang.Exception
public static java.util.HashMap getPropNames(java.lang.Object value)
value
- the value object of the BeanProperty we're parsing
public static java.beans.BeanInfo getBeanvalInfo(java.lang.Object value) throws java.beans.IntrospectionException
value
- the value object of the BeanProperty we're parsing
java.beans.IntrospectionException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |