001 package com.oxygenxml.validate.nvdl;
002
003 /**
004 * An action that allows any element.
005 */
006 class AllowAction extends NoResultAction {
007 /**
008 * Creates this no result action with a given mode usage.
009 * @param modeUsage The mode usage.
010 */
011 AllowAction(ModeUsage modeUsage) {
012 super(modeUsage);
013 }
014
015 /**
016 * Perform this action on the section state.
017 * @param state The section state.
018 */
019 void perform(SectionState state) {
020 state.addChildMode(getModeUsage(), null);
021 state.addAttributeValidationModeUsage(getModeUsage());
022 }
023
024 /**
025 * Get a new allow action with a mode usage with the current mode changed.
026 * This is useful when we have modes extending other modes as we need to get
027 * the actions from the base mode as actions on the new mode.
028 */
029 NoResultAction changeCurrentMode(Mode mode) {
030 return new AllowAction(getModeUsage().changeCurrentMode(mode));
031 }
032 }