public final class XmlUtils
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
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 and Description |
|---|
XmlUtils() |
| Modifier and Type | Method and Description |
|---|---|
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 <T extends AliasProvider> |
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 <T> T |
fromXML(java.io.File file)
Returns Object deserialized from XML content.
|
static <T> T |
fromXML(java.io.InputStream input)
Returns Object deserialized from XML content.
|
static <T> T |
fromXML(java.lang.Object source)
Returns Object deserialized from XML content.
|
static <T> T |
fromXML(java.io.Reader reader)
Returns Object deserialized from XML content.
|
static <T> T |
fromXML(ResourceFile resource)
Returns Object deserialized from XML text
|
static <T> T |
fromXML(java.lang.String xml)
Returns Object deserialized from XML content.
|
static <T> T |
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.
|
public static boolean aliasJdkClasses
public static final ColorConverter colorConverter
public static final InsetsConverter insetsConverter
public static final PasswordConverter passwordConverter
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 serializepublic 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 sourcepublic static <T> T fromXML(java.io.InputStream input)
T - read object typeinput - XML text sourcepublic static <T> T fromXML(java.net.URL url)
T - read object typeurl - XML text sourcepublic static <T> T fromXML(java.io.File file)
T - read object typefile - file with XML contentpublic static <T> T fromXML(java.lang.String xml)
T - read object typexml - XML contentpublic static <T> T fromXML(java.lang.Object source)
T - read object typesource - XML text sourcepublic static <T> T fromXML(ResourceFile resource)
T - read object typeresource - XML text source descriptionpublic static java.lang.String loadString(java.lang.Object source)
source - one of possible sources: URL, String, File, Reader, InputStreampublic static java.lang.String loadString(ResourceFile resource)
resource - file descriptionpublic static javax.swing.ImageIcon loadImageIcon(java.lang.Object source)
source - one of possible sources: URL, String, File, Reader, InputStreampublic static javax.swing.ImageIcon loadImageIcon(ResourceFile resource)
resource - file descriptionpublic static java.util.List<javax.swing.ImageIcon> loadImagesList(java.lang.Object source)
source - one of possible sources: URL, String, File, Reader, InputStreampublic static java.util.List<javax.swing.ImageIcon> loadImagesList(ResourceList resourceList)
resourceList - ResourceFile listpublic static ResourceMap loadResourceMap(java.lang.Object source)
source - one of possible sources: URL, String, File, Reader, InputStreampublic static ResourceList loadResourceList(java.lang.Object source)
source - one of possible sources: URL, String, File, Reader, InputStreampublic static ResourceFile loadResourceFile(java.lang.Object source)
source - one of possible sources: URL, String, File, Reader, InputStream