001: /**
002: * JOnAS: Java(TM) Open Application Server
003: * Copyright (C) 2005 Bull S.A.
004: * Contact: jonas-team@objectweb.org
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
019: * USA
020: *
021: * --------------------------------------------------------------------------
022: * $Id: HCElementRestrictions.java 7521 2005-10-19 02:14:21Z pasmith $
023: * --------------------------------------------------------------------------
024: */package org.objectweb.jonas.webapp.jonasadmin.xml.xs.hardcoded;
025:
026: import java.util.List;
027:
028: import org.objectweb.jonas.webapp.jonasadmin.xml.xs.ElementRestrictions;
029:
030: /**
031: * Represents schema restrictions for a single element. The restrictions are
032: * hard coded.
033: *
034: * @author Gregory Lapouchnian
035: * @author Patrick Smith
036: */
037: /**
038: * @author pasmith
039: *
040: * TODO To change the template for this generated type comment go to
041: * Window - Preferences - Java - Code Style - Code Templates
042: */
043: public class HCElementRestrictions implements ElementRestrictions {
044:
045: /** The name of the element. */
046: private String name;
047:
048: /** is this element complex */
049: private boolean isComplex = false;
050:
051: /** is this element a sequence */
052: private boolean isSequence = false;
053:
054: /** The children of this element. */
055: private List children;
056:
057: /** The attributes of this element.*/
058: private List attributes;
059:
060: /**
061: * Makes a new Hard coded element restriction.
062: * @param name the name of the element.
063: * @param complex is this element complex.
064: * @param children the children of this element.
065: * @param attrs the attributes of this element.
066: */
067: public HCElementRestrictions(String name, boolean complex,
068: List children, List attrs) {
069: this .name = name;
070: this .isComplex = complex;
071: this .children = children;
072: this .attributes = attrs;
073: }
074:
075: /**
076: * Is this element a simple type with no attributes.
077: * @return true if this element is simple with no attributes, false otherwise.
078: */
079: public boolean isSimpleAndNoAttributes() {
080: return (children == null && attributes == null);
081: }
082:
083: /**
084: * Returns a list of children for this element.
085: * @return a list of children for this element.
086: */
087: public List getChildren() {
088: return children;
089: }
090:
091: /**
092: * Set the list of children for this element.
093: * @param children the list of children for this element.
094: */
095: public void setChildren(List children) {
096: if (isComplex()) {
097: this .children = children;
098: }
099: }
100:
101: /**
102: * Is this element complex.
103: * @return true if this element is complex.
104: */
105: public boolean isComplex() {
106: return isComplex;
107: }
108:
109: /**
110: * Sets if this element is complex or not.
111: * @param isComplex if this element is complex or not.
112: */
113: public void setComplex(boolean isComplex) {
114: this .isComplex = isComplex;
115: }
116:
117: /**
118: * Returns the name of this element
119: * @return the name of this element.
120: */
121: public String getName() {
122: return name;
123: }
124:
125: /**
126: * sets the name of this element.
127: * @param name the name of this element.
128: */
129: public void setName(String name) {
130: this .name = name;
131: }
132:
133: /**
134: * Returns the list of attributes for this element.
135: * @return the list of attributes for this element.
136: */
137: public List getAttributes() {
138: return attributes;
139: }
140:
141: /**
142: * Sets the list of elements for this element.
143: * @param attributes the list of attributs to set for this element.
144: */
145: public void setAttributes(List attributes) {
146: this .attributes = attributes;
147: }
148:
149: /**
150: * Returns the min occurances for this element.
151: * @return the min occurances for this element.
152: */
153: public int getMinOccurs() {
154: return 0;
155: }
156:
157: /**
158: * Sets the min occurances for this element.
159: * @param min the min occurances for this element.
160: */
161: public void setMinOccurs(int min) {
162: // TODO Auto-generated method stub
163: }
164:
165: /**
166: * Returns the max occurances for this element.
167: * @return the max occurances for this element.
168: */
169: public int getMaxOccurs() {
170: return 0;
171: }
172:
173: /**
174: * Sets the max occurances for this element.
175: * @param min the max occurances for this element.
176: */
177: public void setMaxOccurs(int min) {
178: // TODO Auto-generated method stub
179: }
180:
181: /**
182: * Returns if this element is a sequence or not.
183: * @return true if this element is a sequence.
184: */
185: public boolean isSequence() {
186: return isSequence;
187: }
188:
189: /**
190: * Sets if this element is a sequence.
191: * @param isSequence the value to set if this element is a sequence.
192: */
193: public void setSequence(boolean isSequence) {
194: this.isSequence = isSequence;
195: }
196: }
|