public class XmlReader extends Object
Note: Special case for the string stored as null
which is in fact stored as NULL
. When
read, the NULL
string is return if the stored string was null
.
Example:
final XmlNode node = XmlFactory.createXmlNode("node"); node.writeBoolean("value", true);
Modifier and Type | Field and Description |
---|---|
protected Document |
document
Document.
|
static String |
NULL
Null string (represents a string stored as
null ). |
protected Element |
root
Root reference.
|
Constructor and Description |
---|
XmlReader(Media media)
Create node from media.
|
XmlReader(String name)
Create node.
|
Modifier and Type | Method and Description |
---|---|
Map<String,String> |
getAttributes()
Get all attributes.
|
String |
getNodeName()
Get the name of the current node.
|
String |
getText()
Return the text inside the node.
|
boolean |
hasAttribute(String attribute)
Check if node has the following attribute.
|
boolean |
hasChild(String child)
Check if node has the following child.
|
boolean |
readBoolean(boolean defaultValue,
String attribute)
Read a boolean.
|
boolean |
readBoolean(String attribute)
Read a boolean.
|
byte |
readByte(byte defaultValue,
String attribute)
Read a byte.
|
byte |
readByte(String attribute)
Read a byte.
|
double |
readDouble(double defaultValue,
String attribute)
Read a double.
|
double |
readDouble(String attribute)
Read a double.
|
float |
readFloat(float defaultValue,
String attribute)
Read a float.
|
float |
readFloat(String attribute)
Read a float.
|
int |
readInteger(int defaultValue,
String attribute)
Read an integer.
|
int |
readInteger(String attribute)
Read an integer.
|
long |
readLong(long defaultValue,
String attribute)
Read a long.
|
long |
readLong(String attribute)
Read a long.
|
short |
readShort(short defaultValue,
String attribute)
Read a short.
|
short |
readShort(String attribute)
Read a short.
|
String |
readString(String attribute)
Read a string.
|
String |
readString(String defaultValue,
String attribute)
Read a string.
|
public static final String NULL
null
).protected final Document document
protected final Element root
public XmlReader(Media media)
media
- The XML media path.LionEngineException
- If error when loading media.public XmlReader(String name)
name
- The node name.LionEngineException
- If error when creating the node.public boolean readBoolean(String attribute)
attribute
- The boolean name.LionEngineException
- If error when reading.public boolean readBoolean(boolean defaultValue, String attribute)
defaultValue
- The value returned if attribute not found.attribute
- The boolean name.public byte readByte(String attribute)
attribute
- The integer name.LionEngineException
- If error when reading.public byte readByte(byte defaultValue, String attribute)
defaultValue
- The value returned if attribute not found.attribute
- The integer name.public short readShort(String attribute)
attribute
- The integer name.LionEngineException
- If error when reading.public short readShort(short defaultValue, String attribute)
defaultValue
- The value returned if attribute not found.attribute
- The integer name.public int readInteger(String attribute)
attribute
- The integer name.LionEngineException
- If error when reading.public int readInteger(int defaultValue, String attribute)
defaultValue
- The value returned if attribute not found.attribute
- The integer name.public long readLong(String attribute)
attribute
- The float name.LionEngineException
- If error when reading.public long readLong(long defaultValue, String attribute)
defaultValue
- The value returned if attribute not found.attribute
- The float name.public float readFloat(String attribute)
attribute
- The float name.LionEngineException
- If error when reading.public float readFloat(float defaultValue, String attribute)
defaultValue
- The value returned if attribute not found.attribute
- The float name.public double readDouble(String attribute)
attribute
- The double name.LionEngineException
- If error when reading.public double readDouble(double defaultValue, String attribute)
defaultValue
- The value returned if attribute not found.attribute
- The double name.public String readString(String attribute)
NULL
, null
will be returned instead.attribute
- The string name.LionEngineException
- If error when reading.public String readString(String defaultValue, String attribute)
NULL
, null
will be returned instead.defaultValue
- The value returned if attribute not found.attribute
- The string name.public String getNodeName()
public String getText()
public Map<String,String> getAttributes()
public boolean hasAttribute(String attribute)
attribute
- The attribute name.true
if attribute exists, false
else.public boolean hasChild(String child)
child
- The child name.true
if child exists, false
else.Copyright © 2017 Byron 3D Games Studio. All rights reserved.