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