1 /**
2 * Redistribution and use of this software and associated documentation
3 * ("Software"), with or without modification, are permitted provided
4 * that the following conditions are met:
5 *
6 * 1. Redistributions of source code must retain copyright
7 * statements and notices. Redistributions must also contain a
8 * copy of this document.
9 *
10 * 2. Redistributions in binary form must reproduce the
11 * above copyright notice, this list of conditions and the
12 * following disclaimer in the documentation and/or other
13 * materials provided with the distribution.
14 *
15 * 3. The name "Exolab" must not be used to endorse or promote
16 * products derived from this Software without prior written
17 * permission of Intalio, Inc. For written permission,
18 * please contact info@exolab.org.
19 *
20 * 4. Products derived from this Software may not be called "Exolab"
21 * nor may "Exolab" appear in their names without prior written
22 * permission of Intalio, Inc. Exolab is a registered
23 * trademark of Intalio, Inc.
24 *
25 * 5. Due credit should be given to the Exolab Project
26 * (http://www.exolab.org/).
27 *
28 * THIS SOFTWARE IS PROVIDED BY INTALIO, INC. AND CONTRIBUTORS
29 * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
30 * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
31 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
32 * INTALIO, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
33 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
34 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
35 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
36 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
37 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
38 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
39 * OF THE POSSIBILITY OF SUCH DAMAGE.
40 *
41 * Copyright 2001 (C) Intalio, Inc. All Rights Reserved.
42 *
43 * $Id$
44 */
45
46
47 package org.exolab.castor.xml.schema;
48
49 import org.exolab.castor.xml.ValidationException;
50
51 /**
52 * A class which represents the selector for an IdentityConstraint
53 *
54 * @author <a href="mailto:kvisco@intalio.com">Keith Visco</a>
55 * @version $Revision$ $Date: 2006-04-14 04:14:43 -0600 (Fri, 14 Apr 2006) $
56 **/
57 public class IdentitySelector extends Annotated {
58 /** SerialVersionUID */
59 private static final long serialVersionUID = -66732684639814508L;
60
61 /**
62 * Identity Selector id (optional)
63 **/
64 private String _id = null;
65
66 /**
67 * XPath expression for selector nodes (required)
68 **/
69 private String _xpath = null;
70
71 /**
72 * Creates a new IdentitySelector.
73 *
74 * @param xpath the xpath for the IdentitySelector. Must not be null.
75 * @exception SchemaException if xpath is null.
76 **/
77 public IdentitySelector(String xpath)
78 throws SchemaException
79 {
80 setXPath(xpath);
81 } //-- IdentitySelector
82
83 /**
84 * Returns the Id of this IdentitySelector, or null if no
85 * Id has been set.
86 *
87 * @return the Id of this IdentitySelector, or null if no
88 * Id has been set.
89 **/
90 public String getId() {
91 return _id;
92 } //-- getId
93
94 /**
95 * Returns the XPath of this IdentitySelector. This value will
96 * never be null.
97 *
98 * @return the XPath of this IdentitySelector.
99 **/
100 public String getXPath() {
101 return _xpath;
102 } //-- getXPath
103
104
105 /**
106 * Sets the Id for this IdentitySelector.
107 *
108 * @param id the Id for this IdentitySelector.
109 **/
110 public void setId(String id) {
111 _id = id;
112 } //-- setId
113
114 /**
115 * Sets the XPath expression for this Selector.
116 *
117 * @param xpath the XPath expression for this IdentitySelector. Must not
118 * be null.
119 * @exception SchemaException if xpath is null.
120 **/
121 public void setXPath(String xpath)
122 throws SchemaException
123 {
124 if (xpath == null)
125 throw new SchemaException("The xpath of a 'selector' must not be null.");
126
127 _xpath = xpath;
128 } //-- setXPath
129
130 /**
131 * Returns the type of this Schema Structure
132 * @return the type of this Schema Structure
133 **/
134 public short getStructureType() {
135 return Structure.IDENTITY_SELECTOR;
136 } //-- getStructureType
137
138 /**
139 * Checks the validity of this Schema defintion.
140 * @exception ValidationException when this Schema definition
141 * is invalid.
142 **/
143 public void validate()
144 throws ValidationException
145 {
146 //-- do nothing, if it can be constructed, it's valid.
147 //-- validate XPath expression in the future?
148 } //-- validate
149
150 } //-- class: IdentitySelector