Source Code Cross Referenced for PropertyManager.java in  » 6.0-JDK-Modules » sjsxp » com » sun » xml » stream » 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 » 6.0 JDK Modules » sjsxp » com.sun.xml.stream 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: PropertyManager.java,v 1.6 2007/04/06 13:49:02 spericas Exp $
003:         */
004:
005:        /*
006:         * The contents of this file are subject to the terms
007:         * of the Common Development and Distribution License
008:         * (the License).  You may not use this file except in
009:         * compliance with the License.
010:         * 
011:         * You can obtain a copy of the license at
012:         * https://glassfish.dev.java.net/public/CDDLv1.0.html.
013:         * See the License for the specific language governing
014:         * permissions and limitations under the License.
015:         * 
016:         * When distributing Covered Code, include this CDDL
017:         * Header Notice in each file and include the License file
018:         * at https://glassfish.dev.java.net/public/CDDLv1.0.html.
019:         * If applicable, add the following below the CDDL Header,
020:         * with the fields enclosed by brackets [] replaced by
021:         * you own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         * 
024:         * [Name of File] [ver.__] [Date]
025:         * 
026:         * Copyright 2006 Sun Microsystems Inc. All Rights Reserved
027:         */
028:
029:        package com.sun.xml.stream;
030:
031:        import java.util.HashMap;
032:        import javax.xml.stream.XMLInputFactory;
033:        import javax.xml.stream.XMLOutputFactory;
034:        import javax.xml.stream.XMLResolver;
035:
036:        /**
037:         *  This class manages different properties related to Stax specification and its implementation.
038:         * This class constructor also takes itself (PropertyManager object) as parameter and initializes the
039:         * object with the property taken from the object passed.
040:         *
041:         * @author  Neeraj Bajaj, neeraj.bajaj@sun.com
042:         * @author K.Venugopal@sun.com
043:         */
044:
045:        public class PropertyManager {
046:
047:            protected static final String STAX_NOTATIONS = "javax.xml.stream.notations";
048:            protected static final String STAX_ENTITIES = "javax.xml.stream.entities";
049:
050:            private static final String STRING_INTERNING = "http://xml.org/sax/features/string-interning";
051:
052:            HashMap supportedProps = new HashMap();
053:
054:            public static final int CONTEXT_READER = 1;
055:            public static final int CONTEXT_WRITER = 2;
056:
057:            /** Creates a new instance of PropertyManager */
058:            public PropertyManager(int context) {
059:                switch (context) {
060:                case CONTEXT_READER: {
061:                    initConfigurableReaderProperties();
062:                    break;
063:                }
064:                case CONTEXT_WRITER: {
065:                    initWriterProps();
066:                    break;
067:                }
068:                }
069:            }
070:
071:            /**
072:             * Initialize this object with the properties taken from passed PropertyManager object.
073:             */
074:            public PropertyManager(PropertyManager propertyManager) {
075:
076:                HashMap properties = propertyManager.getProperties();
077:                supportedProps.putAll(properties);
078:            }
079:
080:            private HashMap getProperties() {
081:                return supportedProps;
082:            }
083:
084:            /**
085:             * Important point:
086:             * 1. We are not exposing Xerces namespace property. Application should configure namespace through
087:             * Stax specific property.
088:             *
089:             */
090:            private void initConfigurableReaderProperties() {
091:                //spec default values
092:                supportedProps.put(XMLInputFactory.IS_NAMESPACE_AWARE,
093:                        Boolean.TRUE);
094:                supportedProps
095:                        .put(XMLInputFactory.IS_VALIDATING, Boolean.FALSE);
096:                supportedProps.put(
097:                        XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES,
098:                        Boolean.TRUE);
099:                supportedProps.put(
100:                        XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES,
101:                        Boolean.TRUE);
102:                supportedProps
103:                        .put(XMLInputFactory.IS_COALESCING, Boolean.FALSE);
104:                supportedProps.put(XMLInputFactory.SUPPORT_DTD, Boolean.TRUE);
105:                supportedProps.put(XMLInputFactory.REPORTER, null);
106:                supportedProps.put(XMLInputFactory.RESOLVER, null);
107:                supportedProps.put(XMLInputFactory.ALLOCATOR, null);
108:                supportedProps.put(STAX_NOTATIONS, null);
109:
110:                //zephyr (implementation) specific properties which can be set by the application.
111:                //interning is always done
112:                supportedProps.put(Constants.SAX_FEATURE_PREFIX
113:                        + Constants.STRING_INTERNING_FEATURE, Boolean.TRUE);
114:                //recognizing java encoding names by default
115:                supportedProps.put(Constants.XERCES_FEATURE_PREFIX
116:                        + Constants.ALLOW_JAVA_ENCODINGS_FEATURE, Boolean.TRUE);
117:                supportedProps.put(Constants.REUSE_INSTANCE, Boolean.FALSE);
118:                supportedProps.put(Constants.ZEPHYR_PROPERTY_PREFIX
119:                        + Constants.STAX_REPORT_CDATA_EVENT, Boolean.FALSE);
120:                supportedProps.put(Constants.XERCES_FEATURE_PREFIX
121:                        + Constants.WARN_ON_DUPLICATE_ATTDEF_FEATURE,
122:                        Boolean.FALSE);
123:                supportedProps.put(Constants.XERCES_FEATURE_PREFIX
124:                        + Constants.WARN_ON_DUPLICATE_ENTITYDEF_FEATURE,
125:                        Boolean.FALSE);
126:                supportedProps.put(Constants.XERCES_FEATURE_PREFIX
127:                        + Constants.WARN_ON_UNDECLARED_ELEMDEF_FEATURE,
128:                        Boolean.FALSE);
129:                supportedProps.put(Constants.ZEPHYR_PROPERTY_PREFIX
130:                        + Constants.IMPLEMENTATION_NAME, "sjsxp");
131:            }
132:
133:            private void initWriterProps() {
134:                supportedProps.put(XMLOutputFactory.IS_REPAIRING_NAMESPACES,
135:                        Boolean.FALSE);
136:                //default value of escaping characters is 'true'
137:                supportedProps.put(Constants.ESCAPE_CHARACTERS, Boolean.TRUE);
138:                supportedProps.put(Constants.REUSE_INSTANCE, Boolean.FALSE);
139:                supportedProps.put(Constants.ZEPHYR_PROPERTY_PREFIX
140:                        + Constants.IMPLEMENTATION_NAME, "sjsxp");
141:                supportedProps.put(Constants.ZEPHYR_PROPERTY_PREFIX
142:                        + Constants.OUTPUTSTREAM, null);
143:            }
144:
145:            /**
146:             * public void reset(){
147:             * supportedProps.clear() ;
148:             * }
149:             */
150:            public boolean containsProperty(String property) {
151:                return supportedProps.containsKey(property);
152:            }
153:
154:            public Object getProperty(String property) {
155:                return supportedProps.get(property);
156:            }
157:
158:            public void setProperty(String property, Object value) {
159:                String equivalentProperty = null;
160:                if (property == XMLInputFactory.IS_NAMESPACE_AWARE
161:                        || property.equals(XMLInputFactory.IS_NAMESPACE_AWARE)) {
162:                    equivalentProperty = Constants.XERCES_FEATURE_PREFIX
163:                            + Constants.NAMESPACES_FEATURE;
164:                } else if (property == XMLInputFactory.IS_VALIDATING
165:                        || property.equals(XMLInputFactory.IS_VALIDATING)) {
166:                    if ((value instanceof  Boolean)
167:                            && ((Boolean) value).booleanValue()) {
168:                        throw new java.lang.IllegalArgumentException(
169:                                "true value of isValidating not supported");
170:                    }
171:                } else if (property == STRING_INTERNING
172:                        || property.equals(STRING_INTERNING)) {
173:                    if ((value instanceof  Boolean)
174:                            && !((Boolean) value).booleanValue()) {
175:                        throw new java.lang.IllegalArgumentException(
176:                                "false value of " + STRING_INTERNING
177:                                        + "feature is not supported");
178:                    }
179:                } else if (property == XMLInputFactory.RESOLVER
180:                        || property.equals(XMLInputFactory.RESOLVER)) {
181:                    //add internal stax property
182:                    supportedProps.put(Constants.XERCES_PROPERTY_PREFIX
183:                            + Constants.STAX_ENTITY_RESOLVER_PROPERTY,
184:                            new StaxEntityResolverWrapper((XMLResolver) value));
185:                }
186:                supportedProps.put(property, value);
187:                if (equivalentProperty != null) {
188:                    supportedProps.put(equivalentProperty, value);
189:                }
190:            }
191:
192:            public String toString() {
193:                return supportedProps.toString();
194:            }
195:
196:        }//PropertyManager
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.