/** * Writes the primitive value to the stream. * * @param out A stream to write to. * @param value A value to write. * @throws IOException If an I/O error occurs. */ static void writePrimitive(DataOutput out, Object value) throws IOException { if (value instanceof Byte) out.writeByte((Byte) value); else if (value instanceof Short) out.writeShort((Short) value); else if (value instanceof Integer) out.writeInt((Integer) value); else if (value instanceof Long) out.writeLong((Long) value); else if (value instanceof Float) out.writeFloat((Float) value); else if (value instanceof Double) out.writeDouble((Double) value); else if (value instanceof Boolean) out.writeBoolean((Boolean) value); else if (value instanceof Character) out.writeChar((Character) value); else throw new IllegalArgumentException(); }
public void write(DataOutput out) throws IOException { out.write(BASE_TYPE); out.writeUTF(name); out.writeInt(sampleStrs.size()); for (int i = 0; i < sampleStrs.size(); i++) { UTF8.writeString(out, sampleStrs.get(i)); } out.writeInt(tokenClassIdentifier); out.writeBoolean(tokenParameter != null); if (tokenParameter != null) { UTF8.writeString(out, tokenParameter); } }