当前位置: 首页>>代码示例>>Java>>正文


Java DataInput.readShort方法代码示例

本文整理汇总了Java中java.io.DataInput.readShort方法的典型用法代码示例。如果您正苦于以下问题:Java DataInput.readShort方法的具体用法?Java DataInput.readShort怎么用?Java DataInput.readShort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.io.DataInput的用法示例。


在下文中一共展示了DataInput.readShort方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: readShortArray

import java.io.DataInput; //导入方法依赖的package包/类
/**
 * Reads an array of <code>short</code>s from a <code>DataInput</code>.
 *
 * @throws IOException A problem occurs while reading from <code>in</code>
 *
 * @see #writeShortArray
 */
public static short[] readShortArray(DataInput in) throws IOException {

  InternalDataSerializer.checkIn(in);

  int length = InternalDataSerializer.readArrayLength(in);
  if (length == -1) {
    return null;
  } else {
    short[] array = new short[length];
    for (int i = 0; i < length; i++) {
      array[i] = in.readShort();
    }

    if (logger.isTraceEnabled(LogMarker.SERIALIZER)) {
      logger.trace(LogMarker.SERIALIZER, "Read short array of length {}", length);
    }

    return array;
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:28,代码来源:DataSerializer.java

示例2: fromData

import java.io.DataInput; //导入方法依赖的package包/类
/**
 * Fill out this instance of the message using the <code>DataInput</code> Required to be a
 * {@link org.apache.geode.DataSerializable}Note: must be symmetric with
 * {@link #toData(DataOutput)}in what it reads
 */
@Override
public void fromData(DataInput in) throws IOException, ClassNotFoundException {
  super.fromData(in);
  this.flags = in.readShort();
  setFlags(this.flags, in);
  this.regionPath = DataSerializer.readString(in);
  this.isTransactionDistributed = in.readBoolean();
}
 
开发者ID:ampool,项目名称:monarch,代码行数:14,代码来源:RemoteOperationMessage.java

示例3: newDataInput

import java.io.DataInput; //导入方法依赖的package包/类
/**
 * Creates a new {@link NormalizedNodeDataInput} instance that reads from the given input. This method first reads
 * and validates that the input contains a valid NormalizedNode stream.
 *
 * @param input the DataInput to read from
 * @return a new {@link NormalizedNodeDataInput} instance
 * @throws IOException if an error occurs reading from the input
 */
public static NormalizedNodeDataInput newDataInput(@Nonnull final DataInput input) throws IOException {
    final byte marker = input.readByte();
    if (marker != TokenTypes.SIGNATURE_MARKER) {
        throw new InvalidNormalizedNodeStreamException(String.format("Invalid signature marker: %d", marker));
    }

    final short version = input.readShort();
    switch (version) {
        case TokenTypes.LITHIUM_VERSION:
            return new NormalizedNodeInputStreamReader(input, true);
        default:
            throw new InvalidNormalizedNodeStreamException(String.format("Unhandled stream version %s", version));
    }
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:23,代码来源:NormalizedNodeInputOutput.java

示例4: loadRoot

import java.io.DataInput; //导入方法依赖的package包/类
/**
 * 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);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:FSImageFormat.java

示例5: fromData

import java.io.DataInput; //导入方法依赖的package包/类
public void fromData(DataInput in) throws IOException, ClassNotFoundException {
  int flags = in.readUnsignedShort();
  if (logger.isTraceEnabled(LogMarker.VERSION_TAG)) {
    logger.info(LogMarker.VERSION_TAG, "deserializing {} with flags 0x{}", this.getClass(),
        Integer.toHexString(flags));
  }
  bitsUpdater.set(this, 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);
    }
  }
  setIsRemoteForTesting();
}
 
开发者ID:ampool,项目名称:monarch,代码行数:31,代码来源:VersionTag.java

示例6: fromData662

import java.io.DataInput; //导入方法依赖的package包/类
public void fromData662(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();
}
 
开发者ID:ampool,项目名称:monarch,代码行数:10,代码来源:PersistentMemberID.java

示例7: readId

import java.io.DataInput; //导入方法依赖的package包/类
protected long readId(final DataInput in, final byte idType) throws IOException {
    switch (idType) {
    case ID_ONE_BYTE:
        return in.readByte() - Byte.MIN_VALUE;
    case ID_TWO_BYTES:
        return in.readShort() - Short.MIN_VALUE;
    case ID_FOUR_BYTES:
        return in.readInt() - Integer.MIN_VALUE;
    case ID_EIGHT_BYTES:
        return in.readLong() - Long.MIN_VALUE;
    default:
        throw new Error("Unknown idType " + idType);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:Token.java

示例8: readString

import java.io.DataInput; //导入方法依赖的package包/类
/**
 * Utility method to read a {@code String} from a {@code DataInput}, as encoded by {@link ByteBufferOut#writeString(String)}.
 * @param data The {@code DataInput} from which to read the {@code String}.
 * @return The {@code String}.
 * @throws IOException from reading {@code data}.
 */
public static String readString(DataInput data) throws IOException {
	int sz = data.readShort();
	if (sz < 0)
		return null;
	if (sz == 0)
		return "";
	byte[] buf = new byte[sz];
	data.readFully(buf);
	return new String(buf, Message.charset);
}
 
开发者ID:matthieu-labas,项目名称:JRF,代码行数:17,代码来源:Utils.java

示例9: readOrdinal

import java.io.DataInput; //导入方法依赖的package包/类
/**
 * 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();
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:12,代码来源:Version.java

示例10: read

import java.io.DataInput; //导入方法依赖的package包/类
@Override
public void read(DataInput stream) throws IOException{
    this.data = stream.readShort();
}
 
开发者ID:RockBottomGame,项目名称:API,代码行数:5,代码来源:PartShort.java

示例11: readLocalName

import java.io.DataInput; //导入方法依赖的package包/类
public static byte[] readLocalName(DataInput in) throws IOException {
  byte[] createdNodeName = new byte[in.readShort()];
  in.readFully(createdNodeName);
  return createdNodeName;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:6,代码来源:FSImageSerialization.java

示例12: fromData

import java.io.DataInput; //导入方法依赖的package包/类
@Override
public void fromData(DataInput in) throws IOException, ClassNotFoundException {
  // super.fromData(in);
  short bits = in.readShort();
  short extBits = in.readShort();
  this.flags = bits;
  setFlags(bits, in);
  this.regionPath = DataSerializer.readString(in);
  this.op = Operation.fromOrdinal(in.readByte());
  // TODO dirack There's really no reason to send this flag across the wire
  // anymore
  this.directAck = (bits & DIRECT_ACK_MASK) != 0;
  this.possibleDuplicate = (bits & POSSIBLE_DUPLICATE_MASK) != 0;
  if ((bits & CALLBACK_ARG_MASK) != 0) {
    this.callbackArg = DataSerializer.readObject(in);
  }
  this.hasDelta = (bits & DELTA_MASK) != 0;
  this.hasOldValue = (bits & OLD_VALUE_MASK) != 0;
  if (this.hasOldValue) {
    byte b = in.readByte();
    if (b == 0) {
      this.oldValueIsSerialized = false;
    } else if (b == 1) {
      this.oldValueIsSerialized = true;
    } else {
      throw new IllegalStateException("expected 0 or 1");
    }
    this.oldValue = DataSerializer.readByteArray(in);
  }
  boolean hasFilterInfo = (bits & FILTER_INFO_MASK) != 0;
  this.needsRouting = (bits & NEEDS_ROUTING_MASK) != 0;
  if (hasFilterInfo) {
    this.filterRouting = new FilterRoutingInfo();
    InternalDataSerializer.invokeFromData(this.filterRouting, in);
  }
  if ((bits & VERSION_TAG_MASK) != 0) {
    boolean persistentTag = (bits & PERSISTENT_TAG_MASK) != 0;
    this.versionTag = VersionTag.create(persistentTag, in);
  }
  if ((extBits & INHIBIT_NOTIFICATIONS_MASK) != 0) {
    this.inhibitAllNotifications = true;
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:44,代码来源:DistributedCacheOperation.java

示例13: fromData

import java.io.DataInput; //导入方法依赖的package包/类
@Override
public void fromData(DataInput in) throws IOException, ClassNotFoundException {
  versionOrdinal = in.readShort();
}
 
开发者ID:ampool,项目名称:monarch,代码行数:5,代码来源:VersionResponse.java

示例14: read

import java.io.DataInput; //导入方法依赖的package包/类
void read(DataInput input, int depth, NBTSizeTracker sizeTracker) throws IOException
{
    sizeTracker.read(80L);
    this.data = input.readShort();
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:6,代码来源:NBTTagShort.java

示例15: readFields

import java.io.DataInput; //导入方法依赖的package包/类
@Override
public void readFields(DataInput in) throws IOException {
  super.readFields(in);
  type = in.readShort();
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:6,代码来源:Commit.java


注:本文中的java.io.DataInput.readShort方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。