本文整理汇总了Java中org.eclipse.jdt.core.util.IClassFileReader类的典型用法代码示例。如果您正苦于以下问题:Java IClassFileReader类的具体用法?Java IClassFileReader怎么用?Java IClassFileReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IClassFileReader类属于org.eclipse.jdt.core.util包,在下文中一共展示了IClassFileReader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: calculateSerialVersionId
import org.eclipse.jdt.core.util.IClassFileReader; //导入依赖的package包/类
public static Long calculateSerialVersionId(ITypeBinding typeBinding, final IProgressMonitor monitor) throws CoreException, IOException {
try {
IFile classfileResource = getClassfile(typeBinding);
if (classfileResource == null) {
return null;
}
InputStream contents = classfileResource.getContents();
try {
IClassFileReader cfReader = ToolFactory.createDefaultClassFileReader(contents, IClassFileReader.ALL);
if (cfReader != null) {
return calculateSerialVersionId(cfReader);
}
} finally {
contents.close();
}
return null;
} finally {
if (monitor != null) {
monitor.done();
}
}
}
示例2: getClassModifiers
import org.eclipse.jdt.core.util.IClassFileReader; //导入依赖的package包/类
private static int getClassModifiers(IClassFileReader cfReader) {
IInnerClassesAttribute innerClassesAttribute = cfReader.getInnerClassesAttribute();
if (innerClassesAttribute != null) {
IInnerClassesAttributeEntry[] entries = innerClassesAttribute.getInnerClassAttributesEntries();
for (int i = 0; i < entries.length; i++) {
IInnerClassesAttributeEntry entry = entries[i];
char[] innerClassName = entry.getInnerClassName();
if (innerClassName != null) {
if (CharOperation.equals(cfReader.getClassName(), innerClassName)) {
return entry.getAccessFlags();
}
}
}
}
return cfReader.getAccessFlags();
}
示例3: getSortedMethods
import org.eclipse.jdt.core.util.IClassFileReader; //导入依赖的package包/类
private static IMethodInfo[] getSortedMethods(IClassFileReader cfReader) {
IMethodInfo[] allMethods = cfReader.getMethodInfos();
Arrays.sort(allMethods, new Comparator<IMethodInfo>() {
@Override
public int compare(IMethodInfo mi1, IMethodInfo mi2) {
if (mi1.isConstructor() != mi2.isConstructor()) {
return mi1.isConstructor() ? -1 : 1;
} else if (mi1.isConstructor()) {
return 0;
}
int res = CharOperation.compareTo(mi1.getName(), mi2.getName());
if (res != 0) {
return res;
}
return CharOperation.compareTo(mi1.getDescriptor(), mi2.getDescriptor());
}
});
return allMethods;
}
示例4: calculateSerialVersionId
import org.eclipse.jdt.core.util.IClassFileReader; //导入依赖的package包/类
public static Long calculateSerialVersionId(ITypeBinding typeBinding, final IProgressMonitor monitor) throws CoreException, IOException {
try {
IFile classfileResource= getClassfile(typeBinding);
if (classfileResource == null)
return null;
InputStream contents= classfileResource.getContents();
try {
IClassFileReader cfReader= ToolFactory.createDefaultClassFileReader(contents, IClassFileReader.ALL);
if (cfReader != null) {
return calculateSerialVersionId(cfReader);
}
} finally {
contents.close();
}
return null;
} finally {
if (monitor != null)
monitor.done();
}
}
示例5: getClassModifiers
import org.eclipse.jdt.core.util.IClassFileReader; //导入依赖的package包/类
private static int getClassModifiers(IClassFileReader cfReader) {
IInnerClassesAttribute innerClassesAttribute= cfReader.getInnerClassesAttribute();
if (innerClassesAttribute != null) {
IInnerClassesAttributeEntry[] entries = innerClassesAttribute.getInnerClassAttributesEntries();
for (int i= 0; i < entries.length; i++) {
IInnerClassesAttributeEntry entry = entries[i];
char[] innerClassName = entry.getInnerClassName();
if (innerClassName != null) {
if (CharOperation.equals(cfReader.getClassName(), innerClassName)) {
return entry.getAccessFlags();
}
}
}
}
return cfReader.getAccessFlags();
}
示例6: getSortedMethods
import org.eclipse.jdt.core.util.IClassFileReader; //导入依赖的package包/类
private static IMethodInfo[] getSortedMethods(IClassFileReader cfReader) {
IMethodInfo[] allMethods= cfReader.getMethodInfos();
Arrays.sort(allMethods, new Comparator<IMethodInfo>() {
public int compare(IMethodInfo mi1, IMethodInfo mi2) {
if (mi1.isConstructor() != mi2.isConstructor()) {
return mi1.isConstructor() ? -1 : 1;
} else if (mi1.isConstructor()) {
return 0;
}
int res= CharOperation.compareTo(mi1.getName(), mi2.getName());
if (res != 0) {
return res;
}
return CharOperation.compareTo(mi1.getDescriptor(), mi2.getDescriptor());
}
});
return allMethods;
}
示例7: getSortedInterfacesNames
import org.eclipse.jdt.core.util.IClassFileReader; //导入依赖的package包/类
private static char[][] getSortedInterfacesNames(IClassFileReader cfReader) {
char[][] interfaceNames = cfReader.getInterfaceNames();
Arrays.sort(interfaceNames, new Comparator<char[]>() {
@Override
public int compare(char[] o1, char[] o2) {
return CharOperation.compareTo(o1, o2);
}
});
return interfaceNames;
}
示例8: getSortedFields
import org.eclipse.jdt.core.util.IClassFileReader; //导入依赖的package包/类
private static IFieldInfo[] getSortedFields(IClassFileReader cfReader) {
IFieldInfo[] allFields = cfReader.getFieldInfos();
Arrays.sort(allFields, new Comparator<IFieldInfo>() {
@Override
public int compare(IFieldInfo o1, IFieldInfo o2) {
return CharOperation.compareTo(o1.getName(), o2.getName());
}
});
return allFields;
}
示例9: hasStaticClassInitializer
import org.eclipse.jdt.core.util.IClassFileReader; //导入依赖的package包/类
private static boolean hasStaticClassInitializer(IClassFileReader cfReader) {
IMethodInfo[] methodInfos = cfReader.getMethodInfos();
for (int i = 0; i < methodInfos.length; i++) {
if (methodInfos[i].isClinit()) {
return true;
}
}
return false;
}
示例10: getAttribute
import org.eclipse.jdt.core.util.IClassFileReader; //导入依赖的package包/类
public static IClassFileAttribute getAttribute(
IClassFileReader classFileReader, char[] attributeName) {
IClassFileAttribute[] attributes = classFileReader.getAttributes();
for (int i = 0, max = attributes.length; i < max; i++) {
if (CharOperation.equals(attributes[i].getAttributeName(), attributeName)) {
return attributes[i];
}
}
return null;
}
示例11: getSortedInterfacesNames
import org.eclipse.jdt.core.util.IClassFileReader; //导入依赖的package包/类
private static char[][] getSortedInterfacesNames(IClassFileReader cfReader) {
char[][] interfaceNames= cfReader.getInterfaceNames();
Arrays.sort(interfaceNames, new Comparator<char[]>() {
public int compare(char[] o1, char[] o2) {
return CharOperation.compareTo(o1, o2);
}
});
return interfaceNames;
}
示例12: getSortedFields
import org.eclipse.jdt.core.util.IClassFileReader; //导入依赖的package包/类
private static IFieldInfo[] getSortedFields(IClassFileReader cfReader) {
IFieldInfo[] allFields= cfReader.getFieldInfos();
Arrays.sort(allFields, new Comparator<IFieldInfo>() {
public int compare(IFieldInfo o1, IFieldInfo o2) {
return CharOperation.compareTo(o1.getName(), o2.getName());
}
});
return allFields;
}
示例13: hasStaticClassInitializer
import org.eclipse.jdt.core.util.IClassFileReader; //导入依赖的package包/类
private static boolean hasStaticClassInitializer(IClassFileReader cfReader) {
IMethodInfo[] methodInfos= cfReader.getMethodInfos();
for (int i= 0; i < methodInfos.length; i++) {
if (methodInfos[i].isClinit()) {
return true;
}
}
return false;
}
示例14: checkClassFile
import org.eclipse.jdt.core.util.IClassFileReader; //导入依赖的package包/类
private boolean checkClassFile(IClassFileReader classFileReader) {
IMethodInfo[] methodInfos = classFileReader.getMethodInfos();
for (int i = 0, max = methodInfos.length; i < max; i++) {
ICodeAttribute codeAttribute = methodInfos[i].getCodeAttribute();
if (codeAttribute != null && codeAttribute.getLineNumberAttribute() != null) {
return true;
}
}
return false;
}
示例15: openBuffer
import org.eclipse.jdt.core.util.IClassFileReader; //导入依赖的package包/类
/**
* @see Openable#openBuffer(IProgressMonitor, Object)
*/
protected IBuffer openBuffer(IProgressMonitor pm, Object info) throws JavaModelException {
// create buffer
IBuffer buffer = BufferManager.createBuffer(this);
// set the buffer source
IBuffer classFileBuffer = this.classFile.getBuffer();
if (classFileBuffer != null) {
buffer.setContents(classFileBuffer.getCharacters());
} else {
// Disassemble
IClassFileReader reader = ToolFactory.createDefaultClassFileReader(this.classFile, IClassFileReader.ALL);
Disassembler disassembler = new Disassembler();
String contents = disassembler.disassemble(reader, Util.getLineSeparator("", getJavaProject()), ClassFileBytesDisassembler.WORKING_COPY); //$NON-NLS-1$
buffer.setContents(contents);
}
// add buffer to buffer cache
BufferManager bufManager = getBufferManager();
bufManager.addBuffer(buffer);
// listen to buffer changes
buffer.addBufferChangedListener(this);
return buffer;
}