List of usage examples for java.util Stack push
public E push(E item)
From source file:net.firejack.platform.core.utils.Factory.java
public Class getGenericParameterClass(Class actualClass, Class genericClass, int parameterIndex) { if (!genericClass.isAssignableFrom(actualClass) || genericClass.equals(actualClass)) { throw new IllegalArgumentException( "Class " + genericClass.getName() + " is not a superclass of " + actualClass.getName() + "."); }//from www .ja va 2s . c o m Stack<ParameterizedType> types = new Stack<ParameterizedType>(); Class clazz = actualClass; while (true) { Type currentType = genericClass.isInterface() ? getGenericInterface(clazz, genericClass) : clazz.getGenericSuperclass(); Type rawType; if (currentType instanceof ParameterizedType) { ParameterizedType type = (ParameterizedType) currentType; types.push(type); rawType = type.getRawType(); } else { types.clear(); rawType = currentType; } if (!rawType.equals(genericClass)) { clazz = (Class) rawType; } else { break; } } if (types.isEmpty()) { return (Class) genericClass.getTypeParameters()[parameterIndex].getGenericDeclaration(); } Type result = types.pop().getActualTypeArguments()[parameterIndex]; while (result instanceof TypeVariable && !types.empty()) { int actualArgumentIndex = getParameterTypeDeclarationIndex((TypeVariable) result); ParameterizedType type = types.pop(); result = type.getActualTypeArguments()[actualArgumentIndex]; } if (result instanceof TypeVariable) { throw new IllegalStateException("Unable to resolve type variable " + result + "." + " Try to replace instances of parametrized class with its non-parameterized subtype."); } if (result instanceof ParameterizedType) { result = ((ParameterizedType) result).getRawType(); } if (result == null) { throw new IllegalStateException( "Unable to determine actual parameter type for " + actualClass.getName() + "."); } if (!(result instanceof Class)) { throw new IllegalStateException( "Actual parameter type for " + actualClass.getName() + " is not a Class."); } return (Class) result; }
From source file:org.apache.tajo.plan.ExprAnnotator.java
@Override public EvalNode visitInPredicate(Context ctx, Stack<Expr> stack, InPredicate expr) throws TajoException { stack.push(expr); EvalNode lhs = visit(ctx, stack, expr.getLeft()); ValueSetEval valueSetEval = (ValueSetEval) visit(ctx, stack, expr.getInValue()); stack.pop();//w w w . ja v a2 s .c o m Pair<EvalNode, EvalNode> pair = convertTypesIfNecessary(ctx, lhs, valueSetEval); return new InEval(pair.getFirst(), (ValueSetEval) pair.getSecond(), expr.isNot()); }
From source file:org.apache.tajo.plan.ExprAnnotator.java
@Override public EvalNode visitSign(Context ctx, Stack<Expr> stack, SignedExpr expr) throws TajoException { stack.push(expr); EvalNode numericExpr = visit(ctx, stack, expr.getChild()); stack.pop();/* ww w .j av a 2 s . c om*/ if (expr.isNegative()) { return new SignedEval(expr.isNegative(), numericExpr); } else { return numericExpr; } }
From source file:web.diva.server.model.SomClustering.SomClustImgGenerator.java
public int countgenes(Node trunk) { java.util.Stack c = new java.util.Stack(); int ret = 0;//ww w .j av a2s . c om c.push(trunk); Node tr = trunk; if (trunk == null) { System.out.print("\n!No trunk\n"); } while (!c.empty()) { tr = (Node) c.pop(); if (tr.merged) { c.push(tr.left); c.push(tr.right); } else { ret++; } } return ret; }
From source file:org.apache.tajo.plan.ExprAnnotator.java
@Override public EvalNode visitAnd(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 www .ja v a 2s . c o m return new BinaryEval(EvalType.AND, left, right); }
From source file:org.apache.tajo.plan.ExprAnnotator.java
@Override public EvalNode visitOr(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 . jav a 2s. co m*/ return new BinaryEval(EvalType.OR, left, right); }
From source file:org.apache.tajo.plan.ExprAnnotator.java
@Override public EvalNode visitPlus(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();// www. jav a2 s . c o m return createBinaryNode(ctx, EvalType.PLUS, left, right); }
From source file:org.apache.tajo.plan.ExprAnnotator.java
@Override public EvalNode visitMinus(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 w w. j a va 2s . co m return createBinaryNode(ctx, EvalType.MINUS, left, right); }
From source file:org.apache.tajo.plan.ExprAnnotator.java
@Override public EvalNode visitMultiply(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 www . j a v a 2s .com return createBinaryNode(ctx, EvalType.MULTIPLY, left, right); }
From source file:org.apache.tajo.plan.ExprAnnotator.java
@Override public EvalNode visitDivide(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. jav a2s . c o m return createBinaryNode(ctx, EvalType.DIVIDE, left, right); }