⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 operatornode.java

📁 一个完整的XACML工程,学习XACML技术的好例子!
💻 JAVA
字号:
/*
* Copyright (c) 2000-2005, University of Salford
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without 
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this 
* list of conditions and the following disclaimer.
* 
* Redistributions in binary form must reproduce the above copyright notice, 
* this list of conditions and the following disclaimer in the documentation 
* and/or other materials provided with the distribution. 
*
* Neither the name of the University of Salford nor the names of its 
* contributors may be used to endorse or promote products derived from this 
* software without specific prior written permission. 
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
* POSSIBILITY OF SUCH DAMAGE.
*/

package issrg.pba.rbac.xmlpolicy.ifstatement;

/**
 * This is the class for Operator node of the IF-statement. Its functionality is
 * very much determined by OperationNode, which is
 * configured to deliver the following semantics:
 *
 * <p>This operation expects no or any number of Terms of any type, and 
 * returns a 
 * value of type determined by the matching Interpreter.
 * There must be an interpreter for
 * the required set of Terms, and it implements the semantics of the evaluation.
 *
 * <p>It is possible to register the interpreters for specific 
 * combinations of Terms. Use registerOperatorInterpreter method to do that. 
 * There is no default Interpreter. 
 *
 * @see #registerOperatorInterpreter
 *
 * @author A.Otenko
 */
public class OperatorNode extends OperationNode {
  public final static String OPERATOR_NODE = "Operator";

  /**
   * This method should be called to register the node with the XML Parser
   */
  public static void register(){
    try{
      issrg.pba.rbac.xmlpolicy.XMLPolicyParser.registerXMLNode(OPERATOR_NODE, OperatorNode.class);
    }catch (NoSuchMethodException nsme){
      nsme.printStackTrace();
    }
  }

  /**
   * This method maintains a register of interpreters for specific combinations
   * of Terms for the specified operator. If no special interpreters are 
   * registered, the evaluation error
   * occurs. The semantics of the interpreters ensure the semantics of 
   * evaluation of the operator.
   *
   * @param name - the operator name
   * @param i - the Interpreter instance that can evaluate the expression
   *   for some combination of Terms
   *
   * @see Interpreter#evaluate
   */
  public static void registerOperatorInterpreter(String name, Interpreter i){
    OperationNode.registerInterpreterForNode(OPERATOR_NODE+" "+name, i);
  }

  protected OperatorNode(){};

  /**
   * This constructor builds a OperatorNode given the XMLPolicyParser and the 
   * set of
   * attributes of this XML element. It expects that there are no or many
   * child nodes. It expects there is a
   * issrg.pba.rbac.xmlpolicy.XMLTags.NAME_ATTRIBUTE ("Name") attribute in this
   * XML element.
   *
   * @param p - the XMLPolicyParser that builds this LtNode
   * @param attrs - the attributes of this XML element
   *
   * @throws issrg.pba.rbac.PolicyParsingException if there is no 
   *  issrg.pba.rbac.xmlpolicy.XMLTags.NAME_ATTRIBUTE in this XML element
   */
  public OperatorNode(issrg.pba.rbac.xmlpolicy.XMLPolicyParser p, org.xml.sax.Attributes attrs) throws issrg.pba.rbac.PolicyParsingException {
    super(OPERATOR_NODE, attrs, -1, -1);

    String opname=(String)getAttributes().get(issrg.pba.rbac.xmlpolicy.XMLTags.NAME_ATTRIBUTE);
    if (opname==null) throw new issrg.pba.rbac.PolicyParsingException(issrg.pba.rbac.xmlpolicy.XMLTags.NAME_ATTRIBUTE+" attribute was expected for "+OPERATOR_NODE);
    name = OPERATOR_NODE+" "+opname;
  }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -