Java Code Examples for java.io.DataInput#readByte()
The following examples show how to use
java.io.DataInput#readByte() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ServerToHostProtocolHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Override public void handleRequest(final DataInput input, final ActiveOperation.ResultHandler<Void> resultHandler, final ManagementRequestContext<ServerInventory> context) throws IOException { final byte param = input.readByte(); // Started / Failed PARAM_OK final String message = input.readUTF(); // Server started/failed message context.executeAsync(new ManagementRequestContext.AsyncTask<ServerInventory>() { @Override public void execute(ManagementRequestContext<ServerInventory> serverInventoryManagementRequestContext) throws Exception { try { final ServerInventory inventory = context.getAttachment(); if(param == DomainServerProtocol.PARAM_OK) { inventory.serverStarted(serverProcessName); } else { inventory.serverStartFailed(serverProcessName); } } finally { resultHandler.done(null); } } }); }
Example 2
Source File: ZigZagLEB128Codec.java From incubator-hivemall with Apache License 2.0 | 5 votes |
public static int readUnsignedInt(@Nonnull final DataInput in) throws IOException { int value = 0; int i = 0; int b; while (((b = in.readByte()) & 0x80) != 0) { value |= (b & 0x7F) << i; i += 7; if (i > 35) { throw new IllegalArgumentException("Variable length quantity is too long: " + i); } } return value | (b << i); }
Example 3
Source File: DiskInitFileParser.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
private void readEndOfRecord(DataInput di) throws IOException { int b = di.readByte(); if (b != DiskInitFile.END_OF_RECORD_ID) { if (b == 0) { // this is expected if this is the last record and we died while writing it. throw new EOFException("found partial last record"); } else { // Our implementation currently relies on all unwritten bytes having // a value of 0. So throw this exception if we find one we didn't expect. throw new IllegalStateException("expected end of record (byte==" + DiskInitFile.END_OF_RECORD_ID + ") or zero but found " + b); } } }
Example 4
Source File: jMutRepair_0045_t.java From coming with MIT License | 5 votes |
static OfYear readFrom(DataInput in) throws IOException { return new OfYear((char)in.readUnsignedByte(), (int)in.readUnsignedByte(), (int)in.readByte(), (int)in.readUnsignedByte(), in.readBoolean(), (int)readMillis(in)); }
Example 5
Source File: AbstractDelegationTokenIdentifier.java From hadoop with Apache License 2.0 | 5 votes |
@Override public void readFields(DataInput in) throws IOException { byte version = in.readByte(); if (version != VERSION) { throw new IOException("Unknown version of delegation token " + version); } owner.readFields(in, Text.DEFAULT_MAX_LEN); renewer.readFields(in, Text.DEFAULT_MAX_LEN); realUser.readFields(in, Text.DEFAULT_MAX_LEN); issueDate = WritableUtils.readVLong(in); maxDate = WritableUtils.readVLong(in); sequenceNumber = WritableUtils.readVInt(in); masterKeyId = WritableUtils.readVInt(in); }
Example 6
Source File: ZoneInfoFile.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public static ZoneInfo getZoneInfo(DataInput in, String zoneId) throws Exception { byte type = in.readByte(); // TBD: assert ZRULES: int stdSize = in.readInt(); long[] stdTrans = new long[stdSize]; for (int i = 0; i < stdSize; i++) { stdTrans[i] = readEpochSec(in); } int [] stdOffsets = new int[stdSize + 1]; for (int i = 0; i < stdOffsets.length; i++) { stdOffsets[i] = readOffset(in); } int savSize = in.readInt(); long[] savTrans = new long[savSize]; for (int i = 0; i < savSize; i++) { savTrans[i] = readEpochSec(in); } int[] savOffsets = new int[savSize + 1]; for (int i = 0; i < savOffsets.length; i++) { savOffsets[i] = readOffset(in); } int ruleSize = in.readByte(); ZoneOffsetTransitionRule[] rules = new ZoneOffsetTransitionRule[ruleSize]; for (int i = 0; i < ruleSize; i++) { rules[i] = new ZoneOffsetTransitionRule(in); } return getZoneInfo(zoneId, stdTrans, stdOffsets, savTrans, savOffsets, rules); }
Example 7
Source File: ZclDataUtil.java From arcusplatform with Apache License 2.0 | 5 votes |
private static long readBits(DataInput input, int bytes) throws IOException { long result = 0; long shift = 0; for (int i = 0; i < bytes; ++i) { result = result | ((input.readByte() & 0xFFL) << shift); shift += 8; } return result; }
Example 8
Source File: SedesHelper.java From spork with Apache License 2.0 | 5 votes |
/** * @param in to read bytes from * @return decode value * @throws IOException if {@link DataInput} throws {@link IOException} * @throws IllegalArgumentException if variable-length value does not terminate * after 9 bytes have been read * @see #writeUnsignedVarLong(long, DataOutput) */ public static long readUnsignedVarLong(DataInput in) throws IOException { long value = 0L; int i = 0; long b; while (((b = in.readByte()) & 0x80L) != 0) { value |= (b & 0x7F) << i; i += 7; if (i > 63) { throw new RuntimeException("Variable length quantity is too long"); } } return value | (b << i); }
Example 9
Source File: IndexCreationMsg.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
@Override public void fromData(DataInput in) throws IOException, ClassNotFoundException { super.fromData(in); this.name = in.readUTF(); this.fromClause = in.readUTF(); this.indexedExpression = in.readUTF(); this.indexType = in.readByte(); this.importsNeeded = in.readBoolean(); if (this.importsNeeded) this.imports = in.readUTF(); // this.ifNew = in.readBoolean(); // this.ifOld = in.readBoolean(); }
Example 10
Source File: SerializedObjectPartList.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
@Override public void fromData(DataInput in) throws IOException, ClassNotFoundException { boolean keysPresent = in.readBoolean(); if (keysPresent) { this.keys = new ArrayList(); } this.hasKeys = keysPresent; int numObjects = in.readInt(); this.objectTypeArray = new byte[numObjects]; if (numObjects > 0) { for (int index = 0; index < numObjects; ++index) { if (keysPresent) { Object key = DataSerializer.readObject(in); this.keys.add(key); } byte objectType = in.readByte(); this.objectTypeArray[index] = objectType; Object value; if (objectType==EXCEPTION) { byte[] exBytes = DataSerializer.readByteArray(in); value = CacheServerHelper.deserialize(exBytes); // ignore the exception string meant for native clients DataSerializer.readString(in); } else { value = DataSerializer.readByteArray(in); } this.objects.add(value); } } }
Example 11
Source File: RemotePutMessage.java From gemfirexd-oss with Apache License 2.0 | 4 votes |
@Override public void fromData(DataInput in) throws IOException, ClassNotFoundException { super.fromData(in); final Version version = InternalDataSerializer.getVersionForDataStream(in); final boolean isVer11 = (Version.SQLF_11.compareTo(version) <= 0); setKey(DataSerializer.readObject(in)); final int extraFlags = in.readUnsignedByte(); this.deserializationPolicy = (byte)(extraFlags & DistributedCacheOperation.DESERIALIZATION_POLICY_MASK); if (!isVer11) { this.cbArg = DataSerializer.readObject(in); } this.lastModified = in.readLong(); this.op = Operation.fromOrdinal(in.readByte()); if (isVer11 && (extraFlags & HAS_CALLBACKARG) != 0) { this.cbArg = DataSerializer.readObject(in); } if ((extraFlags & HAS_BRIDGE_CONTEXT) != 0) { this.bridgeContext = DataSerializer.readObject(in); } if ((extraFlags & HAS_ORIGINAL_SENDER) != 0) { this.originalSender = DataSerializer.readObject(in); } this.eventId = new EventID(); InternalDataSerializer.invokeFromData(this.eventId, in); final short flags = this.flags; this.ifNew = (flags & IF_NEW) != 0; this.ifOld = (flags & IF_OLD) != 0; this.requireOldValue = (flags & REQUIRED_OLD_VAL) != 0; this.hasOldValue = (flags & HAS_OLD_VAL) != 0; this.cacheWrite = (flags & CACHE_WRITE) != 0; this.useOriginRemote = (flags & USE_ORIGIN_REMOTE) != 0; this.isPutDML = (flags & IS_PUT_DML) != 0; if ((flags & HAS_EXPECTED_OLD_VAL) != 0) { this.expectedOldValue = DataSerializer.readObject(in); } if (this.hasOldValue) { this.oldValueIsSerialized = in.readByte(); if (this.oldValueIsSerialized == VALUE_IS_OBJECT) { setOldValObj(DataSerializer.readObject(in)); } else { setOldValBytes(DataSerializer.readByteArray(in)); } } if (this.deserializationPolicy == DistributedCacheOperation.DESERIALIZATION_POLICY_EAGER) { setValObj(DataSerializer.readObject(in)); } else { setValBytes(DataSerializer.readByteArray(in)); } if ((flags & HAS_DELTA_BYTES) != 0) { this.applyDeltaBytes = true; this.deltaBytes = DataSerializer.readByteArray(in); } if ((extraFlags & HAS_VERSION_TAG) != 0) { this.versionTag = DataSerializer.readObject(in); } }
Example 12
Source File: CompressLZF.java From FastBootWeixin with Apache License 2.0 | 4 votes |
public void expand(DataInput in, byte[] out, int outPos, int outLen) throws IOException { // if ((inPos | outPos | outLen) < 0) { assert(outLen>=0); do { int ctrl = in.readByte() & 255; if (ctrl < MAX_LITERAL) { // literal run of length = ctrl + 1, ctrl++; // copy to output and move forward this many bytes in.readFully(out,outPos,ctrl); outPos += ctrl; } else { // back reference // the highest 3 bits are the match length int len = ctrl >> 5; // if the length is maxed, add the next byte to the length if (len == 7) { len += in.readByte() & 255; } // minimum back-reference is 3 bytes, // so 2 was subtracted before storing size len += 2; // ctrl is now the offset for a back-reference... // the logical AND operation removes the length bits ctrl = -((ctrl & 0x1f) << 8) - 1; // the next byte augments/increases the offset ctrl -= in.readByte() & 255; // copy the back-reference bytes from the given // location in output to current position ctrl += outPos; if (outPos + len >= out.length) { // reduce array bounds checking throw new ArrayIndexOutOfBoundsException(); } for (int i = 0; i < len; i++) { out[outPos++] = out[ctrl++]; } } } while (outPos < outLen); }
Example 13
Source File: MonthDay.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
static MonthDay readExternal(DataInput in) throws IOException { byte month = in.readByte(); byte day = in.readByte(); return MonthDay.of(month, day); }
Example 14
Source File: Constant.java From commons-bcel with Apache License 2.0 | 4 votes |
/** * Reads one constant from the given input, the type depends on a tag byte. * * @param dataInput Input stream * @return Constant object * @throws IOException if an I/O error occurs reading from the given {@code dataInput}. * @throws ClassFormatException if the next byte is not recognized * @since 6.0 made public */ public static Constant readConstant(final DataInput dataInput) throws IOException, ClassFormatException { final byte b = dataInput.readByte(); // Read tag byte switch (b) { case Const.CONSTANT_Class: return new ConstantClass(dataInput); case Const.CONSTANT_Fieldref: return new ConstantFieldref(dataInput); case Const.CONSTANT_Methodref: return new ConstantMethodref(dataInput); case Const.CONSTANT_InterfaceMethodref: return new ConstantInterfaceMethodref(dataInput); case Const.CONSTANT_String: return new ConstantString(dataInput); case Const.CONSTANT_Integer: return new ConstantInteger(dataInput); case Const.CONSTANT_Float: return new ConstantFloat(dataInput); case Const.CONSTANT_Long: return new ConstantLong(dataInput); case Const.CONSTANT_Double: return new ConstantDouble(dataInput); case Const.CONSTANT_NameAndType: return new ConstantNameAndType(dataInput); case Const.CONSTANT_Utf8: return ConstantUtf8.getInstance(dataInput); case Const.CONSTANT_MethodHandle: return new ConstantMethodHandle(dataInput); case Const.CONSTANT_MethodType: return new ConstantMethodType(dataInput); case Const.CONSTANT_Dynamic: return new ConstantDynamic(dataInput); case Const.CONSTANT_InvokeDynamic: return new ConstantInvokeDynamic(dataInput); case Const.CONSTANT_Module: return new ConstantModule(dataInput); case Const.CONSTANT_Package: return new ConstantPackage(dataInput); default: throw new ClassFormatException("Invalid byte tag in constant pool: " + b); } }
Example 15
Source File: DistributedPutAllOperation.java From gemfirexd-oss with Apache License 2.0 | 4 votes |
/** * Constructor to use when receiving a putall from someone else */ public PutAllEntryData(DataInput in, EventID baseEventID, int idx, Version version, ByteArrayDataInput bytesIn) throws IOException, ClassNotFoundException { this.key = DataSerializer.readObject(in); byte flgs = in.readByte(); if ((flgs & IS_OBJECT) != 0) { this.value = DataSerializer.readObject(in); } else { byte[] bb = DataSerializer.readByteArray(in); if ((flgs & IS_CACHED_DESER) != 0) { if (CachedDeserializableFactory.preferObject()) { this.value = EntryEventImpl.deserialize(bb, version, bytesIn); } else { this.value = CachedDeserializableFactory.create(bb); } } else { this.value = bb; } } this.oldValue = null; this.op = Operation.fromOrdinal(in.readByte()); this.flags = in.readByte(); if ((this.flags & FILTER_ROUTING) != 0) { this.filterRouting = (FilterRoutingInfo)DataSerializer.readObject(in); } if ((this.flags & VERSION_TAG) != 0) { boolean persistentTag = (this.flags & PERSISTENT_TAG) != 0; this.versionTag = VersionTag.create(persistentTag, in); } if (isUsedFakeEventId()) { this.eventID = new EventID(); InternalDataSerializer.invokeFromData(this.eventID, in); } else { this.eventID = new EventID(baseEventID, idx); } if ((this.flags & HAS_CALLBACKARG) != 0) { this.callbackArg = DataSerializer.readObject(in); } else { this.callbackArg = null; } if ((this.flags & HAS_TAILKEY) != 0) { this.tailKey = InternalDataSerializer.readSignedVL(in); } }
Example 16
Source File: Ser.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
static Object read(DataInput in) throws IOException, ClassNotFoundException { byte type = in.readByte(); return readInternal(type, in); }
Example 17
Source File: Ser.java From threetenbp with BSD 3-Clause "New" or "Revised" License | 4 votes |
static Object read(DataInput in) throws IOException { byte type = in.readByte(); return readInternal(type, in); }
Example 18
Source File: ThaiBuddhistDate.java From Java8CN with Apache License 2.0 | 4 votes |
static ThaiBuddhistDate readExternal(DataInput in) throws IOException { int year = in.readInt(); int month = in.readByte(); int dayOfMonth = in.readByte(); return ThaiBuddhistChronology.INSTANCE.date(year, month, dayOfMonth); }
Example 19
Source File: LocalDate.java From threetenbp with BSD 3-Clause "New" or "Revised" License | 4 votes |
static LocalDate readExternal(DataInput in) throws IOException { int year = in.readInt(); int month = in.readByte(); int dayOfMonth = in.readByte(); return LocalDate.of(year, month, dayOfMonth); }
Example 20
Source File: Ser.java From jdk8u_jdk with GNU General Public License v2.0 | 2 votes |
/** * Reads the state from the stream. * * @param in the input stream, not null * @return the created object, not null * @throws IOException if an error occurs */ static ZoneOffset readOffset(DataInput in) throws IOException { int offsetByte = in.readByte(); return (offsetByte == 127 ? ZoneOffset.ofTotalSeconds(in.readInt()) : ZoneOffset.ofTotalSeconds(offsetByte * 900)); }