com.vaadin.data.util.sqlcontainer.
Class ColumnProperty
java.lang.Object
com.vaadin.data.util.sqlcontainer.ColumnProperty
All Implemented Interfaces:
ColumnProperty represents the value of one column in a RowItem. In addition to the value, ColumnProperty also contains some basic column attributes such as nullability status, read-only status and data type. Note that depending on the QueryDelegate in use this does not necessarily map into an actual column in a database table.
See Also:
Nested Class Summary | |
---|---|
class |
ColumnProperty.NotNullableException
An exception that signals that a null value was passed to
the setValue method, but the value of this property can not
be set to null . |
Nested classes/interfaces inherited from interface com.vaadin.data.Property |
---|
Property.ConversionException, Property.Editor, Property.ReadOnlyException, Property.ReadOnlyStatusChangeEvent, Property.ReadOnlyStatusChangeListener, Property.ReadOnlyStatusChangeNotifier, Property.ValueChangeEvent, Property.ValueChangeListener, Property.ValueChangeNotifier, Property.Viewer |
Constructor Summary | |
---|---|
ColumnProperty(String propertyId,
boolean readOnly,
boolean allowReadOnlyChange,
boolean nullable,
boolean primaryKey,
Object value,
Class<?> type)
Creates a new ColumnProperty instance. |
|
ColumnProperty(String propertyId,
boolean readOnly,
boolean allowReadOnlyChange,
boolean nullable,
Object value,
Class<?> type)
Deprecated. |
Method Summary | |
---|---|
void |
commit()
|
Object |
getOldValue()
Returns the original non-modified value of this property if it has been modified. |
String |
getPropertyId()
|
Class<?> |
getType()
Returns the type of the Property. |
Object |
getValue()
Returns the current value for this property. |
boolean |
isModified()
|
boolean |
isNullable()
|
boolean |
isPersistent()
Return whether the value of this property should be persisted to the database. |
boolean |
isPrimaryKey()
|
boolean |
isReadOnly()
Tests if the Property is in read-only mode. |
boolean |
isReadOnlyChangeAllowed()
Returns whether the read-only status of this property can be changed using setReadOnly(boolean) . |
boolean |
isRowIdentifier()
Returns whether or not this property is used as a row identifier. |
boolean |
isVersionColumn()
|
void |
setOwner(RowItem owner)
|
void |
setReadOnly(boolean newStatus)
Sets the Property's read-only mode to the specified status. |
void |
setValue(Object newValue)
Sets the value of the Property. |
void |
setVersionColumn(boolean versionColumn)
|
String |
toString()
Returns the value of the Property in human readable textual format. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
ColumnProperty
@Deprecated
public ColumnProperty(String propertyId,
boolean readOnly,
boolean allowReadOnlyChange,
boolean nullable,
Object value,
Class<?> type)
- Parameters:
propertyId
-readOnly
-allowReadOnlyChange
-nullable
-value
-type
-
Deprecated.
Deprecated constructor for ColumnProperty. If this is used the primary keys are not identified correctly in some cases for some databases (i.e. Oracle). See http://dev.vaadin.com/ticket/9145.
ColumnProperty
public ColumnProperty(String propertyId,
boolean readOnly,
boolean allowReadOnlyChange,
boolean nullable,
boolean primaryKey,
Object value,
Class<?> type)
- Parameters:
propertyId
- The ID of this property.readOnly
- Whether this property is read-only.allowReadOnlyChange
- Whether the read-only status of this property can be changed.nullable
- Whether this property accepts null values.primaryKey
- Whether this property corresponds to a database primary key.value
- The value of this property.type
- The type of this property.
Creates a new ColumnProperty instance.
Method Detail |
---|
getValue
public Object getValue()
- Returns:
Returns the current value for this property. To get the previous value
(if one exists) for a modified property use getOldValue()
.
getOldValue
public Object getOldValue()
- Returns:
- The original value if
isModified()
is true,getValue()
otherwise.
Returns the original non-modified value of this property if it has been modified.
setValue
public void setValue(Object newValue)
throws Property.ReadOnlyException,
Property.ConversionException
- Parameters:
newValue
- New value of the Property. This should be assignable to the type returned by getType, but also String type should be supported- Throws:
Property.ReadOnlyException
- if the object is in read-only modeProperty.ConversionException
- if newValue can't be converted into the Property's native type directly or through String
Description copied from interface: Property
Sets the value of the Property.
Implementing this functionality is optional. If the functionality is
missing, one should declare the Property to be in read-only mode and
throw Property.ReadOnlyException
in this function.
String
in addition to the native type of the
Property (as given by the getType
method). If the
String
conversion fails or is unsupported, the method should
throw Property.ConversionException
. The string conversion
should at least understand the format returned by the
toString
method of the Property.
getType
public Class<?> getType()
- Returns:
- type of the Property
Description copied from interface: Property
Returns the type of the Property. The methods getValue
and
setValue
must be compatible with this type: one must be able
to safely cast the value returned from getValue
to the given
type and pass any variable assignable to this type as an argument to
setValue
.
isReadOnly
public boolean isReadOnly()
- Specified by:
isReadOnly
in interfaceProperty
- Returns:
true
if the Property is in read-only mode,false
if it's not
Description copied from interface: Property
Tests if the Property is in read-only mode. In read-only mode calls to
the method setValue
will throw
ReadOnlyException
and will not modify the value of the
Property.
isReadOnlyChangeAllowed
public boolean isReadOnlyChangeAllowed()
- Returns:
- true if the read-only status can be changed, false otherwise.
Returns whether the read-only status of this property can be changed
using setReadOnly(boolean)
.
Used to prevent setting to read/write mode a property that is not allowed to be written by the underlying database. Also used for values like VERSION and AUTO_INCREMENT fields that might be set to read-only by the container but the database still allows writes.
setReadOnly
public void setReadOnly(boolean newStatus)
- Specified by:
setReadOnly
in interfaceProperty
- Parameters:
newStatus
- new read-only status of the Property
Description copied from interface: Property
Sets the Property's read-only mode to the specified status.
This functionality is optional, but all properties must implement the
isReadOnly
mode query correctly.
isPrimaryKey
public boolean isPrimaryKey()
getPropertyId
public String getPropertyId()
toString
public String toString()
- Returns:
String
representation of the value stored in the Property
Description copied from interface: Property
Returns the value of the Property in human readable textual format. The
return value should be assignable to the setValue
method if
the Property is not in read-only mode.
setOwner
public void setOwner(RowItem owner)
isModified
public boolean isModified()
isVersionColumn
public boolean isVersionColumn()
setVersionColumn
public void setVersionColumn(boolean versionColumn)
isNullable
public boolean isNullable()
isPersistent
public boolean isPersistent()
- Returns:
- true if the value should be written to the database, false otherwise.
Return whether the value of this property should be persisted to the database.
isRowIdentifier
public boolean isRowIdentifier()
- Returns:
- true if the property is a row identifier, false otherwise.
Returns whether or not this property is used as a row identifier.
commit
public void commit()