pl.edu.agh.cast.model.attributes
Class Attribute

java.lang.Object
  extended by pl.edu.agh.cast.model.attributes.Attribute
All Implemented Interfaces:
Serializable, Comparable<Attribute>, IPropertyChangeProvider

public class Attribute
extends Object
implements Serializable, Comparable<Attribute>, IPropertyChangeProvider

Stores information about a single attribute registered in an attribute manager. Two Attributes are considered equal if their names are equal.

Author:
AGH CAST Team
See Also:
Serialized Form

Field Summary
static String PROPERTY_SHOW_AS_LABEL
          ID of the ShowAsLabel property.
 
Constructor Summary
Attribute(String name, boolean nameIsLocalizable, ValueType type, Object defaultValue, boolean permanent, boolean editable, boolean showAsLabel, String ownerTypeName, String modelExtensionId)
          Constructor.
 
Method Summary
 void addPropertyChangeListener(PropertyChangeListener l)
          Add a property change listener to the object.
 int compareTo(Attribute o)
          
 Attribute copy()
          Returns a copy of this Attribute instance.
 boolean equals(Object obj)
          Two Attributes are considered equal if their names are equal.
protected  void firePropertyChange(String property, Object oldValue, Object newValue)
           
 AttributeMergePolicy getDefaultMergePolicy()
           
 Object getDefaultValue()
           
 String getDisplayName()
          The human readable name of the attribute.
 String getName()
           
 ValueType getType()
           
 int hashCode()
          
 boolean isEditable()
           
 boolean isNameLocalizable()
           
 boolean isPermanent()
           
 boolean isShowAsLabel()
           
protected  Object readResolve()
           
 void removePropertyChangeListener(PropertyChangeListener l)
          Remove a property change listener to the object.
 void setDefaultMergePolicy(AttributeMergePolicy defaultMergePolicy)
           
 void setShowAsLabel(boolean showAsLabel)
          Sets new value of showAsLabel flag.
 String toString()
          
 boolean validateValue(Object value)
          Checks if given value is valid for this attribute.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

PROPERTY_SHOW_AS_LABEL

public static final String PROPERTY_SHOW_AS_LABEL
ID of the ShowAsLabel property.

See Also:
Constant Field Values
Constructor Detail

Attribute

public Attribute(String name,
                 boolean nameIsLocalizable,
                 ValueType type,
                 Object defaultValue,
                 boolean permanent,
                 boolean editable,
                 boolean showAsLabel,
                 String ownerTypeName,
                 String modelExtensionId)
Constructor.

Parameters:
name - name of the attribute
nameIsLocalizable - whether the name is localizable
type - value type
defaultValue - default attribute value
permanent - whether the attribute is permanent
editable - whether the attribute can be edited
showAsLabel - whether the attribute should be displayed in label
ownerTypeName - the name of the type (in some domain model) which defines this attribute - it might be null, if the attribute is created, but it doesn't matter since such attributes are not localizable
modelExtensionId - the ID of the model extension in which this attribute is defined. It might be null if the attribute is created by user or it is some predefined attribute. In the first case, the attribute is not localizable, in the second, the localized message is taken from the Core plug-in.
Method Detail

getType

public ValueType getType()

isPermanent

public boolean isPermanent()

isNameLocalizable

public boolean isNameLocalizable()

isEditable

public boolean isEditable()

isShowAsLabel

public boolean isShowAsLabel()

getName

public String getName()

getDefaultValue

public Object getDefaultValue()

getDisplayName

public String getDisplayName()
The human readable name of the attribute. If the attribute is localizable (i.e. is a predefined attribute or is defined in some domain model) the localized representation of the name is returned. Otherwise the raw name is returned.

Returns:
The human readable name of the attribute.

validateValue

public boolean validateValue(Object value)
Checks if given value is valid for this attribute.

Parameters:
value - value to check
Returns:
validation result

equals

public boolean equals(Object obj)
Two Attributes are considered equal if their names are equal.

Overrides:
equals in class Object
See Also:
Object.equals(java.lang.Object)

hashCode

public int hashCode()

Overrides:
hashCode in class Object
See Also:
Object.hashCode()

compareTo

public int compareTo(Attribute o)

Specified by:
compareTo in interface Comparable<Attribute>
See Also:
Comparable.compareTo(java.lang.Object)

toString

public String toString()

Overrides:
toString in class Object
See Also:
Object.toString()

setShowAsLabel

public void setShowAsLabel(boolean showAsLabel)
Sets new value of showAsLabel flag. Fires a PROPERTY_SHOW_AS_LABEL event.

Parameters:
showAsLabel - new showAsLabel value

copy

public Attribute copy()
Returns a copy of this Attribute instance.

Returns:
copy of this instance

readResolve

protected Object readResolve()

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener l)
Add a property change listener to the object.

Specified by:
addPropertyChangeListener in interface IPropertyChangeProvider
Parameters:
l - property change listener
See Also:
IPropertyChangeProvider.addPropertyChangeListener(java.beans.PropertyChangeListener)

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener l)
Remove a property change listener to the object.

Specified by:
removePropertyChangeListener in interface IPropertyChangeProvider
Parameters:
l - property change listener
See Also:
#removePropertyChangeListener(java.beans.PropertyChangeListener)

firePropertyChange

protected void firePropertyChange(String property,
                                  Object oldValue,
                                  Object newValue)

getDefaultMergePolicy

public AttributeMergePolicy getDefaultMergePolicy()

setDefaultMergePolicy

public void setDefaultMergePolicy(AttributeMergePolicy defaultMergePolicy)


Copyright © 2007-2009 IISG AGH-UST Krakow, Poland. All Rights Reserved.