Source Code Cross Referenced for NameSpaceTranslatorFactory.java in  » GIS » GeoServer » org » geoserver » wfs » xml » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » GIS » GeoServer » org.geoserver.wfs.xml 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Created on Feb 5, 2004
003:         *
004:         * To change the template for this generated file go to
005:         * Window - Preferences - Java - Code Generation - Code and Comments
006:         */
007:        package org.geoserver.wfs.xml;
008:
009:        import java.lang.reflect.Constructor;
010:        import java.util.HashMap;
011:        import java.util.Map;
012:
013:        /**
014:         * NameSpaceTranslatorFactory purpose.
015:         * <p>
016:         * Follows the factory pattern. Creates and stores a list of name space translators.
017:         * </p>
018:         * @see NameSpaceTranslator
019:         * @author dzwiers, Refractions Research, Inc.
020:         * @author $Author: dmzwiers $ (last modification)
021:         * @version $Id: NameSpaceTranslatorFactory.java 6177 2007-02-19 10:11:27Z aaime $
022:         */
023:        public class NameSpaceTranslatorFactory {
024:            /** map of namespace names as Strings -> Class representations of NameSpaceTranslators */
025:            private Map namespaceTranslators;
026:
027:            /** map of prefixs as String -> Instances of NameSpaceTranslators */
028:            private Map namespaceTranslatorInstances;
029:
030:            /** the only instance */
031:            private final static NameSpaceTranslatorFactory instance = new NameSpaceTranslatorFactory();
032:
033:            /**
034:             * NameSpaceTranslatorFactory constructor.
035:             * <p>
036:             * Loads some default prefixes into memory when the class is first loaded.
037:             * </p>
038:             *
039:             */
040:            private NameSpaceTranslatorFactory() {
041:                namespaceTranslators = new HashMap();
042:                namespaceTranslatorInstances = new HashMap();
043:
044:                //TODO replace null for these default namespaces.
045:                namespaceTranslators.put("http://www.w3.org/2001/XMLSchema",
046:                        XMLSchemaTranslator.class);
047:                namespaceTranslators.put("http://www.opengis.net/gml",
048:                        GMLSchemaTranslator.class);
049:
050:                addNameSpaceTranslator("xs", "http://www.w3.org/2001/XMLSchema");
051:                addNameSpaceTranslator("xsd",
052:                        "http://www.w3.org/2001/XMLSchema");
053:                addNameSpaceTranslator("gml", "http://www.opengis.net/gml");
054:            }
055:
056:            /**
057:             * getInstance purpose.
058:             * <p>
059:             * Completes the singleton pattern of this factory class.
060:             * </p>
061:             * @return NameSpaceTranslatorFactory The instance.
062:             */
063:            public static NameSpaceTranslatorFactory getInstance() {
064:                return instance;
065:            }
066:
067:            /**
068:             * addNameSpaceTranslator purpose.
069:             * <p>
070:             * Adds a new translator for the namespace specified if a
071:             * NameSpaceTranslator was registered for that namespace.
072:             * </p>
073:             * <p>
074:             * Some the magic for creating instances using the classloader occurs here
075:             * (ie. the translators are not loaded lazily)
076:             * </p>
077:             * @param prefix The desired namespace prefix
078:             * @param namespace The desired namespace.
079:             */
080:            public void addNameSpaceTranslator(String prefix, String namespace) {
081:                if ((prefix == null) || (namespace == null)) {
082:                    throw new NullPointerException();
083:                }
084:
085:                try {
086:                    Class nstClass = (Class) namespaceTranslators
087:                            .get(namespace);
088:
089:                    if (nstClass == null) {
090:                        return;
091:                    }
092:
093:                    Constructor nstConstructor = nstClass
094:                            .getConstructor(new Class[] { String.class, });
095:                    NameSpaceTranslator nst = (NameSpaceTranslator) nstConstructor
096:                            .newInstance(new Object[] { prefix, });
097:                    namespaceTranslatorInstances.put(prefix, nst);
098:                } catch (Exception e) {
099:                    e.printStackTrace();
100:                }
101:            }
102:
103:            /**
104:             * getNameSpaceTranslator purpose.
105:             * <p>
106:             * Description ...
107:             * </p>
108:             * @param prefix the prefix of the translator to get.
109:             * @return the translator, or null if it was not found
110:             */
111:            public NameSpaceTranslator getNameSpaceTranslator(String prefix) {
112:                return (NameSpaceTranslator) namespaceTranslatorInstances
113:                        .get(prefix);
114:            }
115:
116:            /**
117:             * registerNameSpaceTranslator purpose.
118:             * <p>
119:             * Registers a namespace and it's translator with the factory. good for adding additional namespaces :)
120:             * </p>
121:             * @param namespace The namespace.
122:             * @param nameSpaceTranslator The translator class for this namespace.
123:             */
124:            public void registerNameSpaceTranslator(String namespace,
125:                    Class nameSpaceTranslator) {
126:                if ((nameSpaceTranslator != null)
127:                        && NameSpaceTranslator.class
128:                                .isAssignableFrom(nameSpaceTranslator)) {
129:                    namespaceTranslators.put(namespace, nameSpaceTranslator);
130:                }
131:            }
132:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.