varenumerator.java
来自「这是一个Linux下的集成开发环境」· Java 代码 · 共 83 行
JAVA
83 行
// Copyright (c) 1997 Per M.A. Bothner.// This is free software; for terms and warranty disclaimer see ./COPYING.package gnu.bytecode;/** Use this Enuemration class to iterate over the Variables in a Scope. * Descends into child scopes. * @author Per Bothner <bothner@cygnus.com> */public class VarEnumerator implements java.util.Enumeration{ Scope topScope; Scope currentScope; Variable next; public VarEnumerator (Scope scope) { topScope = scope; reset (); } public final void reset () { currentScope = topScope; if (topScope != null) { next = currentScope.firstVar (); if (next == null) fixup (); } } private void fixup () { while (next == null) { if (currentScope.firstChild != null) currentScope = currentScope.firstChild; else { while (currentScope.nextSibling == null) { if (currentScope == topScope) return; currentScope = currentScope.parent; } currentScope = currentScope.nextSibling; } next = currentScope.firstVar (); } } /** Return the next Variable in the Scope tree, or null if done. */ public final Variable nextVar () { Variable result = next; if (result != null) { next = result.nextVar (); if (next == null) fixup (); } return result; } public final boolean hasMoreElements () { return next != null; } public Object nextElement () { Variable result = nextVar (); if (result == null) throw new java.util.NoSuchElementException("VarEnumerator"); return result; } }
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?