|
common-util | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectlocal.tomas.common.xml.XMLTypeHandler
public abstract class XMLTypeHandler
The type handlers are used to convert specific types to and from XML.
| Field Summary | |
|---|---|
protected Class<?> |
arrayType
The corresponding array type. |
protected XMLTypeHandler |
arrayTypeHandler
Handler for corresponding array type. |
protected String |
name
Type name |
protected Class<?> |
type
The type |
| Constructor Summary | |
|---|---|
protected |
XMLTypeHandler(Class<?> type)
Construct type handler from type. |
protected |
XMLTypeHandler(Class<?> type,
Class<?> arrayType)
Construct type handler from type and array type. |
| Method Summary | |
|---|---|
protected abstract int |
getArraySize(Object src)
Get size of array. |
Class<?> |
getArrayType()
Get type of array of base type. |
XMLTypeHandler |
getArrayTypeHandler()
Get handler for type of array of base type. |
String |
getName()
Get name of type handled by this instance. |
Class<?> |
getType()
Get type handled by this instance. |
void |
marshall(String name,
Class<?> type,
Object src,
XMLTokenGenerator gen)
Create XML description of an object. |
void |
marshall(String name,
int index,
Class<?> type,
Object src,
XMLTokenGenerator gen)
Create XML description of an object. |
protected abstract void |
marshallArrayElements(Class type,
Object src,
XMLTokenGenerator gen)
Generate XML description of array elements. |
protected void |
marshallNullPrefix(String name,
int index,
Class<?> type,
XMLTokenGenerator gen)
Generate start token of null value. |
protected void |
marshallNullSuffix(String name,
Class<?> type,
XMLTokenGenerator gen)
Generate end token of null value. |
protected void |
marshallPrefix(String name,
int index,
Class<?> type,
Object src,
XMLTokenGenerator gen)
Generate start token. |
boolean |
marshallRef(String name,
int index,
Class<?> type,
Object src,
XMLTokenGenerator gen)
Try to create an XML reference for an object. |
protected void |
marshallSuffix(String name,
Class<?> type,
XMLTokenGenerator gen)
Generate end token. |
protected abstract void |
marshallValue(Class type,
Object src,
XMLTokenGenerator gen)
Generate XML description of object value. |
boolean |
match(Class<?> type)
Determine if type can be handled by this instance. |
Object |
newArray(Class<?> type,
int size)
Create an array of the type handled. |
Object |
newInstance(Class<?> type)
Create an instance of the type handled. |
Object |
newInstance(Class<?> type,
int size)
Create an instance of the type handled with a given size. |
Object |
newInstance(Class<?> type,
String value)
Create an instance of the type handled initialized with a string value. |
protected abstract void |
setArrayElement(Object dest,
int index,
Object value)
Set array component. |
void |
setProperty(Object dest,
String name,
int index,
Object value)
Set property of an object. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected String name
protected Class<?> type
protected Class<?> arrayType
protected XMLTypeHandler arrayTypeHandler
| Constructor Detail |
|---|
protected XMLTypeHandler(Class<?> type,
Class<?> arrayType)
type - typearrayType - array typeprotected XMLTypeHandler(Class<?> type)
type - the type| Method Detail |
|---|
public Class<?> getArrayType()
public XMLTypeHandler getArrayTypeHandler()
public String getName()
public Class<?> getType()
public boolean match(Class<?> type)
type - - test candidate
public Object newInstance(Class<?> type)
throws XMLException
type - - type of instance
XMLException
public Object newInstance(Class<?> type,
String value)
throws XMLException
type - - type of instancevalue - - the string value
XMLException
public Object newInstance(Class<?> type,
int size)
throws XMLException
type - - type of instancesize - - the size
XMLException
public Object newArray(Class<?> type,
int size)
throws XMLException
type - - component typesize - - size of array
XMLException
public void marshall(String name,
int index,
Class<?> type,
Object src,
XMLTokenGenerator gen)
throws XMLException
name - - XML tag nameindex - - index attribute, negative values are omittedtype - - type of objectsrc - - the objectgen - - used to generate XML tokens
XMLException
public void marshall(String name,
Class<?> type,
Object src,
XMLTokenGenerator gen)
throws XMLException
name - - XML tag nametype - - type of objectsrc - - the objectgen - - used to generate XML tokens
XMLException
public boolean marshallRef(String name,
int index,
Class<?> type,
Object src,
XMLTokenGenerator gen)
throws XMLException
name - - XML tag nameindex - - index attribute, negative values are omittedtype - - type of objectsrc - - the objectgen - - used to generate XML tokens
XMLException
protected void marshallNullPrefix(String name,
int index,
Class<?> type,
XMLTokenGenerator gen)
throws XMLException
name - - XML tag nametype - - value typegen - - used to generate XML tokens
XMLException
protected void marshallNullSuffix(String name,
Class<?> type,
XMLTokenGenerator gen)
throws XMLException
name - - XML tag nametype - - value typegen - - used to generate XML tokens
XMLException
protected void marshallPrefix(String name,
int index,
Class<?> type,
Object src,
XMLTokenGenerator gen)
throws XMLException
name - - token nameindex - - index attribute, negative values are omittedtype - - value typesrc - - valuegen - - used to generate XML tokens
XMLException
protected void marshallSuffix(String name,
Class<?> type,
XMLTokenGenerator gen)
throws XMLException
name - - token nametype - - type of objectgen - - used to generate XML tokens
XMLException
protected abstract void marshallValue(Class type,
Object src,
XMLTokenGenerator gen)
throws XMLException
type - - object typesrc - - the objectgen - - used to generate XML tokens
XMLExceptionprotected abstract int getArraySize(Object src)
src - - the array
protected abstract void marshallArrayElements(Class type,
Object src,
XMLTokenGenerator gen)
throws XMLException
type - - the array typesrc - - the arraygen - - used to generate XML tokens
XMLException
protected abstract void setArrayElement(Object dest,
int index,
Object value)
throws XMLException
dest - - the arrayindex - - the index within the arrayvalue - - the value to assign
XMLException
public void setProperty(Object dest,
String name,
int index,
Object value)
throws XMLException
dest - - the objectname - - the property nameindex - - a property indexvalue - - the new property value
XMLException
|
common-util | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||