Java Code Examples for java.io.ObjectOutput#writeUTF()

The following examples show how to use java.io.ObjectOutput#writeUTF() . 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: HAKieSerializedSession.java    From hacep with Apache License 2.0 6 votes vote down vote up
@Override
public void writeObject(ObjectOutput output, HAKieSerializedSession object) throws IOException {
    output.writeInt(object.getSessionSize());
    if (object.session != null) {
        output.write(object.session);
        output.writeUTF(object.version);
    }

    Fact[] fa = new Fact[object.buffer.size()];
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ObjectOutputStream oo = new ObjectOutputStream(baos);

    oo.writeObject( object.buffer.toArray(fa) );
    byte[] ba = baos.toByteArray();
    output.writeInt( ba.length );
    output.write( ba );
}
 
Example 2
Source File: MimeType.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * The object implements the writeExternal method to save its contents
 * by calling the methods of DataOutput for its primitive values or
 * calling the writeObject method of ObjectOutput for objects, strings
 * and arrays.
 * @exception IOException Includes any I/O exceptions that may occur
 */
public void writeExternal(ObjectOutput out) throws IOException {
    String s = toString(); // contains ASCII chars only
    // one-to-one correspondence between ASCII char and byte in UTF string
    if (s.length() <= 65535) { // 65535 is max length of UTF string
        out.writeUTF(s);
    } else {
        out.writeByte(0);
        out.writeByte(0);
        out.writeInt(s.length());
        out.write(s.getBytes());
    }
}
 
Example 3
Source File: Person.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override public void writeExternal(ObjectOutput out) throws IOException {
    out.writeInt(id);
    out.writeInt(orgId);
    out.writeUTF(firstName);
    out.writeUTF(lastName);
    out.writeDouble(salary);
}
 
Example 4
Source File: ValueExpressionImpl.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
@Override
public void writeExternal(ObjectOutput out) throws IOException {
    out.writeUTF(this.expr);
    out.writeUTF((this.expectedType != null) ? this.expectedType.getName()
            : "");
    out.writeObject(this.fnMapper);
    out.writeObject(this.varMapper);
}
 
Example 5
Source File: MeasureFormat.java    From j2objc with Apache License 2.0 5 votes vote down vote up
public void writeExternal(ObjectOutput out) throws IOException {
    out.writeByte(0); // version
    out.writeUTF(locale.toLanguageTag());
    out.writeByte(formatWidth.ordinal());
    out.writeObject(numberFormat);
    out.writeByte(subClass);
    out.writeObject(keyValues);
}
 
Example 6
Source File: NameODA.java    From org.openntf.domino with Apache License 2.0 5 votes vote down vote up
@Override
public void writeExternal(final ObjectOutput out) throws IOException {
	super.writeExternal(out);
	out.writeInt(EXTERNALVERSIONUID);
	out.writeUTF(getCanonical());
	out.writeUTF(_language);
}
 
Example 7
Source File: TCPEndpoint.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Write endpoint to output stream.
 */
public void write(ObjectOutput out) throws IOException {
    if (csf == null) {
        out.writeByte(FORMAT_HOST_PORT);
        out.writeUTF(host);
        out.writeInt(port);
    } else {
        out.writeByte(FORMAT_HOST_PORT_FACTORY);
        out.writeUTF(host);
        out.writeInt(port);
        out.writeObject(csf);
    }
}
 
Example 8
Source File: MotionsDBDescriptor.java    From opensim-gui with Apache License 2.0 5 votes vote down vote up
public void writeExternal(ObjectOutput out) throws IOException {
    out.writeLong(serialVersionUID);
    out.writeInt(getModelFileNames().size());
    for (int i=0; i<getModelFileNames().size(); i++) {
        out.writeUTF(getModelFileNames().get(i));
        out.writeUTF(getMotionFileNames().get(i));
    }
}
 
Example 9
Source File: DeleteTableWriterBuilder.java    From spliceengine with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void writeExternal(ObjectOutput out) throws IOException {
    out.writeLong(heapConglom);
    out.writeLong(tempConglomID);
    out.writeUTF(tableVersion);
    SIDriver.driver().getOperationFactory().writeTxn(txn, out);
    out.writeBoolean(operationContext!=null);
    if (operationContext!=null)
        out.writeObject(operationContext);
    ArrayUtil.writeIntArray(out, updateCounts);
    out.writeObject(execRowDefinition);
}
 
Example 10
Source File: MeasureFormat.java    From fitnotifications with Apache License 2.0 5 votes vote down vote up
public void writeExternal(ObjectOutput out) throws IOException {
    out.writeByte(0); // version
    out.writeUTF(locale.toLanguageTag());
    out.writeByte(formatWidth.ordinal());
    out.writeObject(numberFormat);
    out.writeByte(subClass);
    out.writeObject(keyValues);
}
 
Example 11
Source File: TCPEndpoint.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Write endpoint to output stream.
 */
public void write(ObjectOutput out) throws IOException {
    if (csf == null) {
        out.writeByte(FORMAT_HOST_PORT);
        out.writeUTF(host);
        out.writeInt(port);
    } else {
        out.writeByte(FORMAT_HOST_PORT_FACTORY);
        out.writeUTF(host);
        out.writeInt(port);
        out.writeObject(csf);
    }
}
 
Example 12
Source File: DElementStore.java    From org.openntf.domino with Apache License 2.0 5 votes vote down vote up
@Override
public void writeExternal(final ObjectOutput out) throws IOException {
	out.writeLong(delegateKey_);
	out.writeInt(getTypes().size());
	for (Class<?> clazz : getTypes()) {
		out.writeUTF(clazz.getName());
	}
}
 
Example 13
Source File: BaseClassFieldReader.java    From kogito-runtimes with Apache License 2.0 5 votes vote down vote up
public void writeExternal(ObjectOutput out) throws IOException {
    out.writeInt( index );
    out.writeObject( valueType );
    if (fieldType == null) {
        out.writeUTF( "" );
    } else {
        out.writeUTF( fieldType.getName() );
    }
}
 
Example 14
Source File: GridCacheAtomicLongImpl.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override public void writeExternal(ObjectOutput out) throws IOException {
    out.writeObject(ctx.kernalContext());
    out.writeUTF(name);
}
 
Example 15
Source File: IgfsControlResponse.java    From ignite with Apache License 2.0 4 votes vote down vote up
/**
 * Writes object to data output. Do not use externalizable interface to avoid marshaller.
 *
 * @param out Data output.
 * @throws IOException If error occurred.
 */
public void writeExternal(ObjectOutput out) throws IOException {
    byte[] hdr = new byte[RES_HEADER_SIZE];

    U.intToBytes(resType, hdr, 0);

    int off = 4;

    hdr[off++] = err != null ? (byte)1 : (byte)0;

    if (resType == RES_TYPE_BYTE_ARRAY)
        U.intToBytes(len, hdr, off);

    out.write(hdr);

    if (err != null) {
        out.writeUTF(err);
        out.writeInt(errCode);

        if (resType == RES_TYPE_ERR_STREAM_ID)
            out.writeLong((Long)res);

        return;
    }

    switch (resType) {
        case RES_TYPE_BOOLEAN:
            out.writeBoolean((Boolean)res);

            break;

        case RES_TYPE_LONG:
            out.writeLong((Long)res);

            break;

        case RES_TYPE_BYTE_ARRAY:
            byte[][] buf = (byte[][])res;

            for (byte[] bytes : buf)
                out.write(bytes);

            break;

        case RES_TYPE_IGFS_PATH:
        case RES_TYPE_IGFS_PATH_SUMMARY:
        case RES_TYPE_IGFS_FILE:
        case RES_TYPE_IGFS_STREAM_DESCRIPTOR:
        case RES_TYPE_HANDSHAKE:
        case RES_TYPE_MODE_RESOLVER:
        case RES_TYPE_STATUS: {
            out.writeBoolean(res != null);

            if (res != null)
                ((Externalizable)res).writeExternal(out);

            break;
        }

        case RES_TYPE_COL_IGFS_FILE:
        case RES_TYPE_COL_IGFS_PATH:
        case RES_TYPE_COL_IGFS_BLOCK_LOCATION: {
            Collection<Externalizable> items = (Collection<Externalizable>)res;

            if (items != null) {
                out.writeInt(items.size());

                for (Externalizable item : items)
                    item.writeExternal(out);
            }
            else
                out.writeInt(-1);

            break;
        }
    }
}
 
Example 16
Source File: SerializableConfiguration.java    From beam with Apache License 2.0 4 votes vote down vote up
@Override
public void writeExternal(ObjectOutput out) throws IOException {
  out.writeUTF(conf.getClass().getCanonicalName());
  conf.write(out);
}
 
Example 17
Source File: SerializedRule.java    From kogito-runtimes with Apache License 2.0 4 votes vote down vote up
public void writeExternal(ObjectOutput out) throws IOException {
    out.writeUTF( name );
    out.writeUTF( packageName );
    out.writeObject( this.metaAttributes );
}
 
Example 18
Source File: RemoteRefreshDatedObjectResult.java    From reladomo with Apache License 2.0 4 votes vote down vote up
public void writeExternal(ObjectOutput out) throws IOException
{
    this.writeRemoteTransactionId(out);
    out.writeUTF(MithraSerialUtil.getDataClassNameToSerialize(this.refreshedData));
    this.refreshedData.zSerializeFullData(out);
}
 
Example 19
Source File: Value.java    From directory-ldap-api with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void writeExternal( ObjectOutput out ) throws IOException
{
    // Write a boolean for the HR flag
    out.writeBoolean( isHR );

    if ( isHR )
    { 
        // Write the value if any
        out.writeBoolean( upValue != null );

        if ( upValue != null )
        {
            // Write the value
            out.writeInt( bytes.length );

            if ( bytes.length > 0 )
            {
                out.write( bytes );
            }
        }

        // Write the prepared value if any
        out.writeBoolean( normValue != null );

        if ( normValue != null )
        {
            // Write the value
            out.writeUTF( normValue );
        }
    }
    else
    {
        // Just write the bytes if not null
        out.writeBoolean( bytes != null );

        if ( bytes != null )
        {
            out.writeInt( bytes.length );
            
            if ( bytes.length > 0 )
            {
                out.write( bytes );
            }
        }
    }

    // and flush the data
    out.flush();
}
 
Example 20
Source File: ConfigurableHDFSFileSource.java    From components with Apache License 2.0 4 votes vote down vote up
@Override
public void writeExternal(ObjectOutput out) throws IOException {
    out.writeUTF(split.getClass().getCanonicalName());
    ((Writable) split).write(out);
}