Java Code Examples for java.util.Stack#get()

The following examples show how to use java.util.Stack#get() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OLAPTableScan.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
/**
 * There're 3 special RelNode in parents stack, OLAPProjectRel, OLAPToEnumerableConverter
 * and OLAPUnionRel. OLAPProjectRel will helps collect required columns but the other two
 * don't. Go through the parent RelNodes from bottom to top, and the first-met special
 * RelNode determines the behavior.
 *      * OLAPProjectRel -> skip column collection
 *      * OLAPToEnumerableConverter and OLAPUnionRel -> require column collection
 */
private boolean needCollectionColumns(OLAPImplementor implementor) {
    Stack<RelNode> allParents = implementor.getParentNodeStack();
    int index = allParents.size() - 1;

    while (index >= 0) {
        RelNode parent = allParents.get(index);
        if (parent instanceof OLAPProjectRel) {
            return false;
        }

        if (parent instanceof OLAPToEnumerableConverter || parent instanceof OLAPUnionRel) {
            return true;
        }

        OLAPRel olapParent = (OLAPRel) allParents.get(index);
        if (olapParent.getContext() != null && olapParent.getContext() != this.context) {
            // if the whole context has not projection, let table scan take care of itself
            break;
        }
        index--;
    }

    return true;
}
 
Example 2
Source File: Digester.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * <p>Gets the top object from the stack with the given name.
 * This method does not remove the object from the stack.
 * </p>
 * <p><strong>Note:</strong> a stack is considered empty
 * if no objects have been pushed onto it yet.</p>
 *
 * @param stackName the name of the stack to be peeked
 * @param n Index of the desired element, where 0 is the top of the stack,
 *  1 is the next element down, and so on.
 * @return the specified <code>Object</code> on the stack.
 * @throws EmptyStackException if the named stack is empty 
 *
 * @since 1.6
 */
public Object peek(String stackName, int n) {
    Object result = null;
    Stack<Object> namedStack = stacksByName.get(stackName);
    if (namedStack == null ) {
        if (log.isDebugEnabled()) {
            log.debug("Stack '" + stackName + "' is empty");
        }        
        throw new EmptyStackException();
    
    } else {
        int index = (namedStack.size() - 1) - n;
        if (index < 0) {
            throw new EmptyStackException();
        }
        result = namedStack.get(index);
    }
    return result;
}
 
Example 3
Source File: ReturnStatement.java    From Concurnas with MIT License 6 votes vote down vote up
@Override
public void setLabelBeforeAction(Label endLabel) {
	Stack<Pair<Label, Block>> onEntry = this.getLinesToVisitOnEntry();
	
	//they are stored in reverse order
	for(int n=onEntry.size()-1; n >= 0; n--){
		Pair<Label, Block> level = onEntry.get(n);
		if(level.getA()!=null){
			onEntry.set(n, new Pair<Label, Block>(endLabel, level.getB()));//overrite the label
			return;
		}
		
	}
	//nothing extra to insert so...
	setLabelToVisitJustBeforeReturnOpCode(endLabel);
}
 
Example 4
Source File: OLAPTableScan.java    From kylin with Apache License 2.0 6 votes vote down vote up
/**
 * There're 3 special RelNode in parents stack, OLAPProjectRel, OLAPToEnumerableConverter
 * and OLAPUnionRel. OLAPProjectRel will helps collect required columns but the other two
 * don't. Go through the parent RelNodes from bottom to top, and the first-met special
 * RelNode determines the behavior.
 *      * OLAPProjectRel -> skip column collection
 *      * OLAPToEnumerableConverter and OLAPUnionRel -> require column collection
 */
private boolean needCollectionColumns(OLAPImplementor implementor) {
    Stack<RelNode> allParents = implementor.getParentNodeStack();
    int index = allParents.size() - 1;

    while (index >= 0) {
        RelNode parent = allParents.get(index);
        if (parent instanceof OLAPProjectRel) {
            return false;
        }

        if (parent instanceof OLAPToEnumerableConverter || parent instanceof OLAPUnionRel) {
            return true;
        }

        OLAPRel olapParent = (OLAPRel) allParents.get(index);
        if (olapParent.getContext() != null && olapParent.getContext() != this.context) {
            // if the whole context has not projection, let table scan take care of itself
            break;
        }
        index--;
    }

    return true;
}
 
Example 5
Source File: DefaultModuleDescriptor.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
private void checkConf(Stack<String> confs, String confName) {
    int index = confs.indexOf(confName);
    if (index != -1) {
        StringBuilder cycle = new StringBuilder();
        for (; index < confs.size(); index++) {
            cycle.append(confs.get(index)).append(" => ");
        }
        cycle.append(confName);
        throw new IllegalStateException("illegal cycle detected in configuration extension: "
                + cycle);
    }
    Configuration conf = getConfiguration(confName);
    if (conf == null) {
        throw new IllegalStateException("unknown configuration '" + confName
                + "'. It is extended by " + confs.get(confs.size() - 1));
    }
    for (String ext : conf.getExtends()) {
        confs.push(conf.getName());
        checkConf(confs, ext.trim());
        confs.pop();
    }
}
 
Example 6
Source File: DefaultShortArrayReader.java    From domino-jackson with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public short[] readArray(JsonReader reader) {
    Stack<Short> shortStack = new Stack<>();
    reader.beginArray();
    while (JsonToken.END_ARRAY != reader.peek()) {
        if (JsonToken.NULL == reader.peek()) {
            reader.skipValue();
            shortStack.push(null);
        } else {
            shortStack.push(new Integer(reader.nextInt()).shortValue());
        }
    }
    reader.endArray();
    short[] shorts = new short[shortStack.size()];
    for (int i = 0; i < shortStack.size(); i++) {
        shorts[i] = shortStack.get(i);
    }
    return shorts;
}
 
Example 7
Source File: Solution3.java    From LeetCode-Solution-in-Good-Style with Apache License 2.0 6 votes vote down vote up
private boolean noDanger(Stack<Integer> pre, int len) {
    int[] board = new int[len];
    for (int i = 0; i < len; i++) {
        board[i] = pre.get(i);
    }
    for (int i = 0; i < len - 1; i++) {
        for (int j = i + 1; j < len; j++) {
            // 得到所有不同的 i j 的组合,是一个组合问题,按顺序来就行
            // System.out.println(i + "\t" + j);
            if (i - j == board[i] - board[j]) {
                return false;
            }
            if (i - j == -(board[i] - board[j])) {
                return false;
            }
        }

    }
    // 走到这里表示通过检验
    // System.out.println(Arrays.toString(board));
    return true;
}
 
Example 8
Source File: MilestoneRectangle.java    From reladomo with Apache License 2.0 5 votes vote down vote up
public static List<MilestoneRectangle> merge(List<MilestoneRectangle> input)
{
    Stack<MilestoneRectangle> mergeStack = new Stack<MilestoneRectangle>();
    for (MilestoneRectangle rectangle : input)
    {
        if (rectangle.isValid())
        {
            mergeStack.push(rectangle);
        }
        else
        {
            MithraDataObject dataObject = (MithraDataObject) rectangle.data;
            LOGGER.warn("Invalid milestoning of " + dataObject.getClass().getSimpleName() + '[' + dataObject.zGetPrintablePrimaryKey() + ']');
        }
    }
    List<MilestoneRectangle> merged = FastList.newList(input.size());
    while (!mergeStack.isEmpty())
    {
        MilestoneRectangle next = mergeStack.pop();

        boolean fragmented = false;
        for(int i = mergeStack.size() - 1; !fragmented && i >=0; i--)
        {
            MilestoneRectangle rect = mergeStack.get(i);
            if (next.intersects(rect))
            {
                next.fragment(rect, mergeStack);
                fragmented = true;
            }
        }
        if (!fragmented)
        {
            merged.add(next);
        }
    }
    return merged;
}
 
Example 9
Source File: TestLambdaMultithreaded.java    From openjdk-systemtest with Apache License 2.0 5 votes vote down vote up
private void assertStack(Stack<Integer> stack, int... expectedValues) {
	assertEquals("Stack size wrong. Contains " + stack + " Sizes:", expectedValues.length, stack.size());
	
	for (int i=0; i<expectedValues.length; i++) {
		int actual = (int) stack.get(expectedValues.length - i -1);
		int expected = expectedValues[i];
		assertEquals("Stack does not contain expected value at index[" + i + "].", expected, actual);
	}
}
 
Example 10
Source File: RequestRateThrottleFilter.java    From Alpine with Apache License 2.0 5 votes vote down vote up
/**
 * Determines if the request rate is below or has exceeded the the maximum requests per second
 * for the given time period. If exceeded, a HTTP status code of 429 (too many requests) will
 * be send and no further processing of the request will be done. If the request has not exceeded
 * the limit, the request will continue on as normal.
 *
 * @param request a ServletRequest
 * @param response a ServletResponse
 * @param chain a FilterChain
 * @throws IOException a IOException
 * @throws ServletException a ServletException
 */
public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain chain)
        throws IOException, ServletException {
    final HttpServletRequest httpRequest = (HttpServletRequest) request;
    final HttpServletResponse httpResponse = (HttpServletResponse) response;
    final HttpSession session = httpRequest.getSession(true);

    synchronized (session.getId().intern()) {
        Stack<Date> times = HttpUtil.getSessionAttribute(session, "times");
        if (times == null) {
            times = new Stack<>();
            times.push(new Date(0));
            session.setAttribute("times", times);
        }
        times.push(new Date());
        if (times.size() >= maximumRequestsPerPeriod) {
            times.removeElementAt(0);
        }
        final Date newest = times.get(times.size() - 1);
        final Date oldest = times.get(0);
        final long elapsed = newest.getTime() - oldest.getTime();
        if (elapsed < timePeriodSeconds * 1000) {
            httpResponse.sendError(429);
            return;
        }
    }
    chain.doFilter(request, response);
}
 
Example 11
Source File: SwipeLayout.java    From FragmentRigger with MIT License 5 votes vote down vote up
@Nullable
private Fragment getPreFragment() {
    Stack<String> stack = Rigger.getRigger(mPuppetHost).getFragmentStack();
    if (stack.size() <= 1) {
        return null;
    }
    String topTag = stack.get(stack.size() - 2);
    return Rigger.getRigger(mPuppetHost).findFragmentByTag(topTag);
}
 
Example 12
Source File: ScriptBuilder.java    From bcm-android with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Adds the given number as a push data chunk to the given index in the program.
 * This is intended to use for negative numbers or values greater than 16, and although
 * it will accept numbers in the range 0-16 inclusive, the encoding would be
 * considered non-standard.
 *
 * @see #number(long)
 */
protected ScriptBuilder bigNum(int index, long num) {
    final byte[] data;

    if (num == 0) {
        data = new byte[0];
    } else {
        Stack<Byte> result = new Stack<>();
        final boolean neg = num < 0;
        long absvalue = Math.abs(num);

        while (absvalue != 0) {
            result.push((byte) (absvalue & 0xff));
            absvalue >>= 8;
        }

        if ((result.peek() & 0x80) != 0) {
            // The most significant byte is >= 0x80, so push an extra byte that
            // contains just the sign of the value.
            result.push((byte) (neg ? 0x80 : 0));
        } else if (neg) {
            // The most significant byte is < 0x80 and the value is negative,
            // set the sign bit so it is subtracted and interpreted as a
            // negative when converting back to an integral.
            result.push((byte) (result.pop() | 0x80));
        }

        data = new byte[result.size()];
        for (int byteIdx = 0; byteIdx < data.length; byteIdx++) {
            data[byteIdx] = result.get(byteIdx);
        }
    }

    // At most the encoded value could take up to 8 bytes, so we don't need
    // to use OP_PUSHDATA opcodes
    return addChunk(index, new ScriptChunk(data.length, data));
}
 
Example 13
Source File: Solution.java    From codekata with MIT License 5 votes vote down vote up
public int[] asteroidCollision(int[] asteroids) {
    Stack<Integer> stack = new Stack<>();
    for (int asteroid : asteroids) {
        if (!stack.isEmpty() && stack.peek() > 0 && asteroid < 0) {
            boolean isDestroyed = false;
            while (!stack.isEmpty() && stack.peek() > 0) {
                if (stack.peek() > Math.abs(asteroid)) {
                    isDestroyed = true;
                    break;
                } else if (stack.peek() < Math.abs(asteroid)) {
                    stack.pop();
                } else {
                    isDestroyed = true;
                    stack.pop();
                    break;
                }
            }
            if (!isDestroyed) stack.add(asteroid);
        } else {
            stack.add(asteroid);
        }
    }

    int[] result = new int[stack.size()];
    for (int i = 0; i < result.length; i++) result[i] = stack.get(i);
    return result;
}
 
Example 14
Source File: ScriptBuilder.java    From GreenBits with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Adds the given number as a push data chunk to the given index in the program.
 * This is intended to use for negative numbers or values > 16, and although
 * it will accept numbers in the range 0-16 inclusive, the encoding would be
 * considered non-standard.
 * 
 * @see #number(int)
 */
protected ScriptBuilder bigNum(int index, long num) {
    final byte[] data;

    if (num == 0) {
        data = new byte[0];
    } else {
        Stack<Byte> result = new Stack<>();
        final boolean neg = num < 0;
        long absvalue = Math.abs(num);

        while (absvalue != 0) {
            result.push((byte) (absvalue & 0xff));
            absvalue >>= 8;
        }

        if ((result.peek() & 0x80) != 0) {
            // The most significant byte is >= 0x80, so push an extra byte that
            // contains just the sign of the value.
            result.push((byte) (neg ? 0x80 : 0));
        } else if (neg) {
            // The most significant byte is < 0x80 and the value is negative,
            // set the sign bit so it is subtracted and interpreted as a
            // negative when converting back to an integral.
            result.push((byte) (result.pop() | 0x80));
        }

        data = new byte[result.size()];
        for (int byteIdx = 0; byteIdx < data.length; byteIdx++) {
            data[byteIdx] = result.get(byteIdx);
        }
    }

    // At most the encoded value could take up to 8 bytes, so we don't need
    // to use OP_PUSHDATA opcodes
    return addChunk(index, new ScriptChunk(data.length, data));
}
 
Example 15
Source File: ModuleGraph.java    From PGM with GNU Affero General Public License v3.0 5 votes vote down vote up
protected void addFactory(Class<? extends M> key, F factory) {
  factories.put(key, factory);

  final Stack<ModuleLoadException> errors = new Stack<>();
  if (loaded.get()) {
    load(key, null, errors);
  }

  if (!errors.isEmpty()) {
    throw errors.get(0);
  }
}
 
Example 16
Source File: Timeline.java    From jpexs-decompiler with GNU General Public License v3.0 4 votes vote down vote up
public Shape getOutline(int frame, int time, RenderContext renderContext, Matrix transformation, boolean stroked) {
    Frame fr = getFrame(frame);
    Area area = new Area();
    Stack<Clip> clips = new Stack<>();
    for (int d = maxDepth; d >= 0; d--) {
        Clip currentClip = null;
        for (int i = clips.size() - 1; i >= 0; i--) {
            Clip cl = clips.get(i);
            if (cl.depth <= d) {
                clips.remove(i);
            }
        }
        if (!clips.isEmpty()) {
            currentClip = clips.peek();
        }
        DepthState layer = fr.layers.get(d);
        if (layer == null) {
            continue;
        }
        if (!layer.isVisible) {
            continue;
        }
        CharacterTag character = swf.getCharacter(layer.characterId);
        if (character instanceof DrawableTag) {
            DrawableTag drawable = (DrawableTag) character;
            Matrix m = transformation.concatenate(new Matrix(layer.matrix));

            int drawableFrameCount = drawable.getNumFrames();
            if (drawableFrameCount == 0) {
                drawableFrameCount = 1;
            }

            int dframe = time % drawableFrameCount;
            if (character instanceof ButtonTag) {
                dframe = ButtonTag.FRAME_UP;
                if (renderContext.cursorPosition != null) {
                    ButtonTag buttonTag = (ButtonTag) character;
                    Shape buttonShape = buttonTag.getOutline(ButtonTag.FRAME_HITTEST, time, layer.ratio, renderContext, m, stroked);
                    if (buttonShape.contains(renderContext.cursorPosition)) {
                        if (renderContext.mouseButton > 0) {
                            dframe = ButtonTag.FRAME_DOWN;
                        } else {
                            dframe = ButtonTag.FRAME_OVER;
                        }
                    }
                }
            }

            Shape cshape = ((DrawableTag) character).getOutline(dframe, time, layer.ratio, renderContext, m, stroked);
            Area addArea = new Area(cshape);
            if (currentClip != null) {
                Area a = new Area(new Rectangle(displayRect.Xmin, displayRect.Ymin, displayRect.getWidth(), displayRect.getHeight()));
                a.subtract(new Area(currentClip.shape));
                addArea.subtract(a);
            }

            if (layer.clipDepth > -1) {
                Clip clip = new Clip(addArea, layer.clipDepth);
                clips.push(clip);
            } else {
                area.add(addArea);
            }
        }
    }
    return area;
}
 
Example 17
Source File: DestackerFallback.java    From securify with Apache License 2.0 4 votes vote down vote up
/**
 * Ensure that there exists a canonical stack with unique variables at the given instruction.
 * @param jumpsrc jump source where some variable reassignments may be made, null if we're in local execution (i.e. it's not a jump)
 * @param jumpdest jump destination where the canonical stack should be defined
 * @param stack canonical stack candidate
 */
private void ensureUniqueCanonicalStack(Instruction jumpsrc, int jumpdest, Instruction inlineDest, Stack<Variable> stack) {
	if (jumpsrc == null && inlineDest == null || jumpsrc != null && inlineDest != null)
		throw new IllegalArgumentException();

	// check if the current stack is going to be used as a canonical stack
	if (!canonicalStackForBranchJoinJumpdest.containsKey(jumpdest)) {
		// if so, check for duplicate variables in the stack, which may cause merge conflicts
		if (stack.size() != stack.stream().distinct().count()) {
			log.println("undup canonical stack @" + HexPrinter.toHex(jumpdest));
			// map duplicate variables to new ones
			if (jumpsrc != null && variableReassignments.containsKey(jumpsrc) ||
					jumpsrc == null && variableReassignmentsInline.containsKey(inlineDest)) {
				throw new IllegalStateException("reassignment does already exist");
			}
			Map<Variable, Variable> reassignments = new HashMap<>();
			Set<Variable> processedVars = new HashSet<>();
			for (int i = 0; i < stack.size(); ++i) {
				Variable var = stack.get(i);
				if (processedVars.contains(var)) {
					// duplicate variable, create new one with reassigment
					Variable undupVar = new Variable();
					stack.set(i, undupVar);
					reassignments.put(undupVar, var);
					log.println(" " + undupVar + " <- " + var);
				}
				else {
					processedVars.add(var);
				}
			}
			if (jumpsrc == null) {
				variableReassignmentsInline.put(inlineDest, reassignments);
			}
			else {
				variableReassignments.put(new Pair<>(jumpsrc, true), reassignments);
			}
		}
		// add some placeholder variable at the stack's bottom,
		// in case our canonical stack is too small to map another merged stack
		if (jumpsInv.get(jumpdest).size() > 1) {
			for (int i = 0; i < 20; ++i) {
				Variable virtualVar = new Variable();
				virtualCanonicalVars.add(virtualVar);
				stack.insertElementAt(virtualVar, 0);
			}
			sawPlaceholderVarsAtStackBottom = true;
		}
	}
}
 
Example 18
Source File: MappingPrinter.java    From proguard with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Prints out the mapping of the specified inlined methods and its
 * enclosing methods.
 */
private void printInlinedMethodMapping(String         className,
                                       String         methodName,
                                       String         methodDescriptor,
                                       LineNumberInfo inlinedInfo,
                                       Stack          enclosingLineNumbers,
                                       String         obfuscatedMethodName)
{
    String source = inlinedInfo.getSource();

    // Parse the information from the source string of the
    // inlined method.
    int separatorIndex1 = source.indexOf('.');
    int separatorIndex2 = source.indexOf('(', separatorIndex1 + 1);
    int separatorIndex3 = source.indexOf(':', separatorIndex2 + 1);
    int separatorIndex4 = source.indexOf(':', separatorIndex3 + 1);

    String inlinedClassName        = source.substring(0, separatorIndex1);
    String inlinedMethodName       = source.substring(separatorIndex1 + 1, separatorIndex2);
    String inlinedMethodDescriptor = source.substring(separatorIndex2, separatorIndex3);
    String inlinedRange            = source.substring(separatorIndex3);

    int startLineNumber = Integer.parseInt(source.substring(separatorIndex3 + 1, separatorIndex4));
    int endLineNumber   = Integer.parseInt(source.substring(separatorIndex4 + 1));

    // Compute the shifted line number range.
    int shiftedStartLineNumber = inlinedInfo.u2lineNumber;
    int shiftedEndLineNumber   = shiftedStartLineNumber + endLineNumber - startLineNumber;

    // Print out the line number range of the inlined method.
    ps.println("    " +
               shiftedStartLineNumber                                      + ":" +
               shiftedEndLineNumber                                        + ":" +
               ClassUtil.externalMethodReturnType(inlinedMethodDescriptor) + " " +
               (inlinedClassName.equals(className) ? "" :
               ClassUtil.externalClassName(inlinedClassName)               + JavaConstants.PACKAGE_SEPARATOR)     +
               inlinedMethodName                                           + JavaConstants.METHOD_ARGUMENTS_OPEN  +
               ClassUtil.externalMethodArguments(inlinedMethodDescriptor)  + JavaConstants.METHOD_ARGUMENTS_CLOSE +
               inlinedRange                                                + " -> " +
               obfuscatedMethodName);

    // Print out the line numbers of the accumulated enclosing
    // methods.
    for (int enclosingIndex = enclosingLineNumbers.size()-1; enclosingIndex >= 0; enclosingIndex--)
    {
        LineNumberInfo enclosingInfo =
            (LineNumberInfo)enclosingLineNumbers.get(enclosingIndex);

        printEnclosingMethodMapping(className,
                                    methodName,
                                    methodDescriptor,
                                    shiftedStartLineNumber + ":" +
                                    shiftedEndLineNumber,
                                    enclosingInfo,
                                    obfuscatedMethodName);


    }
}
 
Example 19
Source File: RTDebuggerWindow.java    From trygve with GNU General Public License v2.0 4 votes vote down vote up
private void printMiniStackStatus() {
	// Experiment: Pop down stack looking for information about the method
    RTPostReturnProcessing returnChit = null;
    int lastLineNumber = RunTimeEnvironment.runTimeEnvironment_.currentExecutingLineNumber();
    final Stack<RTStackable> theStack = RunTimeEnvironment.runTimeEnvironment_.theStack();
	RTStackable topOfStack = null;
	tracebackScrollContent_ = "";
	for (int stackIndex = theStack.size() - 1; 0 <= stackIndex; stackIndex--) {
		RTPostReturnProcessing currentMethodReturn;
		topOfStack = theStack.get(stackIndex);
		if (topOfStack instanceof RTPostReturnProcessing) {
			returnChit = (RTPostReturnProcessing) topOfStack;
			currentMethodReturn = (RTPostReturnProcessing)topOfStack;
			tracebackScrollContent_ = tracebackScrollContent_.concat("In `" +
					currentMethodReturn.debugName() + "." +
					currentMethodReturn.name() + ":' " + lastLineNumber + "\n");
			lastLineNumber = returnChit.lineNumber();
		} else {
			tracebackScrollContent_ = tracebackScrollContent_.concat(
					"In " + topOfStack.getClass().getSimpleName() + ": "
					+ "???" + "\n");
		}
		for (stackIndex--; 0 <= stackIndex; stackIndex--) {
			topOfStack = theStack.get(stackIndex);
			if (topOfStack instanceof RTPostReturnProcessing) {
				returnChit = (RTPostReturnProcessing) topOfStack;
				currentMethodReturn = (RTPostReturnProcessing)topOfStack;
				tracebackScrollContent_ = tracebackScrollContent_.concat(
						" Called from `" + currentMethodReturn.debugName() + "." +
						currentMethodReturn.name() + ":' " + lastLineNumber + "\n");
				lastLineNumber = returnChit.lineNumber();
			}
		}
		/*
		tracebackScrollContent_ = tracebackScrollContent_.concat(
				" popping stack: type is " + topOfStack.getClass().getSimpleName() + "\n");
		*/
	}
	if (topOfStack instanceof RTPostReturnProcessing) {
		returnChit = (RTPostReturnProcessing) topOfStack;
		tracebackScrollContent_ = tracebackScrollContent_.concat(
			" Called from `main:' " + returnChit.lineNumber() + "\n");
	} else if (null == topOfStack) {
		final int current = RunTimeEnvironment.runTimeEnvironment_.currentExecutingLineNumber();
		tracebackScrollContent_ = tracebackScrollContent_.concat(
				" Called from `main:' " + current + "\n");
	}

	tracebackPanel_.setText(tracebackScrollContent_);
	final JScrollBar vertical = tracebackScrollPane_.getVerticalScrollBar();
	vertical.setValue( vertical.getMaximum() );
}
 
Example 20
Source File: IvyContext.java    From ant-ivy with Apache License 2.0 3 votes vote down vote up
/**
 * Reads the first object from the list saved under given key in the first context from the
 * context stack in which this key is defined. If value under key in any of the contexts form
 * the stack represents non List object then a RuntimeException is thrown.
 * <p>
 * This methods does a similar job to {@link #peek(String)}, except that it considers the whole
 * context stack and not only one instance.
 * </p>
 *
 * @param key
 *            context key for the string
 * @return top object from the list (index 0) of the first context in the stack containing this
 *         key or null if no key or list empty in all contexts from the context stack
 * @see #peek(String)
 */
public static Object peekInContextStack(String key) {
    Object value = null;
    Stack<IvyContext> contextStack = getCurrentStack();
    for (int i = contextStack.size() - 1; i >= 0 && value == null; i--) {
        IvyContext ctx = contextStack.get(i);
        value = ctx.peek(key);
    }
    return value;
}