org.apache.xerces.impl.validation.datatypes.eTypes.Models
Class AbstractProperty

java.lang.Object
  |
  +--org.apache.xerces.impl.validation.datatypes.eTypes.Models.AbstractProperty
Direct Known Subclasses:
PartialOrder

public abstract class AbstractProperty
extends java.lang.Object
implements Property, java.lang.Cloneable

This class models a property which consists of a set of sub-properties, each of which can be constrained. Each of these sub-properties corresponds to a column in the subProp array and requires two static methods. One method (eval) expects the argument to validate and the sub-property constraint as parameters. It returns null if and only if the object fails to satisfy the constraint. The second (merge) expects the result of eval and a 'running total' as arguments and returns a new running total. Note the (1) twin (used by factory methods) assumes that the objects used as constraints are not modified and (2) accumulation assumes that a newly constructed object has null in the third row of subProp[3][#sub-properties].

Version:
$Id: AbstractProperty.java,v 1.1.2.2 2000/10/30 18:14:23 lehors Exp $
Author:
Leonard C. Berman, Jeffrey Rodriguez

Inner Class Summary
 class AbstractProperty.AbstractSummary
           
 
Inner classes inherited from class org.apache.xerces.impl.validation.datatypes.eTypes.Interfaces.Property
Property.ValidationSummary
 
Field Summary
static int classNumberSubProperties
          subProperties are the things that can be accumulated.
static java.util.Hashtable ht
          Table use to keep track of classNumberSubProperties for different classes
protected  java.lang.Boolean required
           
 
Fields inherited from interface org.apache.xerces.impl.validation.datatypes.eTypes.Interfaces.Property
accumulate, classNumberSubProperties, constraint, eval, instance, merge
 
Constructor Summary
  AbstractProperty()
           
protected AbstractProperty(java.lang.Class cl)
          sets underlying type of property
protected AbstractProperty(java.lang.Class cl, java.lang.String str)
          Sets underlying type and name of property
 
Method Summary
 boolean accumulate(java.lang.Object dt)
           
 void add2Report(java.lang.String msg)
           
 java.lang.Object clone()
           
protected abstract  void enableSubProp(java.lang.String name)
          The next method is included to remind developer's that they are responsible for setting the eval and merge functions for subProp's for classes which they define.
 java.lang.Class getJClass()
          The property uses a particular class for its internal representation.
 java.lang.String getName()
          Name of property
 boolean getPossible(int i)
           
 Property.ValidationSummary getReport()
           
 java.lang.Object getSubProp(int i, java.lang.Integer type)
           
protected  java.lang.reflect.Method getSubPropEval(int i)
           
protected  java.lang.reflect.Method getSubPropMerge(int i)
           
 java.lang.String getSubPropName(int i)
           
 int getSubPropNameIndex(java.lang.String s)
           
 void merge()
          For each subProp.
 void msg(java.lang.String m)
           
 void resetAccumulator()
           
 void resetConstraint()
           
 void resetInstance()
           
 void setJClass(java.lang.Class newJClass)
           
 void setName(java.lang.String newName)
           
 void setPossible(boolean newPossible, int i)
           
 void setRequired(java.lang.Boolean newRequired)
           
 void setSubProp(java.lang.Object o, int i, java.lang.Integer type)
           
 void setSubProp(java.lang.Object o, int i, java.lang.String name, java.lang.Integer type)
           
 void setSubPropEval(int i, java.lang.reflect.Method m)
          Sets the method that will be used to determine whether an object satisfies a constraint.
 void setSubPropMerge(int i, java.lang.reflect.Method mergeMethod)
          Sets the method that will be used to accumulate an object representing subProp-i on a sequence of objects validated by this property.
protected  void setSubPropName(int i, java.lang.String s)
           
 java.lang.String toString()
           
 Property twin()
          Returns 'virgin' Property which has same constraint as this, and methods as this but no experience, i.e.
 boolean validate(java.lang.Object obj)
          validate returns false if (a) for some non-null subProp[ Property.constraint ], the result of subPropEval is null, or the validate method of the derived class sets possible[ instance ] = false.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

required

protected java.lang.Boolean required

classNumberSubProperties

public static final int classNumberSubProperties
subProperties are the things that can be accumulated. The following static field should be hidden as sub-properties are added in derived classes.

ht

public static java.util.Hashtable ht
Table use to keep track of classNumberSubProperties for different classes
Constructor Detail

AbstractProperty

public AbstractProperty()

AbstractProperty

protected AbstractProperty(java.lang.Class cl)
sets underlying type of property

AbstractProperty

protected AbstractProperty(java.lang.Class cl,
                           java.lang.String str)
Sets underlying type and name of property
Method Detail

accumulate

public boolean accumulate(java.lang.Object dt)
Specified by:
accumulate in interface Property

add2Report

public void add2Report(java.lang.String msg)

clone

public java.lang.Object clone()
Specified by:
clone in interface Property
Overrides:
clone in class java.lang.Object

enableSubProp

protected abstract void enableSubProp(java.lang.String name)
The next method is included to remind developer's that they are responsible for setting the eval and merge functions for subProp's for classes which they define.

getJClass

public java.lang.Class getJClass()
The property uses a particular class for its internal representation. This function returns that class.
Returns:
java.lang.Class

getName

public java.lang.String getName()
Name of property
Specified by:
getName in interface Property
Returns:
java.lang.String

getPossible

public boolean getPossible(int i)
Parameters:
i - int
Returns:
boolean

getReport

public Property.ValidationSummary getReport()

getSubProp

public final java.lang.Object getSubProp(int i,
                                         java.lang.Integer type)

getSubPropEval

protected java.lang.reflect.Method getSubPropEval(int i)

getSubPropMerge

protected java.lang.reflect.Method getSubPropMerge(int i)

getSubPropName

public java.lang.String getSubPropName(int i)

getSubPropNameIndex

public int getSubPropNameIndex(java.lang.String s)

merge

public void merge()
For each subProp. If there is a subPropMerge method, use it to accumulate the results of a sequence of tests.
Specified by:
merge in interface Property

msg

public final void msg(java.lang.String m)

resetAccumulator

public final void resetAccumulator()

resetConstraint

public final void resetConstraint()

resetInstance

public final void resetInstance()

setJClass

public void setJClass(java.lang.Class newJClass)

setName

public void setName(java.lang.String newName)

setPossible

public void setPossible(boolean newPossible,
                        int i)
Parameters:
newPossible - boolean

setRequired

public void setRequired(java.lang.Boolean newRequired)

setSubProp

public final void setSubProp(java.lang.Object o,
                             int i,
                             java.lang.Integer type)

setSubProp

public final void setSubProp(java.lang.Object o,
                             int i,
                             java.lang.String name,
                             java.lang.Integer type)

setSubPropEval

public void setSubPropEval(int i,
                           java.lang.reflect.Method m)
Sets the method that will be used to determine whether an object satisfies a constraint. representing subProp-i on a sequence of objects validated by this property.
mergeMethod should have signature:
Object mergeMethod(Object currentEval, Object runningAccumulation).
The object it returns will be the runningAccumulation argument on the next call to mergeMethod.

setSubPropMerge

public void setSubPropMerge(int i,
                            java.lang.reflect.Method mergeMethod)
Sets the method that will be used to accumulate an object representing subProp-i on a sequence of objects validated by this property.
mergeMethod should have signature:
Object mergeMethod(Object currentEval, Object runningAccumulation).
The object it returns will be the runningAccumulation argument on the next call to mergeMethod. Note, if mergeMethod is set, it is called at each validation whether or not constraint is present. If constraint is not present, currentEval == currentObject. Also note that for Helpers.and and Helpers.allFalse, the accumulator is initialized to Boolean.TRUE.

setSubPropName

protected void setSubPropName(int i,
                              java.lang.String s)

toString

public final java.lang.String toString()
Overrides:
toString in class java.lang.Object

twin

public Property twin()
Returns 'virgin' Property which has same constraint as this, and methods as this but no experience, i.e. any instance or accumulation data is set to null. This requires 'cloning' any mutable Objects held in AbstractProperty (or derived classes). Current fields include:

non-mutable: name, jClass, required, sValue, method
mutable: possible, subProp, subPropName, subPropMethod, re, enumValues, report

Specified by:
twin in interface Property

validate

public boolean validate(java.lang.Object obj)
validate returns false if (a) for some non-null subProp[ Property.constraint ], the result of subPropEval is null, or the validate method of the derived class sets possible[ instance ] = false. If there is a subPropMerge method, use it to accumulate the results of a sequence of tests. If a subProp has no eval method, this object is referenced as the result of
Specified by:
validate in interface Property


Copyright © 1999-2001 Apache XML Project. All Rights Reserved.