org.ceryle.wiki.plugin.assertion
Class Assertion

java.lang.Object
  extended by org.ceryle.wiki.plugin.query.Expression
      extended by org.ceryle.wiki.plugin.assertion.Assertion
All Implemented Interfaces:
Comparable, Operand, PluginConstants

public class Assertion
extends Expression
implements Comparable, PluginConstants

Every Expression (of which Assertion is a subclass) has a left + operator + right. In this class they are respectively subject, predicate and object. An alternate form is subject, property name and value.

Encapsulates a Wiki Assertion as a struct comprised of its subject, predicate and object. Note that the expression of the Assertion (i.e., the values of its terms) is immutable.

Templates

An Assertion may be designated as a template. When processed into the Topic Map it is scoped as a Template and used to provide role specifications to Associations typed by it. Property Assertions cannot act as templates.

toString() and toXHTML() Methods

There are a variety of static and non-static toString() and toXHTML() methods, the former are designed to provide a non-marked-up ("black and white"), the latter a marked up serialization/representation (in color and/or with links) of the Assertion. The black and white contain no XHTML markup and are used to create the unique base64 hash identifier for the Assertion.

Author:
Murray Altheim
See Also:
Assertion, AssertionEvent, AssertionHandler, Expression

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.ceryle.wiki.plugin.query.Operand
Operand.NullOperand
 
Field Summary
static String CLASS_ASSERTED
          View anchor class attribute value for asserted (query) messages.
static String CLASS_ASSERTION
          View anchor class attribute value for assertion messages.
static String CLASS_DEBUG
          View anchor class attribute value for assertion debugging messages.
static String CLASS_ERROR
          View anchor class attribute value for assertion error messages.
static String CLASS_HIDE
          View anchor class attribute value for hidden assertion messages.
static String CLASS_OBJECT
          View anchor class attribute value for subject.
static String CLASS_PAGENAME
          View anchor class attribute value for page name.
static String CLASS_PREDICATE
          View anchor class attribute value for subject.
static String CLASS_PROPNAME
          Property name class attribute value.
static String CLASS_PROPVALUE
          Property value class attribute value.
static String CLASS_PROTOTYPE
          View anchor class attribute value for assertion prototype (testing) messages.
static String CLASS_SUBJECT
          View anchor class attribute value for subject.
static String PAGE_ATTRIB_ASSERTIONS
          The set of assertions for a given wiki page is stored in an attribute identified by this string constant.
static String Span_blue
           
static String Span_green
           
static String Span_red
           
static String SpClnSpObjSp
           
static String SpClnSpSubSp
           
static String SpCmaSp
           
static String SpLBrSp
           
static String SpRBrSpTemp
           
 
Fields inherited from class org.ceryle.wiki.plugin.query.Expression
EMPTY, m_left, m_operator, m_parser, m_right
 
Fields inherited from interface org.ceryle.wiki.plugin.util.PluginConstants
ACL, AOP, APOS_ENT, ASTERISK, BCL, BOP, BR, CAPCL, CAPOP, CLATT, COLON, COMMA, DIV_class, DIV_style, DIVCL, DOT, EQ, EQQUO, EQSQUO, FALSE, FORMCL, FORMOP, GET, ICL, INPUTOP, IOP, LABELCL, LABELFOR, LABELOP, LCURL, LICL, LIOP, LPAR, LSBR, MT, NBSP, NL, OLCL, OLOP, P_class, PCL, PLUGCL, PLUGO, POP, POST, QUO, QUOCL, QUOETCL, RCURL, RPAR, RSBR, SEMI, SP, SPAN_class, SPANCL, SPANOP, SQUO, TABLECL, TABLEOP, TDCL, TDOP, THCL, THOP, TRCL, TROP, TRUE, TTCL, TTOP, ULCL, ULOP, UNDER
 
Fields inherited from interface org.ceryle.wiki.plugin.query.Operand
NULL
 
Constructor Summary
Assertion(String pagename, Term subject, Predicate predicate, Property property)
          Constructor for an Assertion with the name of the wiki page where it was declared and three requisite components, a Term subject (a form of Operand), a Predicate predicate (assumed as a property assignment predicate or property name), and a Property property.
Assertion(String pagename, Term subject, Predicate predicate, Term object)
          Constructor for an Assertion with the name of the wiki page where it was declared and three requisite components, a Term subject (a form of Operand), a Predicate predicate (a form of Operator), and a Term object (a form of Operand).
 
Method Summary
 int compareTo(Object o)
          Compares this object with the specified object for order.
 boolean equals(Object o)
          Returns true if the parameter is the same Object as this one, or is an Assertion and has the same String representation.
 long getCreated()
          Return the timestamp of when the Assertion was created.
 Term getObject()
          Return this Assertion's object (right Operand, a Term).
 String getPageName()
          Returns the Wiki page name associated with this Assertion (the page upon which the AssertionPlugin was found).
 Predicate getPredicate()
          Return this Assertion's predicate (Operator, a Predicate).
 String getSignature()
          Returns a base 64-encoded version of the String representation of this Assertion, which should be a reliable unique identifier.
static String getSignature(String pagename, String subject, String predicate, String object, boolean isProperty, boolean isTemplate)
          A static utility method that returns a base 64-encoded version of the String representation of an Assertion with the provided parameters, which should be a reliable unique identifier.
 Term getSubject()
          Return this Assertion's subject (left Operand, a Term).
 boolean isPropertyAssignment()
          Return true if this Assertion is a property assignment, by testing to see if it its object (right Operand) is a Property rather than simply a Term.
 boolean isTemplate()
          Returns true if this Assertion is a template.
 void setTemplate(boolean isTemplate)
          Sets the flag indicating this Assertion is or is not a template.
 String toString()
          Return a displayable version of this Assertion.
static String toString(Assertion assertion)
          Return a displayable String version of the provided Assertion.
static String toString(String pagename, String subject, String predicate, String object, boolean isProperty, boolean isTemplate)
          A utility method returning a displayable String version of an Assertion having the provided pagename, subject, predicate, and object (as Strings).
static String toString(String pagename, Term subject, Predicate predicate, Term object, boolean isTemplate)
          A utility method returning a displayable String version of an Assertion having the provided Predicate and Terms.
 String toXHTML()
          Return a displayable version of this assertion.
static String toXHTML(Assertion assertion)
          Return a displayable XHTML version of the Assertion.
static String toXHTML(String pagename, String subject, String predicate, String object, boolean isProperty, boolean isTemplate)
          A utility method returning a displayable XHTML version of an Assertion having the provided pagename, subject, predicate, and object (as Strings).
static String toXHTML(WikiContext context, Assertion assertion)
          Return a displayable XHTML version of the Assertion.
static String toXHTML(WikiContext context, String pagename, String subject, String predicate, String object, boolean isProperty, boolean isTemplate)
          A utility method returning a displayable XHTML version of an Assertion having the provided pagename, subject, predicate, and object (as Strings).
 
Methods inherited from class org.ceryle.wiki.plugin.query.Expression
accepts, evaluateOperand, getLeftOperand, getOperator, getRightOperand, parse
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PAGE_ATTRIB_ASSERTIONS

public static final String PAGE_ATTRIB_ASSERTIONS
The set of assertions for a given wiki page is stored in an attribute identified by this string constant. Its value is "org.ceryle.wiki.plugin.assertions".

See Also:
Constant Field Values

CLASS_ASSERTION

public static String CLASS_ASSERTION
View anchor class attribute value for assertion messages. The default value is "assertion".


CLASS_ASSERTED

public static String CLASS_ASSERTED
View anchor class attribute value for asserted (query) messages. The default value is "asserted".


CLASS_PAGENAME

public static String CLASS_PAGENAME
View anchor class attribute value for page name. The default value is "ass_page".


CLASS_SUBJECT

public static String CLASS_SUBJECT
View anchor class attribute value for subject. The default value is "ass_sub".


CLASS_PREDICATE

public static String CLASS_PREDICATE
View anchor class attribute value for subject. The default value is "ass_prd".


CLASS_OBJECT

public static String CLASS_OBJECT
View anchor class attribute value for subject. The default value is "ass_obj".


CLASS_PROPNAME

public static String CLASS_PROPNAME
Property name class attribute value. The default value is "ass_pnam".


CLASS_PROPVALUE

public static String CLASS_PROPVALUE
Property value class attribute value. The default value is "ass_pval".


CLASS_DEBUG

public static String CLASS_DEBUG
View anchor class attribute value for assertion debugging messages. The default value is "ass_debug".


CLASS_ERROR

public static String CLASS_ERROR
View anchor class attribute value for assertion error messages. The default value is "ass_error".


CLASS_PROTOTYPE

public static String CLASS_PROTOTYPE
View anchor class attribute value for assertion prototype (testing) messages. The default value is "ass_proto".


CLASS_HIDE

public static String CLASS_HIDE
View anchor class attribute value for hidden assertion messages. The default value is "ass_hide".


Span_red

public static final String Span_red

Span_green

public static final String Span_green

Span_blue

public static final String Span_blue

SpLBrSp

public static final String SpLBrSp
See Also:
Constant Field Values

SpClnSpSubSp

public static final String SpClnSpSubSp
See Also:
Constant Field Values

SpCmaSp

public static final String SpCmaSp
See Also:
Constant Field Values

SpClnSpObjSp

public static final String SpClnSpObjSp
See Also:
Constant Field Values

SpRBrSpTemp

public static final String SpRBrSpTemp
See Also:
Constant Field Values
Constructor Detail

Assertion

public Assertion(String pagename,
                 Term subject,
                 Predicate predicate,
                 Term object)
          throws AssertionException
Constructor for an Assertion with the name of the wiki page where it was declared and three requisite components, a Term subject (a form of Operand), a Predicate predicate (a form of Operator), and a Term object (a form of Operand).

Parameters:
pagename - the wiki page where the Assertion was declared.
subject - the subject Term of the Assertion.
predicate - the Predicate of the Assertion.
object - the object Term of the Assertion.
Throws:
AssertionException - if any of the parameters is null

Assertion

public Assertion(String pagename,
                 Term subject,
                 Predicate predicate,
                 Property property)
          throws AssertionException
Constructor for an Assertion with the name of the wiki page where it was declared and three requisite components, a Term subject (a form of Operand), a Predicate predicate (assumed as a property assignment predicate or property name), and a Property property.

Parameters:
pagename - the wiki page where the Assertion was declared.
subject - the subject Term of the Assertion.
predicate - the Predicate of the Assertion.
property - the asserted Property.
Throws:
AssertionException - if any of the parameters is null
Method Detail

setTemplate

public void setTemplate(boolean isTemplate)
                 throws AssertionException
Sets the flag indicating this Assertion is or is not a template.

Throws:
AssertionException - if this Assertion is a property assertion (since such assertions can't act as templates).

isTemplate

public boolean isTemplate()
Returns true if this Assertion is a template.


getCreated

public long getCreated()
Return the timestamp of when the Assertion was created. This is generated from the Java System method, and is a long value being the difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC.


getPageName

public String getPageName()
Returns the Wiki page name associated with this Assertion (the page upon which the AssertionPlugin was found). This is a convenience method.

Returns:
the Wiki page name associated with this Assertion.

getSubject

public Term getSubject()
Return this Assertion's subject (left Operand, a Term).


getPredicate

public Predicate getPredicate()
Return this Assertion's predicate (Operator, a Predicate).


getObject

public Term getObject()
Return this Assertion's object (right Operand, a Term). If this Assertion is a property assignment, this may safely be cast as a Property.


isPropertyAssignment

public boolean isPropertyAssignment()
Return true if this Assertion is a property assignment, by testing to see if it its object (right Operand) is a Property rather than simply a Term.


equals

public boolean equals(Object o)
Returns true if the parameter is the same Object as this one, or is an Assertion and has the same String representation. This permits the object to be either an Assertion or a three element String array containing the subject, predicate, object triple.

Overrides:
equals in class Object
Throws:
ClassCastException - if the parameter is not an Assertion or a String array.

compareTo

public int compareTo(Object o)
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object. This compares the String representation of the Assertion, or a six element String array containing:
   pagename, subject, predicate, object, isPropertyAssignment, isTemplate
 
 where the last two booleans are simply "true" or "false"
 (and must be provided as such).

Specified by:
compareTo in interface Comparable
Parameters:
o - the Object to compare with this Assertion.
Throws:
ClassCastException - if the parameter is not an Assertion or a String array.
NullPointerException - if the String array contains a null value where required
ArrayIndexOutOfBoundsException - if the String array provided is too small
See Also:
for Assertion equality

toXHTML

public String toXHTML()
Return a displayable version of this assertion.


toXHTML

public static String toXHTML(Assertion assertion)
Return a displayable XHTML version of the Assertion. Note that this does not include link markup; it is for display only.

Parameters:
assertion - the Assertion to display.

toXHTML

public static String toXHTML(WikiContext context,
                             Assertion assertion)
Return a displayable XHTML version of the Assertion. Note that this does not include link markup; it is for display only.

Parameters:
context - optional; if provided the output will include link markup.
assertion - the Assertion to display.

toXHTML

public static String toXHTML(String pagename,
                             String subject,
                             String predicate,
                             String object,
                             boolean isProperty,
                             boolean isTemplate)
A utility method returning a displayable XHTML version of an Assertion having the provided pagename, subject, predicate, and object (as Strings). All parameters are optional; this method does no validation, so the results when nulls are present may not make any sense.

While the pagename is not normally part of the serialized Assertion, it can be displayed prior to the Assertion itself; when present it is prepended as "pn: " (where 'pn' is the page name).

Parameters:
pagename - the wiki page source of the Assertion.
subject - the subject of the Assertion.
predicate - the predicate of the Assertion.
object - the object of the Assertion.
isProperty - when true, the Assertion is treated as a property assertion.
isTemplate - when true, the output is formatted as an Assertion template.

toXHTML

public static String toXHTML(WikiContext context,
                             String pagename,
                             String subject,
                             String predicate,
                             String object,
                             boolean isProperty,
                             boolean isTemplate)
A utility method returning a displayable XHTML version of an Assertion having the provided pagename, subject, predicate, and object (as Strings). If the WikiContext is non-null links to pages will be created. All parameters are optional; this method does no validation, so the results when nulls are present may not make any sense.

While the pagename is not normally part of the serialized Assertion, it can be displayed prior to the Assertion itself; when present it is prepended as "pn: " (where 'pn' is the page name).

Parameters:
context - the WikiContext of the generated markup.
pagename - the wiki page source of the Assertion.
subject - the subject of the Assertion.
predicate - the predicate of the Assertion.
object - the object of the Assertion.
isProperty - when true, the Assertion is treated as a property assertion.
isTemplate - when true, the output is formatted as an Assertion template.

toString

public String toString()
Return a displayable version of this Assertion.

Overrides:
toString in class Expression

toString

public static String toString(Assertion assertion)
Return a displayable String version of the provided Assertion.


toString

public static String toString(String pagename,
                              Term subject,
                              Predicate predicate,
                              Term object,
                              boolean isTemplate)
A utility method returning a displayable String version of an Assertion having the provided Predicate and Terms. Term and Predicate parameters are optional; this method does no validation, so the results when nulls are present may not make any sense.

Parameters:
pagename - the wiki page source of the Assertion.
subject - the subject of the Assertion.
predicate - the predicate of the Assertion.
object - the object of the Assertion.
isTemplate - when true provides XHTML markup for an assertion template.

toString

public static String toString(String pagename,
                              String subject,
                              String predicate,
                              String object,
                              boolean isProperty,
                              boolean isTemplate)
A utility method returning a displayable String version of an Assertion having the provided pagename, subject, predicate, and object (as Strings). All parameters are optional; this method does no validation, so the results when nulls are present may not make any sense.

While the pagename is not normally part of the serialized Assertion, it is a necessary component in the creation of hashes if one wants to differentiate the wiki page source of an assertion; when present it is prepended as "pn: " (where 'pn' is the page name).

Parameters:
pagename - the wiki page source of the Assertion.
subject - the subject of the Assertion.
predicate - the predicate of the Assertion.
object - the object of the Assertion.
isProperty - when true, the Assertion is treated as a property assertion.
isTemplate - when true, the output is formatted as an Assertion template.

getSignature

public String getSignature()
Returns a base 64-encoded version of the String representation of this Assertion, which should be a reliable unique identifier. This is only generated once and cached.


getSignature

public static String getSignature(String pagename,
                                  String subject,
                                  String predicate,
                                  String object,
                                  boolean isProperty,
                                  boolean isTemplate)
A static utility method that returns a base 64-encoded version of the String representation of an Assertion with the provided parameters, which should be a reliable unique identifier. The isProperty and isTemplate parameters are mutually exclusive; if both are true this will throw an IllegalStateException.

Parameters:
pagename - the wiki page source of the Assertion.
subject - the subject of the Assertion.
predicate - the predicate of the Assertion.
object - the object of the Assertion.
isProperty - when true, the Assertion is treated as a property assertion.
isTemplate - when true, the output is formatted as an Assertion template.
Throws:
IllegalStateException - if both isProperty and isTemplate are true.


The Ceryle Project. Copyright ©2001-2007 Murray Altheim, All Rights Reserved. See LICENSE included with distribution.