org.writersforge.catalan.process.workers
Class BaseMetadataHolder

java.lang.Object
  extended byorg.writersforge.catalan.process.workers.BaseMetadataHolder
All Implemented Interfaces:
IMetadataHolder
Direct Known Subclasses:
BaseCommand, BaseJob, BaseWorker

public abstract class BaseMetadataHolder
extends java.lang.Object
implements IMetadataHolder

Minimal implementation of IWorker interface. Includes metadata and default properties, but not the process() method.

Author:
jsheets
See Also:
BaseWorker

Constructor Summary
BaseMetadataHolder(IWorkMetadata metadata)
          Creates a new instance of BaseWorker with full metadata.
BaseMetadataHolder(java.lang.String name, java.lang.String description)
          Creates a new instance of BaseWorker with no property metadata.
BaseMetadataHolder(java.lang.String name, java.lang.String description, PropertyInfo[] required, OptionalPropertyInfo[] optional)
          Creates a new instance of BaseWorker with no property metadata.
 
Method Summary
 IWorkMetadata getMetadata()
          Retrieves metadata associated with this object.
protected  void setOptionalProperties(OptionalPropertyInfo[] info)
          Assigns metadata for all optional properties in this command.
protected  void setRequiredProperties(PropertyInfo[] info)
          Assigns metadata for all required properties in this command.
 void validateProperties(IWorkProperties props, boolean required)
          Validate properties against IWorkMetadata.
 void validateType(PropertyInfo info, java.lang.String name, java.lang.Object value)
          Make sure property type matches any of the required types.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BaseMetadataHolder

public BaseMetadataHolder(java.lang.String name,
                          java.lang.String description)
Creates a new instance of BaseWorker with no property metadata.

Parameters:
name - name of associated object
description - user-friendly description of associated object

BaseMetadataHolder

public BaseMetadataHolder(java.lang.String name,
                          java.lang.String description,
                          PropertyInfo[] required,
                          OptionalPropertyInfo[] optional)
Creates a new instance of BaseWorker with no property metadata.

Parameters:
name - name of associated object
description - user-friendly description of associated object
required - property info for all required properties
optional - property info for all optional properties

BaseMetadataHolder

public BaseMetadataHolder(IWorkMetadata metadata)
Creates a new instance of BaseWorker with full metadata.

Parameters:
metadata - metadata for associated object
Method Detail

getMetadata

public IWorkMetadata getMetadata()
Retrieves metadata associated with this object.

Specified by:
getMetadata in interface IMetadataHolder
Returns:
worker metadata

setRequiredProperties

protected final void setRequiredProperties(PropertyInfo[] info)
                                    throws MetadataException
Assigns metadata for all required properties in this command. Safe to call inside the constructor.

Parameters:
info - property metadata
Throws:
MetadataException - if unable to assign new required properties

setOptionalProperties

protected final void setOptionalProperties(OptionalPropertyInfo[] info)
                                    throws MetadataException
Assigns metadata for all optional properties in this command. Safe to call inside the constructor.

Parameters:
info - property metadata
Throws:
MetadataException - if unable to assign new required properties

validateProperties

public void validateProperties(IWorkProperties props,
                               boolean required)
                        throws WorkPropertyException
Validate properties against IWorkMetadata.

Specified by:
validateProperties in interface IMetadataHolder
Parameters:
props - properties to validate
required - true if property must be contain a non-null value
Throws:
WorkPropertyException - if properties fail to match constraints

validateType

public void validateType(PropertyInfo info,
                         java.lang.String name,
                         java.lang.Object value)
                  throws WorkPropertyException
Make sure property type matches any of the required types.

Specified by:
validateType in interface IMetadataHolder
Parameters:
info - property metadata
name - property name
value - property value
Throws:
WorkPropertyException - if property value is not valid