001: //$$HeadURL: https://svn.wald.intevation.org/svn/deegree/base/trunk/src/org/deegree/tools/shape/AVLPointSymbolCodeList.java $$
002: /*---------------- FILE HEADER ------------------------------------------
003: This file is part of deegree.
004: Copyright (C) 2001-2008 by:
005: Department of Geography, University of Bonn
006: http://www.giub.uni-bonn.de/deegree/
007: lat/lon GmbH
008: http://www.lat-lon.de
009:
010: This library is free software; you can redistribute it and/or
011: modify it under the terms of the GNU Lesser General Public
012: License as published by the Free Software Foundation; either
013: version 2.1 of the License, or (at your option) any later version.
014:
015: This library is distributed in the hope that it will be useful,
016: but WITHOUT ANY WARRANTY; without even the implied warranty of
017: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
018: Lesser General Public License for more details.
019:
020: You should have received a copy of the GNU Lesser General Public
021: License along with this library; if not, write to the Free Software
022: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
023:
024: Contact:
025:
026: Andreas Poth
027: lat/lon GmbH
028: Aennchenstraße 19
029: 53177 Bonn
030: Germany
031: E-Mail: poth@lat-lon.de
032:
033: Prof. Dr. Klaus Greve
034: Department of Geography
035: University of Bonn
036: Meckenheimer Allee 166
037: 53115 Bonn
038: Germany
039: E-Mail: greve@giub.uni-bonn.de
040:
041: ---------------------------------------------------------------------------*/
042: package org.deegree.tools.shape;
043:
044: import java.io.IOException;
045: import java.util.HashMap;
046: import java.util.List;
047: import java.util.Map;
048:
049: import org.deegree.framework.xml.NamespaceContext;
050: import org.deegree.framework.xml.XMLFragment;
051: import org.deegree.framework.xml.XMLParsingException;
052: import org.deegree.framework.xml.XMLTools;
053: import org.deegree.ogcbase.CommonNamespaces;
054: import org.w3c.dom.Document;
055: import org.w3c.dom.Node;
056: import org.xml.sax.SAXException;
057:
058: /**
059: *
060: *
061: * @author <a href="mailto:poth@lat-lon.de">Andreas Poth </a>
062: * @author last edited by: $Author: apoth $
063: *
064: * @version 1.1, $Revision: 9346 $, $Date: 2007-12-27 08:39:07 -0800 (Thu, 27 Dec 2007) $
065: *
066: * @since 1.1
067: */
068: class AVLPointSymbolCodeList {
069:
070: private static final String CODELIST = "AVLPointSymbolCodeList.xml";
071:
072: private Map<String, String> map = new HashMap<String, String>();
073:
074: /**
075: *
076: */
077: public AVLPointSymbolCodeList() throws SAXException, IOException,
078: XMLParsingException {
079:
080: XMLFragment frag = new XMLFragment(AVLPointSymbolCodeList.class
081: .getResource(CODELIST));
082: Document doc = frag.getRootElement().getOwnerDocument();
083:
084: /* ************************* OLD ********************************* */
085: // Node nsNode = XMLTools.getNamespaceNode( new String[] {} );
086: // NodeList nl = XMLTools.getXPath( "Symbols", element, nsNode );
087: NamespaceContext nsContext = CommonNamespaces
088: .getNamespaceContext();
089: List nl = XMLTools.getNodes(doc, "Symbols", nsContext);
090:
091: for (Object o : nl) {
092: if (o instanceof Node) {
093: Node n = (Node) o;
094: String code = XMLTools.getRequiredNodeAsString(n,
095: "@code", nsContext);
096: String sym = XMLTools.getRequiredNodeAsString(n,
097: "@symbol", nsContext);
098: map.put(code, sym);
099: }
100: }
101: }
102:
103: public String getSymbol(String code) {
104: return map.get(code);
105: }
106: }
|