Package eu.bandm.tools.util.xml
Class NamespaceName2String
- All Implemented Interfaces:
Map<NamespaceName,
String>
Maintains a map from to
String
,
and reads different file formats.
FIXME delegatin to ".map" raus,
use simply "extends HashMap<NamespaceName,String>"-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,
V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object, V extends Object> -
Field Summary
-
Constructor Summary
ConstructorDescriptionConstruct an empty map.Constructs a map with the given data. -
Method Summary
Modifier and TypeMethodDescriptionboolean
containsPattern
(String patternMarker) Returns whether the pattern marker is contained anywhere in the values of this map.void
divideValues
(Predicate<String> test, NamespaceName2String yes, NamespaceName2String no) Pipe all entries in this instance according to the result of test to their values.void
dump
(PrintStream p) Print this map in a symbolic representation to the print stream.entrySet()
boolean
Directly delegate to the implementing map.<A,
B> void fillFromOptions
(MessageReceiver<SimpleMessage<?>> msg, @Opt List<A> files, @Opt List<B> pairs) Add the pairs from the files and then the pairs directly contained in a command line option.void
Create a map reading the data from the given source.void
Create a map reading the data from the given source.void
from
(InputStream s, Charset encoding) Create a map reading the data from the given source.void
Create a map reading the data from the given source.void
Add a key/value pair to the map.int
hashCode()
Directly delegate to the implementing map.put
(NamespaceName k, String v) replacePattern
(String patternMarker, String value) Return a new copy in the data of which all occurences of the patternMarker are replaced by the given value.Methods inherited from class java.util.AbstractMap
clear, clone, containsKey, containsValue, get, isEmpty, keySet, putAll, remove, size, toString, values
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Field Details
-
map
The stored data. Can freely be manipulated from outside without harm, but the methods provided here are more convenient.
-
-
Constructor Details
-
NamespaceName2String
public NamespaceName2String()Construct an empty map. (This constructor is required by collections framework convention.) -
NamespaceName2String
Constructs a map with the given data.
-
-
Method Details
-
equals
Directly delegate to the implementing map.- Specified by:
equals
in interfaceMap<NamespaceName,
String> - Overrides:
equals
in classAbstractMap<NamespaceName,
String>
-
hashCode
public int hashCode()Directly delegate to the implementing map.- Specified by:
hashCode
in interfaceMap<NamespaceName,
String> - Overrides:
hashCode
in classAbstractMap<NamespaceName,
String>
-
from
Create a map reading the data from the given source. For details of the file format seefrom(reader)
.- Throws:
IOException
-
from
Create a map reading the data from the given source. UseStandardCharsets.UTF_8
as encoding. For details of the file format seefrom(reader)
.- Throws:
IOException
-
from
Create a map reading the data from the given source. For details of the file format seefrom(reader)
.- Throws:
IOException
-
from
Create a map reading the data from the given source. Each line must start with a namespace name used as a key. The key is limited by a single blank. It must follow the inline syntax, seeNamespaceName.parseInlineURIFormat(java.lang.String)
. The rest of the line, after that separating single blank, is the value stored with the key. With duplicate keys, the later overrides the earlier without notice.Empty lines or lines starting with a "
#
" are ignored as comments.- Throws:
IOException
-
from
Add a key/value pair to the map. The key must follow the inline syntax, seeNamespaceName.parseInlineURIFormat(java.lang.String)
. With double keys, the later overrides the earlier without notice.- Parameters:
k
- the key must be parseable byNamespaceName#parseInlineURIFormat()
.- Throws:
IllegalArgumentException
-
dump
Print this map in a symbolic representation to the print stream. -
entrySet
- Specified by:
entrySet
in interfaceMap<NamespaceName,
String> - Specified by:
entrySet
in classAbstractMap<NamespaceName,
String>
-
put
- Specified by:
put
in interfaceMap<NamespaceName,
String> - Overrides:
put
in classAbstractMap<NamespaceName,
String>
-
containsPattern
Returns whether the pattern marker is contained anywhere in the values of this map. (Prototypical use with xslt style-sheet parameters.) -
replacePattern
Return a new copy in the data of which all occurences of the patternMarker are replaced by the given value. (Prototypical use with xslt style-sheet parameters.) -
divideValues
Pipe all entries in this instance according to the result of test to their values.- Parameters:
test
- criterium for the divisionyes
- where to copy the entry in case of a positive test resultno
- where to copy the entry in case of a negative test result
-
fillFromOptions
public <A,B> void fillFromOptions(MessageReceiver<SimpleMessage<?>> msg, @Opt @Opt List<A> files, @Opt @Opt List<B> pairs) Add the pairs from the files and then the pairs directly contained in a command line option. A file later in the list has priority over its predecessors; explicit assignments from the command line option have priority over the files' contents.Since the options compiler generates totally independent classes for each application, this code must use reflection to get the getter methods. Exceptions caused by reflection application are translated to error messages.
- Parameters:
A
- the type of value objects. Must provide a method "get_0()
" which delivers a String which is a file name.B
- the type of value objects. Must provide methods "get_0()
" and "get_1()
" which deliver the NamespaceName key and a String value.
-