com.myjavatools.xml
Interface XmlData

All Known Implementing Classes:
BasicXmlData, Rss, Rss.Image, Rss.Item, Rss.Member, Rss.TextInput

public interface XmlData


Nested Class Summary
static interface XmlData.Condition
          XmlData.Condition has just one method that checks whether XmlData satisfies a condition.
 
Method Summary
 XmlData addKid(XmlData kid)
          Adds a kid to the set of kids.
 void addKids(java.util.Collection<? extends XmlData> kids)
          Adds all XmlData elements from given Collection to the set of kids, skipping elements that are not XmlData.
 boolean castKids(java.lang.String type, java.lang.Class<? extends XmlData> clazz)
          Casts kids of specified type to a specified class (actually replacing them with the new instances).
 void cleanAttributes()
          cleans attributes map Just removes all the attributes
 XmlData clone()
          Clones XmlData, same thing as deepCopy.
 boolean equals(java.lang.Object other)
          Compares contents with other Object
 java.util.Collection<? extends XmlData> getAllKids()
          Gets a collection of all kids of XmlData.
 java.lang.String getAttribute(java.lang.String name)
          Gets the value of a specified attribute.
 java.lang.String getAttribute(java.lang.String name, java.lang.String defaultValue)
          Gets the value of a specified attribute; if there is none, returns default value.
 java.util.Map<java.lang.String,java.lang.String> getAttributes()
          Gets a Map of attributes.
 java.lang.String getId()
          Gets the id of XmlData, which is the value of attribute "id".
 XmlData getKid(int position)
          Gets a kid at specified position.
 XmlData getKid(java.lang.String type)
          Gets a kid of specified type, if any.
 XmlData getKid(java.lang.String type, java.lang.String id)
          Gets a kid having specified type and specified id.
 XmlData getKid(java.lang.String type, java.lang.String attribute, java.lang.String value)
          Gets a kid of specified type that has an attribute with a specified value.
 java.lang.String getKidAttribute(java.lang.String type, java.lang.String attribute)
          Gets the value of specified attribute of a kid of specified type, if any
 int getKidCount(java.lang.String type)
          Gets the number of kids of specified type.
 java.util.Collection<? extends XmlData> getKids(java.lang.String type)
          Gets a Collection<? extends XmlData> of kids of specified type.
 java.lang.String getKidValue(java.lang.String type)
          Gets the value of a kid of specified type, if any.
 java.lang.String getName()
          Gets the name of XmlData, which is the value of attribute "name".
 java.lang.String getType()
          Gets XmlData type, which is just a String.
 java.lang.String getValue()
          Gets a value of XmlData, which is just a String.
 XmlData getXmlContent()
          Gets the contents of this XmlData (probably, itself).
 void removeKid(XmlData kid)
          Removes a kid from the set of kids.
 java.util.Collection<? extends XmlData> removeKids(java.lang.String type)
          Removes all kids of given type.
 void replaceKid(XmlData oldKid, XmlData newKid)
          Replaces a kid with another kid.
 XmlData selectTree(XmlData.Condition condition)
           
 void setAttribute(java.lang.String name, java.lang.String value)
          Sets an attribute value.
 void setAttributes(org.xml.sax.AttributeList attributes)
          Sets attributes from an AttributeList.
 void setAttributes(java.util.Map<java.lang.String,java.lang.String> attributes)
          Sets attributes from a Map, name -> value.
 void setAttributes(java.lang.String... attributes)
          Sets attributes from an array of name-value pairs.
 void setKidValue(java.lang.String type, java.lang.String value)
          Sets the value of a kid of specified type, creating it if necessary.
 XmlData setValue(java.lang.String v)
          Sets the value of XmlData.
 void setXmlContent(XmlData org)
          Sets the contents from another XmlData.
 

Method Detail

equals

boolean equals(java.lang.Object other)
Compares contents with other Object

Overrides:
equals in class java.lang.Object
Parameters:
other - Object
Returns:
boolean

setXmlContent

void setXmlContent(XmlData org)
Sets the contents from another XmlData.

Parameters:
org - original XmlData

getXmlContent

XmlData getXmlContent()
Gets the contents of this XmlData (probably, itself).

Returns:
itself

clone

XmlData clone()
Clones XmlData, same thing as deepCopy.

Returns:
deep copy of itself

cleanAttributes

void cleanAttributes()
cleans attributes map Just removes all the attributes


setAttribute

void setAttribute(java.lang.String name,
                  java.lang.String value)
Sets an attribute value.

Parameters:
name - attribute name
value - attribute value

setAttributes

void setAttributes(java.lang.String... attributes)
Sets attributes from an array of name-value pairs. The preexisting attributes are not removed by this operation.

Parameters:
attributes - a String array consisting of name-value pairs.

setAttributes

void setAttributes(org.xml.sax.AttributeList attributes)
Sets attributes from an AttributeList.

Parameters:
attributes - AttributeList

setAttributes

void setAttributes(java.util.Map<java.lang.String,java.lang.String> attributes)
Sets attributes from a Map, name -> value. The preexisting attributes are not removed by this operation.

Parameters:
attributes - a Map, attributeName -> attributeValue.

getAttributes

java.util.Map<java.lang.String,java.lang.String> getAttributes()
Gets a Map of attributes.

Returns:
a Map that maps attribute names to attribute values, all Strings

getType

java.lang.String getType()
Gets XmlData type, which is just a String.

Returns:
the type string

getValue

java.lang.String getValue()
Gets a value of XmlData, which is just a String.

Returns:
the value

setValue

XmlData setValue(java.lang.String v)
Sets the value of XmlData.

Parameters:
v - new value for XmlData
Returns:
itself

getAttribute

java.lang.String getAttribute(java.lang.String name)
Gets the value of a specified attribute.

Parameters:
name - attribute name
Returns:
attribute value

getAttribute

java.lang.String getAttribute(java.lang.String name,
                              java.lang.String defaultValue)
Gets the value of a specified attribute; if there is none, returns default value.

Parameters:
name - attribute name
defaultValue -
Returns:
attribute value or defaultValue

getName

java.lang.String getName()
Gets the name of XmlData, which is the value of attribute "name".

Returns:
the name string

getId

java.lang.String getId()
Gets the id of XmlData, which is the value of attribute "id".

Returns:
the id string

getAllKids

java.util.Collection<? extends XmlData> getAllKids()
Gets a collection of all kids of XmlData. Normally you would not need it; retrieving kids by type is what one normally does, but you never know...

Returns:
a Collection of XmlData that contains all kids

getKids

java.util.Collection<? extends XmlData> getKids(java.lang.String type)
Gets a Collection<? extends XmlData> of kids of specified type.

Parameters:
type - type of the kids to choose
Returns:
all kids that have the specified type

getKidCount

int getKidCount(java.lang.String type)
Gets the number of kids of specified type.

Parameters:
type -
Returns:
the number of such kids

getKid

XmlData getKid(int position)
Gets a kid at specified position.

Parameters:
position - position of the kid to retrieve, starting with 0;
Returns:
any kid that has this type or null if there is no such kid

getKid

XmlData getKid(java.lang.String type)
Gets a kid of specified type, if any.

Parameters:
type - type of the kid to chose
Returns:
any kid that has this type or null if there is no such kid

getKidValue

java.lang.String getKidValue(java.lang.String type)
Gets the value of a kid of specified type, if any.

Parameters:
type -
Returns:
the value of a kid of specified type or null if there's none

setKidValue

void setKidValue(java.lang.String type,
                 java.lang.String value)
Sets the value of a kid of specified type, creating it if necessary.

Parameters:
type -
value -

getKidAttribute

java.lang.String getKidAttribute(java.lang.String type,
                                 java.lang.String attribute)
Gets the value of specified attribute of a kid of specified type, if any

Parameters:
type - kid type
attribute - attribute name
Returns:
String the value of the attribute of the kid of specified type, or null if ther's none

getKid

XmlData getKid(java.lang.String type,
               java.lang.String attribute,
               java.lang.String value)
Gets a kid of specified type that has an attribute with a specified value.

Parameters:
type - type of the kid to choose
attribute - attribute name
value - attribute value
Returns:
such a kid, if found, or null otherwise

getKid

XmlData getKid(java.lang.String type,
               java.lang.String id)
Gets a kid having specified type and specified id.

Parameters:
type - kid type
id - kid id
Returns:
a kid of specified type that has the value named "id" equal to id

addKid

XmlData addKid(XmlData kid)
Adds a kid to the set of kids.

Parameters:
kid - kid to add
Returns:
the kid

removeKid

void removeKid(XmlData kid)
Removes a kid from the set of kids.

Parameters:
kid - kid to remove

replaceKid

void replaceKid(XmlData oldKid,
                XmlData newKid)
Replaces a kid with another kid.

Parameters:
oldKid - kid to remove
newKid - kid to insert in its place

addKids

void addKids(java.util.Collection<? extends XmlData> kids)
Adds all XmlData elements from given Collection to the set of kids, skipping elements that are not XmlData.

Parameters:
kids -

removeKids

java.util.Collection<? extends XmlData> removeKids(java.lang.String type)
Removes all kids of given type.

Parameters:
type - type of kids to remove
Returns:
Collection<? extends XmlData> of removed kids

selectTree

XmlData selectTree(XmlData.Condition condition)

castKids

boolean castKids(java.lang.String type,
                 java.lang.Class<? extends XmlData> clazz)
Casts kids of specified type to a specified class (actually replacing them with the new instances).

Parameters:
type - type of the kids to cast
clazz - class to cast to
Returns:
true in case of success, false if casting failed somehow To cast, the class has to have a constructor that takes XmlData as the only argument