/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package net.sourceforge.phpdt.core; import net.sourceforge.phpdt.internal.compiler.env.IConstants; /** * Utility class for decoding modifier flags in Java elements. *
* This class provides static methods only; it is not intended to be * instantiated or subclassed by clients. *
*
* Note that the numeric values of these flags match the ones for class files as
* described in the Java Virtual Machine Specification. The AST class
* Modifier
provides the same functionality as this class, only
* in the net.sourceforge.phpdt.core.dom
package.
*
abstract
* modifier.
*
* @param flags
* the flags
* @return true
if the abstract
modifier is
* included
*/
public static boolean isAbstract(int flags) {
return (flags & AccAbstract) != 0;
}
/**
* Returns whether the given integer includes the indication that the
* element is deprecated (@deprecated
tag in Javadoc comment).
*
* @param flags
* the flags
* @return true
if the element is marked as deprecated
*/
public static boolean isDeprecated(int flags) {
return (flags & AccDeprecated) != 0;
}
/**
* Returns whether the given integer includes the final
* modifier.
*
* @param flags
* the flags
* @return true
if the final
modifier is
* included
*/
public static boolean isFinal(int flags) {
return (flags & AccFinal) != 0;
}
/**
* Returns whether the given integer includes the interface
* modifier.
*
* @param flags
* the flags
* @return true
if the interface
modifier is
* included
* @since 2.0
*/
public static boolean isInterface(int flags) {
return (flags & AccInterface) != 0;
}
/**
* Returns whether the given integer includes the native
* modifier.
*
* @param flags
* the flags
* @return true
if the native
modifier is
* included
*/
// public static boolean isNative(int flags) {
// return (flags & AccNative) != 0;
// }
/**
* Returns whether the given integer includes the private
* modifier.
*
* @param flags
* the flags
* @return true
if the private
modifier is
* included
*/
public static boolean isPrivate(int flags) {
return (flags & AccPrivate) != 0;
}
/**
* Returns whether the given integer includes the protected
* modifier.
*
* @param flags
* the flags
* @return true
if the protected
modifier is
* included
*/
public static boolean isProtected(int flags) {
return (flags & AccProtected) != 0;
}
/**
* Returns whether the given integer includes the public
* modifier.
*
* @param flags
* the flags
* @return true
if the public
modifier is
* included
*/
public static boolean isPublic(int flags) {
return (flags & AccPublic) != 0;
}
/**
* Returns whether the given integer includes the static
* modifier.
*
* @param flags
* the flags
* @return true
if the static
modifier is
* included
*/
public static boolean isStatic(int flags) {
return (flags & AccStatic) != 0;
}
/**
* Returns whether the given integer includes the strictfp
* modifier.
*
* @param flags
* the flags
* @return true
if the strictfp
modifier is
* included
*/
// public static boolean isStrictfp(int flags) {
// return (flags & AccStrictfp) != 0;
// }
/**
* Returns whether the given integer includes the synchronized
* modifier.
*
* @param flags
* the flags
* @return true
if the synchronized
modifier
* is included
*/
// public static boolean isSynchronized(int flags) {
// return (flags & AccSynchronized) != 0;
// }
/**
* Returns whether the given integer includes the indication that the
* element is synthetic.
*
* @param flags
* the flags
* @return true
if the element is marked synthetic
*/
// public static boolean isSynthetic(int flags) {
// return (flags & AccSynthetic) != 0;
// }
/**
* Returns whether the given integer includes the transient
* modifier.
*
* @param flags
* the flags
* @return true
if the transient
modifier is
* included
*/
// public static boolean isTransient(int flags) {
// return (flags & AccTransient) != 0;
// }
/**
* Returns whether the given integer includes the volatile
* modifier.
*
* @param flags
* the flags
* @return true
if the volatile
modifier is
* included
*/
// public static boolean isVolatile(int flags) {
// return (flags & AccVolatile) != 0;
// }
/**
* Returns a standard string describing the given modifier flags. Only
* modifier flags are included in the output; the deprecated and synthetic
* flags are ignored if set.
* * The flags are output in the following order: * *
** * This is a compromise between the orders specified in sections 8.1.1, * 8.3.1, 8.4.3, 8.8.3, 9.1.1, and 9.3 of The Java Language * Specification, Second Edition * (JLS2). * ** public *
* protected *
* private *
** static *
** abstract *
* final *
* native *
* synchronized *
* transient *
* volatile *
* strictfp *
*
* Examples results: * *
** * * * @param flags * the flags * @return the standard string representation of the given flags */ public static String toString(int flags) { StringBuffer sb = new StringBuffer(); if (isPublic(flags)) sb.append("public "); //$NON-NLS-1$ if (isProtected(flags)) sb.append("protected "); //$NON-NLS-1$ if (isPrivate(flags)) sb.append("private "); //$NON-NLS-1$ if (isStatic(flags)) sb.append("static "); //$NON-NLS-1$ // if (isAbstract(flags)) // sb.append("abstract "); //$NON-NLS-1$ if (isFinal(flags)) sb.append("final "); //$NON-NLS-1$ // if (isNative(flags)) // sb.append("native "); //$NON-NLS-1$ // if (isSynchronized(flags)) // sb.append("synchronized "); //$NON-NLS-1$ // if (isTransient(flags)) // sb.append("transient "); //$NON-NLS-1$ // if (isVolatile(flags)) // sb.append("volatile "); //$NON-NLS-1$ // if (isStrictfp(flags)) // sb.append("strictfp "); //$NON-NLS-1$ int len = sb.length(); if (len == 0) return ""; //$NON-NLS-1$ sb.setLength(len - 1); return sb.toString(); } }* "public static final" *
** "private native" *
*