intarsys runtime library

de.intarsys.tools.tag
Class TagTools

java.lang.Object
  extended by de.intarsys.tools.tag.TagTools

public class TagTools
extends Object

A tool class for implementing a generic String based tagging feature.


Constructor Summary
TagTools()
           
 
Method Summary
static void addTag(Object object, String key, String value)
          Add a tag to an object.
static void addTag(Object object, Tag tag)
          Add a tag to an object.
static void addTags(Object object, List<Tag> pTags)
           
static void addTags(Object object, Map<String,String> pTags)
           
static void addTags(Object object, String tagString)
          Add a tag string to object.
static void addTags(Object object, Tag[] pTags)
           
static Tag getTag(Object object, String key)
          Get the first tag matching "key".
static Tag[] getTags(Object object)
          Get all tags for object.
static Tag[] getTags(Object object, String key)
          Get all tags matching "key".
static String getTagValue(Object object, String key)
          Get the value of the first tag matching "key".
static String[] getTagValues(Object object)
          Get all tags values for object.
static String[] getTagValues(Object object, String key)
          Get all tag values for tags matching "key".
static boolean hasTag(Object object, String key)
          true if object is tagged with "key"
static boolean hasTags(Object object)
          true if object has tags
static void removeTags(Object object, String key)
          Remove all tags for key.
static void setTag(Object object, String key, String value)
          Replace the previous association of tags for key in object with value.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TagTools

public TagTools()
Method Detail

addTag

public static void addTag(Object object,
                          String key,
                          String value)
Add a tag to an object.

Parameters:
object - The object to be tagged
key - The tag key
value - The tag value

addTag

public static void addTag(Object object,
                          Tag tag)
Add a tag to an object.

Parameters:
object - The object to be tagged
tag - The new tag

addTags

public static void addTags(Object object,
                           List<Tag> pTags)

addTags

public static void addTags(Object object,
                           Map<String,String> pTags)

addTags

public static void addTags(Object object,
                           String tagString)
Add a tag string to object. The string is parsed to enumerate all new tags to add.

Parameters:
object - The object to be tagged
tagString - A tag string of the form "key1=value1;key2=value2..."

addTags

public static void addTags(Object object,
                           Tag[] pTags)

getTag

public static Tag getTag(Object object,
                         String key)
Get the first tag matching "key".

Parameters:
object - The tagged object
key - The key value that is searched
Returns:
The first matching tag or null

getTags

public static Tag[] getTags(Object object)
Get all tags for object.

Parameters:
object - The tagged object
Returns:
Get all tags for object.

getTags

public static Tag[] getTags(Object object,
                            String key)
Get all tags matching "key".

Parameters:
object - The tagged object
key - The key value that is searched
Returns:
All matching tags

getTagValue

public static String getTagValue(Object object,
                                 String key)
Get the value of the first tag matching "key".

Parameters:
object - The tagged object
key - The key value that is searched
Returns:
The first matching tag or null

getTagValues

public static String[] getTagValues(Object object)
Get all tags values for object.

Parameters:
object - The tagged object
Returns:
Get all tags values for object.

getTagValues

public static String[] getTagValues(Object object,
                                    String key)
Get all tag values for tags matching "key".

Parameters:
object - The tagged object
key - The key value that is searched
Returns:
all tag values for tags matching "key".

hasTag

public static boolean hasTag(Object object,
                             String key)
true if object is tagged with "key"

Parameters:
object - The tagged object
key - The key value that is searched
Returns:
true if object is tagged with "key"

hasTags

public static boolean hasTags(Object object)
true if object has tags

Parameters:
object - The tagged object
Returns:
true if object has tags

removeTags

public static void removeTags(Object object,
                              String key)
Remove all tags for key.

Parameters:
object - The tagged object
key - The key value for the tags to be removed

setTag

public static void setTag(Object object,
                          String key,
                          String value)
Replace the previous association of tags for key in object with value.

Parameters:
object - The tagged object.
key - The key for the tag to be replaced
value - The new value

intarsys runtime library

Copyright © 2012 intarsys consulting GmbH. All Rights Reserved.