WPI GDC CMS 0.0.1

org.wpi.gdc.cms.db
Class Restriction

java.lang.Object
  |
  +--org.wpi.gdc.cms.db.Restriction
Direct Known Subclasses:
StringRestriction

public abstract class Restriction
extends java.lang.Object

Restrictions describe what values are required for certain fields.

Generally speaking, a restriction should be translatable into a SQL WHERE clause. Restrictions can form a chain, or they can be used specifically to constrain certain fields.

Version:
1.2
Author:
dmpotter

Field Summary
protected  int bool
          Boolean to the next restriction in the chain.
protected  boolean bool_not
          When true, signifies that the boolean logic for this restriction should be reversed; otherwise, the boolean logic is normal.
static int BOOLEAN_AND
          Boolean AND operator.
static int BOOLEAN_OR
          Boolean OR operator.
protected  java.lang.String field
          The field this applies to - varies based on object.
protected  Restriction next
          The next restriction in the chain or null if there is none.
 
Constructor Summary
Restriction()
           
 
Method Summary
 int getBoolean()
          Retrieves the boolean value for the next restriction in the chain.
 java.lang.String getField()
          Retrieves the field.
 boolean getNot()
          Determines if the logic for this restriction is reveresed or not (if it has a logical NOT applied to it).
 void setBoolean(int bool)
          Sets the boolean value for the next restriction in the chain.
 void setField(java.lang.String field)
          Sets the field.
 void setNot(boolean not)
          Sets if the logic for this restriction is reveresed or not (if it has a logical NOT applied to it).
abstract  boolean validate(java.lang.Object o)
          Validate this restriction against a sample object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BOOLEAN_AND

public static final int BOOLEAN_AND
Boolean AND operator.

BOOLEAN_OR

public static final int BOOLEAN_OR
Boolean OR operator.

bool

protected int bool
Boolean to the next restriction in the chain.

One of BOOLEAN_AND or BOOLEAN_OR.

See Also:
BOOLEAN_AND, BOOLEAN_OR

next

protected Restriction next
The next restriction in the chain or null if there is none.

bool_not

protected boolean bool_not
When true, signifies that the boolean logic for this restriction should be reversed; otherwise, the boolean logic is normal.

field

protected java.lang.String field
The field this applies to - varies based on object.

This field can only be null when the field is not important, other uses may result in a java.lang.NullPointerException.

Constructor Detail

Restriction

public Restriction()
Method Detail

getField

public java.lang.String getField()
Retrieves the field.

The field is the portion of an object that this restriction applies to. The various load methods that accept restrictions will list what fields are acceptable.

Returns:
the field.
See Also:
field, setField(String)

setField

public void setField(java.lang.String field)
Sets the field.
Parameters:
field - The new field value.
See Also:
field, getField()

getBoolean

public int getBoolean()
Retrieves the boolean value for the next restriction in the chain.
Returns:
The boolean value, one of BOOLEAN_AND or BOOLEAN_OR.
See Also:
bool, BOOLEAN_AND, BOOLEAN_OR

setBoolean

public void setBoolean(int bool)
Sets the boolean value for the next restriction in the chain.
Parameters:
bool - The boolean value, one of BOOLEAN_AND or BOOLEAN_OR.
Throws:
java.lang.IllegalArgumentException - if the passed value is not one of BOOLEAN_AND or BOOLEAN_OR.
See Also:
bool, BOOLEAN_AND, BOOLEAN_OR

getNot

public boolean getNot()
Determines if the logic for this restriction is reveresed or not (if it has a logical NOT applied to it).
Returns:
true if the logic is inverted, false if not.

setNot

public void setNot(boolean not)
Sets if the logic for this restriction is reveresed or not (if it has a logical NOT applied to it).
Parameters:
true - if the logic is to be inverted, false if not.

validate

public abstract boolean validate(java.lang.Object o)
Validate this restriction against a sample object. (People who write custom extensions should remember to XOR the final result with bool_not to get the proper boolean value.)
Returns:
true if the object matches, false otherwise.

WPI GDC CMS 0.0.1

Copyright © 2001 WPI Game Development Club. All Rights Reserved.