org.eclipse.jdt.core.Flags.toString()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(9.4k)|赞(0)|评价(0)|浏览(98)

本文整理了Java中org.eclipse.jdt.core.Flags.toString()方法的一些代码示例,展示了Flags.toString()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Flags.toString()方法的具体详情如下:
包路径:org.eclipse.jdt.core.Flags
类名称:Flags
方法名:toString

Flags.toString介绍

[英]Returns a standard string describing the given modifier flags. Only modifier flags are included in the output; deprecated, synthetic, bridge, etc. flags are ignored.

The flags are output in the following order:

public protected private 
abstract default static final synchronized native strictfp transient volatile

This order is consistent with the recommendations in JLS8 ("*Modifier:" rules in chapters 8 and 9).

Note that the flags of a method can include the AccVarargs flag that has no standard description. Since the AccVarargs flag has the same value as the AccTransient flag (valid for fields only), attempting to get the description of method modifiers with the AccVarargs flag set would result in an unexpected description. Clients should ensure that the AccVarargs is not included in the flags of a method as follows:

IMethod method = ... 
int flags = method.getFlags() & ~Flags.AccVarargs; 
return Flags.toString(flags);

Examples results:

"public static final" 
"private native"

[中]返回描述给定修改器标志的标准字符串。输出中只包含修改器标志;弃用、合成、桥接等标志被忽略。
标志按以下顺序输出:

public protected private 
abstract default static final synchronized native strictfp transient volatile

该顺序与JLS8中的建议一致(“第8章和第9章中的规则”)。
请注意,方法的标志可以包括没有标准描述的AccVarargs标志。由于AccVarargs标志与AccTransient标志具有相同的值(仅对字段有效),因此尝试获取设置了AccVarargs标志的方法修饰符的说明将导致意外的说明。客户端应确保AccVarargs不包含在方法的标志中,如下所示:

IMethod method = ... 
int flags = method.getFlags() & ~Flags.AccVarargs; 
return Flags.toString(flags);

示例结果:

"public static final" 
"private native"

代码示例

代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.core.manipulation

@Override
  public String toString() {
    StringBuffer buf= new StringBuffer("change signature to "); //$NON-NLS-1$
    buf.append("\n\tvisibility: ").append(Flags.toString(fNewVisibility)); //$NON-NLS-1$
    buf.append("\n\treturn type sig: ").append(fNewReturnType); //$NON-NLS-1$
    buf.append("\n\tnew name: ").append(fNewName); //$NON-NLS-1$
    buf.append("\n\tkeep original: ").append(fKeepOriginal); //$NON-NLS-1$
    for (int i= 0; i < fNewParameters.length; i++) {
      buf.append("\n\tparameter ").append(i).append(": ").append(fNewParameters[i]); //$NON-NLS-1$ //$NON-NLS-2$
    }
    for (int i= 0; i < fThrownExceptions.length; i++) {
      buf.append("\n\texception ").append(i).append(": ").append(fThrownExceptions[i]); //$NON-NLS-1$ //$NON-NLS-2$
    }
    return buf.toString();
  }
}

代码示例来源:origin: com.google.code.maven-play-plugin.org.eclipse.jdt/org.eclipse.jdt.core

protected char[] generateFlags() {
  char[] flags= Flags.toString(getFlags() & ~Flags.AccVarargs).toCharArray();
  if (flags.length == 0) {
    return flags;
  } else {
    return CharOperation.concat(flags, new char[] {' '});
  }
}/**
 * @see IDOMNode#getJavaElement

代码示例来源:origin: org.eclipse.tycho/org.eclipse.jdt.core

protected char[] generateFlags() {
  char[] flags= Flags.toString(getFlags() & ~Flags.AccVarargs).toCharArray();
  if (flags.length == 0) {
    return flags;
  } else {
    return CharOperation.concat(flags, new char[] {' '});
  }
}/**
 * @see IDOMNode#getJavaElement

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.core

protected char[] generateFlags() {
  char[] flags= Flags.toString(getFlags() & ~Flags.AccVarargs).toCharArray();
  if (flags.length == 0) {
    return flags;
  } else {
    return CharOperation.concat(flags, new char[] {' '});
  }
}/**
 * @see IDOMNode#getJavaElement

代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.core

@Override
protected char[] generateFlags() {
  char[] flags= Flags.toString(getFlags() & ~Flags.AccVarargs).toCharArray();
  if (flags.length == 0) {
    return flags;
  } else {
    return CharOperation.concat(flags, new char[] {' '});
  }
}/**
 * @see IDOMNode#getJavaElement

代码示例来源:origin: org.jibx.config.3rdparty.org.eclipse/org.eclipse.jdt.core

protected char[] generateFlags() {
  char[] flags= Flags.toString(getFlags() & ~Flags.AccVarargs).toCharArray();
  if (flags.length == 0) {
    return flags;
  } else {
    return CharOperation.concat(flags, new char[] {' '});
  }
}/**
 * @see IDOMNode#getJavaElement

代码示例来源:origin: trylimits/Eclipse-Postfix-Code-Completion

protected char[] generateFlags() {
  char[] flags= Flags.toString(getFlags() & ~Flags.AccVarargs).toCharArray();
  if (flags.length == 0) {
    return flags;
  } else {
    return CharOperation.concat(flags, new char[] {' '});
  }
}/**
 * @see IDOMNode#getJavaElement

代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.core

/**
 * Returns a <code>String</code> describing the modifiers for this member,
 * ending with whitespace (if not empty). This value serves as a replacement
 * value for the member's modifier range when the modifiers have been altered
 * from their original contents.
 */
protected char[] generateFlags() {
  char[] flags= Flags.toString(getFlags()).toCharArray();
  if (flags.length == 0) {
    return flags;
  } else {
    return CharOperation.concat(flags, new char[] {' '});
  }
}
/**

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.core

/**
 * Returns a <code>String</code> describing the modifiers for this member,
 * ending with whitespace (if not empty). This value serves as a replacement
 * value for the member's modifier range when the modifiers have been altered
 * from their original contents.
 */
protected char[] generateFlags() {
  char[] flags= Flags.toString(getFlags()).toCharArray();
  if (flags.length == 0) {
    return flags;
  } else {
    return CharOperation.concat(flags, new char[] {' '});
  }
}
/**

代码示例来源:origin: org.jibx.config.3rdparty.org.eclipse/org.eclipse.jdt.core

/**
 * Returns a <code>String</code> describing the modifiers for this member,
 * ending with whitespace (if not empty). This value serves as a replacement
 * value for the member's modifier range when the modifiers have been altered
 * from their original contents.
 */
protected char[] generateFlags() {
  char[] flags= Flags.toString(getFlags()).toCharArray();
  if (flags.length == 0) {
    return flags;
  } else {
    return CharOperation.concat(flags, new char[] {' '});
  }
}
/**

代码示例来源:origin: org.eclipse.tycho/org.eclipse.jdt.core

/**
 * Returns a <code>String</code> describing the modifiers for this member,
 * ending with whitespace (if not empty). This value serves as a replacement
 * value for the member's modifier range when the modifiers have been altered
 * from their original contents.
 */
protected char[] generateFlags() {
  char[] flags= Flags.toString(getFlags()).toCharArray();
  if (flags.length == 0) {
    return flags;
  } else {
    return CharOperation.concat(flags, new char[] {' '});
  }
}
/**

代码示例来源:origin: com.google.code.maven-play-plugin.org.eclipse.jdt/org.eclipse.jdt.core

/**
 * Returns a <code>String</code> describing the modifiers for this member,
 * ending with whitespace (if not empty). This value serves as a replacement
 * value for the member's modifier range when the modifiers have been altered
 * from their original contents.
 */
protected char[] generateFlags() {
  char[] flags= Flags.toString(getFlags()).toCharArray();
  if (flags.length == 0) {
    return flags;
  } else {
    return CharOperation.concat(flags, new char[] {' '});
  }
}
/**

代码示例来源:origin: trylimits/Eclipse-Postfix-Code-Completion

/**
 * Returns a <code>String</code> describing the modifiers for this member,
 * ending with whitespace (if not empty). This value serves as a replacement
 * value for the member's modifier range when the modifiers have been altered
 * from their original contents.
 */
protected char[] generateFlags() {
  char[] flags= Flags.toString(getFlags()).toCharArray();
  if (flags.length == 0) {
    return flags;
  } else {
    return CharOperation.concat(flags, new char[] {' '});
  }
}
/**

代码示例来源:origin: org.eclipse/org.eclipse.ajdt.ui

buf.append(Flags.toString(modifiers));
if (modifiers != 0) {
  buf.append(' ');

代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.ui

buf.append(Flags.toString(modifiers));
if (modifiers != 0) {
  buf.append(' ');

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.ui

buf.append(Flags.toString(modifiers));
if (modifiers != 0) {
  buf.append(' ');

代码示例来源:origin: org.eclipse/org.eclipse.jdt.ui

buf.append(Flags.toString(modifiers));
if (modifiers != 0) {
  buf.append(' ');

代码示例来源:origin: org.eclipse/org.eclipse.jdt.ui

protected void appendFlags(final IMember member) throws JavaModelException {
  int flags= member.getFlags();
  final int kind= member.getElementType();
  if (kind == IJavaElement.TYPE) {
    flags&= ~Flags.AccSuper;
    final IType type= (IType) member;
    if (!type.isMember())
      flags&= ~Flags.AccPrivate;
  }
  if (Flags.isEnum(flags))
    flags&= ~Flags.AccFinal;
  if (kind == IJavaElement.METHOD) {
    flags&= ~Flags.AccVarargs;
    flags&= ~Flags.AccBridge;
  }
  if (flags != 0)
    fBuffer.append(Flags.toString(flags));
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.ui

protected void appendFlags(final IMember member) throws JavaModelException {
  if (member instanceof IAnnotatable)
    for (IAnnotation annotation : ((IAnnotatable) member).getAnnotations()) {
      appendAnnotation(annotation);
    }
  
  int flags= member.getFlags();
  final int kind= member.getElementType();
  if (kind == IJavaElement.TYPE) {
    flags&= ~Flags.AccSuper;
    final IType type= (IType) member;
    if (!type.isMember())
      flags&= ~Flags.AccPrivate;
    if (Flags.isEnum(flags))
      flags&= ~Flags.AccAbstract;
  }
  if (Flags.isEnum(flags))
    flags&= ~Flags.AccFinal;
  if (kind == IJavaElement.METHOD) {
    flags&= ~Flags.AccVarargs;
    flags&= ~Flags.AccBridge;
  }
  if (flags != 0)
    fBuffer.append(Flags.toString(flags));
}

代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.ui

protected void appendFlags(final IMember member) throws JavaModelException {
  if (member instanceof IAnnotatable)
    for (IAnnotation annotation : ((IAnnotatable) member).getAnnotations()) {
      appendAnnotation(annotation);
    }
  
  int flags= member.getFlags();
  final int kind= member.getElementType();
  if (kind == IJavaElement.TYPE) {
    flags&= ~Flags.AccSuper;
    final IType type= (IType) member;
    if (!type.isMember())
      flags&= ~Flags.AccPrivate;
    if (Flags.isEnum(flags))
      flags&= ~Flags.AccAbstract;
  }
  if (Flags.isEnum(flags))
    flags&= ~Flags.AccFinal;
  if (kind == IJavaElement.METHOD) {
    flags&= ~Flags.AccVarargs;
    flags&= ~Flags.AccBridge;
  }
  if (flags != 0)
    fBuffer.append(Flags.toString(flags));
}

相关文章