com.waveset.object
Class LogicalExpression

java.lang.Object
  extended bycom.waveset.util.AbstractXmlObject
      extended bycom.waveset.object.LogicalExpression
All Implemented Interfaces:
AttributeExpression, javax.naming.Referenceable, XmlObject
Direct Known Subclasses:
Conjunct, Disjunct

public abstract class LogicalExpression
extends AbstractXmlObject
implements AttributeExpression

A complex expression that contains:

  1. a logical operator; and
  2. a set of attribute expressions.
For instance, a "logical AND" or a "logical OR".

Logical expressions can be nested to form a "tree" of attribute expressions.


Field Summary
protected  java.util.List _nodes
           
protected  LogicalOperator _operator
           
static java.lang.String code_id
           
 
Fields inherited from class com.waveset.util.AbstractXmlObject
_trace
 
Constructor Summary
protected LogicalExpression()
          Protected "empty" constructor for the convenience of subclasses and other classes in this package.
  LogicalExpression(org.w3c.dom.Element e)
          Construct an LogicalExpression from an XML element
  LogicalExpression(java.lang.String xml)
          Construct an LogicalExpression from an XML string
 
Method Summary
 void addNode(AttributeExpression expression)
           
protected  java.lang.String checkMembers()
           
 int compareTo(java.lang.Object o)
           
protected  void confirmMembers()
           
static LogicalExpression convert(AttributeCondition attrCond)
          Convert the specified array of attribute conditions to an equivalent logical expression.
static LogicalExpression convert(AttributeCondition[] attrConds)
          Convert the specified array of attribute conditions to an equivalent logical expression.
static LogicalExpression convert(java.util.List attrConds)
          Convert specified list of attribute conditions to an equivalent logical expression.
static LogicalExpression convert(java.util.Map attrs)
          Convert specified map of attribute values to an equivalent logical expression.
static LogicalExpression convert(WSAttributes attrs)
          Convert specified WSAttributes to an equivalent logical expression.
 boolean equals(java.lang.Object o)
           
 java.util.List getAttributeConditions()
           
abstract  java.lang.String getElementName()
          Return the element name.
 java.util.List getNodes()
           
 LogicalOperator getOperator()
           
 java.lang.String getSymbol()
           
protected  boolean isAConjunct()
           
protected  boolean isADisjunct()
           
 boolean isMetBy(WSAttributes attrs)
           
 void parseXml(org.w3c.dom.Element e)
           
 void parseXml(java.lang.String xml)
           
static LogicalExpression preProcess(Type type, AttributeCondition[] attrConds, ObjectGroupLister objectGroupLister, java.lang.Object conn)
          Bug#11392: Magically transmute any attribute condition that refers to Attribute.CONTAINED_BY_OBJECT_GROUP for a type other than Type.OBJECT_GROUP into an attribute condition that refers to MEMBER_OBJECT_GROUPS.
static void println(java.lang.Object o)
          Ubiquitous macro.
protected  void setNodes(java.util.List nodes)
           
 java.lang.String toLdapSearchFilter()
           
static java.lang.String toLdapSearchFilter(AttributeCondition[] attrConds)
           
 java.lang.String toString()
           
 void toXml(java.lang.StringBuffer b)
          Convert this LogicalExpression to an XML string adding it to the provided buffer.
 void toXml(java.lang.StringBuffer b, int indent)
          Convert this LogicalExpression 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, 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

_operator

protected LogicalOperator _operator

_nodes

protected java.util.List _nodes
Constructor Detail

LogicalExpression

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


LogicalExpression

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

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

LogicalExpression

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

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

getOperator

public LogicalOperator getOperator()

getSymbol

public java.lang.String getSymbol()

getNodes

public java.util.List getNodes()

setNodes

protected void setNodes(java.util.List nodes)

addNode

public void addNode(AttributeExpression expression)

getAttributeConditions

public java.util.List getAttributeConditions()
Returns:
a list of attribute conditions from the authorization filter.

Each leaf node in an attribute expression is an attribute condition. Each interior node is a logical expression that applies a logical operator such as "AND" or "OR" to its "child" nodes.


toString

public java.lang.String toString()

toLdapSearchFilter

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

confirmMembers

protected final void confirmMembers()
Throws:
java.lang.IllegalArgumentException - - if member validation fails

checkMembers

protected java.lang.String checkMembers()
Returns:
error message if validation fails; otherwise true.

isAConjunct

protected boolean isAConjunct()

isADisjunct

protected boolean isADisjunct()

isMetBy

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

convert

public static final LogicalExpression convert(WSAttributes attrs)
Convert specified WSAttributes to an equivalent logical expression.


convert

public static final LogicalExpression convert(java.util.Map attrs)
Convert specified map of attribute values to an equivalent logical expression.


convert

public static final LogicalExpression convert(AttributeCondition attrCond)
Convert the specified array of attribute conditions to an equivalent logical expression.


convert

public static final LogicalExpression convert(AttributeCondition[] attrConds)
Convert the specified array of attribute conditions to an equivalent logical expression.


convert

public static final LogicalExpression convert(java.util.List attrConds)
Convert specified list of attribute conditions to an equivalent logical expression.


preProcess

public static LogicalExpression preProcess(Type type,
                                           AttributeCondition[] attrConds,
                                           ObjectGroupLister objectGroupLister,
                                           java.lang.Object conn)
                                    throws WavesetException
Bug#11392: Magically transmute any attribute condition that refers to Attribute.CONTAINED_BY_OBJECT_GROUP for a type other than Type.OBJECT_GROUP into an attribute condition that refers to MEMBER_OBJECT_GROUPS.

Parameters:
objectGroupLister - - A handle to any class that implements the ObjectGroupLister interface.
conn - - Can be used to pass arbitrary data in to the #identifyObjectGroups method of the ObjectGroupLister.
Returns:
a filter that is equivalent to the specified attribute conditions for the specified type.

Throws:
WavesetException

toLdapSearchFilter

public static final java.lang.String toLdapSearchFilter(AttributeCondition[] attrConds)
Returns:
equivalent RFC2254 String format LDAP Search filter

getElementName

public abstract 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 LogicalExpression 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 LogicalExpression 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

equals

public boolean equals(java.lang.Object o)

compareTo

public int compareTo(java.lang.Object o)

println

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