View Javadoc
1   /*
2    * Copyright 2006 Werner Guttmann
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5    * in compliance with the License. You may obtain a copy of the License at
6    *
7    * http://www.apache.org/licenses/LICENSE-2.0
8    *
9    * Unless required by applicable law or agreed to in writing, software distributed under the License
10   * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11   * or implied. See the License for the specific language governing permissions and limitations under
12   * the License.
13   */
14  package org.exolab.castor.builder.types;
15  
16  import org.exolab.javasource.JSourceCode;
17  
18  /**
19   * A collection of IDREF type.
20   * 
21   * @author <a href="mailto:werner DOT guttmann AT gmx DOT net">Werner Guttmann</a>
22   * @since 1.1
23   * @version $Revision: 6729 $ $Date: 2005-12-13 14:58:48 -0700 (Tue, 13 Dec 2005) $
24   */
25  public class XSIdRefs extends XSListType {
26  
27    /** Name of the IDREFS type. */
28    public static final String IDREFS_NAME = "IDREFS";
29  
30    /**
31     * Create a XSNMTokens instance.
32     *
33     * @param colType Type of collection to use.
34     * @param useJava50 If true, the collection will be generated using Java 5 features such as
35     *        generics.
36     */
37    public XSIdRefs(final String colType, final boolean useJava50) {
38      super(colType, new XSIdRef(), useJava50);
39    }
40  
41    /**
42     * {@inheritDoc}
43     */
44    public String getName() {
45      return IDREFS_NAME;
46    }
47  
48    /**
49     * {@inheritDoc}
50     */
51    public short getType() {
52      return XSType.IDREFS_TYPE;
53    }
54  
55    /**
56     * {@inheritDoc}
57     */
58    public void validationCode(final JSourceCode jsc, final String fixedValue,
59        final String validatorInstanceName) {
60      jsc.add("org.exolab.castor.xml.validators.IdRefsValidator typeValidator = "
61          + "new org.exolab.castor.xml.validators.IdRefsValidator();");
62      jsc.add("fieldValidator.setValidator(typeValidator);");
63      jsc.add("desc.setValidator(fieldValidator);");
64    }
65  
66  
67  
68  }