Path: blob/master/src/jdk.jdeps/share/classes/com/sun/tools/javap/Options.java
58461 views
/*1* Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package com.sun.tools.javap;2627import java.util.EnumSet;28import java.util.HashSet;29import java.util.Set;3031import com.sun.tools.classfile.AccessFlags;3233/*34* Provides access to javap's options, set via the command line35* or JSR 199 API.36* <p><b>This is NOT part of any supported API.37* If you write code that depends on this, you do so at your own risk.38* This code and its internal interfaces are subject to change or39* deletion without notice.</b>40*/41public class Options {42public static Options instance(Context context) {43Options instance = context.get(Options.class);44if (instance == null)45instance = new Options(context);46return instance;47}4849protected Options(Context context) {50context.put(Options.class, this);51}5253/**54* Checks access of class, field or method.55*/56public boolean checkAccess(AccessFlags flags){5758boolean isPublic = flags.is(AccessFlags.ACC_PUBLIC);59boolean isProtected = flags.is(AccessFlags.ACC_PROTECTED);60boolean isPrivate = flags.is(AccessFlags.ACC_PRIVATE);61boolean isPackage = !(isPublic || isProtected || isPrivate);6263if ((showAccess == AccessFlags.ACC_PUBLIC) && (isProtected || isPrivate || isPackage))64return false;65else if ((showAccess == AccessFlags.ACC_PROTECTED) && (isPrivate || isPackage))66return false;67else if ((showAccess == 0) && (isPrivate))68return false;69else70return true;71}7273public boolean help;74public boolean verbose;75public boolean version;76public boolean fullVersion;77public boolean showFlags;78public boolean showLineAndLocalVariableTables;79public int showAccess;80public Set<String> accessOptions = new HashSet<>();81public Set<InstructionDetailWriter.Kind> details = EnumSet.noneOf(InstructionDetailWriter.Kind.class);82public boolean showDisassembled;83public boolean showDescriptors;84public boolean showAllAttrs;85public boolean showConstants;86public boolean sysInfo;87public boolean showInnerClasses;88public int indentWidth = 2; // #spaces per indentWidth level; must be > 089public int tabColumn = 40; // column number for comments; must be > 090public String moduleName;91}929394