com.waveset.object
Class AttributeCondition

java.lang.Object
  extended bycom.waveset.util.AbstractXmlObject
      extended bycom.waveset.object.AttributeCondition
All Implemented Interfaces:
AttributeExpression, java.lang.Comparable, javax.naming.Referenceable, XmlObject

public class AttributeCondition
extends AbstractXmlObject
implements java.lang.Comparable, AttributeExpression

AttributeCondition structures query expressions. Typically contains attribute, operator, and value.

Asserts that:
at least one value of the specified attribute compares as specified by the operator to the value(s) of the operand.


Nested Class Summary
static class AttributeCondition.Operator
          A static instance represents each operator supported by the AttributeCondition class.
 
Field Summary
static java.lang.String code_id
           
static java.lang.String ELEMENT
           
protected static Trace trace
           
 
Fields inherited from class com.waveset.util.AbstractXmlObject
_trace
 
Constructor Summary
protected AttributeCondition()
          Protected "empty" constructor for the convenience of subclasses and other classes in this package.
  AttributeCondition(Attribute attribute, AttributeCondition.Operator operator, java.lang.Object operand)
          Describes an attribute-value comparison to a string.
  AttributeCondition(org.w3c.dom.Element e)
          Construct an AttributeCondition from an XML element
  AttributeCondition(java.lang.String xml)
          Construct an AttributeCondition from an XML string
  AttributeCondition(java.lang.String attrName, AttributeCondition.Operator operator, java.lang.Object operand)
          Describes an attribute-value comparison to a string.
  AttributeCondition(java.lang.String attrName, java.lang.String operatorName, java.lang.Object operand)
          Describes an attribute-value comparison to a string.
 
Method Summary
 int compareTo(java.lang.Object o)
           
static AttributeCondition[] convert(WSAttributes attrs)
          Convert WSAttributes argument to an equivalent array of attribute conditions.
 Attribute getAttribute()
           
 java.lang.String getAttrName()
           
 java.lang.String getAttrNameIgnoreCase()
           
 java.lang.String getElementName()
          Return the element name.
 java.lang.Object getOperand()
           
 java.lang.String getOperandAsString()
           
 java.lang.String getOperandIgnoreCase()
           
 AttributeCondition.Operator getOperator()
           
 boolean isMetBy(AttributeValues attrVals)
           
 boolean isMetBy(java.lang.Object attrVal)
          Evaluate this attribute condition against the value.
 boolean isMetBy(java.lang.String stringAttrVal)
          Evaluate this attribute condition against the value.
 boolean isMetBy(WSAttribute attr)
          Test whether the input attribute meets this attribute condition.
 boolean isMetBy(WSAttributes attrs)
           
static void main(java.lang.String[] args)
           
 void parseXml(org.w3c.dom.Element e)
           
 void parseXml(java.lang.String xml)
           
static void println(java.lang.Object o)
          Ubiquitous macro.
static AttributeCondition[] toArray(WSAttributes attrs)
          Convert WSAttributes into an array of AttributeConditions.
 java.lang.String toLdapSearchFilter()
           
static java.util.List toList(java.util.Map attrs)
          Convert a Map of name/value pairs into a List of conditions.
static java.util.List toList(WSAttributes attrs)
          Convert WSAttributes into a List of conditions.
 java.lang.String toLocalizedString(java.util.Locale locale)
          Build a summary of AttributeConditions from the view
 java.lang.String toString()
           
 void toXml(java.lang.StringBuffer b)
          Convert this AttributeCondition to an XML string adding it to the provided buffer.
 void toXml(java.lang.StringBuffer b, int indent)
          Convert this AttributeCondition to an XML string adding it to the provided buffer at the specified indent level
 
Methods inherited from class com.waveset.util.AbstractXmlObject
addXmlHeader, cloneObject, dump, dumpFile, getReference, setTrace, toIdentityString, toVerboseString, toVerboseString, toXml, toXml
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

code_id

public static final java.lang.String code_id
See Also:
Constant Field Values

trace

protected static Trace trace

ELEMENT

public static final java.lang.String ELEMENT
See Also:
Constant Field Values
Constructor Detail

AttributeCondition

protected AttributeCondition()
Protected "empty" constructor for the convenience of subclasses and other classes in this package.


AttributeCondition

public AttributeCondition(java.lang.String attrName,
                          AttributeCondition.Operator operator,
                          java.lang.Object operand)
Describes an attribute-value comparison to a string.

Parameters:
attrName - - the name of the attribute to be compared
operator - - the comparison to be made
operand - - compare to this value.
NOTE: Operand value is converted to a String, except when the operator is Operator.IS_ONE_OF (A.K.A. Operator.IN). In this case, the operand must be a List. Each item in the list is treated as a String.

NOTE: equality and ordinality comparisons are lexical and case-insensitive.


AttributeCondition

public AttributeCondition(Attribute attribute,
                          AttributeCondition.Operator operator,
                          java.lang.Object operand)
Describes an attribute-value comparison to a string.

Parameters:
attribute - - a handle to the attribute to be compared
operator - - the comparison to be made
operand - - compare to this value

NOTE: equality and ordinality comparisons are lexical and case-insensitive.


AttributeCondition

public AttributeCondition(java.lang.String attrName,
                          java.lang.String operatorName,
                          java.lang.Object operand)
Describes an attribute-value comparison to a string.

Parameters:
attrName - - the name of the attribute to be compared.
operatorName - - the (name of the) comparison to be made.
operand - - compare to this value.
NOTE: Operand value is converted to a String, except when the operator is Operator.IS_ONE_OF (A.K.A. Operator.IN). In this case, the operand must be a List. Each item in the list is treated as a String.

NOTE: equality and ordinality comparisons are lexical and case-insensitive.


AttributeCondition

public AttributeCondition(java.lang.String xml)
                   throws WavesetException
Construct an AttributeCondition from an XML string

Parameters:
xml - - an AttributeCondition serialized as an XML string.

AttributeCondition

public AttributeCondition(org.w3c.dom.Element e)
                   throws WavesetException
Construct an AttributeCondition from an XML element

Parameters:
e - - the XML representation of the AttributeCondition to be created
Method Detail

getAttribute

public Attribute getAttribute()

getAttrName

public java.lang.String getAttrName()

getAttrNameIgnoreCase

public java.lang.String getAttrNameIgnoreCase()

getOperator

public AttributeCondition.Operator getOperator()

getOperand

public java.lang.Object getOperand()

getOperandAsString

public java.lang.String getOperandAsString()

getOperandIgnoreCase

public java.lang.String getOperandIgnoreCase()

toString

public java.lang.String toString()

toLocalizedString

public java.lang.String toLocalizedString(java.util.Locale locale)
Build a summary of AttributeConditions from the view


toLdapSearchFilter

public java.lang.String toLdapSearchFilter()
Specified by:
toLdapSearchFilter in interface AttributeExpression
Returns:
equivalent RFC2254 String Format LDAP Search Filter.

isMetBy

public boolean isMetBy(WSAttributes attrs)
Specified by:
isMetBy in interface AttributeExpression
Returns:
true if the attribute expression evaluates to true for the specified attribute values; otherwise false.

isMetBy

public boolean isMetBy(WSAttribute attr)
Test whether the input attribute meets this attribute condition.

For multi-valued attributes, this is a "subset" comparison,

Returns:
true if the attribute contains at least one value that meets the condition; otherwise false.

isMetBy

public boolean isMetBy(AttributeValues attrVals)

isMetBy

public boolean isMetBy(java.lang.Object attrVal)
Evaluate this attribute condition against the value.

Parameters:
attrVal - - the value to test.
Returns:
true if the value meets the condition; otherwise false.

isMetBy

public boolean isMetBy(java.lang.String stringAttrVal)
Evaluate this attribute condition against the value.

Returns:
true if the value meets the condition; otherwise false.
Throws:
java.lang.IllegalArgumentException - if the attribute condition has been improperly initialized.

convert

public static final AttributeCondition[] convert(WSAttributes attrs)
Convert WSAttributes argument to an equivalent array of attribute conditions.


toList

public static final java.util.List toList(WSAttributes attrs)
Convert WSAttributes into a List of conditions. Used in some of the newer more script friendly interfaces where Lists are easier to deal with.


toArray

public static final AttributeCondition[] toArray(WSAttributes attrs)
Convert WSAttributes into an array of AttributeConditions.


toList

public static final java.util.List toList(java.util.Map attrs)
Convert a Map of name/value pairs into a List of conditions. Used in some of the newer more script friendly interfaces.


getElementName

public java.lang.String getElementName()
Description copied from class: AbstractXmlObject
Return the element name.

Specified by:
getElementName in interface XmlObject
Specified by:
getElementName in class AbstractXmlObject

toXml

public void toXml(java.lang.StringBuffer b)
Convert this AttributeCondition to an XML string adding it to the provided buffer.

Overrides:
toXml in class AbstractXmlObject
Parameters:
b - - the buffer to append the XML string to

Merely invokes toXml(b, 0).


toXml

public void toXml(java.lang.StringBuffer b,
                  int indent)
Convert this AttributeCondition to an XML string adding it to the provided buffer at the specified indent level

Specified by:
toXml in interface XmlObject
Specified by:
toXml in class AbstractXmlObject
Parameters:
b - - the buffer to append the XML string to
indent - - how many spaces to indent the XML

parseXml

public void parseXml(java.lang.String xml)
              throws WavesetException
Throws:
WavesetException

parseXml

public void parseXml(org.w3c.dom.Element e)
              throws WavesetException
Throws:
WavesetException

compareTo

public int compareTo(java.lang.Object o)
Specified by:
compareTo in interface java.lang.Comparable

println

public static void println(java.lang.Object o)
Ubiquitous macro.


main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Throws:
java.lang.Exception