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 2001 (C) Intalio, Inc. All Rights Reserved.
042: *
043: * $Id: Form.java 5951 2006-05-30 22:18:48Z bsnyder $
044: */package org.exolab.castor.xml.schema;
045:
046: /**
047: * Represents an enumerated type which consists of two values:
048: * "qualified" and "unqualified". This is used for the "form"
049: * property on attribute and element defintions as well as
050: * the attributeFormDefault and elementFormDefault proprties on
051: * the Schema itself.
052: *
053: * @author <a href="mailto:kvisco@intalio.com">Keith Visco</a>
054: * @version $Revision: 5951 $ $Date: 2003-03-03 00:05:44 -0700 (Mon, 03 Mar 2003) $
055: **/
056: public class Form {
057:
058: /**
059: * The String value for the qualified Form
060: **/
061: public static final String QUALIFIED_VALUE = "qualified";
062:
063: /**
064: * The String value for the unqualified Form
065: **/
066: public static final String UNQUALIFIED_VALUE = "unqualified";
067:
068: /**
069: * The Qualified Form Object
070: **/
071: public static final Form Qualified = new Form(QUALIFIED_VALUE);
072:
073: /**
074: * The Qualified Form Object
075: **/
076: public static final Form Unqualified = new Form(UNQUALIFIED_VALUE);
077:
078: /**
079: * The value of this Form
080: **/
081: private String _value = UNQUALIFIED_VALUE;
082:
083: /**
084: * Creates a new Form
085: *
086: * @param value the value of the Form
087: **/
088: private Form(String value) {
089: _value = value;
090: } //-- Form
091:
092: /**
093: * Returns the String value of this Form.
094: *
095: * @return the String value of this Form.
096: **/
097: public String getValue() {
098: return _value;
099: } //-- getValue
100:
101: /**
102: * Returns true if this Form is the qualified Form.
103: *
104: * @return true if this Form is the qualified Form.
105: **/
106: public boolean isQualified() {
107: return (this == Qualified);
108: } //-- isQualified
109:
110: /**
111: * Returns true if this Form is the unqualified Form.
112: *
113: * @return true if this Form is the unqualified Form.
114: **/
115: public boolean isUnqualified() {
116: return (this == Unqualified);
117: } //-- isUnqualified
118:
119: /**
120: * Returns the String value of this Form.
121: *
122: * @return the String value of this Form.
123: **/
124: public String toString() {
125: return _value;
126: } //-- toString
127:
128: /**
129: * Returns the Form corresponding to the given value.
130: *
131: * @param formValue the value of the Form to return.
132: * @return the Form corresponding to the given value.
133: * @exception IllegalArgumentException when the given value
134: * is not valid.
135: **/
136: public static Form valueOf(String formValue) {
137: if (QUALIFIED_VALUE.equals(formValue)) {
138: return Form.Qualified;
139: } else if (UNQUALIFIED_VALUE.equals(formValue)) {
140: return Form.Unqualified;
141: } else {
142: String err = formValue + " is not a valid Form value.";
143: throw new IllegalArgumentException(err);
144: }
145: } //-- valueOf
146:
147: } //-- Form
|