jsdsi
Class SetTag

java.lang.Object
  extended byjsdsi.Obj
      extended byjsdsi.Tag
          extended byjsdsi.ExprTag
              extended byjsdsi.SetTag
All Implemented Interfaces:
java.io.Serializable

public class SetTag
extends ExprTag

A tag that specifies a set of allowed values.

Note: Currently empty and singleton sets are allowed, but will be made illegal in a future release.

Version:
$Revision: 1.11.2.2 $ $Date: 2005/11/08 03:12:52 $
Author:
Sameer Ajmani, Sean Radford
See Also:
Serialized Form

Field Summary
 
Fields inherited from class jsdsi.Tag
ALL_TAG, NULL_TAG
 
Fields inherited from class jsdsi.Obj
_obj
 
Constructor Summary
SetTag(java.util.Collection c)
          Deprecated. use SetTag(List)
SetTag(ExprTag[] e)
          Creates a new SetTag for a given array of tags.
SetTag(java.util.List list)
          Creates a new SetTag for a given collection of tags.
 
Method Summary
 boolean contains(ExprTag tag)
          Returns true if this SetTag contains the specified tag.
 boolean equals(java.lang.Object that)
           
 ExprTag[] getElements()
           
 int hashCode()
           
 int indexOf(ExprTag tag)
          Returns the index in this list of the first occurrence of the specified tag, or -1 if this list does not contain this tag.
 Tag intersect(SetTag that)
          Returns a new Tag whose elements are the all-pairs intersections of the elements of this and that, excluding non-ExprTags such as NULL_TAG and ALL_TAG.
 Tag intersect(Tag that)
          If that is a SetTag, returns intersect(SetTag).
 Sexp toTagSexp()
           
 
Methods inherited from class jsdsi.Tag
implies, toSexp
 
Methods inherited from class jsdsi.Obj
parseObj, parseObj, readResolve, toByteArray, toString, toString, toTransport
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SetTag

public SetTag(ExprTag[] e)
Creates a new SetTag for a given array of tags.

Note: Currently empty and singleton sets are allowed, but will be made illegal in a future release.

Parameters:
e - array of ExprTags.
Throws:
java.lang.IllegalArgumentException - if e contains less than 2 elements (IN A FUTURE RELEASE)

SetTag

public SetTag(java.util.List list)
Creates a new SetTag for a given collection of tags.

Note: Currently empty and singleton sets are allowed, but will be made illegal in a future release.

Parameters:
list - list of ExprTags.
Throws:
java.lang.IllegalArgumentException - if list contains less than 2 elements (IN A FUTURE RELEASE)

SetTag

public SetTag(java.util.Collection c)
Deprecated. use SetTag(List)

Creates a new SetTag for a given collection of tags.

Note: Currently empty and singleton sets are allowed, but will be made illegal in a future release.

Parameters:
c - collection of ExprTags.
Method Detail

intersect

public Tag intersect(Tag that)
If that is a SetTag, returns intersect(SetTag). Else returns a Tag of the intersections of that with each Tag in this SetTag (if the the result is a single element then that Tag itself is returned.) Otherwise returns NULL_TAG.

Specified by:
intersect in class Tag
Parameters:
that -
Returns:
a SetTag, ExprTag, or Tag.NULL_TAG representing the intersection.
See Also:
Tag.intersect(Tag)

intersect

public Tag intersect(SetTag that)
Returns a new Tag whose elements are the all-pairs intersections of the elements of this and that, excluding non-ExprTags such as NULL_TAG and ALL_TAG.

Parameters:
that -
Returns:
the intersection

equals

public boolean equals(java.lang.Object that)
Specified by:
equals in class Obj
See Also:
Object.equals(Object)

indexOf

public int indexOf(ExprTag tag)
Returns the index in this list of the first occurrence of the specified tag, or -1 if this list does not contain this tag.

Parameters:
tag - tag to search for.
Returns:
the index in this list of the specified tag, or -1 if this SetTag does not contain this tag.

contains

public boolean contains(ExprTag tag)
Returns true if this SetTag contains the specified tag.

Parameters:
tag - tag whose presence in this list is to be tested.
Returns:
true if this list contains the specified tag.

hashCode

public int hashCode()
Specified by:
hashCode in class Obj
See Also:
Object.hashCode()

getElements

public ExprTag[] getElements()
Returns:
the tags of this SetTag.

toTagSexp

public Sexp toTagSexp()
Specified by:
toTagSexp in class Tag
See Also:
Tag.toTagSexp()


Copyright © 2002-2006 JSDSI. All Rights Reserved.