org.nees.repo.chef
Class DisplayRelation

java.lang.Object
  extended byorg.nees.repo.chef.DisplayRelation

public class DisplayRelation
extends java.lang.Object

Represents a Relation for the purpose of displaying and manipulating it in a user interface. The value(s) of the relation are represented with DisplayRelationValue objects. Other information about the Relation, such as its id, its type, and cardinality are also managed by this class.

Typical Usage:

Contained in a DisplayMetadataObject passed to a velocity template, which interrogates the DisplayRelation for information and values.

Life Cycle:

Created by DisplayMetadataObject. Kept in its read-only displayRelations property.

See Also:
DisplayMetadataObject, DisplayRelationValue

Constructor Summary
DisplayRelation()
           
DisplayRelation(java.lang.String title, int type, int min, int max, Identifier relID, boolean cardUnbounded)
           
 
Method Summary
 void addValue(DisplayRelationValue drv)
          Add a value.
 java.util.Date[] getAllowedDates()
          Get allowed classes for reference type relations.
 double[] getAllowedDoubles()
          Get allowed values for Double type relations.
 int[] getAllowedInts()
          Get allowed values for Int type relations.
 long[] getAllowedLongs()
          Get allowed values for Long type relations.
 Identifier[] getAllowedReferences()
          Get allowed classes for reference type relations.
 java.lang.String[] getAllowedStrings()
          Get allowed values for String type relations.
 java.lang.String[] getAllowedValuesAsStrings()
          return an array of allowed values as strings.
 boolean getCardUnbounded()
           
 java.lang.String getIsDate()
           
 boolean getIsUnitQuant()
          Get if the relation allows a unitQuant Reference;
 Identifier getRelationId()
          Get the Relation Identifier.
 java.lang.String getRelationIdSerialized()
          /** Get the Relation ID as a String.
 int getRelationMax()
          Get the Relation cardinality minimum (the maximum number of values permitted)
 int getRelationMin()
          Get the Relation cardinality minimum (the minimum number of values permitted)
 int getRelationType()
           
 java.lang.String getTitle()
          Get the human-readable title for this DisplayRelation.
 DisplayRelationValue getValue()
          Get the first value.
 int getValueCount()
          Get the number of values this relation has.
 java.util.ArrayList getValues()
          Get the values.
 boolean hasConstrainedValues()
          Convenience method for determining if values are constrained.
 void setAllowedDates(java.util.Date[] values)
          Set allowed Dates for Date type relations.
 void setAllowedDoubles(double[] values)
          Set allowed values for Double type relations.
 void setAllowedInts(int[] values)
          Set allowed values for Int type relations.
 void setAllowedLongs(long[] values)
          Set allowed values for Long type relations.
 void setAllowedReferences(Identifier[] values)
          Set allowed classes for reference type relations.
 void setAllowedStrings(java.lang.String[] values)
          Set allowed values for String type relations.
 void setIsUnitQuant(boolean is)
          Set the isUnitQuant.
 void setValue(DisplayRelationValue drv)
          Set the value.
 void testing()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DisplayRelation

public DisplayRelation()

DisplayRelation

public DisplayRelation(java.lang.String title,
                       int type,
                       int min,
                       int max,
                       Identifier relID,
                       boolean cardUnbounded)
Method Detail

getCardUnbounded

public boolean getCardUnbounded()

getIsDate

public java.lang.String getIsDate()

setAllowedStrings

public void setAllowedStrings(java.lang.String[] values)
Set allowed values for String type relations. Zero-sized array passed in will be turned into a single null value.


getAllowedStrings

public java.lang.String[] getAllowedStrings()
Get allowed values for String type relations.

Returns:
array of allowed Strings; null if not limited.

setAllowedLongs

public void setAllowedLongs(long[] values)
Set allowed values for Long type relations. Zero-sized array passed in will be turned into a single null value.


getAllowedLongs

public long[] getAllowedLongs()
Get allowed values for Long type relations.

Returns:
array of allowed Longs; null if not limited.

setAllowedDoubles

public void setAllowedDoubles(double[] values)
Set allowed values for Double type relations. Zero-sized array passed in will be turned into a single null value.


getAllowedDoubles

public double[] getAllowedDoubles()
Get allowed values for Double type relations.

Returns:
array of allowed Doubles; null if not limited.

setAllowedInts

public void setAllowedInts(int[] values)
Set allowed values for Int type relations. Zero-sized array passed in will be turned into a single null value.


getAllowedInts

public int[] getAllowedInts()
Get allowed values for Int type relations.

Returns:
array of allowed Ints; null if not limited.

setAllowedReferences

public void setAllowedReferences(Identifier[] values)
Set allowed classes for reference type relations. Zero-sized array passed in will be turned into a single null value.


getAllowedReferences

public Identifier[] getAllowedReferences()
Get allowed classes for reference type relations.

Returns:
array of allowed classes; null if not limited.

setAllowedDates

public void setAllowedDates(java.util.Date[] values)
Set allowed Dates for Date type relations. Zero-sized array passed in will be turned into a single null value.


getAllowedDates

public java.util.Date[] getAllowedDates()
Get allowed classes for reference type relations.

Returns:
array of allowed classes; null if not limited.

hasConstrainedValues

public boolean hasConstrainedValues()
Convenience method for determining if values are constrained.


getAllowedValuesAsStrings

public java.lang.String[] getAllowedValuesAsStrings()
return an array of allowed values as strings.


getRelationMin

public int getRelationMin()
Get the Relation cardinality minimum (the minimum number of values permitted)

Returns:
the Relation cardinality minimum

getRelationMax

public int getRelationMax()
Get the Relation cardinality minimum (the maximum number of values permitted)

Returns:
the Relation cardinality maximum (-1 if unbounded.)

getRelationId

public Identifier getRelationId()
Get the Relation Identifier.

Returns:
the string (serialized) form of the Relation Identifier

getRelationIdSerialized

public java.lang.String getRelationIdSerialized()
/** Get the Relation ID as a String.

Returns:
the Relation Id

getIsUnitQuant

public boolean getIsUnitQuant()
Get if the relation allows a unitQuant Reference;

Returns:
the allowsUnitQuant

setIsUnitQuant

public void setIsUnitQuant(boolean is)
Set the isUnitQuant.


getTitle

public java.lang.String getTitle()
Get the human-readable title for this DisplayRelation.


getRelationType

public int getRelationType()

setValue

public void setValue(DisplayRelationValue drv)
Set the value.

Parameters:
drv - a DisplayRelationValue representing the value

addValue

public void addValue(DisplayRelationValue drv)
Add a value.

Parameters:
drv - a DisplayRelationValue representing the value

getValueCount

public int getValueCount()
Get the number of values this relation has.

Returns:
the number of values this relation has.

getValues

public java.util.ArrayList getValues()
Get the values.

Returns:
a Vector of DisplayRelationValues

getValue

public DisplayRelationValue getValue()
Get the first value. This is a convenience method. Don't call this if there are no values.

Returns:
the first value

testing

public void testing()