All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.thaiopensource.validate.nvdl.ValidateAction Maven / Gradle / Ivy

There is a newer version: 20151127.0.1
Show newest version
package com.thaiopensource.validate.nvdl;

import com.thaiopensource.validate.Schema;
import org.xml.sax.SAXException;

/**
 * Validate no result action.
 *
 */
class ValidateAction extends NoResultAction {
  /**
   * The schema to validate with.
   */
  private final Schema schema;

  /**
   * Creates a validate action.
   * @param modeUsage The mode usage.
   * @param schema The schema.
   */
  ValidateAction(ModeUsage modeUsage, Schema schema) {
    super(modeUsage);
    this.schema = schema;
  }

  /**
   * Perform this action on the section state.
   * @param state the section state.
   */
  void perform(SectionState state) throws SAXException {
    state.addValidator(schema, getModeUsage());
  }

  /**
   * Get a new validate action with a mode usage with the current mode changed.
   * This is useful when we have modes extending other modes as we need to get
   * the actions from the base mode as actions on the new mode.
   */
  NoResultAction changeCurrentMode(Mode mode) {
    return new ValidateAction(getModeUsage().changeCurrentMode(mode), schema);
  }

  /**
   * Checks if this action is equal with a given action.
   */
  public boolean equals(Object obj) {
    return super.equals(obj) && schema.equals(((ValidateAction)obj).schema);
  }

  /**
   * Computes a hashCode.
   */
  public int hashCode() {
    return super.hashCode() ^ schema.hashCode();
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy