Package org.apache.imperius.spl.parser.factory

Source Code of org.apache.imperius.spl.parser.factory.ActionFactory

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements.  See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership.  The ASF licenses this file
* to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied.  See the License for the
* specific language governing permissions and limitations
* under the License. 
*/
//
/**
* @author Neeraj Joshi <jneeraj@us.ibm.com>
*
*/
package org.apache.imperius.spl.parser.factory;

import java.util.List;
import java.util.logging.Logger;

import org.apache.imperius.spl.core.Expression;
import org.apache.imperius.spl.parser.compiler.SPLTreeParserTokenTypes;
import org.apache.imperius.spl.parser.compiler.symboltable.SPLSymbolTable;
import org.apache.imperius.spl.parser.exceptions.SPLException;
import org.apache.imperius.spl.parser.statements.ActionBlock;
import org.apache.imperius.spl.parser.statements.actions.impl.AnchorMethodInvokeAction;
import org.apache.imperius.spl.parser.statements.actions.impl.ArrowActionBlock;
import org.apache.imperius.spl.parser.statements.actions.impl.ConcurrentActionBlock;
import org.apache.imperius.spl.parser.statements.actions.impl.ExtrinsicMethodInvokeAction;
import org.apache.imperius.spl.parser.statements.actions.impl.InvokePolicyAction;
import org.apache.imperius.spl.parser.statements.actions.impl.LogicalAndActionBlock;
import org.apache.imperius.spl.parser.statements.actions.impl.LogicalOrActionBlock;
import org.apache.imperius.spl.parser.statements.actions.impl.SetActionBlock;
import org.apache.imperius.util.SPLLogger;

public class ActionFactory
{
  private static Logger logger = SPLLogger.getSPLLogger().getLogger();
  private static final String sourceClass = "ActionFactory";

  public static ActionBlock createAction(ActionBlock ab1, ActionBlock ab2,
      int type, SPLSymbolTable sTab)
  {
    logger.entering(sourceClass, Thread.currentThread().getName() + " "
        + "createAction");

    ActionBlock returnBlock = null;
    switch (type)
    {
    case SPLTreeParserTokenTypes.ARROW:
      returnBlock = new ArrowActionBlock(ab1, ab2);
      break;

    case SPLTreeParserTokenTypes.LOR:
      returnBlock = new LogicalOrActionBlock(ab1, ab2);
      break;
    case SPLTreeParserTokenTypes.LAND:
      returnBlock = new LogicalAndActionBlock(ab1, ab2);
      break;
    case SPLTreeParserTokenTypes.BOR:
      returnBlock = new ConcurrentActionBlock(ab1, ab2);

    }

    logger.exiting(sourceClass, Thread.currentThread().getName() + " "
        + "createAction");

    return returnBlock;
  }

  /*
   * x.y(...) y(...) set.y(...)
   *
   */

  public static ActionBlock createAction(String className1, List paramList,
      List identTupleList, boolean isBuiltInMethod, String set,
      String op, Expression c, SPLSymbolTable symTab) throws SPLException
  {
    logger.entering(sourceClass, Thread.currentThread().getName() + " "
        + "createAction");
    ActionBlock returnBlock = null;

    if (set.equalsIgnoreCase("Set"))
    {
      List anchorClasses = symTab.getAnchorData().getAnchorClassList();

      returnBlock = new SetActionBlock((String) anchorClasses.get(0),
          paramList, symTab);
    }
    else if (set.equalsIgnoreCase("InvokePolicy"))
    {
      returnBlock = new InvokePolicyAction(paramList);
    }
    else if (ACPLParserMap.isKnownActionExpressionType(className1))
    {
      returnBlock = new ExtrinsicMethodInvokeAction(className1,
          paramList, symTab);
    }
    else
    {
      returnBlock = new AnchorMethodInvokeAction(className1,
          identTupleList, op, c, symTab);
    }
    logger.exiting(sourceClass, Thread.currentThread().getName() + " "
        + "createAction");

    return returnBlock;
  }
}
TOP

Related Classes of org.apache.imperius.spl.parser.factory.ActionFactory

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.