Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.archive.crawler.settings
Class Constraint

    java.lang.Object
      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:

- `Level.SEVERE`The attribute could not be set whatsoever.
- `Level.WARNING`The attribute is illegal i CrawlJobs, but could be set in profiles. Mostly used as holder value for settings that should be changed for every entity running a crawl.
- `Level.INFO`The attribute has a legal value, but is outside the bounds of what are considered a reasonable value. The user could be warned that she should investigate if the value actally is what she wants it be.

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.FailedCheck`if 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.FailedCheck`if 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.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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