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: IdentitySelector.java 6230 2006-09-19 07:56:07Z wguttmn $
044: */package org.exolab.castor.xml.schema;
045:
046: import org.exolab.castor.xml.ValidationException;
047:
048: /**
049: * A class which represents the selector for an IdentityConstraint
050: *
051: * @author <a href="mailto:kvisco@intalio.com">Keith Visco</a>
052: * @version $Revision: 6230 $ $Date: 2006-04-14 04:14:43 -0600 (Fri, 14 Apr 2006) $
053: **/
054: public class IdentitySelector extends Annotated {
055: /** SerialVersionUID */
056: private static final long serialVersionUID = -66732684639814508L;
057:
058: /**
059: * Identity Selector id (optional)
060: **/
061: private String _id = null;
062:
063: /**
064: * XPath expression for selector nodes (required)
065: **/
066: private String _xpath = null;
067:
068: /**
069: * Creates a new IdentitySelector.
070: *
071: * @param xpath the xpath for the IdentitySelector. Must not be null.
072: * @exception SchemaException if xpath is null.
073: **/
074: public IdentitySelector(String xpath) throws SchemaException {
075: setXPath(xpath);
076: } //-- IdentitySelector
077:
078: /**
079: * Returns the Id of this IdentitySelector, or null if no
080: * Id has been set.
081: *
082: * @return the Id of this IdentitySelector, or null if no
083: * Id has been set.
084: **/
085: public String getId() {
086: return _id;
087: } //-- getId
088:
089: /**
090: * Returns the XPath of this IdentitySelector. This value will
091: * never be null.
092: *
093: * @return the XPath of this IdentitySelector.
094: **/
095: public String getXPath() {
096: return _xpath;
097: } //-- getXPath
098:
099: /**
100: * Sets the Id for this IdentitySelector.
101: *
102: * @param id the Id for this IdentitySelector.
103: **/
104: public void setId(String id) {
105: _id = id;
106: } //-- setId
107:
108: /**
109: * Sets the XPath expression for this Selector.
110: *
111: * @param xpath the XPath expression for this IdentitySelector. Must not
112: * be null.
113: * @exception SchemaException if xpath is null.
114: **/
115: public void setXPath(String xpath) throws SchemaException {
116: if (xpath == null)
117: throw new SchemaException(
118: "The xpath of a 'selector' must not be null.");
119:
120: _xpath = xpath;
121: } //-- setXPath
122:
123: /**
124: * Returns the type of this Schema Structure
125: * @return the type of this Schema Structure
126: **/
127: public short getStructureType() {
128: return Structure.IDENTITY_SELECTOR;
129: } //-- getStructureType
130:
131: /**
132: * Checks the validity of this Schema defintion.
133: * @exception ValidationException when this Schema definition
134: * is invalid.
135: **/
136: public void validate() throws ValidationException {
137: //-- do nothing, if it can be constructed, it's valid.
138: //-- validate XPath expression in the future?
139: } //-- validate
140:
141: } //-- class: IdentitySelector
|