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
voidaddAttribute(String key, String value)
Add a new attribute.
voidaddAttribute(String key, Object value)
Add a new attribute.
voidaddAttribute(String key, int value)
Add a new attribute.
voidaddAttribute(String key, Date value)
Add a new date attribute.
voidaddContent(String string)
Add a new content string.
voidaddContent(Tag tag)
Add a new content tag.
static voidconvert(Collection c, String type, Tag parent)
StringfindRecursiveAttribute(String name)
StringgetAttribute(String key)
Return the attribute value.
StringgetAttribute(String key, String deflt)
Return the attribute value or a default if not defined.
MapgetAttributes()
Answer the attributes as a Dictionary object.
VectorgetContents()
Return the contents.
VectorgetContents(String tag)
Return only the tags of the first level of descendants that match the name.
StringgetContentsAsString()
Return the whole contents as a String (no tag info and attributes).
voidgetContentsAsString(StringBuffer sb)
convenient method to get the contents in a StringBuffer.
StringgetLocalName()
StringgetName()
Return the name of the tag.
StringgetNameSpace()
StringgetNameSpace(String name)
StringgetString(String path)
StringgetStringContent()
booleanmatch(String search, Tag child, Tag mapping)
voidprint(int indent, PrintWriter pw)
Print the tag formatted to a PrintWriter.
voidrename(String string)
Tag[]select(String path)
root/preferences/native/os
Tag[]select(String path, Tag mapping)
StringtoString()
Return a string representation of this Tag and all its children recursively.

Constructor Detail

Tag

public Tag(String name)
Construct a new Tag with a name.

Tag

public Tag(String name, Map attributes)
Construct a new Tag with a name.

Tag

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 ) ...

Tag

public Tag(String name, String content)
Construct a new Tag with a single string as content.

Method Detail

addAttribute

public void addAttribute(String key, String value)
Add a new attribute.

addAttribute

public void addAttribute(String key, Object value)
Add a new attribute.

addAttribute

public void addAttribute(String key, int value)
Add a new attribute.

addAttribute

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.

addContent

public void addContent(String string)
Add a new content string.

addContent

public void addContent(Tag tag)
Add a new content tag.

convert

public static void convert(Collection c, String type, Tag parent)

findRecursiveAttribute

public String findRecursiveAttribute(String name)

getAttribute

public String getAttribute(String key)
Return the attribute value.

getAttribute

public String getAttribute(String key, String deflt)
Return the attribute value or a default if not defined.

getAttributes

public Map getAttributes()
Answer the attributes as a Dictionary object.

getContents

public Vector getContents()
Return the contents.

getContents

public Vector getContents(String tag)
Return only the tags of the first level of descendants that match the name.

getContentsAsString

public String getContentsAsString()
Return the whole contents as a String (no tag info and attributes).

getContentsAsString

public void getContentsAsString(StringBuffer sb)
convenient method to get the contents in a StringBuffer.

getLocalName

public String getLocalName()

getName

public String getName()
Return the name of the tag.

getNameSpace

public String getNameSpace()

getNameSpace

public String getNameSpace(String name)

getString

public String getString(String path)

getStringContent

public String getStringContent()

match

public boolean match(String search, Tag child, Tag mapping)

print

public void print(int indent, PrintWriter pw)
Print the tag formatted to a PrintWriter.

rename

public void rename(String string)

select

public Tag[] select(String path)
root/preferences/native/os

select

public Tag[] select(String path, Tag mapping)

toString

public String toString()
Return a string representation of this Tag and all its children recursively.
Copyright © 2006-2009 Apache Software Foundation. All Rights Reserved.