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.xml.validators;
15  
16  import org.exolab.castor.xml.TypeValidator;
17  import org.exolab.castor.xml.ValidationContext;
18  import org.exolab.castor.xml.ValidationException;
19  
20  /**
21   * The IDREFS Validation class.
22   *
23   * @author <a href="mailto:werner DOT guttmann AT gmx DOT net">Werner Guttman</a>
24   * @version $Revision: 0000 $ $Date: $
25   */
26  public class IdRefsValidator implements TypeValidator {
27  
28    /** Our IdRefValidator. */
29    private IdRefValidator _idRefValidator;
30  
31    /**
32     * Creates a new IdRefsValidator with no restrictions.
33     */
34    public IdRefsValidator() {
35      super();
36      _idRefValidator = new IdRefValidator();
37    }
38  
39    /**
40     * Validates the given Object.
41     *
42     * @param object the Object to validate
43     * @param context the ValidationContext
44     * @throws ValidationException if the object fails validation.
45     */
46    public void validate(final Object object, final ValidationContext context)
47        throws ValidationException {
48      if (object == null) {
49        String err = "The object of type IDREFS is null!";
50        throw new ValidationException(err);
51      }
52  
53      Object[] objects = (Object[]) object;
54      for (int i = 0; i < objects.length; i++) {
55        _idRefValidator.validate(objects[i], context);
56      }
57  
58      // validate(value, context);
59    } // -- validate
60  
61  }