hprose.io.serialize.ShortArraySerializer Maven / Gradle / Ivy
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* ShortArraySerializer.java *
* *
* short array serializer class for Java. *
* *
* LastModified: Aug 6, 2016 *
* Author: Ma Bingyao *
* *
\**********************************************************/
package hprose.io.serialize;
import static hprose.io.HproseTags.TagClosebrace;
import static hprose.io.HproseTags.TagList;
import static hprose.io.HproseTags.TagOpenbrace;
import java.io.IOException;
import java.io.OutputStream;
public final class ShortArraySerializer extends ReferenceSerializer {
public final static ShortArraySerializer instance = new ShortArraySerializer();
@Override
public final void serialize(Writer writer, short[] array) throws IOException {
super.serialize(writer, array);
OutputStream stream = writer.stream;
stream.write(TagList);
int length = array.length;
if (length > 0) {
ValueWriter.writeInt(stream, length);
}
stream.write(TagOpenbrace);
for (int i = 0; i < length; ++i) {
ValueWriter.write(stream, array[i]);
}
stream.write(TagClosebrace);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy