1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.millscript.commons.xml.tokenizer;
22
23 import org.millscript.commons.util.IMap;
24 import org.millscript.commons.util.IMapDefault;
25 import org.millscript.commons.util.defaults.ChainedMapDefault;
26 import org.millscript.commons.util.defaults.ConstantMapDefault;
27 import org.millscript.commons.util.map.IArrayMap;
28 import org.millscript.commons.xml.api.Name;
29
30 /**
31 * This interface represents the namespaces that are currently in scope, it is
32 * a mapping from a prefix to it's IRI for the current scope.
33 */
34 public class PrefixToNamespaceMap extends IArrayMap< String, String > {
35
36 /**
37 * This is the ID from the release 0.3.0 for future compatibility.
38 */
39 private static final long serialVersionUID = -2468263354341428509L;
40
41 public static final IMapDefault< String, String > NAMESPACE_MAP_DEFAULT = new ConstantMapDefault< String, String >( "" );
42
43 /**
44 * Constructs a new namespace to prefix map with the initial
45 * <code>xml</code> and <code>xmlns</code> prefixes declared.
46 */
47 public PrefixToNamespaceMap() {
48 super(
49 new String[] {
50 "", "",
51 "xml", Name.XML,
52 "xmlns", Name.XMLNS
53 },
54 true
55 );
56 this.setDefault( NAMESPACE_MAP_DEFAULT );
57 }
58
59 /**
60 * Constructs a new namespace to prefix map with the specified parent
61 * mapping and the given key-value pair array of mappings. If a given
62 * prefix is not found in the given array, a lookup will be performed on
63 * the parent map.
64 *
65 * @param parent the map in which to lookup missing keys
66 * @param store the array of key-value pairs for this mapping
67 */
68 public PrefixToNamespaceMap( final IMap< String, String > parent, final String[] store ) {
69 super( store, true );
70 this.setDefault(
71 new ChainedMapDefault< String, String >( parent )
72 );
73 }
74
75 }