Example usage for java.util Stack push

List of usage examples for java.util Stack push

Introduction

In this page you can find the example usage for java.util Stack push.

Prototype

public E push(E item) 

Source Link

Document

Pushes an item onto the top of this stack.

Usage

From source file:org.apache.tajo.plan.ExprAnnotator.java

@Override
public EvalNode visitModular(Context ctx, Stack<Expr> stack, BinaryOperator expr) throws TajoException {
    stack.push(expr);
    EvalNode left = visit(ctx, stack, expr.getLeft());
    EvalNode right = visit(ctx, stack, expr.getRight());
    stack.pop();/*w  w  w .  ja  v  a2  s.  com*/

    return createBinaryNode(ctx, EvalType.MODULAR, left, right);
}

From source file:com.bluexml.xforms.controller.mapping.MappingToolAlfrescoToClassForms.java

/**
 * Fill x forms association type./*from   w ww . j a v  a  2 s.c  o  m*/
 * 
 * @param transaction
 *            the login
 * @param xformsDocument
 *            the xforms document
 * @param classElement
 *            the class element
 * @param association
 *            the association
 * @param alfrescoClass
 *            the alfresco class
 * @param initParams
 *            the init params
 * @param stack
 *            the stack
 * @param isServletRequest
 * 
 * @throws ServletException
 * 
 */
@SuppressWarnings("unused")
@Deprecated
private void fillXFormsAssociationType(AlfrescoTransaction transaction, Document xformsDocument,
        Element classElement, AssociationType association, GenericClass alfrescoClass,
        Map<String, String> initParams, Stack<AssociationType> stack, boolean formIsReadOnly,
        boolean isServletRequest) throws ServletException {
    if (!stackContains(stack, association)) {
        stack.push(association);
        List<GenericAssociation> alfrescoAssociations = findAssociations(alfrescoClass, association);
        String targetClassType = classTypeToString(association.getType());
        fillXFormsAssociationRoot(transaction, xformsDocument, classElement, association, stack,
                alfrescoAssociations, targetClassType, initParams, formIsReadOnly, isServletRequest);
        stack.pop();
    }
}

From source file:org.apache.tajo.plan.ExprAnnotator.java

@Override
public EvalNode visitConcatenate(Context ctx, Stack<Expr> stack, BinaryOperator expr) throws TajoException {
    stack.push(expr);
    EvalNode lhs = visit(ctx, stack, expr.getLeft());
    EvalNode rhs = visit(ctx, stack, expr.getRight());
    stack.pop();//  w  w  w .j  av a 2 s  .  c o m

    if (lhs.getValueType().kind() != TajoDataTypes.Type.TEXT) {
        lhs = convertType(ctx, lhs, Text);
    }
    if (rhs.getValueType().kind() != TajoDataTypes.Type.TEXT) {
        rhs = convertType(ctx, rhs, Text);
    }

    return new BinaryEval(EvalType.CONCATENATE, lhs, rhs);
}

From source file:org.apache.tajo.plan.ExprAnnotator.java

@Override
public EvalNode visitIsNullPredicate(Context ctx, Stack<Expr> stack, IsNullPredicate expr)
        throws TajoException {
    stack.push(expr);
    EvalNode child = visit(ctx, stack, expr.getPredicand());
    stack.pop();/* w ww  .j a  v  a2  s.c om*/
    return new IsNullEval(expr.isNot(), child);
}

From source file:org.apache.tajo.plan.ExprAnnotator.java

@Override
public EvalNode visitBetween(Context ctx, Stack<Expr> stack, BetweenPredicate between) throws TajoException {
    stack.push(between);
    EvalNode predicand = visit(ctx, stack, between.predicand());
    EvalNode begin = visit(ctx, stack, between.begin());
    EvalNode end = visit(ctx, stack, between.end());
    stack.pop();//from   ww w .  ja v a 2s  . co  m

    // implicit type conversion
    DataType widestType = CatalogUtil.getWidestType(convert(predicand.getValueType()).getDataType(),
            convert(begin.getValueType()).getDataType(), convert(end.getValueType()).getDataType());

    BetweenPredicateEval betweenEval = new BetweenPredicateEval(between.isNot(), between.isSymmetric(),
            predicand, begin, end);

    betweenEval = (BetweenPredicateEval) convertType(ctx, betweenEval, TypeConverter.convert(widestType));
    return betweenEval;
}

From source file:org.apache.cloudstack.spring.module.model.impl.DefaultModuleDefinitionSet.java

protected void withModule(ModuleDefinition def, Stack<ModuleDefinition> parents, WithModule with) {
    long moduleStart = System.currentTimeMillis();
    if (def == null)
        return;//from   w  ww  .  java 2 s  .c  o  m

    if (!shouldLoad(def)) {
        log.info("Excluding context [{}] based on configuration", def.getName());
        return;
    }

    count++;

    with.with(def, parents);

    if (messagePrefix != null) {
        CONSOLE_LOG.info("[{}/{}] [{}ms] [{}ms] {} {}", count, total, (System.currentTimeMillis() - start),
                (System.currentTimeMillis() - moduleStart), messagePrefix, def.getName());
    }

    parents.push(def);

    for (ModuleDefinition child : def.getChildren()) {
        withModule(child, parents, with);
    }

    parents.pop();
}

From source file:org.apache.tajo.plan.ExprAnnotator.java

public EvalNode visitCommonComparison(Context ctx, Stack<Expr> stack, BinaryOperator expr)
        throws TajoException {
    stack.push(expr);
    EvalNode left = visit(ctx, stack, expr.getLeft());
    EvalNode right = visit(ctx, stack, expr.getRight());
    stack.pop();/*from   w  ww.  j a  va 2  s . co  m*/

    EvalType evalType;
    switch (expr.getType()) {
    case Equals:
        evalType = EvalType.EQUAL;
        break;
    case NotEquals:
        evalType = EvalType.NOT_EQUAL;
        break;
    case LessThan:
        evalType = EvalType.LTH;
        break;
    case LessThanOrEquals:
        evalType = EvalType.LEQ;
        break;
    case GreaterThan:
        evalType = EvalType.GTH;
        break;
    case GreaterThanOrEquals:
        evalType = EvalType.GEQ;
        break;
    default:
        throw new IllegalStateException("Wrong Expr Type: " + expr.getType());
    }

    return createBinaryNode(ctx, evalType, left, right);
}

From source file:org.apache.hadoop.hbase.filter.ParseFilter.java

/**
 * This function is called while parsing the filterString and an operator is parsed
 * <p>/*from  www  .  ja  v  a 2  s. c o  m*/
 * @param operatorStack the stack containing the operators and parenthesis
 * @param filterStack the stack containing the filters
 * @param operator the operator found while parsing the filterString
 */
public void reduce(Stack<ByteBuffer> operatorStack, Stack<Filter> filterStack, ByteBuffer operator) {
    while (!operatorStack.empty() && !(ParseConstants.LPAREN_BUFFER.equals(operatorStack.peek()))
            && hasHigherPriority(operatorStack.peek(), operator)) {
        filterStack.push(popArguments(operatorStack, filterStack));
    }
}

From source file:com.concentricsky.android.khanacademy.app.ManageDownloadsActivity.java

private void launchVideoDetailActivity(Video video, String parentTopicId) {
    // This may be a video in a different topic from where the user came from.
    // We synthesize the correct back stack for this video.

    Stack<Topic> stack = new Stack<Topic>();
    Topic topic = null;//  w ww. j a v a 2 s  .  c  o m
    try {
        Dao<Topic, String> topicDao = getDataService().getHelper().getTopicDao();
        topic = topicDao.queryForId(parentTopicId);
        while (topic != null) {
            stack.push(topic);
            topicDao.refresh(topic);
            topic = topic.getParentTopic();
        }
    } catch (SQLException e) {
        e.printStackTrace();
    } catch (ServiceUnavailableException e) {
        e.printStackTrace();
    }

    TaskStackBuilder t = TaskStackBuilder.create(this);
    Intent intent;
    while (!stack.isEmpty()) {
        topic = stack.pop();
        if (topic.getParentTopic() == null) {
            // Root topic gets the HomeActivity.
            intent = new Intent(this, HomeActivity.class);
            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        } else if (stack.isEmpty()) {
            // The video's immediate parent topic gets a VideoList.
            intent = new Intent(this, VideoListActivity.class);
            intent.putExtra(PARAM_TOPIC_ID, topic.getId());
        } else {
            // All other intermediate topics get TopicLists.
            intent = new Intent(this, TopicListActivity.class);
            intent.putExtra(PARAM_TOPIC_ID, topic.getId());
        }
        t.addNextIntent(intent);
    }

    // Add a manage downloads activity also, for back. It is skipped when going "up" from videos.
    intent = new Intent(this, ManageDownloadsActivity.class);
    t.addNextIntent(intent);

    intent = new Intent(this, VideoDetailActivity.class);
    intent.putExtra(PARAM_VIDEO_ID, video.getId());
    intent.putExtra(PARAM_TOPIC_ID, parentTopicId);
    t.addNextIntent(intent);
    t.startActivities();

    /*
        TaskStackBuilder just does this:
                
       intents[0].addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
       IntentCompat.FLAG_ACTIVITY_CLEAR_TASK |
       IntentCompat.FLAG_ACTIVITY_TASK_ON_HOME);
               
    and then uses Activity#startActivities. Support library fallback pre-honeycomb is to just start the top
    activity and allow back to progress back through the actual back stack (no synthesis).
     */

    //      startActivity(intent);
}

From source file:org.apache.tajo.plan.ExprAnnotator.java

@Override
public EvalNode visitFunction(Context ctx, Stack<Expr> stack, FunctionExpr expr) throws TajoException {
    stack.push(expr); // <--- Push

    // Given parameters
    Expr[] params = expr.getParams();/*from   w  w  w. ja  v a  2 s. c o  m*/
    if (params == null) {
        params = new Expr[0];
    }

    EvalNode[] givenArgs = new EvalNode[params.length];
    DataType[] paramTypes = new DataType[params.length];

    for (int i = 0; i < params.length; i++) {
        givenArgs[i] = visit(ctx, stack, params[i]);
        paramTypes[i] = convert(givenArgs[i].getValueType()).getDataType();
    }

    stack.pop(); // <--- Pop

    if (!catalog.containFunction(expr.getSignature(), paramTypes)) {
        throw new UndefinedFunctionException(buildSimpleFunctionSignature(expr.getSignature(), paramTypes));
    }

    FunctionDesc funcDesc = catalog.getFunction(expr.getSignature(), paramTypes);

    // trying the implicit type conversion between actual parameter types and the definition types.
    if (CatalogUtil.checkIfVariableLengthParamDefinition(Arrays.asList(funcDesc.getParamTypes()))) {
        DataType lastDataType = funcDesc.getParamTypes()[0];
        for (int i = 0; i < givenArgs.length; i++) {
            if (i < (funcDesc.getParamTypes().length - 1)) { // variable length
                lastDataType = funcDesc.getParamTypes()[i];
            } else {
                lastDataType = CatalogUtil
                        .newSimpleDataType(CatalogUtil.getPrimitiveTypeOf(lastDataType.getType()));
            }
            givenArgs[i] = convertType(ctx, givenArgs[i], TypeConverter.convert(lastDataType));
        }
    } else {
        assertEval(funcDesc.getParamTypes().length == givenArgs.length,
                "The number of parameters is mismatched to the function definition: " + funcDesc.toString());
        // According to our function matching method, each given argument can be casted to the definition parameter.
        for (int i = 0; i < givenArgs.length; i++) {
            givenArgs[i] = convertType(ctx, givenArgs[i], TypeConverter.convert(funcDesc.getParamTypes()[i]));
        }
    }

    FunctionType functionType = funcDesc.getFuncType();
    if (functionType == FunctionType.GENERAL || functionType == FunctionType.UDF) {
        return new GeneralFunctionEval(ctx.queryContext, funcDesc, givenArgs);
    } else if (functionType == FunctionType.AGGREGATION || functionType == FunctionType.UDA) {
        if (!ctx.currentBlock.hasNode(NodeType.GROUP_BY)) {
            ctx.currentBlock.setAggregationRequire();
        }
        return new AggregationFunctionCallEval(funcDesc, givenArgs);
    } else if (functionType == FunctionType.DISTINCT_AGGREGATION || functionType == FunctionType.DISTINCT_UDA) {
        throw new UnsupportedException(funcDesc.toString());
    } else {
        throw new UnsupportedException("function type '" + functionType.name() + "'");
    }
}