final class XmlUtils extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
XmlUtils.ReadMapCallback |
static interface |
XmlUtils.WriteMapCallback |
Modifier and Type | Method and Description |
---|---|
static void |
beginDocument(XmlPullParser parser,
String firstElementName) |
static boolean |
convertValueToBoolean(CharSequence value,
boolean defaultValue) |
static int |
convertValueToInt(CharSequence charSeq,
int defaultValue) |
static int |
convertValueToList(CharSequence value,
String[] options,
int defaultValue) |
static int |
convertValueToUnsignedInt(String value,
int defaultValue) |
static void |
nextElement(XmlPullParser parser) |
static boolean |
nextElementWithin(XmlPullParser parser,
int outerDepth) |
static int |
parseUnsignedIntAttribute(CharSequence charSeq) |
static Bitmap |
readBitmapAttribute(XmlPullParser in,
String name) |
static boolean |
readBooleanAttribute(XmlPullParser in,
String name) |
static boolean |
readBooleanAttribute(XmlPullParser in,
String name,
boolean defaultValue) |
static byte[] |
readByteArrayAttribute(XmlPullParser in,
String name) |
static float |
readFloatAttribute(XmlPullParser in,
String name) |
static int |
readIntAttribute(XmlPullParser in,
String name) |
static int |
readIntAttribute(XmlPullParser in,
String name,
int defaultValue) |
static ArrayList |
readListXml(InputStream in)
Read an ArrayList from an InputStream containing XML.
|
static long |
readLongAttribute(XmlPullParser in,
String name) |
static long |
readLongAttribute(XmlPullParser in,
String name,
long defaultValue) |
static HashMap<String,?> |
readMapXml(InputStream in)
Read a HashMap from an InputStream containing XML.
|
static HashSet |
readSetXml(InputStream in)
Read a HashSet from an InputStream containing XML.
|
static String |
readStringAttribute(XmlPullParser in,
String name) |
static double[] |
readThisDoubleArrayXml(XmlPullParser parser,
String endTag,
String[] name)
Read a double[] object from an XmlPullParser.
|
static int[] |
readThisIntArrayXml(XmlPullParser parser,
String endTag,
String[] name)
Read an int[] object from an XmlPullParser.
|
static ArrayList |
readThisListXml(XmlPullParser parser,
String endTag,
String[] name)
Read an ArrayList object from an XmlPullParser.
|
static long[] |
readThisLongArrayXml(XmlPullParser parser,
String endTag,
String[] name)
Read a long[] object from an XmlPullParser.
|
static HashMap<String,?> |
readThisMapXml(XmlPullParser parser,
String endTag,
String[] name)
Read a HashMap object from an XmlPullParser.
|
static HashMap<String,?> |
readThisMapXml(XmlPullParser parser,
String endTag,
String[] name,
XmlUtils.ReadMapCallback callback)
Read a HashMap object from an XmlPullParser.
|
static HashSet |
readThisSetXml(XmlPullParser parser,
String endTag,
String[] name)
Read a HashSet object from an XmlPullParser.
|
static String[] |
readThisStringArrayXml(XmlPullParser parser,
String endTag,
String[] name)
Read a String[] object from an XmlPullParser.
|
static Uri |
readUriAttribute(XmlPullParser in,
String name) |
static Object |
readValueXml(XmlPullParser parser,
String[] name)
Read a flattened object from an XmlPullParser.
|
static void |
skipCurrentTag(XmlPullParser parser) |
static void |
writeBooleanAttribute(XmlSerializer out,
String name,
boolean value) |
static void |
writeByteArrayAttribute(XmlSerializer out,
String name,
byte[] value) |
static void |
writeByteArrayXml(byte[] val,
String name,
XmlSerializer out)
Flatten a byte[] into an XmlSerializer.
|
static void |
writeDoubleArrayXml(double[] val,
String name,
XmlSerializer out)
Flatten a double[] into an XmlSerializer.
|
static void |
writeFloatAttribute(XmlSerializer out,
String name,
float value) |
static void |
writeIntArrayXml(int[] val,
String name,
XmlSerializer out)
Flatten an int[] into an XmlSerializer.
|
static void |
writeIntAttribute(XmlSerializer out,
String name,
int value) |
static void |
writeListXml(List val,
OutputStream out)
Flatten a List into an output stream as XML.
|
static void |
writeListXml(List val,
String name,
XmlSerializer out)
Flatten a List into an XmlSerializer.
|
static void |
writeLongArrayXml(long[] val,
String name,
XmlSerializer out)
Flatten a long[] into an XmlSerializer.
|
static void |
writeLongAttribute(XmlSerializer out,
String name,
long value) |
static void |
writeMapXml(Map val,
OutputStream out)
Flatten a Map into an output stream as XML.
|
static void |
writeMapXml(Map val,
String name,
XmlSerializer out)
Flatten a Map into an XmlSerializer.
|
static void |
writeMapXml(Map val,
String name,
XmlSerializer out,
XmlUtils.WriteMapCallback callback)
Flatten a Map into an XmlSerializer.
|
static void |
writeMapXml(Map val,
XmlSerializer out,
XmlUtils.WriteMapCallback callback)
Flatten a Map into an XmlSerializer.
|
static void |
writeSetXml(Set val,
String name,
XmlSerializer out) |
static void |
writeStringArrayXml(String[] val,
String name,
XmlSerializer out)
Flatten a String[] into an XmlSerializer.
|
static void |
writeStringAttribute(XmlSerializer out,
String name,
String value) |
static void |
writeUriAttribute(XmlSerializer out,
String name,
Uri value) |
static void |
writeValueXml(Object v,
String name,
XmlSerializer out)
Flatten an object's value into an XmlSerializer.
|
public static void skipCurrentTag(XmlPullParser parser) throws XmlPullParserException, IOException
XmlPullParserException
IOException
public static final int convertValueToList(CharSequence value, String[] options, int defaultValue)
public static final boolean convertValueToBoolean(CharSequence value, boolean defaultValue)
public static final int convertValueToInt(CharSequence charSeq, int defaultValue)
public static int convertValueToUnsignedInt(String value, int defaultValue)
public static int parseUnsignedIntAttribute(CharSequence charSeq)
public static final void writeMapXml(Map val, OutputStream out) throws XmlPullParserException, IOException
val
- The map to be flattened.out
- Where to write the XML data.XmlPullParserException
IOException
writeMapXml(Map, String, XmlSerializer)
,
writeListXml(java.util.List, java.io.OutputStream)
,
writeValueXml(java.lang.Object, java.lang.String, org.xmlpull.v1.XmlSerializer)
,
readMapXml(java.io.InputStream)
public static final void writeListXml(List val, OutputStream out) throws XmlPullParserException, IOException
val
- The list to be flattened.out
- Where to write the XML data.XmlPullParserException
IOException
writeListXml(List, String, XmlSerializer)
,
writeMapXml(java.util.Map, java.io.OutputStream)
,
writeValueXml(java.lang.Object, java.lang.String, org.xmlpull.v1.XmlSerializer)
,
readListXml(java.io.InputStream)
public static final void writeMapXml(Map val, String name, XmlSerializer out) throws XmlPullParserException, IOException
val
- The map to be flattened.name
- Name attribute to include with this list's tag, or null for
none.out
- XmlSerializer to write the map into.XmlPullParserException
IOException
writeMapXml(Map, OutputStream)
,
writeListXml(java.util.List, java.io.OutputStream)
,
writeValueXml(java.lang.Object, java.lang.String, org.xmlpull.v1.XmlSerializer)
,
readMapXml(java.io.InputStream)
public static final void writeMapXml(Map val, String name, XmlSerializer out, XmlUtils.WriteMapCallback callback) throws XmlPullParserException, IOException
val
- The map to be flattened.name
- Name attribute to include with this list's tag, or null for
none.out
- XmlSerializer to write the map into.callback
- Method to call when an Object type is not recognized.XmlPullParserException
IOException
writeMapXml(Map, OutputStream)
,
writeListXml(java.util.List, java.io.OutputStream)
,
writeValueXml(java.lang.Object, java.lang.String, org.xmlpull.v1.XmlSerializer)
,
readMapXml(java.io.InputStream)
public static final void writeMapXml(Map val, XmlSerializer out, XmlUtils.WriteMapCallback callback) throws XmlPullParserException, IOException
val
- The map to be flattened.out
- XmlSerializer to write the map into.XmlPullParserException
IOException
writeMapXml(Map, OutputStream)
,
writeListXml(java.util.List, java.io.OutputStream)
,
writeValueXml(java.lang.Object, java.lang.String, org.xmlpull.v1.XmlSerializer)
,
readMapXml(java.io.InputStream)
public static final void writeListXml(List val, String name, XmlSerializer out) throws XmlPullParserException, IOException
val
- The list to be flattened.name
- Name attribute to include with this list's tag, or null for
none.out
- XmlSerializer to write the list into.XmlPullParserException
IOException
writeListXml(List, OutputStream)
,
writeMapXml(java.util.Map, java.io.OutputStream)
,
writeValueXml(java.lang.Object, java.lang.String, org.xmlpull.v1.XmlSerializer)
,
readListXml(java.io.InputStream)
public static final void writeSetXml(Set val, String name, XmlSerializer out) throws XmlPullParserException, IOException
XmlPullParserException
IOException
public static final void writeByteArrayXml(byte[] val, String name, XmlSerializer out) throws XmlPullParserException, IOException
val
- The byte array to be flattened.name
- Name attribute to include with this array's tag, or null for
none.out
- XmlSerializer to write the array into.XmlPullParserException
IOException
writeMapXml(java.util.Map, java.io.OutputStream)
,
writeValueXml(java.lang.Object, java.lang.String, org.xmlpull.v1.XmlSerializer)
public static final void writeIntArrayXml(int[] val, String name, XmlSerializer out) throws XmlPullParserException, IOException
val
- The int array to be flattened.name
- Name attribute to include with this array's tag, or null for
none.out
- XmlSerializer to write the array into.XmlPullParserException
IOException
writeMapXml(java.util.Map, java.io.OutputStream)
,
writeValueXml(java.lang.Object, java.lang.String, org.xmlpull.v1.XmlSerializer)
,
readThisIntArrayXml(org.xmlpull.v1.XmlPullParser, java.lang.String, java.lang.String[])
public static final void writeLongArrayXml(long[] val, String name, XmlSerializer out) throws XmlPullParserException, IOException
val
- The long array to be flattened.name
- Name attribute to include with this array's tag, or null for
none.out
- XmlSerializer to write the array into.XmlPullParserException
IOException
writeMapXml(java.util.Map, java.io.OutputStream)
,
writeValueXml(java.lang.Object, java.lang.String, org.xmlpull.v1.XmlSerializer)
,
readThisIntArrayXml(org.xmlpull.v1.XmlPullParser, java.lang.String, java.lang.String[])
public static final void writeDoubleArrayXml(double[] val, String name, XmlSerializer out) throws XmlPullParserException, IOException
val
- The double array to be flattened.name
- Name attribute to include with this array's tag, or null for
none.out
- XmlSerializer to write the array into.XmlPullParserException
IOException
writeMapXml(java.util.Map, java.io.OutputStream)
,
writeValueXml(java.lang.Object, java.lang.String, org.xmlpull.v1.XmlSerializer)
,
readThisIntArrayXml(org.xmlpull.v1.XmlPullParser, java.lang.String, java.lang.String[])
public static final void writeStringArrayXml(String[] val, String name, XmlSerializer out) throws XmlPullParserException, IOException
val
- The long array to be flattened.name
- Name attribute to include with this array's tag, or null for
none.out
- XmlSerializer to write the array into.XmlPullParserException
IOException
writeMapXml(java.util.Map, java.io.OutputStream)
,
writeValueXml(java.lang.Object, java.lang.String, org.xmlpull.v1.XmlSerializer)
,
readThisIntArrayXml(org.xmlpull.v1.XmlPullParser, java.lang.String, java.lang.String[])
public static final void writeValueXml(Object v, String name, XmlSerializer out) throws XmlPullParserException, IOException
v
- The object to be flattened.name
- Name attribute to include with this value's tag, or null
for none.out
- XmlSerializer to write the object into.XmlPullParserException
IOException
writeMapXml(java.util.Map, java.io.OutputStream)
,
writeListXml(java.util.List, java.io.OutputStream)
,
readValueXml(org.xmlpull.v1.XmlPullParser, java.lang.String[])
public static final HashMap<String,?> readMapXml(InputStream in) throws XmlPullParserException, IOException
in
- The InputStream from which to read.XmlPullParserException
IOException
readListXml(java.io.InputStream)
,
readValueXml(org.xmlpull.v1.XmlPullParser, java.lang.String[])
,
#see #writeMapXml
public static final ArrayList readListXml(InputStream in) throws XmlPullParserException, IOException
in
- The InputStream from which to read.XmlPullParserException
IOException
readMapXml(java.io.InputStream)
,
readValueXml(org.xmlpull.v1.XmlPullParser, java.lang.String[])
,
readThisListXml(org.xmlpull.v1.XmlPullParser, java.lang.String, java.lang.String[])
,
writeListXml(java.util.List, java.io.OutputStream)
public static final HashSet readSetXml(InputStream in) throws XmlPullParserException, IOException
in
- The InputStream from which to read.XmlPullParserException
IOException
readValueXml(org.xmlpull.v1.XmlPullParser, java.lang.String[])
,
readThisSetXml(org.xmlpull.v1.XmlPullParser, java.lang.String, java.lang.String[])
,
writeSetXml(java.util.Set, java.lang.String, org.xmlpull.v1.XmlSerializer)
public static final HashMap<String,?> readThisMapXml(XmlPullParser parser, String endTag, String[] name) throws XmlPullParserException, IOException
parser
- The XmlPullParser from which to read the map data.endTag
- Name of the tag that will end the map, usually "map".name
- An array of one string, used to return the name attribute
of the map's tag.XmlPullParserException
IOException
readMapXml(java.io.InputStream)
public static final HashMap<String,?> readThisMapXml(XmlPullParser parser, String endTag, String[] name, XmlUtils.ReadMapCallback callback) throws XmlPullParserException, IOException
parser
- The XmlPullParser from which to read the map data.endTag
- Name of the tag that will end the map, usually "map".name
- An array of one string, used to return the name attribute
of the map's tag.XmlPullParserException
IOException
readMapXml(java.io.InputStream)
public static final ArrayList readThisListXml(XmlPullParser parser, String endTag, String[] name) throws XmlPullParserException, IOException
parser
- The XmlPullParser from which to read the list data.endTag
- Name of the tag that will end the list, usually "list".name
- An array of one string, used to return the name attribute
of the list's tag.XmlPullParserException
IOException
readListXml(java.io.InputStream)
public static final HashSet readThisSetXml(XmlPullParser parser, String endTag, String[] name) throws XmlPullParserException, IOException
parser
- The XmlPullParser from which to read the set data.endTag
- Name of the tag that will end the set, usually "set".name
- An array of one string, used to return the name attribute
of the set's tag.XmlPullParserException
IOException
readSetXml(java.io.InputStream)
public static final int[] readThisIntArrayXml(XmlPullParser parser, String endTag, String[] name) throws XmlPullParserException, IOException
parser
- The XmlPullParser from which to read the list data.endTag
- Name of the tag that will end the list, usually "list".name
- An array of one string, used to return the name attribute
of the list's tag.XmlPullParserException
IOException
readListXml(java.io.InputStream)
public static final long[] readThisLongArrayXml(XmlPullParser parser, String endTag, String[] name) throws XmlPullParserException, IOException
parser
- The XmlPullParser from which to read the list data.endTag
- Name of the tag that will end the list, usually "list".name
- An array of one string, used to return the name attribute
of the list's tag.XmlPullParserException
IOException
readListXml(java.io.InputStream)
public static final double[] readThisDoubleArrayXml(XmlPullParser parser, String endTag, String[] name) throws XmlPullParserException, IOException
parser
- The XmlPullParser from which to read the list data.endTag
- Name of the tag that will end the list, usually "double-array".name
- An array of one string, used to return the name attribute
of the list's tag.XmlPullParserException
IOException
readListXml(java.io.InputStream)
public static final String[] readThisStringArrayXml(XmlPullParser parser, String endTag, String[] name) throws XmlPullParserException, IOException
parser
- The XmlPullParser from which to read the list data.endTag
- Name of the tag that will end the list, usually "string-array".name
- An array of one string, used to return the name attribute
of the list's tag.XmlPullParserException
IOException
readListXml(java.io.InputStream)
public static final Object readValueXml(XmlPullParser parser, String[] name) throws XmlPullParserException, IOException
parser
- The XmlPullParser from which to read the object.name
- An array of one string, used to return the name attribute
of the value's tag.XmlPullParserException
IOException
readMapXml(java.io.InputStream)
,
readListXml(java.io.InputStream)
,
writeValueXml(java.lang.Object, java.lang.String, org.xmlpull.v1.XmlSerializer)
public static final void beginDocument(XmlPullParser parser, String firstElementName) throws XmlPullParserException, IOException
XmlPullParserException
IOException
public static final void nextElement(XmlPullParser parser) throws XmlPullParserException, IOException
XmlPullParserException
IOException
public static boolean nextElementWithin(XmlPullParser parser, int outerDepth) throws IOException, XmlPullParserException
IOException
XmlPullParserException
public static int readIntAttribute(XmlPullParser in, String name, int defaultValue)
public static int readIntAttribute(XmlPullParser in, String name) throws IOException
IOException
public static void writeIntAttribute(XmlSerializer out, String name, int value) throws IOException
IOException
public static long readLongAttribute(XmlPullParser in, String name, long defaultValue)
public static long readLongAttribute(XmlPullParser in, String name) throws IOException
IOException
public static void writeLongAttribute(XmlSerializer out, String name, long value) throws IOException
IOException
public static float readFloatAttribute(XmlPullParser in, String name) throws IOException
IOException
public static void writeFloatAttribute(XmlSerializer out, String name, float value) throws IOException
IOException
public static boolean readBooleanAttribute(XmlPullParser in, String name)
public static boolean readBooleanAttribute(XmlPullParser in, String name, boolean defaultValue)
public static void writeBooleanAttribute(XmlSerializer out, String name, boolean value) throws IOException
IOException
public static Uri readUriAttribute(XmlPullParser in, String name)
public static void writeUriAttribute(XmlSerializer out, String name, Uri value) throws IOException
IOException
public static String readStringAttribute(XmlPullParser in, String name)
public static void writeStringAttribute(XmlSerializer out, String name, String value) throws IOException
IOException
public static byte[] readByteArrayAttribute(XmlPullParser in, String name)
public static void writeByteArrayAttribute(XmlSerializer out, String name, byte[] value) throws IOException
IOException
public static Bitmap readBitmapAttribute(XmlPullParser in, String name)