|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.alee.utils.XmlUtils
public final class XmlUtils
This class provides a set of utilities to easily serialize and deserialize objects into and from XML. There are is a lot of methods to read specific library objects using various resource files.
Field Summary | |
---|---|
static boolean |
aliasJdkClasses
Whether should offer better aliases for standard Java classes like Point and Rectangle or not. |
static ColorConverter |
colorConverter
Custom converters. |
static InsetsConverter |
insetsConverter
|
static PasswordConverter |
passwordConverter
Custom password converter that encrypts serialized passwords. |
Constructor Summary | |
---|---|
XmlUtils()
|
Method Summary | ||
---|---|---|
static void |
addImplicitArray(java.lang.Class type,
java.lang.String field)
Adds an implicit array. |
|
static void |
addImplicitArray(java.lang.Class type,
java.lang.String field,
java.lang.String itemName)
Adds an implicit array which is used for all items of the given element name defined by itemName. |
|
static
|
alias(java.lang.Class<T> aliasProvider)
Calls static "provideAliases" method on a class that implements AliasProvider. |
|
static void |
alias(java.lang.String name,
java.lang.Class type)
Alias a Class to a shorter name to be used in XML elements. |
|
static
|
fromXML(java.io.File file)
Returns Object deserialized from XML content. |
|
static
|
fromXML(java.io.InputStream input)
Returns Object deserialized from XML content. |
|
static
|
fromXML(java.lang.Object source)
Returns Object deserialized from XML content. |
|
static
|
fromXML(java.io.Reader reader)
Returns Object deserialized from XML content. |
|
static
|
fromXML(ResourceFile resource)
Returns Object deserialized from XML text |
|
static
|
fromXML(java.lang.String xml)
Returns Object deserialized from XML content. |
|
static
|
fromXML(java.net.URL url)
Returns Object deserialized from XML text |
|
static com.thoughtworks.xstream.XStream |
getXStream()
Returns global XStream instance configured with all required aliases and converters. |
|
static javax.swing.ImageIcon |
loadImageIcon(java.lang.Object source)
Returns ImageIcon which is read from the source. |
|
static javax.swing.ImageIcon |
loadImageIcon(ResourceFile resource)
Returns ImageIcon which is read from specified ResourceFile. |
|
static java.util.List<javax.swing.ImageIcon> |
loadImagesList(java.lang.Object source)
Returns ImageIcon list which is read from the source. |
|
static java.util.List<javax.swing.ImageIcon> |
loadImagesList(ResourceList resourceList)
Returns ImageIcon list which is read from specified ResourceList. |
|
static ResourceFile |
loadResourceFile(java.lang.Object source)
Returns ResourceFile which is read from the source. |
|
static ResourceList |
loadResourceList(java.lang.Object source)
Returns ResourceList which is read from the source. |
|
static ResourceMap |
loadResourceMap(java.lang.Object source)
Returns ResourceMap which is read from the source. |
|
static java.lang.String |
loadString(java.lang.Object source)
Returns text which is read from the source. |
|
static java.lang.String |
loadString(ResourceFile resource)
Returns text which is read from specified ResourceFile. |
|
static void |
processAnnotations(java.lang.Class type)
Process the annotations of the given type and configure the XStream. |
|
static void |
processAnnotations(java.lang.Class[] types)
Process the annotations of the given types and configure the XStream. |
|
static void |
registerConverter(com.thoughtworks.xstream.converters.Converter converter)
Adds a new converter into converters registry. |
|
static void |
registerConverter(com.thoughtworks.xstream.converters.SingleValueConverter converter)
Adds a new converter into converters registry. |
|
static java.lang.String |
toXML(java.lang.Object obj)
Returns Object serialized into XML. |
|
static void |
toXML(java.lang.Object obj,
java.io.File file)
Serializes Object into XML and writes it into specified file. |
|
static void |
toXML(java.lang.Object obj,
java.io.OutputStream out)
Serializes Object into XML and writes it using a specified OutputStream. |
|
static void |
toXML(java.lang.Object obj,
java.lang.String file)
Serializes Object into XML and writes it into specified file. |
|
static void |
toXML(java.lang.Object obj,
java.io.Writer out)
Serializes Object into XML and writes it using a specified Writer. |
|
static void |
useAttributeFor(java.lang.Class type,
java.lang.String field)
Use an attribute for a field declared in a specific type. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static boolean aliasJdkClasses
public static final ColorConverter colorConverter
public static final InsetsConverter insetsConverter
public static final PasswordConverter passwordConverter
Constructor Detail |
---|
public XmlUtils()
Method Detail |
---|
public static com.thoughtworks.xstream.XStream getXStream()
public static void processAnnotations(java.lang.Class type)
type
- the type with XStream annotationspublic static void processAnnotations(java.lang.Class[] types)
types
- the types with XStream annotationspublic static void alias(java.lang.String name, java.lang.Class type)
name
- Short nametype
- Type to be aliasedpublic static void useAttributeFor(java.lang.Class type, java.lang.String field)
type
- the name of the fieldfield
- the Class containing such fieldpublic static void addImplicitArray(java.lang.Class type, java.lang.String field)
type
- class owning the implicit arrayfield
- name of the array fieldpublic static void addImplicitArray(java.lang.Class type, java.lang.String field, java.lang.String itemName)
type
- class owning the implicit arrayfield
- name of the array field in the ownerTypeitemName
- alias name of the itemspublic static void registerConverter(com.thoughtworks.xstream.converters.Converter converter)
converter
- the new converterpublic static void registerConverter(com.thoughtworks.xstream.converters.SingleValueConverter converter)
converter
- the new converterpublic static <T extends AliasProvider> void alias(java.lang.Class<T> aliasProvider)
T
- specific class typealiasProvider
- AliasProvider ancestor classpublic static void toXML(java.lang.Object obj, java.lang.String file)
obj
- object to serializefile
- output filepublic static void toXML(java.lang.Object obj, java.io.File file)
obj
- object to serializefile
- output filepublic static java.lang.String toXML(java.lang.Object obj)
obj
- object to serialize
public static void toXML(java.lang.Object obj, java.io.Writer out)
obj
- object to serializeout
- output writerpublic static void toXML(java.lang.Object obj, java.io.OutputStream out)
obj
- object to serializeout
- output streampublic static <T> T fromXML(java.io.Reader reader)
T
- read object typereader
- XML text source
public static <T> T fromXML(java.io.InputStream input)
T
- read object typeinput
- XML text source
public static <T> T fromXML(java.net.URL url)
T
- read object typeurl
- XML text source
public static <T> T fromXML(java.io.File file)
T
- read object typefile
- file with XML content
public static <T> T fromXML(java.lang.String xml)
T
- read object typexml
- XML content
public static <T> T fromXML(java.lang.Object source)
T
- read object typesource
- XML text source
public static <T> T fromXML(ResourceFile resource)
T
- read object typeresource
- XML text source description
public static java.lang.String loadString(java.lang.Object source)
source
- one of possible sources: URL, String, File, Reader, InputStream
public static java.lang.String loadString(ResourceFile resource)
resource
- file description
public static javax.swing.ImageIcon loadImageIcon(java.lang.Object source)
source
- one of possible sources: URL, String, File, Reader, InputStream
public static javax.swing.ImageIcon loadImageIcon(ResourceFile resource)
resource
- file description
public static java.util.List<javax.swing.ImageIcon> loadImagesList(java.lang.Object source)
source
- one of possible sources: URL, String, File, Reader, InputStream
public static java.util.List<javax.swing.ImageIcon> loadImagesList(ResourceList resourceList)
resourceList
- ResourceFile list
public static ResourceMap loadResourceMap(java.lang.Object source)
source
- one of possible sources: URL, String, File, Reader, InputStream
public static ResourceList loadResourceList(java.lang.Object source)
source
- one of possible sources: URL, String, File, Reader, InputStream
public static ResourceFile loadResourceFile(java.lang.Object source)
source
- one of possible sources: URL, String, File, Reader, InputStream
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |