com.threerings.antidote.field
Class BaseComponent

java.lang.Object
  extended by org.apache.tools.ant.ProjectComponent
      extended by org.apache.tools.ant.Task
          extended by com.threerings.antidote.field.BaseComponent
All Implemented Interfaces:
Field, ReferenceField, RequiresValidation, Cloneable
Direct Known Subclasses:
BaseField, BaseTask, ListComponent

abstract class BaseComponent
extends Task
implements ReferenceField

A base class for all Ant fields providing useful functionality, such as Violation management. Ideally this class would extend from ProjectComponent. However, Task objects act as fields and end up benefiting greatly from this classes functionality. Use the BaseTask functionality if the implementing class requires Task functionality, otherwise, use BaseField. Package private. Use one of the subclasses.

See Also:
BaseField, BaseTask

Field Summary
 
Fields inherited from class org.apache.tools.ant.Task
target, taskName, taskType, wrapper
 
Fields inherited from class org.apache.tools.ant.ProjectComponent
description, location, project
 
Constructor Summary
BaseComponent()
           
 
Method Summary
protected  void appendViolation(Violation violation)
          Add a violation to the list of violations returned when this Field is validated.
protected  void appendViolationList(List<Violation> violations)
          Add a list of violations to the list of violations returned when this Field is validated.
 Object getReferencedField()
          Returns the Object that this ReferenceField holds a reference to.
 boolean isReference()
          Returns true if this Field is a reference, false otherwise.
protected  void registerField(Class<? extends Field> clazz)
          Register a given Field class as a data type for this Project.
protected  void reportConflictingProperties(Property<?> property, Property<?>... conflicts)
          If the supplied property is set, e.g.
protected  void reportUnsetDependentFields(FieldWrapper<?> field, FieldWrapper<?>... depends)
          If the supplied FieldWrapper is unset then report a violation that the field cannot be unset if any of the supplied list of FieldWrapper objects are set.
protected  void reportUnsetDependentProperties(Property<?> property, Property<?>... dependents)
          If the supplied property is unset, then report a violation that the property cannot be unset if any of the supplied list of Property objects are set.
protected  void reportUnsetField(FieldWrapper<?> field)
          Report as a violation if the supplied FieldWrapper is unset.
protected  void setReference(Reference reference)
          A protected setter meant for concrete classes to optionally support Ant reference setting by using a public setter method which calls this, e.g.
 List<Violation> validate()
          Implement validate() in the base abstract class ensuring correct behavior.
protected  ValidStatus validateChildFields(FieldWrapper<?>... childFields)
          Validate a varargs list of FieldWrapper objects that are children of this Field.
protected  ValidStatus validateChildFields(List<? extends FieldWrapper<?>> childFields)
          Validate a List of FieldWrapper objects that are children of this Field.
protected abstract  void validateField()
          Give each subclass a chance to do field specific validation.
protected  ValidStatus validateOptionalProperties(Property<?>... properties)
          Validate a list of Property objects that are optional.
protected  ValidStatus validateProperties(List<Property<?>> properties)
          Validate a list of Property objects.
protected  ValidStatus validateProperties(Property<?>... properties)
          Validate a varargs list of Property objects.
 
Methods inherited from class org.apache.tools.ant.Task
bindToOwner, execute, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
 
Methods inherited from class org.apache.tools.ant.ProjectComponent
clone, getDescription, getLocation, getProject, setDescription, setLocation, setProject
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.threerings.antidote.field.Field
getFieldName, getLocation
 

Constructor Detail

BaseComponent

BaseComponent()
Method Detail

validate

public final List<Violation> validate()
Implement validate() in the base abstract class ensuring correct behavior. Provide accessors to the list of violations in protected methods.

Specified by:
validate in interface RequiresValidation
See Also:
appendViolation(Violation)

getReferencedField

public Object getReferencedField()
Description copied from interface: ReferenceField
Returns the Object that this ReferenceField holds a reference to. This is not type safe. Use FieldWrapper.getField() which is type safe. Should not be called before ReferenceField.isReference() is checked. If the Reference has not been set, a UnsetReferenceException will be thrown.

Specified by:
getReferencedField in interface ReferenceField

isReference

public boolean isReference()
Description copied from interface: ReferenceField
Returns true if this Field is a reference, false otherwise.

Specified by:
isReference in interface ReferenceField

setReference

protected void setReference(Reference reference)
A protected setter meant for concrete classes to optionally support Ant reference setting by using a public setter method which calls this, e.g. setRefid.


validateField

protected abstract void validateField()
Give each subclass a chance to do field specific validation.


appendViolation

protected void appendViolation(Violation violation)
Add a violation to the list of violations returned when this Field is validated.


appendViolationList

protected void appendViolationList(List<Violation> violations)
Add a list of violations to the list of violations returned when this Field is validated.


validateChildFields

protected ValidStatus validateChildFields(FieldWrapper<?>... childFields)
Validate a varargs list of FieldWrapper objects that are children of this Field.

See Also:
validateChildFields(List)

validateChildFields

protected ValidStatus validateChildFields(List<? extends FieldWrapper<?>> childFields)
Validate a List of FieldWrapper objects that are children of this Field. Return a ValidStatus enum describing the valid state of the list.

Throws:
IllegalArgumentException - If the supplied FieldWrapper is null.

validateProperties

protected ValidStatus validateProperties(Property<?>... properties)
Validate a varargs list of Property objects.

See Also:
validateProperties(List)

validateProperties

protected ValidStatus validateProperties(List<Property<?>> properties)
Validate a list of Property objects. Return a ValidStatus enum describing the valid state of the list.


validateOptionalProperties

protected ValidStatus validateOptionalProperties(Property<?>... properties)
Validate a list of Property objects that are optional. If they are unset, nothing will happen. Returns the ValidStatus of the set properties. If no properties are set, ALL_VALID is returned.


reportUnsetDependentProperties

protected void reportUnsetDependentProperties(Property<?> property,
                                              Property<?>... dependents)
If the supplied property is unset, then report a violation that the property cannot be unset if any of the supplied list of Property objects are set.


reportConflictingProperties

protected void reportConflictingProperties(Property<?> property,
                                           Property<?>... conflicts)
If the supplied property is set, e.g. not null, then report a violation that the property cannot be set if any of the supplied list of Property objects are set.


reportUnsetDependentFields

protected void reportUnsetDependentFields(FieldWrapper<?> field,
                                          FieldWrapper<?>... depends)
If the supplied FieldWrapper is unset then report a violation that the field cannot be unset if any of the supplied list of FieldWrapper objects are set.


reportUnsetField

protected void reportUnsetField(FieldWrapper<?> field)
Report as a violation if the supplied FieldWrapper is unset.


registerField

protected void registerField(Class<? extends Field> clazz)
Register a given Field class as a data type for this Project.



Copyright © 2007-2008 Three Rings Design, Inc. All Rights Reserved. Released under a BSD license.