本文整理汇总了Java中java.io.DataInputStream.readUnsignedShort方法的典型用法代码示例。如果您正苦于以下问题:Java DataInputStream.readUnsignedShort方法的具体用法?Java DataInputStream.readUnsignedShort怎么用?Java DataInputStream.readUnsignedShort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.io.DataInputStream
的用法示例。
在下文中一共展示了DataInputStream.readUnsignedShort方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: read
import java.io.DataInputStream; //导入方法依赖的package包/类
public void read(DataInputStream paramDataInputStream, ConstantPool paramConstantPool) throws IOException {
this.iInnerClassInfoIndex = paramDataInputStream.readUnsignedShort();
this.iOuterClassInfoIndex = paramDataInputStream.readUnsignedShort();
this.iInnerNameIndex = paramDataInputStream.readUnsignedShort();
this.accFlags.read(paramDataInputStream);
this.cpInnerClass = (this.cpOuterClass = this.cpInnerName = null);
if (0 != this.iInnerClassInfoIndex) {
this.cpInnerClass = paramConstantPool.getPoolInfo(this.iInnerClassInfoIndex);
}
if (0 != this.iOuterClassInfoIndex) {
this.cpOuterClass = paramConstantPool.getPoolInfo(this.iOuterClassInfoIndex);
}
if (0 != this.iInnerNameIndex) {
this.cpInnerName = paramConstantPool.getPoolInfo(this.iInnerNameIndex);
}
}
示例2: loadEnumValue
import java.io.DataInputStream; //导入方法依赖的package包/类
private static ElementValue loadEnumValue(DataInputStream in,
ConstantPool pool)
throws IOException {
int type = in.readUnsignedShort();
CPEntry cpe = pool.get(type);
if (cpe.getTag() == ConstantPool.CONSTANT_FieldRef) {
// workaround for 1.5 beta 1 and earlier builds
CPFieldInfo fe = (CPFieldInfo)cpe;
String enumType = fe.getClassName().getInternalName();
String enumName = fe.getFieldName();
return new EnumElementValue(enumType, enumName);
} else {
int name = in.readUnsignedShort();
return new EnumElementValue(pool, type, name);
}
}
示例3: getLineNumberTable
import java.io.DataInputStream; //导入方法依赖的package包/类
@Override
public LineNumberTable getLineNumberTable() {
if (lineNumberTableBytes == null) {
return null;
}
final int lineNumberTableLength = lineNumberTableBytes.length / LINE_NUMBER_TABLE_ENTRY_SIZE_IN_BYTES;
DataInputStream stream = new DataInputStream(new ByteArrayInputStream(lineNumberTableBytes));
int[] bci = new int[lineNumberTableLength];
int[] line = new int[lineNumberTableLength];
for (int i = 0; i < lineNumberTableLength; i++) {
try {
bci[i] = stream.readUnsignedShort();
line[i] = stream.readUnsignedShort();
} catch (IOException e) {
throw new GraalError(e);
}
}
return new LineNumberTable(line, bci);
}
示例4: decodeChunk
import java.io.DataInputStream; //导入方法依赖的package包/类
public static Chunk decodeChunk(DataInputStream in) throws IOException {
final int type = in.readUnsignedShort(); // marker type
if ((type & 0xFF00) != 0xFF00) {
throw new IOException("initial byte of chunk must be FF");
}
byte[] data;
if (type == TEM || (RST0 <= type && type <= EOI)) {
// These chunks have no data
data = new byte[0];
}
else {
final int length = in.readUnsignedShort();
data = new byte[length-2]; // length is inclusive of its own 2 bytes
in.readFully(data);
}
// NB: This will blow up after reaching an SOS, due to it being follwed
// by raw data instead of another chunk. If we want to find the next
// chunk after an SOS, we have to scan for FF xx, where xx != 00.
return new Chunk(type, data);
}
示例5: read
import java.io.DataInputStream; //导入方法依赖的package包/类
public void read(DataInputStream paramDataInputStream) throws IOException {
this.iTag = paramDataInputStream.readByte();
switch (this.iTag) {
case 7:
this.iNameIndex = paramDataInputStream.readUnsignedShort();
break;
case 8:
this.iStringIndex = paramDataInputStream.readUnsignedShort();
break;
case 9:
case 10:
case 11:
this.iClassIndex = paramDataInputStream.readUnsignedShort();
this.iNameAndTypeIndex = paramDataInputStream.readUnsignedShort();
break;
case 3:
this.iIntValue = paramDataInputStream.readInt();
break;
case 4:
this.fFloatVal = paramDataInputStream.readFloat();
break;
case 12:
this.iNameIndex = paramDataInputStream.readUnsignedShort();
this.iDescriptorIndex = paramDataInputStream.readUnsignedShort();
break;
case 5:
this.lLongVal = paramDataInputStream.readLong();
break;
case 6:
this.dDoubleVal = paramDataInputStream.readDouble();
break;
case 1:
this.sUTFStr = paramDataInputStream.readUTF();
break;
case 2:
default:
System.out.println("Unknown constant pool type: " + this.iTag);
}
}
示例6: createNode
import java.io.DataInputStream; //导入方法依赖的package包/类
/**
* Creates a new node with unresolved references.
*
* @param stream
* A just opended byte stream of a class file. If this method finishes succefully the internal pointer of
* the stream will point onto the superclass index.
* @param source
* Optional source of the class file. Can be <code>null</code>.
* @param size
* Number of bytes of the class file.
* @param reflectionPattern
* Pattern used to check whether a {@link StringConstant} refer to a class. Can be <tt>null</tt>.
* @return a node with unresolved link of all classes used by the analysed class.
*/
private static UnresolvedNode createNode(InputStream stream, String source, int size,
StringPattern reflectionPattern) throws IOException {
// Reads constant pool, accessFlags, and class name
final DataInputStream dataStream = new DataInputStream(stream);
final Constant[] pool = Constant.extractConstantPool(dataStream);
final int accessFlags = dataStream.readUnsignedShort();
final String name = ((ClassConstant) pool[dataStream.readUnsignedShort()]).getName();
ClassAttributes attributes = null;
if ((accessFlags & ACC_INTERFACE) != 0) {
attributes = ClassAttributes.createInterface(name, source, size);
} else {
if ((accessFlags & ACC_ABSTRACT) != 0) {
attributes = ClassAttributes.createAbstractClass(name, source, size);
} else {
attributes = ClassAttributes.createClass(name, source, size);
}
}
// Creates a new node with unresolved references
final UnresolvedNode node = new UnresolvedNode();
node.setAttributes(attributes);
for (int i = 0; i < pool.length; i++) {
final Constant constant = pool[i];
if (constant instanceof ClassConstant) {
final ClassConstant cc = (ClassConstant) constant;
if (!cc.getName().startsWith("[") && !cc.getName().equals(name)) {
node.addLinkTo(cc.getName());
}
} else if (constant instanceof UTF8Constant) {
parseUTF8Constant((UTF8Constant) constant, node, name);
} else if (reflectionPattern != null && constant instanceof StringConstant) {
final String str = ((StringConstant) constant).getString();
if (ClassNameExtractor.isValid(str) && reflectionPattern.matches(str)) {
node.addLinkTo(str);
}
}
}
return node;
}
示例7: read
import java.io.DataInputStream; //导入方法依赖的package包/类
public void read(DataInputStream dis, ConstantPool constPool) throws IOException {
int iIndex;
iInterfacesCount = dis.readUnsignedShort();
vectInterfaces = new Vector(iInterfacesCount);
for (iIndex = 0; iIndex < iInterfacesCount; iIndex++) {
int iInterfaceIndex = dis.readUnsignedShort();
ConstantPoolInfo cpInfo = constPool.getPoolInfo(iInterfaceIndex);
vectInterfaces.addElement(cpInfo);
cpInfo.addRef();
}
}
示例8: load
import java.io.DataInputStream; //导入方法依赖的package包/类
static AnnotationComponent load(DataInputStream in, ConstantPool pool,
boolean runtimeVisible)
throws IOException {
int iName = in.readUnsignedShort();
String name = ((CPName)pool.get(iName)).getName();
ElementValue value = ElementValue.load(in, pool, runtimeVisible);
return new AnnotationComponent(name, value);
}
示例9: read
import java.io.DataInputStream; //导入方法依赖的package包/类
public void read(DataInputStream paramDataInputStream, ConstantPool paramConstantPool) throws IOException {
this.iAttributesCount = paramDataInputStream.readUnsignedShort();
this.attribVect = new Vector(this.iAttributesCount);
for (int i = 0; i < this.iAttributesCount; i++) {
Attribute localAttribute = Attribute.readAndCreate(paramDataInputStream, paramConstantPool);
this.attribVect.addElement(localAttribute);
}
}
示例10: readAttributs
import java.io.DataInputStream; //导入方法依赖的package包/类
private AttributeInfo[] readAttributs( @Nonnull DataInputStream input ) throws IOException {
AttributeInfo[] attrs = new AttributeInfo[input.readUnsignedShort()];
for( int i = 0; i < attrs.length; i++ ) {
attrs[i] = new AttributeInfo( input, constantPool );
}
return attrs;
}
示例11: loadExceptionTable
import java.io.DataInputStream; //导入方法依赖的package包/类
static ExceptionTableEntry[] loadExceptionTable(DataInputStream in, ConstantPool pool)
throws IOException {
int n = in.readUnsignedShort();
ExceptionTableEntry[] exceptions = new ExceptionTableEntry[n];
for (int i = 0; i < n; i++)
exceptions[i] = new ExceptionTableEntry(in, pool);
return exceptions;
}
示例12: parseResponse
import java.io.DataInputStream; //导入方法依赖的package包/类
public static Record[] parseResponse(byte[] response, int id, String domain) throws
IOException {
boolean recursionAvailable = true;
DataInputStream dis = new DataInputStream(new ByteArrayInputStream(response));
int answerId = dis.readUnsignedShort();
if (answerId != id) {
throw new DnsException(domain, "the answer id " + answerId + " is not match " + id);
}
int header = dis.readUnsignedShort();
boolean recursionDesired;
if (((header >> 8) & 1) == 1) {
recursionDesired = true;
} else {
recursionDesired = false;
}
if (((header >> 7) & 1) != 1) {
recursionAvailable = false;
}
if (recursionAvailable && recursionDesired) {
int questionCount = dis.readUnsignedShort();
int answerCount = dis.readUnsignedShort();
dis.readUnsignedShort();
dis.readUnsignedShort();
readQuestions(dis, response, questionCount);
return readAnswers(dis, response, answerCount);
}
throw new DnsException(domain, "the dns server cant support recursion ");
}
示例13: getExceptionHandlers
import java.io.DataInputStream; //导入方法依赖的package包/类
@Override
public ExceptionHandler[] getExceptionHandlers() {
if (exceptionTableBytes == null) {
return new ExceptionHandler[0];
}
final int exceptionTableLength = exceptionTableBytes.length / EXCEPTION_HANDLER_TABLE_SIZE_IN_BYTES;
ExceptionHandler[] handlers = new ExceptionHandler[exceptionTableLength];
DataInputStream stream = new DataInputStream(new ByteArrayInputStream(exceptionTableBytes));
for (int i = 0; i < exceptionTableLength; i++) {
try {
final int startPc = stream.readUnsignedShort();
final int endPc = stream.readUnsignedShort();
final int handlerPc = stream.readUnsignedShort();
int catchTypeIndex = stream.readUnsignedShort();
JavaType catchType;
if (catchTypeIndex == 0) {
catchType = null;
} else {
final int opcode = -1; // opcode is not used
catchType = constantPool.lookupType(catchTypeIndex, opcode);
// Check for Throwable which catches everything.
if (catchType.toJavaName().equals("java.lang.Throwable")) {
catchTypeIndex = 0;
catchType = null;
}
}
handlers[i] = new ExceptionHandler(startPc, endPc, handlerPc, catchTypeIndex, catchType);
} catch (IOException e) {
throw new GraalError(e);
}
}
return handlers;
}
示例14: ExportsEntry
import java.io.DataInputStream; //导入方法依赖的package包/类
ExportsEntry(final DataInputStream in, final ConstantPool cp) throws IOException {
pkg = ((CPPackageInfo) cp.get(in.readUnsignedShort())).getName();
flags = in.readUnsignedShort();
final int toCnt = in.readUnsignedShort();
final String[] t = new String[toCnt];
for (int i=0; i< toCnt; i++) {
t[i] = ((CPModuleInfo) cp.get(in.readUnsignedShort())).getName();
}
to = Collections.unmodifiableList(Arrays.asList(t));
}
示例15: OpensEntry
import java.io.DataInputStream; //导入方法依赖的package包/类
OpensEntry(final DataInputStream in, final ConstantPool cp) throws IOException {
pkg = ((CPPackageInfo) cp.get(in.readUnsignedShort())).getName();
flags = in.readUnsignedShort();
final int toCnt = in.readUnsignedShort();
final String[] t = new String[toCnt];
for (int i=0; i< toCnt; i++) {
t[i] = ((CPModuleInfo) cp.get(in.readUnsignedShort())).getName();
}
to = Collections.unmodifiableList(Arrays.asList(t));
}