| org.cougaar.lib.contract.Operator
Operator | public interface Operator extends UnaryPredicate(Code) | | An extended UnaryPredicate with improved toString,
XML generation, and new "implies" capability.
Operator s feature improved:
- toString in "paren" or "xml" formats
- added XML generation (getXML)
- (most important) comparison capabilities based upon the
behavior of the
Operator
(implies, allows, equals)
The comparison methods will be used for automated analysis, such as
the ability to generate Plugin "contracts" of
publish/subscribe behavior.
Note: The default implementation of Operator
is currently kept in the utility module as "org.cougaar.lib.contract.lang" --
see the "index.html" file there for language details.
See Also: OperatorFactory |
Method Summary | |
boolean | allows(Operator oper)
"(this.allows(oper))" is defined as:
there exists an Object o such that
((this.execute(o) == true) &&
(oper.execute(o) == true)).
Note that this Object might never arise in practice, but
the two Operator s are at least logically compatable.
One often uses publishOp.allows(subscribeOp), since we
are looking to see if any Object might pass both the publishOp
and the subscribeOp. | boolean | equals(Operator oper)
"(this.equals(oper))" is defined as:
for all Objects o1..on,
(this.execute(oi) == oper.execute(oi)). | boolean | execute(Object o) execute method from UnaryPredicate . | Element | getXML(Document doc, int style) Get an XML Element representation in the given style. | Element | getXML(Document doc) Get an XML Element representation in the
DEFAULT_STYLE. | boolean | impliedBy(Operator oper) Equivalent to oper.implies(this). | boolean | implies(Operator oper)
"(this.implies(oper))" is defined as:
for all Objects o1..on,
if (this.execute(oi) == true)
then (oper.execute(oi) == true). | Object | operate(Object o) | void | setConst(String key, Object val) Sets a constant value in the Operator , which is accessed
internally via (get "key").
For example, a paren-style predicate might be
(and (isString) (equals (get "mystr")))
and parsed into Operator op. | String | toString(int style) Convert this to a String . |
DEFAULT_STYLE | int DEFAULT_STYLE(Code) | | Default style for toString -- currently pretty-printed XML.
|
PAREN_FLAG | int PAREN_FLAG(Code) | | Constants for Operator parse and
toString style.
|
PRETTY_FLAG | int PRETTY_FLAG(Code) | | |
VERBOSE_FLAG | int VERBOSE_FLAG(Code) | | |
allows | boolean allows(Operator oper)(Code) | |
"(this.allows(oper))" is defined as:
there exists an Object o such that
((this.execute(o) == true) &&
(oper.execute(o) == true)).
Note that this Object might never arise in practice, but
the two Operator s are at least logically compatable.
One often uses publishOp.allows(subscribeOp), since we
are looking to see if any Object might pass both the publishOp
and the subscribeOp. Although it's logically equivalent
to test subscribeOp.allows(publishOp), the prior form
is likely faster and better supported.
See Also: Operator.implies See Also: Operator.equals |
equals | boolean equals(Operator oper)(Code) | |
"(this.equals(oper))" is defined as:
for all Objects o1..on,
(this.execute(oi) == oper.execute(oi)).
Note that real "program" equivalency is NP-complete (Halting problem),
so this is at best an approximation! The same caveat goes for
implies and allows.
See Also: Operator.implies See Also: Operator.allows |
execute | boolean execute(Object o)(Code) | | execute method from UnaryPredicate .
|
getXML | Element getXML(Document doc, int style)(Code) | | Get an XML Element representation in the given style.
Parameters: style - currently only VERBOSE_FLAG is used |
impliedBy | boolean impliedBy(Operator oper)(Code) | | Equivalent to oper.implies(this).
|
implies | boolean implies(Operator oper)(Code) | |
"(this.implies(oper))" is defined as:
for all Objects o1..on,
if (this.execute(oi) == true)
then (oper.execute(oi) == true).
Note that there might never be an Object where this.execute(o)
is true, and oper might match other Objects.
One can use "implies" to see if the given oper will
"fire" if this Operator fires.
See Also: Operator.allows See Also: Operator.equals |
operate | Object operate(Object o)(Code) | | operate method acts like execute, but returns
an Object -- UnaryPredicate users should
use execute instead!
|
setConst | void setConst(String key, Object val)(Code) | | Sets a constant value in the Operator , which is accessed
internally via (get "key").
For example, a paren-style predicate might be
(and (isString) (equals (get "mystr")))
and parsed into Operator op. One can then set
the value of variable "mystr" to be the String
"foo" via
op.setConst("mystr", "foo")
and the predicate will behave as
(and (isString) (equals (get "foo")))
One can also specify the expected type of the constant to be
other than String within the predicate via
(and (isInteger) (equals (get "myint" "Integer")))
and then set it via
op.setConst("mystr", new Integer(123))
The goal is to allow predicates to be used as simple parameterized
templates.
Parameters: key - the "get" constant identifier Parameters: val - the new value of the constant |
toString | String toString(int style)(Code) | | Convert this to a String .
Parameters: style - use a bit-mix of *_FLAG constants, such as(XML_FLAG | VERBOSE_FLAG) or(PAREN_FLAG | PRETTY_FLAG), etc |
|
|