public abstract class IlvAbstractStringProperty extends Object implements IlvStringProperty
IlvAbstractStringProperty
provides a common framework for
accessing arbitrary object properties via the generic IlvStringProperty
interface. A Format
can be supplied to convert non-String
properties to/from a string.Modifier and Type | Field and Description |
---|---|
protected Format |
_formatter
The formatter which is used to convert the
target object's
property to/from a string, or null if no formatting is
desired. |
Constructor and Description |
---|
IlvAbstractStringProperty()
Creates an
IlvAbstractStringProperty . |
Modifier and Type | Method and Description |
---|---|
Iterator<IlvHierarchyNode> |
changedRowsIterator(EventObject event)
Returns an iterator over the activities or resources that the specified
event reports have changed with respect to this property.
|
Format |
getFormat()
Returns the formatter which is used to convert the property represented
by this adapter to/from a string, or
null if there is no
formatter. |
String |
getValue(Object target)
Returns the
String value of the property represented by this
adapter from the specified target object. |
protected abstract Object |
getValueImpl(Object target)
Returns the value of the property represented by this adapter from the
specified
target object. |
boolean |
isPropertyChangedEvent(EventObject event)
Returns whether the specified event is a changed event for
this property.
|
void |
setFormat(Format formatter)
Sets the formatter which will be used to convert the property represented
by this adapter to/from a string.
|
void |
setValue(Object target,
String s)
Sets the value of the property represented by this adapter in the specified
target object. |
protected abstract void |
setValueImpl(Object target,
Object newValue)
Sets the value of the property represented by this adapter in the specified
target object. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getEventClass
protected Format _formatter
target
object's
property to/from a string, or null
if no formatting is
desired. Typically, this will be the case if the property value is
a String
and no additional formatting is desired.public IlvAbstractStringProperty()
IlvAbstractStringProperty
.public String getValue(Object target)
String
value of the property represented by this
adapter from the specified target
object. This method first
invokes getValueImpl()
to obtain target
's
property value. If this adapter has a Format
set, it is then
applied to the property value to obtain its string representation.
Otherwise, if no Format
is set, then the property value's
toString()
method is invoked to obtain its string representation.getValue
in interface IlvProperty
getValue
in interface IlvStringProperty
target
- the target objecttarget
's property, represented as a String
getValueImpl(java.lang.Object)
,
setFormat(java.text.Format)
public void setValue(Object target, String s) throws ParseException
target
object. If this adapter has a Format
set,
it is used to parse s
into the appropriate type of property
value. The parsed property value is then passed to setValueImpl()
to actually set target
's property. Otherwise, if no
Format
is set, then s
is directly passed to
setValueImpl()
as the new value of target
's
property. If s
cannot be parsed into a valid property value,
a ParseException
will be thrown.setValue
in interface IlvStringProperty
target
- the target objects
- the new value of the propertyParseException
- if s
cannot be parsed into a valid
property valuesetValueImpl(java.lang.Object, java.lang.Object)
,
setFormat(java.text.Format)
protected abstract Object getValueImpl(Object target)
target
object. Subclasses should provide an
implementation of this method similar to this:
// Adapter representing the Bar property of Foo objects. The value of Bar // is an instance of the class BarType. public class FooBarProperty extends IlvAbstractStringProperty { protected Object getValueImpl (Object aFoo) { return ((Foo)aFoo).getBar(); } ... }
target
- the target objectgetValue(java.lang.Object)
protected abstract void setValueImpl(Object target, Object newValue) throws ParseException
target
object. Subclasses should provide an implementation of
this method similar to this:
// Adapter representing the Bar property of Foo objects. The value of Bar // is an instance of the class BarType. public class FooBarProperty extends IlvAbstractStringProperty { protected Object setValueImpl (Object aFoo, Object newValue) { ((Foo)aFoo).setBar((BarType) newValue); } ... }
target
- the target objectnewValue
- the new value of the propertyParseException
- if newValue
cannot be parsed into a
valid property valuesetValue(java.lang.Object, java.lang.String)
public Format getFormat()
null
if there is no
formatter. Typically, this will be the case if the property value is
a String
and no additional formatting is desired.setFormat(java.text.Format)
public void setFormat(Format formatter)
null
can be supplied if
the property type is a String
and no additional formatting
is desired.formatter
- the formatter or null
if no formatter is
desiredgetFormat()
public boolean isPropertyChangedEvent(EventObject event)
true
if and only if event
is the same or a subclass of
IlvProperty.getEventClass()
, is also an IlvPropertyEvent
,
and ((IlvPropertyEvent)event).isChangedEvent()
returns
true
. This implementation is suitable for a property that
fires a specific IlvPropertyEvent
subclass when its value
changes. Subclasses should override this method as necessary.isPropertyChangedEvent
in interface IlvProperty
public Iterator<IlvHierarchyNode> changedRowsIterator(EventObject event)
IlvActivityNameProperty
and event
is an
ActivityNameEvent
, then
this method returns an iterator over the single activity that fired the
event.
The default implementation returns an iterator over event
's
source if event
is a property changed event. This
implementation is suitable for an activity or resource property that fires
a specific IlvPropertyEvent
subclass when its value changes.
Subclasses should override this method as necessary.
changedRowsIterator
in interface IlvProperty
© Copyright Rogue Wave Software, Inc. 1997, 2018. All Rights Reserved.