Index: org/exolab/castor/xml/schema/XMLType.java
===================================================================
--- org/exolab/castor/xml/schema/XMLType.java (Revision 6172)
+++ org/exolab/castor/xml/schema/XMLType.java (Arbeitskopie)
@@ -163,7 +163,8 @@
**/
public final boolean isSimpleType() {
return ((getStructureType() == Structure.SIMPLE_TYPE) ||
- (getStructureType() == Structure.UNION));
+ (getStructureType() == Structure.UNION) ||
+ (getStructureType() == Structure.LIST));
} //-- isSimpleType
Index: org/exolab/castor/xml/schema/simpletypes/ListType.java
===================================================================
--- org/exolab/castor/xml/schema/simpletypes/ListType.java (Revision 6172)
+++ org/exolab/castor/xml/schema/simpletypes/ListType.java (Arbeitskopie)
@@ -120,7 +120,7 @@
* @return the type of this Schema Structure
*/
public short getStructureType() {
- return Structure.SIMPLE_TYPE; //-- should be changed to LIST
+ return Structure.LIST;
} //-- getStructureType
/**
Index: org/exolab/castor/builder/types/XSListODMG30.java
===================================================================
--- org/exolab/castor/builder/types/XSListODMG30.java (Revision 6172)
+++ org/exolab/castor/builder/types/XSListODMG30.java (Arbeitskopie)
@@ -43,62 +43,36 @@
package org.exolab.castor.builder.types;
-
import org.exolab.javasource.*;
-
/**
* A list type for ODMG 3.0 that adapts the Castor preset list type.
+ *
* @author Frank Thelen
- * @version $Revision$ $Date: 2005-12-13 14:58:48 -0700 (Tue, 13 Dec 2005) $
-**/
+ * @version $Revision$ $Date: 2005-12-13 14:58:48 -0700 (Tue, 13 Dec
+ * 2005) $
+ */
public class XSListODMG30 extends XSList {
-
- int maxSize = -1; //-- undefined
- int minSize = 0;
-
- XSType contentType = null;
-
/**
* The JType represented by this XSType
- **/
- private static final JType jType
- //= new JClass("java.util.Vector");
- = new JClass("org.odmg.DArray");
+ */
+ private static final JType jType = new JClass("org.odmg.DArray");
+ /**
+ * Creates an instance of this specialised XSList sub-class
+ * @param contentType Type of the list content.
+ */
public XSListODMG30(XSType contentType) {
super(contentType);
- this.contentType = contentType;
- } //-- XSListODMG30
+ } // -- XSListODMG30
-
/**
* Returns the JType that this XSType represents
* @return the JType that this XSType represents
- **/
+ */
public JType getJType() {
return XSListODMG30.jType;
}
- public int getMinimumSize() {
- return minSize;
- } //-- getMinimumSize
-
- public int getMaximumSize() {
- return maxSize;
- } //-- getMaximumSize
-
- public XSType getContentType() {
- return contentType;
- }
-
- public void setMaximumSize(int size) {
- maxSize = size;
- } //-- setMaximumSize
-
- public void setMinimumSize(int size) {
- minSize = size;
- } //-- setMinimumSize
-
-} //-- XSListODMG30
+} // -- XSListODMG30
Index: org/exolab/castor/builder/types/XSListJ2.java
===================================================================
--- org/exolab/castor/builder/types/XSListJ2.java (Revision 6172)
+++ org/exolab/castor/builder/types/XSListJ2.java (Arbeitskopie)
@@ -34,33 +34,25 @@
*/
package org.exolab.castor.builder.types;
-
import org.exolab.javasource.*;
-
/**
* A list type for Java 2 collection that adapts the Castor preset list type.
* @author Assaf Arkin
+ * @author Werner Guttmann
* @version $Revision$ $Date: 2005-12-13 14:58:48 -0700 (Tue, 13 Dec 2005) $
-**/
+ **/
public class XSListJ2 extends XSList {
-
- int maxSize = -1; //-- undefined
- int minSize = 0;
-
- XSType contentType = null;
-
/**
- * The JType represented by this XSType
- **/
- private JType jType = null;
-
- public XSListJ2(XSType contentType, String collectionType) {
+ * Creates an instance of this XSList sub-class specific to Java 2 collections
+ * @param contentType The type of the collection content.
+ * @param collectionType The collection type.
+ */
+ public XSListJ2(final XSType contentType, final String collectionType) {
super(contentType);
- this.contentType = contentType;
if (collectionType.equalsIgnoreCase("arraylist")) {
- this.jType = JType.createCollection("java.util.ArrayList", contentType.getJType());
+ setJType(JType.createCollection("java.util.ArrayList", contentType.getJType()));
}
// else if (collectionType.equalsIgnoreCase("collection")) {
// this.jType = JType.createCollection("java.util.Collection", contentType.getJType());
@@ -69,34 +61,5 @@
// }
} //-- XSListJ2
-
- /**
- * Returns the JType that this XSType represents
- * @return the JType that this XSType represents
- **/
- public JType getJType() {
- return this.jType;
- }
-
- public int getMinimumSize() {
- return minSize;
- } //-- getMinimumSize
-
- public int getMaximumSize() {
- return maxSize;
- } //-- getMaximumSize
-
- public XSType getContentType() {
- return contentType;
- }
-
- public void setMaximumSize(int size) {
- maxSize = size;
- } //-- setMaximumSize
-
- public void setMinimumSize(int size) {
- minSize = size;
- } //-- setMinimumSize
-
} //-- XSListJ2
Index: org/exolab/castor/builder/types/XSList.java
===================================================================
--- org/exolab/castor/builder/types/XSList.java (Revision 6172)
+++ org/exolab/castor/builder/types/XSList.java (Arbeitskopie)
@@ -44,49 +44,75 @@
*/
package org.exolab.castor.builder.types;
+
+import java.util.Enumeration;
+
+import org.exolab.castor.xml.schema.Facet;
import org.exolab.castor.xml.schema.SimpleType;
import org.exolab.javasource.*;
/**
* A list type....this will change soon
+ *
* @author Keith Visco
- * @version $Revision$ $Date: 2005-12-13 14:58:48 -0700 (Tue, 13 Dec 2005) $
-**/
-public class XSList extends XSType {
+ * @version $Revision$ $Date: 2005-12-13 14:58:48 -0700 (Tue, 13 Dec
+ * 2005) $
+ */
+public class XSList extends XSPatternBase {
+ private int maxSize = -1; // -- undefined
- int maxSize = -1; //-- undefined
- int minSize = 0;
+ private int minSize = 0;
- XSType contentType = null;
+ private XSType contentType = null;
+ /**
+ * The length facet
+ */
+ private int _length = 0;
+
/**
+ * The max length facet
+ **/
+ private int maxLength = -1;
+
+ /**
+ * The min length facet
+ **/
+ private int minLength = 0;
+
+ /**
* The JType represented by this XSType
- **/
+ */
private JType jType = null;
public XSList(XSType contentType) {
super(XSType.COLLECTION);
this.contentType = contentType;
- this.jType = JType.createCollection("java.util.Vector", contentType.getJType());
- } //-- XSList
+ this.jType = JType.createCollection("java.util.Vector", contentType
+ .getJType());
+ } // -- XSList
-
/**
* Returns the JType that this XSType represents
+ *
* @return the JType that this XSType represents
- **/
+ */
public JType getJType() {
return this.jType;
}
+
+ public void setJType (final JType jType) {
+ this.jType = jType;
+ }
public int getMinimumSize() {
return minSize;
- } //-- getMinimumSize
+ } // -- getMinimumSize
public int getMaximumSize() {
return maxSize;
- } //-- getMaximumSize
+ } // -- getMaximumSize
public XSType getContentType() {
return contentType;
@@ -94,29 +120,132 @@
public void setMaximumSize(int size) {
maxSize = size;
- } //-- setMaximumSize
+ } // -- setMaximumSize
public void setMinimumSize(int size) {
minSize = size;
- } //-- setMinimumSize
+ } // -- setMinimumSize
- public void setFacets(SimpleType simpleType) {}
+ public void setFacets(SimpleType simpleType) {
+ Enumeration enumeration = getFacets(simpleType);
+ while (enumeration.hasMoreElements()) {
+
+ Facet facet = (Facet) enumeration.nextElement();
+ String name = facet.getName();
+
+ if (Facet.LENGTH.equals(name))
+ setLength(facet.toInt());
+ else if (Facet.MAX_LENGTH.equals(name))
+ setMaxLength(facet.toInt());
+ else if (Facet.MIN_LENGTH.equals(name))
+ setMinLength(facet.toInt());
+ else if (Facet.PATTERN.equals(name))
+ setPattern(facet.getValue());
+
+ }
+ }
+
+ /**
+ * Returns the length that this type must have
+ * @return the length that this type must have
+ */
+ public int getLength() {
+ return this._length;
+ }
+
+ /**
+ * Returns the maximum length occurances of this type can be.
+ * A negative value denotes no maximum length
+ * @return the maximum length facet
+ **/
+ public int getMaxLength() {
+ return maxLength;
+ } //-- getMaxLength
+
+ /**
+ * Returns the minimum length occurances of this type can be.
+ * @return the minimum length facet
+ **/
+ public int getMinLength() {
+ return minLength;
+ } //-- getMinLength
+
+
+ /**
+ * Sets the length of this XSList
+ * While setting the length, the maxLength and minLength are also
+ * set up to this length
+ * @param length the length to set
+ * @see #setMaxLength
+ * @see #setMinLength
+ */
+ public void setLength(int length) {
+ this._length = length;
+ setMaxLength(length);
+ setMinLength(length);
+ }
- /**
- * Creates the validation code for an instance of this XSType. The validation
- * code should if necessary create a newly configured TypeValidator, that
- * should then be added to a FieldValidator instance whose name is provided.
- *
- * @param fixedValue a fixed value to use if any
- * @param jsc the JSourceCode to fill in.
- * @param fieldValidatorInstanceName the name of the FieldValidator
- * that the configured TypeValidator should be added to.
- */
- public void validationCode (JSourceCode jsc, String fixedValue, String fieldValidatorInstanceName) {
-
+ /**
+ * Sets the maximum length of this XSString. To remove the max length
+ * facet, use a negative value.
+ * @param maxLength the maximum length for occurances of this type
+ **/
+ public void setMaxLength(int maxLength) {
+ this.maxLength = maxLength;
+ } //-- setMaxLength
+
+ /**
+ * Sets the minimum length of this XSString.
+ * @param minLength the minimum length for occurances of this type
+ **/
+ public void setMinLength(int minLength) {
+ this.minLength = minLength;
+ } //-- setMinLength
+
+ /**
+ * Returns true if a length has been set
+ * @return true if a length has been set
+ */
+ public boolean hasLength() {
+ return (_length > 0);
+ }
+
+ /**
+ * Returns true if a maximum length has been set
+ * @return true if a maximum length has been set
+ **/
+ public boolean hasMaxLength() {
+ return (maxLength >= 0);
+ } //-- hasMaxLength
+
+ /**
+ * Returns true if a minimum length has been set
+ * @return true if a minimum length has been set
+ **/
+ public boolean hasMinLength() {
+ return (minLength > 0);
+ } //-- hasMinLength
+
+ /**
+ * Creates the validation code for an instance of this XSType. The
+ * validation code should if necessary create a newly configured
+ * TypeValidator, that should then be added to a FieldValidator instance
+ * whose name is provided.
+ *
+ * @param fixedValue
+ * a fixed value to use if any
+ * @param jsc
+ * the JSourceCode to fill in.
+ * @param fieldValidatorInstanceName
+ * the name of the FieldValidator that the configured
+ * TypeValidator should be added to.
+ */
+ public void validationCode(JSourceCode jsc, String fixedValue,
+ String fieldValidatorInstanceName) {
+
if (jsc == null)
jsc = new JSourceCode();
-
- //--TBD
+
+ // --TBD
}
-} //-- XSList
+} // -- XSList
Index: org/exolab/castor/builder/SourceFactory.java
===================================================================
--- org/exolab/castor/builder/SourceFactory.java (Revision 6172)
+++ org/exolab/castor/builder/SourceFactory.java (Arbeitskopie)
@@ -1435,13 +1435,14 @@
//-- if we have a new SimpleType...generate ClassInfo
SimpleType sType = attr.getSimpleType();
if (sType != null) {
- if ( ! (SimpleTypesFactory.isBuiltInType(sType.getTypeCode())) )
+ if ( ! (SimpleTypesFactory.isBuiltInType(sType.getTypeCode())) ) {
- if (sType.getSchema() == component.getSchema())
- {
- if (state.resolve(sType) == null) {
- if (sType.hasFacet(Facet.ENUMERATION)) {
- createSourceCode(sType, state.getSGStateInfo());
+ if (sType.getSchema() == component.getSchema()) {
+ if (state.resolve(sType) == null) {
+ if (sType.hasFacet(Facet.ENUMERATION)
+ || sType.getStructureType() == Structure.LIST) {
+ createSourceCode(sType, state.getSGStateInfo());
+ }
}
}
}