本文整理汇总了Java中org.nustaq.serialization.FSTObjectOutput.writeInt方法的典型用法代码示例。如果您正苦于以下问题:Java FSTObjectOutput.writeInt方法的具体用法?Java FSTObjectOutput.writeInt怎么用?Java FSTObjectOutput.writeInt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.nustaq.serialization.FSTObjectOutput
的用法示例。
在下文中一共展示了FSTObjectOutput.writeInt方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeObject
import org.nustaq.serialization.FSTObjectOutput; //导入方法依赖的package包/类
@Override
public void writeObject(FSTObjectOutput out, Object toWrite, FSTClazzInfo clzInfo, FSTClazzInfo.FSTFieldInfo referencedBy, int streamPosition) throws IOException {
EnumSet enset = (EnumSet) toWrite;
int count = 0;
out.writeInt(enset.size());
if ( enset.isEmpty() ) { //WTF only way to determine enumtype ..
EnumSet compl = EnumSet.complementOf(enset);
out.writeClassTag(FSTUtil.getRealEnumClass(compl.iterator().next().getClass()));
} else {
for (Object element : enset) {
if ( count == 0 ) {
out.writeClassTag(FSTUtil.getRealEnumClass(element.getClass()));
}
out.writeObjectInternal(element, null, Enum.class);
count++;
}
}
}
示例2: writeObject
import org.nustaq.serialization.FSTObjectOutput; //导入方法依赖的package包/类
@Override
public void writeObject(FSTObjectOutput out, Object toWrite, FSTClazzInfo clzInfo, FSTClazzInfo.FSTFieldInfo referencedBy, int streamPosition) throws IOException {
ArrayList col = (ArrayList)toWrite;
int size = col.size();
out.writeInt(size);
Class lastClz = null;
FSTClazzInfo lastInfo = null;
for (int i = 0; i < size; i++) {
Object o = col.get(i);
if ( o != null ) {
lastInfo = out.writeObjectInternal(o, o.getClass() == lastClz ? lastInfo : null, null);
lastClz = o.getClass();
} else
out.writeObjectInternal(o, null, null);
}
}
示例3: writeObject
import org.nustaq.serialization.FSTObjectOutput; //导入方法依赖的package包/类
@Override
public void writeObject(FSTObjectOutput out, Object toWrite, FSTClazzInfo clzInfo, FSTClazzInfo.FSTFieldInfo referencedBy, int streamPosition) throws IOException {
Map col = (Map)toWrite;
out.writeInt(col.size());
FSTClazzInfo lastKClzI = null;
FSTClazzInfo lastVClzI = null;
Class lastKClz = null;
Class lastVClz = null;
for (Iterator iterator = col.entrySet().iterator(); iterator.hasNext(); ) {
Map.Entry next = (Map.Entry) iterator.next();
Object key = next.getKey();
Object value = next.getValue();
if ( key != null && value != null ) {
lastKClzI = out.writeObjectInternal(key, key.getClass() == lastKClz ? lastKClzI : null, null);
lastVClzI = out.writeObjectInternal(value, value.getClass() == lastVClz ? lastVClzI : null, null);
lastKClz = key.getClass();
lastVClz = value.getClass();
} else
{
out.writeObjectInternal(key, null, null);
out.writeObjectInternal(value, null, null);
}
}
}
示例4: writeObject
import org.nustaq.serialization.FSTObjectOutput; //导入方法依赖的package包/类
@Override
public void writeObject(FSTObjectOutput out, Object toWrite, FSTClazzInfo clzInfo, FSTClazzInfo.FSTFieldInfo referencedBy, int streamPosition) throws IOException {
EnumSet enset = (EnumSet) toWrite;
int count = 0;
out.writeInt(enset.size());
if ( enset.isEmpty() ) { //WTF only way to determine enumtype ..
EnumSet compl = EnumSet.complementOf(enset);
out.writeStringUTF(FSTUtil.getRealEnumClass(compl.iterator().next().getClass()).getName());
} else {
for (Object element : enset) {
if ( count == 0 ) {
out.writeStringUTF(FSTUtil.getRealEnumClass(element.getClass()).getName());
}
out.writeStringUTF(element.toString());
count++;
}
}
}
示例5: writeObject
import org.nustaq.serialization.FSTObjectOutput; //导入方法依赖的package包/类
@Override
public void writeObject(FSTObjectOutput out, Object toWrite,
FSTClazzInfo clzInfo, FSTFieldInfo referencedBy, int streamPosition)
throws IOException {
DAGObject dagObj = (DAGObject) toWrite;
byte serialisationState = DefaultSerialisationMechanism.idSerialise();
boolean idOnly = false;
if (serialisationState == DefaultSerialisationMechanism.ID
|| (serialisationState == NODES && dagObj instanceof DAGNode))
idOnly = true;
if (dagObj.getID() < 0)
idOnly = false;
out.writeBoolean(idOnly);
if (idOnly)
out.writeInt(dagObj.getID());
else
out.defaultWriteObject(toWrite, clzInfo);
}
示例6: writeObject
import org.nustaq.serialization.FSTObjectOutput; //导入方法依赖的package包/类
@Override
public void writeObject(FSTObjectOutput out, Object toWrite, FSTClazzInfo clzInfo, FSTClazzInfo.FSTFieldInfo referencedBy, int streamPosition) throws IOException {
Sentence sen = (Sentence) toWrite;
out.writeInt(sen.getID());
out.writeObjectInternal(sen.getTokens(), null, (Class[]) null);
out.writeObjectInternal(sen.getCCGbankParse(), null, (Class[]) null);
}
示例7: writeObject
import org.nustaq.serialization.FSTObjectOutput; //导入方法依赖的package包/类
@Override
public void writeObject(FSTObjectOutput out, Object toWrite, FSTClazzInfo clzInfo, FSTClazzInfo.FSTFieldInfo referencedBy,
int streamPosition) throws IOException {
byte[] value = ((BigInteger) toWrite).toByteArray();
out.writeInt(value.length);
out.write(value);
}
示例8: writeObject
import org.nustaq.serialization.FSTObjectOutput; //导入方法依赖的package包/类
@Override
public void writeObject(FSTObjectOutput out, Object toWrite, FSTClazzInfo clzInfo, FSTClazzInfo.FSTFieldInfo referencedBy, int streamPosition) throws IOException {
out.writeObject(clzInfo.getClazz());
Collection coll = (Collection) toWrite;
out.writeInt(coll.size());
for (Iterator iterator = coll.iterator(); iterator.hasNext(); ) {
out.writeObject(iterator.next());
}
}
开发者ID:RuedigerMoeller,项目名称:fast-serialization,代码行数:10,代码来源:FSTJSonUnmodifiableCollectionSerializer.java
示例9: writeObject
import org.nustaq.serialization.FSTObjectOutput; //导入方法依赖的package包/类
/**
* write the contents of a given object
*/
@Override
public void writeObject(FSTObjectOutput out, Object toWrite, FSTClazzInfo clzInfo, FSTClazzInfo.FSTFieldInfo referencedBy, int streamPosition) throws IOException {
FSTStruct str = (FSTStruct) toWrite;
if ( ! str.isOffHeap() ) {
str = str.toOffHeap();
}
int byteSize = str.getByteSize();
out.writeInt(byteSize);
if ( COMPRESS ) {
long base = str.___offset;
int intsiz = byteSize/4;
for ( int i=0; i<intsiz;i++ ) {
int value = str.getInt();
value = (value << 1) ^ (value >> 31);
str.___offset+=4;
while ((value & 0xFFFFFF80) != 0L) {
out.writeByte((value & 0x7F) | 0x80);
value >>>= 7;
}
out.writeByte(value & 0x7F);
}
int remainder = byteSize&3;
for ( int i = 0; i < remainder; i++) {
byte aByte = str.getByte();
out.writeByte(aByte);
str.___offset++;
}
str.___offset = base;
} else {
byte b[] = new byte[byteSize]; // fixme: cache threadlocal
str.getBase().getArr(str.getOffset(), b, 0, byteSize);
out.write( b, 0, byteSize);
}
}
示例10: writeObject
import org.nustaq.serialization.FSTObjectOutput; //导入方法依赖的package包/类
@Override
public void writeObject(FSTObjectOutput out, Object toWrite, FSTClazzInfo clzInfo, FSTFieldInfo referencedBy,
int streamPosition) throws IOException {
byte[] value = ((PeerAddress) toWrite).toByteArray();
out.writeInt(value.length);
out.write(value);
}
示例11: writeInt
import org.nustaq.serialization.FSTObjectOutput; //导入方法依赖的package包/类
public static void writeInt(OutputStream stream, int i) throws IOException {
FSTObjectOutput out = conf.getObjectOutput(stream);
out.writeInt(i);
out.flush();
}