001: /*
002: * This class was automatically generated with
003: * <a href="http://www.castor.org">Castor 1.1-M2</a>, using an XML
004: * Schema.
005: * $Id: ClassType.java 6766 2007-01-18 21:12:08Z wguttmn $
006: */
007:
008: package org.exolab.castor.builder.binding.xml;
009:
010: //---------------------------------/
011: //- Imported classes and packages -/
012: //---------------------------------/
013:
014: import org.exolab.castor.xml.Marshaller;
015: import org.exolab.castor.xml.Unmarshaller;
016:
017: /**
018: * This type gathers the needed information to generate a Java
019: * Class
020: * from a binding file. Options such as generating the equals
021: * method,
022: * using wrapper classes for primitives or using bound properties
023: * can
024: * be defined via that element. When defined locally the options
025: * override
026: * the values defined in the castor.properties file.
027: *
028: *
029: * @version $Revision: 6766 $ $Date$
030: */
031: public class ClassType implements java.io.Serializable {
032:
033: //--------------------------/
034: //- Class/Member Variables -/
035: //--------------------------/
036:
037: /**
038: * Field _package.
039: */
040: private java.lang.String _package;
041:
042: /**
043: * Field _name.
044: */
045: private java.lang.String _name;
046:
047: /**
048: * Field _final.
049: */
050: private boolean _final;
051:
052: /**
053: * keeps track of state for field: _final
054: */
055: private boolean _has_final;
056:
057: /**
058: * Field _abstract.
059: */
060: private boolean _abstract;
061:
062: /**
063: * keeps track of state for field: _abstract
064: */
065: private boolean _has_abstract;
066:
067: /**
068: * Field _equals.
069: */
070: private boolean _equals;
071:
072: /**
073: * keeps track of state for field: _equals
074: */
075: private boolean _has_equals;
076:
077: /**
078: * Field _bound.
079: */
080: private boolean _bound;
081:
082: /**
083: * keeps track of state for field: _bound
084: */
085: private boolean _has_bound;
086:
087: /**
088: * Field _implementsList.
089: */
090: private java.util.List _implements List;
091:
092: /**
093: * Field _extends.
094: */
095: private java.lang.String _extends;
096:
097: //----------------/
098: //- Constructors -/
099: //----------------/
100:
101: public ClassType() {
102: super ();
103: this ._implements List = new java.util.ArrayList();
104: }
105:
106: //-----------/
107: //- Methods -/
108: //-----------/
109:
110: /**
111: *
112: *
113: * @param vImplements
114: * @throws java.lang.IndexOutOfBoundsException if the index
115: * given is outside the bounds of the collection
116: */
117: public void addImplements(final java.lang.String vImplements)
118: throws java.lang.IndexOutOfBoundsException {
119: this ._implements List.add(vImplements);
120: }
121:
122: /**
123: *
124: *
125: * @param index
126: * @param vImplements
127: * @throws java.lang.IndexOutOfBoundsException if the index
128: * given is outside the bounds of the collection
129: */
130: public void addImplements(final int index,
131: final java.lang.String vImplements)
132: throws java.lang.IndexOutOfBoundsException {
133: this ._implements List.add(index, vImplements);
134: }
135:
136: /**
137: */
138: public void deleteAbstract() {
139: this ._has_abstract = false;
140: }
141:
142: /**
143: */
144: public void deleteBound() {
145: this ._has_bound = false;
146: }
147:
148: /**
149: */
150: public void deleteEquals() {
151: this ._has_equals = false;
152: }
153:
154: /**
155: */
156: public void deleteFinal() {
157: this ._has_final = false;
158: }
159:
160: /**
161: * Method enumerateImplements.
162: *
163: * @return an Enumeration over all possible elements of this
164: * collection
165: */
166: public java.util.Enumeration enumerateImplements() {
167: return java.util.Collections.enumeration(this ._implements List);
168: }
169:
170: /**
171: * Returns the value of field 'abstract'.
172: *
173: * @return the value of field 'Abstract'.
174: */
175: public boolean getAbstract() {
176: return this ._abstract;
177: }
178:
179: /**
180: * Returns the value of field 'bound'.
181: *
182: * @return the value of field 'Bound'.
183: */
184: public boolean getBound() {
185: return this ._bound;
186: }
187:
188: /**
189: * Returns the value of field 'equals'.
190: *
191: * @return the value of field 'Equals'.
192: */
193: public boolean getEquals() {
194: return this ._equals;
195: }
196:
197: /**
198: * Returns the value of field 'extends'.
199: *
200: * @return the value of field 'Extends'.
201: */
202: public java.lang.String getExtends() {
203: return this ._extends;
204: }
205:
206: /**
207: * Returns the value of field 'final'.
208: *
209: * @return the value of field 'Final'.
210: */
211: public boolean getFinal() {
212: return this ._final;
213: }
214:
215: /**
216: * Method getImplements.
217: *
218: * @param index
219: * @throws java.lang.IndexOutOfBoundsException if the index
220: * given is outside the bounds of the collection
221: * @return the value of the java.lang.String at the given index
222: */
223: public java.lang.String getImplements(final int index)
224: throws java.lang.IndexOutOfBoundsException {
225: // check bounds for index
226: if (index < 0 || index >= this ._implements List.size()) {
227: throw new IndexOutOfBoundsException(
228: "getImplements: Index value '" + index
229: + "' not in range [0.."
230: + (this ._implements List.size() - 1) + "]");
231: }
232:
233: return (java.lang.String) _implements List.get(index);
234: }
235:
236: /**
237: * Method getImplements.Returns the contents of the collection
238: * in an Array. <p>Note: Just in case the collection contents
239: * are changing in another thread, we pass a 0-length Array of
240: * the correct type into the API call. This way we <i>know</i>
241: * that the Array returned is of exactly the correct length.
242: *
243: * @return this collection as an Array
244: */
245: public java.lang.String[] getImplements() {
246: java.lang.String[] array = new java.lang.String[0];
247: return (java.lang.String[]) this ._implements List.toArray(array);
248: }
249:
250: /**
251: * Method getImplementsCount.
252: *
253: * @return the size of this collection
254: */
255: public int getImplementsCount() {
256: return this ._implements List.size();
257: }
258:
259: /**
260: * Returns the value of field 'name'.
261: *
262: * @return the value of field 'Name'.
263: */
264: public java.lang.String getName() {
265: return this ._name;
266: }
267:
268: /**
269: * Returns the value of field 'package'.
270: *
271: * @return the value of field 'Package'.
272: */
273: public java.lang.String getPackage() {
274: return this ._package;
275: }
276:
277: /**
278: * Method hasAbstract.
279: *
280: * @return true if at least one Abstract has been added
281: */
282: public boolean hasAbstract() {
283: return this ._has_abstract;
284: }
285:
286: /**
287: * Method hasBound.
288: *
289: * @return true if at least one Bound has been added
290: */
291: public boolean hasBound() {
292: return this ._has_bound;
293: }
294:
295: /**
296: * Method hasEquals.
297: *
298: * @return true if at least one Equals has been added
299: */
300: public boolean hasEquals() {
301: return this ._has_equals;
302: }
303:
304: /**
305: * Method hasFinal.
306: *
307: * @return true if at least one Final has been added
308: */
309: public boolean hasFinal() {
310: return this ._has_final;
311: }
312:
313: /**
314: * Returns the value of field 'abstract'.
315: *
316: * @return the value of field 'Abstract'.
317: */
318: public boolean isAbstract() {
319: return this ._abstract;
320: }
321:
322: /**
323: * Returns the value of field 'bound'.
324: *
325: * @return the value of field 'Bound'.
326: */
327: public boolean isBound() {
328: return this ._bound;
329: }
330:
331: /**
332: * Returns the value of field 'equals'.
333: *
334: * @return the value of field 'Equals'.
335: */
336: public boolean isEquals() {
337: return this ._equals;
338: }
339:
340: /**
341: * Returns the value of field 'final'.
342: *
343: * @return the value of field 'Final'.
344: */
345: public boolean isFinal() {
346: return this ._final;
347: }
348:
349: /**
350: * Method isValid.
351: *
352: * @return true if this object is valid according to the schema
353: */
354: public boolean isValid() {
355: try {
356: validate();
357: } catch (org.exolab.castor.xml.ValidationException vex) {
358: return false;
359: }
360: return true;
361: }
362:
363: /**
364: * Method iterateImplements.
365: *
366: * @return an Iterator over all possible elements in this
367: * collection
368: */
369: public java.util.Iterator iterateImplements() {
370: return this ._implements List.iterator();
371: }
372:
373: /**
374: *
375: *
376: * @param out
377: * @throws org.exolab.castor.xml.MarshalException if object is
378: * null or if any SAXException is thrown during marshaling
379: * @throws org.exolab.castor.xml.ValidationException if this
380: * object is an invalid instance according to the schema
381: */
382: public void marshal(final java.io.Writer out)
383: throws org.exolab.castor.xml.MarshalException,
384: org.exolab.castor.xml.ValidationException {
385: Marshaller.marshal(this , out);
386: }
387:
388: /**
389: *
390: *
391: * @param handler
392: * @throws java.io.IOException if an IOException occurs during
393: * marshaling
394: * @throws org.exolab.castor.xml.ValidationException if this
395: * object is an invalid instance according to the schema
396: * @throws org.exolab.castor.xml.MarshalException if object is
397: * null or if any SAXException is thrown during marshaling
398: */
399: public void marshal(final org.xml.sax.ContentHandler handler)
400: throws java.io.IOException,
401: org.exolab.castor.xml.MarshalException,
402: org.exolab.castor.xml.ValidationException {
403: Marshaller.marshal(this , handler);
404: }
405:
406: /**
407: */
408: public void removeAllImplements() {
409: this ._implements List.clear();
410: }
411:
412: /**
413: * Method removeImplements.
414: *
415: * @param vImplements
416: * @return true if the object was removed from the collection.
417: */
418: public boolean removeImplements(final java.lang.String vImplements) {
419: boolean removed = _implements List.remove(vImplements);
420: return removed;
421: }
422:
423: /**
424: * Method removeImplementsAt.
425: *
426: * @param index
427: * @return the element removed from the collection
428: */
429: public java.lang.String removeImplementsAt(final int index) {
430: java.lang.Object obj = this ._implements List.remove(index);
431: return (java.lang.String) obj;
432: }
433:
434: /**
435: * Sets the value of field 'abstract'.
436: *
437: * @param _abstract
438: * @param abstract the value of field 'abstract'.
439: */
440: public void setAbstract(final boolean _abstract) {
441: this ._abstract = _abstract;
442: this ._has_abstract = true;
443: }
444:
445: /**
446: * Sets the value of field 'bound'.
447: *
448: * @param bound the value of field 'bound'.
449: */
450: public void setBound(final boolean bound) {
451: this ._bound = bound;
452: this ._has_bound = true;
453: }
454:
455: /**
456: * Sets the value of field 'equals'.
457: *
458: * @param equals the value of field 'equals'.
459: */
460: public void setEquals(final boolean equals) {
461: this ._equals = equals;
462: this ._has_equals = true;
463: }
464:
465: /**
466: * Sets the value of field 'extends'.
467: *
468: * @param _extends
469: * @param extends the value of field 'extends'.
470: */
471: public void setExtends(final java.lang.String _extends) {
472: this ._extends = _extends;
473: }
474:
475: /**
476: * Sets the value of field 'final'.
477: *
478: * @param _final
479: * @param final the value of field 'final'.
480: */
481: public void setFinal(final boolean _final) {
482: this ._final = _final;
483: this ._has_final = true;
484: }
485:
486: /**
487: *
488: *
489: * @param index
490: * @param vImplements
491: * @throws java.lang.IndexOutOfBoundsException if the index
492: * given is outside the bounds of the collection
493: */
494: public void setImplements(final int index,
495: final java.lang.String vImplements)
496: throws java.lang.IndexOutOfBoundsException {
497: // check bounds for index
498: if (index < 0 || index >= this ._implements List.size()) {
499: throw new IndexOutOfBoundsException(
500: "setImplements: Index value '" + index
501: + "' not in range [0.."
502: + (this ._implements List.size() - 1) + "]");
503: }
504:
505: this ._implements List.set(index, vImplements);
506: }
507:
508: /**
509: *
510: *
511: * @param vImplementsArray
512: */
513: public void setImplements(final java.lang.String[] vImplementsArray) {
514: //-- copy array
515: _implements List.clear();
516:
517: for (int i = 0; i < vImplementsArray.length; i++) {
518: this ._implements List.add(vImplementsArray[i]);
519: }
520: }
521:
522: /**
523: * Sets the value of field 'name'.
524: *
525: * @param name the value of field 'name'.
526: */
527: public void setName(final java.lang.String name) {
528: this ._name = name;
529: }
530:
531: /**
532: * Sets the value of field 'package'.
533: *
534: * @param _package
535: * @param package the value of field 'package'.
536: */
537: public void setPackage(final java.lang.String _package) {
538: this ._package = _package;
539: }
540:
541: /**
542: * Method unmarshalClassType.
543: *
544: * @param reader
545: * @throws org.exolab.castor.xml.MarshalException if object is
546: * null or if any SAXException is thrown during marshaling
547: * @throws org.exolab.castor.xml.ValidationException if this
548: * object is an invalid instance according to the schema
549: * @return the unmarshaled
550: * org.exolab.castor.builder.binding.ClassType
551: */
552: public static org.exolab.castor.builder.binding.xml.ClassType unmarshalClassType(
553: final java.io.Reader reader)
554: throws org.exolab.castor.xml.MarshalException,
555: org.exolab.castor.xml.ValidationException {
556: return (org.exolab.castor.builder.binding.xml.ClassType) Unmarshaller
557: .unmarshal(
558: org.exolab.castor.builder.binding.xml.ClassType.class,
559: reader);
560: }
561:
562: /**
563: *
564: *
565: * @throws org.exolab.castor.xml.ValidationException if this
566: * object is an invalid instance according to the schema
567: */
568: public void validate()
569: throws org.exolab.castor.xml.ValidationException {
570: org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
571: validator.validate(this);
572: }
573:
574: }
|