|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.lapetus_ltd.api.common.TLptsXmlUtil
public class TLptsXmlUtil
Class Description : The XML Manager is responsible for dealing with XML files and data.
The main functions of this class are the marshal and unmarshal, which in affect read and write
XML data structures to and from streams (files or communication streams).
The unmarshal capabilities is designed to read from files, jar files or URLs.
Refer to the javadoc below, on the unmarshal function for specific details.
unmarshal(java.lang.String, java.lang.Class
Method Summary | ||
---|---|---|
static java.util.List<java.lang.String> |
getDelimitedKeyList(java.lang.String delimitedString,
char delimiter)
Extracts the keys of a delimited string with KVP. |
|
static java.util.List<java.lang.String> |
getDelimitedValueList(java.lang.String delimitedString,
char delimiter)
Extracts the values of a delimited string with KVP. |
|
static java.lang.String |
getIdentifier()
Gets a unique GUUID string in the form of 8-4-4-4-12 hexadecimal characters. |
|
static java.util.List<java.lang.String> |
getTokens(java.lang.String line,
char delimiter)
Extracts the tokens of a delimited string. |
|
static
|
marshal(java.lang.String path,
java.lang.Class<T> typeObject,
java.lang.Object jaxbElement)
This writes a XML file to the hard disk. |
|
static
|
unmarshal(java.lang.String path,
java.lang.Class<T> typeObject)
Reads a XML file from a path on the disk, a URL or the jar resource. |
|
static void |
zI()
Obfuscated, as it is not required by the application. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static java.util.List<java.lang.String> getDelimitedKeyList(java.lang.String delimitedString, char delimiter)
Extracts the keys of a delimited string with KVP.
Notes : Thread Safe : Yes Spawns its own Thread : No May Return NULL : Never. An empty list is returned in the worst case. Example :String input = "key1=value1;key2=value2;key3=value3"; Listkeys = TLptsXmlUtil.getDelimitedKeyList(input,';'); for (String key : keys) System.out.print(key + " "); Result : key1 key2 key3
delimitedString
- in the format key=value;key1=value1; (where ; is the delimiter)delimiter
- this is the character used to break up the tokens of a line
public static java.util.List<java.lang.String> getDelimitedValueList(java.lang.String delimitedString, char delimiter)
Extracts the values of a delimited string with KVP.
Notes : Thread Safe : Yes Spawns its own Thread : No May Return NULL : Never. An empty list is returned in the worst case. Example :String input = "key1=value1;key2=value2;key3=value3"; Listvalues = TLptsXmlUtil.getDelimitedValueList(input,';'); for (String value : values) System.out.print(value + " "); Result : value1 value2 value3
delimitedString
- in the format key=value;key1=value1; (where ; is the delimiter)delimiter
- this is the character used to break up the tokens of a line
public static java.lang.String getIdentifier()
public static java.util.List<java.lang.String> getTokens(java.lang.String line, char delimiter)
Extracts the tokens of a delimited string.
Notes : Thread Safe : Yes Spawns its own Thread : No May Return NULL : Never. An empty list is returned in the worst case. Example :String input = "string1:string2:string3=string4:string5"; Liststrings = TLptsXmlUtil.getTokens(input,':'); for (String string : strings) System.out.print(string + " "); Result : string1 string2 string3=string4 string5
line
- in the format key=value;key1=value1; (where ; is the delimiter)delimiter
- this is the character used to break up the tokens of a line
public static <T> boolean marshal(java.lang.String path, java.lang.Class<T> typeObject, java.lang.Object jaxbElement)
This writes a XML file to the hard disk.
Notes : Thread Safe : Yes Spawns its own Thread : No May Return NULL : Never Example :TLptsWorkspaceType myWs = new TLptsDBWorkspaceType(anotherWorkspace); myWs.SetSplit1Location(100); // change the value ObjectFactory of = new ObjectFactory(); // write it to file. TLptsXmlUtil.marshal("my.file.xml", XLptsDBWorkspaceType.class,of.createXLptsDBWorkspaceType(myWs));
path
- The path and filename on the disk to write to.typeObject
- This is normally a file XLptsXXXX.class, but it can be any generated XSD to class.jaxbElement
- This is the object that needs to be written. The ObjectFactory needs to be employed to create the object.
ie: ObjectFactory of = new ObjectFactory();
Object jaxbEelement = of.createXXXType(object));
TLptsLogger
.public static <T> java.lang.Object unmarshal(java.lang.String path, java.lang.Class<T> typeObject)
Reads a XML file from a path on the disk, a URL or the jar resource.
Notes : This function tries to read the provided path with many combinations.TLptsLogger
String pathToWorkspace = "users/me/lapetus/workspace.xml" XLptsDBWorkspaceType ws = (XLptsDBWorkspaceType) TLptsXmlUtil.unmarshal(pathToWorkspace, XLptsDBWorkspaceType.class); TLptsWorkspaceType myWs = new TLptsDBWorkspaceType(ws); // now it is initialised and I can work with it. myWs.set...
T
- The object of the class type specified in the call to unmarshal.path
- the path of the source of the xml data. This can be a URL like http://... or a directory file /mydir/myfile.xml
or it can be inside a jar file within the application class loaded jars (we just supply the path /path/to/xml/in/jar.xml),
or we supply the whole jar path, ie. file:jar://my.jar!/path/to/my.file.xml if it is elsewhere in a jar file
(not loaded by the current class loader)typeObject
- The class of the object to be read and verified from the xml file.
This is supplied so that the xml subsystem can verify the xml file as being the correct type.
TLptsLogger
.public static void zI()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |