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

COVERAGE SUMMARY FOR SOURCE FILE [JavacOption.java]

nameclass, %method, %block, %line, %
JavacOption.java75%  (3/4)35%  (9/26)37%  (91/249)46%  (20.9/45)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class JavacOption$OptionKind0%   (0/1)0%   (0/4)0%   (0/48)0%   (0/4)
<static initializer> 0%   (0/1)0%   (0/34)0%   (0/4)
JavacOption$OptionKind (String, int): void 0%   (0/1)0%   (0/5)0%   (0/1)
valueOf (String): JavacOption$OptionKind 0%   (0/1)0%   (0/5)0%   (0/1)
values (): JavacOption$OptionKind [] 0%   (0/1)0%   (0/4)0%   (0/1)
     
class JavacOption$HiddenOption100% (1/1)20%  (1/5)38%  (6/16)29%  (2/7)
JavacOption$HiddenOption (OptionName, String): void 0%   (0/1)0%   (0/6)0%   (0/2)
getKind (): JavacOption$OptionKind 0%   (0/1)0%   (0/2)0%   (0/1)
help (PrintWriter): void 0%   (0/1)0%   (0/1)0%   (0/1)
xhelp (PrintWriter): void 0%   (0/1)0%   (0/1)0%   (0/1)
JavacOption$HiddenOption (OptionName): void 100% (1/1)100% (6/6)100% (2/2)
     
class JavacOption$Option100% (1/1)50%  (6/12)44%  (73/166)55%  (14.9/27)
getKind (): JavacOption$OptionKind 0%   (0/1)0%   (0/2)0%   (0/1)
help (PrintWriter): void 0%   (0/1)0%   (0/32)0%   (0/5)
helpSynopsis (): String 0%   (0/1)0%   (0/31)0%   (0/1)
process (Options, String): boolean 0%   (0/1)0%   (0/22)0%   (0/3)
toString (): String 0%   (0/1)0%   (0/4)0%   (0/1)
xhelp (PrintWriter): void 0%   (0/1)0%   (0/1)0%   (0/1)
hasArg (): boolean 100% (1/1)90%  (9/10)90%  (0.9/1)
JavacOption$Option (OptionName, String): void 100% (1/1)100% (6/6)100% (2/2)
JavacOption$Option (OptionName, String, String): void 100% (1/1)100% (32/32)100% (7/7)
getName (): OptionName 100% (1/1)100% (3/3)100% (1/1)
matches (String): boolean 100% (1/1)100% (15/15)100% (1/1)
process (Options, String, String): boolean 100% (1/1)100% (8/8)100% (3/3)
     
class JavacOption$XOption100% (1/1)40%  (2/5)63%  (12/19)57%  (4/7)
getKind (): JavacOption$OptionKind 0%   (0/1)0%   (0/2)0%   (0/1)
help (PrintWriter): void 0%   (0/1)0%   (0/1)0%   (0/1)
xhelp (PrintWriter): void 0%   (0/1)0%   (0/4)0%   (0/1)
JavacOption$XOption (OptionName, String): void 100% (1/1)100% (6/6)100% (2/2)
JavacOption$XOption (OptionName, String, String): void 100% (1/1)100% (6/6)100% (2/2)

1/*
2 * Copyright 2006 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.main;
27 
28import com.sun.tools.javac.util.Log;
29import com.sun.tools.javac.util.Options;
30import java.io.PrintWriter;
31 
32/**
33 * TODO: describe com.sun.tools.javac.main.JavacOption
34 *
35 * <p><b>This is NOT part of any API supported by Sun Microsystems.
36 * If you write code that depends on this, you do so at your own
37 * risk.  This code and its internal interfaces are subject to change
38 * or deletion without notice.</b></p>
39 */
40public interface JavacOption {
41 
42    OptionKind getKind();
43 
44    /** Does this option take a (separate) operand? */
45    boolean hasArg();
46 
47    /** Does argument string match option pattern?
48     *  @param arg        The command line argument string.
49     */
50    boolean matches(String arg);
51 
52    /** Process the option (with arg). Return true if error detected.
53     */
54    boolean process(Options options, String option, String arg);
55 
56    /** Process the option (without arg). Return true if error detected.
57     */
58    boolean process(Options options, String option);
59 
60    OptionName getName();
61 
62    enum OptionKind {
63        NORMAL,
64        EXTENDED,
65        HIDDEN,
66    }
67 
68    /** This class represents an option recognized by the main program
69     */
70    static class Option implements JavacOption {
71 
72        /** Option string.
73         */
74        OptionName name;
75 
76        /** Documentation key for arguments.
77         */
78        String argsNameKey;
79 
80        /** Documentation key for description.
81         */
82        String descrKey;
83 
84        /** Suffix option (-foo=bar or -foo:bar)
85         */
86        boolean hasSuffix;
87 
88        Option(OptionName name, String argsNameKey, String descrKey) {
89            this.name = name;
90            this.argsNameKey = argsNameKey;
91            this.descrKey = descrKey;
92            char lastChar = name.optionName.charAt(name.optionName.length()-1);
93            hasSuffix = lastChar == ':' || lastChar == '=';
94        }
95        Option(OptionName name, String descrKey) {
96            this(name, null, descrKey);
97        }
98 
99        public String toString() {
100            return name.optionName;
101        }
102 
103        /** Does this option take a (separate) operand?
104         */
105        public boolean hasArg() {
106            return argsNameKey != null && !hasSuffix;
107        }
108 
109        /** Does argument string match option pattern?
110         *  @param arg        The command line argument string.
111         */
112        public boolean matches(String arg) {
113            return hasSuffix ? arg.startsWith(name.optionName) : arg.equals(name.optionName);
114        }
115 
116        /** Print a line of documentation describing this option, if standard.
117         */
118        void help(PrintWriter out) {
119            String s = "  " + helpSynopsis();
120            out.print(s);
121            for (int j = s.length(); j < 29; j++) out.print(" ");
122            Log.printLines(out, Main.getLocalizedString(descrKey));
123        }
124        String helpSynopsis() {
125            return name +
126                (argsNameKey == null ? "" :
127                 ((hasSuffix ? "" : " ") +
128                  Main.getLocalizedString(argsNameKey)));
129        }
130 
131        /** Print a line of documentation describing this option, if non-standard.
132         */
133        void xhelp(PrintWriter out) {}
134 
135        /** Process the option (with arg). Return true if error detected.
136         */
137        public boolean process(Options options, String option, String arg) {
138            if (options != null)
139                options.put(option, arg);
140            return false;
141        }
142 
143        /** Process the option (without arg). Return true if error detected.
144         */
145        public boolean process(Options options, String option) {
146            if (hasSuffix)
147                return process(options, name.optionName, option.substring(name.optionName.length()));
148            else
149                return process(options, option, option);
150        }
151 
152        public OptionKind getKind() { return OptionKind.NORMAL; }
153 
154        public OptionName getName() { return name; }
155    };
156 
157    /** A nonstandard or extended (-X) option
158     */
159    static class XOption extends Option {
160        XOption(OptionName name, String argsNameKey, String descrKey) {
161            super(name, argsNameKey, descrKey);
162        }
163        XOption(OptionName name, String descrKey) {
164            this(name, null, descrKey);
165        }
166        void help(PrintWriter out) {}
167        void xhelp(PrintWriter out) { super.help(out); }
168        public OptionKind getKind() { return OptionKind.EXTENDED; }
169    };
170 
171    /** A hidden (implementor) option
172     */
173    static class HiddenOption extends Option {
174        HiddenOption(OptionName name) {
175            super(name, null, null);
176        }
177        HiddenOption(OptionName name, String argsNameKey) {
178            super(name, argsNameKey, null);
179        }
180        void help(PrintWriter out) {}
181        void xhelp(PrintWriter out) {}
182        public OptionKind getKind() { return OptionKind.HIDDEN; }
183    };
184 
185}

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