001    package com.oxygenxml.validate.nvdl;
002    
003    /**
004     * Stores a set of element actions.
005     * The actions are result actions and no result actions.
006     * An action set contains only one result action and more no result actions.
007     *
008     */
009    class ActionSet {
010      /**
011       * The result action.
012       */
013      private ResultAction resultAction;
014      /**
015       * The no result actions.
016       */
017      private NoResultAction[] noResultActions = new NoResultAction[0];
018    
019      /**
020       * Cancel nested actions flag.
021       */
022      private boolean cancelNestedActions;
023      
024      /**
025       * Getter for the result action.
026       * @return The result action.
027       */
028      ResultAction getResultAction() {
029        return resultAction;
030      }
031    
032      /**
033       * Setter for the result action.
034       * @param resultAction The result action.
035       */
036      void setResultAction(ResultAction resultAction) {
037        this.resultAction = resultAction;
038      }
039    
040      /**
041       * Adds a no result action to the no result actions.
042       * @param action The no result action.
043       */
044      void addNoResultAction(NoResultAction action) {
045        NoResultAction[] actions = new NoResultAction[noResultActions.length + 1];
046        System.arraycopy(noResultActions, 0, actions, 0, noResultActions.length);
047        actions[noResultActions.length] = action;
048        noResultActions = actions;
049      }
050    
051      /**
052       * Getter for the no result actions array.
053       * @return The no result actions.
054       */
055      NoResultAction[] getNoResultActions() {
056        return noResultActions;
057      }
058    
059      /**
060       * Getter for the cancel nested actions flag. 
061       */
062      boolean getCancelNestedActions() {
063        return cancelNestedActions;
064      }
065      
066      /**
067       * Set the cancel nested actions flag.
068       * @param cancelNestedActions The new value.
069       */
070      void setCancelNestedActions(boolean cancelNestedActions) {
071        this.cancelNestedActions = cancelNestedActions;
072      }
073      
074      
075      /**
076       * Gets a new ActionSet containing all the actions with the
077       * current mode changed.
078       * 
079       * @param mode The new current mode.
080       * @return A new ActionSet with actions with the current mode changed.
081       */
082      ActionSet changeCurrentMode(Mode mode) {
083        ActionSet actions = new ActionSet();
084        if (this.resultAction != null)
085          actions.resultAction = this.resultAction.changeCurrentMode(mode);
086        actions.noResultActions = new NoResultAction[this.noResultActions.length];
087        for (int i = 0; i < actions.noResultActions.length; i++)
088          actions.noResultActions[i] = this.noResultActions[i].changeCurrentMode(mode);
089        return actions;
090      }
091    }