AbstractRange.java :  » Content-Management-System » harmonise » org » openharmonise » vfs » metadata » range » Java Open Source

Java Open Source » Content Management System » harmonise 
harmonise » org » openharmonise » vfs » metadata » range » AbstractRange.java
/*
 * The contents of this file are subject to the 
 * Mozilla Public License Version 1.1 (the "License"); 
 * you may not use this file except in compliance with the License. 
 * You may obtain a copy of the License at http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. 
 * See the License for the specific language governing rights and 
 * limitations under the License.
 *
 * The Initial Developer of the Original Code is Simulacra Media Ltd.
 * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
 *
 * All Rights Reserved.
 *
 * Contributor(s):
 */
package org.openharmonise.vfs.metadata.range;

import java.util.*;

import org.openharmonise.vfs.metadata.*;


/**
 * AbstractRange is a base class for implementors of the {@link org.openharmonise.vfs.metadata.Range}
 * interface.
 * 
 * @author Matthew Large
 * @version $Revision: 1.1 $
 *
 */
public abstract class AbstractRange {

  /**
   * 
   */
  public AbstractRange() {
    super();
  }
  
  /**
   * Validates a list of values using the restrictions described by this
   * range.
   * 
   * @param aValues
   * @return Validation result
   * 
   * @see Range#validate(List)
   */
  public ValidationResult validate(List aValues) {
    ValidationResult finalResult = new ValidationResult();
    
    Iterator itor =  aValues.iterator();
    
    while(itor.hasNext()) {
      ValidationResult result = this.validate( ((ValueInstance)itor.next()) );
      finalResult.addNestedValidation(result);
      if(!result.isValid()) {
        finalResult.setValid(false);
      }
    }
    
    return finalResult;
  }
  
  /**
   * Validates a single value using the restrictions described by this
   * range.
   * 
   * @param val Value
   * @return Validation result
   * 
   * @see Range#validate(ValueInstance)
   */
  public abstract ValidationResult validate(ValueInstance value);

}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.