Project Wonder 5.0

er.taggable
Class ERTaggable<T extends ERXGenericRecord>

java.lang.Object
  extended by er.taggable.ERTaggable<T>
Type Parameters:
T - the type of EO that is being wrapped

public class ERTaggable<T extends ERXGenericRecord>
extends java.lang.Object

ERTaggable provides a wrapper around a taggable EO, extending it with tagging-related methods. Typically you would provide a cover method from your EO to an instance of an ERTaggable:

 public class Person extends _Person {
   ...
   public ERTaggable taggable() {
     return ERTaggable.taggable(this);
   }
 }
 

Author:
mschrag

Constructor Summary
protected ERTaggable(ERTaggableEntity<T> entity, T item)
          Constructs an ERTaggable wrapper.
 
Method Summary
protected  void addTag(ERTag tag)
          Adds the tag to this item.
 void addTagNamed(java.lang.String tagName)
          This method applies tags to the target object, by looking up the corresponding Tag object instances and adding it to the tag collection of the object.
 void addTags(boolean clear, java.lang.Object tags)
          This method applies tags to the target object, by parsing the tags parameter into Tag object instances and adding them to the tag collection of the object.
 void addTags(java.lang.Object tags)
          This method applies tags to the target object, by parsing the tags parameter into Tag object instances and adding them to the tag collection of the object.
 void clearTags()
          Removes all of the tags associated with this item.
 boolean equals(java.lang.Object obj)
           
 int hashCode()
           
 boolean isTaggedWith(java.lang.String tagName)
          Checks to see if this object has been tagged with the given tag name.
 boolean isTaggedWithAll(java.lang.Object tags)
          Checks to see if this object has been tagged with all the given tags.
 boolean isTaggedWithAny(java.lang.Object tags)
          Checks to see if this object has been tagged with any of the given tags.
 T item()
          Returns the tagged item that this is taggable is wrapping.
protected  void removeTag(ERTag tag)
          Removes the tag from this item.
 void removeTagNamed(java.lang.String tagName)
          This method removes tags from the target object, by looking up the corresponding Tag object instances and removing them from the tag collection of the object if they exist.
 void removeTags(java.lang.Object tags)
          This method removes tags from the target object, by parsing the tags parameter into Tag object instances and removing them from the tag collection of the object if they exist.
 void setTags(java.lang.Object tags)
          Clears the current tags collection and sets the tag names for this object.
static
<T extends ERXGenericRecord>
ERTaggable<T>
taggable(T eo)
          A factory method for generating a taggable from an EO.
 ERTaggableEntity<T> taggableEntity()
          Returns the taggable entity for this taggable.
 com.webobjects.foundation.NSArray<java.lang.String> tagNames()
          Returns an array of strings containing the tag names applied to this object.
 com.webobjects.foundation.NSArray<ERTag> tags()
          Returns an array of ERTags associated with this item.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ERTaggable

protected ERTaggable(ERTaggableEntity<T> entity,
                     T item)
Constructs an ERTaggable wrapper.

Parameters:
entity - the ERTaggableEntity that corresponds to this item's entity
item - the item to wrap
Method Detail

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

taggable

public static <T extends ERXGenericRecord> ERTaggable<T> taggable(T eo)
A factory method for generating a taggable from an EO.

Type Parameters:
T - the type of the EO being wrapped
Parameters:
eo - the EO being wrapped
Returns:
a taggable wrapper around the EO

item

public T item()
Returns the tagged item that this is taggable is wrapping.

Returns:
the tagged item

taggableEntity

public ERTaggableEntity<T> taggableEntity()
Returns the taggable entity for this taggable.

Returns:
the taggable entity for this taggable

tags

public com.webobjects.foundation.NSArray<ERTag> tags()
Returns an array of ERTags associated with this item.

Returns:
an array of ERTags associated with this item

clearTags

public void clearTags()
Removes all of the tags associated with this item.


removeTags

public void removeTags(java.lang.Object tags)
This method removes tags from the target object, by parsing the tags parameter into Tag object instances and removing them from the tag collection of the object if they exist.

Parameters:
tags - the tags to remove (String to tokenize, NSArray, etc)

removeTagNamed

public void removeTagNamed(java.lang.String tagName)
This method removes tags from the target object, by looking up the corresponding Tag object instances and removing them from the tag collection of the object if they exist.

Parameters:
tagName - the tag to remove (String to tokenize, NSArray, etc)

addTagNamed

public void addTagNamed(java.lang.String tagName)
This method applies tags to the target object, by looking up the corresponding Tag object instances and adding it to the tag collection of the object. If the tag name already exists in the tags table, it just adds a relationship to the existing tag record. If it doesn't exist, it then creates a new Tag record for it. This is equivalent to addTags(false, tags).

Parameters:
tagName - the tag name to add

addTags

public void addTags(java.lang.Object tags)
This method applies tags to the target object, by parsing the tags parameter into Tag object instances and adding them to the tag collection of the object. If the tag name already exists in the tags table, it just adds a relationship to the existing tag record. If it doesn't exist, it then creates a new Tag record for it. This is equivalent to addTags(false, tags).

Parameters:
tags - the tags to add (String to tokenize, NSArray, etc)

addTags

public void addTags(boolean clear,
                    java.lang.Object tags)
This method applies tags to the target object, by parsing the tags parameter into Tag object instances and adding them to the tag collection of the object. If the tag name already exists in the tags table, it just adds a relationship to the existing tag record. If it doesn't exist, it then creates a new Tag record for it.

Parameters:
tags - the tags to add (String to tokenize, NSArray, etc)
clear - if true, existing tags will be removed first

addTag

protected void addTag(ERTag tag)
Adds the tag to this item. This is the single method that to override if you need to perform some additional operations.

Parameters:
tag - the tag to add

removeTag

protected void removeTag(ERTag tag)
Removes the tag from this item. This is the single method that to override if you need to perform some additional operations.

Parameters:
tag - the tag to remove

setTags

public void setTags(java.lang.Object tags)
Clears the current tags collection and sets the tag names for this object. Equivalent of calling addTags(tags, true).

Parameters:
tags - the tags to add (String to tokenize, NSArray, etc)

tagNames

public com.webobjects.foundation.NSArray<java.lang.String> tagNames()
Returns an array of strings containing the tag names applied to this object.

Returns:
an array of strings containing the tag names applied to this object

isTaggedWith

public boolean isTaggedWith(java.lang.String tagName)
Checks to see if this object has been tagged with the given tag name.

Parameters:
tagName - the tag name to check
Returns:
true if this eo is tagged with the given tag name, false otherwise

isTaggedWithAll

public boolean isTaggedWithAll(java.lang.Object tags)
Checks to see if this object has been tagged with all the given tags.

Parameters:
tags - the tags to add (String to tokenize, NSArray, etc)
Returns:
true if this eo is tagged with all of the given tag names, false otherwise

isTaggedWithAny

public boolean isTaggedWithAny(java.lang.Object tags)
Checks to see if this object has been tagged with any of the given tags.

Parameters:
tags - the tags to add (String to tokenize, NSArray, etc)
Returns:
true if this eo is tagged with any of the given tag names, false otherwise

Last updated: Tue, Feb 21, 2017 • 05:45 PM CET

Copyright © 2002 – 2007 Project Wonder.