本文整理汇总了Java中org.jf.util.ExceptionWithContext.withContext方法的典型用法代码示例。如果您正苦于以下问题:Java ExceptionWithContext.withContext方法的具体用法?Java ExceptionWithContext.withContext怎么用?Java ExceptionWithContext.withContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jf.util.ExceptionWithContext
的用法示例。
在下文中一共展示了ExceptionWithContext.withContext方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readFrom
import org.jf.util.ExceptionWithContext; //导入方法依赖的package包/类
@Nonnull
public static EncodedValue readFrom(@Nonnull DexReader reader) {
int startOffset = reader.getOffset();
try {
int b = reader.readUbyte();
int valueType = b & 0x1f;
int valueArg = b >>> 5;
switch (valueType) {
case ValueType.BYTE:
Preconditions.checkValueArg(valueArg, 0);
return new ImmutableByteEncodedValue((byte)reader.readByte());
case ValueType.SHORT:
Preconditions.checkValueArg(valueArg, 1);
return new ImmutableShortEncodedValue((short)reader.readSizedInt(valueArg + 1));
case ValueType.CHAR:
Preconditions.checkValueArg(valueArg, 1);
return new ImmutableCharEncodedValue((char)reader.readSizedSmallUint(valueArg + 1));
case ValueType.INT:
Preconditions.checkValueArg(valueArg, 3);
return new ImmutableIntEncodedValue(reader.readSizedInt(valueArg + 1));
case ValueType.LONG:
Preconditions.checkValueArg(valueArg, 7);
return new ImmutableLongEncodedValue(reader.readSizedLong(valueArg + 1));
case ValueType.FLOAT:
Preconditions.checkValueArg(valueArg, 3);
return new ImmutableFloatEncodedValue(Float.intBitsToFloat(
reader.readSizedRightExtendedInt(valueArg + 1)));
case ValueType.DOUBLE:
Preconditions.checkValueArg(valueArg, 7);
return new ImmutableDoubleEncodedValue(Double.longBitsToDouble(
reader.readSizedRightExtendedLong(valueArg + 1)));
case ValueType.STRING:
Preconditions.checkValueArg(valueArg, 3);
return new DexBackedStringEncodedValue(reader, valueArg);
case ValueType.TYPE:
Preconditions.checkValueArg(valueArg, 3);
return new DexBackedTypeEncodedValue(reader, valueArg);
case ValueType.FIELD:
Preconditions.checkValueArg(valueArg, 3);
return new DexBackedFieldEncodedValue(reader, valueArg);
case ValueType.METHOD:
Preconditions.checkValueArg(valueArg, 3);
return new DexBackedMethodEncodedValue(reader, valueArg);
case ValueType.ENUM:
Preconditions.checkValueArg(valueArg, 3);
return new DexBackedEnumEncodedValue(reader, valueArg);
case ValueType.ARRAY:
Preconditions.checkValueArg(valueArg, 0);
return new DexBackedArrayEncodedValue(reader);
case ValueType.ANNOTATION:
Preconditions.checkValueArg(valueArg, 0);
return new DexBackedAnnotationEncodedValue(reader);
case ValueType.NULL:
Preconditions.checkValueArg(valueArg, 0);
return ImmutableNullEncodedValue.INSTANCE;
case ValueType.BOOLEAN:
Preconditions.checkValueArg(valueArg, 1);
return ImmutableBooleanEncodedValue.forBoolean(valueArg == 1);
default:
throw new ExceptionWithContext("Invalid encoded_value type: 0x%x", valueType);
}
} catch (Exception ex) {
throw ExceptionWithContext.withContext(ex, "Error while reading encoded value at offset 0x%x", startOffset);
}
}
示例2: skipFrom
import org.jf.util.ExceptionWithContext; //导入方法依赖的package包/类
public static void skipFrom(@Nonnull DexReader reader) {
int startOffset = reader.getOffset();
try {
int b = reader.readUbyte();
int valueType = b & 0x1f;
switch (valueType) {
case ValueType.BYTE:
reader.skipByte();
break;
case ValueType.SHORT:
case ValueType.CHAR:
case ValueType.INT:
case ValueType.LONG:
case ValueType.FLOAT:
case ValueType.DOUBLE:
case ValueType.STRING:
case ValueType.TYPE:
case ValueType.FIELD:
case ValueType.METHOD:
case ValueType.ENUM:
int valueArg = b >>> 5;
reader.moveRelative(valueArg+1);
break;
case ValueType.ARRAY:
DexBackedArrayEncodedValue.skipFrom(reader);
break;
case ValueType.ANNOTATION:
DexBackedAnnotationEncodedValue.skipFrom(reader);
break;
case ValueType.NULL:
case ValueType.BOOLEAN:
break;
default:
throw new ExceptionWithContext("Invalid encoded_value type: 0x%x", valueType);
}
} catch (Exception ex) {
throw ExceptionWithContext.withContext(ex, "Error while skipping encoded value at offset 0x%x",
startOffset);
}
}
示例3: readFrom
import org.jf.util.ExceptionWithContext; //导入方法依赖的package包/类
public static EncodedValue readFrom( DexReader reader) {
int startOffset = reader.getOffset();
try {
int b = reader.readUbyte();
int valueType = b & 0x1f;
int valueArg = b >>> 5;
switch (valueType) {
case ValueType.BYTE:
Preconditions.checkValueArg(valueArg, 0);
return new ImmutableByteEncodedValue((byte)reader.readByte());
case ValueType.SHORT:
Preconditions.checkValueArg(valueArg, 1);
return new ImmutableShortEncodedValue((short)reader.readSizedInt(valueArg + 1));
case ValueType.CHAR:
Preconditions.checkValueArg(valueArg, 1);
return new ImmutableCharEncodedValue((char)reader.readSizedSmallUint(valueArg + 1));
case ValueType.INT:
Preconditions.checkValueArg(valueArg, 3);
return new ImmutableIntEncodedValue(reader.readSizedInt(valueArg + 1));
case ValueType.LONG:
Preconditions.checkValueArg(valueArg, 7);
return new ImmutableLongEncodedValue(reader.readSizedLong(valueArg + 1));
case ValueType.FLOAT:
Preconditions.checkValueArg(valueArg, 3);
return new ImmutableFloatEncodedValue(Float.intBitsToFloat(
reader.readSizedRightExtendedInt(valueArg + 1)));
case ValueType.DOUBLE:
Preconditions.checkValueArg(valueArg, 7);
return new ImmutableDoubleEncodedValue(Double.longBitsToDouble(
reader.readSizedRightExtendedLong(valueArg + 1)));
case ValueType.STRING:
Preconditions.checkValueArg(valueArg, 3);
return new DexBackedStringEncodedValue(reader, valueArg);
case ValueType.TYPE:
Preconditions.checkValueArg(valueArg, 3);
return new DexBackedTypeEncodedValue(reader, valueArg);
case ValueType.FIELD:
Preconditions.checkValueArg(valueArg, 3);
return new DexBackedFieldEncodedValue(reader, valueArg);
case ValueType.METHOD:
Preconditions.checkValueArg(valueArg, 3);
return new DexBackedMethodEncodedValue(reader, valueArg);
case ValueType.ENUM:
Preconditions.checkValueArg(valueArg, 3);
return new DexBackedEnumEncodedValue(reader, valueArg);
case ValueType.ARRAY:
Preconditions.checkValueArg(valueArg, 0);
return new DexBackedArrayEncodedValue(reader);
case ValueType.ANNOTATION:
Preconditions.checkValueArg(valueArg, 0);
return new DexBackedAnnotationEncodedValue(reader);
case ValueType.NULL:
Preconditions.checkValueArg(valueArg, 0);
return ImmutableNullEncodedValue.INSTANCE;
case ValueType.BOOLEAN:
Preconditions.checkValueArg(valueArg, 1);
return ImmutableBooleanEncodedValue.forBoolean(valueArg == 1);
default:
throw new ExceptionWithContext("Invalid encoded_value type: 0x%x", valueType);
}
} catch (Exception ex) {
throw ExceptionWithContext.withContext(ex, "Error while reading encoded value at offset 0x%x", startOffset);
}
}
示例4: skipFrom
import org.jf.util.ExceptionWithContext; //导入方法依赖的package包/类
public static void skipFrom( DexReader reader) {
int startOffset = reader.getOffset();
try {
int b = reader.readUbyte();
int valueType = b & 0x1f;
switch (valueType) {
case ValueType.BYTE:
reader.skipByte();
break;
case ValueType.SHORT:
case ValueType.CHAR:
case ValueType.INT:
case ValueType.LONG:
case ValueType.FLOAT:
case ValueType.DOUBLE:
case ValueType.STRING:
case ValueType.TYPE:
case ValueType.FIELD:
case ValueType.METHOD:
case ValueType.ENUM:
int valueArg = b >>> 5;
reader.moveRelative(valueArg+1);
break;
case ValueType.ARRAY:
DexBackedArrayEncodedValue.skipFrom(reader);
break;
case ValueType.ANNOTATION:
DexBackedAnnotationEncodedValue.skipFrom(reader);
break;
case ValueType.NULL:
case ValueType.BOOLEAN:
break;
default:
throw new ExceptionWithContext("Invalid encoded_value type: 0x%x", valueType);
}
} catch (Exception ex) {
throw ExceptionWithContext.withContext(ex, "Error while skipping encoded value at offset 0x%x",
startOffset);
}
}