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

The following are Jave code examples for showing how to use writeUTF() of the java.io.ObjectOutput class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: lazycat   File: SerializablePrincipal.java   Source Code and License Vote up 6 votes
public static void writePrincipal(GenericPrincipal p, ObjectOutput out) throws IOException {
	out.writeUTF(p.getName());
	out.writeBoolean(p.getPassword() != null);
	if (p.getPassword() != null)
		out.writeUTF(p.getPassword());
	String[] roles = p.getRoles();
	if (roles == null)
		roles = new String[0];
	out.writeInt(roles.length);
	for (int i = 0; i < roles.length; i++)
		out.writeUTF(roles[i]);
	boolean hasUserPrincipal = (p != p.getUserPrincipal() && p.getUserPrincipal() instanceof Serializable);
	out.writeBoolean(hasUserPrincipal);
	if (hasUserPrincipal)
		out.writeObject(p.getUserPrincipal());
}
 
Example 2
Project: directory-ldap-api   File: Dn.java   Source Code and License Vote up 6 votes
/**
 * {@inheritDoc}
 */
@Override
public void writeExternal( ObjectOutput out ) throws IOException
{
    if ( upName == null )
    {
        String message = "Cannot serialize a NULL Dn";
        LOG.error( message );
        throw new IOException( message );
    }

    // Write the UPName
    out.writeUTF( upName );

    // Write the RDNs.
    // First the number of RDNs
    out.writeInt( size() );

    // Loop on the RDNs
    for ( Rdn rdn : rdns )
    {
        rdn.writeExternal( out );
    }

    out.flush();
}
 
Example 3
Project: apache-tomcat-7.0.73-with-comment   File: FunctionMapperImpl.java   Source Code and License Vote up 6 votes
@Override
public void writeExternal(ObjectOutput out) throws IOException {
    out.writeUTF((this.prefix != null) ? this.prefix : "");
    out.writeUTF(this.localName);
    // make sure m isn't null
    getMethod();
    out.writeUTF((this.owner != null) ?
             this.owner :
             this.m.getDeclaringClass().getName());
    out.writeUTF((this.name != null) ?
             this.name :
             this.m.getName());
    out.writeObject((this.types != null) ?
             this.types :
             ReflectionUtil.toTypeNameArray(this.m.getParameterTypes()));

}
 
Example 4
Project: knime-activelearning   File: KernelCalculator.java   Source Code and License Vote up 6 votes
@Override
public void writeExternal(final ObjectOutput out) throws IOException {
    // write kernelFunction
    out.writeUTF(m_kernelFunction.getClass().getName());
    m_kernelFunction.writeExternal(out);

    // write trainingData
    // rows
    out.writeInt(m_rowCount);
    // columns
    out.writeInt(m_colCount);
    // data
    for (final double[] row : m_trainingData) {
        for (final double col : row) {
            out.writeDouble(col);
        }
    }

}
 
Example 5
Project: jdk8u-jdk   File: TCPEndpoint.java   Source Code and License Vote up 5 votes
/**
 * 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 6
Project: knime-activelearning   File: MultiClassKNFST.java   Source Code and License Vote up 5 votes
@Override
public void writeExternal(final ObjectOutput arg0) throws IOException {
    // call super method
    super.writeExternal(arg0);

    // write labels
    arg0.writeInt(m_labels.length);
    for (final String label : m_labels) {
        arg0.writeUTF(label);
    }

}
 
Example 7
Project: directory-ldap-api   File: DefaultAttribute.java   Source Code and License Vote up 5 votes
/**
 * This is the place where we serialize attributes, and all theirs
 * elements.
 * 
 * {@inheritDoc}
 */
@Override
public void writeExternal( ObjectOutput out ) throws IOException
{
    // Write the UPId
    out.writeUTF( upId );
    
    // Write the ID
    out.writeUTF( id );

    // Write the HR flag, if not null
    if ( isHR != null )
    {
        out.writeBoolean( true );
        out.writeBoolean( isHR );
    }
    else
    {
        out.writeBoolean( false );
    }

    // Write the number of values
    out.writeInt( size() );

    if ( size() > 0 )
    {
        // Write each value
        for ( Value value : values )
        {
            // Write the value
            value.writeExternal( out );
        }
    }

    out.flush();
}
 
Example 8
Project: openjdk-jdk10   File: MimeType.java   Source Code and License Vote up 5 votes
/**
 * 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.
 *
 * @throws 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 9
Project: apache-tomcat-7.0.73-with-comment   File: MethodExpressionImpl.java   Source Code and License Vote up 5 votes
@Override
public void writeExternal(ObjectOutput out) throws IOException {
    out.writeUTF(this.expr);
    out.writeUTF((this.expectedType != null) ? this.expectedType.getName()
            : "");
    out.writeObject(ReflectionUtil.toTypeNameArray(this.paramTypes));
    out.writeObject(this.fnMapper);
    out.writeObject(this.varMapper);
}
 
Example 10
Project: tomcat7   File: MethodExpressionImpl.java   Source Code and License Vote up 5 votes
@Override
public void writeExternal(ObjectOutput out) throws IOException {
    out.writeUTF(this.expr);
    out.writeUTF((this.expectedType != null) ? this.expectedType.getName()
            : "");
    out.writeObject(ReflectionUtil.toTypeNameArray(this.paramTypes));
    out.writeObject(this.fnMapper);
    out.writeObject(this.varMapper);
}
 
Example 11
Project: Higher-Cloud-Computing-Project   File: SparseDistributedVectorStorage.java   Source Code and License Vote up 5 votes
/** {@inheritDoc} */
@Override public void writeExternal(ObjectOutput out) throws IOException {
    out.writeInt(size);
    out.writeInt(acsMode);
    out.writeObject(uuid);
    out.writeUTF(cache.getName());
}
 
Example 12
Project: lams   File: MethodExpressionImpl.java   Source Code and License Vote up 5 votes
public void writeExternal(ObjectOutput out) throws IOException {
    out.writeUTF(this.expr);
    out.writeUTF((this.expectedType != null) ? this.expectedType.getName()
            : "");
    out.writeObject(ReflectionUtil.toTypeNameArray(this.paramTypes));
    out.writeObject(this.fnMapper);
    out.writeObject(this.varMapper);
}
 
Example 13
Project: tomcat7   File: MethodExpressionLiteral.java   Source Code and License Vote up 5 votes
@Override
public void writeExternal(ObjectOutput out) throws IOException {
    out.writeUTF(this.expr);
    out.writeUTF((this.expectedType != null) ? this.expectedType.getName()
            : "");
    out.writeObject(ReflectionUtil.toTypeNameArray(this.paramTypes));
}
 
Example 14
Project: openjdk-jdk10   File: ActivatableRef.java   Source Code and License Vote up 5 votes
/**
 * Write out external representation for remote ref.
 */
public void writeExternal(ObjectOutput out) throws IOException
{
    RemoteRef localRef = ref;

    out.writeObject(id);
    if (localRef == null) {
        out.writeUTF("");
    } else {
        out.writeUTF(localRef.getRefClass(out));
        localRef.writeExternal(out);
    }
}
 
Example 15
Project: lazycat   File: FunctionMapperImpl.java   Source Code and License Vote up 5 votes
@Override
public void writeExternal(ObjectOutput out) throws IOException {
	out.writeUTF((this.prefix != null) ? this.prefix : "");
	out.writeUTF(this.localName);
	// make sure m isn't null
	getMethod();
	out.writeUTF((this.owner != null) ? this.owner : this.m.getDeclaringClass().getName());
	out.writeUTF((this.name != null) ? this.name : this.m.getName());
	out.writeObject(
			(this.types != null) ? this.types : ReflectionUtil.toTypeNameArray(this.m.getParameterTypes()));

}
 
Example 16
Project: lazycat   File: JspMethodExpression.java   Source Code and License Vote up 4 votes
@Override
public void writeExternal(ObjectOutput out) throws IOException {
	out.writeUTF(this.mark);
	out.writeObject(this.target);
}
 
Example 17
Project: alfresco-repository   File: ModuleVersionNumber.java   Source Code and License Vote up 4 votes
@Override
public void writeExternal(ObjectOutput out) throws IOException
{
    out.writeUTF(delegate.toString());
}
 
Example 18
Project: lams   File: JspValueExpression.java   Source Code and License Vote up 4 votes
public void writeExternal(ObjectOutput out) throws IOException {
    out.writeUTF(this.mark);
    out.writeObject(this.target);
}
 
Example 19
Project: lazycat   File: ValueExpressionLiteral.java   Source Code and License Vote up 4 votes
@Override
public void writeExternal(ObjectOutput out) throws IOException {
	out.writeObject(this.value);
	out.writeUTF((this.expectedType != null) ? this.expectedType.getName() : "");
}
 
Example 20
Project: eventapis   File: Event.java   Source Code and License Vote up 4 votes
public void writeExternal(ObjectOutput out) throws IOException {
    out.writeUTF(eventId.toString());
    out.writeUTF(eventState.name());
}