| Package | ch.capi.data.xml |
| Class | public class XMLDescriptor |
| Inheritance | XMLDescriptor Object |
XMLDescriptor is based on a XMLNode that is used
to retrieve all the attributes and subnodes.
| Property | Defined By | ||
|---|---|---|---|
| node : XMLNode [read-only]
Defines the source XMLNode. | XMLDescriptor | ||
| Method | Defined By | ||
|---|---|---|---|
XMLDescriptor(source:Object)
Creates a new XMLDescriptor object. | XMLDescriptor | ||
clone():Object
Returns a deep clone of the current XMLDescriptor. | XMLDescriptor | ||
create(name:String):XMLDescriptor [static]
Creates a new XMLDescriptor object with the specified node name. | XMLDescriptor | ||
getAttribute(name:String, defaultValue:String = null):String
Retrieves the specified attribute. | XMLDescriptor | ||
getAttributeAsBoolean(name:String, defaultValue:Boolean = false):Boolean
Retrieves the specified attribute as Boolean. | XMLDescriptor | ||
getAttributeAsInt(name:String, defaultValue:Number = 0, radix:int = 0):Number
Retrieves the specified attribute as integer. | XMLDescriptor | ||
getAttributeAsNumber(name:String, defaultValue:Number = 0):Number
Retrieves the specified attribute as Number. | XMLDescriptor | ||
getAttributes():Array
Retrieves all the attributes name contained in the XMLDescriptor. | XMLDescriptor | ||
getChild(name:String = null):XMLNode
Retrieves the first XMLNode that matches the specified name. | XMLDescriptor | ||
getChildren(name:String = null):Array
Retrieves all the first level sub-nodes of the current XMLDescriptor. | XMLDescriptor | ||
getName():String
Retrieves the XMLDescriptor node name. | XMLDescriptor | ||
getText(strict:Boolean = false):String
Retrieves the text of the XMLDescriptor node. | XMLDescriptor | ||
getTextAsBoolean(defaultValue:Boolean = false, strict:Boolean = false):Boolean
Retrieves the text node as Boolean. | XMLDescriptor | ||
getTextAsInt(defaultValue:int = 0, radix:int = 0, strict:Boolean = false):int
Retrieves the node text as integer. | XMLDescriptor | ||
getTextAsNumber(defaultValue:Number = 0, strict:Boolean = false):Number
Retrieves the text node as Number. | XMLDescriptor | ||
getTextTrim(strict:Boolean = false):String
Retrieves the trimmed text of the XMLDescriptor node. | XMLDescriptor | ||
hasAttribute(name:String):Boolean
Retrieves if the specified attribute exist in the XMLDescriptor on the root XMLNode. | XMLDescriptor | ||
hasText(strict:Boolean = false):Boolean
Retrieves if the XMLDescriptor has a text. | XMLDescriptor | ||
hasTextTrim(strict:Boolean = false):Boolean
Retrieves if the XMLDescriptor has a trimmed text. | XMLDescriptor | ||
setAttribute(name:String, value:* = null):String
Set the value to the specified attribute. | XMLDescriptor | ||
setName(name:String):void
Set the specified name to the XMLDescriptor. | XMLDescriptor | ||
setText(text:String, strict:Boolean = false):void
Set the specified text to the node. | XMLDescriptor | ||
toString():String
Retrieves the XMLDescriptor as a String. | XMLDescriptor | ||
toXML():XML
Retrieves a XML of the XMLDescriptor. | XMLDescriptor | ||
toXMLDocument():XMLDocument
Retrieves a XMLDocument of the XMLDescriptor. | XMLDescriptor | ||
toXMLNode(deepClone:Boolean = true):XMLNode
Retrieves a cloned XMLNode. | XMLDescriptor | ||
toXMLString():String
Retrieves the XMLDescriptor as a String. | XMLDescriptor | ||
| Method | Defined By | ||
|---|---|---|---|
getTextNode(node:XMLNode = null):XMLNode
Retrieves the first text node in the first level sub-nodes of the specified node. | XMLDescriptor | ||
isTextEnough(text:String = null):Boolean
Retrieves if the specified String is good enough to be considered as a valid node text. | XMLDescriptor | ||
parseSource(source:Object):XMLNode
Parses the specified object to a XMLNode. | XMLDescriptor | ||
| node | property |
node:XMLNode [read-only]
Defines the source XMLNode.
protected function get node():XMLNode| XMLDescriptor | () | Constructor |
public function XMLDescriptor(source:Object)
Creates a new XMLDescriptor object.
source:Object — The source object.
|
See also
| clone | () | method |
public function clone():Object
Returns a deep clone of the current XMLDescriptor.
Object — A deep clone of the current XMLDescriptor.
|
| create | () | method |
public static function create(name:String):XMLDescriptor
Creates a new XMLDescriptor object with the specified node name.
Parameters
name:String — The node name.
|
XMLDescriptor — The created XMLDescriptor.
|
| getAttribute | () | method |
public function getAttribute(name:String, defaultValue:String = null):StringRetrieves the specified attribute.
Parameters
name:String — The attribute name.
| |
defaultValue:String (default = null) — The default value if the attribute doesn't exist.
|
String — The attribute value or the defaultValue if the attribute doesn't exist.
|
| getAttributeAsBoolean | () | method |
public function getAttributeAsBoolean(name:String, defaultValue:Boolean = false):Boolean
Retrieves the specified attribute as Boolean. If the attribute doesn't exist,
false is returned.
Parameters
name:String — The name of the attribute.
| |
defaultValue:Boolean (default = false) — The default value.
|
Boolean — The boolean value or defaultValue if the attribute doesn't exist.
|
See also
| getAttributeAsInt | () | method |
public function getAttributeAsInt(name:String, defaultValue:Number = 0, radix:int = 0):Number
Retrieves the specified attribute as integer. If the attribute isn't found, then the
defaultValue is returned. Elste the specified radix is used to
parse the value with the parseInt global function.
Note that the return type is denoted as Number because int and
uint doesn't support the NaN value.
Parameters
name:String — The attribute name.
| |
defaultValue:Number (default = 0) — The default value.
| |
radix:int (default = 0) — The base for the attribute parsing.
|
Number — The value parsed as integer or the defaultValue (attribute not found) or NaN (not parsable value).
|
See also
| getAttributeAsNumber | () | method |
public function getAttributeAsNumber(name:String, defaultValue:Number = 0):Number
Retrieves the specified attribute as Number. If the attribute isn't found, then the
defaultValue is returned. Else the value is parsed using the parseFloat
global function.
Parameters
name:String — The attribute name.
| |
defaultValue:Number (default = 0) — The default value.
|
Number — The value parsed as a Number or the defaultValue (attribute not found) or NaN (not parsable value).
|
See also
| getAttributes | () | method |
public function getAttributes():Array
Retrieves all the attributes name contained in the XMLDescriptor.
Array — An Array containing the name of the attributes.
|
| getChild | () | method |
public function getChild(name:String = null):XMLNode
Retrieves the first XMLNode that matches the specified name. If the name is not
specified, then the method will return the first child. Be aware that the XMLNode returned is a
direct reference.
Parameters
name:String (default = null) — The node name.
|
XMLNode — The element of null if no node with the specified name has been found.
|
| getChildren | () | method |
public function getChildren(name:String = null):Array
Retrieves all the first level sub-nodes of the current XMLDescriptor. Be aware that the XMLNode returned
are direct references to the XMLNode.
Parameters
name:String (default = null) — The name of the nodes to retrieve.
|
Array — An Array with all the nodes that matches the specified name. If the name
is null, then all the nodes are returned.
|
| getName | () | method |
public function getName():String
Retrieves the XMLDescriptor node name.
String — The node name.
|
| getText | () | method |
public function getText(strict:Boolean = false):String
Retrieves the text of the XMLDescriptor node. This method will retrieves the nodeValue
attribute of the current XMLNode. If the strict argument is true, then this value
will be returned however its value is null. If the strict argument is false and
the nodeValue is null, the method will return the first text node nodeValue property.
Parameters
strict:Boolean (default = false) — Indicates if the text should be retrieved on the first text node if the nodeValue is null.
|
String — The text of the node or null.
|
See also
| getTextAsBoolean | () | method |
public function getTextAsBoolean(defaultValue:Boolean = false, strict:Boolean = false):Boolean
Retrieves the text node as Boolean. If the node has no text, then the
defaultValue is returned.
Parameters
defaultValue:Boolean (default = false) — The default value.
| |
strict:Boolean (default = false) — Indicates if the text should be retrieved on the first text node if the nodeValue is null.
|
Boolean — The value parsed as a Boolean or the defaultValue (attribute not found).
|
See also
| getTextAsInt | () | method |
public function getTextAsInt(defaultValue:int = 0, radix:int = 0, strict:Boolean = false):int
Retrieves the node text as integer. If the node has no text, then the
defaultValue is returned.
Parameters
defaultValue:int (default = 0) — The default value.
| |
radix:int (default = 0) — The base for the attribute parsing.
| |
strict:Boolean (default = false) — Indicates if the text should be retrieved on the first text node if the nodeValue is null.
|
int — The value parsed as integer or the defaultValue (attribute not found) or NaN (not parsable value).
|
See also
| getTextAsNumber | () | method |
public function getTextAsNumber(defaultValue:Number = 0, strict:Boolean = false):Number
Retrieves the text node as Number. If the node has no text, then the
defaultValue is returned.
Parameters
defaultValue:Number (default = 0) — The default value.
| |
strict:Boolean (default = false) — Indicates if the text should be retrieved on the first text node if the nodeValue is null.
|
Number — The value parsed as a Number or the defaultValue (attribute not found).
|
See also
| getTextNode | () | method |
protected function getTextNode(node:XMLNode = null):XMLNode
Retrieves the first text node in the first level sub-nodes of the specified node. If the
specified node is null the current node will be used.
Parameters
node:XMLNode (default = null) — The node to retrieve de text node.
|
XMLNode — The first text node or null if there is no text node.
|
| getTextTrim | () | method |
public function getTextTrim(strict:Boolean = false):String
Retrieves the trimmed text of the XMLDescriptor node.
Parameters
strict:Boolean (default = false) — Indicates if the text should be retrieved on the first text node if the nodeValue is null.
|
String — The text of the node or null if there is only blank chars or no text.
|
See also
| hasAttribute | () | method |
public function hasAttribute(name:String):Boolean
Retrieves if the specified attribute exist in the XMLDescriptor on the root XMLNode.
Parameters
name:String — The attribute name.
|
Boolean — true if the attribute exists.
|
| hasText | () | method |
public function hasText(strict:Boolean = false):Boolean
Retrieves if the XMLDescriptor has a text.
Parameters
strict:Boolean (default = false) — Indicates if the text should be retrieved on the first text node if the nodeValue is null.
|
Boolean — true if the text node is not null and its length is greater than zero.
|
See also
| hasTextTrim | () | method |
public function hasTextTrim(strict:Boolean = false):Boolean
Retrieves if the XMLDescriptor has a trimmed text.
Parameters
strict:Boolean (default = false) — Indicates if the text should be retrieved on the first text node if the nodeValue is null.
|
Boolean — true if the text node is not null and its length is greater than zero.
|
See also
| isTextEnough | () | method |
protected function isTextEnough(text:String = null):Boolean
Retrieves if the specified String is good enough to be considered as a valid node text. This
method simply checks if the specified text is not null and has a length greater than 0.
Parameters
text:String (default = null) — A node text.
|
Boolean — true if the String is good enough.
|
| parseSource | () | method |
protected function parseSource(source:Object):XMLNode
Parses the specified object to a XMLNode. There are the actions of the method :
source is a XML, the String is retrieved and sent to a XMLDocument
to be parsed. Then, the firstChild is returned.source is a XMLDocuement, the firstChild will be returned.source is a XMLNode, it is simply returned.source is a String, a XMLDocument is used to parse it and the firstChild
is returned.For the parsing with the XMLDocument object, the ignoreWhite attribute is always set to true.
Parameters
source:Object — The source object.
|
XMLNode |
ArgumentError If — the source is null or invalid.
|
| setAttribute | () | method |
public function setAttribute(name:String, value:* = null):StringSet the value to the specified attribute.
Parameters
name:String — The attribute name.
| |
value:* (default = null) — The attribute value (null to delete).
|
String — The old value or null if the attribute didn't exist before.
|
| setName | () | method |
public function setName(name:String):void
Set the specified name to the XMLDescriptor.
Parameters
name:String — The name.
|
| setText | () | method |
public function setText(text:String, strict:Boolean = false):voidSet the specified text to the node.
Parameters
text:String — The text to set.
| |
strict:Boolean (default = false) — Indicates if the text can be set in the first text node if the current node is not a text node.
|
See also
| toString | () | method |
public function toString():String
Retrieves the XMLDescriptor as a String. This method will simply use the
XMLNode.toString() method.
String — The XMLDescriptor as a String.
|
| toXML | () | method |
public function toXML():XML
Retrieves a XML of the XMLDescriptor.
XML — A XML instance based on the XMLDescriptor.
|
| toXMLDocument | () | method |
public function toXMLDocument():XMLDocument
Retrieves a XMLDocument of the XMLDescriptor.
XMLDocument — A XMLDocument instance based on the XMLDescriptor.
|
| toXMLNode | () | method |
public function toXMLNode(deepClone:Boolean = true):XMLNode
Retrieves a cloned XMLNode.
Parameters
deepClone:Boolean (default = true) — If the XMLNode must be cloned deeply.
|
XMLNode — The cloned XMLNode.
|
| toXMLString | () | method |
public function toXMLString():String
Retrieves the XMLDescriptor as a String. This method will simply use the
XML.toXMLString() method.
String — The XMLDescriptor as a String.
|
var xml:XML = <node name="myNode">textNode</node>
var desc:XMLDescriptor = new XMLDescriptor(xml);
trace(desc.getText()); //textNode
trace(desc.getAttribute("name")); //myNode
trace(desc.toXMLString());