Java Code Examples for java.io.ObjectOutputStream#writeLong()
The following examples show how to use
java.io.ObjectOutputStream#writeLong() .
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
Source Project: kogito-runtimes File: InputStreamMarkResetTest.java License: 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 2
Source Project: deltaspike File: DependentProvider.java License: 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 Project: myrrix-recommender File: GenerationSerializer.java License: 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 4
Source Project: ratebeer File: SerializableHttpCookie.java License: 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 5
Source Project: mattermost-android-classic File: SerializableHttpCookie.java License: 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 6
Source Project: 4pdaClient-plus File: SerializableHttpCookie.java License: 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 7
Source Project: morpheus-core File: MappedArrayWithLongCoding.java License: 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 8
Source Project: Bytecoder File: Date.java License: 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 9
Source Project: TencentKona-8 File: CustomObjTrees.java License: 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 Project: morpheus-core File: MappedArrayOfLongs.java License: 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 11
Source Project: NewsMe File: SerializableHttpCookie.java License: 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 12
Source Project: openjdk-8-source File: CustomObjTrees.java License: 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 13
Source Project: DoraemonKit File: SerializableCookie.java License: 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 14
Source Project: SparseBitSet File: SparseBitSet.java License: 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 15
Source Project: pentaho-reporting File: Element.java License: 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 Project: mrgeo File: TileIdWritable.java License: Apache License 2.0 | 4 votes |
private void writeObject(ObjectOutputStream stream) throws IOException { stream.writeLong(get()); }
Example 17
Source Project: pxf File: HdfsUtilities.java License: 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 Project: TencentKona-8 File: Date.java License: 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 19
Source Project: j2objc File: Date.java License: 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 20
Source Project: jdk8u60 File: Date.java License: 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()); }