EMMA Coverage Report (generated Thu Dec 06 15:52:10 GMT 2007)
[all classes][com.sun.tools.javac.model]

COVERAGE SUMMARY FOR SOURCE FILE [FilteredMemberList.java]

nameclass, %method, %block, %line, %
FilteredMemberList.java0%   (0/2)0%   (0/11)0%   (0/143)0%   (0/30)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class FilteredMemberList0%   (0/1)0%   (0/7)0%   (0/73)0%   (0/15)
FilteredMemberList (Scope): void 0%   (0/1)0%   (0/6)0%   (0/3)
access$000 (FilteredMemberList): Scope 0%   (0/1)0%   (0/3)0%   (0/1)
access$100 (Symbol): boolean 0%   (0/1)0%   (0/3)0%   (0/1)
get (int): Symbol 0%   (0/1)0%   (0/24)0%   (0/4)
iterator (): Iterator 0%   (0/1)0%   (0/5)0%   (0/1)
size (): int 0%   (0/1)0%   (0/19)0%   (0/5)
unwanted (Symbol): boolean 0%   (0/1)0%   (0/13)0%   (0/1)
     
class FilteredMemberList$10%   (0/1)0%   (0/4)0%   (0/70)0%   (0/16)
FilteredMemberList$1 (FilteredMemberList): void 0%   (0/1)0%   (0/15)0%   (0/3)
hasNext (): boolean 0%   (0/1)0%   (0/30)0%   (0/6)
next (): Symbol 0%   (0/1)0%   (0/21)0%   (0/6)
remove (): void 0%   (0/1)0%   (0/4)0%   (0/1)

1/*
2 * Copyright 2005 Sun Microsystems, Inc.  All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.  Sun designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Sun in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 * CA 95054 USA or visit www.sun.com if you need additional information or
23 * have any questions.
24 */
25 
26package com.sun.tools.javac.model;
27 
28import com.sun.tools.javac.util.*;
29import java.util.AbstractList;
30import java.util.Iterator;
31import java.util.NoSuchElementException;
32import com.sun.tools.javac.code.Scope;
33import com.sun.tools.javac.code.Symbol;
34 
35import static com.sun.tools.javac.code.Flags.*;
36 
37/**
38 * Utility to construct a view of a symbol's members,
39 * filtering out unwanted elements such as synthetic ones.
40 * This view is most efficiently accessed through its iterator() method.
41 *
42 * <p><b>This is NOT part of any API supported by Sun Microsystems.  If
43 * you write code that depends on this, you do so at your own risk.
44 * This code and its internal interfaces are subject to change or
45 * deletion without notice.</b>
46 */
47public class FilteredMemberList extends AbstractList<Symbol> {
48 
49    private final Scope scope;
50 
51    public FilteredMemberList(Scope scope) {
52        this.scope = scope;
53    }
54 
55    public int size() {
56        int cnt = 0;
57        for (Scope.Entry e = scope.elems; e != null; e = e.sibling) {
58            if (!unwanted(e.sym))
59                cnt++;
60        }
61        return cnt;
62    }
63 
64    public Symbol get(int index) {
65        for (Scope.Entry e = scope.elems; e != null; e = e.sibling) {
66            if (!unwanted(e.sym) && (index-- == 0))
67                return e.sym;
68        }
69        throw new IndexOutOfBoundsException();
70    }
71 
72    // A more efficient implementation than AbstractList's.
73    public Iterator<Symbol> iterator() {
74        return new Iterator<Symbol>() {
75 
76            /** The next entry to examine, or null if none. */
77            private Scope.Entry nextEntry = scope.elems;
78 
79            private boolean hasNextForSure = false;
80 
81            public boolean hasNext() {
82                if (hasNextForSure) {
83                    return true;
84                }
85                while (nextEntry != null && unwanted(nextEntry.sym)) {
86                    nextEntry = nextEntry.sibling;
87                }
88                hasNextForSure = (nextEntry != null);
89                return hasNextForSure;
90            }
91 
92            public Symbol next() {
93                if (hasNext()) {
94                    Symbol result = nextEntry.sym;
95                    nextEntry = nextEntry.sibling;
96                    hasNextForSure = false;
97                    return result;
98                } else {
99                    throw new NoSuchElementException();
100                }
101            }
102 
103            public void remove() {
104                throw new UnsupportedOperationException();
105            }
106        };
107    }
108 
109    /**
110     * Tests whether this is a symbol that should never be seen by
111     * clients, such as a synthetic class.  Returns true for null.
112     */
113    private static boolean unwanted(Symbol s) {
114        return s == null  ||  (s.flags() & SYNTHETIC) != 0;
115    }
116}

[all classes][com.sun.tools.javac.model]
EMMA 2.0.5312 (C) Vladimir Roubtsov