Source Code Cross Referenced for NamespaceDefinition.java in  » XML » jibx-1.1.5 » org » jibx » binding » def » 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 » XML » jibx 1.1.5 » org.jibx.binding.def 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:        Copyright (c) 2003-2004, Dennis M. Sosnoski
003:        All rights reserved.
004:
005:        Redistribution and use in source and binary forms, with or without modification,
006:        are permitted provided that the following conditions are met:
007:
008:         * Redistributions of source code must retain the above copyright notice, this
009:           list of conditions and the following disclaimer.
010:         * Redistributions in binary form must reproduce the above copyright notice,
011:           this list of conditions and the following disclaimer in the documentation
012:           and/or other materials provided with the distribution.
013:         * Neither the name of JiBX nor the names of its contributors may be used
014:           to endorse or promote products derived from this software without specific
015:           prior written permission.
016:
017:        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
018:        ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
019:        WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
020:        DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
021:        ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
022:        (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
023:        LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
024:        ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
025:        (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
026:        SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
027:         */
028:
029:        package org.jibx.binding.def;
030:
031:        import org.jibx.runtime.JiBXException;
032:
033:        /**
034:         * Namespace definition from binding.
035:         *
036:         * @author Dennis M. Sosnoski
037:         * @version 1.0
038:         */
039:
040:        public class NamespaceDefinition {
041:            //
042:            // Enumeration for namespace usage.
043:
044:            /*package*/static final int NODEFAULT_USAGE = 0;
045:            /*package*/static final int ELEMENTS_USAGE = 1;
046:            /*package*/static final int ATTRIBUTES_USAGE = 2;
047:            /*package*/static final int ALLDEFAULT_USAGE = 3;
048:
049:            //
050:            // Actual instance data
051:
052:            /** Namespace URI. */
053:            private String m_uri;
054:
055:            /** Namespace prefix (may be <code>null</code>, but not ""). */
056:            private String m_prefix;
057:
058:            /** Index in namespace table for binding. */
059:            private int m_index;
060:
061:            /** Use by default for nested elements. */
062:            private boolean m_elementDefault;
063:
064:            /** Use by default for nested attributes. */
065:            private boolean m_attributeDefault;
066:
067:            /**
068:             * Constructor.
069:             *
070:             * @param uri namespace URI
071:             * @param prefix namespace prefix (may be <code>null</code> for default
072:             * namespace, but not "")
073:             * @param usage code for default usage of namespace
074:             * @throws JiBXException if configuration error
075:             */
076:
077:            public NamespaceDefinition(String uri, String prefix, int usage)
078:                    throws JiBXException {
079:                m_uri = uri;
080:                m_prefix = prefix;
081:                m_elementDefault = (usage == ALLDEFAULT_USAGE)
082:                        || (usage == ELEMENTS_USAGE);
083:                m_attributeDefault = (usage == ALLDEFAULT_USAGE)
084:                        || (usage == ATTRIBUTES_USAGE);
085:                if (usage != ELEMENTS_USAGE && prefix == null) {
086:                    throw new JiBXException(
087:                            "Prefix required for namespace unless element default");
088:                }
089:                if (m_attributeDefault && m_prefix == null) {
090:                    throw new JiBXException(
091:                            "Prefix required for attribute namespace");
092:                }
093:            }
094:
095:            /**
096:             * Check if default namespace for attributes.
097:             *
098:             * @return <code>true</code> if default namespace for attributes,
099:             * <code>false</code> if not
100:             */
101:
102:            public boolean isAttributeDefault() {
103:                return m_attributeDefault;
104:            }
105:
106:            /**
107:             * Check if default namespace for elements.
108:             *
109:             * @return <code>true</code> if default namespace for elements,
110:             * <code>false</code> if not
111:             */
112:
113:            public boolean isElementDefault() {
114:                return m_elementDefault;
115:            }
116:
117:            /**
118:             * Get prefix for namespace.
119:             *
120:             * @return namespace prefix (may be <code>null</code>, but not "")
121:             */
122:
123:            public String getPrefix() {
124:                return m_prefix;
125:            }
126:
127:            /**
128:             * Get namespace URI.
129:             *
130:             * @return namespace URI
131:             */
132:
133:            public String getUri() {
134:                return m_uri;
135:            }
136:
137:            /**
138:             * Set namespace index.
139:             *
140:             * @param index namespace index
141:             */
142:
143:            public void setIndex(int index) {
144:                m_index = index;
145:            }
146:
147:            /**
148:             * Get namespace index.
149:             *
150:             * @return namespace index
151:             */
152:
153:            public int getIndex() {
154:                return m_index;
155:            }
156:
157:            /**
158:             * Instance builder with supplied values. Used for canned definitions.
159:             * 
160:             * @param uri namespace URI
161:             * @param prefix namespace prefix
162:             * @throws JiBXException if configuration error
163:             */
164:
165:            public static NamespaceDefinition buildNamespace(String uri,
166:                    String prefix) throws JiBXException {
167:                return new NamespaceDefinition(uri, prefix, NODEFAULT_USAGE);
168:            }
169:
170:            // DEBUG
171:            public void print(int depth) {
172:                BindingDefinition.indent(depth);
173:                System.out.print("namespace " + m_uri);
174:                if (m_prefix != null) {
175:                    System.out.print(" (prefix " + m_prefix + ")");
176:                }
177:                System.out.println();
178:            }
179:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.