View Javadoc

1   ////////////////////////////////////////////////////////////////////////////////
2   // MillScript-XML: an Open Spice interpreter and batch website creation tool
3   // Copyright (C) 2006 Open World Ltd, Kevin Rogers
4   //
5   // This file is part of MillScript-XML.
6   //
7   // MillScript-XML is free software; you can redistribute it and/or modify it under
8   // the terms of the GNU General Public License as published by the Free
9   // Software Foundation; either version 2 of the License, or (at your option)
10  // any later version.
11  //
12  // MillScript-XML is distributed in the hope that it will be useful, but WITHOUT
13  // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
15  // more details.
16  //
17  // You should have received a copy of the GNU General Public License along with
18  // MillScript-XML; if not, write to the Free Software Foundation, Inc., 59 Temple
19  // Place, Suite 330, Boston, MA  02111-1307  USA
20  ////////////////////////////////////////////////////////////////////////////////
21  package org.millscript.millscript.render;
22  
23  import org.millscript.commons.util.IMap;
24  import org.millscript.commons.util.defaults.ChainedMapDefault;
25  import org.millscript.commons.util.map.EArrayMap;
26  import org.millscript.commons.xml.api.Name;
27  
28  /**
29   * This interface represents the namespaces that are currently in scope, it is
30   * a mapping from a prefix to it's IRI for the current scope.
31   */
32  public class PrefixToNamespaceMap extends EArrayMap< String, String > {
33  
34      /**
35       * This is the ID from the release 10.2.0 for future compatibility.
36       */
37      private static final long serialVersionUID = 7402068586916112285L;
38  
39      /**
40       * Constructs a new namespace to prefix map with the initial
41       * <code>xml</code> and <code>xmlns</code> prefixes declared.
42       */
43      public PrefixToNamespaceMap() {
44          this.insert( "", "" );
45          this.insert( "xml", Name.XML );
46          this.insert( "xmlns", Name.XMLNS );
47      }
48  
49      /**
50       * Constructs a new namespace to prefix map with the specified parent
51       * mapping and the given key-value pair array of mappings. If a given
52       * prefix is not found in the given array, a lookup will be performed on
53       * the parent map.
54       *
55       * @param parent    the map in which to lookup missing keys
56       * @param store the array of key-value pairs for this mapping
57       */
58      public PrefixToNamespaceMap( final IMap< String, String > parent ) {
59          this.setDefault(
60              new ChainedMapDefault< String, String >( parent )
61          );
62      }
63  
64  }