Source Code Cross Referenced for Facet.java in  » Database-ORM » castor » org » exolab » castor » xml » schema » 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 » Database ORM » castor » org.exolab.castor.xml.schema 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * Redistribution and use of this software and associated documentation
003:         * ("Software"), with or without modification, are permitted provided
004:         * that the following conditions are met:
005:         *
006:         * 1. Redistributions of source code must retain copyright
007:         *    statements and notices.  Redistributions must also contain a
008:         *    copy of this document.
009:         *
010:         * 2. Redistributions in binary form must reproduce the
011:         *    above copyright notice, this list of conditions and the
012:         *    following disclaimer in the documentation and/or other
013:         *    materials provided with the distribution.
014:         *
015:         * 3. The name "Exolab" must not be used to endorse or promote
016:         *    products derived from this Software without prior written
017:         *    permission of Intalio, Inc.  For written permission,
018:         *    please contact info@exolab.org.
019:         *
020:         * 4. Products derived from this Software may not be called "Exolab"
021:         *    nor may "Exolab" appear in their names without prior written
022:         *    permission of Intalio, Inc. Exolab is a registered
023:         *    trademark of Intalio, Inc.
024:         *
025:         * 5. Due credit should be given to the Exolab Project
026:         *    (http://www.exolab.org/).
027:         *
028:         * THIS SOFTWARE IS PROVIDED BY INTALIO, INC. AND CONTRIBUTORS
029:         * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
030:         * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
031:         * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL
032:         * INTALIO, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
033:         * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
034:         * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
035:         * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
036:         * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
037:         * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
038:         * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
039:         * OF THE POSSIBILITY OF SUCH DAMAGE.
040:         *
041:         * Copyright 1999 (C) Intalio, Inc. All Rights Reserved.
042:         *
043:         * $Id: Facet.java 6605 2006-12-28 06:52:29Z ekuns $
044:         */package org.exolab.castor.xml.schema;
045:
046:        import org.exolab.castor.xml.ValidationException;
047:
048:        /**
049:         * Represents the base type for XML Schema Facets
050:         * @author <a href="mailto:kvisco@intalio.com">Keith Visco</a>
051:         * @version $Revision: 6605 $ $Date: 2005-12-13 14:58:48 -0700 (Tue, 13 Dec 2005) $
052:         **/
053:        public class Facet extends Annotated {
054:            /** SerialVersionUID */
055:            private static final long serialVersionUID = 7821829275720939922L;
056:
057:            public static final String ENUMERATION = "enumeration";
058:            public static final String LENGTH = "length";
059:            public static final String PATTERN = "pattern";
060:            public static final String PRECISION = "precision";
061:            public static final String MAX_EXCLUSIVE = "maxExclusive";
062:            public static final String MAX_INCLUSIVE = "maxInclusive";
063:            public static final String MIN_EXCLUSIVE = "minExclusive";
064:            public static final String MIN_INCLUSIVE = "minInclusive";
065:            public static final String MAX_LENGTH = "maxLength";
066:            public static final String MIN_LENGTH = "minLength";
067:            public static final String WHITESPACE = "whiteSpace";
068:            public static final String TOTALDIGITS = "totalDigits";
069:            public static final String FRACTIONDIGITS = "fractionDigits";
070:
071:            public static final String WHITESPACE_PRESERVE = "preserve";
072:            public static final String WHITESPACE_REPLACE = "replace";
073:            public static final String WHITESPACE_COLLAPSE = "collapse";
074:
075:            private static final String CLASSNAME = Facet.class.getName();
076:
077:            private static final String NULL_ARGUMENT = "A null argument was passed to "
078:                    + CLASSNAME + "#";
079:
080:            private static final String ZERO_LENGTH_STRING = "A zero-length String was passed to "
081:                    + CLASSNAME + "#";
082:
083:            /** The name of this Facet. */
084:            private final String _name;
085:            /** The character value of this Facet. */
086:            private final String _value;
087:
088:            /**
089:             * Creates a new Facet with the given name
090:             * @param name the name of the Facet
091:             * @param value the value of the Facet
092:             **/
093:            public Facet(String name, String value) {
094:                if (name == null) {
095:                    String err = NULL_ARGUMENT;
096:                    err += "Facet: 'name' and 'value' must not be null.";
097:                    throw new IllegalArgumentException(err);
098:                }
099:                if (name.length() == 0) {
100:                    String err = ZERO_LENGTH_STRING;
101:                    err += "Facet: 'name' and 'value' must not be zero-length.";
102:                    throw new IllegalArgumentException(err);
103:                }
104:                this ._name = name;
105:                this ._value = value;
106:            } //-- Facet
107:
108:            /**
109:             * Returns the name of this Facet
110:             * @return the name of this Facet
111:             **/
112:            public String getName() {
113:                return _name;
114:            } //-- getName
115:
116:            /**
117:             * Returns the character (String) representation of this facet
118:             * @return the value of this facet
119:             **/
120:            public String getValue() {
121:                return this ._value;
122:            } //-- getValue
123:
124:            /**
125:             * Returns true if this Facet can occur more than once, such
126:             * as the "enumeration" facet.
127:             * @return true if this Facet can occur more than once.
128:             **/
129:            public boolean isMultivalued() {
130:                return _name.equals(Facet.ENUMERATION)
131:                        || _name.equals(Facet.PATTERN);
132:            }
133:
134:            /**
135:             * Returns an int representation of the value of this facet
136:             * @return an int representation of the value of this facet
137:             * @throws NumberFormatException if the value fails to parse as a int.
138:             **/
139:            public int toInt() throws NumberFormatException {
140:                return Integer.parseInt(_value);
141:            } //-- toInt
142:
143:            /**
144:             * Returns a long representation of the value of this facet
145:             * @return a long representation of the value of this facet
146:             * @throws NumberFormatException if the value fails to parse as a long.
147:             **/
148:            public long toLong() throws NumberFormatException {
149:                return Long.parseLong(_value);
150:            } //-- toInt
151:
152:            /**
153:             * Returns an short representation of the value of this facet
154:             * @return an short representation of the value of this facet
155:             * @throws NumberFormatException if the value fails to parse as a short.
156:             **/
157:            public short toShort() throws NumberFormatException {
158:                return Short.parseShort(_value);
159:            } //-- toShort
160:
161:            /**
162:             * Returns a double representation of the value of this facet
163:             * @return a double representation of the value of this facet
164:             * @throws NumberFormatException if the value fails to parse as a float.
165:             */
166:            public float toFloat() throws NumberFormatException {
167:                if (_value.equals("INF"))
168:                    return Float.POSITIVE_INFINITY;
169:                if (_value.equals("-INF"))
170:                    return Float.NEGATIVE_INFINITY;
171:                return Float.valueOf(_value).floatValue();
172:            } //-- toInt
173:
174:            /**
175:             * Returns a double representation of the value of this facet
176:             * @return a double representation of the value of this facet
177:             * @throws NumberFormatException if the value fails to parse as a double.
178:             **/
179:            public double toDouble() throws NumberFormatException {
180:                return Double.valueOf(_value).doubleValue();
181:            } //-- toInt
182:
183:            /**
184:             * Returns a byte representation of the value of this facet
185:             * @return a byte representation of the value of this facet
186:             * @throws NumberFormatException if the value fails to parse as a byte.
187:             **/
188:            public byte toByte() throws NumberFormatException {
189:                return Byte.parseByte(_value);
190:            } //-- toInt
191:
192:            /**
193:             * Returns the type of this Schema Structure
194:             * @return the type of this Schema Structure
195:             **/
196:            public short getStructureType() {
197:                return Structure.FACET;
198:            } //-- getStructureType
199:
200:            /**
201:             * Checks the validity of this Schema defintion.
202:             * @exception ValidationException when this Schema definition
203:             * is invalid.
204:             **/
205:            public void validate() throws ValidationException {
206:                //-- do nothing for now
207:            } //-- validate
208:
209:        } //-- Facet
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.