org.archive.crawler.settings
Class Constraint

java.lang.Object
  extended by org.archive.crawler.settings.Constraint
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<Constraint>
Direct Known Subclasses:
LegalValueListConstraint, LegalValueTypeConstraint, RegularExpressionConstraint

public abstract class Constraint
extends java.lang.Object
implements java.lang.Comparable<Constraint>, java.io.Serializable

Superclass for constraints that can be set on attribute definitions.

Constraints will be checked against attribute values. If a constraint check fails, an object of type FailedCheck is returned containing information that can be used to build meaningful information to the user.

A constraint has one of three levels:

Author:
John Erik Halse
See Also:
Serialized Form

Nested Class Summary
 class Constraint.FailedCheck
          Objects of this class represents failed constraint checks.
 
Field Summary
(package private) static long serialVersionUID
           
 
Constructor Summary
Constraint(java.util.logging.Level level, java.lang.String msg)
          Constructs a new Constraint.
 
Method Summary
 Constraint.FailedCheck check(CrawlerSettings settings, ComplexType owner, Type definition, java.lang.Object value)
          Run the check.
 int compareTo(Constraint o)
          Compare this constraints level to another constraint.
protected  java.lang.String getDefaultMessage()
          Get the default message to return if a check fails.
abstract  Constraint.FailedCheck innerCheck(CrawlerSettings settings, ComplexType owner, Type definition, java.lang.Object value)
          The method all subclasses should implement to do the actual checking.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

static final long serialVersionUID
See Also:
Constant Field Values
Constructor Detail

Constraint

public Constraint(java.util.logging.Level level,
                  java.lang.String msg)
Constructs a new Constraint.

Parameters:
level - the level for this constraint.
msg - default message to return if the check fails.
Method Detail

check

public final Constraint.FailedCheck check(CrawlerSettings settings,
                                          ComplexType owner,
                                          Type definition,
                                          java.lang.Object value)
Run the check.

Parameters:
owner - the ComplexType owning the attribute to check.
definition - the definition to check the attribute against.
value - the value to check.
Returns:
null if ok, or an instance of Constraint.FailedCheckif the check failed.

innerCheck

public abstract Constraint.FailedCheck innerCheck(CrawlerSettings settings,
                                                  ComplexType owner,
                                                  Type definition,
                                                  java.lang.Object value)
The method all subclasses should implement to do the actual checking.

Parameters:
owner - the ComplexType owning the attribute to check.
definition - the definition to check the attribute against.
value - the value to check.
Returns:
null if ok, or an instance of Constraint.FailedCheckif the check failed.

getDefaultMessage

protected java.lang.String getDefaultMessage()
Get the default message to return if a check fails.

Returns:
the default message to return if a check fails.

compareTo

public int compareTo(Constraint o)
Compare this constraints level to another constraint. This method is implemented to let constraints be sorted with the highest level first.

Specified by:
compareTo in interface java.lang.Comparable<Constraint>
Parameters:
o - a Constraint to compare to.


Copyright © 2003-2011 Internet Archive. All Rights Reserved.