本文整理了Java中com.esotericsoftware.kryo.io.Input.position()
方法的一些代码示例,展示了Input.position()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Input.position()
方法的具体详情如下:
包路径:com.esotericsoftware.kryo.io.Input
类名称:Input
方法名:position
[英]Returns the current position in the buffer.
[中]返回缓冲区中的当前位置。
代码示例来源:origin: org.gradle/gradle-messaging
@Override
protected long maybeSkip(long count) throws IOException {
// Work around some bugs in Input.skip()
int remaining = input.limit() - input.position();
if (remaining == 0) {
long skipped = inputStream.skip(count);
if (skipped > 0) {
extraSkipped += skipped;
}
return skipped;
} else if (count <= remaining) {
input.setPosition(input.position() + (int) count);
return count;
} else {
input.setPosition(input.limit());
return remaining;
}
}
代码示例来源:origin: org.hawkular.titan/titan-core
public Object readClassAndObject(ReadBuffer buffer) {
Input i = buffer.asRelative(INPUT_FACTORY);
int startPos = i.position();
Object value = getKryo().readClassAndObject(i);
buffer.movePositionTo(buffer.getPosition()+i.position()-startPos);
return value;
}
代码示例来源:origin: org.hawkular.titan/titan-core
public <T> T readObjectNotNull(ReadBuffer buffer, Class<T> type) {
Input i = buffer.asRelative(INPUT_FACTORY);
int startPos = i.position();
T value = getKryo().readObject(i, type);
buffer.movePositionTo(buffer.getPosition()+i.position()-startPos);
return value;
}
代码示例来源:origin: inspectIT/inspectIT
/**
* Returns if the input has more bytes that Kryo can read. This method will first check if any
* bytes are left to read in the Input's internal buffer. If no bytes are left there, will check
* the underlying input stream if the amount of available bytes is more than zero.
*
* @param input
* {@link Input}
* @return True if there is at least 1 bytes to read, false otherwise.
* @throws IOException
* If {@link IOException} occurs on the Input's input stream.
*/
public static boolean hasMoreBytes(Input input) throws IOException {
if (input.limit() > input.position()) {
return true;
} else {
return (null != input.getInputStream()) && (input.getInputStream().available() > 0);
}
}
}
代码示例来源:origin: org.apache.apex/malhar-library
@Override
public Slice deserialize(Input input)
{
if (input.getInputStream() != null) {
// The input is backed by a stream, cannot directly use its internal buffer
try {
return new Slice(input.readBytes(input.available()));
} catch (IOException ex) {
throw Throwables.propagate(ex);
}
} else {
return new Slice(input.getBuffer(), input.position(), input.limit() - input.position());
}
}
}
代码示例来源:origin: org.apache.apex/apex-engine
try {
input.setBuffer(dspair.state.buffer, dspair.state.offset, dspair.state.length);
while (input.position() < input.limit()) {
ClassIdPair pair = (ClassIdPair)readClassAndObject(input);
classResolver.registerExplicit(pair);
代码示例来源:origin: net.dempsy/dempsy-serialization.kryo
@Override
public <T> T deserialize(final MessageBufferInput data, final Class<T> clazz) throws IOException {
try (Holder k = getKryoHolder()) {
final Input input = k.input;
input.setBuffer(data.getBuffer(), data.getPosition(), data.getLimit());
final T ret = kryoRunner.doDeserialize(k, input, clazz);
data.setPosition(input.position()); // forward to where Kryo finished.
return ret;
} catch (final KryoException ke) {
throw new IOException("Failed to deserialize.", ke);
} catch (final IllegalArgumentException e) { // this happens when requiring registration but deserializing an unregistered class
throw new IOException("Failed to deserialize. Did you require registration and attempt to deserialize an unregistered class?", e);
}
}
代码示例来源:origin: com.esotericsoftware.kryo/kryo
public void read (Input input, Object object) {
try {
if (TRACE) trace("kryo", "Read field: " + this + " (" + type.getName() + ")" + " pos=" + input.position());
Object value;
代码示例来源:origin: com.esotericsoftware/kryo-shaded
public void read (Input input, Object object) {
try {
if (TRACE) trace("kryo", "Read field: " + this + " (" + type.getName() + ")" + " pos=" + input.position());
Object value;
代码示例来源:origin: com.esotericsoftware/kryo
public void read (Input input, Object object) {
try {
if (TRACE) trace("kryo", "Read field: " + this + " (" + type.getName() + ")" + " pos=" + input.position());
Object value;
代码示例来源:origin: svn2github/kryo
final public void read (Input input, Object object) {
try {
if (TRACE) trace("kryo", "Read field: " + this + " (" + type.getName() + ")" + " pos=" + input.position());
Object value;
内容来源于网络,如有侵权,请联系作者删除!