org.osgi.impl.bundle.obr.resource
Class Tag

java.lang.Object
  extended by org.osgi.impl.bundle.obr.resource.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 content)
          Construct a new Tag with a single string as content.
Tag(String name, String[] attributes)
          Construct a new Tag with a name and a set of attributes.
 
Method Summary
 void addAttribute(String key, Date value)
          Add a new date attribute.
 void addAttribute(String key, int value)
          Add a new attribute.
 void addAttribute(String key, Object value)
          Add a new attribute.
 void addAttribute(String key, String value)
          Add a new 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

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.


getName

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


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.


toString

public String toString()
Return a string representation of this Tag and all its children recursively.

Overrides:
toString in class Object

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.


print

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


select

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


select

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

match

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

getString

public String getString(String path)

getStringContent

public String getStringContent()

getNameSpace

public String getNameSpace()

getNameSpace

public String getNameSpace(String name)

findRecursiveAttribute

public String findRecursiveAttribute(String name)

getLocalName

public String getLocalName()

rename

public void rename(String string)

convert

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


Copyright © 2006-2011 Apache Software Foundation. All Rights Reserved.