|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectxmlwise.Plist
public final class Plist
Plist xml handling (serialization and deserialization)
The xml plist dtd can be found at http://www.apple.com/DTDs/PropertyList-1.0.dtd
The plist spec handles 8 types of objects: booleans, real, integers, dates, binary data, strings, arrays (lists) and dictionaries (maps).
The java Plist lib handles converting xml plists to a nested Map<String, Object>
that can be trivially read from java. It also provides a simple way to convert a nested
Map<String, Object>
into an xml plist representation.
The following mapping will be done when converting from plist to Map:
true/false -> Boolean real -> Double integer -> Integer/Long (depends on size, values exceeding an int will be rendered as longs) data -> byte[] string -> String array -> List dict -> Map
When converting from Map -> plist the conversion is as follows:
Boolean -> true/false Float/Double -> real Byte/Short/Integer/Long -> integer byte[] -> data List -> array Map -> dict
Method Summary | |
---|---|
static java.util.Map<java.lang.String,java.lang.Object> |
fromXml(java.lang.String xml)
Create a nested map<String, Object> from a plist xml string using the default mapping. |
static java.util.Map<java.lang.String,java.lang.Object> |
fromXmlElement(XmlElement element)
Create a nested map<String, Object> from an XmlElement using the default mapping. |
static java.util.Map<java.lang.String,java.lang.Object> |
load(java.io.File file)
Create a nested map<String, Object> from a plist xml file using the default mapping. |
static java.util.Map<java.lang.String,java.lang.Object> |
load(java.lang.String filename)
Create a nested map<String, Object> from a plist xml file using the default mapping. |
static java.lang.Object |
loadObject(java.io.File file)
Create an object from a plist xml file using the default mapping. |
static java.lang.Object |
loadObject(java.lang.String filename)
Create an object from a plist xml file using the default mapping. |
static java.lang.Object |
objectFromXml(java.lang.String xml)
Create an object from a plist xml string using the default mapping. |
static java.lang.Object |
objectFromXmlElement(XmlElement element)
Create an object from an XmlElement using the default mapping. |
static void |
store(java.util.Map<java.lang.String,java.lang.Object> data,
java.io.File file)
Store a nested map<String, Object> as a plist using the default mapping. |
static void |
store(java.util.Map<java.lang.String,java.lang.Object> data,
java.lang.String filename)
Store a nested map<String, Object> as a plist using the default mapping. |
static void |
storeObject(java.lang.Object data,
java.io.File file)
Store an object as a plist using the default mapping. |
static void |
storeObject(java.lang.Object object,
java.lang.String filename)
Store an object as a plist using the default mapping. |
static java.lang.String |
toPlist(java.lang.Object o)
Convert an object to a plist xml string using the default mapping. |
static java.lang.String |
toXml(java.util.Map<java.lang.String,java.lang.Object> data)
Convert a nested map<String, Object> as a plist xml string
using the default mapping. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static java.lang.String toXml(java.util.Map<java.lang.String,java.lang.Object> data)
map<String, Object>
as a plist xml string
using the default mapping.
data
- the nested data to store as a plist.
public static java.lang.String toPlist(java.lang.Object o)
o
- the nested object to store as a plist.
public static void store(java.util.Map<java.lang.String,java.lang.Object> data, java.lang.String filename) throws java.io.IOException
map<String, Object>
as a plist using the default mapping.
data
- the nested data to store as a plist.filename
- the destination file to store the data to.
java.io.IOException
- if there was an IO error saving the file.public static void storeObject(java.lang.Object object, java.lang.String filename) throws java.io.IOException
object
- the object to store as a plist.filename
- the destination file to store the data to.
java.io.IOException
- if there was an IO error saving the file.public static void store(java.util.Map<java.lang.String,java.lang.Object> data, java.io.File file) throws java.io.IOException
map<String, Object>
as a plist using the default mapping.
data
- the nested data to store as a plist.file
- the destination File to store the data to.
java.io.IOException
- if there was an IO error saving the file.public static void storeObject(java.lang.Object data, java.io.File file) throws java.io.IOException
data
- the nested data to store as a plist.file
- the destination File to store the data to.
java.io.IOException
- if there was an IO error saving the file.public static java.util.Map<java.lang.String,java.lang.Object> fromXml(java.lang.String xml) throws XmlParseException
map<String, Object>
from a plist xml string using the default mapping.
xml
- the plist xml data as a string.
XmlParseException
- if the plist could not be properly parsed.public static java.util.Map<java.lang.String,java.lang.Object> fromXmlElement(XmlElement element) throws XmlParseException
map<String, Object>
from an XmlElement using the default mapping.
element
- the plist xml data as a string.
XmlParseException
- if the plist could not be properly parsed.public static java.lang.Object objectFromXmlElement(XmlElement element) throws XmlParseException
element
- the element that represents the plist.
XmlParseException
- if the plist could not be properly parsed.public static java.lang.Object objectFromXml(java.lang.String xml) throws XmlParseException
xml
- the plist xml data as a string.
XmlParseException
- if the plist could not be properly parsed.public static java.util.Map<java.lang.String,java.lang.Object> load(java.io.File file) throws XmlParseException, java.io.IOException
map<String, Object>
from a plist xml file using the default mapping.
file
- the File containing the the plist xml.
XmlParseException
- if the plist could not be properly parsed.
java.io.IOException
- if there was an issue reading the plist file.public static java.lang.Object loadObject(java.io.File file) throws XmlParseException, java.io.IOException
file
- the File containing the the plist xml.
XmlParseException
- if the plist could not be properly parsed.
java.io.IOException
- if there was an issue reading the plist file.public static java.util.Map<java.lang.String,java.lang.Object> load(java.lang.String filename) throws XmlParseException, java.io.IOException
map<String, Object>
from a plist xml file using the default mapping.
filename
- the file containing the the plist xml.
XmlParseException
- if the plist could not be properly parsed.
java.io.IOException
- if there was an issue reading the plist file.public static java.lang.Object loadObject(java.lang.String filename) throws XmlParseException, java.io.IOException
filename
- the file containing the the plist xml.
XmlParseException
- if the plist could not be properly parsed.
java.io.IOException
- if there was an issue reading the plist file.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |