|
Holger's Java API |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.antelmann.db.AbstractDBEntry
com.antelmann.db.PropertyEntryImpl
public class PropertyEntryImpl
This class represents a default PropertyEntry implementation that can serve as a base class for PropertyEntry implementations. In addition this implementation optionally monitors changes on its properties. Finally, this class also provides support for undo/redo.
| Field Summary | |
|---|---|
protected PropertyChangeSupport |
propertyChangeSupport
access to the embedded property change support; this variable is initially null (until initialized by setChangeListenerSupport(boolean)) |
protected HashMap<String,Object> |
props
provides unmonitored and unchecked access to the properties for the inheriting class; altering the properties directly would circumvent the property change support. |
protected UndoManager |
um
access to the embedded undo/redo support; this variable is initially null (until initialized by setUndoSupported(boolean)) |
protected VetoableChangeSupport |
vcs
access to the embedded vetoable change support; this variable is initially null (until initialized by setVetoableChangeSupport(boolean)) |
| Fields inherited from interface com.antelmann.db.DBEntry |
|---|
ENTRY_FLAVOR, ENTRY_LIST_FLAVOR |
| Constructor Summary | |
|---|---|
PropertyEntryImpl()
convenience constructor: creates an instance with a serializable random UUID |
|
PropertyEntryImpl(Object id)
|
|
PropertyEntryImpl(Object id,
Map<String,?> properties)
the given properties do NOT run through the property change check; they ought to be checked once the extending class is fully initialized |
|
PropertyEntryImpl(Object id,
PropertyEntry entity)
all properties from the given entity are copied into this entity; the given properties do NOT run through the property change check. |
|
| Method Summary | ||
|---|---|---|
void |
addPropertyChangeListener(PropertyChangeListener listener)
|
|
void |
addPropertyChangeListener(String propertyKey,
PropertyChangeListener listener)
|
|
void |
addVetoableChangeListener(String propertyKey,
VetoableChangeListener listener)
|
|
void |
addVetoableChangeListener(VetoableChangeListener listener)
|
|
Properties |
asProperties()
|
|
boolean |
canRedo()
|
|
boolean |
canUndo()
|
|
protected void |
checkPropertyChange(String key,
Object value)
determines whether a property can be changed as given. |
|
void |
clearProperties()
clears all properties by removing every key separately (as a removal may not be allowed by checkPropertyChange()) |
|
protected boolean |
containsPropertyText(String text)
searches within the property values (based on toString()) for the given text case-insensivitely |
|
boolean |
containsValuePattern(CharSequence pattern)
searches through all properties and returns true only if the given pattern is found within the String values of the properties |
|
boolean |
equalWithProperties(PropertyEntry entry)
checks (next to equals) whether all properties are the same |
|
static boolean |
equalWithProperties(PropertyEntry entry1,
PropertyEntry entry2)
|
|
boolean |
getBoolean(String key)
|
|
Number |
getNumber(String key)
convenience method; returns either the property value of the given key or 0 if the property value is null |
|
Map<String,Object> |
getProperties()
generates a new view on each call; altering properties can be done via the setProperty(String, Object) method |
|
Object |
getProperty(String key)
allows access to some property; may return null if not set |
|
Object |
getProperty(String key,
Object defaultValue)
if the given key maps to a null value, the defaultValue is returned instead |
|
PropertyChangeListener[] |
getPropertyChangeListeners()
|
|
static Comparator<PropertyEntry> |
getPropertyComparator(String propertyKey)
|
|
static PatternExtractor<PropertyEntry,Object> |
getPropertyExtractor(String propertyKey)
|
|
static
|
getPropertyExtractor(String propertyKey,
Class<T> type)
returns a PatternExtractor based on the value of the given property |
|
String[] |
getPropertyKeys()
note that an existing key may still map to a null value |
|
static PatternExtractor<PropertyEntry,String> |
getStringExtractor(String propertyKey)
returns a PatternExtractor based on the String value of the given property |
|
VetoableChangeListener[] |
getVetoableChangeListeners()
|
|
boolean |
isCaseInsensitive()
determines whether this instance behaves case-insensitive in regards to the property keys. |
|
boolean |
isChangeListenerSupportEnabled()
determines whether listener support is enabled on this object (false by default) |
|
static boolean |
isKeyIn(String key,
String... keyCandidates)
convenience method to more easily check keys in inheriting classes |
|
boolean |
isUndoSupport()
|
|
boolean |
isVetoableChangeSupportEnabled()
|
|
void |
putAll(Map<?,?> map)
all imported properties are checked by checkPropertyChange() |
|
boolean |
redo()
|
|
Object |
removeProperty(String key)
removes the given key from the properties |
|
void |
removePropertyChangeListener(PropertyChangeListener listener)
|
|
void |
removeVetoableChangeListener(VetoableChangeListener listener)
|
|
void |
setAllFrom(Map<?,?> map)
|
|
void |
setCaseInsensitive(boolean caseInsensitive)
|
|
void |
setChangeListenerSupport(boolean flag)
allows to enable/disable listener support on this object (disabled by default). |
|
Object |
setProperty(String key,
Object value)
edit/set a given property value based on the given key. |
|
void |
setUndoSupported(boolean flag)
if one wanted to customize the UndoManager upon creation, this would be the method to override |
|
protected void |
setVetoableChangeSupport(boolean flag)
allows to enable/disable vetoable change support on this object (disabled by default). |
|
String |
toDetailedString()
provides full details of this instance in a String. |
|
boolean |
undo()
|
|
void |
verifyProperties()
This default implementation simply runs all existing properties through checkPropertyChange(String, Object). |
|
| Methods inherited from class com.antelmann.db.AbstractDBEntry |
|---|
equals, getID, hashCode, hashEntry, sameEntry, toString |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface com.antelmann.db.DBEntry |
|---|
getID |
| Field Detail |
|---|
protected final HashMap<String,Object> props
isCaseInsensitive().
protected PropertyChangeSupport propertyChangeSupport
setChangeListenerSupport(boolean))
setChangeListenerSupport(boolean)protected VetoableChangeSupport vcs
setVetoableChangeSupport(boolean))
setVetoableChangeSupport(boolean)protected UndoManager um
setUndoSupported(boolean))
| Constructor Detail |
|---|
public PropertyEntryImpl()
public PropertyEntryImpl(Object id)
public PropertyEntryImpl(Object id,
PropertyEntry entity)
checkPropertyChange(String, Object),
verifyProperties()
public PropertyEntryImpl(Object id,
Map<String,?> properties)
checkPropertyChange(String, Object),
verifyProperties()| Method Detail |
|---|
public boolean isCaseInsensitive()
setCaseInsensitive(boolean)public void setCaseInsensitive(boolean caseInsensitive)
isCaseInsensitive()public boolean equalWithProperties(PropertyEntry entry)
public static boolean equalWithProperties(PropertyEntry entry1,
PropertyEntry entry2)
public Number getNumber(String key)
public boolean getBoolean(String key)
public Object getProperty(String key)
PropertyEntry
getProperty in interface PropertyEntry
public Object getProperty(String key,
Object defaultValue)
public String[] getPropertyKeys()
public void verifyProperties()
throws IllegalArgumentException
checkPropertyChange(String, Object).
If any implementation requires to check for more (e.g. for missing properties),
this method is to be overridden to provide this functionality.
Within the implementation of PropertyEntryImpl, this method is never called.
IllegalArgumentException
protected void checkPropertyChange(String key,
Object value)
throws IllegalArgumentException,
NullPointerException
IllegalArgumentException - if the change of the value is not to be allowed
NullPointerException - if a key or value must not be null but still issetProperty(String, Object),
removeProperty(String)
public static boolean isKeyIn(String key,
String... keyCandidates)
public Object setProperty(String key,
Object value)
throws IllegalArgumentException
PropertyEntry
setProperty in interface PropertyEntryIllegalArgumentException - if checkPropertyChange(key, value) throws one or
if the VetoableChangeSupport is enabled and throws a PropertyVetoException- See Also:
checkPropertyChange(String, Object)
public Object removeProperty(String key)
throws IllegalArgumentException
PropertyEntry
removeProperty in interface PropertyEntryIllegalArgumentException - if checkPropertyChange(key, value) throws one or
if the VetoableChangeSupport is enabled and throws a PropertyVetoException- See Also:
checkPropertyChange(String, Object)public void setAllFrom(Map<?,?> map)
public void putAll(Map<?,?> map)
checkPropertyChange()
public void clearProperties()
throws IllegalArgumentException
IllegalArgumentExceptionpublic Map<String,Object> getProperties()
setProperty(String, Object) method
getProperties in interface PropertyEntrypublic Properties asProperties()
public String toDetailedString()
DetailedString
toDetailedString in interface DetailedStringprotected boolean containsPropertyText(String text)
public boolean isVetoableChangeSupportEnabled()
protected void setVetoableChangeSupport(boolean flag)
isVetoableChangeSupportEnabled()
public void addVetoableChangeListener(VetoableChangeListener listener)
throws IllegalStateException
IllegalStateException - if the vetoable change support is not enabled on this objectisVetoableChangeSupportEnabled()
public void addVetoableChangeListener(String propertyKey,
VetoableChangeListener listener)
throws IllegalStateException
IllegalStateException - if the vetoable change support is not enabled on this objectisVetoableChangeSupportEnabled()
public void removeVetoableChangeListener(VetoableChangeListener listener)
throws IllegalStateException
IllegalStateException - if the vetoable change support is not enabled on this objectisVetoableChangeSupportEnabled()public VetoableChangeListener[] getVetoableChangeListeners()
isVetoableChangeSupportEnabled()public void setChangeListenerSupport(boolean flag)
isChangeListenerSupportEnabled()public boolean isChangeListenerSupportEnabled()
setChangeListenerSupport(boolean)
public void addPropertyChangeListener(PropertyChangeListener listener)
throws IllegalStateException
IllegalStateException - if the listener support is not enabled on this objectisChangeListenerSupportEnabled()
public void addPropertyChangeListener(String propertyKey,
PropertyChangeListener listener)
throws IllegalStateException
IllegalStateException - if the listener support is not enabled on this objectisChangeListenerSupportEnabled()
public void removePropertyChangeListener(PropertyChangeListener listener)
throws IllegalStateException
IllegalStateException - if the listener support is not enabled on this objectisChangeListenerSupportEnabled()public PropertyChangeListener[] getPropertyChangeListeners()
isChangeListenerSupportEnabled()public void setUndoSupported(boolean flag)
public boolean isUndoSupport()
public boolean undo()
public boolean redo()
public boolean canUndo()
public boolean canRedo()
public boolean containsValuePattern(CharSequence pattern)
public static PatternExtractor<PropertyEntry,String> getStringExtractor(String propertyKey)
public static PatternExtractor<PropertyEntry,Object> getPropertyExtractor(String propertyKey)
public static <T> PatternExtractor<PropertyEntry,T> getPropertyExtractor(String propertyKey,
Class<T> type)
public static Comparator<PropertyEntry> getPropertyComparator(String propertyKey)
throws IllegalArgumentException
IllegalArgumentException
|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||