Options.java revision 86
0N/A/*
1879N/A * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation. Sun designates this
0N/A * particular file as subject to the "Classpath" exception as provided
0N/A * by Sun in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
1472N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1472N/A *
1472N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
0N/A * CA 95054 USA or visit www.sun.com if you need additional information or
0N/A * have any questions.
0N/A */
1879N/A
1879N/Apackage com.sun.tools.javap;
1879N/A
1879N/Aimport java.util.HashSet;
0N/Aimport java.util.Set;
0N/Aimport com.sun.tools.classfile.AccessFlags;
0N/A
0N/A/*
0N/A * Provides access to javap's options, set via the command line
0N/A * or JSR 199 API.
0N/A * <p><b>This is NOT part of any API supported by Sun Microsystems. If
0N/A * you write code that depends on this, you do so at your own risk.
0N/A * This code and its internal interfaces are subject to change or
0N/A * deletion without notice.</b>
0N/A */
0N/Apublic class Options {
0N/A public static Options instance(Context context) {
0N/A Options instance = context.get(Options.class);
0N/A if (instance == null)
0N/A instance = new Options(context);
0N/A return instance;
0N/A }
0N/A
0N/A protected Options(Context context) {
0N/A context.put(Options.class, this);
0N/A }
0N/A
0N/A /**
0N/A * Checks access of class, field or method.
0N/A */
0N/A public boolean checkAccess(AccessFlags flags){
0N/A
0N/A boolean isPublic = flags.is(AccessFlags.ACC_PUBLIC);
0N/A boolean isProtected = flags.is(AccessFlags.ACC_PROTECTED);
0N/A boolean isPrivate = flags.is(AccessFlags.ACC_PRIVATE);
0N/A boolean isPackage = !(isPublic || isProtected || isPrivate);
0N/A
0N/A if ((showAccess == AccessFlags.ACC_PUBLIC) && (isProtected || isPrivate || isPackage))
0N/A return false;
0N/A else if ((showAccess == AccessFlags.ACC_PROTECTED) && (isPrivate || isPackage))
0N/A return false;
0N/A else if ((showAccess == 0) && (isPrivate))
0N/A return false;
0N/A else
0N/A return true;
0N/A }
0N/A
0N/A public boolean help;
0N/A public boolean verbose;
0N/A public boolean version;
0N/A public boolean fullVersion;
0N/A public boolean showFlags;
0N/A public boolean showLineAndLocalVariableTables;
0N/A public int showAccess;
0N/A public Set<String> accessOptions = new HashSet<String>();
0N/A public boolean showDisassembled;
0N/A public boolean showInternalSignatures;
0N/A public boolean showAllAttrs;
0N/A public boolean showConstants;
0N/A
0N/A public boolean compat; // bug-for-bug compatibility mode with old javap
0N/A public boolean jsr277;
0N/A public boolean ignoreSymbolFile; // file manager should ignore ct.sym
0N/A}
0N/A