Java Code Examples for java.io.ObjectOutputStream#writeLong()
The following examples show how to use
java.io.ObjectOutputStream#writeLong() .
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: GenerationSerializer.java From myrrix-recommender with Apache License 2.0 | 6 votes |
private static void writeKnownIDs(ObjectOutputStream out, FastByIDMap<FastIDSet> knownItemIDs) throws IOException { if (knownItemIDs == null) { out.writeInt(NULL_COUNT); } else { out.writeInt(knownItemIDs.size()); for (FastByIDMap.MapEntry<FastIDSet> entry : knownItemIDs.entrySet()) { out.writeLong(entry.getKey()); FastIDSet itemIDs = entry.getValue(); out.writeInt(itemIDs.size()); LongPrimitiveIterator it = itemIDs.iterator(); while (it.hasNext()) { out.writeLong(it.nextLong()); } } } }
Example 2
Source File: DependentProvider.java From deltaspike with Apache License 2.0 | 6 votes |
private void writeObject(ObjectOutputStream out) throws IOException { if (!(bean instanceof PassivationCapable)) { throw new NotSerializableException("Bean is not PassivationCapable: " + bean.toString()); } String passivationId = ((PassivationCapable) bean).getId(); if (passivationId == null) { throw new NotSerializableException(bean.toString()); } out.writeLong(serialVersionUID); out.writeObject(passivationId); out.writeObject(instance); out.writeObject(creationalContext); }
Example 3
Source File: InputStreamMarkResetTest.java From kogito-runtimes with Apache License 2.0 | 6 votes |
private byte [] marshallThingy(DataObject thingy ) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream stream = new ObjectOutputStream(baos); stream.writeChar(thingy.type); stream.writeLong(thingy.time); if( thingy.intCount != null ) { stream.writeInt(thingy.intCount); } else if( thingy.strCount != null ) { stream.writeUTF(thingy.strCount); } else { throw new IllegalStateException("Neither the integer nor String count is filled." ); } stream.close(); return baos.toByteArray(); }
Example 4
Source File: SparseBitSet.java From SparseBitSet with Apache License 2.0 | 5 votes |
/** * Save the state of the <code>SparseBitSet</code> instance to a stream * (<i>i.e.</i>, serialize it). * * @param s the ObjectOutputStream to which to write the serialized object * @exception java.io.IOException if an io error occurs * @exception java.lang.InternalError if the SparseBitSet representation is * inconsistent * * @serialData The default data is emitted, followed by the current * <i>compactionCount</i> for the bit set, and then the * <i>length</i> of the set (the position of the last bit), * followed by the <i>cache.count</i> value (an <code>int</code>, * the number of <code>int->long</code> pairs needed to describe * the set), followed by the index (<code>int</code>) and word * (<code>long</code>) for each <code>int->long</code> pair. * The mappings need not be emitted in any particular order. This * is followed by the <i>hashCode</i> for the set that can be used * as an integrity check when the bit set is read back. * * @since 1.6 */ private void writeObject(ObjectOutputStream s) throws IOException, InternalError { statisticsUpdate(); // Update structure and stats if needed. /* Write any hidden stuff. */ s.defaultWriteObject(); s.writeInt(compactionCount); // Needed to preserve value s.writeInt(cache.length); // Needed to know where last bit is /* This is the number of index/value pairs to be written. */ int count = cache.count; // Minimum number of words to be written s.writeInt(count); final long[][][] a1 = bits; final int aLength1 = a1.length; long[][] a2; long[] a3; long word; for (int w1 = 0; w1 != aLength1; ++w1) if ((a2 = a1[w1]) != null) for (int w2 = 0; w2 != LENGTH2; ++w2) if ((a3 = a2[w2]) != null) { final int base = (w1 << SHIFT1) + (w2 << SHIFT2); for (int w3 = 0; w3 != LENGTH3; ++w3) if ((word = a3[w3]) != 0) { s.writeInt(base + w3); s.writeLong(word); --count; } } if (count != 0) throw new InternalError("count of entries not consistent"); /* As a consistency check, write the hash code of the set. */ s.writeInt(cache.hash); }
Example 5
Source File: SerializableCookie.java From DoraemonKit with Apache License 2.0 | 5 votes |
private void writeObject(ObjectOutputStream out) throws IOException { out.defaultWriteObject(); out.writeObject(cookie.name()); out.writeObject(cookie.value()); out.writeLong(cookie.expiresAt()); out.writeObject(cookie.domain()); out.writeObject(cookie.path()); out.writeBoolean(cookie.secure()); out.writeBoolean(cookie.httpOnly()); out.writeBoolean(cookie.hostOnly()); out.writeBoolean(cookie.persistent()); }
Example 6
Source File: CustomObjTrees.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
private void writeObject(ObjectOutputStream out) throws IOException { out.writeBoolean(z); out.writeByte(b); out.writeChar(c); out.writeShort(s); out.writeInt(i); out.writeFloat(f); out.writeLong(j); out.writeDouble(d); out.writeObject(str); out.writeObject(parent); out.writeObject(left); out.writeObject(right); }
Example 7
Source File: SerializableHttpCookie.java From NewsMe with Apache License 2.0 | 5 votes |
private void writeObject(ObjectOutputStream out) throws IOException { out.writeObject(cookie.getName()); out.writeObject(cookie.getValue()); out.writeObject(cookie.getComment()); out.writeObject(cookie.getCommentURL()); out.writeObject(cookie.getDomain()); out.writeLong(cookie.getMaxAge()); out.writeObject(cookie.getPath()); out.writeObject(cookie.getPortlist()); out.writeInt(cookie.getVersion()); out.writeBoolean(cookie.getSecure()); out.writeBoolean(cookie.getDiscard()); }
Example 8
Source File: MappedArrayOfLongs.java From morpheus-core with Apache License 2.0 | 5 votes |
@Override public final void write(ObjectOutputStream os, int[] indexes) throws IOException { for (int index : indexes) { final long value = getLong(index); os.writeLong(value); } }
Example 9
Source File: CustomObjTrees.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private void writeObject(ObjectOutputStream out) throws IOException { out.writeBoolean(z); out.writeByte(b); out.writeChar(c); out.writeShort(s); out.writeInt(i); out.writeFloat(f); out.writeLong(j); out.writeDouble(d); out.writeObject(str); out.writeObject(parent); out.writeObject(left); out.writeObject(right); }
Example 10
Source File: Date.java From Bytecoder with Apache License 2.0 | 5 votes |
/** * Save the state of this object to a stream (i.e., serialize it). * * @serialData The value returned by {@code getTime()} * is emitted (long). This represents the offset from * January 1, 1970, 00:00:00 GMT in milliseconds. */ @java.io.Serial private void writeObject(ObjectOutputStream s) throws IOException { s.defaultWriteObject(); s.writeLong(getTimeImpl()); }
Example 11
Source File: MappedArrayWithLongCoding.java From morpheus-core with Apache License 2.0 | 5 votes |
/** Custom serialization */ private void writeObject(ObjectOutputStream os) throws IOException { os.writeInt(length); os.writeLong(defaultCode); os.writeObject(defaultValue); os.writeObject(coding); for (int i=0; i<length; ++i) { final long value = buffer.get(i); os.writeLong(value); } }
Example 12
Source File: SerializableHttpCookie.java From 4pdaClient-plus with Apache License 2.0 | 5 votes |
private void writeObject(ObjectOutputStream out) throws IOException { out.writeObject(cookie.getName()); out.writeObject(cookie.getValue()); out.writeObject(cookie.getComment()); out.writeObject(cookie.getCommentURL()); out.writeObject(cookie.getDomain()); out.writeLong(cookie.getMaxAge()); out.writeObject(cookie.getPath()); out.writeObject(cookie.getPortlist()); out.writeInt(cookie.getVersion()); out.writeBoolean(cookie.getSecure()); out.writeBoolean(cookie.getDiscard()); out.writeBoolean(getHttpOnly()); }
Example 13
Source File: SerializableHttpCookie.java From mattermost-android-classic with Apache License 2.0 | 5 votes |
private void writeObject(ObjectOutputStream out) throws IOException { out.writeObject(cookie.getName()); out.writeObject(cookie.getValue()); out.writeObject(cookie.getComment()); out.writeObject(cookie.getCommentURL()); out.writeObject(cookie.getDomain()); out.writeLong(cookie.getMaxAge()); out.writeObject(cookie.getPath()); out.writeObject(cookie.getPortlist()); out.writeInt(cookie.getVersion()); out.writeBoolean(cookie.getSecure()); out.writeBoolean(cookie.getDiscard()); }
Example 14
Source File: SerializableHttpCookie.java From ratebeer with GNU General Public License v3.0 | 5 votes |
private void writeObject(ObjectOutputStream out) throws IOException { out.writeObject(cookie.getName()); out.writeObject(cookie.getValue()); out.writeObject(cookie.getComment()); out.writeObject(cookie.getCommentURL()); out.writeObject(cookie.getDomain()); out.writeLong(cookie.getMaxAge()); out.writeObject(cookie.getPath()); out.writeObject(cookie.getPortlist()); out.writeInt(cookie.getVersion()); out.writeBoolean(cookie.getSecure()); out.writeBoolean(cookie.getDiscard()); out.writeBoolean(getHttpOnly()); }
Example 15
Source File: Element.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 4 votes |
/** * A helper method that serializes the element object. * * @param stream * the stream to which the element should be serialized. * @throws IOException * if an IO error occured or a property was not serializable. */ private void writeObject( final ObjectOutputStream stream ) throws IOException { stream.defaultWriteObject(); final ReportAttributeMap attributes = this.attributes; stream.writeLong( attributes.getChangeTracker() ); final String[] nameSpaces = attributes.getNameSpaces(); stream.writeObject( nameSpaces ); for ( int i = 0; i < nameSpaces.length; i++ ) { final String nameSpace = nameSpaces[i]; final String[] names = attributes.getNames( nameSpace ); stream.writeObject( names ); for ( int j = 0; j < names.length; j++ ) { final String name = names[j]; final Object attribute = attributes.getAttribute( nameSpace, name ); final AttributeMetaData data = getMetaData().getAttributeDescription( nameSpace, name ); if ( data != null ) { if ( data.isTransient() ) { stream.writeByte( 1 ); continue; } if ( attribute instanceof ResourceKey ) { final ResourceKey key = (ResourceKey) attribute; final ResourceKey parent = key.getParent(); if ( AttributeNames.Core.NAMESPACE.equals( nameSpace ) && ( AttributeNames.Core.CONTENT_BASE.equals( name ) || AttributeNames.Core.SOURCE.equals( name ) ) ) { if ( parent != null ) { // unwrap the content base attribute. After deserialization, the report assumes the bundle-location // as content base, as the bundle will be gone. if ( isKeySerializable( parent ) ) { stream.writeByte( 0 ); SerializerHelper.getInstance().writeObject( parent, stream ); } else { stream.writeByte( 1 ); } } else { // great, the report was never part of a bundle. That makes life easier and the key should be // safely serializable too. if ( isKeySerializable( key ) ) { stream.writeByte( 0 ); SerializerHelper.getInstance().writeObject( key, stream ); } else { stream.writeByte( 1 ); } } } else { if ( "Resource".equals( data.getValueRole() ) || parent != null ) { stream.writeByte( 0 ); try { final ResourceKey resourceKey = ResourceKeyUtils.embedResourceInKey( locateResourceManager(), key, key.getFactoryParameters() ); SerializerHelper.getInstance().writeObject( resourceKey, stream ); } catch ( ResourceException e ) { throw new IOException( "Failed to convert resource-key into byte-array key: " + e ); } } else { stream.writeByte( 0 ); SerializerHelper.getInstance().writeObject( attribute, stream ); } } } else if ( SerializerHelper.getInstance().isSerializable( attribute ) ) { stream.writeByte( 0 ); SerializerHelper.getInstance().writeObject( attribute, stream ); } else { stream.writeByte( 1 ); } } else if ( attribute instanceof String ) { stream.writeByte( 0 ); SerializerHelper.getInstance().writeObject( attribute, stream ); } else { stream.writeByte( 1 ); } } } }
Example 16
Source File: TileIdWritable.java From mrgeo with Apache License 2.0 | 4 votes |
private void writeObject(ObjectOutputStream stream) throws IOException { stream.writeLong(get()); }
Example 17
Source File: HdfsUtilities.java From pxf with Apache License 2.0 | 3 votes |
/** * Serializes fragment metadata into a ByteArrayOutputStream * * @param start the fragment metadata start * @param length the fragment metadata length * @param locations the data node locations for this split * @return byte serialization of the file split * @throws IOException if I/O errors occur while writing to the underlying * stream */ private static ByteArrayOutputStream writeBaseFragmentInfo(long start, long length, String[] locations) throws IOException { ByteArrayOutputStream byteArrayStream = new ByteArrayOutputStream(); ObjectOutputStream objectStream = new ObjectOutputStream(byteArrayStream); objectStream.writeLong(start); objectStream.writeLong(length); objectStream.writeObject(locations); return byteArrayStream; }
Example 18
Source File: Date.java From j2objc with Apache License 2.0 | 2 votes |
/** * Save the state of this object to a stream (i.e., serialize it). * * @serialData The value returned by <code>getTime()</code> * is emitted (long). This represents the offset from * January 1, 1970, 00:00:00 GMT in milliseconds. */ private void writeObject(ObjectOutputStream s) throws IOException { s.writeLong(getTimeImpl()); }
Example 19
Source File: Date.java From TencentKona-8 with GNU General Public License v2.0 | 2 votes |
/** * Save the state of this object to a stream (i.e., serialize it). * * @serialData The value returned by <code>getTime()</code> * is emitted (long). This represents the offset from * January 1, 1970, 00:00:00 GMT in milliseconds. */ private void writeObject(ObjectOutputStream s) throws IOException { s.writeLong(getTimeImpl()); }
Example 20
Source File: Date.java From jdk8u60 with GNU General Public License v2.0 | 2 votes |
/** * Save the state of this object to a stream (i.e., serialize it). * * @serialData The value returned by <code>getTime()</code> * is emitted (long). This represents the offset from * January 1, 1970, 00:00:00 GMT in milliseconds. */ private void writeObject(ObjectOutputStream s) throws IOException { s.writeLong(getTimeImpl()); }