Java Code Examples for java.io.DataInput#readShort()

The following examples show how to use java.io.DataInput#readShort() . These examples are extracted from open source projects. 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
public void readData(DataInput din) throws IOException {

		m_Reference = din.readShort();
		// read lengths
		int wc = din.readUnsignedShort();
		@SuppressWarnings("unused")
		int bc = din.readUnsignedByte();

		// read values
		if (m_NonWordDataHandler == null) {
			m_Registers = new Register[wc];
			ProcessImageFactory pimf = ModbusCoupler.getReference()
					.getProcessImageFactory();
			for (int i = 0; i < wc; i++) {
				m_Registers[i] = pimf.createRegister(din.readByte(),
						din.readByte());
			}
		} else {
			m_NonWordDataHandler.readData(din, m_Reference, wc);
		}
	}
 
Example 2
Source Project: gemfirexd-oss   File: FilterProfile.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void fromData(DataInput in) throws IOException, ClassNotFoundException {
  super.fromData(in);
  this.processorId = in.readInt();
  this.regionName = in.readUTF();
  this.opType = operationType.values()[in.readShort()];
  this.updatesAsInvalidates = in.readBoolean();
  this.profileVersion = in.readLong();
  if (isCqOp(this.opType)){
    this.serverCqName = in.readUTF();
    if (this.opType == operationType.REGISTER_CQ || 
        this.opType == operationType.SET_CQ_STATE){
      this.cq = new CqQueryImpl();
      InternalDataSerializer.invokeFromData(((CqQueryImpl)this.cq), in);
    }
  } else {
    this.clientID = in.readLong();
    this.interest = DataSerializer.readObject(in);
  }
}
 
Example 3
Source Project: gemfirexd-oss   File: XML.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public final void fromDataForOptimizedResultHolder(final DataInput dis)
    throws IOException, ClassNotFoundException {
  if (xmlStringValue == null) {
    xmlStringValue = new SQLVarchar();
  }
  // skip UTF8_IMPL_ID since it is not used currently
  dis.readShort();

  // invoke method of the underlying string type DVD
  xmlStringValue.fromDataForOptimizedResultHolder(dis);

  // If we read it from row then it must have type
  // XML_DOC_ANY because that's all we allow to be
  // written into an XML column.
  setXType(XML_DOC_ANY);
}
 
Example 4
Source Project: archimedes-ships   File: ChunkIO.java    License: MIT License 6 votes vote down vote up
public static void read(DataInput in, MobileChunk chunk) throws IOException
{
	int count = in.readShort();
	
	ArchimedesShipMod.modLog.debug("Reading mobile chunk data: " + count + " blocks");
	
	int x, y, z;
	int id;
	int meta;
	for (int i = 0; i < count; i++)
	{
		x = in.readByte();
		y = in.readByte();
		z = in.readByte();
		id = in.readShort();
		meta = in.readInt();
		chunk.setBlockIDWithMetadata(x, y, z, Block.getBlockById(id), meta);
	}
}
 
Example 5
Source Project: gemfirexd-oss   File: Version.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Reads ordinal as written by {@link #writeOrdinal} from given
 * {@link DataInput}.
 */
public static short readOrdinal(DataInput in) throws IOException {
  final byte ordinal = in.readByte();
  if (ordinal != TOKEN_ORDINAL) {
    return ordinal;
  }
  else {
    return in.readShort();
  }
}
 
Example 6
Source Project: gemfirexd-oss   File: DataSerializer.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Reads a primitive <code>short</code> from a
 * <code>DataInput</code>.
 *
 * @throws IOException
 *         A problem occurs while reading from <code>in</code>
 * @see DataInput#readShort
 * @since 5.1
 */
public static short readPrimitiveShort(DataInput in) throws IOException {
  InternalDataSerializer.checkIn(in);

  short value = in.readShort();
  if (DEBUG) {
    InternalDataSerializer.logger.info( LocalizedStrings.DEBUG, "Read Short " + value);
  }
  return value;
}
 
Example 7
Source Project: RDFS   File: FileStatus.java    License: Apache License 2.0 5 votes vote down vote up
public void readFields(DataInput in) throws IOException {
  String strPath = Text.readString(in);
  this.path = new Path(strPath);
  this.length = in.readLong();
  this.isdir = in.readBoolean();
  this.block_replication = in.readShort();
  blocksize = in.readLong();
  modification_time = in.readLong();
  access_time = in.readLong();
  permission.readFields(in);
  owner = Text.readString(in);
  group = Text.readString(in);
}
 
Example 8
Source Project: Bytecoder   File: StackMapType.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Construct object from file stream.
 * @param file Input stream
 * @throws IOException
 */
StackMapType(final DataInput file, final ConstantPool constant_pool) throws IOException {
    this(file.readByte(), -1, constant_pool);
    if (hasIndex()) {
        this.index = file.readShort();
    }
    this.constant_pool = constant_pool;
}
 
Example 9
Source Project: big-c   File: FsServerDefaults.java    License: Apache License 2.0 5 votes vote down vote up
@Override
@InterfaceAudience.Private
public void readFields(DataInput in) throws IOException {
  blockSize = in.readLong();
  bytesPerChecksum = in.readInt();
  writePacketSize = in.readInt();
  replication = in.readShort();
  fileBufferSize = in.readInt();
  checksumType = WritableUtils.readEnum(in, DataChecksum.Type.class);
}
 
Example 10
/**
 * now used only for compatibility with GFXD 1.0.3 disk files. DO NOT USE
 * OTHERWISE IN NEW CODE -- INSTEAD SEE {@link #readSignedVL(DataInput)},
 * {@link #readUnsignedVL(DataInput)}.
 */
public static int readCompactInt(final DataInput in) throws IOException {
  final boolean dump = DataSerializer.DEBUG;
  int v = in.readByte();
  if (dump) {
    logger.info(LocalizedStrings.DEBUG, "readCompactValue(byte1)=" + v);
  }
  if (v < MIN_1BYTE_COMPACT_VALUE) {
    if (v == COMPACT_VALUE_2_TOKEN) {
      v = in.readShort();
      if (dump) {
        logger.info(LocalizedStrings.DEBUG, "readCompactValue(short)=" + v);
      }
    }
    else {
      int bytesToRead = (v - COMPACT_VALUE_2_TOKEN) + 2;
      v = in.readByte(); // note the first byte will be a signed byte.
      if (dump) {
        logger.info(LocalizedStrings.DEBUG, "readCompactValue(byte2["
            + bytesToRead + "])=" + v);
      }
      bytesToRead--;
      while (bytesToRead > 0) {
        v <<= 8;
        int b = in.readUnsignedByte();
        v |= b;
        if (dump) {
          logger.info(LocalizedStrings.DEBUG, "readCompactValue("
              + bytesToRead + ")=" + b);
          logger.info(LocalizedStrings.DEBUG, "readCompactValue v=" + v);
        }
        bytesToRead--;
      }
    }
  }
  return v;
}
 
Example 11
public void fromData(DataInput in) throws IOException, ClassNotFoundException {
  long diskStoreIdHigh =  in.readLong();
  long diskStoreIdLow =  in.readLong();
  this.diskStoreId = new DiskStoreID(diskStoreIdHigh, diskStoreIdLow);
  this.host = DataSerializer.readInetAddress(in);
  this.directory = DataSerializer.readString(in);
  this.timeStamp = in.readLong();
  this.version = in.readShort();
  this.name = DataSerializer.readString(in);
}
 
Example 12
Source Project: gemfirexd-oss   File: VersionTag.java    License: Apache License 2.0 5 votes vote down vote up
public void fromData(DataInput in) throws IOException, ClassNotFoundException {
  LogWriterI18n log = null;
  if (DEBUG) {
    log = InternalDistributedSystem.getLoggerI18n();
  }
  int flags = in.readUnsignedShort();
  if (DEBUG) {
    log.info(LocalizedStrings.DEBUG,
            "deserializing " + this.getClass() + " with flags 0x" + Integer.toHexString(flags));
  }
  this.bits = in.readUnsignedShort();
  this.distributedSystemId = in.readByte();
  if ((flags & VERSION_TWO_BYTES) != 0) {
    this.entryVersion = in.readShort() & 0xffff;
  } else {
    this.entryVersion = in.readInt() & 0xffffffff;
  }
  if ((flags & HAS_RVV_HIGH_BYTE) != 0) {
    this.regionVersionHighBytes = in.readShort();
  }
  this.regionVersionLowBytes = in.readInt();
  this.timeStamp = InternalDataSerializer.readUnsignedVL(in);
  if ((flags & HAS_MEMBER_ID) != 0) {
    this.memberID = readMember(in);
  }
  if ((flags & HAS_PREVIOUS_MEMBER_ID) != 0) {
    if ((flags & DUPLICATE_MEMBER_IDS) != 0) {
      this.previousMemberID = this.memberID;
    } else {
      this.previousMemberID = readMember(in);
    }
  }
  this.bits |= BITS_IS_REMOTE_TAG;
}
 
Example 13
Source Project: hadoop   File: FSImageFormat.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Load information about root, and use the information to update the root
 * directory of NameSystem.
 * @param in The {@link DataInput} instance to read.
 * @param counter Counter to increment for namenode startup progress
 */
private void loadRoot(DataInput in, Counter counter)
    throws IOException {
  // load root
  if (in.readShort() != 0) {
    throw new IOException("First node is not root");
  }
  final INodeDirectory root = loadINode(null, false, in, counter)
    .asDirectory();
  // update the root's attributes
  updateRootAttr(root);
}
 
Example 14
Source Project: sagetv   File: Airing.java    License: Apache License 2.0 5 votes vote down vote up
Airing(DataInput in, byte ver, Map<Integer, Integer> idMap) throws IOException
{
  super(in, ver, idMap);
  showID = readID(in, idMap);
  stationID = in.readInt();
  time = in.readLong();
  duration = in.readLong();
  if (duration < 0)
  {
    Wizard.INVALID_AIRING_DURATIONS = true;
    if (Sage.DBG) System.out.println("BAD AIRING DURATION: id=" + id + " showID=" + showID + " time=" + time + " duration=" + duration + " mask=" +
        getMediaMaskString());
  }
  partsB = in.readByte();
  if (ver >= 0x4A)
    miscB = in.readInt();
  else
    miscB = in.readByte() & 0xFF;
  prB = in.readByte();
  if (ver >= 0x41)
    persist = in.readByte();
  if (ver >= 0x4C && ver < 0x54) {
    int size = in.readShort();
    in.skipBytes(size); // url bytes
    long foo = (ver >= 0x51) ? in.readLong() : in.readInt();
    if (foo != 0) {
      in.readShort(); // price
      in.readInt(); // flags
      in.readInt(); // winstart
      if (ver >= 0x4E) {
        size = in.readShort();
        in.skipBytes(size); // provider
      }
    }
  }
}
 
Example 15
Source Project: RDFS   File: UpgradeStatusReport.java    License: Apache License 2.0 4 votes vote down vote up
/**
 */
public void readFields(DataInput in) throws IOException {
  this.version = in.readInt();
  this.upgradeStatus = in.readShort();
}
 
Example 16
Source Project: gemfirexd-oss   File: EntryEventImpl.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Reads the contents of this message from the given input.
 */
public void fromData(DataInput in) throws IOException, ClassNotFoundException {
  this.eventID = (EventID)DataSerializer.readObject(in);
  this.key = DataSerializer.readObject(in);
  this.op = Operation.fromOrdinal(in.readByte());
  short flags = in.readShort();
  this.eventFlags = (short)(flags & EventFlags.FLAG_TRANSIENT_MASK);
  this.extraEventFlags = (short)(flags & 0xFF);
  this.callbackArg = DataSerializer.readObject(in);

  final boolean prefObject = CachedDeserializableFactory.preferObject();
  Version version = null;
  ByteArrayDataInput bytesIn = null;
  if (prefObject) {
    version = InternalDataSerializer.getVersionForDataStreamOrNull(in);
    bytesIn = new ByteArrayDataInput();
  }
  if (in.readBoolean()) {     // isDelta
    this.delta = (Delta)DataSerializer.readObject(in);
  }
  else {
    // OFFHEAP Currently values are never deserialized to off heap memory. If that changes then this code needs to change.
    if (in.readBoolean()) {     // newValueSerialized
      this.newValueBytes = DataSerializer.readByteArray(in);
      if (prefObject) {
        this.newValue = deserialize(this.newValueBytes, version, bytesIn);
      }
      else {
        this.newValue = CachedDeserializableFactory.create(this.newValueBytes);
      }
    }
    else {
      this.newValue = DataSerializer.readObject(in);
    }
  }

  // OFFHEAP Currently values are never deserialized to off heap memory. If that changes then this code needs to change.
  if (in.readBoolean()) {     // oldValueSerialized
    this.oldValueBytes = DataSerializer.readByteArray(in);
    if (prefObject) {
      this.oldValue = deserialize(this.oldValueBytes, version, bytesIn);
    }
    else {
      this.oldValue = CachedDeserializableFactory.create(this.oldValueBytes);
    }
  }
  else {
    this.oldValue = DataSerializer.readObject(in);
  }
  this.distributedMember = DSFIDFactory.readInternalDistributedMember(in);
  this.context = ClientProxyMembershipID.readCanonicalized(in);
  this.tailKey = in.readLong();
}
 
Example 17
/**
 * Constructs and returns a new <code>UID</code> instance by
 * unmarshalling a binary representation from an
 * <code>DataInput</code> instance.
 *
 * <p>Specifically, this method first invokes the given stream's
 * {@link DataInput#readInt()} method to read a <code>unique</code> value,
 * then it invoke's the stream's
 * {@link DataInput#readLong()} method to read a <code>time</code> value,
 * then it invoke's the stream's
 * {@link DataInput#readShort()} method to read a <code>count</code> value,
 * and then it creates and returns a new <code>UID</code> instance
 * that contains the <code>unique</code>, <code>time</code>, and
 * <code>count</code> values that were read from the stream.
 *
 * @param   in the <code>DataInput</code> instance to read
 * <code>UID</code> from
 *
 * @return  unmarshalled <code>UID</code> instance
 *
 * @throws  IOException if an I/O error occurs while performing
 * this operation
 */
public static UID read(DataInput in) throws IOException {
    int unique = in.readInt();
    long time = in.readLong();
    short count = in.readShort();
    return new UID(unique, time, count);
}
 
Example 18
Source Project: JDKSourceCode1.8   File: UID.java    License: MIT License 3 votes vote down vote up
/**
 * Constructs and returns a new <code>UID</code> instance by
 * unmarshalling a binary representation from an
 * <code>DataInput</code> instance.
 *
 * <p>Specifically, this method first invokes the given stream's
 * {@link DataInput#readInt()} method to read a <code>unique</code> value,
 * then it invoke's the stream's
 * {@link DataInput#readLong()} method to read a <code>time</code> value,
 * then it invoke's the stream's
 * {@link DataInput#readShort()} method to read a <code>count</code> value,
 * and then it creates and returns a new <code>UID</code> instance
 * that contains the <code>unique</code>, <code>time</code>, and
 * <code>count</code> values that were read from the stream.
 *
 * @param   in the <code>DataInput</code> instance to read
 * <code>UID</code> from
 *
 * @return  unmarshalled <code>UID</code> instance
 *
 * @throws  IOException if an I/O error occurs while performing
 * this operation
 */
public static UID read(DataInput in) throws IOException {
    int unique = in.readInt();
    long time = in.readLong();
    short count = in.readShort();
    return new UID(unique, time, count);
}
 
Example 19
Source Project: big-c   File: Utils.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Construct the Version object by reading from the input stream.
 * 
 * @param in
 *          input stream
 * @throws IOException
 */
public Version(DataInput in) throws IOException {
  major = in.readShort();
  minor = in.readShort();
}
 
Example 20
Source Project: hadoop-gpu   File: Utils.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Construct the Version object by reading from the input stream.
 * 
 * @param in
 *          input stream
 * @throws IOException
 */
public Version(DataInput in) throws IOException {
  major = in.readShort();
  minor = in.readShort();
}