com.miginfocom.theme
Class PropertyCapability

java.lang.Object
  extended by com.miginfocom.theme.PropertyCapability

public class PropertyCapability
extends java.lang.Object

A class that contains information about what capabilities a property in a Theme can have, which class type, max value, min value, if null is OK, and so on.

Every Property in a Theme should have a PropertyCapability connected to it. assignment is made in Theme.setPropertyCapabilities(...)

Capabilities are immutable so they can be shared.

See Also:
Theme.getPropertyCapabilities(java.lang.String)

Field Summary
static PropertyCapability NO_VALIDATE_CAP
           
 
Constructor Summary
PropertyCapability(java.lang.Class type)
          Creates a capability that indicates that the property can be of the type that 'class' indicates
PropertyCapability(java.lang.Class type, java.lang.Comparable min, java.lang.Comparable max)
          Creates a capability that indicates that the property can be of the type that 'class' indicates and that that it should be within the bounds that 'max' and 'min' represents
PropertyCapability(java.lang.Class type, java.lang.Comparable min, java.lang.Comparable max, java.lang.Number stepSize)
          Creates a capability that indicates that the property can be of the type that 'class' indicates and that that it should be within the bounds that 'max' and 'min' represents
PropertyCapability(java.lang.Class type, NameValuePair[] possibleValues)
          A special constructor that specifies that the property can only have a set of values.
PropertyCapability(NameValuePair[] possibleValues)
          A special constructor that specifies that the property can only have a set of values.
 
Method Summary
 boolean equals(java.lang.Object o)
          Two capabilities equals if they are of same type and have the same max/min.
 java.lang.Comparable getMax()
          Returns the maximum value the Property can have.
 java.lang.Comparable getMin()
          Returns the minimum value the Property can have.
 NameValuePair[] getPossibleValues()
          Returns the possible values that this PropertyCapability indicats that the property can have.
 java.lang.Number getStepSize()
          Returns the step size the Property should have.
 java.lang.Class getType()
          Returns the type of class the Property can have.
 java.lang.String toString()
          Returns a string representation of the capabilities on the form: "Min < ClassName < Max" or
"Value in (|,|,<...>)"
 java.lang.String validate(java.lang.Object value)
          Validates 'value' against the capabilities.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NO_VALIDATE_CAP

public static final PropertyCapability NO_VALIDATE_CAP
Constructor Detail

PropertyCapability

public PropertyCapability(java.lang.Class type)
Creates a capability that indicates that the property can be of the type that 'class' indicates

Parameters:
type - The class type that a Property can be of. IF null only accepts the null type.

PropertyCapability

public PropertyCapability(java.lang.Class type,
                          java.lang.Comparable min,
                          java.lang.Comparable max)
Creates a capability that indicates that the property can be of the type that 'class' indicates and that that it should be within the bounds that 'max' and 'min' represents

Parameters:
type - The class type that a Property can be of. Should be 'Comparable' if 'max' or 'min' != null.
min - The minimum value that the object of type 'type' can have. null indicates no lower bounds. if != null must be of same class as type.
max - The maximum value that the object of type 'type' can have. null indicates no upper bounds. if != null must be of same class as type.

PropertyCapability

public PropertyCapability(java.lang.Class type,
                          java.lang.Comparable min,
                          java.lang.Comparable max,
                          java.lang.Number stepSize)
Creates a capability that indicates that the property can be of the type that 'class' indicates and that that it should be within the bounds that 'max' and 'min' represents

Parameters:
type - The class type that a Property can be of.
min - The minimum value that the object of type 'type' can have. null indicates no lower bounds. if != null must be of same class as type.
max - The maximum value that the object of type 'type' can have. null indicates no upper bounds. if != null must be of same class as type.
stepSize - The value that should be increased or decreased when pressing one of the buttons in the spinner.

PropertyCapability

public PropertyCapability(NameValuePair[] possibleValues)
A special constructor that specifies that the property can only have a set of values. Type is set to NameValuePair.class

Parameters:
possibleValues - The values that are leagal for the property to have. It's actually the NameValuePair's value that is the value that the property have to be one of.

PropertyCapability

public PropertyCapability(java.lang.Class type,
                          NameValuePair[] possibleValues)
A special constructor that specifies that the property can only have a set of values. Note that only editors that supports this possibleValues will use them.

Parameters:
type - The class type that a Property can be of.
possibleValues - The values that are leagal for the property to have.
Method Detail

validate

public java.lang.String validate(java.lang.Object value)
Validates 'value' against the capabilities. The class must be an instance of 'type' and the value must be within 'max' , 'min' or 'possibleValues' if they are set in the constructor

Parameters:
value - The value to validate
Returns:
If 'value' is within these the capabilities, null is returned. Otherwise an error message indicating what's wrong

toString

public java.lang.String toString()
Returns a string representation of the capabilities on the form: "Min < ClassName < Max" or
"Value in (|,|,<...>)"

Overrides:
toString in class java.lang.Object
Returns:
A string representation of the capabilities

equals

public boolean equals(java.lang.Object o)
Two capabilities equals if they are of same type and have the same max/min. If possible value are defined, those must equals as per Arrays.equals() as well.

Overrides:
equals in class java.lang.Object
Parameters:
o -
Returns:
If the two capabilites are equal.

getType

public java.lang.Class getType()
Returns the type of class the Property can have. null means the the property can be null.

Returns:
The type of class the Property can have. null means the the property can be null.

getMin

public java.lang.Comparable getMin()
Returns the minimum value the Property can have. null means no lower bounds.

Returns:
The minimum value the Property can have. null means no lower bounds.

getMax

public java.lang.Comparable getMax()
Returns the maximum value the Property can have. null means no upper bounds.

Returns:
The maximum value the Property can have. null means no upper bounds.

getStepSize

public java.lang.Number getStepSize()
Returns the step size the Property should have. Integer(1) is default.

Returns:
The minimum value the Property can have. Integer(1) is default. Never null

getPossibleValues

public NameValuePair[] getPossibleValues()
Returns the possible values that this PropertyCapability indicats that the property can have. This is != null only if set in the constructor.

Returns:
The possible values that this PropertyCapability indicats that the property can have


Copyright © 2009 MiG InfoCom AB. All Rights Reserved.