|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object bibliothek.gui.dock.station.support.PlaceholderMap
public class PlaceholderMap
A data structure designed to store and retrieve placeholder information
persistently. This data structure basically is a map with a restricted set of types
that are allowed to be stored. This map uses arrays of Path
s as PlaceholderMap.Key
s, there are
two modes how to use the keys:
equals
method to compare keys==
operator to compare keysPlaceholderStrategy
to automatically delete
entries that are no longer valid.
Nested Class Summary | |
---|---|
static interface |
PlaceholderMap.Key
A key is a set of Path s, it is used to identify
entries in a PlaceholderMap . |
Constructor Summary | |
---|---|
PlaceholderMap(DataInputStream in,
PlaceholderStrategy strategy)
Creates a new map reading the content of the map directly from in . |
|
PlaceholderMap(Path format,
int version)
Creates a new map. |
|
PlaceholderMap(XElement in,
PlaceholderStrategy strategy)
Creates a new map reading the content of the map directly from in . |
Method Summary | |
---|---|
void |
add(PlaceholderMap.Key placeholder)
Adds the placeholder placeholder to this map. |
boolean |
contains(PlaceholderMap.Key placeholder,
String key)
Tells whether key exists for placeholder . |
PlaceholderMap |
copy()
Creates a deep copy of this map. |
PlaceholderMap.Key |
copyKey(PlaceholderMap.Key key)
Creates a copy of key . |
PlaceholderMap |
filter(PlaceholderStrategy strategy)
May return this or a copy of this PlaceholderMap to which strategy was applied. |
Object |
get(PlaceholderMap.Key placeholder,
String key)
Gets the data that is stored under key . |
Object[] |
getArray(PlaceholderMap.Key placeholder,
String key)
Gets the map that is stored under key |
boolean |
getBoolean(PlaceholderMap.Key placeholder,
String key)
Gets the boolean that is stored under key |
double |
getDouble(PlaceholderMap.Key placeholder,
String key)
Gets the double that is stored under key |
Path |
getFormat()
Gets the format of this map, the meaning of the format depends on the client. |
int |
getInt(PlaceholderMap.Key placeholder,
String key)
Gets the integer that is stored under key |
String[] |
getKeys(PlaceholderMap.Key placeholder)
Gets all keys that are in use for placeholder in the order
they were first used to put an object into this map. |
long |
getLong(PlaceholderMap.Key placeholder,
String key)
Gets the long that is stored under key |
PlaceholderMap |
getMap(PlaceholderMap.Key placeholder,
String key)
Gets the map that is stored under key |
Path |
getPath(PlaceholderMap.Key placeholder,
String key)
Gets the Path that is stored under key |
PlaceholderMap.Key[] |
getPlaceholders()
Gets all placeholders that are known to this map in the order they were added to this map. |
PlaceholderStrategy |
getPlaceholderStrategy()
Gets the strategy that is observed for removing invalid placeholders. |
String |
getString(PlaceholderMap.Key placeholder,
String key)
Gets the string that is stored under key |
int |
getVersion()
Gets the version of the format used in this map. |
boolean |
isEmpty()
Tells whether this map is completely empty. |
PlaceholderMap.Key |
newKey(Path... placeholders)
Creates a new shared key for any set of placeholders. |
PlaceholderMap.Key |
newKey(String anchor,
Path... placeholders)
Creates a new shared key for any set of placeholders. |
PlaceholderMap.Key |
newUniqueKey(Path... placeholders)
Creates a new non-shared key for any set of placeholders. |
PlaceholderMap.Key |
newUniqueKey(String anchor,
Path... placeholders)
Creates a new non-shared key for any set of placeholders. |
void |
put(PlaceholderMap.Key placeholder,
String key,
Object value)
Stores the value value in this map, adds
placeholder if necessary, overrides the value stored at
key if existent.It is the clients responsibility not to introduce cycles of object references. |
void |
putArray(PlaceholderMap.Key placeholder,
String key,
Object[] value)
Stores the value value in this map, adds
placeholder if necessary, overrides the value stored at
key if existent. |
void |
putBoolean(PlaceholderMap.Key placeholder,
String key,
boolean value)
Stores the value value in this map, adds
placeholder if necessary, overrides the value stored at
key if existent. |
void |
putDouble(PlaceholderMap.Key placeholder,
String key,
double value)
Stores the value value in this map, adds
placeholder if necessary, overrides the value stored at
key if existent. |
void |
putInt(PlaceholderMap.Key placeholder,
String key,
int value)
Stores the value value in this map, adds
placeholder if necessary, overrides the value stored at
key if existent. |
void |
putLong(PlaceholderMap.Key placeholder,
String key,
long value)
Stores the value value in this map, adds
placeholder if necessary, overrides the value stored at
key if existent. |
void |
putMap(PlaceholderMap.Key placeholder,
String key,
PlaceholderMap value)
Stores the value value in this map, adds
placeholder if necessary, overrides the value stored at
key if existent. |
void |
putPath(PlaceholderMap.Key placeholder,
String key,
Path value)
Stores the value value in this map, adds
placeholder if necessary, overrides the value stored at
key if existent. |
void |
putString(PlaceholderMap.Key placeholder,
String key,
String value)
Stores the value value in this map, adds
placeholder if necessary, overrides the value stored at
key if existent. |
void |
remove(PlaceholderMap.Key placeholder)
Removes placeholder and all information that is associated with
placeholder from this map. |
Object |
remove(PlaceholderMap.Key placeholder,
String key)
Removes the value that is stored at key . |
void |
removeAll(Path placeholder,
boolean recursive)
Removes all occurrences of placeholders . |
void |
removeAll(Set<Path> placeholders,
boolean recursive)
Removes all occurrences of all elements of placeholders . |
void |
setPlaceholderStrategy(PlaceholderStrategy strategy)
Sets the strategy that is used to automatically remove invalid placeholders. |
String |
toString()
|
void |
validate(PlaceholderStrategy strategy,
boolean recursive)
Using strategy removes all placeholders that are invalid. |
void |
write(DataOutputStream out)
Writes the contents of this map into out . |
void |
write(XElement out)
Writes the contents of this map into out . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public PlaceholderMap(Path format, int version)
format
- the kind of data stored in this map, the exact meaning depends on the client
that is using this mapversion
- the version of the format, the exact meaning depends on the client
that is using this mappublic PlaceholderMap(DataInputStream in, PlaceholderStrategy strategy) throws IOException
in
.
in
- the contentstrategy
- guard to identify the placeholders which are allowed to be stored, can be null
IOException
- in case of an I/O errorpublic PlaceholderMap(XElement in, PlaceholderStrategy strategy)
in
.
in
- the content to readstrategy
- guard to identify the placeholders which are allowed to be stored, can be null
Method Detail |
---|
public void write(DataOutputStream out) throws IOException
out
.
out
- the stream to write into
IOException
- in case of an I/O errorpublic void write(XElement out)
out
.
out
- the element to fill, its attributes will not be modifiedpublic PlaceholderMap copy()
null
public PlaceholderMap filter(PlaceholderStrategy strategy)
PlaceholderMap
to which strategy
was applied. The
strategy of the result may or may not be set. This map is not modified by this method.
strategy
- the strategy to apply
public PlaceholderMap.Key newKey(Path... placeholders)
placeholders
- the placeholders of the key
public PlaceholderMap.Key newKey(String anchor, Path... placeholders)
anchor
- if the anchor is set, then this key cannot be automatically deleted. It is the clients responsibility
to ensure that no two keys have the same anchor. If two keys have the same anchor, then one of them might override
the other one leading to data loss. Can be null
.placeholders
- the placeholders of the key
public PlaceholderMap.Key newUniqueKey(Path... placeholders)
placeholders
- the placeholders of the key
public PlaceholderMap.Key newUniqueKey(String anchor, Path... placeholders)
placeholders
- the placeholders of the keyanchor
- if the anchor is set, then this key cannot be automatically deleted. It is the clients responsibility
to ensure that no two keys have the same anchor. If two keys have the same anchor, then one of them might override
the other one leading to data loss. Can be null
.
public PlaceholderMap.Key copyKey(PlaceholderMap.Key key)
key
.
key
- the key to copy
public void setPlaceholderStrategy(PlaceholderStrategy strategy)
PlaceholderMap
s that are
stored within this map.
strategy
- the new strategy, can be null
public PlaceholderStrategy getPlaceholderStrategy()
null
public void validate(PlaceholderStrategy strategy, boolean recursive)
strategy
removes all placeholders that are invalid.
strategy
- the strategy for checking the placeholders, a value or null
means that all placeholders are validrecursive
- if true
then validate(PlaceholderStrategy,boolean)
is also
called on all sub-maps of this mappublic void removeAll(Path placeholder, boolean recursive)
placeholders
.
placeholder
- the placeholder to removerecursive
- if true
, this method is called recusively on
every sub-map in this mappublic void removeAll(Set<Path> placeholders, boolean recursive)
placeholders
.
placeholders
- the placeholders to removerecursive
- if true
, this method is called recusively on
every sub-map in this mappublic int getVersion()
the format
public Path getFormat()
null
public void add(PlaceholderMap.Key placeholder)
placeholder
to this map. Nothing happens
if placeholder
is already in this map.
placeholder
- the new placeholder, not null
public void remove(PlaceholderMap.Key placeholder)
placeholder
and all information that is associated with
placeholder
from this map.
placeholder
- the placeholder to clearpublic PlaceholderMap.Key[] getPlaceholders()
added
to this map.
public String[] getKeys(PlaceholderMap.Key placeholder)
placeholder
in the order
they were first used to put an object into this map.
placeholder
- some placeholder
null
if placeholder
is not
known to this mappublic boolean isEmpty()
true
if there are no data stored in this mappublic void putString(PlaceholderMap.Key placeholder, String key, String value)
value
in this map, adds
placeholder
if necessary, overrides the value stored at
key
if existent.
placeholder
- the placeholder for which value
is storedkey
- the unique identifier of the valuevalue
- the new value, not null
public void putPath(PlaceholderMap.Key placeholder, String key, Path value)
value
in this map, adds
placeholder
if necessary, overrides the value stored at
key
if existent.
placeholder
- the placeholder for which value
is storedkey
- the unique identifier of the valuevalue
- the new value, not null
public void putInt(PlaceholderMap.Key placeholder, String key, int value)
value
in this map, adds
placeholder
if necessary, overrides the value stored at
key
if existent.
placeholder
- the placeholder for which value
is storedkey
- the unique identifier of the valuevalue
- the new valuepublic void putLong(PlaceholderMap.Key placeholder, String key, long value)
value
in this map, adds
placeholder
if necessary, overrides the value stored at
key
if existent.
placeholder
- the placeholder for which value
is storedkey
- the unique identifier of the valuevalue
- the new valuepublic void putBoolean(PlaceholderMap.Key placeholder, String key, boolean value)
value
in this map, adds
placeholder
if necessary, overrides the value stored at
key
if existent.
placeholder
- the placeholder for which value
is storedkey
- the unique identifier of the valuevalue
- the new valuepublic void putDouble(PlaceholderMap.Key placeholder, String key, double value)
value
in this map, adds
placeholder
if necessary, overrides the value stored at
key
if existent.
placeholder
- the placeholder for which value
is storedkey
- the unique identifier of the valuevalue
- the new valuepublic void putMap(PlaceholderMap.Key placeholder, String key, PlaceholderMap value)
value
in this map, adds
placeholder
if necessary, overrides the value stored at
key
if existent.
placeholder
- the placeholder for which value
is storedkey
- the unique identifier of the valuevalue
- the new value, not null
public void putArray(PlaceholderMap.Key placeholder, String key, Object[] value)
value
in this map, adds
placeholder
if necessary, overrides the value stored at
key
if existent.
placeholder
- the placeholder for which value
is storedkey
- the unique identifier of the valuevalue
- the new value, not null
. May contain any data type
for which this map offers a put-method.public void put(PlaceholderMap.Key placeholder, String key, Object value)
value
in this map, adds
placeholder
if necessary, overrides the value stored at
key
if existent.
placeholder
- the placeholder for which value
is storedkey
- the unique identifier of the valuevalue
- the new value, not null
IllegalArgumentException
- if value
is neither
String
, Integer
, Long
, Double
, Boolean
PlaceholderMap
nor an array of Object
s containing the mentioned data typespublic Object remove(PlaceholderMap.Key placeholder, String key)
key
. Note that this
method will not remove placeholder
from this map even
if there is no data left associated with placeholder
.
placeholder
- the placeholder in whose realm the data is deletedkey
- the unique identifier of the removed data
null
public boolean contains(PlaceholderMap.Key placeholder, String key)
key
exists for placeholder
.
placeholder
- the placeholder in whose realm key
should existkey
- the key to search
true
if there is some data storedpublic String getString(PlaceholderMap.Key placeholder, String key)
key
placeholder
- the placeholder in whose realm to searchkey
- the unique identifier of the searched data
null
IllegalArgumentException
- if either the value is of the wrong type or missingpublic Path getPath(PlaceholderMap.Key placeholder, String key)
Path
that is stored under key
placeholder
- the placeholder in whose realm to searchkey
- the unique identifier of the searched data
null
IllegalArgumentException
- if either the value is of the wrong type or missingpublic int getInt(PlaceholderMap.Key placeholder, String key)
key
placeholder
- the placeholder in whose realm to searchkey
- the unique identifier of the searched data
null
IllegalArgumentException
- if either the value is of the wrong type or missingpublic long getLong(PlaceholderMap.Key placeholder, String key)
key
placeholder
- the placeholder in whose realm to searchkey
- the unique identifier of the searched data
null
IllegalArgumentException
- if either the value is of the wrong type or missingpublic boolean getBoolean(PlaceholderMap.Key placeholder, String key)
key
placeholder
- the placeholder in whose realm to searchkey
- the unique identifier of the searched data
null
IllegalArgumentException
- if either the value is of the wrong type or missingpublic double getDouble(PlaceholderMap.Key placeholder, String key)
key
placeholder
- the placeholder in whose realm to searchkey
- the unique identifier of the searched data
null
IllegalArgumentException
- if either the value is of the wrong type or missingpublic PlaceholderMap getMap(PlaceholderMap.Key placeholder, String key)
key
placeholder
- the placeholder in whose realm to searchkey
- the unique identifier of the searched data
null
IllegalArgumentException
- if either the value is of the wrong type or missingpublic Object[] getArray(PlaceholderMap.Key placeholder, String key)
key
placeholder
- the placeholder in whose realm to searchkey
- the unique identifier of the searched data
null
IllegalArgumentException
- if either the value is of the wrong type or missingpublic Object get(PlaceholderMap.Key placeholder, String key)
key
.
placeholder
- the realm in which to searchkey
- the key of the data
null
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |