org.osgi.impl.bundle.obr.resource
Class Tag
public
class
Tag
extends Object
The Tag class represents a minimal XML tree. It consist of a named element
with a hashtable of named attributes. Methods are provided to walk the tree
and get its constituents. The content of a Tag is a list that contains String
objects or other Tag objects.
Constructor Summary |
| Tag(String name)
Construct a new Tag with a name. |
| Tag(String name, Map attributes)
Construct a new Tag with a name. |
| Tag(String name, String[] attributes)
Construct a new Tag with a name and a set of attributes. |
| Tag(String name, String content)
Construct a new Tag with a single string as content. |
Method Summary |
void | addAttribute(String key, String value)
Add a new attribute. |
void | addAttribute(String key, Object value)
Add a new attribute. |
void | addAttribute(String key, int value)
Add a new attribute. |
void | addAttribute(String key, Date value)
Add a new date attribute. |
void | addContent(String string)
Add a new content string. |
void | addContent(Tag tag)
Add a new content tag. |
static void | convert(Collection c, String type, Tag parent) |
String | findRecursiveAttribute(String name) |
String | getAttribute(String key)
Return the attribute value. |
String | getAttribute(String key, String deflt)
Return the attribute value or a default if not defined. |
Map | getAttributes()
Answer the attributes as a Dictionary object. |
Vector | getContents()
Return the contents. |
Vector | getContents(String tag)
Return only the tags of the first level of descendants that match the
name. |
String | getContentsAsString()
Return the whole contents as a String (no tag info and attributes). |
void | getContentsAsString(StringBuffer sb)
convenient method to get the contents in a StringBuffer. |
String | getLocalName() |
String | getName()
Return the name of the tag. |
String | getNameSpace() |
String | getNameSpace(String name) |
String | getString(String path) |
String | getStringContent() |
boolean | match(String search, Tag child, Tag mapping) |
void | print(int indent, PrintWriter pw)
Print the tag formatted to a PrintWriter. |
void | rename(String string) |
Tag[] | select(String path)
root/preferences/native/os |
Tag[] | select(String path, Tag mapping) |
String | toString()
Return a string representation of this Tag and all its children
recursively. |
public Tag(String name)
Construct a new Tag with a name.
public Tag(String name, Map attributes)
Construct a new Tag with a name.
public Tag(String name, String[] attributes)
Construct a new Tag with a name and a set of attributes. The attributes
are given as ( name, value ) ...
public Tag(String name, String content)
Construct a new Tag with a single string as content.
public void addAttribute(String key, String value)
Add a new attribute.
public void addAttribute(String key, Object value)
Add a new attribute.
public void addAttribute(String key, int value)
Add a new attribute.
public void addAttribute(String key, Date value)
Add a new date attribute. The date is formatted as the SimpleDateFormat
describes at the top of this class.
public void addContent(String string)
Add a new content string.
public void addContent(
Tag tag)
Add a new content tag.
public static void convert(Collection c, String type,
Tag parent)
public String findRecursiveAttribute(String name)
public String getAttribute(String key)
Return the attribute value.
public String getAttribute(String key, String deflt)
Return the attribute value or a default if not defined.
public Map getAttributes()
Answer the attributes as a Dictionary object.
public Vector getContents()
Return the contents.
public Vector getContents(String tag)
Return only the tags of the first level of descendants that match the
name.
public String getContentsAsString()
Return the whole contents as a String (no tag info and attributes).
public void getContentsAsString(StringBuffer sb)
convenient method to get the contents in a StringBuffer.
public String getLocalName()
public String getName()
Return the name of the tag.
public String getNameSpace()
public String getNameSpace(String name)
public String getString(String path)
public String getStringContent()
public boolean match(String search,
Tag child,
Tag mapping)
public void print(int indent, PrintWriter pw)
Print the tag formatted to a PrintWriter.
public void rename(String string)
public
Tag[] select(String path)
root/preferences/native/os
public
Tag[] select(String path,
Tag mapping)
public String toString()
Return a string representation of this Tag and all its children
recursively.