diff --git a/jvm-serializers-protowar/pom.xml b/jvm-serializers-protowar/pom.xml new file mode 100644 index 0000000..ba74625 --- /dev/null +++ b/jvm-serializers-protowar/pom.xml @@ -0,0 +1,61 @@ + + + 4.0.0 + + jvm-serializers + jvm-serializers-parent + 1.0-SNAPSHOT + + jvm-serializers + jvm-serializers-protowar + 1.0-SNAPSHOT + jvm-serializers-protowar + protowar of jvm-serializers Terraformed... by jim@psychosynthintelligence... on x86_64 x86_64 GNU/Linux... for protowar,scala_media_container,tpc... + http://psychosynthintelligence/protowar + + HEAD + + + + + jvm-serializers-legacy + jvm-serializers-Repo + file://${basedir}/../src/main/repository + default + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.5 + 1.5 + true + 1024m + 1024m + + + + + + + + org.codehaus.mojo + javacc-maven-plugin + 2.4.1 + + + + diff --git a/jvm-serializers-protowar/pom.xml.~1~ b/jvm-serializers-protowar/pom.xml.~1~ new file mode 100644 index 0000000..5c78f0e --- /dev/null +++ b/jvm-serializers-protowar/pom.xml.~1~ @@ -0,0 +1,24 @@ + + + 4.0.0 + + jvm-serializers + jvm-serializers-parent + 1.0-SNAPSHOT + + jvm-serializers + jvm-serializers-protowar + 1.0-SNAPSHOT + jvm-serializers-protowarprotowar of jvm-serializers Terraformed... by jim@psychosynthintelligence... on x86_64 x86_64 GNU/Linux... for protowar,scala_media_container,tpc... + http://psychosynthintelligence/protowarHEAD + jvm-serializers-legacy jvm-serializers-Repo file://${basedir}/../src/main/repository default org.apache.maven.plugins maven-compiler-plugin 1.5 1.5 true 1024m 1024m org.codehaus.mojo javacc-maven-plugin 2.4.1 diff --git a/jvm-serializers-protowar/src/main/java/jvm-serializers/protowar/App.java b/jvm-serializers-protowar/src/main/java/jvm-serializers/protowar/App.java new file mode 100644 index 0000000..ece3c35 --- /dev/null +++ b/jvm-serializers-protowar/src/main/java/jvm-serializers/protowar/App.java @@ -0,0 +1,13 @@ +package jvm-serializers.protowar; + +/** + * Hello world! + * + */ +public class App +{ + public static void main( String[] args ) + { + System.out.println( "Hello World!" ); + } +} diff --git a/jvm-serializers-protowar/src/main/java/org/protowar/ProtoServerHandler.java b/jvm-serializers-protowar/src/main/java/org/protowar/ProtoServerHandler.java new file mode 100644 index 0000000..ce6566c --- /dev/null +++ b/jvm-serializers-protowar/src/main/java/org/protowar/ProtoServerHandler.java @@ -0,0 +1,66 @@ +package org.protowar; + +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; + +import serializers.ObjectSerializer; +import serializers.ProtobufSerializer; +import serializers.protobuf.MediaContentHolder.MediaContent; +import serializers.protobuf.MediaContentHolder.MediaServer; + +import com.google.protobuf.Message; +import com.google.protobuf.RpcCallback; +import com.google.protobuf.RpcController; +import com.google.protobuf.Descriptors.MethodDescriptor; + +class ProtoServerHandler extends MediaServer +{ + private final ObjectSerializer _serializer = new ProtobufSerializer(); + + @Override + public void updateMedia (RpcController controller, MediaContent request, RpcCallback done) + { + try + { + //System.out.println(request.getMedia().getUri()); + done.run(_serializer.create()); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + void handle(final OutputStream os, final InputStream is) throws IOException + { + RpcCallback done = new RpcCallback() + { + DataOutputStream dos = new DataOutputStream(os); + + public void run (Message content) + { + try + { + byte[] array = _serializer.serialize((MediaContent) content); + dos.writeInt(array.length); + dos.write(array); + dos.flush(); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + }; + DataInputStream dis = new DataInputStream(is); + int index = dis.readInt(); + MethodDescriptor method = getDescriptor().getMethods().get(index); + byte[] array = new byte[dis.readInt()]; + dis.readFully(array); + Message request = getRequestPrototype(method).newBuilderForType().mergeFrom(array).build(); + callMethod(method, null, request, done); + } +} diff --git a/jvm-serializers-protowar/src/main/java/org/protowar/ProtoWar.java b/jvm-serializers-protowar/src/main/java/org/protowar/ProtoWar.java new file mode 100644 index 0000000..df39878 --- /dev/null +++ b/jvm-serializers-protowar/src/main/java/org/protowar/ProtoWar.java @@ -0,0 +1,50 @@ +package org.protowar; + +import java.io.IOException; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * Servlet implementation class ProtoWar + */ +public class ProtoWar extends HttpServlet +{ + private static final long serialVersionUID = 1L; + + private ProtoServerHandler _handler = new ProtoServerHandler(); + + /** + * Default constructor. + */ + public ProtoWar () + { + } + + /** + * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) + */ + protected void doGet (HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException + { + doIt(request, response); + } + + /** + * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) + */ + protected void doPost (HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException + { + doIt(request, response); + } + + private void doIt (HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException + { + _handler.handle(response.getOutputStream(), request.getInputStream()); + } + +} diff --git a/jvm-serializers-protowar/src/test/java/jvm-serializers/protowar/AppTest.java b/jvm-serializers-protowar/src/test/java/jvm-serializers/protowar/AppTest.java new file mode 100644 index 0000000..0413ea3 --- /dev/null +++ b/jvm-serializers-protowar/src/test/java/jvm-serializers/protowar/AppTest.java @@ -0,0 +1,38 @@ +package jvm-serializers.protowar; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +/** + * Unit test for simple App. + */ +public class AppTest + extends TestCase +{ + /** + * Create the test case + * + * @param testName name of the test case + */ + public AppTest( String testName ) + { + super( testName ); + } + + /** + * @return the suite of tests being tested + */ + public static Test suite() + { + return new TestSuite( AppTest.class ); + } + + /** + * Rigourous Test :-) + */ + public void testApp() + { + assertTrue( true ); + } +} diff --git a/jvm-serializers-scala_media_container/pom.xml b/jvm-serializers-scala_media_container/pom.xml new file mode 100644 index 0000000..4c21a42 --- /dev/null +++ b/jvm-serializers-scala_media_container/pom.xml @@ -0,0 +1,61 @@ + + + 4.0.0 + + jvm-serializers + jvm-serializers-parent + 1.0-SNAPSHOT + + jvm-serializers + jvm-serializers-scala_media_container + 1.0-SNAPSHOT + jvm-serializers-scala_media_container + scala_media_container of jvm-serializers Terraformed... by jim@psychosynthintelligence... on x86_64 x86_64 GNU/Linux... for protowar,scala_media_container,tpc... + http://psychosynthintelligence/scala_media_container + + HEAD + + + + + jvm-serializers-legacy + jvm-serializers-Repo + file://${basedir}/../src/main/repository + default + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.5 + 1.5 + true + 1024m + 1024m + + + + + + + + org.codehaus.mojo + javacc-maven-plugin + 2.4.1 + + + + diff --git a/jvm-serializers-scala_media_container/pom.xml.~1~ b/jvm-serializers-scala_media_container/pom.xml.~1~ new file mode 100644 index 0000000..a0c360f --- /dev/null +++ b/jvm-serializers-scala_media_container/pom.xml.~1~ @@ -0,0 +1,24 @@ + + + 4.0.0 + + jvm-serializers + jvm-serializers-parent + 1.0-SNAPSHOT + + jvm-serializers + jvm-serializers-scala_media_container + 1.0-SNAPSHOT + jvm-serializers-scala_media_containerscala_media_container of jvm-serializers Terraformed... by jim@psychosynthintelligence... on x86_64 x86_64 GNU/Linux... for protowar,scala_media_container,tpc... + http://psychosynthintelligence/scala_media_containerHEAD + jvm-serializers-legacy jvm-serializers-Repo file://${basedir}/../src/main/repository default org.apache.maven.plugins maven-compiler-plugin 1.5 1.5 true 1024m 1024m org.codehaus.mojo javacc-maven-plugin 2.4.1 diff --git a/jvm-serializers-scala_media_container/src/main/java/jvm-serializers/scala_media_container/App.java b/jvm-serializers-scala_media_container/src/main/java/jvm-serializers/scala_media_container/App.java new file mode 100644 index 0000000..57650a3 --- /dev/null +++ b/jvm-serializers-scala_media_container/src/main/java/jvm-serializers/scala_media_container/App.java @@ -0,0 +1,13 @@ +package jvm-serializers.scala_media_container; + +/** + * Hello world! + * + */ +public class App +{ + public static void main( String[] args ) + { + System.out.println( "Hello World!" ); + } +} diff --git a/jvm-serializers-scala_media_container/src/main/java/serializers/scala/Image.scala b/jvm-serializers-scala_media_container/src/main/java/serializers/scala/Image.scala new file mode 100644 index 0000000..d595466 --- /dev/null +++ b/jvm-serializers-scala_media_container/src/main/java/serializers/scala/Image.scala @@ -0,0 +1,4 @@ +package serializers.scala + +@serializable +case class Image(uri: String, title: String, width: Int, height: Int, size: Size.Value) diff --git a/jvm-serializers-scala_media_container/src/main/java/serializers/scala/Media.scala b/jvm-serializers-scala_media_container/src/main/java/serializers/scala/Media.scala new file mode 100644 index 0000000..4b14c03 --- /dev/null +++ b/jvm-serializers-scala_media_container/src/main/java/serializers/scala/Media.scala @@ -0,0 +1,23 @@ +package serializers.scala + +@serializable +class Media (val uri: String, val title: String, + val width: Int, val height: Int, val format: String, + val duration: Long, val size: Long, + val bitrate: Int, + val copyright: Option[String], + val player: Player.Value){ + + def this(uri: String, title: String, + width: Int, height: Int, format: String, + duration: Long, size: Long, + bitrate: Int, + player: Player.Value) = this(uri, title, width, height, format, duration, size, bitrate, None, player) + + private var _persons: List[String] = Nil + def persons = _persons + + def addPerson(persons: String){ + _persons = persons :: _persons + } +} diff --git a/jvm-serializers-scala_media_container/src/main/java/serializers/scala/MediaContent.scala b/jvm-serializers-scala_media_container/src/main/java/serializers/scala/MediaContent.scala new file mode 100644 index 0000000..d9d1fb8 --- /dev/null +++ b/jvm-serializers-scala_media_container/src/main/java/serializers/scala/MediaContent.scala @@ -0,0 +1,10 @@ +package serializers.scala +@serializable +class MediaContent (val media: Media){ + var _images: List[Image] = Nil + def images = _images + + def addImage(image: Image){ + _images = image :: _images + } +} diff --git a/jvm-serializers-scala_media_container/src/main/java/serializers/scala/Player.scala b/jvm-serializers-scala_media_container/src/main/java/serializers/scala/Player.scala new file mode 100644 index 0000000..a821281 --- /dev/null +++ b/jvm-serializers-scala_media_container/src/main/java/serializers/scala/Player.scala @@ -0,0 +1,5 @@ +package serializers.scala +@serializable +object Player extends Enumeration{ + val JAVA, FLASH = Value +} diff --git a/jvm-serializers-scala_media_container/src/main/java/serializers/scala/Runner.scala b/jvm-serializers-scala_media_container/src/main/java/serializers/scala/Runner.scala new file mode 100644 index 0000000..8f08007 --- /dev/null +++ b/jvm-serializers-scala_media_container/src/main/java/serializers/scala/Runner.scala @@ -0,0 +1,14 @@ +package serializers.scala + +object Runner { + def main(args: Array[String]){ + println("start") + var image1 = new Image("a", "b", 1, 2, Size.SMALL) + var image2 = new Image("a", "b", 1, 2, Size.SMALL) + var content = new MediaContent(null) + content.addImage(image1) + content.addImage(image2) + + println("end") + } +} diff --git a/jvm-serializers-scala_media_container/src/main/java/serializers/scala/SbinarySerializerSupport.scala b/jvm-serializers-scala_media_container/src/main/java/serializers/scala/SbinarySerializerSupport.scala new file mode 100644 index 0000000..b82d4c7 --- /dev/null +++ b/jvm-serializers-scala_media_container/src/main/java/serializers/scala/SbinarySerializerSupport.scala @@ -0,0 +1,91 @@ +package serializers.scala + +import sbinary.DefaultProtocol +import sbinary.DefaultProtocol._ + +object MyProtocol extends DefaultProtocol{ +// import sbinary.DefaultProtocol._ + +// implicit val ImageFormat : Format[Image] = asProduct5(Image)(Image.unapply(_).get) + implicit object ImageFormat extends Format[Image]{ + def reads(in : Input) = { + Image( + read[String](in), + read[String](in), + read[Int](in), + read[Int](in), + read[Size.Value](in) + ) + } + + def writes(out : Output, value : Image) = { + write[String](out, value.uri) + write[String](out, value.title) + write[Int](out, value.width) + write[Int](out, value.height) + write[Size.Value](out, value.size) + } + } + + implicit object MediaFormat extends Format[Media]{ + def reads(in : Input) = { + val back = new Media( + read[String](in), + read[String](in), + read[Int](in), + read[Int](in), + read[String](in), + read[Long](in), + read[Long](in), + read[Int](in), + read[Option[String]](in), + read[Player.Value](in) + ) + read[List[String]](in).foreach(p => back.addPerson(p)) + back + } + + def writes(out : Output, value : Media) = { + write[String](out, value.uri) + write[String](out, value.title) + write[Int](out, value.width) + write[Int](out, value.height) + write[String](out, value.format) + write[Long](out, value.duration) + write[Long](out, value.size) + write[Int](out, value.bitrate) + write[Option[String]](out, value.copyright) + write[Player.Value](out, value.player) + write[List[String]](out, value.persons) + } + } + +// implicit object PlayerFormat extends Format[Player.Value] { +// def reads(in : Input) = Player.Value(read[Int](in)) +// def writed(out : Output, value : Player.Value) = write[Int](out, value) +// } + + implicit val PlayerFormat = enumerationFormat[Player.Value](Player) + implicit val SizeFormat = enumerationFormat[Size.Value](Size) + + implicit object MediaContentFormat extends Format[MediaContent]{ + def reads(in : Input) = { + val back = new MediaContent(read[Media](in)) + read[List[Image]](in).foreach(i => back.addImage(i)) + back + } + + def writes(out : Output, value : MediaContent) = { + write[Media](out, value.media) + write[List[Image]](out, value.images) + } + } + +} + + +object SbinarySerializerSupport { + import MyProtocol._ + def deserialize(array : Array[Byte]) : MediaContent = fromByteArray[MediaContent](array) + def serialize(content : MediaContent) : Array[Byte] = toByteArray(content) +} \ No newline at end of file diff --git a/jvm-serializers-scala_media_container/src/main/java/serializers/scala/Size.scala b/jvm-serializers-scala_media_container/src/main/java/serializers/scala/Size.scala new file mode 100644 index 0000000..6108663 --- /dev/null +++ b/jvm-serializers-scala_media_container/src/main/java/serializers/scala/Size.scala @@ -0,0 +1,5 @@ +package serializers.scala +@serializable +object Size extends Enumeration{ + val SMALL, LARGE = Value +} diff --git a/jvm-serializers-scala_media_container/src/test/java/jvm-serializers/scala_media_container/AppTest.java b/jvm-serializers-scala_media_container/src/test/java/jvm-serializers/scala_media_container/AppTest.java new file mode 100644 index 0000000..923b6df --- /dev/null +++ b/jvm-serializers-scala_media_container/src/test/java/jvm-serializers/scala_media_container/AppTest.java @@ -0,0 +1,38 @@ +package jvm-serializers.scala_media_container; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +/** + * Unit test for simple App. + */ +public class AppTest + extends TestCase +{ + /** + * Create the test case + * + * @param testName name of the test case + */ + public AppTest( String testName ) + { + super( testName ); + } + + /** + * @return the suite of tests being tested + */ + public static Test suite() + { + return new TestSuite( AppTest.class ); + } + + /** + * Rigourous Test :-) + */ + public void testApp() + { + assertTrue( true ); + } +} diff --git a/jvm-serializers-tpc/pom.xml b/jvm-serializers-tpc/pom.xml new file mode 100644 index 0000000..6d37ec3 --- /dev/null +++ b/jvm-serializers-tpc/pom.xml @@ -0,0 +1,537 @@ + + + 4.0.0 + + jvm-serializers + jvm-serializers-parent + 1.0-SNAPSHOT + + jvm-serializers + jvm-serializers-tpc + 1.0-SNAPSHOT + jvm-serializers-tpc + tpc of jvm-serializers Terraformed... by jim@psychosynthintelligence... on x86_64 x86_64 GNU/Linux... for protowar,scala_media_container,tpc... + http://psychosynthintelligence/tpc + + HEAD + + + + + jvm-serializers-legacy + jvm-serializers-Repo + file://${basedir}/../src/main/repository + default + + + + + org.hibernate + hibernate-entitymanager + 3.3.2.GA + + + javax.transaction + jta + 1.0.1B + + + org.mortbay.jetty + jetty-management + 6.1H.8 + + + com.thoughtworks.xstream + xstream + 1.3 + + + FastInfoset + deprecated + 1.2.6 + + + aalto-gpl + aalto + 0.9.5 + + + activemq-protobuf + activemq + 1.1-SNAPSHOT + + + activemq-util + activemq + 6.0-SNAPSHOT + + + argo + deprecated + 2.10 + + + asm + deprecated + 4.0 + + + asm-commons + asm + 3.2 + + + avro + deprecated + 1.7.2 + + + avro-compiler + avro + 1.7.2 + + + avro-tools + avro + 1.7.2 + + + bson4jackson + deprecated + 2.3.0 + + + cakoose-util + deprecated + 1.0-SNAPSHOT + + + cks-core + deprecated + 1.0-SNAPSHOT + + + cks-text-reader + deprecated + 1.0-SNAPSHOT + + + cks-text-writer + deprecated + 1.0-SNAPSHOT + + + cks-tool + deprecated + 1.0-SNAPSHOT + + + commons-beanutils + commons + 1.8.3 + + + commons-codec + commons + 1.3 + + + commons-collections + commons + 3.2.1 + + + commons-httpclient + commons + 3.1 + + + commons-lang + commons + 2.4 + + + commons-logging + commons + 1.1.1 + + + dsl-clc + deprecated + 1.0-SNAPSHOT + + + dsl-json + dsl + 0.9.0 + + + exi-exificient + exi + 0.9.1 + + + ezmorph + deprecated + 1.0.6 + + + fastjson + deprecated + 1.1.19 + + + flexjson + deprecated + 2.1 + + + fst + deprecated + 1.42 + + + gson + deprecated + 2.2.2 + + + hessian + deprecated + 4.0.7 + + + jackson-all + jackson + 1.9.6 + + + jackson-annotations + jackson + 2.5.0 + + + jackson-core + jackson + 2.5.0 + + + jackson-databind + jackson + 2.5.0 + + + jackson-dataformat-avro + jackson-dataformat + 2.5.0 + + + jackson-dataformat-cbor + jackson-dataformat + 2.5.0 + + + jackson-dataformat-smile + jackson-dataformat + 2.5.0 + + + jackson-dataformat-xml + jackson-dataformat + 2.5.0 + + + jackson-dataformat-yaml + jackson-dataformat + 2.5.0 + + + jackson-jr-objects + jackson-jr + 2.5.0 + + + jackson-module-afterburner + jackson-module + 2.5.0 + + + javassist + deprecated + 3.15.0-GA + + + javax.json + deprecated + 1.0-b06 + + + javolution + deprecated + 5.5.1 + + + jboss-marshalling-osgi + jboss-marshalling + 1.3.15.GA + + + jboss-serialization + jboss + 1.0.3.GA + + + jopt-simple + jopt + 3.2 + + + json + deprecated + 0.19-tpc + + + json-lib + json + 2.4-jdk15 + + + json-smart + json + 1.0.8 + + + json.org-ref + json.org + 2011.06.21 + + + json_simple + deprecated + 1.1 + + + jsonij + deprecated + 0.2.7 + + + jsonpath + deprecated + 2011.06.23 + + + kryo + deprecated + 2.23.0 + + + libthrift + deprecated + 1.0-SNAPSHOT + + + log4j + deprecated + 1.2.8 + + + minlog-none + minlog + 1.2 + + + mongo + deprecated + 2.4 + + + msgpack + deprecated + 0.6.9 + + + objenesis + deprecated + 1.2 + + + obser + deprecated + 0.9.0-SNAPSHOT + + + paranamer + deprecated + 1.5 + + + protobuf-java + protobuf + 2.3.0 + + + protostuff-api + protostuff + 1.0.1 + + + protostuff-collectionschema + protostuff + 1.0.1 + + + protostuff-compiler + protostuff + 1.0.1-jarjar + + + protostuff-core + protostuff + 1.0.1 + + + protostuff-json + protostuff + 1.0.1 + + + protostuff-runtime + protostuff + 1.0.1 + + + protostuff-xml + protostuff + 1.0.1 + + + reflectasm + deprecated + 1.05 + + + sbinary_2.11 + deprecated + 0.4.3-SNAPSHOT + + + scala-library_2.11.2 + deprecated + 1.0-SNAPSHOT + + + scala-reflect_2.11.2 + deprecated + 1.0-SNAPSHOT + + + scala-xml_2.11 + scala + 1.0.2 + + + slf4j-api + slf4j + 1.5.10 + + + slf4j-nop + slf4j + 1.5.10 + + + snakeyaml + deprecated + 1.1 + + + stax-api + stax + 1.0.1 + + + stax2-api + stax2 + 3.0.1 + + + stephenerialization + deprecated + 3.0.0 + + + svenson + deprecated + 1.4.0 + + + trove + deprecated + 1.0.2 + + + velocity + deprecated + 1.7-dep + + + velocity + deprecated + 1.7 + + + wobly-core + wobly + 1.0 + + + woodstox-core-asl + woodstox-core + 4.0.7 + + + xpp3_min + deprecated + 1.1.4c + + + xstream + deprecated + 1.3.1 + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.5 + 1.5 + true + 1024m + 1024m + + + + + + + + org.codehaus.mojo + javacc-maven-plugin + 2.4.1 + + + + diff --git a/jvm-serializers-tpc/pom.xml.~1~ b/jvm-serializers-tpc/pom.xml.~1~ new file mode 100644 index 0000000..ad18c03 --- /dev/null +++ b/jvm-serializers-tpc/pom.xml.~1~ @@ -0,0 +1,24 @@ + + + 4.0.0 + + jvm-serializers + jvm-serializers-parent + 1.0-SNAPSHOT + + jvm-serializers + jvm-serializers-tpc + 1.0-SNAPSHOT + jvm-serializers-tpctpc of jvm-serializers Terraformed... by jim@psychosynthintelligence... on x86_64 x86_64 GNU/Linux... for protowar,scala_media_container,tpc... + http://psychosynthintelligence/tpcHEAD + jvm-serializers-legacy jvm-serializers-Repo file://${basedir}/../src/main/repository default org.hibernate hibernate-entitymanager 3.3.2.GA javax.transaction jta 1.0.1B org.mortbay.jetty jetty-management 6.1H.8 com.thoughtworks.xstream xstream 1.3 FastInfoset deprecated 1.2.6 aalto-gpl aalto 0.9.5 activemq-protobuf activemq 1.1-SNAPSHOT activemq-util activemq 6.0-SNAPSHOT argo deprecated 2.10 asm deprecated 4.0 asm-commons asm 3.2 avro deprecated 1.7.2 avro-compiler avro 1.7.2 avro-tools avro 1.7.2 bson4jackson deprecated 2.3.0 cakoose-util deprecated 1.0-SNAPSHOT cks-core deprecated 1.0-SNAPSHOT cks-text-reader deprecated 1.0-SNAPSHOT cks-text-writer deprecated 1.0-SNAPSHOT cks-tool deprecated 1.0-SNAPSHOT commons-beanutils commons 1.8.3 commons-codec commons 1.3 commons-collections commons 3.2.1 commons-httpclient commons 3.1 commons-lang commons 2.4 commons-logging commons 1.1.1 dsl-clc deprecated 1.0-SNAPSHOT dsl-json dsl 0.9.0 exi-exificient exi 0.9.1 ezmorph deprecated 1.0.6 fastjson deprecated 1.1.19 flexjson deprecated 2.1 fst deprecated 1.42 gson deprecated 2.2.2 hessian deprecated 4.0.7 jackson-all jackson 1.9.6 jackson-annotations jackson 2.5.0 jackson-core jackson 2.5.0 jackson-databind jackson 2.5.0 jackson-dataformat-avro jackson-dataformat 2.5.0 jackson-dataformat-cbor jackson-dataformat 2.5.0 jackson-dataformat-smile jackson-dataformat 2.5.0 jackson-dataformat-xml jackson-dataformat 2.5.0 jackson-dataformat-yaml jackson-dataformat 2.5.0 jackson-jr-objects jackson-jr 2.5.0 jackson-module-afterburner jackson-module 2.5.0 javassist deprecated 3.15.0-GA javax.json deprecated 1.0-b06 javolution deprecated 5.5.1 jboss-marshalling-osgi jboss-marshalling 1.3.15.GA jboss-serialization jboss 1.0.3.GA jopt-simple jopt 3.2 json deprecated 0.19-tpc json-lib json 2.4-jdk15 json-smart json 1.0.8 json.org-ref json.org 2011.06.21 json_simple deprecated 1.1 jsonij deprecated 0.2.7 jsonpath deprecated 2011.06.23 kryo deprecated 2.23.0 libthrift deprecated 1.0-SNAPSHOT log4j deprecated 1.2.8 minlog-none minlog 1.2 mongo deprecated 2.4 msgpack deprecated 0.6.9 objenesis deprecated 1.2 obser deprecated 0.9.0-SNAPSHOT paranamer deprecated 1.5 protobuf-java protobuf 2.3.0 protostuff-api protostuff 1.0.1 protostuff-collectionschema protostuff 1.0.1 protostuff-compiler protostuff 1.0.1-jarjar protostuff-core protostuff 1.0.1 protostuff-json protostuff 1.0.1 protostuff-runtime protostuff 1.0.1 protostuff-xml protostuff 1.0.1 reflectasm deprecated 1.05 sbinary_2.11 deprecated 0.4.3-SNAPSHOT scala-library_2.11.2 deprecated 1.0-SNAPSHOT scala-reflect_2.11.2 deprecated 1.0-SNAPSHOT scala-xml_2.11 scala 1.0.2 slf4j-api slf4j 1.5.10 slf4j-nop slf4j 1.5.10 snakeyaml deprecated 1.1 stax-api stax 1.0.1 stax2-api stax2 3.0.1 stephenerialization deprecated 3.0.0 svenson deprecated 1.4.0 trove deprecated 1.0.2 velocity deprecated 1.7-dep velocity deprecated 1.7 wobly-core wobly 1.0 woodstox-core-asl woodstox-core 4.0.7 xpp3_min deprecated 1.1.4c xstream deprecated 1.3.1 org.apache.maven.plugins maven-compiler-plugin 1.5 1.5 true 1024m 1024m org.codehaus.mojo javacc-maven-plugin 2.4.1 diff --git a/jvm-serializers-tpc/src/main/java/com/google/protobuf/JsonFormat.java b/jvm-serializers-tpc/src/main/java/com/google/protobuf/JsonFormat.java new file mode 100644 index 0000000..a0a8305 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/com/google/protobuf/JsonFormat.java @@ -0,0 +1,1395 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// http://code.google.com/p/protobuf/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +package com.google.protobuf; + +import java.io.IOException; +import java.math.BigInteger; +import java.nio.CharBuffer; +import java.util.Iterator; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import com.google.protobuf.ByteString; +import com.google.protobuf.ExtensionRegistry; +import com.google.protobuf.Message; +import com.google.protobuf.UnknownFieldSet; +import com.google.protobuf.Descriptors.Descriptor; +import com.google.protobuf.Descriptors.EnumDescriptor; +import com.google.protobuf.Descriptors.EnumValueDescriptor; +import com.google.protobuf.Descriptors.FieldDescriptor; + +/** + * Copied from http://code.google.com/p/protobuf/issues/detail?id=82 + * + * Provide ascii text parsing and formatting support for proto2 instances. The implementation + * largely follows google/protobuf/text_format.cc. + * + * @author aantonov@orbitz.com Alex Antonov + *

+ * Based on the original code by: + * @author wenboz@google.com Wenbo Zhu + * @author kenton@google.com Kenton Varda + */ +@SuppressWarnings({"serial"}) +public final class JsonFormat { + + /** + * Outputs a textual representation of the Protocol Message supplied into the parameter output. + * (This representation is the new version of the classic "ProtocolPrinter" output from the + * original Protocol Buffer system) + */ + public static void print(Message message, Appendable output) throws IOException { + JsonGenerator generator = new JsonGenerator(output); + generator.print("{"); + print(message, generator); + generator.print("}"); + } + + /** + * Outputs a textual representation of {@code fields} to {@code output}. + */ + public static void print(UnknownFieldSet fields, Appendable output) throws IOException { + JsonGenerator generator = new JsonGenerator(output); + generator.print("{"); + printUnknownFields(fields, generator); + generator.print("}"); + } + + /** + * Like {@code print()}, but writes directly to a {@code String} and returns it. + */ + public static String printToString(Message message) { + try { + StringBuilder text = new StringBuilder(); + print(message, text); + return text.toString(); + } catch (IOException e) { + throw new RuntimeException("Writing to a StringBuilder threw an IOException (should never " + + "happen).", + e); + } + } + + /** + * Like {@code print()}, but writes directly to a {@code String} and returns it. + */ + public static String printToString(UnknownFieldSet fields) { + try { + StringBuilder text = new StringBuilder(); + print(fields, text); + return text.toString(); + } catch (IOException e) { + throw new RuntimeException("Writing to a StringBuilder threw an IOException (should never " + + "happen).", + e); + } + } + + private static void print(Message message, JsonGenerator generator) throws IOException { + + for (Iterator> iter = message.getAllFields().entrySet().iterator(); iter.hasNext();) { + Map.Entry field = iter.next(); + printField(field.getKey(), field.getValue(), generator); + if (iter.hasNext()) { + generator.print(","); + } + } + printUnknownFields(message.getUnknownFields(), generator); + } + + public static void printField(FieldDescriptor field, Object value, JsonGenerator generator) throws IOException { + + printSingleField(field, value, generator); + } + + private static void printSingleField(FieldDescriptor field, + Object value, + JsonGenerator generator) throws IOException { + if (field.isExtension()) { + generator.print("["); + generator.print("\""); + // We special-case MessageSet elements for compatibility with proto1. + if (field.getContainingType().getOptions().getMessageSetWireFormat() + && (field.getType() == FieldDescriptor.Type.MESSAGE) && (field.isOptional()) + // object equality + && (field.getExtensionScope() == field.getMessageType())) { + generator.print(field.getMessageType().getFullName()); + } else { + generator.print(field.getFullName()); + } + generator.print("\""); + generator.print("]"); + } else { + generator.print("\""); + if (field.getType() == FieldDescriptor.Type.GROUP) { + // Groups must be serialized with their original capitalization. + generator.print(field.getMessageType().getName()); + } else { + generator.print(field.getName()); + } + generator.print("\""); + } + + // Done with the name, on to the value + + if (field.getJavaType() == FieldDescriptor.JavaType.MESSAGE) { + generator.print(": "); + generator.indent(); + } else { + generator.print(": "); + } + + + if (field.isRepeated()) { + // Repeated field. Print each element. + generator.print("["); + for (Iterator iter = ((List) value).iterator(); iter.hasNext();) { + printFieldValue(field, iter.next(), generator); + if (iter.hasNext()) { + generator.print(","); + } + } + generator.print("]"); + } else { + printFieldValue(field, value, generator); + if (field.getJavaType() == FieldDescriptor.JavaType.MESSAGE) { + generator.outdent(); + } + } + } + + private static void printFieldValue(FieldDescriptor field, Object value, JsonGenerator generator) throws IOException { + switch (field.getType()) { + case INT32: + case INT64: + case SINT32: + case SINT64: + case SFIXED32: + case SFIXED64: + case FLOAT: + case DOUBLE: + case BOOL: + // Good old toString() does what we want for these types. + generator.print(value.toString()); + break; + + case UINT32: + case FIXED32: + generator.print(unsignedToString((Integer) value)); + break; + + case UINT64: + case FIXED64: + generator.print(unsignedToString((Long) value)); + break; + + case STRING: + generator.print("\""); + generator.print(escapeText((String) value)); + generator.print("\""); + break; + + case BYTES: { + generator.print("\""); + generator.print(escapeBytes((ByteString) value)); + generator.print("\""); + break; + } + + case ENUM: { + generator.print("\""); + generator.print(((EnumValueDescriptor) value).getName()); + generator.print("\""); + break; + } + + case MESSAGE: + case GROUP: + generator.print("{"); + print((Message) value, generator); + generator.print("}"); + break; + } + } + + private static void printUnknownFields(UnknownFieldSet unknownFields, JsonGenerator generator) throws IOException { + for (Map.Entry entry : unknownFields.asMap().entrySet()) { +// String prefix = entry.getKey().toString() + ": "; + UnknownFieldSet.Field field = entry.getValue(); + + for (long value : field.getVarintList()) { + generator.print("\""); + generator.print(entry.getKey().toString()); + generator.print("\""); + generator.print(": "); + generator.print(unsignedToString(value)); + generator.print("\n"); + } + for (int value : field.getFixed32List()) { + generator.print("\""); + generator.print(entry.getKey().toString()); + generator.print("\""); + generator.print(": "); + generator.print(String.format((Locale) null, "0x%08x", value)); + generator.print("\n"); + } + for (long value : field.getFixed64List()) { + generator.print(entry.getKey().toString()); + generator.print(": "); + generator.print(String.format((Locale) null, "0x%016x", value)); + generator.print("\n"); + } + for (ByteString value : field.getLengthDelimitedList()) { + generator.print(entry.getKey().toString()); + generator.print(": \""); + generator.print(escapeBytes(value)); + generator.print("\"\n"); + } + for (UnknownFieldSet value : field.getGroupList()) { + generator.print(entry.getKey().toString()); + generator.print(" {\n"); + generator.indent(); + printUnknownFields(value, generator); + generator.outdent(); + generator.print("}\n"); + } + } + } + + /** + * Convert an unsigned 32-bit integer to a string. + */ + private static String unsignedToString(int value) { + if (value >= 0) { + return Integer.toString(value); + } else { + return Long.toString((value) & 0x00000000FFFFFFFFL); + } + } + + /** + * Convert an unsigned 64-bit integer to a string. + */ + private static String unsignedToString(long value) { + if (value >= 0) { + return Long.toString(value); + } else { + // Pull off the most-significant bit so that BigInteger doesn't think + // the number is negative, then set it again using setBit(). + return BigInteger.valueOf(value & 0x7FFFFFFFFFFFFFFFL).setBit(63).toString(); + } + } + + /** + * An inner class for writing text to the output stream. + */ + static private final class JsonGenerator { + + Appendable output; + boolean atStartOfLine = true; + StringBuilder indent = new StringBuilder(); + + public JsonGenerator(Appendable output) { + this.output = output; + } + + /** + * Indent text by two spaces. After calling Indent(), two spaces will be inserted at the + * beginning of each line of text. Indent() may be called multiple times to produce deeper + * indents. + */ + public void indent() { + indent.append(" "); + } + + /** + * Reduces the current indent level by two spaces, or crashes if the indent level is zero. + */ + public void outdent() { + int length = indent.length(); + if (length == 0) { + throw new IllegalArgumentException(" Outdent() without matching Indent()."); + } + indent.delete(length - 2, length); + } + + /** + * Print text to the output stream. + */ + public void print(CharSequence text) throws IOException { + int size = text.length(); + int pos = 0; + + for (int i = 0; i < size; i++) { + if (text.charAt(i) == '\n') { + write(text.subSequence(pos, size), i - pos + 1); + pos = i + 1; + atStartOfLine = true; + } + } + write(text.subSequence(pos, size), size - pos); + } + + /** + * Appends text to the output stream without starting a new line after it. + */ + @SuppressWarnings("unused") + public void append(CharSequence text) throws IOException { + int size = text.length(); + int pos = 0; + + for (int i = 0; i < size; i++) { + if (text.charAt(i) == '\n') { + write(text.subSequence(pos, size), i - pos + 1); + pos = i + 1; + atStartOfLine = false; + } + } + write(text.subSequence(pos, size), size - pos); + } + + private void write(CharSequence data, int size) throws IOException { + if (size == 0) { + return; + } + if (atStartOfLine) { + atStartOfLine = false; + output.append(indent); + } + output.append(data); + } + } + + // ================================================================= + // Parsing + + /** + * Represents a stream of tokens parsed from a {@code String}. + *

+ *

+ * The Java standard library provides many classes that you might think would be useful for + * implementing this, but aren't. For example: + *

+ *

    + *
  • {@code java.io.StreamTokenizer}: This almost does what we want -- or, at least, something + * that would get us close to what we want -- except for one fatal flaw: It automatically + * un-escapes strings using Java escape sequences, which do not include all the escape sequences + * we need to support (e.g. '\x'). + *
  • {@code java.util.Scanner}: This seems like a great way at least to parse regular + * expressions out of a stream (so we wouldn't have to load the entire input into a single + * string before parsing). Sadly, {@code Scanner} requires that tokens be delimited with some + * delimiter. Thus, although the text "foo:" should parse to two tokens ("foo" and ":"), {@code + * Scanner} would recognize it only as a single token. Furthermore, {@code Scanner} provides no + * way to inspect the contents of delimiters, making it impossible to keep track of line and + * column numbers. + *
+ *

+ *

+ * Luckily, Java's regular expression support does manage to be useful to us. (Barely: We need + * {@code Matcher.usePattern()}, which is new in Java 1.5.) So, we can use that, at least. + * Unfortunately, this implies that we need to have the entire input in one contiguous string. + */ + private static final class Tokenizer { + + private final CharSequence text; + private final Matcher matcher; + private String currentToken; + + // The character index within this.text at which the current token begins. + private int pos = 0; + + // The line and column numbers of the current token. + private int line = 0; + private int column = 0; + + // The line and column numbers of the previous token (allows throwing + // errors *after* consuming). + private int previousLine = 0; + private int previousColumn = 0; + + private static Pattern WHITESPACE = Pattern.compile("(\\s|(#.*$))+", Pattern.MULTILINE); + private static Pattern TOKEN = Pattern.compile("[a-zA-Z_][0-9a-zA-Z_+-]*|" + // an + // identifier + "[0-9+-][0-9a-zA-Z_.+-]*|" + // a number + "\"([^\"\n\\\\]|\\\\.)*(\"|\\\\?$)|" + // a + // double-quoted + // string + "\'([^\"\n\\\\]|\\\\.)*(\'|\\\\?$)", // a + // single-quoted + // string + Pattern.MULTILINE); + + private static Pattern DOUBLE_INFINITY = Pattern.compile("-?inf(inity)?", + Pattern.CASE_INSENSITIVE); + private static Pattern FLOAT_INFINITY = Pattern.compile("-?inf(inity)?f?", + Pattern.CASE_INSENSITIVE); + private static Pattern FLOAT_NAN = Pattern.compile("nanf?", Pattern.CASE_INSENSITIVE); + + /** + * Construct a tokenizer that parses tokens from the given text. + */ + public Tokenizer(CharSequence text) { + this.text = text; + matcher = WHITESPACE.matcher(text); + skipWhitespace(); + nextToken(); + } + + /** + * Are we at the end of the input? + */ + public boolean atEnd() { + return currentToken.length() == 0; + } + + /** + * Advance to the next token. + */ + public void nextToken() { + previousLine = line; + previousColumn = column; + + // Advance the line counter to the current position. + while (pos < matcher.regionStart()) { + if (text.charAt(pos) == '\n') { + ++line; + column = 0; + } else { + ++column; + } + ++pos; + } + + // Match the next token. + if (matcher.regionStart() == matcher.regionEnd()) { + // EOF + currentToken = ""; + } else { + matcher.usePattern(TOKEN); + if (matcher.lookingAt()) { + currentToken = matcher.group(); + matcher.region(matcher.end(), matcher.regionEnd()); + } else { + // Take one character. + currentToken = String.valueOf(text.charAt(pos)); + matcher.region(pos + 1, matcher.regionEnd()); + } + + skipWhitespace(); + } + } + + /** + * Skip over any whitespace so that the matcher region starts at the next token. + */ + private void skipWhitespace() { + matcher.usePattern(WHITESPACE); + if (matcher.lookingAt()) { + matcher.region(matcher.end(), matcher.regionEnd()); + } + } + + /** + * If the next token exactly matches {@code token}, consume it and return {@code true}. + * Otherwise, return {@code false} without doing anything. + */ + public boolean tryConsume(String token) { + if (currentToken.equals(token)) { + nextToken(); + return true; + } else { + return false; + } + } + + /** + * If the next token exactly matches {@code token}, consume it. Otherwise, throw a + * {@link ParseException}. + */ + public void consume(String token) throws ParseException { + if (!tryConsume(token)) { + throw parseException("Expected \"" + token + "\"."); + } + } + + /** + * Returns {@code true} if the next token is an integer, but does not consume it. + */ + public boolean lookingAtInteger() { + if (currentToken.length() == 0) { + return false; + } + + char c = currentToken.charAt(0); + return (('0' <= c) && (c <= '9')) || (c == '-') || (c == '+'); + } + + /** + * If the next token is an identifier, consume it and return its value. Otherwise, throw a + * {@link ParseException}. + */ + public String consumeIdentifier() throws ParseException { + for (int i = 0; i < currentToken.length(); i++) { + char c = currentToken.charAt(i); + if ((('a' <= c) && (c <= 'z')) || (('A' <= c) && (c <= 'Z')) + || (('0' <= c) && (c <= '9')) || (c == '_') || (c == '.') || (c == '"')) { + // OK + } else { + throw parseException("Expected identifier. -" + c); + } + } + + String result = currentToken; + // Need to clean-up result to remove quotes of any kind + result = result.replaceAll("\"|'", ""); + nextToken(); + return result; + } + + /** + * If the next token is a 32-bit signed integer, consume it and return its value. Otherwise, + * throw a {@link ParseException}. + */ + public int consumeInt32() throws ParseException { + try { + int result = parseInt32(currentToken); + nextToken(); + return result; + } catch (NumberFormatException e) { + throw integerParseException(e); + } + } + + /** + * If the next token is a 32-bit unsigned integer, consume it and return its value. + * Otherwise, throw a {@link ParseException}. + */ + public int consumeUInt32() throws ParseException { + try { + int result = parseUInt32(currentToken); + nextToken(); + return result; + } catch (NumberFormatException e) { + throw integerParseException(e); + } + } + + /** + * If the next token is a 64-bit signed integer, consume it and return its value. Otherwise, + * throw a {@link ParseException}. + */ + public long consumeInt64() throws ParseException { + try { + long result = parseInt64(currentToken); + nextToken(); + return result; + } catch (NumberFormatException e) { + throw integerParseException(e); + } + } + + /** + * If the next token is a 64-bit unsigned integer, consume it and return its value. + * Otherwise, throw a {@link ParseException}. + */ + public long consumeUInt64() throws ParseException { + try { + long result = parseUInt64(currentToken); + nextToken(); + return result; + } catch (NumberFormatException e) { + throw integerParseException(e); + } + } + + /** + * If the next token is a double, consume it and return its value. Otherwise, throw a + * {@link ParseException}. + */ + public double consumeDouble() throws ParseException { + // We need to parse infinity and nan separately because + // Double.parseDouble() does not accept "inf", "infinity", or "nan". + if (DOUBLE_INFINITY.matcher(currentToken).matches()) { + boolean negative = currentToken.startsWith("-"); + nextToken(); + return negative ? Double.NEGATIVE_INFINITY : Double.POSITIVE_INFINITY; + } + if (currentToken.equalsIgnoreCase("nan")) { + nextToken(); + return Double.NaN; + } + try { + double result = Double.parseDouble(currentToken); + nextToken(); + return result; + } catch (NumberFormatException e) { + throw floatParseException(e); + } + } + + /** + * If the next token is a float, consume it and return its value. Otherwise, throw a + * {@link ParseException}. + */ + public float consumeFloat() throws ParseException { + // We need to parse infinity and nan separately because + // Float.parseFloat() does not accept "inf", "infinity", or "nan". + if (FLOAT_INFINITY.matcher(currentToken).matches()) { + boolean negative = currentToken.startsWith("-"); + nextToken(); + return negative ? Float.NEGATIVE_INFINITY : Float.POSITIVE_INFINITY; + } + if (FLOAT_NAN.matcher(currentToken).matches()) { + nextToken(); + return Float.NaN; + } + try { + float result = Float.parseFloat(currentToken); + nextToken(); + return result; + } catch (NumberFormatException e) { + throw floatParseException(e); + } + } + + /** + * If the next token is a boolean, consume it and return its value. Otherwise, throw a + * {@link ParseException}. + */ + public boolean consumeBoolean() throws ParseException { + if (currentToken.equals("true")) { + nextToken(); + return true; + } else if (currentToken.equals("false")) { + nextToken(); + return false; + } else { + throw parseException("Expected \"true\" or \"false\"."); + } + } + + /** + * If the next token is a string, consume it and return its (unescaped) value. Otherwise, + * throw a {@link ParseException}. + */ + public String consumeString() throws ParseException { + return consumeByteString().toStringUtf8(); + } + + /** + * If the next token is a string, consume it, unescape it as a + * {@link com.google.protobuf.ByteString}, and return it. Otherwise, throw a + * {@link ParseException}. + */ + public ByteString consumeByteString() throws ParseException { + char quote = currentToken.length() > 0 ? currentToken.charAt(0) : '\0'; + if ((quote != '\"') && (quote != '\'')) { + throw parseException("Expected string."); + } + + if ((currentToken.length() < 2) + || (currentToken.charAt(currentToken.length() - 1) != quote)) { + throw parseException("String missing ending quote."); + } + + try { + String escaped = currentToken.substring(1, currentToken.length() - 1); + ByteString result = unescapeBytes(escaped); + nextToken(); + return result; + } catch (InvalidEscapeSequence e) { + throw parseException(e.getMessage()); + } + } + + /** + * Returns a {@link ParseException} with the current line and column numbers in the + * description, suitable for throwing. + */ + public ParseException parseException(String description) { + // Note: People generally prefer one-based line and column numbers. + return new ParseException((line + 1) + ":" + (column + 1) + ": " + description); + } + + /** + * Returns a {@link ParseException} with the line and column numbers of the previous token + * in the description, suitable for throwing. + */ + public ParseException parseExceptionPreviousToken(String description) { + // Note: People generally prefer one-based line and column numbers. + return new ParseException((previousLine + 1) + ":" + (previousColumn + 1) + ": " + + description); + } + + /** + * Constructs an appropriate {@link ParseException} for the given {@code + * NumberFormatException} when trying to parse an integer. + */ + private ParseException integerParseException(NumberFormatException e) { + return parseException("Couldn't parse integer: " + e.getMessage()); + } + + /** + * Constructs an appropriate {@link ParseException} for the given {@code + * NumberFormatException} when trying to parse a float or double. + */ + private ParseException floatParseException(NumberFormatException e) { + return parseException("Couldn't parse number: " + e.getMessage()); + } + } + + /** + * Thrown when parsing an invalid text format message. + */ + public static class ParseException extends IOException { + + public ParseException(String message) { + super(message); + } + } + + /** + * Parse a text-format message from {@code input} and merge the contents into {@code builder}. + */ + public static void merge(Readable input, Message.Builder builder) throws ParseException, + IOException { + JsonFormat.merge(input, ExtensionRegistry.getEmptyRegistry(), builder); + } + + /** + * Parse a text-format message from {@code input} and merge the contents into {@code builder}. + */ + public static void merge(CharSequence input, Message.Builder builder) throws ParseException { + merge(input, ExtensionRegistry.getEmptyRegistry(), builder); + } + + /** + * Parse a text-format message from {@code input} and merge the contents into {@code builder}. + * Extensions will be recognized if they are registered in {@code extensionRegistry}. + */ + public static void merge(Readable input, + ExtensionRegistry extensionRegistry, + Message.Builder builder) throws ParseException, IOException { + // Read the entire input to a String then parse that. + + // If StreamTokenizer were not quite so crippled, or if there were a kind + // of Reader that could read in chunks that match some particular regex, + // or if we wanted to write a custom Reader to tokenize our stream, then + // we would not have to read to one big String. Alas, none of these is + // the case. Oh well. + + merge(toStringBuilder(input), extensionRegistry, builder); + } + + private static final int BUFFER_SIZE = 4096; + + // TODO(chrisn): See if working around java.io.Reader#read(CharBuffer) + // overhead is worthwhile + private static StringBuilder toStringBuilder(Readable input) throws IOException { + StringBuilder text = new StringBuilder(); + CharBuffer buffer = CharBuffer.allocate(BUFFER_SIZE); + while (true) { + int n = input.read(buffer); + if (n == -1) { + break; + } + buffer.flip(); + text.append(buffer, 0, n); + } + return text; + } + + /** + * Parse a text-format message from {@code input} and merge the contents into {@code builder}. + * Extensions will be recognized if they are registered in {@code extensionRegistry}. + */ + public static void merge(CharSequence input, + ExtensionRegistry extensionRegistry, + Message.Builder builder) throws ParseException { + Tokenizer tokenizer = new Tokenizer(input); + + // Based on the state machine @ http://json.org/ + + tokenizer.consume("{"); // Needs to happen when the object starts. + while (!tokenizer.tryConsume("}")) { // Continue till the object is done + mergeField(tokenizer, extensionRegistry, builder); + } + } + + /** + * Parse a single field from {@code tokenizer} and merge it into {@code builder}. If a ',' is + * detected after the field ends, the next field will be parsed automatically + */ + private static void mergeField(Tokenizer tokenizer, + ExtensionRegistry extensionRegistry, + Message.Builder builder) throws ParseException { + FieldDescriptor field; + Descriptor type = builder.getDescriptorForType(); + ExtensionRegistry.ExtensionInfo extension = null; + + if (tokenizer.tryConsume("[")) { + // An extension. + StringBuilder name = new StringBuilder(tokenizer.consumeIdentifier()); + while (tokenizer.tryConsume(".")) { + name.append("."); + name.append(tokenizer.consumeIdentifier()); + } + + extension = extensionRegistry.findExtensionByName(name.toString()); + + if (extension == null) { + throw tokenizer.parseExceptionPreviousToken("Extension \"" + + name + + "\" not found in the ExtensionRegistry."); + } else if (extension.descriptor.getContainingType() != type) { + throw tokenizer.parseExceptionPreviousToken("Extension \"" + name + + "\" does not extend message type \"" + + type.getFullName() + "\"."); + } + + tokenizer.consume("]"); + + field = extension.descriptor; + } else { + String name = tokenizer.consumeIdentifier(); + field = type.findFieldByName(name); + + // Group names are expected to be capitalized as they appear in the + // .proto file, which actually matches their type names, not their field + // names. + if (field == null) { + // Explicitly specify US locale so that this code does not break when + // executing in Turkey. + String lowerName = name.toLowerCase(Locale.US); + field = type.findFieldByName(lowerName); + // If the case-insensitive match worked but the field is NOT a group, + if ((field != null) && (field.getType() != FieldDescriptor.Type.GROUP)) { + field = null; + } + } + // Again, special-case group names as described above. + if ((field != null) && (field.getType() == FieldDescriptor.Type.GROUP) + && !field.getMessageType().getName().equals(name)) { + field = null; + } + + if (field == null) { + throw tokenizer.parseExceptionPreviousToken("Message type \"" + type.getFullName() + + "\" has no field named \"" + name + + "\"."); + } + } + + tokenizer.consume(":"); + boolean array = tokenizer.tryConsume("["); + + if (array) { + while (!tokenizer.tryConsume("]")) { + handleValue(tokenizer, extensionRegistry, builder, field, extension); + tokenizer.tryConsume(","); + } + } else { + handleValue(tokenizer, extensionRegistry, builder, field, extension); + } + + if (tokenizer.tryConsume(",")) { + // Continue with the next field + mergeField(tokenizer, extensionRegistry, builder); + } + } + + private static void handleValue(Tokenizer tokenizer, + ExtensionRegistry extensionRegistry, + Message.Builder builder, + FieldDescriptor field, + ExtensionRegistry.ExtensionInfo extension) throws ParseException { + + Object value = null; + if (field.getJavaType() == FieldDescriptor.JavaType.MESSAGE) { + value = handleObject(tokenizer, extensionRegistry, builder, field, extension); + } else { + value = handlePrimitive(tokenizer, field); + } + if (field.isRepeated()) { + builder.addRepeatedField(field, value); + } else { + builder.setField(field, value); + } + } + + private static Object handlePrimitive(Tokenizer tokenizer, FieldDescriptor field) throws ParseException { + Object value = null; + switch (field.getType()) { + case INT32: + case SINT32: + case SFIXED32: + value = tokenizer.consumeInt32(); + break; + + case INT64: + case SINT64: + case SFIXED64: + value = tokenizer.consumeInt64(); + break; + + case UINT32: + case FIXED32: + value = tokenizer.consumeUInt32(); + break; + + case UINT64: + case FIXED64: + value = tokenizer.consumeUInt64(); + break; + + case FLOAT: + value = tokenizer.consumeFloat(); + break; + + case DOUBLE: + value = tokenizer.consumeDouble(); + break; + + case BOOL: + value = tokenizer.consumeBoolean(); + break; + + case STRING: + value = tokenizer.consumeString(); + break; + + case BYTES: + value = tokenizer.consumeByteString(); + break; + + case ENUM: { + EnumDescriptor enumType = field.getEnumType(); + + if (tokenizer.lookingAtInteger()) { + int number = tokenizer.consumeInt32(); + value = enumType.findValueByNumber(number); + if (value == null) { + throw tokenizer.parseExceptionPreviousToken("Enum type \"" + + enumType.getFullName() + + "\" has no value with number " + + number + "."); + } + } else { + String id = tokenizer.consumeIdentifier(); + value = enumType.findValueByName(id); + if (value == null) { + throw tokenizer.parseExceptionPreviousToken("Enum type \"" + + enumType.getFullName() + + "\" has no value named \"" + + id + "\"."); + } + } + + break; + } + + case MESSAGE: + case GROUP: + throw new RuntimeException("Can't get here."); + } + return value; + } + + private static Object handleObject(Tokenizer tokenizer, + ExtensionRegistry extensionRegistry, + Message.Builder builder, + FieldDescriptor field, + ExtensionRegistry.ExtensionInfo extension) throws ParseException { + + Object value; + Message.Builder subBuilder; + if (extension == null) { + subBuilder = builder.newBuilderForField(field); + } else { + subBuilder = extension.defaultInstance.newBuilderForType(); + } + + tokenizer.consume("{"); + String endToken = "}"; + + while (!tokenizer.tryConsume(endToken)) { + if (tokenizer.atEnd()) { + throw tokenizer.parseException("Expected \"" + endToken + "\"."); + } + mergeField(tokenizer, extensionRegistry, subBuilder); + if (tokenizer.tryConsume(",")) { + // there are more fields in the object, so continue + continue; + } + } + + value = subBuilder.build(); + return value; + } + + // ================================================================= + // Utility functions + // + // Some of these methods are package-private because Descriptors.java uses + // them. + + /** + * Escapes bytes in the format used in protocol buffer text format, which is the same as the + * format used for C string literals. All bytes that are not printable 7-bit ASCII characters + * are escaped, as well as backslash, single-quote, and double-quote characters. Characters for + * which no defined short-hand escape sequence is defined will be escaped using 3-digit octal + * sequences. + */ + static String escapeBytes(ByteString input) { + StringBuilder builder = new StringBuilder(input.size()); + for (int i = 0; i < input.size(); i++) { + byte b = input.byteAt(i); + switch (b) { + // Java does not recognize \a or \v, apparently. + case 0x07: + builder.append("\\a"); + break; + case '\b': + builder.append("\\b"); + break; + case '\f': + builder.append("\\f"); + break; + case '\n': + builder.append("\\n"); + break; + case '\r': + builder.append("\\r"); + break; + case '\t': + builder.append("\\t"); + break; + case 0x0b: + builder.append("\\v"); + break; + case '\\': + builder.append("\\\\"); + break; + case '\'': + builder.append("\\\'"); + break; + case '"': + builder.append("\\\""); + break; + default: + if (b >= 0x20) { + builder.append((char) b); + } else { + builder.append('\\'); + builder.append((char) ('0' + ((b >>> 6) & 3))); + builder.append((char) ('0' + ((b >>> 3) & 7))); + builder.append((char) ('0' + (b & 7))); + } + break; + } + } + return builder.toString(); + } + + /** + * Un-escape a byte sequence as escaped using + * {@link #escapeBytes(com.google.protobuf.ByteString)}. Two-digit hex escapes (starting with + * "\x") are also recognized. + */ + static ByteString unescapeBytes(CharSequence input) throws InvalidEscapeSequence { + byte[] result = new byte[input.length()]; + int pos = 0; + for (int i = 0; i < input.length(); i++) { + char c = input.charAt(i); + if (c == '\\') { + if (i + 1 < input.length()) { + ++i; + c = input.charAt(i); + if (isOctal(c)) { + // Octal escape. + int code = digitValue(c); + if ((i + 1 < input.length()) && isOctal(input.charAt(i + 1))) { + ++i; + code = code * 8 + digitValue(input.charAt(i)); + } + if ((i + 1 < input.length()) && isOctal(input.charAt(i + 1))) { + ++i; + code = code * 8 + digitValue(input.charAt(i)); + } + result[pos++] = (byte) code; + } else { + switch (c) { + case 'a': + result[pos++] = 0x07; + break; + case 'b': + result[pos++] = '\b'; + break; + case 'f': + result[pos++] = '\f'; + break; + case 'n': + result[pos++] = '\n'; + break; + case 'r': + result[pos++] = '\r'; + break; + case 't': + result[pos++] = '\t'; + break; + case 'v': + result[pos++] = 0x0b; + break; + case '\\': + result[pos++] = '\\'; + break; + case '\'': + result[pos++] = '\''; + break; + case '"': + result[pos++] = '\"'; + break; + + case 'x': + // hex escape + int code = 0; + if ((i + 1 < input.length()) && isHex(input.charAt(i + 1))) { + ++i; + code = digitValue(input.charAt(i)); + } else { + throw new InvalidEscapeSequence("Invalid escape sequence: '\\x' with no digits"); + } + if ((i + 1 < input.length()) && isHex(input.charAt(i + 1))) { + ++i; + code = code * 16 + digitValue(input.charAt(i)); + } + result[pos++] = (byte) code; + break; + + default: + throw new InvalidEscapeSequence("Invalid escape sequence: '\\" + c + + "'"); + } + } + } else { + throw new InvalidEscapeSequence("Invalid escape sequence: '\\' at end of string."); + } + } else { + result[pos++] = (byte) c; + } + } + + return ByteString.copyFrom(result, 0, pos); + } + + /** + * Thrown by {@link JsonFormat#unescapeBytes} and {@link JsonFormat#unescapeText} when an + * invalid escape sequence is seen. + */ + static class InvalidEscapeSequence extends IOException { + + public InvalidEscapeSequence(String description) { + super(description); + } + } + + /** + * Like {@link #escapeBytes(com.google.protobuf.ByteString)}, but escapes a text string. + * Non-ASCII characters are first encoded as UTF-8, then each byte is escaped individually as a + * 3-digit octal escape. Yes, it's weird. + */ + static String escapeText(String input) { + return escapeBytes(ByteString.copyFromUtf8(input)); + } + + /** + * Un-escape a text string as escaped using {@link #escapeText(String)}. Two-digit hex escapes + * (starting with "\x") are also recognized. + */ + static String unescapeText(String input) throws InvalidEscapeSequence { + return unescapeBytes(input).toStringUtf8(); + } + + /** + * Is this an octal digit? + */ + private static boolean isOctal(char c) { + return ('0' <= c) && (c <= '7'); + } + + /** + * Is this a hex digit? + */ + private static boolean isHex(char c) { + return (('0' <= c) && (c <= '9')) || (('a' <= c) && (c <= 'f')) + || (('A' <= c) && (c <= 'F')); + } + + /** + * Interpret a character as a digit (in any base up to 36) and return the numeric value. This is + * like {@code Character.digit()} but we don't accept non-ASCII digits. + */ + private static int digitValue(char c) { + if (('0' <= c) && (c <= '9')) { + return c - '0'; + } else if (('a' <= c) && (c <= 'z')) { + return c - 'a' + 10; + } else { + return c - 'A' + 10; + } + } + + /** + * Parse a 32-bit signed integer from the text. Unlike the Java standard {@code + * Integer.parseInt()}, this function recognizes the prefixes "0x" and "0" to signify + * hexidecimal and octal numbers, respectively. + */ + static int parseInt32(String text) throws NumberFormatException { + return (int) parseInteger(text, true, false); + } + + /** + * Parse a 32-bit unsigned integer from the text. Unlike the Java standard {@code + * Integer.parseInt()}, this function recognizes the prefixes "0x" and "0" to signify + * hexidecimal and octal numbers, respectively. The result is coerced to a (signed) {@code int} + * when returned since Java has no unsigned integer type. + */ + static int parseUInt32(String text) throws NumberFormatException { + return (int) parseInteger(text, false, false); + } + + /** + * Parse a 64-bit signed integer from the text. Unlike the Java standard {@code + * Integer.parseInt()}, this function recognizes the prefixes "0x" and "0" to signify + * hexidecimal and octal numbers, respectively. + */ + static long parseInt64(String text) throws NumberFormatException { + return parseInteger(text, true, true); + } + + /** + * Parse a 64-bit unsigned integer from the text. Unlike the Java standard {@code + * Integer.parseInt()}, this function recognizes the prefixes "0x" and "0" to signify + * hexidecimal and octal numbers, respectively. The result is coerced to a (signed) {@code long} + * when returned since Java has no unsigned long type. + */ + static long parseUInt64(String text) throws NumberFormatException { + return parseInteger(text, false, true); + } + + private static long parseInteger(String text, boolean isSigned, boolean isLong) throws NumberFormatException { + int pos = 0; + + boolean negative = false; + if (text.startsWith("-", pos)) { + if (!isSigned) { + throw new NumberFormatException("Number must be positive: " + text); + } + ++pos; + negative = true; + } + + int radix = 10; + if (text.startsWith("0x", pos)) { + pos += 2; + radix = 16; + } else if (text.startsWith("0", pos)) { + radix = 8; + } + + String numberText = text.substring(pos); + + long result = 0; + if (numberText.length() < 16) { + // Can safely assume no overflow. + result = Long.parseLong(numberText, radix); + if (negative) { + result = -result; + } + + // Check bounds. + // No need to check for 64-bit numbers since they'd have to be 16 chars + // or longer to overflow. + if (!isLong) { + if (isSigned) { + if ((result > Integer.MAX_VALUE) || (result < Integer.MIN_VALUE)) { + throw new NumberFormatException("Number out of range for 32-bit signed integer: " + + text); + } + } else { + if ((result >= (1L << 32)) || (result < 0)) { + throw new NumberFormatException("Number out of range for 32-bit unsigned integer: " + + text); + } + } + } + } else { + BigInteger bigValue = new BigInteger(numberText, radix); + if (negative) { + bigValue = bigValue.negate(); + } + + // Check bounds. + if (!isLong) { + if (isSigned) { + if (bigValue.bitLength() > 31) { + throw new NumberFormatException("Number out of range for 32-bit signed integer: " + + text); + } + } else { + if (bigValue.bitLength() > 32) { + throw new NumberFormatException("Number out of range for 32-bit unsigned integer: " + + text); + } + } + } else { + if (isSigned) { + if (bigValue.bitLength() > 63) { + throw new NumberFormatException("Number out of range for 64-bit signed integer: " + + text); + } + } else { + if (bigValue.bitLength() > 64) { + throw new NumberFormatException("Number out of range for 64-bit unsigned integer: " + + text); + } + } + } + + result = bigValue.longValue(); + } + + return result; + } +} diff --git a/jvm-serializers-tpc/src/main/java/data/ReprUtil.java b/jvm-serializers-tpc/src/main/java/data/ReprUtil.java new file mode 100644 index 0000000..4593071 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/data/ReprUtil.java @@ -0,0 +1,23 @@ +package data; + +public class ReprUtil +{ + public static String repr(String s) + { + if (s == null) return "null"; + return '"' + s + '"'; + } + + public static String repr(Iterable it) + { + StringBuilder buf = new StringBuilder(); + buf.append('['); + String sep = ""; + for (String s : it) { + buf.append(sep); sep = ", "; + buf.append(repr(s)); + } + buf.append(']'); + return buf.toString(); + } +} diff --git a/jvm-serializers-tpc/src/main/java/data/media/FieldMapping.java b/jvm-serializers-tpc/src/main/java/data/media/FieldMapping.java new file mode 100644 index 0000000..b57946f --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/data/media/FieldMapping.java @@ -0,0 +1,85 @@ +package data.media; + +import java.util.HashMap; + +public final class FieldMapping +{ + public final static int FIELD_IX_MEDIA = 1; + public final static String FULL_FIELD_NAME_MEDIA = "media"; + public final static int FIELD_IX_IMAGES = 2; + public final static String FULL_FIELD_NAME_IMAGES = "images"; + public final static int FIELD_IX_PLAYER = 3; + public final static String FULL_FIELD_NAME_PLAYER = "player"; + public final static int FIELD_IX_URI = 4; + public final static String FULL_FIELD_NAME_URI = "uri"; + public final static int FIELD_IX_TITLE = 5; + public final static String FULL_FIELD_NAME_TITLE = "title"; + public final static int FIELD_IX_WIDTH = 6; + public final static String FULL_FIELD_NAME_WIDTH = "width"; + public final static int FIELD_IX_HEIGHT = 7; + public final static String FULL_FIELD_NAME_HEIGHT = "height"; + public final static int FIELD_IX_FORMAT = 8; + public final static String FULL_FIELD_NAME_FORMAT = "format"; + public final static int FIELD_IX_DURATION = 9; + public final static String FULL_FIELD_NAME_DURATION = "duration"; + public final static int FIELD_IX_SIZE = 10; + public final static String FULL_FIELD_NAME_SIZE = "size"; + public final static int FIELD_IX_BITRATE = 11; + public final static String FULL_FIELD_NAME_BITRATE = "bitrate"; + public final static int FIELD_IX_PERSONS = 12; + public final static String FULL_FIELD_NAME_PERSONS = "persons"; + public final static int FIELD_IX_COPYRIGHT = 13; + public final static String FULL_FIELD_NAME_COPYRIGHT = "copyright"; + + // 25-Jun-2011, tatu: Some earlier tests used minimal names; not in use any more + /* + +// public final static String FIELD_NAME_MEDIA = "md"; +// public final static String FIELD_NAME_IMAGES = "im"; +// public final static String FIELD_NAME_PLAYER = "pl"; +// public final static String FIELD_NAME_URI = "ul"; +// public final static String FIELD_NAME_TITLE = "tl"; +// public final static String FIELD_NAME_WIDTH = "wd"; +// public final static String FIELD_NAME_HEIGHT = "hg"; +// public final static String FIELD_NAME_FORMAT = "fr"; +// public final static String FIELD_NAME_DURATION = "dr"; +// public final static String FIELD_NAME_SIZE = "sz"; +// public final static String FIELD_NAME_BITRATE = "br"; +// public final static String FIELD_NAME_PERSONS = "pr"; +// public final static String FIELD_NAME_COPYRIGHT = "cp"; + + public static final HashMap fieldToIndex = new HashMap(); + static { + fieldToIndex.put(FIELD_NAME_MEDIA, FIELD_IX_MEDIA); + fieldToIndex.put(FIELD_NAME_IMAGES, FIELD_IX_IMAGES); + fieldToIndex.put(FIELD_NAME_PLAYER, FIELD_IX_PLAYER); + fieldToIndex.put(FIELD_NAME_URI, FIELD_IX_URI); + fieldToIndex.put(FIELD_NAME_TITLE, FIELD_IX_TITLE); + fieldToIndex.put(FIELD_NAME_WIDTH, FIELD_IX_WIDTH); + fieldToIndex.put(FIELD_NAME_HEIGHT, FIELD_IX_HEIGHT); + fieldToIndex.put(FIELD_NAME_FORMAT, FIELD_IX_FORMAT); + fieldToIndex.put(FIELD_NAME_DURATION, FIELD_IX_DURATION); + fieldToIndex.put(FIELD_NAME_SIZE, FIELD_IX_SIZE); + fieldToIndex.put(FIELD_NAME_BITRATE, FIELD_IX_BITRATE); + fieldToIndex.put(FIELD_NAME_PERSONS, FIELD_IX_PERSONS); + fieldToIndex.put(FIELD_NAME_COPYRIGHT, FIELD_IX_COPYRIGHT); + } + */ + + public static final HashMap fullFieldToIndex = new HashMap(); + static { + fullFieldToIndex.put(FULL_FIELD_NAME_MEDIA, FIELD_IX_MEDIA); + fullFieldToIndex.put(FULL_FIELD_NAME_IMAGES, FIELD_IX_IMAGES); + fullFieldToIndex.put(FULL_FIELD_NAME_PLAYER, FIELD_IX_PLAYER); + fullFieldToIndex.put(FULL_FIELD_NAME_URI, FIELD_IX_URI); + fullFieldToIndex.put(FULL_FIELD_NAME_TITLE, FIELD_IX_TITLE); + fullFieldToIndex.put(FULL_FIELD_NAME_WIDTH, FIELD_IX_WIDTH); + fullFieldToIndex.put(FULL_FIELD_NAME_HEIGHT, FIELD_IX_HEIGHT); + fullFieldToIndex.put(FULL_FIELD_NAME_FORMAT, FIELD_IX_FORMAT); + fullFieldToIndex.put(FULL_FIELD_NAME_DURATION, FIELD_IX_DURATION); + fullFieldToIndex.put(FULL_FIELD_NAME_SIZE, FIELD_IX_SIZE); + fullFieldToIndex.put(FULL_FIELD_NAME_BITRATE, FIELD_IX_BITRATE); + fullFieldToIndex.put(FULL_FIELD_NAME_PERSONS, FIELD_IX_PERSONS); + fullFieldToIndex.put(FULL_FIELD_NAME_COPYRIGHT, FIELD_IX_COPYRIGHT); + } +} diff --git a/jvm-serializers-tpc/src/main/java/data/media/Image.java b/jvm-serializers-tpc/src/main/java/data/media/Image.java new file mode 100644 index 0000000..1446acf --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/data/media/Image.java @@ -0,0 +1,113 @@ +package data.media; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; + +import static data.ReprUtil.repr; + +@XmlAccessorType(XmlAccessType.FIELD) +public class Image implements java.io.Serializable +{ + private static final long serialVersionUID = 1L; + + public enum Size { + SMALL, LARGE + } + + public String uri; + + public String title; // Can be null + public int width; + public int height; + public Size size; + + public Image() {} + + public Image (String uri, String title, int width, int height, Size size) { + this.height = height; + this.title = title; + this.uri = uri; + this.width = width; + this.size = size; + } + + @Override + public boolean equals(Object o) + { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + Image image = (Image) o; + + if (height != image.height) return false; + if (width != image.width) return false; + if (size != image.size) return false; + if (title != null ? !title.equals(image.title) : image.title != null) return false; + if (uri != null ? !uri.equals(image.uri) : image.uri != null) return false; + + return true; + } + + @Override + public int hashCode() + { + int result = uri != null ? uri.hashCode() : 0; + result = 31 * result + (title != null ? title.hashCode() : 0); + result = 31 * result + width; + result = 31 * result + height; + result = 31 * result + (size != null ? size.hashCode() : 0); + return result; + } + + public String toString () { + StringBuilder sb = new StringBuilder(); + sb.append("[Image "); + sb.append("uri=").append(repr(uri)); + sb.append(", title=").append(repr(title)); + sb.append(", width=").append(width); + sb.append(", height=").append(height); + sb.append(", size=").append(size); + sb.append("]"); + return sb.toString(); + } + + public void setUri(String uri) { + this.uri = uri; + } + + public void setTitle(String title) { + this.title = title; + } + + public void setWidth(int width) { + this.width = width; + } + + public void setHeight(int height) { + this.height = height; + } + + public void setSize(Size size) { + this.size = size; + } + + public String getUri() { + return uri; + } + + public String getTitle() { + return title; + } + + public int getWidth() { + return width; + } + + public int getHeight() { + return height; + } + + public Size getSize() { + return size; + } +} diff --git a/jvm-serializers-tpc/src/main/java/data/media/Media.java b/jvm-serializers-tpc/src/main/java/data/media/Media.java new file mode 100644 index 0000000..a590092 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/data/media/Media.java @@ -0,0 +1,214 @@ +package data.media; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlType; +import java.util.List; + +import static data.ReprUtil.repr; + +@SuppressWarnings("serial") +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "JaxbMedia") +public class Media implements java.io.Serializable { + public enum Player { + JAVA, FLASH; + + public static Player find(String str) { + if (str == "JAVA") return JAVA; + if (str == "FLASH") return FLASH; + if ("JAVA".equals(str)) return JAVA; + if ("FLASH".equals(str)) return FLASH; + String desc = (str == null) ? "NULL" : String.format("'%s'", str); + throw new IllegalArgumentException("No Player value of "+desc); + } + } + + public String uri; + public String title; // Can be unset. + public int width; + public int height; + public String format; + public long duration; + public long size; + public int bitrate; // Can be unset. + + @jsonij.json.annotation.JSONIgnore // required by JSONiJ + @org.codehaus.jackson.annotate.JsonIgnore // Jackson 1.x + @com.fasterxml.jackson.annotation.JsonIgnore // Jackson 2.x + public boolean hasBitrate; + + public List persons; + + public Player player; + + public String copyright; // Can be unset. + + public Media() {} + + public Media(String uri, String title, int width, int height, String format, long duration, long size, int bitrate, boolean hasBitrate, List persons, Player player, String copyright) + { + this.uri = uri; + this.title = title; + this.width = width; + this.height = height; + this.format = format; + this.duration = duration; + this.size = size; + this.bitrate = bitrate; + this.hasBitrate = hasBitrate; + this.persons = persons; + this.player = player; + this.copyright = copyright; + } + + @Override + public boolean equals(Object o) + { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + Media media = (Media) o; + + if (bitrate != media.bitrate) return false; + if (duration != media.duration) return false; + if (hasBitrate != media.hasBitrate) return false; + if (height != media.height) return false; + if (size != media.size) return false; + if (width != media.width) return false; + if (copyright != null ? !copyright.equals(media.copyright) : media.copyright != null) return false; + if (format != null ? !format.equals(media.format) : media.format != null) return false; + if (persons != null ? !persons.equals(media.persons) : media.persons != null) return false; + if (player != media.player) return false; + if (title != null ? !title.equals(media.title) : media.title != null) return false; + if (uri != null ? !uri.equals(media.uri) : media.uri != null) return false; + + return true; + } + + @Override + public int hashCode() + { + int result = uri != null ? uri.hashCode() : 0; + result = 31 * result + (title != null ? title.hashCode() : 0); + result = 31 * result + width; + result = 31 * result + height; + result = 31 * result + (format != null ? format.hashCode() : 0); + result = 31 * result + (int) (duration ^ (duration >>> 32)); + result = 31 * result + (int) (size ^ (size >>> 32)); + result = 31 * result + bitrate; + result = 31 * result + (hasBitrate ? 1 : 0); + result = 31 * result + (persons != null ? persons.hashCode() : 0); + result = 31 * result + (player != null ? player.hashCode() : 0); + result = 31 * result + (copyright != null ? copyright.hashCode() : 0); + return result; + } + + public String toString () { + StringBuilder sb = new StringBuilder(); + sb.append("[Media "); + sb.append("uri=").append(repr(uri)); + sb.append(", title=").append(repr(title)); + sb.append(", width=").append(width); + sb.append(", height=").append(height); + sb.append(", format=").append(repr(format)); + sb.append(", duration=").append(duration); + sb.append(", size=").append(size); + sb.append(", hasBitrate=").append(hasBitrate); + sb.append(", bitrate=").append(String.valueOf(bitrate)); + sb.append(", persons=").append(repr(persons)); + sb.append(", player=").append(player); + sb.append(", copyright=").append(repr(copyright)); + sb.append("]"); + return sb.toString(); + } + + public void setUri(String uri) { + this.uri = uri; + } + + public void setTitle(String title) { + this.title = title; + } + + public void setWidth(int width) { + this.width = width; + } + + public void setHeight(int height) { + this.height = height; + } + + public void setFormat(String format) { + this.format = format; + } + + public void setDuration(long duration) { + this.duration = duration; + } + + public void setSize(long size) { + this.size = size; + } + + public void setBitrate(int bitrate) { + this.bitrate = bitrate; + this.hasBitrate = true; + } + + public void setPersons(List persons) { + this.persons = persons; + } + + public void setPlayer(Player player) { + this.player = player; + } + + public void setCopyright(String copyright) { + this.copyright = copyright; + } + + public String getUri() { + return uri; + } + + public String getTitle() { + return title; + } + + public int getWidth() { + return width; + } + + public int getHeight() { + return height; + } + + public String getFormat() { + return format; + } + + public long getDuration() { + return duration; + } + + public long getSize() { + return size; + } + + public int getBitrate() { + return bitrate; + } + + public List getPersons() { + return persons; + } + + public Player getPlayer() { + return player; + } + + public String getCopyright() { + return copyright; + } +} diff --git a/jvm-serializers-tpc/src/main/java/data/media/MediaContent.java b/jvm-serializers-tpc/src/main/java/data/media/MediaContent.java new file mode 100644 index 0000000..06c4aee --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/data/media/MediaContent.java @@ -0,0 +1,69 @@ +package data.media; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlRootElement; +import java.util.List; + +@SuppressWarnings("serial") +@XmlRootElement +@XmlAccessorType(XmlAccessType.FIELD) +public class MediaContent implements java.io.Serializable +{ + public Media media; + public List images; + + public MediaContent() {} + + public MediaContent (Media media, List images) { + this.media = media; + this.images = images; + } + + @Override + public boolean equals(Object o) + { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + MediaContent that = (MediaContent) o; + + if (images != null ? !images.equals(that.images) : that.images != null) return false; + if (media != null ? !media.equals(that.media) : that.media != null) return false; + + return true; + } + + @Override + public int hashCode() + { + int result = media != null ? media.hashCode() : 0; + result = 31 * result + (images != null ? images.hashCode() : 0); + return result; + } + + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("[MediaContent: "); + sb.append("media=").append(media); + sb.append(", images=").append(images); + sb.append("]"); + return sb.toString(); + } + + public void setMedia(Media media) { + this.media = media; + } + + public void setImages(List images) { + this.images = images; + } + + public Media getMedia() { + return media; + } + + public List getImages() { + return images; + } +} diff --git a/jvm-serializers-tpc/src/main/java/data/media/MediaContentCustom.java b/jvm-serializers-tpc/src/main/java/data/media/MediaContentCustom.java new file mode 100644 index 0000000..d873ec6 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/data/media/MediaContentCustom.java @@ -0,0 +1,137 @@ +package data.media; + +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.IOException; +import java.util.ArrayList; + +// I _think_ this is for "obser" package -- should be renamed to reflect that + +public class MediaContentCustom { + private MediaContent content; + + public MediaContentCustom(MediaContent content) { + this.content = content; + } + + public MediaContent getContent() { + return content; + } + + private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException { + writeMediaContent(s, content); + } + + private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException { + content = readMediaContent(s); + } + + public static MediaContent readMediaContent(ObjectInputStream in) throws IOException + { + Media media = readMedia(in); + int numImages = in.readInt(); + ArrayList images = new ArrayList(numImages); + for (int i = 0; i < numImages; i++) { + images.add(readImage(in)); + } + return new MediaContent(media, images); + } + + + public static void writeMediaContent(ObjectOutputStream out, MediaContent m) throws IOException { + writeMedia(out, m.getMedia()); + out.writeInt(m.getImages().size()); + for (Image im : m.getImages()) { + writeImage(out, im); + } + } + + // Media + + private static Media readMedia(ObjectInputStream in) throws IOException { + String uri = in.readUTF(); + String title = readMaybeString(in); + int width = in.readInt(); + int height = in.readInt(); + String format = in.readUTF(); + long duration = in.readLong(); + long size = in.readLong(); + boolean hasBitrate = in.readBoolean(); + int bitrate = 0; + if (hasBitrate) + bitrate = in.readInt(); + int numPersons = in.readInt(); + ArrayList persons = new ArrayList(numPersons); + for (int i = 0; i < numPersons; i++) { + persons.add(in.readUTF()); + } + Media.Player player = Media.Player.values()[in.readByte()]; + String copyright = readMaybeString(in); + + return new Media(uri, title, width, height, format, duration, size, bitrate, hasBitrate, persons, player, copyright); + } + + private static void writeMedia(ObjectOutputStream out, Media m) throws IOException { + out.writeUTF(m.getUri()); + writeMaybeString(out, m.getTitle()); + out.writeInt(m.getWidth()); + out.writeInt(m.getHeight()); + out.writeUTF(m.getFormat()); + out.writeLong(m.getDuration()); + out.writeLong(m.getSize()); + writeMaybeInt(out, m.hasBitrate, m.getBitrate()); + out.writeInt(m.getPersons().size()); + for (String p : m.getPersons()) { + out.writeUTF(p); + } + out.writeByte(m.getPlayer().ordinal()); + writeMaybeString(out, m.getCopyright()); + } + + // Image + + private static Image readImage(ObjectInputStream in) throws IOException { + String uri = in.readUTF(); + String title = readMaybeString(in); + int width = in.readInt(); + int height = in.readInt(); + Image.Size size = Image.Size.values()[in.readByte()]; + + return new Image(uri, title, width, height, size); + } + + private static void writeImage(ObjectOutputStream out, Image im) throws IOException { + out.writeUTF(im.getUri()); + writeMaybeString(out, im.getTitle()); + out.writeInt(im.getWidth()); + out.writeInt(im.getHeight()); + out.writeByte(im.getSize().ordinal()); + } + + public static void writeMaybeString(ObjectOutputStream out, String s) throws IOException { + if (s != null) { + out.writeBoolean(true); + out.writeUTF(s); + } else { + out.writeBoolean(false); + } + } + + public static String readMaybeString(ObjectInputStream in) throws IOException { + if (in.readBoolean()) { + return in.readUTF(); + } else { + return null; + } + } + + public static void writeMaybeInt(ObjectOutputStream out, boolean exists, int value) throws IOException { + if (exists) { + out.writeBoolean(true); + out.writeInt(value); + } else { + out.writeBoolean(false); + } + } + +} diff --git a/jvm-serializers-tpc/src/main/java/data/media/MediaTransformer.java b/jvm-serializers-tpc/src/main/java/data/media/MediaTransformer.java new file mode 100644 index 0000000..b53e567 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/data/media/MediaTransformer.java @@ -0,0 +1,11 @@ +package data.media; + +import serializers.Transformer; + +public abstract class MediaTransformer extends Transformer +{ + public MediaContent[] sourceArray(int size) { return new MediaContent[size]; } + + // just defined to work around Scala issue + public B[] resultArray(int size) { throw new UnsupportedOperationException("Please implement for "+getClass().getName()); } +} diff --git a/jvm-serializers-tpc/src/main/java/jvm-serializers/tpc/App.java b/jvm-serializers-tpc/src/main/java/jvm-serializers/tpc/App.java new file mode 100644 index 0000000..0325a97 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/jvm-serializers/tpc/App.java @@ -0,0 +1,13 @@ +package jvm-serializers.tpc; + +/** + * Hello world! + * + */ +public class App +{ + public static void main( String[] args ) + { + System.out.println( "Hello World!" ); + } +} diff --git a/jvm-serializers-tpc/src/main/java/log4j.xml b/jvm-serializers-tpc/src/main/java/log4j.xml new file mode 100644 index 0000000..177a459 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/log4j.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jvm-serializers-tpc/src/main/java/serializers/BenchmarkBase.java b/jvm-serializers-tpc/src/main/java/serializers/BenchmarkBase.java new file mode 100644 index 0000000..6447287 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/BenchmarkBase.java @@ -0,0 +1,820 @@ +package serializers; + +import java.io.*; +import java.net.URLEncoder; +import java.util.*; +import java.util.regex.Pattern; +import java.util.zip.DeflaterOutputStream; + +/** + * Common base class for various benchmark implementations. + */ +abstract class BenchmarkBase +{ + public final static int DEFAULT_ITERATIONS = 2000; + public final static int DEFAULT_TEST_RUN_MILLIS = 10000; // 10 seconds + + /** + * Number of milliseconds to warm up for each operation type for each serializer. Let's + * start with 3 seconds. + */ + final static long DEFAULT_WARMUP_MSECS = 10000; + + // These tests aren't included by default. Use the "-hidden" flag to enable them. + protected static final HashSet HIDDEN = new HashSet(); + static { + // CKS is not included because it's not really publicly released. + HIDDEN.add("cks"); + HIDDEN.add("cks-text"); + } + + protected static final String ERROR_DIVIDER = "-------------------------------------------------------------------"; + + // ------------------------------------------------------------------------------------ + // Helper classes, enums + // ------------------------------------------------------------------------------------ + + public enum measurements + { + totalTime("total (nanos)"), timeSerialize("ser (nanos)"), + timeDeserialize("deser (nanos)"), + length("size (bytes)"), lengthDeflate("size+dfl (bytes)"), + timeCreate("create (nanos)") + ; + + public final String displayName; + + measurements(String displayName) + { + this.displayName = displayName; + } + } + + // Simple container class for config parameters from command-line + protected final static class Params + { + public int iterations = DEFAULT_ITERATIONS; + public int testRunMillis = DEFAULT_TEST_RUN_MILLIS; + public long warmupTime = DEFAULT_WARMUP_MSECS; + public boolean prewarm = true; + public Boolean filterIsInclude; + public Set filterStrings; + public boolean printChart = false; + public boolean enableHidden = false; + + // Information in input data file: + public String dataFileName; + public String dataType; // from first part of file name (comma-separated) + public String dataExtra; // from second part + public String dataExtension; // from last part of file name + } + + + // ------------------------------------------------------------------------------------ + // Actual benchmark flow + // ------------------------------------------------------------------------------------ + + protected void runBenchmark(String[] args, + TestCase testCreate, + TestCase testSerialize, + TestCase testDeserialize) + { + Params params = new Params(); + findParameters(args, params); + TestGroups groups = new TestGroups(); + addTests(groups); + runTests(groups, params, + testCreate, + testSerialize, + testDeserialize); + } + + /** + * Method called to find add actual test codecs + */ + protected abstract void addTests(TestGroups groups); + + protected void findParameters(String[] args, Params params) + { + Set optionsSeen = new HashSet(); + + for (String arg : args) { + String remainder; + if (arg.startsWith("--")) { + remainder = arg.substring(2); + } + else if (arg.startsWith("-")) { + remainder = arg.substring(1); + } + else if (params.dataFileName == null) { + params.dataFileName = arg; + continue; + } + else { + System.err.println("Expecting only one non-option argument ( = \"" + params.dataFileName + "\")."); + System.err.println("Found a second one: \"" + arg + "\""); + System.err.println("Use \"-help\" for usage information."); + System.exit(1); return; + } + String option, value; + int eqPos = remainder.indexOf('='); + if (eqPos >= 0) { + option = remainder.substring(0, eqPos); + value = remainder.substring(eqPos+1); + } else { + option = remainder; + value = null; + } + if (!optionsSeen.add(option)) { + System.err.println("Repeated option: \"" + arg + "\""); + System.exit(1); + } + if (option.equals("include")) { + if (value == null) { + System.err.println("The \"include\" option requires a value."); + System.exit(1); + } + if (params.filterIsInclude == null) { + params.filterIsInclude = true; + params.filterStrings = new HashSet(Arrays.asList(value.split(","))); + } else { + System.err.println("Can't use 'include' and 'exclude' options at the same time."); + System.exit(1); + } + } + else if (option.equals("exclude")) { + if (value == null) { + System.err.println("The \"exclude\" option requires a value."); + System.exit(1); + } + if (params.filterIsInclude == null) { + params.filterIsInclude = false; + params.filterStrings = new HashSet(Arrays.asList(value.split(","))); + } else { + System.err.println("Can't use 'include' and 'exclude' options at the same time."); + System.exit(1); + } + } + else if (option.equals("iterations")) { + if (value == null) { + System.err.println("The \"iterations\" option requires a value."); + System.exit(1); + } + try { + params.iterations = Integer.parseInt(value); + } catch (NumberFormatException ex) { + System.err.println("Invalid value for \"iterations\" option: \"" + value + "\""); + System.exit(1); + } + if (params.iterations < 1) { + System.err.println("Invalid value for \"iterations\" option: \"" + value + "\""); + System.exit(1); + } + } + else if (option.equals("testRunMillis")) { + if (value == null) { + System.err.println("The \"testRunMillis\" option requires a value."); + System.exit(1); + } + try { + params.testRunMillis = Integer.parseInt(value); + } catch (NumberFormatException ex) { + System.err.println("Invalid value for \"testRunMillis\" option: \"" + value + "\""); + System.exit(1); + } + if (params.testRunMillis < 1) { + System.err.println("Invalid value for \"testRunMillis\" option: \"" + value + "\""); + System.exit(1); + } + } + else if (option.equals("warmup-time")) { + if (value == null) { + System.err.println("The \"warmup-time\" option requires a value."); + System.exit(1); + } + try { + params.warmupTime = Long.parseLong(value); + } catch (NumberFormatException ex) { + System.err.println("Invalid value for \"warmup-time\" option: \"" + value + "\""); + System.exit(1); + } + if (params.warmupTime < 0) { + System.err.println("Invalid value for \"warmup-time\" option: \"" + value + "\""); + System.exit(1); + } + } + else if (option.equals("skip-pre-warmup")) { + if (value != null) { + System.err.println("The \"skip-pre-warmup\" option does not take a value: \"" + arg + "\""); + System.exit(1); + } + params.prewarm = false; + } + else if (option.equals("chart")) { + if (value != null) { + System.err.println("The \"chart\" option does not take a value: \"" + arg + "\""); + System.exit(1); + } + params.printChart = true; + } + else if (option.equals("hidden")) { + if (value != null) { + System.err.println("The \"hidden\" option does not take a value: \"" + arg + "\""); + System.exit(1); + } + params.enableHidden = true; + } + else if (option.equals("help")) { + if (value != null) { + System.err.println("The \"help\" option does not take a value: \"" + arg + "\""); + System.exit(1); + } + if (args.length != 1) { + System.err.println("The \"help\" option cannot be combined with any other option."); + System.exit(1); + } + System.out.println(); + System.out.println("Usage: run [options] "); + System.out.println(); + System.out.println("Options:"); + System.out.println(" -iterations=n [default=" + DEFAULT_ITERATIONS + "]"); + System.out.println(" -testRunMillis=n [default=" + DEFAULT_TEST_RUN_MILLIS + "ms]"); + System.out.println(" -warmup-time=millis [default=" + DEFAULT_WARMUP_MSECS + "]"); + System.out.println(" -skip-pre-warmup (don't warm all serializers before the first measurement)"); + System.out.println(" -chart (generate a Google Chart URL for the results)"); + System.out.println(" -include=impl1,impl2,impl3,..."); + System.out.println(" -exclude=impl1,impl2,impl3,..."); + System.out.println(" -hidden (enable \"hidden\" serializers)"); + System.out.println(" -help"); + System.out.println(); + System.out.println("Example: run -chart -include=protobuf,thrift data/media.1.cks"); + System.out.println(); + System.exit(0); + } + else { + System.err.println("Unknown option: \"" + arg + "\""); + System.err.println("Use \"-help\" for usage information."); + System.exit(1); + } + } + + if (params.dataFileName == null) { + System.err.println("Missing argument."); + System.err.println("Use \"-help\" for usage information."); + System.exit(1); + } + + // And then let's verify input data file bit more... + File dataFile = new File(params.dataFileName); + if (!dataFile.exists()) { + System.out.println("Couldn't find data file \"" + dataFile.getPath() + "\""); + System.exit(1); + } + String[] parts = dataFile.getName().split("\\."); + if (parts.length < 3) { + System.out.println("Data file \"" + dataFile.getName() + "\" should be of the form \"..\""); + System.exit(1); + } + params.dataType = parts[0]; + params.dataExtra = parts[1]; + params.dataExtension = parts[parts.length-1]; + } + + /** + * Method called to run individual test cases + */ + protected void runTests(TestGroups groups, Params params, + TestCase testCreate, + TestCase testSerialize, + TestCase testDeserialize) + { + TestGroup bootstrapGroup = findGroupForTestData(groups, params); + Object testData = loadTestData(bootstrapGroup, params); + Iterable> matchingEntries + = findApplicableTests(groups, params, bootstrapGroup); + + StringWriter errors = new StringWriter(); + PrintWriter errorsPW = new PrintWriter(errors); + try { + EnumMap> values = runMeasurements(errorsPW, params, matchingEntries, testData, + testCreate, + testSerialize, + testDeserialize + ); + + if (params.printChart) { + printImages(values); + } + } + catch (Exception ex) { + ex.printStackTrace(System.err); + System.exit(1); return; + } + + // Print errors after chart. That way you can't miss it. + String errorsString = errors.toString(); + if (errorsString.length() > 0) { + System.out.println(ERROR_DIVIDER); + System.out.println("Errors occurred during benchmarking:"); + System.out.print(errorsString); + System.exit(1); return; + } + } + + protected TestGroup findGroupForTestData(TestGroups groups, Params params) + { + TestGroup group = groups.groupMap.get(params.dataType); + if (group == null) { + System.out.println("Data file \"" + params.dataFileName + "\" can't be loaded."); + System.out.println("Don't know about data type \"" + params.dataType + "\""); + System.exit(1); + } + return group; + } + + protected abstract Object convertTestData(TestGroup.Entry loader, Params params, byte[] data) + throws Exception; + + protected Object loadTestData(TestGroup bootstrapGroup, Params params) + { + TestGroup.Entry loader = bootstrapGroup.extensionMap.get(params.dataExtension); + if (loader == null) { + System.out.println("Data file \"" + params.dataFileName + "\" can't be loaded."); + System.out.println("No deserializer registered for data type \"" + params.dataType + + "\" and file extension \"." + params.dataExtension + "\""); + System.exit(1); + } + byte[] fileBytes; + try { + fileBytes = readFile(new File(params.dataFileName)); // Load entire file into a byte array. + } + catch (Exception ex) { + System.err.println("Error loading data from file \"" + params.dataFileName + "\"."); + System.err.println(ex.getMessage()); + System.exit(1); return null; + } + try { + return convertTestData(loader, params, fileBytes); + } catch (Exception ex) { + System.err.println("Error converting test data from file \"" + params.dataFileName + "\"."); + System.err.println(ex.getMessage()); + System.exit(1); return null; + } + } + + /** + * Method called to both load in test data and figure out which tests should + * actually be run, from all available test cases. + */ + protected Iterable> findApplicableTests(TestGroups groups, Params params, + TestGroup bootstrapGroup) + { + @SuppressWarnings("unchecked") + TestGroup group_ = (TestGroup) bootstrapGroup; + Set matched = new HashSet(); + + Iterable> available; + + if (params.enableHidden) { + // Use all of them. + available = group_.entries; + } else { + // Remove the hidden ones. + ArrayList> unhidden = new ArrayList>(); + for (TestGroup.Entry entry_ : bootstrapGroup.entries) { + @SuppressWarnings("unchecked") + TestGroup.Entry entry = (TestGroup.Entry) entry_; + String name = entry.serializer.getName(); + if (!HIDDEN.contains(name)) unhidden.add(entry); + } + available = unhidden; + } + + if (params.filterStrings == null) { + return available; + } + ArrayList> matchingEntries = new ArrayList>(); + + for (TestGroup.Entry entry_ : available) { + @SuppressWarnings("unchecked") + TestGroup.Entry entry = (TestGroup.Entry) entry_; + String name = entry.serializer.getName(); + // See if any of the filters match. + boolean found = false; + for (String s : params.filterStrings) { + boolean thisOneMatches = match(s, name); + if (thisOneMatches) { + matched.add(s); + found = true; + } + } + + if (found == params.filterIsInclude) { + matchingEntries.add(entry); + } + } + Set unmatched = new HashSet(params.filterStrings); + unmatched.removeAll(matched); + for (String s : unmatched) { + System.err.println("Warning: there is no implementation name matching the pattern \"" + s + "\""); + if (!params.enableHidden) { + for (String hiddenName : HIDDEN) { + if (match(s, hiddenName)) { + System.err.println("(The \"" + hiddenName + "\", serializer is hidden by default."); + System.err.println(" Use the \"-hidden\" option to enable hidden serializers)"); + break; + } + } + } + } + return matchingEntries; + } + + protected EnumMap> runMeasurements(PrintWriter errors, + Params params, Iterable> groups, J value, + TestCase testCreate, + TestCase testSerialize, + TestCase testDeserialize + ) throws Exception + { + // Check correctness first. + System.out.println("Checking correctness..."); + for (TestGroup.Entry entry : groups) + { + checkCorrectness(errors, entry.transformer, entry.serializer, value); + } + System.out.println("[done]"); + + // Pre-warm. + if (params.prewarm) { + System.out.print("Pre-warmup..."); + for (TestGroup.Entry entry : groups) + { + TestCaseRunner runner = new TestCaseRunner(entry.transformer, entry.serializer, value); + String name = entry.serializer.getName(); + System.out.print(" " + name); + + warmTest(runner, params.warmupTime, testCreate); + warmTest(runner, params.warmupTime, testSerialize); + } + System.out.println(); + System.out.println("[done]"); + } + + System.out.printf("%-34s %6s %7s %7s %7s %6s %5s\n", + params.printChart ? "\npre." : "", + "create", + "ser", + "deser", + "total", + "size", + "+dfl"); + EnumMap> values = new EnumMap>(measurements.class); + for (measurements m : measurements.values()) + values.put(m, new HashMap()); + + // Actual tests. + for (TestGroup.Entry entry : groups) + { + TestCaseRunner runner = new TestCaseRunner(entry.transformer, entry.serializer, value); + String name = entry.serializer.getName(); + try { + /* + * Should only warm things for the serializer that we test next: HotSpot JIT will + * otherwise spent most of its time optimizing slower ones... + */ + warmTest(runner, params.warmupTime/3, testCreate); + + doGc(); + // ruediger: turns out startup/init time is pretty equal for all tests. + // No need to spend too much time here + double timeCreate = runner.runWithTimeMeasurement(params.testRunMillis / 3, testCreate, params.iterations); + + warmTest(runner, params.warmupTime, testSerialize); + + doGc(); + double timeSerialize = runner.runWithTimeMeasurement(params.testRunMillis, testSerialize, params.iterations); + + doGc(); + double timeDeserialize = runner.runWithTimeMeasurement(params.testRunMillis, testDeserialize, params.iterations); + + double totalTime = timeSerialize + timeDeserialize; + + byte[] array = serializeForSize(entry.transformer, entry.serializer, value); + byte[] compressDeflate = compressDeflate(array); + + System.out.printf("%-34s %6.0f %7.0f %7.0f %7.0f %6d %5d\n", + name, + timeCreate, + timeSerialize, + timeDeserialize, + totalTime, + array.length, + compressDeflate.length); + + addValue(values, name, timeCreate, timeSerialize, + timeDeserialize, totalTime, + array.length, compressDeflate.length); + } + catch (Exception ex) { + System.out.println("ERROR: \"" + name + "\" crashed during benchmarking."); + errors.println(ERROR_DIVIDER); + errors.println("\"" + name + "\" crashed during benchmarking."); + ex.printStackTrace(errors); + } + } + + return values; + } + + protected abstract byte[] serializeForSize(Transformer tranformer, Serializer serializer, J value) + throws Exception; + + protected static void addValue( + EnumMap> values, + String name, + double timeCreate, + double timeSerialize, + double timeDeserialize, + double totalTime, + double length, double lengthDeflate) + { + values.get(measurements.timeSerialize).put(name, timeSerialize); + values.get(measurements.timeDeserialize).put(name, timeDeserialize); + values.get(measurements.totalTime).put(name, totalTime); + values.get(measurements.length).put(name, length); + values.get(measurements.lengthDeflate).put(name, lengthDeflate); + values.get(measurements.timeCreate).put(name, timeCreate); + } + + // ------------------------------------------------------------------------------------ + // Helper methods for test warmup + // ------------------------------------------------------------------------------------ + + protected void warmTest(TestCaseRunner runner, long warmupTime, TestCase test) throws Exception + { + // Instead of fixed counts, let's try to prime by running for N seconds + long endTime = System.currentTimeMillis() + warmupTime; + do { + runner.run(test, 10); + } + while (System.currentTimeMillis() < endTime); + } + + // ------------------------------------------------------------------------------------ + // Helper methods, validation, result graph generation + // ------------------------------------------------------------------------------------ + + /** + * Method that tries to validate correctness of serializer, using + * round-trip (construct, serializer, deserialize; compare objects + * after steps 1 and 3). + */ + protected abstract void checkCorrectness(PrintWriter errors, Transformer transformer, + Serializer serializer, J value) + throws Exception; + + protected void checkSingleItem(PrintWriter errors, Transformer transformer, + Serializer serializer, J value) + throws Exception + { + Object specialInput; + String name = serializer.getName(); + try { + specialInput = transformer.forward(value); + } + catch (Exception ex) { + System.out.println("ERROR: \"" + name + "\" crashed during forward transformation."); + errors.println(ERROR_DIVIDER); + errors.println("\"" + name + "\" crashed during forward transformation."); + ex.printStackTrace(errors); + return; + } + + byte[] array; + try { + array = serializer.serialize(specialInput); + } + catch (Exception ex) { + ex.printStackTrace(); + System.out.println("ERROR: \"" + name + "\" crashed during serialization."); + errors.println(ERROR_DIVIDER); + errors.println("\"" + name + "\" crashed during serialization."); + ex.printStackTrace(errors); + return; + } + + Object specialOutput; + + try { + specialOutput = serializer.deserialize(array); + } + catch (Exception ex) { + System.out.println("ERROR: \"" + name + "\" crashed during deserialization."); + errors.println(ERROR_DIVIDER); + errors.println("\"" + name + "\" crashed during deserialization."); + ex.printStackTrace(errors); + return; + } + + J output; + try { + output = transformer.reverse(specialOutput); + } + catch (Exception ex) { + System.out.println("ERROR: \"" + name + "\" crashed during reverse transformation."); + errors.println(ERROR_DIVIDER); + errors.println("\"" + name + "\" crashed during reverse transformation."); + ex.printStackTrace(errors); + return; + } + if (!value.equals(output)) { + System.out.println("ERROR: \"" + name + "\" failed round-trip check (item type: " + +value.getClass().getName()+")."); + errors.println(ERROR_DIVIDER); + errors.println("\"" + name + "\" failed round-trip check."); + errors.println("ORIGINAL: " + value); + errors.println("ROUNDTRIP: " + output); + + System.err.println("ORIGINAL: " + value); + System.err.println("ROUNDTRIP: " + output); + + } + } + + // ------------------------------------------------------------------------------------ + // Helper methods, result graph generation + // ------------------------------------------------------------------------------------ + + protected static void printImages(EnumMap> values) + { + System.out.println(); + for (measurements m : values.keySet()) { + Map map = values.get(m); + ArrayList> list = new ArrayList>(map.entrySet()); + Collections.sort(list, new Comparator>() { + public int compare (Map.Entry o1, Map.Entry o2) { + double diff = o1.getValue() - o2.getValue(); + return diff > 0 ? 1 : (diff < 0 ? -1 : 0); + } + }); + LinkedHashMap sortedMap = new LinkedHashMap(); + for (Map.Entry entry : list) { + if( !entry.getValue().isNaN() ) { + sortedMap.put(entry.getKey(), entry.getValue()); + } + } + if (!sortedMap.isEmpty()) printImage(sortedMap, m); + } + System.out.println(); + } + + protected static void printImage(Map map, measurements m) + { + StringBuilder valSb = new StringBuilder(); + String names = ""; + double max = Double.MIN_NORMAL; + for (Map.Entry entry : map.entrySet()) + { + double value = entry.getValue(); + valSb.append((int) value).append(','); + max = Math.max(max, entry.getValue()); + names = urlEncode(entry.getKey()) + '|' + names; + } + + int headerSize = 30; + int maxPixels = 300 * 1000; // Limit set by Google's Chart API. + int maxHeight = 600; + int width = maxPixels / maxHeight; + + int barThickness = 10; + int barSpacing = 10; + + int height; + + // Reduce bar thickness and spacing until we can fit in the maximum height. + while (true) { + height = headerSize + map.size()*(barThickness + barSpacing); + if (height <= maxHeight) break; + barSpacing--; + if (barSpacing == 1) break; + height = headerSize + map.size()*(barThickness + barSpacing); + if (height <= maxHeight) break; + barThickness--; + if (barThickness == 1) break; + } + + boolean truncated = false; + if (height > maxHeight) { + truncated = true; + height = maxHeight; + } + + double scale = max * 1.1; + System.out.println(""); + + if (truncated) { + System.err.println("WARNING: Not enough room to fit all bars in chart."); + } + } + + // ------------------------------------------------------------------------------------ + // Static helper methods + // ------------------------------------------------------------------------------------ + + protected static double iterationTime(long delta, int iterations) + { + return (double) delta / (double) (iterations); + } + + protected static String urlEncode(String s) + { + try { + return URLEncoder.encode(s, "UTF-8"); + } catch (UnsupportedEncodingException e) { + throw new RuntimeException(e); + } + } + + // JVM is not required to honor GC requests, but adding bit of sleep around request is + // most likely to give it a chance to do it. + protected static void doGc() + { + try { + Thread.sleep(50L); + } catch (InterruptedException ie) { + System.err.println("Interrupted while sleeping in serializers.BenchmarkBase.doGc()"); + } + System.gc(); + try { // longer sleep afterwards (not needed by GC, but may help with scheduling) + Thread.sleep(200L); + } catch (InterruptedException ie) { + System.err.println("Interrupted while sleeping in serializers.BenchmarkBase.doGc()"); + } + } + + protected static byte[] readFile(File file) throws IOException + { + FileInputStream fin = new FileInputStream(file); + try { + ByteArrayOutputStream baos = new ByteArrayOutputStream(1024); + byte[] data = new byte[1024]; + while (true) { + int numBytes = fin.read(data); + if (numBytes < 0) break; + baos.write(data, 0, numBytes); + } + return baos.toByteArray(); + } + finally { + fin.close(); + } + } + + protected static byte[] compressDeflate(byte[] data) + { + try { + ByteArrayOutputStream bout = new ByteArrayOutputStream(500); + DeflaterOutputStream compresser = new DeflaterOutputStream(bout); + compresser.write(data, 0, data.length); + compresser.finish(); + compresser.flush(); + return bout.toByteArray(); + } + catch (IOException ex) { + AssertionError ae = new AssertionError("IOException while writing to ByteArrayOutputStream!"); + ae.initCause(ex); + throw ae; + } + } + protected static boolean match(String pattern, String name) + { + StringBuilder regex = new StringBuilder(); + + while (pattern.length() > 0) { + int starPos = pattern.indexOf('*'); + if (starPos < 0) { + regex.append(Pattern.quote(pattern)); + break; + } + else { + String beforeStar = pattern.substring(0, starPos); + String afterStar = pattern.substring(starPos + 1); + + regex.append(Pattern.quote(beforeStar)); + regex.append(".*"); + pattern = afterStar; + } + } + + return Pattern.matches(regex.toString(), name); + } + +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/BenchmarkExporter.java b/jvm-serializers-tpc/src/main/java/serializers/BenchmarkExporter.java new file mode 100644 index 0000000..8a48822 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/BenchmarkExporter.java @@ -0,0 +1,70 @@ +package serializers; + +/** + * Copyright (c) 2012, Ruediger Moeller. All rights reserved. + *

+ * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + *

+ * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + *

+ * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + *

+ * Date: 09.03.14 + * Time: 10:09 + * To change this template use File | Settings | File Templates. + */ + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Set; + +/** + * tweak to generate a string containing all registered benchmarks and extract bench feature data. called by run script + */ +public class BenchmarkExporter extends BenchmarkRunner { + + String alltests = ""; // ',' separated + HashMap featureMap = new HashMap(); // have to map back after running .. sigh + + public BenchmarkExporter() { + runBenchmark(new String[0]); + } + + protected void runBenchmark(String[] args) + { + TestGroups groups = new TestGroups(); + addTests(groups); + Set media = groups.groupMap.get("media").entryNames; + for (Iterator iterator = media.iterator(); iterator.hasNext(); ) { + String next = iterator.next().trim(); + if ( ! next.equals("cks") && ! next.equals("cks-text") ) // used to read data, exclude + alltests += next+ (iterator.hasNext() ? "," : ""); + SerFeatures features = groups.groupMap.get("media").getSerMap().get(next).getFeatures(); +// System.out.println("serializer:"+next+" miscFeatures: "+miscFeatures); + featureMap.put(next, features); + } + } + + public String getAlltests() { + return alltests; + } + + public HashMap getFeatureMap() { + return featureMap; + } + + public static void main(String arg[]) { + System.out.println(new BenchmarkExporter().getAlltests()); + } + +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/BenchmarkRunner.java b/jvm-serializers-tpc/src/main/java/serializers/BenchmarkRunner.java new file mode 100644 index 0000000..2619dc7 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/BenchmarkRunner.java @@ -0,0 +1,134 @@ +package serializers; + +import serializers.avro.AvroGeneric; +import serializers.avro.AvroSpecific; +import serializers.cks.CksBinary; +import serializers.cks.CksText; +import serializers.jackson.*; +import serializers.javaxjson.*; +import serializers.json.*; +import serializers.kryo.Kryo; +import serializers.msgpack.MsgPack; +import serializers.protobuf.Protobuf; +import serializers.protobuf.ProtobufJson; +import serializers.protostuff.Protostuff; +import serializers.protostuff.ProtostuffJson; +import serializers.wobly.Wobly; +import serializers.xml.*; +import serializers.dslplatform.DSLPlatform; + +/** + * Full test of various codecs, using a single MediaItem + * as test data. + */ +public class BenchmarkRunner extends MediaItemBenchmark +{ + public static void main(String[] args) { + new BenchmarkRunner().runBenchmark(args); + } + + protected void addTests(TestGroups groups) + { + // Binary Formats; language-specific ones + JaxbAalto.register(groups); + Jaxb.register(groups); + JavaBuiltIn.register(groups); + JavaManual.register(groups); + Stephenerialization.register(groups); + + Scala.register(groups); +// hessian, kryo and wobly are Java object serializations + Hessian.register(groups); + Kryo.register(groups); + FastSerialization.register(groups); + Wobly.register(groups); + JBossSerialization.register(groups); + JBossMarshalling.register(groups); +// 06-May-2013, tatu: Fails on basic Java7, mismatch with Unsafe; commented out +// Obser.register(groups); + + // Binary formats, generic: protobuf, thrift, avro, CKS, msgpack, CBOR + Protobuf.register(groups); + // 16-May-2012, Nate: As discussed on mailing list, removed ActiveMQProtobuf as + // its lazy deserialization isn't comparable to other serializers. + // ActiveMQProtobuf.register(groups); + Protostuff.register(groups); + Thrift.register(groups); + AvroSpecific.register(groups); + AvroGeneric.register(groups); + CksBinary.register(groups); + // 01-Oct-2014: MsgPack implementation uses questionable technique as well: instead of using Maps (name/value), + // uses arrays, presumes ordering (and implied schema thereby) -- not inter-operable with most non-Java MsgPack + // usage, and basically seems to optimize for benchmarks instead of reflecting real usage. + MsgPack.register(groups); + JacksonCBORDatabind.register(groups); + + // JSON + JacksonJsonManual.register(groups); + JacksonJsonDatabind.register(groups); + JacksonJrDatabind.register(groups); + // 01-Oct-2014, tatu: not 100% sure this is still needed, but left just in case +// JacksonJsonTree.register(groups); + JavaxJsonTreeGlassfish.register(groups); + JavaxJsonStreamGlassfish.register(groups); + JsonTwoLattes.register(groups); + ProtostuffJson.register(groups); + + ProtobufJson.register(groups); + JsonGsonManual.register(groups); + JsonGsonTree.register(groups); + JsonGsonDatabind.register(groups); + JsonSvensonDatabind.register(groups); + FlexjsonDatabind.register(groups); + + JsonLibJsonDatabind.register(groups); + FastJSONDatabind.register(groups); + JsonSimpleWithContentHandler.register(groups); +// JsonSimpleManualTree.register(groups); + JsonSmartManualTree.register(groups); + JsonDotOrgManualTree.register(groups); + JsonijJpath.register(groups); +// JsonijManualTree.register(groups); + JsonArgoTree.register(groups); +// 06-May-2013, tatu: Too slow (100x above fastest) +// JsonPathDeserializerOnly.register(groups); + + // Then JSON-like + // CKS text is textual JSON-like format + CksText.register(groups); + // then binary variants + // Smile is 1-to-1 binary JSON serialization + JacksonSmileManual.register(groups); + JacksonSmileDatabind.register(groups); + + // 06-May-2013, tatu: Unfortunately there is a version conflict + // here too -- commenting out, to let David fix it +// ProtostuffSmile.register(groups); + // BSON is JSON-like format with extended datatypes + JacksonBsonDatabind.register(groups); + MongoDB.register(groups); + + // YAML (using Jackson module built on SnakeYAML) + JacksonYAMLDatabind.register(groups); + + // XML-based formats; first textual XML + XmlStax.register(groups, true, true, false); // woodstox/aalto/- + XmlXStream.register(groups); + JacksonXmlDatabind.register(groups); + XmlJavolution.register(groups); + + // Then binary XML; Fast Infoset, EXI + XmlStax.register(groups, false, false, true); // -/-/fast-infoset + ExiExificient.register(groups); + + // Other things... + + // Jackson databind with Afterburner; add-on module that uses bytecode gen for speed + JacksonWithAfterburner.registerAll(groups); + + // Jackson's column-oriented variants for formats that usually use key/value notation + JacksonWithColumnsDatabind.registerAll(groups); + + DSLPlatform.register(groups); + } +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/FastSerialization.java b/jvm-serializers-tpc/src/main/java/serializers/FastSerialization.java new file mode 100644 index 0000000..31f461f --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/FastSerialization.java @@ -0,0 +1,170 @@ +package serializers; + +import data.media.*; +import de.ruedigermoeller.serialization.*; + +import java.io.*; + +/** + * Copyright (c) 2012, Ruediger Moeller. All rights reserved. + *

+ * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + *

+ * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + *

+ * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + *

+ * Date: 01.03.14 + * Time: 23:59 + * To change this template use File | Settings | File Templates. + */ +public class FastSerialization { + + public static void register (TestGroups groups) { + register(groups.media, JavaBuiltIn.mediaTransformer); + } + + private static void register (TestGroup group, Transformer transformer) { + group.add(transformer, new BasicSerializer("fst-flat-pre",true,true), + new SerFeatures( + SerFormat.BINARY, + SerGraph.FLAT_TREE, + SerClass.CLASSES_KNOWN, + "fst in unshared mode with preregistered classes" + ) + ); + + group.add(transformer, new BasicSerializer("fst-flat",true,false), + new SerFeatures( + SerFormat.BINARY, + SerGraph.FLAT_TREE, + SerClass.ZERO_KNOWLEDGE, + "fst default, but unshared mode" + ) + ); + group.add(transformer, new BasicSerializer("fst",false,false), + new SerFeatures( + SerFormat.BINARY, + SerGraph.FULL_GRAPH, + SerClass.ZERO_KNOWLEDGE, + "default: JDK serialization drop-in-replacement mode" + ) + ); + + } + + // ------------------------------------------------------------ + // Serializers + + /** + * setup similar to kryo + */ + public static class BasicSerializer extends Serializer { + final static FSTConfiguration confUnsharedUnregistered; + final static FSTConfiguration confUnsharedRegister; + final static FSTConfiguration confShared; + static { +// System.setProperty("fst.unsafe", "true"); + confUnsharedUnregistered = FSTConfiguration.createDefaultConfiguration(); + confUnsharedUnregistered.setShareReferences(false); + + confUnsharedRegister = FSTConfiguration.createDefaultConfiguration(); + confUnsharedRegister.setShareReferences(false); + confUnsharedRegister.registerClass( + Image.Size.class, + Image.class, + Media.Player.class, + Media.class, + MediaContent[].class, + MediaContent.class, + MediaContent.class); + + confShared = FSTConfiguration.createDefaultConfiguration(); + } + + FSTObjectInput objectInput; + FSTObjectOutput objectOutput; + boolean unshared; + String name; + Class type[] = { MediaContent.class }; + + public BasicSerializer (String name, boolean flat, boolean register) { + this.name = name; + this.unshared = flat; + if ( flat ) { + if ( register ) { + objectInput = new FSTObjectInputNoShared(confUnsharedRegister); + objectOutput = new FSTObjectOutputNoShared(confUnsharedRegister); + } else { + objectInput = new FSTObjectInputNoShared(confUnsharedUnregistered); + objectOutput = new FSTObjectOutputNoShared(confUnsharedUnregistered); + } + } else { + objectInput = new FSTObjectInput(confShared); + objectOutput = new FSTObjectOutput(confShared); + } + } + + @SuppressWarnings("unchecked") + public T deserialize (byte[] array) { + return (T) deserializeInternal(array); + } + + private Object deserializeInternal(byte[] array) { + try { + objectInput.resetForReuseUseArray(array); + return objectInput.readObject(type); + } catch (Throwable e) { + e.printStackTrace(); + } + return null; + } + + public byte[] serialize (T content) { + try { + objectOutput.resetForReUse(); + objectOutput.writeObject(content,type); + return objectOutput.getCopyOfWrittenBuffer(); + } catch (IOException e) { + e.printStackTrace(); + } + return null; + } + + public void serializeItems (T[] items, OutputStream outStream) throws Exception { + objectOutput.resetForReUse(); + for (int i = 0; i < items.length; i++) { + objectOutput.writeObject(items[i]); + } + outStream.write(objectOutput.getBuffer(),0,objectOutput.getWritten()); // avoid copy + } + + @SuppressWarnings("unchecked") + public T[] deserializeItems (InputStream inStream, int numberOfItems) throws IOException { + try { + MediaContent[] result = new MediaContent[numberOfItems]; + objectInput.resetForReuse(inStream); + for ( int i=0; i < numberOfItems; i++) + result[i] = (MediaContent) objectInput.readObject(); + return (T[]) result; + } catch (Throwable e) { + e.printStackTrace(); + } + return null; + } + + public String getName () { + return name; + } + } + +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/Hessian.java b/jvm-serializers-tpc/src/main/java/serializers/Hessian.java new file mode 100644 index 0000000..d6707f2 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/Hessian.java @@ -0,0 +1,74 @@ +package serializers; + +import java.io.*; +import java.lang.reflect.Array; + +import data.media.MediaContent; + +import com.caucho.hessian.io.*; + +public class Hessian +{ + public static void register(TestGroups groups) + { + groups.media.add(JavaBuiltIn.mediaTransformer, new HessianSerializer(MediaContent.class), + new SerFeatures( + SerFormat.BIN_CROSSLANG, + SerGraph.FULL_GRAPH, + SerClass.ZERO_KNOWLEDGE,"" + ) + ); + } + + // ------------------------------------------------------------ + // Serializer (just one) + + public final static class HessianSerializer extends Serializer + { + private final Class clz; + + public HessianSerializer(Class c) { clz = c; } + + public String getName() { return "hessian"; } + + @SuppressWarnings("unchecked") + public T deserialize(byte[] array) throws Exception + { + ByteArrayInputStream in = new ByteArrayInputStream(array); + Hessian2StreamingInput hin = new Hessian2StreamingInput(in); + return (T) hin.readObject(); + } + + public byte[] serialize(T data) throws java.io.IOException + { + ByteArrayOutputStream out = outputStream(data); + Hessian2StreamingOutput hout = new Hessian2StreamingOutput(out); + hout.writeObject(data); + return out.toByteArray(); + } + + @Override + public final void serializeItems(T[] items, OutputStream out) throws Exception + { + Hessian2StreamingOutput hout = new Hessian2StreamingOutput(out); + for (Object item : items) { + hout.writeObject(item); + } + hout.flush(); + hout.close(); + } + + @SuppressWarnings("unchecked") + @Override + public T[] deserializeItems(InputStream in, int numberOfItems) throws Exception + { + Hessian2StreamingInput hin = new Hessian2StreamingInput(in); + T[] result = (T[]) Array.newInstance(clz, numberOfItems); + for (int i = 0; i < numberOfItems; ++i) { + result[i] = (T) hin.readObject(); + } + hin.close(); + return result; + } + } +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/JBossMarshalling.java b/jvm-serializers-tpc/src/main/java/serializers/JBossMarshalling.java new file mode 100644 index 0000000..99a1c32 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/JBossMarshalling.java @@ -0,0 +1,678 @@ +package serializers; + +import java.io.IOException; +import java.io.InputStream; +import java.io.ObjectInput; +import java.io.ObjectOutput; +import java.io.OutputStream; +import java.lang.reflect.Array; +import java.util.ArrayList; + +import org.jboss.marshalling.ByteInput; +import org.jboss.marshalling.ByteOutput; +import org.jboss.marshalling.ClassExternalizerFactory; +import org.jboss.marshalling.ClassTable; +import org.jboss.marshalling.Creator; +import org.jboss.marshalling.Externalizer; +import org.jboss.marshalling.Marshaller; +import org.jboss.marshalling.MarshallerFactory; +import org.jboss.marshalling.Marshalling; +import org.jboss.marshalling.MarshallingConfiguration; +import org.jboss.marshalling.Unmarshaller; +import org.jboss.marshalling.reflect.SunReflectiveCreator; +import org.jboss.marshalling.river.RiverMarshallerFactory; +import org.jboss.marshalling.serial.SerialMarshallerFactory; + +import data.media.Image; +import data.media.Media; +import data.media.MediaContent; + +public class JBossMarshalling { + + public static void register(final TestGroups groups) { + MarshallerFactory riverFactory = new RiverMarshallerFactory(); + + groups.media.add( + JavaBuiltIn.mediaTransformer, + new MarshallingSerializer( + MediaContent.class, + "jboss-marshalling-river", + riverFactory, + false, + false + ), + new SerFeatures( + SerFormat.BINARY, + SerGraph.FULL_GRAPH, + SerClass.ZERO_KNOWLEDGE, + "full graph zero knowledge" + ) + ); + groups.media.add( + JavaBuiltIn.mediaTransformer, + new MarshallingSerializer( + MediaContent.class, + "jboss-marshalling-river-manual", + riverFactory, + false, + true + ), + new SerFeatures( + SerFormat.BINARY, + SerGraph.FULL_GRAPH, + SerClass.MANUAL_OPT, + "full graph with manual optimizations" + ) + ); + groups.media.add( + JavaBuiltIn.mediaTransformer, + new MarshallingSerializer( + MediaContent.class, + "jboss-marshalling-river-ct", + riverFactory, + true, + false + ), + new SerFeatures( + SerFormat.BINARY, + SerGraph.FULL_GRAPH, + SerClass.CLASSES_KNOWN, + "full graph with preregistered classes" + ) + ); + groups.media.add( + JavaBuiltIn.mediaTransformer, + new MarshallingSerializer( + MediaContent.class, + "jboss-marshalling-river-ct-manual", + riverFactory, + true, + true + ), + new SerFeatures( + SerFormat.BINARY, + SerGraph.FULL_GRAPH, + SerClass.MANUAL_OPT, + "full graph preregistered classes, manual optimization" + ) + ); + groups.media.add( + JavaBuiltIn.mediaTransformer, + new MarshallingSerializer( + MediaContent.class, + "jboss-marshalling-serial", + new SerialMarshallerFactory(), + false, + false + ), + new SerFeatures( + SerFormat.BINARY, + SerGraph.FULL_GRAPH, + SerClass.ZERO_KNOWLEDGE, + "" + ) + ); + } + + private static final class MarshallingSerializer extends Serializer { + + private final Class clz; + + private final Marshaller marshaller; + + private final Unmarshaller unmarshaller; + + private final String name; + + private final ByteArrayInput input = new ByteArrayInput(); + + private final ByteArrayOutput output = new ByteArrayOutput(); + + public MarshallingSerializer( + final Class clz, + final String name, + final MarshallerFactory marshallerFactory, + final boolean useCustomClassTable, + final boolean useExternalizers + ) { + this.clz = clz; + this.name = name; + + MarshallingConfiguration cfg = new MarshallingConfiguration(); + cfg.setBufferSize(Serializer.BUFFER_SIZE); + cfg.setExternalizerCreator(new SunReflectiveCreator()); + + if (useCustomClassTable) { + cfg.setClassTable(new CustomClassTable()); + } + + if (useExternalizers) { + cfg.setClassExternalizerFactory(new CustomCEF()); + } + + try { + marshaller = marshallerFactory.createMarshaller(cfg); + unmarshaller = marshallerFactory.createUnmarshaller(cfg); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + @Override + public String getName() { + return name; + } + + @Override + public T deserialize(final byte[] array) throws Exception { + input.setBuffer(array); + unmarshaller.start(input); + T val = unmarshaller.readObject(clz); + unmarshaller.finish(); + return val; + } + + @Override + public byte[] serialize(final T data) throws IOException { + marshaller.start(output); + marshaller.writeObject(data); + marshaller.finish(); + return output.toByteArray(); + } + + @Override + public final void serializeItems(final T[] items, final OutputStream os) + throws Exception { + marshaller.start(Marshalling.createByteOutput(os)); + for (Object item : items) { + marshaller.writeObject(item); + } + marshaller.finish(); + } + + @Override + public T[] deserializeItems(final InputStream in, final int numOfItems) + throws Exception { + unmarshaller.start(Marshalling.createByteInput(in)); + + @SuppressWarnings("unchecked") + T[] result = (T[]) Array.newInstance(clz, numOfItems); + for (int i = 0; i < numOfItems; ++i) { + result[i] = unmarshaller.readObject(clz); + } + unmarshaller.finish(); + + return result; + } + + private static void writeMaybeString( + final ObjectOutput output, + final String s + ) throws IOException { + if (s != null) { + output.writeBoolean(true); + output.writeUTF(s); + } else { + output.writeBoolean(false); + } + } + + private static String readMaybeString(final ObjectInput input) + throws IOException { + if (input.readBoolean()) { + return input.readUTF(); + } else { + return null; + } + } + + private static Image readImage(final ObjectInput input) + throws IOException { + final Image image = new Image(); + readImage(input, image); + return image; + } + + private static void readImage(final ObjectInput input, final Image img) + throws IOException { + img.setUri(input.readUTF()); + img.setTitle(readMaybeString(input)); + img.setWidth(input.readInt()); + img.setHeight(input.readInt()); + img.setSize(Image.Size.values()[input.readByte()]); + } + + private static void writeImage( + final ObjectOutput output, + final Image image + ) throws IOException { + output.writeUTF(image.uri); + writeMaybeString(output, image.title); + output.writeInt(image.width); + output.writeInt(image.height); + output.writeByte(image.size.ordinal()); + } + + private static Media readMedia(final ObjectInput input) + throws IOException { + final Media m = new Media(); + readMedia(input, m); + return m; + } + + private static void readMedia(final ObjectInput input, final Media m) + throws IOException { + m.setUri(input.readUTF()); + m.setTitle(readMaybeString(input)); + m.setWidth(input.readInt()); + m.setHeight(input.readInt()); + m.setFormat(input.readUTF()); + m.setDuration(input.readLong()); + m.setSize(input.readLong()); + if (input.readBoolean()) { + m.setBitrate(input.readInt()); + } + int numPersons = input.readInt(); + ArrayList persons = new ArrayList(numPersons); + for (int i = 0; i < numPersons; i++) { + persons.add(input.readUTF()); + } + m.setPersons(persons); + m.setPlayer(Media.Player.values()[input.readByte()]); + m.setCopyright(readMaybeString(input)); + } + + private static void writeMedia( + final ObjectOutput output, + final Media m + ) throws IOException { + output.writeUTF(m.uri); + writeMaybeString(output, m.title); + output.writeInt(m.width); + output.writeInt(m.height); + output.writeUTF(m.format); + output.writeLong(m.duration); + output.writeLong(m.size); + output.writeBoolean(m.hasBitrate); + if (m.hasBitrate) { + output.writeInt(m.bitrate); + } + output.writeInt(m.persons.size()); + for (String p : m.persons) { + output.writeUTF(p); + } + output.writeByte(m.player.ordinal()); + writeMaybeString(output, m.copyright); + } + + private static void writeMediaContent( + final ObjectOutput output, + final MediaContent mc + ) throws IOException { + writeMedia(output, mc.media); + output.writeInt(mc.images.size()); + for (Image image : mc.images) { + writeImage(output, image); + } + } + + private static void readMediaContent( + final ObjectInput input, + final MediaContent mc + ) throws IOException { + mc.setMedia(readMedia(input)); + int numImages = input.readInt(); + ArrayList images = new ArrayList(numImages); + for (int i = 0; i < numImages; i++) { + images.add(readImage(input)); + } + mc.setImages(images); + } + + private static final class CustomCEF + implements ClassExternalizerFactory { + + private static Class[] CLASSES = { + Media.class, + MediaContent.class, + Image.class, + MediaExternalizer.class, + MediaContentExternalizer.class, + ImageExternalizer.class + }; + + private static final Externalizer[] EXTERNALIZERS = { + new MediaExternalizer(), + new MediaContentExternalizer(), + new ImageExternalizer(), + null, + null, + null + }; + + public CustomCEF() { + ExternalizerExternalizer ext = new ExternalizerExternalizer(); + + EXTERNALIZERS[3] = ext; + EXTERNALIZERS[4] = ext; + EXTERNALIZERS[5] = ext; + } + + @Override + public Externalizer getExternalizer(final Class type) { + for (int i = 0; i < CLASSES.length; i++) { + if (CLASSES[i].equals(type)) { + return EXTERNALIZERS[i]; + } + } + + if (!ExternalizerExternalizer.class.equals(type)) { + System.err.println("No externalizer for type " + type); + } + + return null; + } + } + + private static final class MediaExternalizer implements Externalizer { + + private static final long serialVersionUID = 1L; + + @Override + public void writeExternal( + final Object subject, + final ObjectOutput output + ) throws IOException { + writeMedia(output, (Media)subject); + } + + @Override + public void readExternal( + final Object subject, + final ObjectInput input + ) throws IOException, ClassNotFoundException { + readMedia(input, (Media)subject); + } + + @Override + public Object createExternal( + final Class subjectType, + final ObjectInput input, + final Creator defaultCreator + ) throws IOException, ClassNotFoundException { + return new Media(); + } + } + + private static final class MediaContentExternalizer + implements Externalizer { + + private static final long serialVersionUID = 1L; + + @Override + public void writeExternal( + final Object subject, + final ObjectOutput output + ) throws IOException { + writeMediaContent(output, (MediaContent)subject); + } + + @Override + public void readExternal( + final Object subject, + final ObjectInput input + ) throws IOException, ClassNotFoundException { + readMediaContent(input, (MediaContent)subject); + } + + @Override + public Object createExternal( + final Class subjectType, + final ObjectInput input, + final Creator defaultCreator + ) throws IOException, ClassNotFoundException { + return new MediaContent(); + } + } + + private static final class ExternalizerExternalizer + implements Externalizer { + + private static final long serialVersionUID = 1L; + + private static final Externalizer[] EXTERNALIZERS = { + new MediaExternalizer(), + new MediaContentExternalizer(), + new ImageExternalizer() + }; + + @Override + public void writeExternal( + final Object subject, + final ObjectOutput output + ) throws IOException { + // there is no state + } + + @Override + public void readExternal( + final Object subject, + final ObjectInput input + ) throws IOException, ClassNotFoundException { + // there is no state + } + + @Override + public Object createExternal( + final Class subjectType, + final ObjectInput input, + final Creator defaultCreator + ) throws IOException, ClassNotFoundException { + for (Externalizer ext : EXTERNALIZERS) { + if (ext.getClass().equals(subjectType)) { + return ext; + } + } + + throw new ClassNotFoundException("Unknown type " + subjectType); + } + } + + private static final class ImageExternalizer + implements Externalizer { + + private static final long serialVersionUID = 1L; + + @Override + public void writeExternal( + final Object subject, + final ObjectOutput output + ) throws IOException { + writeImage(output, (Image)subject); + } + + @Override + public void readExternal( + final Object subject, + final ObjectInput input + ) throws IOException, ClassNotFoundException { + readImage(input, (Image)subject); + } + + @Override + public Object createExternal( + final Class subjectType, + final ObjectInput input, + final Creator defaultCreator + ) throws IOException, ClassNotFoundException { + return new Image(); + } + } + + private static final class CustomClassTable implements ClassTable { + + private static final Class[] CLASSES = { + MediaContent.class, + Media.Player.class, + Media.class, + Image.Size.class, + Image.class, + CustomCEF.class, + MediaExternalizer.class, + MediaContentExternalizer.class, + ImageExternalizer.class, + ExternalizerExternalizer.class, + ArrayList.class + }; + + private static final Writer WRITERS[] = new Writer[CLASSES.length]; + + public CustomClassTable() { + for (int i = 0; i < WRITERS.length; i++) { + final byte b = (byte)i; + WRITERS[i] = new Writer() { + @Override + public void writeClass( + final Marshaller marshaller, + final Class clazz + ) throws IOException { + marshaller.writeByte(b); + } + }; + } + } + + @Override + public Writer getClassWriter(final Class c) throws IOException { + for (int i = 0; i < CLASSES.length; i++) { + if (CLASSES[i].equals(c)) { + return WRITERS[i]; + } + } + + throw new IOException("Unexpected class " + c); + } + + @Override + public Class readClass(final Unmarshaller unmarshaller) + throws IOException, ClassNotFoundException { + byte b = unmarshaller.readByte(); + + if (b < 0 || b >= CLASSES.length) { + throw new ClassNotFoundException( + "Unexcepted class number " + b + ); + } + + return CLASSES[b]; + } + } + + private static final class ByteArrayInput implements ByteInput { + + private byte[] buffer; + + private int position; + + public void setBuffer(final byte[] buffer) { + this.buffer = buffer; + position = 0; + } + + @Override + public void close() throws IOException { + buffer = null; + position = -1; + } + + @Override + public int read() throws IOException { + if (position >= buffer.length) { + return -1; + } + + return buffer[position++]; + } + + @Override + public int read(final byte[] b) throws IOException { + return read(b, 0, b.length); + } + + @Override + public int read(final byte[] b, final int off, final int len) + throws IOException { + if (position >= buffer.length) { + return -1; + } + + int n = len; + if (n > buffer.length - position) { + n = buffer.length - position; + } + + System.arraycopy(buffer, position, b, off, n); + position += n; + + return n; + } + + @Override + public int available() throws IOException { + return buffer.length - position; + } + + @Override + public long skip(final long n) throws IOException { + throw new IOException("Unsupported operation"); + } + } + + private static final class ByteArrayOutput implements ByteOutput { + + private byte[] buffer = new byte[Serializer.BUFFER_SIZE]; + + private int position; + + @Override + public void close() throws IOException { + position = 0; + buffer = null; + } + + @Override + public void flush() throws IOException { + } + + @Override + public void write(final int b) throws IOException { + throw new IOException("Unsupported operation"); + } + + @Override + public void write(final byte[] b) throws IOException { + write(b, 0, b.length); + } + + @Override + public void write(final byte[] b, final int off, final int len) + throws IOException { + if (buffer.length - position < len) { + byte[] newBuffer = new byte[2 * buffer.length]; + System.arraycopy(buffer, 0, newBuffer, 0, position); + buffer = newBuffer; + } + + System.arraycopy(b, off, buffer, position, len); + position += len; + } + + public byte[] toByteArray() { + byte[] result = new byte[position]; + System.arraycopy(buffer, 0, result, 0, position); + position = 0; + return result; + } + } + } +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/JBossSerialization.java b/jvm-serializers-tpc/src/main/java/serializers/JBossSerialization.java new file mode 100644 index 0000000..bd2c47f --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/JBossSerialization.java @@ -0,0 +1,92 @@ +package serializers; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.lang.reflect.Array; + +import org.jboss.serial.io.JBossObjectInputStream; +import org.jboss.serial.io.JBossObjectOutputStream; +import org.jboss.serial.util.StringUtilBuffer; + +import data.media.MediaContent; + +public class JBossSerialization { + + public static void register(final TestGroups groups) { + groups.media.add( + JavaBuiltIn.mediaTransformer, + new JBossSerializationSerializer(MediaContent.class) + , + new SerFeatures( + SerFormat.BINARY, + SerGraph.FULL_GRAPH, + SerClass.ZERO_KNOWLEDGE, + "" + ) + ); + } + + private static final class JBossSerializationSerializer + extends Serializer { + + private final Class clz; + + public JBossSerializationSerializer(final Class c) { + clz = c; + } + + @Override + public String getName() { + return "jboss-serialization"; + } + + @Override + @SuppressWarnings("unchecked") + public T deserialize(final byte[] array) throws Exception { + ByteArrayInputStream bais = new ByteArrayInputStream(array); + JBossObjectInputStream jois = new JBossObjectInputStream( + bais, + new StringUtilBuffer(BUFFER_SIZE, BUFFER_SIZE) + ); + return (T) jois.readObject(); + } + + @Override + public byte[] serialize(final T data) throws IOException { + ByteArrayOutputStream baos = outputStream(data); + JBossObjectOutputStream joos = new JBossObjectOutputStream( + baos, + new StringUtilBuffer(BUFFER_SIZE, BUFFER_SIZE) + ); + joos.writeObject(data); + return baos.toByteArray(); + } + + @Override + public final void serializeItems(final T[] items, final OutputStream os) + throws Exception { + JBossObjectOutputStream jous = new JBossObjectOutputStream(os); + for (Object item : items) { + jous.writeObject(item); + } + jous.flush(); + jous.close(); + } + + @SuppressWarnings("unchecked") + @Override + public T[] deserializeItems(final InputStream in, final int numOfItems) + throws Exception { + JBossObjectInputStream jois = new JBossObjectInputStream(in); + T[] result = (T[]) Array.newInstance(clz, numOfItems); + for (int i = 0; i < numOfItems; ++i) { + result[i] = (T) jois.readObject(); + } + jois.close(); + return result; + } + } +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/JavaBuiltIn.java b/jvm-serializers-tpc/src/main/java/serializers/JavaBuiltIn.java new file mode 100644 index 0000000..59ff189 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/JavaBuiltIn.java @@ -0,0 +1,122 @@ +package serializers; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.util.ArrayList; +import java.util.Collections; + +import data.media.Image; +import data.media.Media; +import data.media.MediaContent; +import data.media.MediaTransformer; + +public class JavaBuiltIn +{ + public static void register(TestGroups groups) + { + groups.media.add(mediaTransformer, new GenericSerializer("java-built-in",true), + new SerFeatures( + SerFormat.BINARY, + SerGraph.FLAT_TREE, + SerClass.ZERO_KNOWLEDGE, + "" + ) + ); + groups.media.add(mediaTransformer, new GenericSerializer("java-built-in-serializer",false), + new SerFeatures( + SerFormat.BINARY, + SerGraph.FULL_GRAPH, + SerClass.ZERO_KNOWLEDGE, + "" + ) + ); + } + + // ------------------------------------------------------------ + // Serializer (just one) + + public static class GenericSerializer extends Serializer + { + private final String name; + boolean unshared; + + public GenericSerializer(String name) { + this( name, true ); + } + + public GenericSerializer(String name, boolean unshared) + { + this.name = name; + this.unshared = unshared; + } + + @SuppressWarnings("unchecked") + public T deserialize(byte[] array) throws Exception + { + ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(array)); + if ( unshared ) { + return (T) ois.readUnshared(); + } else { + return (T) ois.readObject(); + } + } + + public byte[] serialize(T data) throws IOException + { + ByteArrayOutputStream baos = outputStream(data); + ObjectOutputStream oos = new ObjectOutputStream(baos); + if ( unshared ) { + oos.writeUnshared(data); + } else { + oos.writeObject(data); + } + return baos.toByteArray(); + } + + public String getName() + { + return name; + } + } + + // ------------------------------------------------------------ + // MediaTransformer + + public static final MediaTransformer mediaTransformer = new MediaTransformer() + { + @Override + public MediaContent[] resultArray(int size) { return new MediaContent[size]; } + + public MediaContent forward(MediaContent mc) + { + return copy(mc); + } + + public MediaContent reverse(MediaContent mc) + { + return copy(mc); + } + + private MediaContent copy(MediaContent mc) + { + ArrayList images = new ArrayList(mc.images.size()); + for (Image i : mc.images) { + images.add(new Image(i.uri, i.title, i.width, i.height, i.size)); + } + return new MediaContent(copy(mc.media), images); + } + + private Media copy(Media m) + { + return new Media(m.uri, m.title, m.width, m.height, m.format, m.duration, m.size, m.bitrate, m.hasBitrate, new ArrayList(m.persons), m.player, m.copyright); + } + + public MediaContent shallowReverse(MediaContent mc) + { + return new MediaContent(copy(mc.media), Collections.emptyList()); + } + }; +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/JavaManual.java b/jvm-serializers-tpc/src/main/java/serializers/JavaManual.java new file mode 100644 index 0000000..2cec3e4 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/JavaManual.java @@ -0,0 +1,196 @@ +package serializers; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.ArrayList; + +import data.media.*; + +public final class JavaManual +{ + public static void register(TestGroups groups) { + groups.media.add(JavaBuiltIn.mediaTransformer, new MediaContentSerializer(), + new SerFeatures( + SerFormat.BINARY, + SerGraph.FLAT_TREE, + SerClass.MANUAL_OPT, + "" + ) + ); + } + + // ------------------------------------------------------------ + // Serializer (just one) + + private static final class MediaContentSerializer extends Serializer + { + public MediaContentSerializer() { super(); } + + public String getName() { return "java-manual"; } + + public MediaContent deserialize(byte[] array) throws IOException { + return readMediaContent(new DataInputStream(new ByteArrayInputStream(array))); + } + + public byte[] serialize(MediaContent data) throws IOException + { + ByteArrayOutputStream baos = outputStream(data); + DataOutputStream oos = new DataOutputStream(baos); + writeMediaContent(oos, data); + oos.flush(); + return baos.toByteArray(); + } + + @Override + public final void serializeItems(MediaContent[] items, OutputStream out0) throws IOException + { + DataOutputStream out = new DataOutputStream(out0); + for (int i = 0, len = items.length; i < len; ++i) { + writeMediaContent(out, items[i]); + } + out.flush(); + } + + @Override + public MediaContent[] deserializeItems(InputStream in0, int numberOfItems) throws IOException + { + DataInputStream in = new DataInputStream(in0); + MediaContent[] result = new MediaContent[numberOfItems]; + for (int i = 0; i < numberOfItems; ++i) { + result[i] = readMediaContent(in); + } + return result; + } + + // MediaContent + + private static MediaContent readMediaContent(DataInputStream in) throws IOException + { + Media media = readMedia(in); + int numImages = in.readInt(); + ArrayList images = new ArrayList(numImages); + for (int i = 0; i < numImages; i++) { + images.add(readImage(in)); + } + return new MediaContent(media, images); + } + + private static void writeMediaContent(DataOutputStream out, MediaContent m) + throws IOException + { + writeMedia(out, m.media); + out.writeInt(m.images.size()); + for (Image im : m.images) { + writeImage(out, im); + } + } + + // Media + + private static Media readMedia(DataInputStream in) + throws IOException + { + String uri = in.readUTF(); + String title = readMaybeString(in); + int width = in.readInt(); + int height = in.readInt(); + String format = in.readUTF(); + long duration = in.readLong(); + long size = in.readLong(); + boolean hasBitrate = in.readBoolean(); + int bitrate = 0; + if (hasBitrate) bitrate = in.readInt(); + int numPersons = in.readInt(); + ArrayList persons = new ArrayList(numPersons); + for (int i = 0; i < numPersons; i++) { + persons.add(in.readUTF()); + } + Media.Player player = Media.Player.values()[in.readByte()]; + String copyright = readMaybeString(in); + + return new Media( + uri, title, width, height, format, duration, size, + bitrate, hasBitrate, persons, player, copyright); + } + + private static void writeMedia(DataOutputStream out, Media m) + throws IOException + { + out.writeUTF(m.uri); + writeMaybeString(out, m.title); + out.writeInt(m.width); + out.writeInt(m.height); + out.writeUTF(m.format); + out.writeLong(m.duration); + out.writeLong(m.size); + writeMaybeInt(out, m.hasBitrate, m.bitrate); + out.writeInt(m.persons.size()); + for (String p : m.persons) { + out.writeUTF(p); + } + out.writeByte(m.player.ordinal()); + writeMaybeString(out, m.copyright); + } + + // Image + + private static Image readImage(DataInputStream in) + throws IOException + { + String uri = in.readUTF(); + String title = readMaybeString(in); + int width = in.readInt(); + int height = in.readInt(); + Image.Size size = Image.Size.values()[in.readByte()]; + + return new Image(uri, title, width, height, size); + } + + private static void writeImage(DataOutputStream out, Image im) + throws IOException + { + out.writeUTF(im.uri); + writeMaybeString(out, im.title); + out.writeInt(im.width); + out.writeInt(im.height); + out.writeByte(im.size.ordinal()); + } + } + + public static void writeMaybeString(DataOutputStream out, String s) + throws IOException + { + if (s != null) { + out.writeBoolean(true); + out.writeUTF(s); + } else { + out.writeBoolean(false); + } + } + + public static String readMaybeString(DataInputStream in) + throws IOException + { + if (in.readBoolean()) { + return in.readUTF(); + } else { + return null; + } + } + + public static void writeMaybeInt(DataOutputStream out, boolean exists, int value) + throws IOException + { + if (exists) { + out.writeBoolean(true); + out.writeInt(value); + } else { + out.writeBoolean(false); + } + } +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/MediaItemBenchmark.java b/jvm-serializers-tpc/src/main/java/serializers/MediaItemBenchmark.java new file mode 100644 index 0000000..1c9e01f --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/MediaItemBenchmark.java @@ -0,0 +1,127 @@ +package serializers; + +import java.io.PrintWriter; + +/** + * Intermediate base class for tests that use a single MediaItem + * as data. + * The only method missing is addTests, which defines codecs to use. + */ +public abstract class MediaItemBenchmark extends BenchmarkBase +{ + public MediaItemBenchmark() { } + + protected void runBenchmark(String[] args) { + runBenchmark(args, + Create, + Serialize, + Deserialize); + } + + @Override + protected byte[] serializeForSize(Transformer transformer, Serializer serializer, J value) + throws Exception + { + return serializer.serialize(transformer.forward(value)); + } + + @Override + protected void checkCorrectness(PrintWriter errors, Transformer transformer, + Serializer serializer, J value) + throws Exception + { + checkSingleItem(errors, transformer, serializer, value); + } + + @Override + protected Object convertTestData(TestGroup.Entry loader, Params params, byte[] data) + throws Exception + { + Object deserialized = loader.serializer.deserialize(data); + return loader.transformer.reverse(deserialized); + } + + // ------------------------------------------------------------------------------------ + // Test case objects + // ------------------------------------------------------------------------------------ + + protected final TestCase Create = new TestCase() + { + public double run(Transformer transformer, Serializer serializer, J value, int iterations) throws Exception + { + long start = System.nanoTime(); + for (int i = 0; i < iterations; i++) + { + transformer.forward(value); + } + return iterationTime(System.nanoTime() - start, iterations); + } + }; + + protected final TestCase Serialize = new TestCase() + { + public double run(Transformer transformer, Serializer serializer, J value, int iterations) throws Exception + { + /* 16-Nov-2012, tatu: Time to serialize should consider time to + * convert from POJO to intermediate representation, because + * some format libs (Avro) do significant amount of pre-processing. + * We could do this by adding Create time as well, but this should + * model usual usage bit more accurately. + */ + Object[] objects = new Object[iterations]; + long start = System.nanoTime(); + for (int i = 0; i < iterations; i++) { + Object input = transformer.forward(value); + objects[i] = serializer.serialize(input); + } + return iterationTime(System.nanoTime() - start, iterations); + } + }; + + protected final TestCase Deserialize = new TestCase() + { + public double run(Transformer transformer, Serializer serializer, J value, int iterations) throws Exception + { + byte[] array = serializer.serialize(transformer.forward(value)); + long start = System.nanoTime(); + for (int i = 0; i < iterations; i++) + { + serializer.deserialize(array); + } + return iterationTime(System.nanoTime() - start, iterations); + } + }; + +// 16-May-2012, Nate: As discussed on mailing list, removed these two as they only exist in an attempt to +// make the comparison with ActiveMQProtobuf fair with the rest of the serializers. This adds overhead to +// the rest of the serializers, skewing the results. ActiveMQProtobuf has been disabled, so these aren't needed. +// protected final TestCase DeserializeAndCheck = new TestCase() +// { +// public double run(Transformer transformer, Serializer serializer, J value, int iterations) throws Exception +// { +// byte[] array = serializer.serialize(transformer.forward(value)); +// long start = System.nanoTime(); +// for (int i = 0; i < iterations; i++) +// { +// Object obj = serializer.deserialize(array); +// transformer.reverse(obj); +// } +// return iterationTime(System.nanoTime() - start, iterations); +// } +// }; +// +// protected final TestCase DeserializeAndCheckShallow = new TestCase() +// { +// public double run(Transformer transformer, Serializer serializer, J value, int iterations) throws Exception +// { +// byte[] array = serializer.serialize(transformer.forward(value)); +// long start = System.nanoTime(); +// for (int i = 0; i < iterations; i++) +// { +// Object obj = serializer.deserialize(array); +// transformer.shallowReverse(obj); +// } +// return iterationTime(System.nanoTime() - start, iterations); +// } +// }; +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/MediaStreamBenchmark.java b/jvm-serializers-tpc/src/main/java/serializers/MediaStreamBenchmark.java new file mode 100644 index 0000000..1a26525 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/MediaStreamBenchmark.java @@ -0,0 +1,194 @@ +package serializers; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.PrintWriter; + +import serializers.avro.AvroSpecific; +import serializers.cks.CksText; +import serializers.jackson.*; +import serializers.kryo.Kryo; +import serializers.protobuf.Protobuf; +import serializers.xml.XmlStax; + +/** + * Alternative benchmark which uses a sequence of data items for testing, + * instead of a single item that main test uses. + */ +public class MediaStreamBenchmark extends BenchmarkBase +{ + public static void main(String[] args) { + new MediaStreamBenchmark().runBenchmark(args); + } + + private void runBenchmark(String[] args) { + runBenchmark(args, + Create, + Serialize, + Deserialize); + } + + @Override + protected void addTests(TestGroups groups) + { + // Binary Formats; language-specific ones + JavaManual.register(groups); + Hessian.register(groups); + Kryo.register(groups); + FastSerialization.register(groups); + JBossSerialization.register(groups); + JBossMarshalling.register(groups); + + // Binary formats, generic: protobuf, thrift, avro, CKS, msgpack + Protobuf.register(groups); + Thrift.register(groups); + AvroSpecific.register(groups); + + // JSON + JacksonJsonManual.register(groups); + JacksonJsonDatabind.register(groups); + JacksonWithAfterburner.registerJSON(groups); // databind with bytecode generation (faster) + + // JSON-like + // share both names & values for data streams: + JacksonSmileManual.register(groups, true, true); + JacksonSmileDatabind.register(groups, true, true); + JacksonWithAfterburner.registerSmile(groups, true, true); + + // this one needed to read in test data, too: + CksText.register(groups); + + // XML (only fastest codecs) + XmlStax.register(groups, false, true, true); // skip woodstox, include aalto and fast-infoset + } + + @Override + protected Object convertTestData(TestGroup.Entry loader, Params params, byte[] data) + throws Exception + { + String extra = params.dataExtra; + int count = 0; + try { + count = Integer.parseInt(extra); + } catch (Exception e) { + throw new IllegalArgumentException("Non-integer extra part ('"+extra+"') of data file: must be count"); + } + Object[] deserialized = loader.serializer.deserializeItems(new ByteArrayInputStream(data), count); + return loader.transformer.reverseAll(deserialized); + } + + @Override + protected byte[] serializeForSize(Transformer transformer, Serializer serializer, J value) + throws Exception + { + @SuppressWarnings("unchecked") + Object[] result = transformer.forwardAll((J[]) value); + return serializer.serializeAsBytes(result); + } + + @Override + protected void checkCorrectness(PrintWriter errors, Transformer transformer, + Serializer serializer, J input) + throws Exception + { + // nasty cast, but works (and has to be used) here: + @SuppressWarnings("unchecked") + J[] items = (J[]) input; + for (J item : items) { + checkSingleItem(errors, transformer, serializer, item); + } + } + + // ------------------------------------------------------------------------------------ + // Test case objects + // ------------------------------------------------------------------------------------ + + protected final TestCase Create = new TestCase() + { + public double run(Transformer transformer, Serializer serializer, J value, int iterations) throws Exception + { + @SuppressWarnings("unchecked") + J[] src = (J[]) value; + Object[] result = new Object[src.length]; + long start = System.nanoTime(); + for (int i = 0; i < iterations; i++) { + transformer.forward(src, result); + } + return iterationTime(System.nanoTime() - start, iterations); + } + }; + + protected final TestCase Serialize = new TestCase() + { + public double run(Transformer transformer, Serializer serializer, J value, int iterations) throws Exception + { + @SuppressWarnings("unchecked") + J[] src = (J[]) value; + Object[][] objects = new Object[iterations][]; + for (int i = 0; i < iterations; i++) { + objects[i] = transformer.forwardAll(src); + } + ByteArrayOutputStream out = serializer.outputStreamForList(src); + long start = System.nanoTime(); + for (int i = 0; i < iterations; i++) { + serializer.serializeItems(objects[i], out); + out.reset(); + } + return iterationTime(System.nanoTime() - start, iterations); + } + }; + + protected final TestCase Deserialize = new TestCase() + { + public double run(Transformer transformer, Serializer serializer, J value, int iterations) throws Exception + { + @SuppressWarnings("unchecked") + J[] src = (J[]) value; + byte[] bytes = serializer.serializeAsBytes(transformer.forwardAll(src)); + long start = System.nanoTime(); + for (int i = 0; i < iterations; i++) { + serializer.deserializeItems(new ByteArrayInputStream(bytes), src.length); + } + return iterationTime(System.nanoTime() - start, iterations); + } + }; + +// 16-May-2012, Nate: As discussed on mailing list, removed these two as they only exist in an attempt to +// make the comparison with ActiveMQProtobuf fair with the rest of the serializers. This adds overhead to +// the rest of the serializers, skewing the results. ActiveMQProtobuf has been disabled, so these aren't needed. +// protected final TestCase DeserializeAndCheck = new TestCase() +// { +// public double run(Transformer transformer, Serializer serializer, J value, int iterations) throws Exception +// { +// @SuppressWarnings("unchecked") +// J[] src = (J[]) value; +// byte[] bytes = serializer.serializeAsBytes(transformer.forwardAll(src)); +// long start = System.nanoTime(); +// for (int i = 0; i < iterations; i++) { +// Object[] items = serializer.deserializeItems(new ByteArrayInputStream(bytes), src.length); +// for (Object item : items) { +// transformer.reverse(item); +// } +// } +// return iterationTime(System.nanoTime() - start, iterations); +// } +// }; +// +// protected final TestCase DeserializeAndCheckShallow = new TestCase() +// { +// public double run(Transformer transformer, Serializer serializer, J value, int iterations) throws Exception +// { +// @SuppressWarnings("unchecked") +// J[] src = (J[]) value; +// byte[] bytes = serializer.serializeAsBytes(transformer.forwardAll(src)); +// long start = System.nanoTime(); +// for (int i = 0; i < iterations; i++) { +// Object[] items = serializer.deserializeItems(new ByteArrayInputStream(bytes), src.length); +// for (Object item : items) { +// transformer.shallowReverse(item); +// } +// } +// return iterationTime(System.nanoTime() - start, iterations); +// } +// }; +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/MiscFeatures.java b/jvm-serializers-tpc/src/main/java/serializers/MiscFeatures.java new file mode 100644 index 0000000..b8bd1f3 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/MiscFeatures.java @@ -0,0 +1,35 @@ +package serializers; + +/** + * Copyright (c) 2012, Ruediger Moeller. All rights reserved. + *

+ * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + *

+ * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + *

+ * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + *

+ * Date: 11.03.14 + * Time: 19:48 + * To change this template use File | Settings | File Templates. + */ + +/** + * describes misc miscFeatures a serializer might have. + */ +public enum MiscFeatures { + VERSIONING_BACKWARD_COMPATIBLE, + VERSIONING_FORWARD_COMPATIBLE, + VERSIONING_MISMATCH_DETECTION, + CONTAINS_SCHEMA, + OPTIMIZATION_BY_ANNOTATION +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/MongoDB.java b/jvm-serializers-tpc/src/main/java/serializers/MongoDB.java new file mode 100644 index 0000000..c323d38 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/MongoDB.java @@ -0,0 +1,233 @@ +package serializers; + +import static data.media.FieldMapping.*; + +import java.util.ArrayList; +import java.util.List; + +import org.bson.BSONDecoder; +import org.bson.BSONEncoder; +import org.bson.BSONObject; +import org.bson.BasicBSONObject; +import org.bson.types.BasicBSONList; + +import data.media.Image; +import data.media.Media; +import data.media.MediaContent; + +public class MongoDB +{ + public static void register(TestGroups groups) + { + groups.media.add(JavaBuiltIn.mediaTransformer, new MongoDBSerializer(), + new SerFeatures( + SerFormat.BIN_CROSSLANG, + SerGraph.FLAT_TREE, + SerClass.MANUAL_OPT, + "" + ) + ); + } + + public static final class MongoDBSerializer extends Serializer + { + @Override + public String getName() + { + return "bson/mongodb/manual"; + } + + @Override + public byte[] serialize(MediaContent data) throws Exception + { + BSONObject o = new BasicBSONObject(); + + BSONObject media = serializeMedia(data.media); + o.put(FULL_FIELD_NAME_MEDIA, media); + + BSONObject[] images = new BSONObject[data.images.size()]; + int j = 0; + for (Image i : data.images) + { + images[j++] = serializeImage(i); + } + + o.put(FULL_FIELD_NAME_IMAGES, images); + + BSONEncoder enc = new BSONEncoder(); + return enc.encode(o); + } + + protected BSONObject serializeMedia(Media media) + { + BSONObject r = new BasicBSONObject(); + + r.put(FULL_FIELD_NAME_PLAYER, media.player.name()); + r.put(FULL_FIELD_NAME_URI, media.uri); + if (media.title != null) + r.put(FULL_FIELD_NAME_TITLE, media.title); + r.put(FULL_FIELD_NAME_WIDTH, media.width); + r.put(FULL_FIELD_NAME_HEIGHT, media.height); + r.put(FULL_FIELD_NAME_FORMAT, media.format); + r.put(FULL_FIELD_NAME_DURATION, media.duration); + r.put(FULL_FIELD_NAME_SIZE, media.size); + if (media.hasBitrate) + r.put(FULL_FIELD_NAME_BITRATE, media.bitrate); + if (media.copyright != null) + r.put(FULL_FIELD_NAME_COPYRIGHT, media.copyright); + r.put(FULL_FIELD_NAME_PERSONS, media.persons); + + return r; + } + + protected BSONObject serializeImage(Image image) + { + BSONObject r = new BasicBSONObject(); + + r.put(FULL_FIELD_NAME_URI, image.uri); + if (image.title != null) + r.put(FULL_FIELD_NAME_TITLE, image.title); + r.put(FULL_FIELD_NAME_WIDTH, image.width); + r.put(FULL_FIELD_NAME_HEIGHT, image.height); + r.put(FULL_FIELD_NAME_SIZE, image.size.name()); + + return r; + } + + public MediaContent deserialize(byte[] array) throws Exception + { + MediaContent r = new MediaContent(); + + BSONDecoder dec = new BSONDecoder(); + BSONObject o = dec.readObject(array); + for (String name : o.keySet()) + { + Integer i = fullFieldToIndex.get(name); + if (i != null) + { + switch (i) + { + case FIELD_IX_MEDIA: + r.media = deserializeMedia((BSONObject)o.get(name)); + continue; + + case FIELD_IX_IMAGES: + r.images = deserializeImages((BasicBSONList)o.get(name)); + continue; + } + } + throw new IllegalStateException("Unexpected field '" + name + "'"); + } + + return r; + } + + protected Media deserializeMedia(BSONObject media) { + Media r = new Media(); + + for (String name : media.keySet()) + { + Integer i = fullFieldToIndex.get(name); + if (i != null) + { + switch (i) + { + case FIELD_IX_PLAYER: + r.player = Media.Player.valueOf((String)media.get(name)); + continue; + + case FIELD_IX_URI: + r.uri = (String)media.get(name); + continue; + + case FIELD_IX_TITLE: + r.title = (String)media.get(name); + continue; + + case FIELD_IX_WIDTH: + r.width = (Integer)media.get(name); + continue; + + case FIELD_IX_HEIGHT: + r.height = (Integer)media.get(name); + continue; + + case FIELD_IX_FORMAT: + r.format = (String)media.get(name); + continue; + + case FIELD_IX_DURATION: + r.duration = (Long)media.get(name); + continue; + + case FIELD_IX_SIZE: + r.size = (Long)media.get(name); + continue; + + case FIELD_IX_BITRATE: + r.bitrate = (Integer)media.get(name); + r.hasBitrate = true; + continue; + + case FIELD_IX_PERSONS: + BasicBSONList pl = (BasicBSONList)media.get(name); + List persons = new ArrayList(); + for (Object o : pl) { + persons.add((String)o); + } + r.persons = persons; + continue; + + case FIELD_IX_COPYRIGHT: + r.copyright = (String)media.get(name); + continue; + } + } + throw new IllegalStateException("Unexpected field '" + name + "'"); + } + + return r; + } + + protected List deserializeImages(BasicBSONList images) { + List r = new ArrayList(); + for (Object o : images) { + r.add(deserializeImage((BSONObject)o)); + } + return r; + } + + protected Image deserializeImage(BSONObject image) { + Image r = new Image(); + + for (String name : image.keySet()) + { + Integer i = fullFieldToIndex.get(name); + if (i != null) + { + switch (i) + { + case FIELD_IX_URI: + r.uri = (String)image.get(name); + continue; + case FIELD_IX_TITLE: + r.title = (String)image.get(name); + continue; + case FIELD_IX_WIDTH: + r.width = (Integer)image.get(name); + continue; + case FIELD_IX_HEIGHT: + r.height = (Integer)image.get(name); + continue; + case FIELD_IX_SIZE: + r.size = Image.Size.valueOf((String)image.get(name)); + continue; + } + } + throw new IllegalStateException("Unexpected field '" + name + "'"); + } + + return r; + } + } +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/Obser.java b/jvm-serializers-tpc/src/main/java/serializers/Obser.java new file mode 100644 index 0000000..9650df6 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/Obser.java @@ -0,0 +1,173 @@ + +package serializers; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.nio.ByteBuffer; +import java.util.ArrayList; + +import data.media.Image; +import data.media.Media; +import data.media.MediaContent; +import data.media.MediaContentCustom; +import net.sockali.obser.ObserEncoding; +import net.sockali.obser.ObserFactory; + +@SuppressWarnings("unchecked") +public class Obser { + public static void register (TestGroups groups) { + register(groups.media, JavaBuiltIn.mediaTransformer); + } + + private static void register (TestGroup group, Transformer transformer) { + group.add(transformer, new BasicSerializer(), + new SerFeatures( + SerFormat.BINARY, + SerGraph.FULL_GRAPH, + SerClass.CLASSES_KNOWN, + "" + ) + ); + group.add(transformer, new CompactSerializer(), + new SerFeatures( + SerFormat.BINARY, + SerGraph.FULL_GRAPH, + SerClass.CLASSES_KNOWN, + "" + ) + ); + group.add(transformer, new CustomSerializer(), + new SerFeatures( + SerFormat.BINARY, + SerGraph.FULL_GRAPH, + SerClass.MANUAL_OPT, + "" + ) + ); + group.add(transformer, new CustomCompactSerializer(), + new SerFeatures( + SerFormat.BINARY, + SerGraph.FULL_GRAPH, + SerClass.MANUAL_OPT, + "" + ) + ); + } + + + // ------------------------------------------------------------ + // Serializers + + public static class BasicSerializer extends Serializer { + final net.sockali.obser.Obser obser; +// private final byte[] buffer = new byte[1024*1024]; + private ByteBuffer buffer = ByteBuffer.allocateDirect(1024*1024); + + public BasicSerializer () { + this.obser = ObserFactory.createObser(ObserEncoding.nativeEncoding()); + obser.registerClass(data.media.MediaContentCustom.class); + obser.registerClass(MediaContent.class); + obser.registerClass(Media.class); + obser.registerClass(Media.Player.class); + obser.registerClass(Image.class); + obser.registerClass(Image.Size.class); + obser.registerClass(ArrayList.class); + obser.registerClass(MediaContent[].class); + obser.registerClass(MediaContentCustom[].class); + } + + @Override + public T deserialize (byte[] array) { + buffer.position(0); + buffer.put(array); + + return (T) obser.deserialize(buffer, 0); + } + + @Override + public byte[] serialize (T content) { + buffer.position(0); + int pos = obser.serialize(content, buffer, 0); + byte[] ret = new byte[pos]; + buffer.get(ret); + return ret; + } + + @Override + public void serializeItems (T[] items, OutputStream outStream) throws Exception { + obser.serialize(items, outStream); + } + + @Override + public T[] deserializeItems (InputStream inStream, int numberOfItems) throws IOException { + return obser.deserialize(inStream); + } + + @Override + public String getName () { + return "obser"; + } + } + + public static class CompactSerializer extends BasicSerializer { + public CompactSerializer () { + super(); + obser.setEncoding(ObserEncoding.nativeCompactEncoding()); + } + + @Override + public String getName () { + return "obser-compact"; + } + } + + public static class CustomSerializer extends BasicSerializer { + @Override + public byte[] serialize(Object content) { + MediaContentCustom mcc = new MediaContentCustom((MediaContent) content); + return super.serialize(mcc); + } + + @Override + public MediaContent deserialize(byte[] array) { + MediaContentCustom mcc = (MediaContentCustom) ((Object) super.deserialize(array)); + return mcc.getContent(); + } + + @Override + public void serializeItems(Object[] items, OutputStream outStream) throws Exception { + MediaContentCustom[] data = new MediaContentCustom[items.length]; + for (int i=0; i sdata} + +object Scala +{ + def register(groups: TestGroups) + { + groups.media.add(MediaTransformer, new JavaBuiltIn.GenericSerializer[sdata.media.MediaContent]("scala/java-built-in")) + groups.media.add(MediaTransformer, MediaSerializer) + } + + // -------------------------------------------------------------------------- + // MediaContent + + object MediaTransformer extends data.media.MediaTransformer[sdata.media.MediaContent] + { + import sdata.media._ + + def forward(mc: data.media.MediaContent) : MediaContent = + new MediaContent(forwardMedia(mc.media), List.concat(mc.images.map(forwardImage))) + + def forwardMedia(m: data.media.Media) : Media = + new Media( + m.uri, + nullToOption(m.title), + m.width, + m.height, + m.format, + m.duration, + m.size, + if (m.hasBitrate) Some(m.bitrate) else None, + List.concat(m.persons), + forwardPlayer(m.player), + nullToOption(m.copyright)) + + def forwardPlayer(p: data.media.Media.Player) : Media.Player = p match { + case data.media.Media.Player.JAVA => Media.Player.Java + case data.media.Media.Player.FLASH => Media.Player.Flash + } + + def forwardImage(im: data.media.Image) : Image = + new Image( + im.uri, + nullToOption(im.title), + im.width, + im.height, + forwardSize(im.size)) + + def forwardSize(s: data.media.Image.Size) = s match { + case data.media.Image.Size.SMALL => Image.Size.Small + case data.media.Image.Size.LARGE => Image.Size.Large + } + + def reverse(mc: MediaContent) : data.media.MediaContent = + new data.media.MediaContent(reverseMedia(mc.media), new ArrayList(mc.images.map(reverseImage))) + + def reverseMedia(m: Media) : data.media.Media = + new data.media.Media( + m.uri, + m.title.getOrElse(null), + m.width, + m.height, + m.format, + m.duration, + m.size, + m.bitrate.getOrElse(0), + m.bitrate.isDefined, + new ArrayList(m.persons), + reversePlayer(m.player), + m.copyright.getOrElse(null)) + + def reversePlayer(s: Media.Player) : data.media.Media.Player = s match { + case Media.Player.Java => data.media.Media.Player.JAVA + case Media.Player.Flash => data.media.Media.Player.FLASH + } + + def reverseImage(im: Image) : data.media.Image = + new data.media.Image( + im.uri, + im.title.getOrElse(null), + im.width, + im.height, + reverseSize(im.size)) + + def reverseSize(s: Image.Size) : data.media.Image.Size = s match { + case Image.Size.Small => data.media.Image.Size.SMALL + case Image.Size.Large => data.media.Image.Size.LARGE + } + + def shallowReverse(mc: MediaContent) : data.media.MediaContent = + new data.media.MediaContent(reverseMedia(mc.media), new ArrayList()) + + } + + def nullToOption(s: String) = + if (s == null) None else Some(s) + + // ------------------------------------------------------- + // SBinary Serializers + + object MediaSerializer extends Serializer[sdata.media.MediaContent] + { + import sdata.media._ + + def getName = "scala/sbinary" + def serialize(content: MediaContent) = Operations.toByteArray[MediaContent](content)(MediaProtocol.MediaContentFormat) + def deserialize(array: Array[Byte]) = Operations.fromByteArray[MediaContent](array)(MediaProtocol.MediaContentFormat) + } + + object MediaProtocol extends DefaultProtocol + { + import sdata.media._ + import Operations.{read, write} + + implicit object MediaContentFormat extends Format[MediaContent] + { + def reads(in : Input) = + new MediaContent( + read[Media](in)(MediaFormat), + read[List[Image]](in)(listFormat(ImageFormat))) + + def writes(out : Output, value : MediaContent) = { + write[Media](out, value.media)(MediaFormat) + write[List[Image]](out, value.images)(listFormat(ImageFormat)) + } + } + + implicit object MediaFormat extends Format[Media] + { + def reads(in : Input) = + new Media( + read[String](in), + read[Option[String]](in), + read[Int](in), + read[Int](in), + read[String](in), + read[Long](in), + read[Long](in), + read[Option[Int]](in), + read[List[String]](in), + read[Media.Player](in)(PlayerFormat), + read[Option[String]](in)) + + def writes(out : Output, value : Media) = { + write[String](out, value.uri) + write[Option[String]](out, value.title) + write[Int](out, value.width) + write[Int](out, value.height) + write[String](out, value.format) + write[Long](out, value.duration) + write[Long](out, value.size) + write[Option[Int]](out, value.bitrate) + write[List[String]](out, value.persons) + write[Media.Player](out, value.player)(PlayerFormat) + write[Option[String]](out, value.copyright) + } + } + + implicit object ImageFormat extends Format[Image] + { + def reads(in : Input) = + Image( + read[String](in), + read[Option[String]](in), + read[Int](in), + read[Int](in), + read[Image.Size](in)(SizeFormat)) + + def writes(out : Output, value : Image) { + write[String](out, value.uri) + write[Option[String]](out, value.title) + write[Int](out, value.width) + write[Int](out, value.height) + write[Image.Size](out, value.size)(SizeFormat) + } + } + + implicit object PlayerFormat extends Format[Media.Player] + { + def reads(in : Input) = read[Byte](in) match { + case 0 => Media.Player.Java + case 1 => Media.Player.Flash + } + + def writes(out : Output, value : Media.Player) { + write[Byte](out, value match { + case Media.Player.Java => 0 + case Media.Player.Flash => 1 + }) + } + } + + implicit object SizeFormat extends Format[Image.Size] + { + def reads(in : Input) = read[Byte](in) match { + case 0 => Image.Size.Small + case 1 => Image.Size.Large + } + + def writes(out : Output, value : Image.Size) { + write[Byte](out, value match { + case Image.Size.Small => 0 + case Image.Size.Large => 1 + }) + } + } + } +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/SerClass.java b/jvm-serializers-tpc/src/main/java/serializers/SerClass.java new file mode 100644 index 0000000..430ef6a --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/SerClass.java @@ -0,0 +1,43 @@ +package serializers; + +/** + * Copyright (c) 2012, Ruediger Moeller. All rights reserved. + *

+ * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + *

+ * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + *

+ * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + *

+ * Date: 09.03.14 + * Time: 11:31 + * To change this template use File | Settings | File Templates. + */ +public enum SerClass { + /** + * nothing must be known in advance or language built-in (e.g. JDK Serializable) + */ + ZERO_KNOWLEDGE, + /** + * requires knowledge in advance which classes can be serialized. Preconfiguration/Code Generation required + */ + CLASSES_KNOWN, + /** + * requires knowledge in advance which classes can be serialized. Preconfiguration/Code Generation required + * additionally field specific manually written read/write code + */ + MANUAL_OPT, + /** + * add new category if you fall into this :-) + */ + MISC +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/SerFeatures.java b/jvm-serializers-tpc/src/main/java/serializers/SerFeatures.java new file mode 100644 index 0000000..e598c86 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/SerFeatures.java @@ -0,0 +1,113 @@ +package serializers; + +import java.util.EnumSet; +import java.util.Formatter; + +/** + * Copyright (c) 2012, Ruediger Moeller. All rights reserved. + *

+ * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + *

+ * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + *

+ * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + *

+ * Date: 09.03.14 + * Time: 11:41 + * To change this template use File | Settings | File Templates. + */ +public class SerFeatures { + SerFormat format = SerFormat.MISC; + SerGraph graph = SerGraph.UNKNOWN; + SerClass clz = SerClass.MISC; + // FIXME: should have used one EnumSet from the beginning so we could get rid of + // SerFormat,SerGraph,SerClass .. sigh. Too lazy to change this now :-). ruediger + EnumSet miscFeatures = EnumSet.noneOf(MiscFeatures.class); + String description; + + public SerFeatures() { + } + + public SerFeatures(SerFormat format, SerGraph graph, SerClass clz) { + this.format = format; + this.graph = graph; + this.clz = clz; + } + + public SerFeatures(SerFormat format, SerGraph graph, SerClass clz, String description) { + this.format = format; + this.graph = graph; + this.clz = clz; + this.description = description; + } + + public SerFeatures(SerFormat format, SerGraph graph, SerClass clz, String description, EnumSet features) { + this.format = format; + this.graph = graph; + this.clz = clz; + this.miscFeatures = features; + this.description = description; + } + + public EnumSet getMiscFeatures() { + return miscFeatures; + } + + public void setMiscFeatures(EnumSet miscFeatures) { + this.miscFeatures = miscFeatures; + } + + public String toString(String name) { + Formatter format = new Formatter().format( + "%-34s %-15s %-14s %-10s %-60s", + name, + getClz(), + getFormat(), + getGraph(), + getMiscFeatures()+" "+getDescription() + ); + return format.toString(); + } + + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public SerFormat getFormat() { + return format; + } + + public void setFormat(SerFormat format) { + this.format = format; + } + + public SerGraph getGraph() { + return graph; + } + + public void setGraph(SerGraph graph) { + this.graph = graph; + } + + public SerClass getClz() { + return clz; + } + + public void setClz(SerClass clz) { + this.clz = clz; + } +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/SerFormat.java b/jvm-serializers-tpc/src/main/java/serializers/SerFormat.java new file mode 100644 index 0000000..f5a3b31 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/SerFormat.java @@ -0,0 +1,46 @@ +package serializers; + +/** + * Copyright (c) 2012, Ruediger Moeller. All rights reserved. + *

+ * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + *

+ * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + *

+ * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + *

+ * Date: 09.03.14 + * Time: 11:29 + */ +public enum SerFormat { + /** + * unspecified binary format (e.g. JDK serialization) + */ + BINARY, + /** + * specified binary format which might be read by another language/implementation + */ + BIN_CROSSLANG, + /** + * text based JSon format + */ + JSON, + /** + * text based XML format + */ + XML, + /** + * none of the above + */ + MISC +} + diff --git a/jvm-serializers-tpc/src/main/java/serializers/SerGraph.java b/jvm-serializers-tpc/src/main/java/serializers/SerGraph.java new file mode 100644 index 0000000..0cb0a65 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/SerGraph.java @@ -0,0 +1,35 @@ +package serializers; + +/** + * Copyright (c) 2012, Ruediger Moeller. All rights reserved. + *

+ * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + *

+ * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + *

+ * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + *

+ * Date: 09.03.14 + * Time: 11:36 + * To change this template use File | Settings | File Templates. + */ +public enum SerGraph { + /** + * cannot process object graphs containing cyclic references (flat tree only) + */ + FLAT_TREE, + /** + * capable of read/write fully linked object graphs with reference restauration + */ + FULL_GRAPH, + UNKNOWN +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/Serializer.java b/jvm-serializers-tpc/src/main/java/serializers/Serializer.java new file mode 100644 index 0000000..8cbe591 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/Serializer.java @@ -0,0 +1,68 @@ +package serializers; + +import java.io.*; + +public abstract class Serializer +{ + /** + * Buffer size for serializers. Defaults to 1024 and can be changed + * via system properties. Minimum set to 256. + */ + public static final int BUFFER_SIZE = Math.max( + Integer.getInteger("buffer_size", 1024), 256); + + public abstract S deserialize(byte[] array) throws Exception; + public abstract byte[] serialize(S content) throws Exception; + public abstract String getName(); + + SerFeatures features = new SerFeatures(); // ruediger: everything misc by default. + + public ByteArrayOutputStream outputStream (S content) { + return new ByteArrayOutputStream(BUFFER_SIZE); + } + + public SerFeatures getFeatures() { + return features; + } + + public void setFeatures(SerFeatures features) { + this.features = features; + } + + // And then bit bigger default when serializing a list or array + public ByteArrayOutputStream outputStreamForList (S[] items) { + return new ByteArrayOutputStream(BUFFER_SIZE * items.length); + } + + // Multi-item interfaces + + public S[] deserializeItems(InputStream in, int numberOfItems) throws Exception { + throw new UnsupportedOperationException("Not implemented"); + } + + public void serializeItems(S[] items, OutputStream out) throws Exception { + throw new UnsupportedOperationException("Not implemented"); + } + + @SuppressWarnings("resource") + public final byte[] serializeAsBytes(S[] items) throws Exception { + ByteArrayOutputStream bytes = outputStreamForList(items); + serializeItems(items, bytes); + return bytes.toByteArray(); + } + + // // // Helper methods + + protected byte[] readAll(InputStream in) throws IOException + { + ByteArrayOutputStream bytes = new ByteArrayOutputStream(4000); + byte[] buffer = new byte[4000]; + int count; + + while ((count = in.read(buffer)) >= 0) { + bytes.write(buffer, 0, count); + } + in.close(); + return bytes.toByteArray(); + } +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/SimpleClassLoader.java b/jvm-serializers-tpc/src/main/java/serializers/SimpleClassLoader.java new file mode 100644 index 0000000..31a03a8 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/SimpleClassLoader.java @@ -0,0 +1,63 @@ +package serializers; + +import java.io.*; +import java.util.*; +import java.util.zip.*; + +/** + * Class loader to use for loading non-shared implementation classes. This is necessary so + * that implementation classes can be loaded in, and as importantly, swapped out, + * before and after test run. + * + * @author tatu + */ +public class SimpleClassLoader + extends ClassLoader +{ + private final HashMap loadedByteCode = new HashMap(); + + public SimpleClassLoader(ClassLoader parent, File dir) throws IOException + { + ByteArrayOutputStream bytes = new ByteArrayOutputStream(); + byte[] buffer = new byte[8000]; + + for (File file : dir.listFiles()) { + if (!file.getName().endsWith(".jar")) continue; + ZipInputStream zis = new ZipInputStream(new FileInputStream(file)); + ZipEntry entry; + + while ((entry = zis.getNextEntry()) != null) { + String name = entry.getName(); + if (name.endsWith(".class")) { + // strip out ".class"; replace '/' with '.' + String className = name.substring(0, name.length()-6); + className = className.replace('/', '.'); + byte[] data = readAll(zis, buffer, bytes); + if (loadedByteCode.put(name, data) != null) { + throw new IllegalArgumentException("Duplicate class '"+className+"' (from jar '"+file.getPath()+"')"); + } + } + } + } + } + + @Override + public Class findClass(String name) + { + byte[] bytecode = loadedByteCode.get(name); + if (bytecode == null) return null; + return defineClass(name, bytecode, 0, bytecode.length); + } + + private final byte[] readAll(InputStream in, byte[] buffer, ByteArrayOutputStream bytes) throws IOException + { + bytes.reset(); + + int count; + + while ((count = in.read(buffer)) > 0) { + bytes.write(buffer, 0, count); + } + return bytes.toByteArray(); + } +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/StatsCruncher.java b/jvm-serializers-tpc/src/main/java/serializers/StatsCruncher.java new file mode 100644 index 0000000..84c2139 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/StatsCruncher.java @@ -0,0 +1,534 @@ +package serializers; + +/** + * Copyright (c) 2012, Ruediger Moeller. All rights reserved. + *

+ * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + *

+ * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + *

+ * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + *

+ * Date: 08.03.14 + * Time: 22:08 + * To change this template use File | Settings | File Templates. + */ + +import java.io.*; +import java.lang.reflect.Field; +import java.net.URLEncoder; +import java.util.*; + +/** + * smallish program to read in the stats created by isolated runs (see new runscripts) + *

+ * 1. run-script runs each test in an isolated VM + * 2. the stats script collects result to stats.txt and runs this class to produce various charts from the bench data + *

+ * this helps in filtering out outliers / modify charts without having to run the tests + *

+ * assumes to be run in the same working dir as the bash run script + */ +public class StatsCruncher { + + public static final int MAX_CHART_BARS = 18; + HashMap mappedFeatures = new HashMap(); + HashMap mappedResults; + + static SerFormat BIN = SerFormat.BINARY; + static SerFormat BIN_CL = SerFormat.BIN_CROSSLANG; + static SerFormat JSON = SerFormat.JSON; + static SerFormat XML = SerFormat.XML; + static SerFormat MISC = SerFormat.MISC; + + public StatsCruncher() { + mappedFeatures = new BenchmarkExporter().getFeatureMap(); + } + + // ruediger: funny i am falling back to old school text parsing with +20 serializers on board ;-) + List readStats(String inputFile) throws IOException { + BufferedReader din = new BufferedReader(new InputStreamReader(new FileInputStream(inputFile))); + + mappedResults = new HashMap(); + List results = new ArrayList(); + + String line; + while ((line = din.readLine()) != null) { + String split[] = line.split("\\s+"); + if (split == null || split.length < 2) { + continue; + } + String split1 = split[1].trim(); + if (split1.length() == 0 || !Character.isDigit(split1.charAt(0))) { + continue; + } + TestCaseResult res = new TestCaseResult(); + res.setName(split[0].trim()); + res.setCreate(Integer.parseInt(split1.trim())); + res.setSer(Integer.parseInt(split[2].trim())); + res.setDeser(Integer.parseInt(split[3].trim())); + res.setTotal(Integer.parseInt(split[4].trim())); + res.setSize(Integer.parseInt(split[5].trim())); + res.setCompressedSize(Integer.parseInt(split[6].trim())); + mappedResults.put(res.getName(), res); + res.setFeatures(mappedFeatures.get(res.getName())); + results.add(res); + } + din.close(); + return results; + } + + public int max(List resultList, String arg, int elems) { + int max = Integer.MIN_VALUE; + for (int i = 0; i < Math.min(elems,resultList.size()); i++) { + TestCaseResult testCaseResult = resultList.get(i); + max = Math.max(testCaseResult.getInt(arg),max); + } + return max; + } + + public int min(List resultList, String arg) { + int min = Integer.MAX_VALUE; + for (int i = 0; i < resultList.size(); i++) { + TestCaseResult testCaseResult = resultList.get(i); + min = Math.min(testCaseResult.getInt(arg),min); + } + return min; + } + + public String generateChart(List resultList, String title, String lowerValueName, String higherValueName) { + int chartSize = Math.min(MAX_CHART_BARS, resultList.size() ); // more bars aren't possible with gcharts + int max = max(resultList, higherValueName, MAX_CHART_BARS); + String res = "https://chart.googleapis.com/chart?cht=bhs&chs=600x"+(chartSize *20+14); // html: finally a device independent technology +// res+="&chtt="+URLEncoder.encode(title); + res+="&chd=t:"; + for (int i = 0; i < chartSize; i++) { + TestCaseResult testCaseResult = resultList.get(i); + int val = testCaseResult.getInt(lowerValueName); + res+= val +((i< chartSize -1) ? ",":"|"); + } + for (int i = 0; i < chartSize; i++) { + TestCaseResult testCaseResult = resultList.get(i); + int valLower = (testCaseResult.getInt(lowerValueName)); + int val = testCaseResult.getInt(higherValueName); + val -= valLower; + res+=val+((i< chartSize -1) ? ",":""); + } + res += "&chco=5d99f9,4d89f9"; + res += "&chdlp=t"; + res += "&chbh=15"; + res += "&chds=0,"+max; + res += "&chxr=1,0,"+max; + res += "&chxt=y,x&chxl=0:|"; + for (int i = 0; i < chartSize; i++) { + TestCaseResult testCaseResult = resultList.get(chartSize -i-1); + res += urlEncode(testCaseResult.getName())+((i< chartSize -1) ? "|":""); + } + return ""+title+"
"; + } + + private static String urlEncode(String s) + { + try { + return URLEncoder.encode(s, "UTF-8"); + } + catch (java.io.UnsupportedEncodingException ex) { + throw new AssertionError("UTF-8 not supported? " + ex); + } + } + + /** + * + * @param commaSeparatedNames - * for all + * @param intFieldToSort - result field name to sort for (create ser deser total size compressedSize) + * @param maxRangeDiff - max distance of min value (remove outliers) + * @param maxListLen - max number of entries in result + * @return + */ + public List generateChartList(List resultList, + String commaSeparatedNames, final String intFieldToSort, int maxRangeDiff, int maxListLen, SerFeatures featureFilter) + { + String toChart[] = commaSeparatedNames.split(","); + List chartList = new ArrayList(); + if ( commaSeparatedNames.equals("*") ) { + chartList.addAll(resultList); + } else { + for (int i = 0; i < toChart.length; i++) { + toChart[i] = toChart[i].trim(); + TestCaseResult res = mappedResults.get(toChart[i]); + if ( res == null ) { + System.out.println("Cannot chart "+toChart[i]+" (not found in stats)"); + } else { + chartList.add(res); + } + } + } + chartList = sort(intFieldToSort, chartList); + // process feature filter (I am in dirt mode here ..) + for (int i = 0; i < chartList.size(); i++) { + TestCaseResult testCaseResult = chartList.get(i); + SerFeatures feature = testCaseResult.getFeatures(); + if ( feature != null ) { + if ( + ( featureFilter.getClz() != null && ! featureFilter.getClz().equals(feature.getClz()) ) || + ( featureFilter.getFormat() != null && ! featureFilter.getFormat().equals(feature.getFormat()) ) || + ( featureFilter.getGraph() != null && ! featureFilter.getGraph().equals(feature.getGraph()) ) + ) + { + chartList.remove(i--); + } + } else { + System.out.println("feature is unexpectedly null for "+testCaseResult.getName()); + chartList.remove(i--); + } + } + + // process rangeDiff and maxLen + int min = min(chartList,intFieldToSort); + for (int i = 0; i < chartList.size(); i++) { + TestCaseResult testCaseResult = chartList.get(i); + if ( min * maxRangeDiff < testCaseResult.getInt(intFieldToSort) || i >= maxListLen ) + chartList.remove(i--); + } + return chartList; + } + + protected List sort(final String intFieldToSort, List chartList) { + List res = new ArrayList(chartList); + Collections.sort(res, new Comparator() { + @Override + public int compare(TestCaseResult o1, TestCaseResult o2) { + return o1.getInt(intFieldToSort) - o2.getInt(intFieldToSort); + } + }); + return res; + } + + String dump(List total) { + String res = "\n

                                   create     ser   deser   total   size  +dfl\n";
+        for (int i = 0; i < total.size(); i++) {
+            TestCaseResult testCaseResult = total.get(i);
+            res+=testCaseResult.toString()+"\n";
+        }
+        return res+"
\n"; + } + + String dumpFeatures(List total) { + String res = "\n
                                   Effort          Format         Structure  Misc\n";
+        for (int i = 0; i < total.size(); i++) {
+            TestCaseResult testCaseResult = total.get(i);
+            res+=testCaseResult.getFeatures().toString(testCaseResult.getName())+"\n";
+        }
+        return res+"
\n"; + } + + String generateResultSection(List testCaseResults, String title, String desc) { + return "\n\n

"+title+"

\n"+desc+"\n"+ + generateChart(testCaseResults,"Ser Time+Deser Time (ns)","ser","total")+"\n
"+ + generateChart( sort("size",testCaseResults),"Size, Compressed size [light] in bytes","compressedSize","size")+"\n
"+ + dump(testCaseResults); + } + + ////////////////////////////////////////////////////////////////////////////////// + + + // i just keep everything in code .. configfiles would add additional complexity and a query language .. + // the report is built to be displayed with Textile + public static void main(String args[]) throws Exception { + if (args.length != 2) { + System.err.println("Usage: COMMAND "); + System.exit(1); + return; + } + + String inputFile = args[0]; + String outputFile = args[1]; + + StatsCruncher statsCruncher = new StatsCruncher(); + List stats = statsCruncher.readStats(inputFile); + +// PrintStream out = System.out; + PrintStream out = new PrintStream(new FileOutputStream(outputFile)); + + out.println("

Test Platform

"); + out.println("OS:"+System.getProperty("os.name")); + out.println("JVM:"+System.getProperty("java.vendor")+" "+System.getProperty("java.version")); + out.println("CPU:"+System.getenv("PROCESSOR_IDENTIFIER")+" os-arch:"+System.getenv("PROCESSOR_ARCHITECTURE")); + out.println("Cores (incl HT):"+Runtime.getRuntime().availableProcessors()); + out.println(); + + out.println("

Disclaimer

\n" + + "\n" + + "This test focusses on en/decoding of a cyclefree data structure, but the featureset of the libraries compared differs a lot:\n
    " + + "
  • some serializers support cycle detection/object sharing others just write non-cyclic tree structures
  • \n" + + "
  • some include full metadata in serialized output, some don't
  • \n" + + "
  • some are cross platform, some are language specific
  • \n" + + "
  • some are text based, some are binary,
  • \n" + + "
  • some support versioning forward/backward, both, some don't
\n\n" + + "(See \"ToolBehavior\":wiki/ToolBehavior)\n" + + "Other test data will yield different results (e.g. adding a non ascii char to every string :-) ). However the results give a raw estimation of library performance." + ); + + // first chart (like in previous tests) + // fastest of flat serializers (with or without preparation, exclude manually optimized) + List all = statsCruncher.generateChartList(stats, "*", "total", 1000, 1000, new SerFeatures(null, null, null)); + for (int i = 0; i < all.size(); i++) { + TestCaseResult testCaseResult = all.get(i); + if ( + testCaseResult.getFeatures().getGraph() == SerGraph.FULL_GRAPH // exclude full serializers + || testCaseResult.getFeatures().getClz() == SerClass.MANUAL_OPT // exclude manually optimized + || ",kryo-flat,fst-flat,protobuf/protostuff,protostuff-runtime,protobuf/protostuff-runtime," + .indexOf(","+testCaseResult.getName()+",") >= 0 // prevent some libs to contribute twice to chart + ) { + all.remove(i--); + } + } + String desc = "Benchmarks serializers\n
    " + + "
  • Only cycle free tree structures. An object referenced twice will be serialized twice.
  • \n" + + "
  • no manual optimizations.
  • \n" + + "
  • schema is known in advance (pre registration or even class generation). (Not all might make use of that)
  • \n" + +"
"; + out.println( statsCruncher.generateResultSection(all, "Serializers (no shared refs)", desc ) ); + + + // Second chart + // plain vanilla Full Graph serializers without generation/preparation + all = statsCruncher.generateChartList(stats, "*", "total", 1000, 1000, new SerFeatures(null, null, null)); + for (int i = 0; i < all.size(); i++) { + TestCaseResult testCaseResult = all.get(i); + if ( + testCaseResult.getFeatures().getGraph() != SerGraph.FULL_GRAPH // exclude full serializers + || testCaseResult.getFeatures().getClz() == SerClass.MANUAL_OPT // exclude manually optimized + || ",,".indexOf(","+testCaseResult.getName()+",") >= 0 // prevent some libs to contribute twice to chart + ) { + all.remove(i--); + } + } + + desc = + "Contains serializer(-configurations)\n
    "+ + "
  • supporting full object graph write/read. Object graph may contain cycles. If an Object is referenced twice, it will be so after deserialization.
  • \n"+ + "
  • nothing is known in advance, no class generation, no preregistering of classes. Everything is captured at runtime using e.g. reflection.
  • \n"+ + "
  • note this usually cannot be used cross language, however JSON/XML formats may enable cross language deserialization.
  • \n" + +"
"; + out.println( statsCruncher.generateResultSection(all, "Full Object Graph Serializers",desc) ); + + // 3rd chart + // Cross language binary serializer + all = statsCruncher.generateChartList(stats, "*", "total", 1000, 1000, new SerFeatures(null, null, null)); + for (int i = 0; i < all.size(); i++) { + TestCaseResult testCaseResult = all.get(i); + if ( + testCaseResult.getFeatures().getFormat() != SerFormat.BIN_CROSSLANG + || testCaseResult.getFeatures().getClz() == SerClass.MANUAL_OPT // exclude manually optimized + || ",,".indexOf(","+testCaseResult.getName()+",") >= 0 // prevent some libs to contribute twice to chart + ) { + all.remove(i--); + } + } + desc = + "Contains serializer(-configurations)\n
    "+ + "
  • Only cycle free tree structures. An object referenced twice will be serialized twice.
  • \n" + + "
  • schema is known in advance (pre registration, intermediate message description languages, class generation).
  • \n" + +"
" + ; + out.println( statsCruncher.generateResultSection(all, "Cross Lang Binary Serializers", desc) ); + + // 4th chart + // JSon+XML + all = statsCruncher.generateChartList(stats, "*", "total", 1000, 1000, new SerFeatures(null, null, null)); + for (int i = 0; i < all.size(); i++) { + TestCaseResult testCaseResult = all.get(i); + if ( + (testCaseResult.getFeatures().getFormat() != SerFormat.JSON + && testCaseResult.getFeatures().getFormat() != SerFormat.XML) + || testCaseResult.getFeatures().getClz() == SerClass.MANUAL_OPT // exclude manually optimized + || ",,".indexOf(","+testCaseResult.getName()+",") >= 0 // prevent some libs to contribute twice to chart + ) + { + all.remove(i--); + } + } + desc = "
    " + +"
  • text format based. Usually can be read by anybody. Frequently inline schema inside data.
  • \n" + +"
  • Mixed regarding required preparation, object graph awareness (references).
  • \n" + +"
" + ; + out.println( statsCruncher.generateResultSection(all, "XML/JSon Serializers", desc) ); + + // Manually optimized + all = statsCruncher.generateChartList(stats, "*", "total", 1000, 1000, new SerFeatures(null, null, null)); + for (int i = 0; i < all.size(); i++) { + TestCaseResult testCaseResult = all.get(i); + if ( + testCaseResult.getFeatures().getClz() != SerClass.MANUAL_OPT // exclude NON manually optimized + || ",,".indexOf(","+testCaseResult.getName()+",") >= 0 // prevent some libs to contribute twice to chart + ) + { + all.remove(i--); + } + } + + desc = "all flavours of manually optimized serializers. Handcoded and hardwired to exactly the benchmark's message structures.\n"+ + "
  • illustrates what's possible, at what level generic approaches can be optimized in case\n
"; + + out.println( statsCruncher.generateResultSection(all, "Manually optimized Serializers", desc) ); + + // Cost of miscFeatures + all = statsCruncher.generateChartList(stats, "*", "total", 1000, 1000, new SerFeatures(null, null, null)); + for (int i = 0; i < all.size(); i++) { + TestCaseResult testCaseResult = all.get(i); + if ((",fst,fst-flat,fst-flat-pre,kryo-manual,kryo-serializer,kryo-flat,kryo-flat-pre,protostuff,protostuff-runtime,protostuf-manual," + +"msgpack/databind,msgpack/manual,") + .indexOf(","+testCaseResult.getName()+",") < 0 // only these + ) + { + all.remove(i--); + } + } + desc = "shows performance vs convenience of manually-selected libs.\n
    "+ + "
  • cycle free, schema known at compile time, manual optimization: kryo-manual, msgpack/manual
  • \n"+ + "
  • cycle free, schema known at compile time: protostuff, fst-flat-pre, kryo-flat-pre. (note: protostuff uses class generation while the other two just require a list of classes to be written)
  • \n" + + "
  • cycle free, schema UNKNOWN at compile time: fst-flat, kryo-flat, protostuff-runtime, msgpack/databind
  • \n"+ + "
  • full object graph awareness, schema UNKNOWN at compile time: fst, kryo.
  • \n"+ + "
"; + out.println( statsCruncher.generateResultSection(all, "Cost of features",desc) ); + + all = statsCruncher.generateChartList(stats, "*", "total", 1000, 1000, new SerFeatures(null, null, null)); + out.println("

Full data

\n"); + out.println(statsCruncher.dump(all)); + out.println(); + out.println(statsCruncher.dumpFeatures(all)); + + out.flush(); + out.close(); + } + + ////////////////////////////////////////////////////////////////////////////////// + + static class TestCaseResult { + String name; + int create; + int ser; + int deser; + int total; + int size; + int compressedSize; + SerFeatures features = new SerFeatures(); + + TestCaseResult() { + } + + TestCaseResult(String name, int create, int ser, int deser, int total, int size, int compressedSize) { + this.name = name; + this.create = create; + this.ser = ser; + this.deser = deser; + this.total = total; + this.size = size; + this.compressedSize = compressedSize; + } + + public SerFeatures getFeatures() { + return features; + } + + public void setFeatures(SerFeatures features) { + this.features = features; + } + + public int getInt(String name) { + try { + final Field f = TestCaseResult.class.getDeclaredField(name); + f.setAccessible(true); + return f.getInt(this); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (NoSuchFieldException e) { + e.printStackTrace(); + } + return 0; + } + + public String toString() { + @SuppressWarnings("resource") + Formatter format = new Formatter().format( + "%-34s %6d %7d %7d %7d %6d %5d", + name, + create, + ser, + deser, + total, + size, + compressedSize); + return format.toString(); + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getCreate() { + return create; + } + + public void setCreate(int create) { + this.create = create; + } + + public int getSer() { + return ser; + } + + public void setSer(int ser) { + this.ser = ser; + } + + public int getDeser() { + return deser; + } + + public void setDeser(int deser) { + this.deser = deser; + } + + public int getTotal() { + return total; + } + + public void setTotal(int total) { + this.total = total; + } + + public int getSize() { + return size; + } + + public void setSize(int size) { + this.size = size; + } + + public int getCompressedSize() { + return compressedSize; + } + + public void setCompressedSize(int compressedSize) { + this.compressedSize = compressedSize; + } + + } + +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/Stephenerialization.java b/jvm-serializers-tpc/src/main/java/serializers/Stephenerialization.java new file mode 100644 index 0000000..8de0669 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/Stephenerialization.java @@ -0,0 +1,125 @@ +package serializers; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.util.ArrayList; +import java.util.List; + +import data.media.MediaTransformer; + +import serializers.stephenerialization.Image; +import serializers.stephenerialization.Media; +import serializers.stephenerialization.MediaContent; + +public class Stephenerialization { + public static void register(TestGroups groups) + { + groups.media.add(mediaTransformer, new StephenerializationSerializer("stephenerialization"), new SerFeatures(SerFormat.BINARY, SerGraph.FULL_GRAPH, SerClass.ZERO_KNOWLEDGE)); + } + + // ------------------------------------------------------------ + // Serializer (just one) + + public static class StephenerializationSerializer extends Serializer + { + private final String name; + public StephenerializationSerializer(String name) + { + this.name = name; + } + + public T deserialize(byte[] array) throws Exception + { + ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(array)); + @SuppressWarnings("unchecked") + T v = (T) ois.readObject(); + return v; + } + + public byte[] serialize(T data) throws IOException + { + ByteArrayOutputStream baos = outputStream(data); + ObjectOutputStream oos = new ObjectOutputStream(baos); + oos.writeObject(data); + return baos.toByteArray(); + } + + public String getName() + { + return name; + } + } + + // ------------------------------------------------------------ + // MediaTransformer + + public static final MediaTransformer mediaTransformer = new MediaTransformer() + { + public MediaContent forward(data.media.MediaContent a) { + return new MediaContent(forwardMedia(a.media), forwardImages(a.images)); + } + + public data.media.MediaContent reverse(MediaContent a) { + return new data.media.MediaContent(reverseMedia(a.media), reverseImages(a.images)); + } + + public data.media.MediaContent shallowReverse(MediaContent a) { + return new data.media.MediaContent(reverseMedia(a.media), new ArrayList()); + } + + private List forwardImages(List images) { + List convertedImages = new ArrayList(); + for (data.media.Image image : images) { + convertedImages.add(forwardImage(image)); + } + return convertedImages; + } + + private Image forwardImage(data.media.Image a) { + return new Image(a.uri, a.title, a.width, a.height, forwardSize(a.size)); + } + + private Image.Size forwardSize(data.media.Image.Size a) { + return Image.Size.valueOf(a.name()); + } + + private Media forwardMedia(data.media.Media a) { + return new Media(a.uri, a.title, a.width, a.height, a.format, + a.duration, a.size, a.bitrate, a.hasBitrate, a.persons, + forwardPlayer(a.player), a.copyright); + } + + private Media.Player forwardPlayer(data.media.Media.Player a) { + return Media.Player.find(a.name()); + } + + private List reverseImages(List images) { + List convertedImages = new ArrayList(); + for (Image image : images) { + convertedImages.add(reverseImage(image)); + } + return convertedImages; + } + + private data.media.Image reverseImage(Image a) { + return new data.media.Image(a.uri, a.title, a.width, a.height, reverseSize(a.size)); + } + + private data.media.Image.Size reverseSize(Image.Size a) { + return data.media.Image.Size.valueOf(a.name()); + } + + private data.media.Media reverseMedia(Media a) { + return new data.media.Media(a.uri, a.title, a.width, a.height, a.format, + a.duration, a.size, a.bitrate, a.hasBitrate, a.persons, + reversePlayer(a.player), a.copyright); + } + + private data.media.Media.Player reversePlayer(Media.Player a) { + return data.media.Media.Player.find(a.name()); + } + }; +} \ No newline at end of file diff --git a/jvm-serializers-tpc/src/main/java/serializers/TestCase.java b/jvm-serializers-tpc/src/main/java/serializers/TestCase.java new file mode 100644 index 0000000..a8f40bc --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/TestCase.java @@ -0,0 +1,6 @@ +package serializers; + +public abstract class TestCase +{ + public abstract double run(Transformer transformer, Serializer serializer, J value, int iterations) throws Exception; +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/TestCaseRunner.java b/jvm-serializers-tpc/src/main/java/serializers/TestCaseRunner.java new file mode 100644 index 0000000..44057e6 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/TestCaseRunner.java @@ -0,0 +1,65 @@ +package serializers; + +import java.util.Arrays; + +public final class TestCaseRunner +{ + static double measurementVals[] = new double[1000*1000]; + // because full gc is triggered by main loop, this should move to oldgen + private final Transformer transformer; + private final Serializer serializer; + private final J value; + + public TestCaseRunner(Transformer transformer, Serializer serializer, J value) + { + this.transformer = transformer; + this.serializer = serializer; + this.value = value; + } + + public double run(TestCase tc, int iterations) throws Exception + { + return tc.run(transformer, serializer, value, iterations); + } + + public double runWithTimeMeasurement(int timeMillis, TestCase tc, int iterations) throws Exception + { + // ruediger: + // 1. made this also time based (like warmup). + // fast serializers get more exposure to hotspot and the slow ones will + // finish below 30 minute runtime :-). + // this is reasonable as the faster a serializer is, the more significant + // some few nanos become. A slow serializer being > 10seconds will not be biased + // by having some fewer loops. + // 2. taking the minimum time makes results very erratic. You get very different results + // with each run. Especially effects of bad allocation is hidden this way, as you only + // capture the "good" runs. + // therefore i switch to average measurement (and increase warmup time to avoid measurement of + // unjitted runs, see Params). + // We can do this when running each serializer isolated in an own VM. + long start = System.currentTimeMillis(); + + double sumTime = 0; + int count = 0; + System.err.println("test-time "+timeMillis+" iteration "+iterations); + while ( System.currentTimeMillis()-start < timeMillis ) + { + double time = tc.run(transformer, serializer, value, iterations); + sumTime += time; + measurementVals[count] = time; + count++; + } + double avg = sumTime / count; + Arrays.sort(measurementVals,0,count); + System.err.println("-----------------------------------------------------------------------------"); + System.err.println(serializer.getName()); + System.err.println("min:" + measurementVals[0]); + System.err.println("1/4:"+measurementVals[count/4]); + System.err.println("1/2:"+measurementVals[count/2]); + System.err.println("3/4:"+measurementVals[count/4*3]); + System.err.println("max:"+measurementVals[count-1]); + System.err.println("average:"+ avg +"ms deviation:"+(avg-measurementVals[count/2])+"ms"); + System.err.println("-----------------------------------------------------------------------------"); + return avg; + } +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/TestGroup.java b/jvm-serializers-tpc/src/main/java/serializers/TestGroup.java new file mode 100644 index 0000000..8198814 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/TestGroup.java @@ -0,0 +1,72 @@ +package serializers; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +public final class TestGroup +{ + public final ArrayList> entries = new ArrayList>(); + final Set entryNames = new HashSet(); + public final Map> extensionMap = new HashMap>(); // So we know which one to use to load from files. + Map serMap= new HashMap(); + + public void add(Transformer transformer, Serializer serializer) + { + add(transformer,serializer,(SerFeatures)null); + } + + public void add(Transformer transformer, Serializer serializer, SerFeatures features) + { + if ( features != null ) + serializer.setFeatures(features); + add_(transformer, serializer); + } + + public void add(Transformer transformer, Serializer serializer, String extension ) + { + Entry entry_ = add_(transformer, serializer); + + Object displaced = extensionMap.put(extension, entry_); + if (displaced != null) { + throw new AssertionError("Duplicate entry for file extension \"" + extension + "\""); + } + } + + public Map getSerMap() { + return serMap; + } + + public Entry add_(Transformer transformer, Serializer serializer) + { + Entry entry = new Entry(transformer, serializer); + serMap.put(serializer.getName(),serializer); + + @SuppressWarnings("unchecked") + Entry entry_ = (Entry) entry; + + entries.add(entry_); + + String name = entry_.serializer.getName(); + boolean isUnique = entryNames.add(name); + if (!isUnique) { + throw new AssertionError("duplicate serializer name \"" + name + "\""); + } + + return entry_; + } + + public static final class Entry + { + public final Transformer transformer; + public final Serializer serializer; + + public Entry(Transformer transformer, Serializer serializer) + { + this.transformer = transformer; + this.serializer = serializer; + } + } +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/TestGroups.java b/jvm-serializers-tpc/src/main/java/serializers/TestGroups.java new file mode 100644 index 0000000..1bca4bc --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/TestGroups.java @@ -0,0 +1,14 @@ +package serializers; + +import java.util.HashMap; +import java.util.Map; + +public final class TestGroups +{ + public final TestGroup media = new TestGroup(); + public final Map> groupMap = new HashMap>(); + + { + groupMap.put("media", media); + } +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/Thrift.java b/jvm-serializers-tpc/src/main/java/serializers/Thrift.java new file mode 100644 index 0000000..16a4310 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/Thrift.java @@ -0,0 +1,256 @@ +package serializers; + +import java.io.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.apache.thrift.TDeserializer; +import org.apache.thrift.TSerializer; +import org.apache.thrift.protocol.TBinaryProtocol; +import org.apache.thrift.protocol.TCompactProtocol; +import org.apache.thrift.protocol.TProtocolFactory; + +import data.media.MediaTransformer; + +import serializers.thrift.media.*; + +public class Thrift +{ + public static void register(TestGroups groups) + { + groups.media.add(mediaTransformer, new MediaSerializer(ProtocolSpec.DefaultBinary), + new SerFeatures( + SerFormat.BIN_CROSSLANG, + SerGraph.FLAT_TREE, + SerClass.CLASSES_KNOWN, + "" + ) + ); + groups.media.add(mediaTransformer, new MediaSerializer(ProtocolSpec.CompactBinary), + new SerFeatures( + SerFormat.BIN_CROSSLANG, + SerGraph.FLAT_TREE, + SerClass.CLASSES_KNOWN, + "" + ) + ); + } + + // ------------------------------------------------------------ + // Serializers + + public static final class ProtocolSpec + { + public final TProtocolFactory factory; + public final String suffix; + + public ProtocolSpec(TProtocolFactory factory, String suffix) + { + this.factory = factory; + this.suffix = suffix; + } + + public static final ProtocolSpec DefaultBinary = new ProtocolSpec(new TBinaryProtocol.Factory(), ""); + public static final ProtocolSpec CompactBinary = new ProtocolSpec(new TCompactProtocol.Factory(), "-compact"); + } + + public static final class MediaSerializer extends Serializer + { + private final ProtocolSpec spec; + + public MediaSerializer(ProtocolSpec spec) + { + this.spec = spec; + } + + public MediaContent deserialize(byte[] array) throws Exception + { + MediaContent content = new MediaContent(); + new TDeserializer(spec.factory).deserialize(content, array); + return content; + } + + public byte[] serialize(MediaContent content) throws Exception + { + return new TSerializer(spec.factory).serialize(content); + } + + public String getName() + { + return "thrift" + spec.suffix; + } + + @Override + public final void serializeItems(MediaContent[] items, OutputStream out0) throws Exception + { + DataOutputStream out = new DataOutputStream(out0); + TSerializer ser = new TSerializer(spec.factory); + for (MediaContent item : items) { + byte[] data = ser.serialize(item); + out.writeInt(data.length); + out.write(data); + } + // should we write end marker (length of 0) or not? For now, omit it + out.flush(); + } + + @Override + public MediaContent[] deserializeItems(InputStream in0, int numberOfItems) throws Exception + { + DataInputStream in = new DataInputStream(in0); + TDeserializer deser = new TDeserializer(spec.factory); + MediaContent[] result = new MediaContent[numberOfItems]; + for (int i = 0; i < numberOfItems; ++i) { + int len = in.readInt(); + byte[] data = new byte[len]; + in.readFully(data); + MediaContent content = new MediaContent(); + deser.deserialize(content, data); + result[i] = content; + } + return result; + } + } + + // ------------------------------------------------------------ + // Transformers + + public static final MediaTransformer mediaTransformer = new MediaTransformer() + { + @Override + public MediaContent[] resultArray(int size) { return new MediaContent[size]; } + + // ---------------------------------------------------------- + // Forward + + public MediaContent forward(data.media.MediaContent mc) + { + MediaContent cb = new MediaContent(); + + cb.setMedia(forwardMedia(mc.media)); + for (data.media.Image image : mc.images) { + cb.addToImage(forwardImage(image)); + } + + return cb; + } + + private Media forwardMedia(data.media.Media media) + { + // Media + Media mb = new Media(); + mb.setUri(media.uri); + if (media.title != null) mb.setTitle(media.title); + mb.setWidth(media.width); + mb.setHeight(media.height); + mb.setFormat(media.format); + mb.setDuration(media.duration); + mb.setSize(media.size); + if (media.hasBitrate) mb.setBitrate(media.bitrate); + for (String person : media.persons) { + mb.addToPerson(person); + } + mb.setPlayer(forwardPlayer(media.player)); + if (media.copyright != null) mb.setCopyright(media.copyright); + + return mb; + } + + public Player forwardPlayer(data.media.Media.Player p) + { + switch (p) { + case JAVA: return Player.JAVA; + case FLASH: return Player.FLASH; + default: + throw new AssertionError("invalid case: " + p); + } + } + + private Image forwardImage(data.media.Image image) + { + Image ib = new Image(); + ib.setUri(image.uri); + if (image.title != null) ib.setTitle(image.title); + ib.setWidth(image.width); + ib.setHeight(image.height); + ib.setSize(forwardSize(image.size)); + return ib; + } + + public Size forwardSize(data.media.Image.Size s) + { + switch (s) { + case SMALL: return Size.SMALL; + case LARGE: return Size.LARGE; + default: + throw new AssertionError("invalid case: " + s); + } + } + + // ---------------------------------------------------------- + // Reverse + + public data.media.MediaContent reverse(MediaContent mc) + { + List images = new ArrayList(mc.getImageSize()); + + for (Image image : mc.getImage()) { + images.add(reverseImage(image)); + } + + return new data.media.MediaContent(reverseMedia(mc.getMedia()), images); + } + + private data.media.Media reverseMedia(Media media) + { + // Media + return new data.media.Media( + media.getUri(), + media.isSetTitle() ? media.getTitle() : null, + media.getWidth(), + media.getHeight(), + media.getFormat(), + media.getDuration(), + media.getSize(), + media.isSetBitrate() ? media.getBitrate() : 0, + media.isSetBitrate(), + new ArrayList(media.getPerson()), + reversePlayer(media.getPlayer()), + media.isSetCopyright() ? media.getCopyright() : null + ); + } + + public data.media.Media.Player reversePlayer(Player p) + { + if (p == Player.JAVA) return data.media.Media.Player.JAVA; + if (p == Player.FLASH) return data.media.Media.Player.FLASH; + throw new AssertionError("invalid case: " + p); + } + + private data.media.Image reverseImage(Image image) + { + return new data.media.Image( + image.getUri(), + image.isSetTitle() ? image.getTitle() : null, + image.getWidth(), + image.getHeight(), + reverseSize(image.getSize())); + } + + public data.media.Image.Size reverseSize(Size s) + { + switch (s) { + case SMALL: return data.media.Image.Size.SMALL; + case LARGE: return data.media.Image.Size.LARGE; + default: + throw new AssertionError("invalid case: " + s); + } + } + + public data.media.MediaContent shallowReverse(MediaContent mc) + { + return new data.media.MediaContent(reverseMedia(mc.getMedia()), Collections.emptyList()); + } + }; +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/Transformer.java b/jvm-serializers-tpc/src/main/java/serializers/Transformer.java new file mode 100644 index 0000000..7d3a239 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/Transformer.java @@ -0,0 +1,38 @@ +package serializers; + +public abstract class Transformer +{ + public abstract B forward(A a); + public abstract A reverse(B a); + public abstract A shallowReverse(B a); + + public abstract A[] sourceArray(int size); + public abstract B[] resultArray(int size); + + public B[] forwardAll(A[] a) + { + // this is unfortunate shuffling around type variables, but has to do: + B[] b = resultArray(a.length); + forward(a, b); + return b; + } + + /** + * Method called to convert an array of items from custom representation to standard one + */ + public void forward(A[] a, B[] b) + { + for (int i = 0, len = a.length; i < len; ++i) { + b[i] = forward(a[i]); + } + } + + public A[] reverseAll(B[] b) + { + A[] a = sourceArray(b.length); + for (int i = 0, len = b.length; i < len; ++i) { + a[i] = reverse(b[i]); + } + return a; + } +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/WriteResultsToJavascript.java b/jvm-serializers-tpc/src/main/java/serializers/WriteResultsToJavascript.java new file mode 100644 index 0000000..35e7f3b --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/WriteResultsToJavascript.java @@ -0,0 +1,378 @@ +package serializers; + +import com.fasterxml.jackson.core.JsonEncoding; +import com.fasterxml.jackson.core.JsonFactory; +import com.fasterxml.jackson.core.JsonGenerator; + +import java.io.*; +import java.util.*; + +/** + * Run this via the "./mk-js-stats" script. + */ +public class WriteResultsToJavascript +{ + public static final String[] columns = { "create", "ser", "deser", "total", "size", "size-gz" }; + public static final int roundTripColumnIndex = 3; + + public static void _main(String[] args) + throws Exit + { + if (args.length != 2) { + throw new Exit(1, "Usage: COMMAND "); + } + + File inputFile = new File(args[0]); + File outputFile = new File(args[1]); + + + List entries = readInputFile(inputFile); + loadEntryProperties(entries); + calculateSpeedProperties(entries); + writeOutputFile(outputFile, entries); + } + + // ---------------------------------------------------------------------------- + // Lookup/derive "properties" for each serializer. + + private static void calculateSpeedProperties(List entries) + { + // Get a sorted list of all running times. + int[] times = new int[entries.size()]; + int i = 0; + for (Entry e : entries) { + times[i++] = e.results.get(roundTripColumnIndex); + } + Arrays.sort(times); + + // TODO: something smarter than percentiles. + int p50 = times[(times.length + 1) / 2]; + int p75 = times[(times.length * 3) / 4]; + + for (Entry e : entries) { + int time = e.results.get(roundTripColumnIndex); + if (time <= p50) { + e.properties.add(Property.Fast); + } + if (time > p75) { + e.properties.add(Property.Slow); + } + } + } + + private static void loadEntryProperties(List entries) + throws Exit + { + Map featureMap = new BenchmarkExporter().getFeatureMap(); + + for (Entry e : entries) { + SerFeatures f = featureMap.get(e.name); + if (f == null) { + throw new Exit(1, "Unable to load serializer features for \"" + e.name + "\".", + "Are you sure this serializer name is still valid in the benchmark code?"); + } + switch (f.format) { + case BINARY: + e.properties.add(Property.Binary); + break; + case BIN_CROSSLANG: + e.properties.add(Property.Binary); + e.properties.add(Property.Neutral); + break; + case XML: + e.properties.add(Property.Xml); + e.properties.add(Property.Text); + e.properties.add(Property.Neutral); + break; + case JSON: + e.properties.add(Property.Json); + e.properties.add(Property.Text); + e.properties.add(Property.Neutral); + break; + } + + // TODO: Clean up the Category.Spec stuff. + } + } + + // ---------------------------------------------------------------------------- + // Write output file. + + private static void writeOutputFile(File outputFile, List entries) + throws Exit + { + // Write output. + try { + FileOutputStream fout = new FileOutputStream(outputFile); + try { + JsonFactory factory = new JsonFactory(); + factory.disable(JsonGenerator.Feature.QUOTE_FIELD_NAMES); + JsonGenerator gen = factory.createGenerator(fout, JsonEncoding.UTF8); + gen.useDefaultPrettyPrinter(); + fout.write("var benchmarkResults = ".getBytes("UTF-8")); + writeJavascriptStats(gen, columns, entries); + } + finally { + fout.close(); + } + } + catch (IOException ex) { + throw new Exit(1, "Error writing to output file \"" + outputFile.getPath() + "\": " + ex.getMessage()); + } + } + + private static void writeJavascriptStats(JsonGenerator g, String[] columns, List entries) + throws IOException + { + g.writeStartObject(); + + // Write properties (grouped by category). + g.writeArrayFieldStart("categories"); + for (Category category : Category.values()) { + g.writeStartObject(); + + g.writeStringField("name", category.ident); + g.writeStringField("description", category.description); + g.writeArrayFieldStart("properties"); + for (Property property : category.properties) { + g.writeStartObject(); + g.writeStringField("name", property.ident); + g.writeStringField("description", property.description); + g.writeEndObject(); + } + g.writeEndArray(); + + g.writeEndObject(); + } + g.writeEndArray(); + + // Write columns. + g.writeArrayFieldStart("columns"); + for (String column : columns) { + g.writeString(column); + } + g.writeEndArray(); + + // Write entries. + g.writeArrayFieldStart("entries"); + for (Entry entry : entries) { + g.writeStartObject(); + { + g.writeStringField("name", entry.name); + g.writeArrayFieldStart("properties"); + for (Property property : entry.properties) { + g.writeString(property.ident); + } + g.writeEndArray(); + g.writeArrayFieldStart("results"); + for (int i : entry.results) { + g.writeNumber(i); + } + g.writeEndArray(); + } + g.writeEndObject(); + } + g.writeEndArray(); + + g.writeEndObject(); + + g.flush(); + } + + // ---------------------------------------------------------------------------- + // Read input file. + + private static List readInputFile(File inputFile) throws Exit + { + if (!inputFile.exists()) { + throw new Exit(1, "Input file \"" + inputFile.getPath() + "\" doesn't exist."); + } + if (!inputFile.isFile()) { + throw new Exit(1, "Input file \"" + inputFile.getPath() + "\" doesn't refer to a normal file."); + } + + try { + FileInputStream fin = new FileInputStream(inputFile); + try { + return readStats(new InputStreamReader(fin, "UTF-8")); + } + finally { + try { fin.close(); } catch (IOException ex) { /* ignore */ } + } + } + catch (InputError ex) { + throw new Exit(1, "Error in input file \"" + inputFile.getPath() + "\": " + ex.getMessage()); + } + catch (IOException ex) { + throw new Exit(1, "Error reading from input file \"" + inputFile.getPath() + "\": " + ex.getMessage()); + } + } + + private static List readStats(Reader in0) + throws IOException, InputError + { + BufferedReader in = new BufferedReader(in0); + ArrayList entries = new ArrayList(); + Set entryNames = new HashSet(); + int lineNumber = 0; + int tokensPerLine = columns.length + 1; + while (true) { + String line = in.readLine(); + if (line == null) break; + lineNumber++; + line = line.trim(); + if (line.length() == 0) continue; // skip blank lines. + + String[] parts = line.split(" +"); + if (parts.length != tokensPerLine) { + throw new InputError(lineNumber, "Expecting " + tokensPerLine + " tokens, got " + parts.length + "."); + } + String name = parts[0]; + + boolean added = entryNames.add(name); + if (!added) { + throw new InputError(lineNumber, "Duplicate row name: \"" + name + "\""); + } + + Entry entry = new Entry(name); + entries.add(entry); + + for (int i = 0; i < columns.length; i++) { + int ci = i+1; + String c = parts[ci]; + int v; + try { + v = Integer.parseInt(c); + } + catch (NumberFormatException ex) { + throw new InputError(lineNumber, "column " + (ci+1) + ": Expecting integer, got \"" + c + "\"."); + } + if (v < 0) { + throw new InputError(lineNumber, "column " + (ci+1) + ": Negatives not allowed."); + } + entry.results.add(v); + } + } + + if (entries.isEmpty()) { + throw new InputError(lineNumber, "No valid rows found."); + } + + return entries; + } + + public static final class InputError extends Exception + { + public InputError(int lineNumber, String message) { + super("line " + lineNumber + ": " + message); + } + } + + // ---------------------------------------------------------------------------- + // Model objects + + public enum Category + { + Format("Format", "The format used to serialize."), + Spec("Spec", "How you specify the data structure to the serializer."), + PojoHints("POJO Hints", "For POJO serializers, did we specify any hints to help them out?"), + Speed("Speed", null), + ; + + public final String ident; + public final String description; + public final List properties; + + Category(String ident, String description) + { + this.ident = ident; + this.description = description; + this.properties = new ArrayList(); + } + } + + public enum Property + { + Neutral(Category.Format, "neutral", "The serialization format is language-neutral."), + Binary (Category.Format, "binary", "Some binary format."), + Text (Category.Format, "text", "Some human-readable text format."), + Json (Category.Format, "json", null), + Xml (Category.Format, "xml", null), + + Pojo (Category.Spec, "pojo", "The serializer works with user-defined plain Java classes."), + Schema (Category.Spec, "schema", "You must define a schema for your data types and run the library's compiler to generate Java classes."), + Manual (Category.Spec, "manual", "You must call the serialization routines manually."), + ManualMore(Category.Spec, "manual.more", "You must call the serialization routines manually, and there is more effort than in the \"manual\" case."), + + HintType(Category.PojoHints, "hint.type", "The serializer was given the list of types."), + HintNull(Category.PojoHints, "hint.null", "The serializer was given the list of non-null fields."), + + Fast(Category.Speed, "fast", "Serializers whose round-trip time is in the top 50th percentile."), + Slow(Category.Speed, "slow", "Serializers whose round-trip time is in the bottom 25th percentile."), + ; + + public final Category category; + public final String ident; + public final String description; + + Property(Category category, String ident, String description) + { + this.ident = ident; + this.category = category; + this.description = description; + category.properties.add(this); + } + + static { + HashSet idents = new HashSet(); + for (Property p : Property.values()) { + boolean added = idents.add(p.ident); + if (!added) { + throw new AssertionError("duplicate identifier \"" + p.ident + "\""); + } + } + } + } + + public static final class Entry + { + public final String name; + public final EnumSet properties = EnumSet.noneOf(Property.class); + public final List results = new ArrayList(); + + public Entry(String name) + { + this.name = name; + } + } + + // ---------------------------------------------------------------------------- + // Command-line app boilerplate. + + public static void main(String[] args) + { + int exitCode = 0; + try { + _main(args); + } + catch (Exit exit) { + for (String line : exit.errorLines) { + System.err.println(line); + } + exitCode = exit.code; + } + System.exit(exitCode); + } + + public static final class Exit extends Exception + { + public final int code; + public final String[] errorLines; + + public Exit(int code, String... errorLines) + { + this.code = code; + this.errorLines = errorLines; + } + } +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/avro/Avro.java b/jvm-serializers-tpc/src/main/java/serializers/avro/Avro.java new file mode 100644 index 0000000..6aab533 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/avro/Avro.java @@ -0,0 +1,20 @@ +package serializers.avro; + +import org.apache.avro.Schema; + +public class Avro +{ + // ------------------------------------------------------------- + // Media + + public static final class Media + { + public static final Schema sMediaContent = serializers.avro.media.MediaContent.SCHEMA$; + public static final Schema sMedia = serializers.avro.media.Media.SCHEMA$; + public static final Schema sImage = serializers.avro.media.Image.SCHEMA$; + + public static final Schema sImages = sMediaContent.getField("images").schema(); + public static final Schema sPersons = sMedia.getField("persons").schema(); + } + +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/avro/AvroGeneric.java b/jvm-serializers-tpc/src/main/java/serializers/avro/AvroGeneric.java new file mode 100644 index 0000000..c464b60 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/avro/AvroGeneric.java @@ -0,0 +1,259 @@ +package serializers.avro; + +import data.media.*; + +import org.apache.avro.Schema; +import org.apache.avro.generic.GenericData; +import org.apache.avro.generic.GenericDatumReader; +import org.apache.avro.generic.GenericDatumWriter; +import org.apache.avro.generic.GenericRecord; +import org.apache.avro.io.EncoderFactory; +import org.apache.avro.io.DecoderFactory; +import org.apache.avro.io.BinaryEncoder; +import org.apache.avro.io.BinaryDecoder; + +import serializers.*; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +public class AvroGeneric +{ + public static void register(TestGroups groups) + { + groups.media.add(MediaTransformer, new GenericSerializer(Avro.Media.sMediaContent), + new SerFeatures( + SerFormat.BIN_CROSSLANG, + SerGraph.FLAT_TREE, + SerClass.MANUAL_OPT, + "" + ) + ); + } + + // ------------------------------------------------------------ + // Serializer (just one class) + + private static final DecoderFactory DECODER_FACTORY + = DecoderFactory.get(); + private static final EncoderFactory ENCODER_FACTORY + = EncoderFactory.get(); + + public static class GenericSerializer extends Serializer + { + public String getName() { return "avro-generic"; } + + private final GenericDatumWriter WRITER; + private final GenericDatumReader READER; + + private BinaryEncoder encoder; + private BinaryDecoder decoder; + + public GenericSerializer(Schema schema) + { + WRITER = new GenericDatumWriter(schema); + READER = new GenericDatumReader(schema); + } + + public GenericRecord deserialize(byte[] array) throws Exception + { + decoder = DECODER_FACTORY.binaryDecoder(array, decoder); + return READER.read(null, decoder); + } + + public byte[] serialize(GenericRecord data) throws IOException + { + ByteArrayOutputStream out = outputStream(data); + encoder = ENCODER_FACTORY.binaryEncoder(out, encoder); + WRITER.write(data, encoder); + encoder.flush(); + return out.toByteArray(); + } + } + + // ------------------------------------------------------------ + // MediaTransformer + + public static final Schema sMediaContent = serializers.avro.media.MediaContent.SCHEMA$; + + public static final Transformer MediaTransformer = new MediaTransformer() + { + @SuppressWarnings("unused") + private final Schema sImage = serializers.avro.media.Image.SCHEMA$; + private final Schema sMedia = serializers.avro.media.Media.SCHEMA$; + + @SuppressWarnings("unused") + private final Schema sImages = sMediaContent.getField("images").schema(); + @SuppressWarnings("unused") + private final Schema sPersons = sMedia.getField("persons").schema(); + + public GenericRecord[] resultArray(int size) { + return new GenericRecord[size]; + } + + // ---------------------------------------------------------- + // Forward + + public GenericRecord forward(MediaContent mc) + { + GenericRecord content = new GenericData.Record(Avro.Media.sMediaContent); + + content.put("media", forwardMedia(mc.media)); + + GenericData.Array images = new GenericData.Array(mc.images.size(), Avro.Media.sImages); + for (Image image : mc.images) { + images.add(forwardImage(image)); + } + content.put("images", images); + + return content; + } + + private GenericRecord forwardMedia(Media media) + { + GenericRecord m = new GenericData.Record(Avro.Media.sMedia); + m.put("uri", media.uri); + m.put("format", media.format); + if (media.title != null) { + m.put("title", media.title); + } + m.put("duration", media.duration); + if (media.hasBitrate) { + m.put("bitrate", media.bitrate); + } + + GenericData.Array persons = new GenericData.Array(media.persons.size(), Avro.Media.sPersons); + for (String p : media.persons) { + persons.add(p); + } + + m.put("persons", persons); + m.put("player", forwardPlayer(media.player)); + m.put("height", media.height); + m.put("width", media.width); + m.put("size", media.size); + if (media.copyright != null) { + m.put("copyright", media.copyright); + } + + return m; + } + + public int forwardPlayer(Media.Player p) + { + switch (p) { + case JAVA: return 1; + case FLASH: return 2; + default: + throw new AssertionError("invalid case: " + p); + } + } + + private GenericRecord forwardImage(Image image) + { + GenericRecord i = new GenericData.Record(Avro.Media.sImage); + i.put("uri", image.uri); + i.put("width", image.width); + i.put("height", image.height); + i.put("size", forwardSize(image.size)); + if (image.title != null) { + i.put("title", image.title); + } + return i; + } + + public int forwardSize(Image.Size s) + { + switch (s) { + case SMALL: return 1; + case LARGE: return 2; + default: + throw new AssertionError("invalid case: " + s); + } + } + + // ---------------------------------------------------------- + // Reverse + + public MediaContent reverse(GenericRecord mc) + { + @SuppressWarnings("unchecked") + GenericData.Array gimages = (GenericData.Array) mc.get("images"); + List images = new ArrayList((int) gimages.size()); + for (GenericRecord image : gimages) { + images.add(reverseImage(image)); + } + + return new MediaContent(reverseMedia((GenericRecord) mc.get("media")), images); + } + + private Media reverseMedia(GenericRecord media) + { + // Media + + @SuppressWarnings("unchecked") + GenericData.Array gpersons = (GenericData.Array) media.get("persons"); + List persons = new ArrayList((int) gpersons.size()); + for (CharSequence person : gpersons) { + persons.add(person.toString()); + } + + // Optional fields. + CharSequence title = (CharSequence) media.get("title"); + Integer bitrate = (Integer) media.get("bitrate"); + CharSequence copyright = (CharSequence) media.get("copyright"); + + return new Media( + ((CharSequence) media.get("uri")).toString(), + title != null ? title.toString() : null, + (Integer) media.get("width"), + (Integer) media.get("height"), + ((CharSequence) media.get("format")).toString(), + (Long) media.get("duration"), + (Long) media.get("size"), + bitrate != null ? bitrate : 0, + bitrate != null, + persons, + reversePlayer((Integer) media.get("player")), + copyright != null ? copyright.toString() : null + ); + } + + public Media.Player reversePlayer(int p) + { + switch (p) { + case 1: return Media.Player.JAVA; + case 2: return Media.Player.FLASH; + default: throw new AssertionError("invalid case: " + p); + } + } + + private Image reverseImage(GenericRecord image) + { + CharSequence title = (CharSequence) image.get("title"); + return new Image( + ((CharSequence) image.get("uri")).toString(), + title == null ? null : title.toString(), + (Integer) image.get("width"), + (Integer) image.get("height"), + reverseSize((Integer) image.get("size"))); + } + + public Image.Size reverseSize(int s) + { + switch (s) { + case 1: return Image.Size.SMALL; + case 2: return Image.Size.LARGE; + default: throw new AssertionError("invalid case: " + s); + } + } + + public MediaContent shallowReverse(GenericRecord mc) + { + return new MediaContent(reverseMedia((GenericRecord) mc.get("media")), Collections.emptyList()); + } + }; +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/avro/AvroSpecific.java b/jvm-serializers-tpc/src/main/java/serializers/avro/AvroSpecific.java new file mode 100644 index 0000000..e0c10c9 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/avro/AvroSpecific.java @@ -0,0 +1,91 @@ +package serializers.avro; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.lang.reflect.Array; + +import org.apache.avro.io.EncoderFactory; +import org.apache.avro.io.DecoderFactory; +import org.apache.avro.io.BinaryEncoder; +import org.apache.avro.io.BinaryDecoder; +import org.apache.avro.specific.SpecificDatumReader; +import org.apache.avro.specific.SpecificDatumWriter; + +import serializers.*; +import serializers.avro.media.*; + +public class AvroSpecific +{ + public static void register(TestGroups groups) + { + groups.media.add(new AvroTransformer(), new GenericSerializer(MediaContent.class), + new SerFeatures( + SerFormat.BIN_CROSSLANG, + SerGraph.UNKNOWN, + SerClass.MANUAL_OPT, + "" + ) + ); + } + + private static final DecoderFactory DECODER_FACTORY = DecoderFactory.get(); + private static final EncoderFactory ENCODER_FACTORY = EncoderFactory.get(); + + public static final class GenericSerializer extends Serializer + { + public String getName() { return "avro-specific"; } + + private final SpecificDatumReader READER; + private final SpecificDatumWriter WRITER; + + private BinaryEncoder encoder; + private BinaryDecoder decoder; + + private final Class clazz; + + public GenericSerializer(Class clazz) + { + this.clazz = clazz; + this.READER = new SpecificDatumReader(clazz); + this.WRITER = new SpecificDatumWriter(clazz); + } + + public T deserialize(byte[] array) throws Exception { + decoder = DECODER_FACTORY.binaryDecoder(array, decoder); + return READER.read(null, decoder); + } + + public byte[] serialize(T content) throws Exception { + ByteArrayOutputStream out = outputStream(content); + encoder = ENCODER_FACTORY.binaryEncoder(out, encoder); + WRITER.write(content, encoder); + encoder.flush(); + return out.toByteArray(); + } + + @Override + public void serializeItems(T[] items, OutputStream out) throws IOException + { + encoder = ENCODER_FACTORY.binaryEncoder(out, encoder); + for (T item : items) { + WRITER.write(item, encoder); + } + encoder.flush(); + } + + @Override + public T[] deserializeItems(InputStream in0, int numberOfItems) throws IOException + { + decoder = DECODER_FACTORY.binaryDecoder(in0, decoder); + @SuppressWarnings("unchecked") + T[] result = (T[]) Array.newInstance(clazz, numberOfItems); + T item = null; + for (int i = 0; i < numberOfItems; ++i) { + result[i] = READER.read(item, decoder); + } + return result; + } + } +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/avro/AvroTransformer.java b/jvm-serializers-tpc/src/main/java/serializers/avro/AvroTransformer.java new file mode 100644 index 0000000..130e6df --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/avro/AvroTransformer.java @@ -0,0 +1,169 @@ +package serializers.avro; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.apache.avro.generic.GenericArray; +import org.apache.avro.generic.GenericData; + +import serializers.avro.media.Image; +import serializers.avro.media.Media; +import serializers.avro.media.MediaContent; +import data.media.MediaTransformer; + +/** + * Transformer is needed when we use Avro-generated Java classes, to convert + * between these and POJOs for verification purposes. This transformation + * is NOT done during performance testing, as it could be viewed as + * unfair overhead for use cases where generated class is used instead + * of equivalent POJO. + */ +public class AvroTransformer extends MediaTransformer +{ + @Override + public MediaContent[] resultArray(int size) { return new MediaContent[size]; } + + // ---------------------------------------------------------- + // Forward + + public MediaContent forward(data.media.MediaContent mc) + { + GenericArray images = new GenericData.Array(mc.images.size(), Avro.Media.sImages); + for (data.media.Image image : mc.images) { + images.add(forwardImage(image)); + } + + MediaContent amc = new MediaContent(); + amc.setMedia(forwardMedia(mc.media)); + amc.setImages(images); + return amc; + } + + private Media forwardMedia(data.media.Media media) + { + Media m = new Media(); + + m.setUri(media.uri); + m.setTitle(media.title); + m.setWidth(media.width); + m.setHeight(media.height); + m.setFormat(media.format); + m.setDuration(media.duration); + m.setSize(media.size); + if (media.hasBitrate) { + m.setBitrate(media.bitrate); + } + + GenericArray persons = new GenericData.Array(media.persons.size(), Avro.Media.sPersons); + for (String s : media.persons) { + persons.add(s); + } + m.setPersons(persons); + m.setPlayer(forwardPlayer(media.player)); + m.setCopyright(media.copyright); + + return m; + } + + public int forwardPlayer(data.media.Media.Player p) + { + switch (p) { + case JAVA: return 1; + case FLASH: return 2; + default: throw new AssertionError("invalid case: " + p); + } + } + + private Image forwardImage(data.media.Image image) + { + Image i = new Image(); + i.setUri(image.uri); + i.setTitle(image.title); + i.setWidth(image.width); + i.setHeight(image.height); + i.setSize(forwardSize(image.size)); + return i; + } + + public int forwardSize(data.media.Image.Size s) + { + switch (s) { + case SMALL: return 1; + case LARGE: return 2; + default: throw new AssertionError("invalid case: " + s); + } + } + + // ---------------------------------------------------------- + // Reverse + + public data.media.MediaContent reverse(MediaContent mc) + { + List images = new ArrayList((int) mc.getImages().size()); + + for (Image image : mc.getImages()) { + images.add(reverseImage(image)); + } + + return new data.media.MediaContent(reverseMedia(mc.getMedia()), images); + } + + private data.media.Media reverseMedia(Media media) + { + // Media + List persons = new ArrayList(); + for (CharSequence p : media.getPersons()) { + persons.add(p.toString()); + } + + return new data.media.Media( + media.getUri().toString(), + media.getTitle() != null ? media.getTitle().toString() : null, + media.getWidth(), + media.getHeight(), + media.getFormat().toString(), + media.getDuration(), + media.getSize(), + media.getBitrate() != null ? media.getBitrate() : 0, + media.getBitrate() != null, + persons, + reversePlayer(media.getPlayer()), + media.getCopyright() != null ? media.getCopyright().toString() : null + ); + } + + public data.media.Media.Player reversePlayer(int p) + { + switch (p) { + case 1: return data.media.Media.Player.JAVA; + case 2: return data.media.Media.Player.FLASH; + default: throw new AssertionError("invalid case: " + p); + } + } + + private data.media.Image reverseImage(Image image) + { + return new data.media.Image( + image.getUri().toString(), + image.getTitle() != null ? image.getTitle().toString() : null, + image.getWidth(), + image.getHeight(), + reverseSize(image.getSize())); + } + + public data.media.Image.Size reverseSize(int s) + { + switch (s) { + case 1: return data.media.Image.Size.SMALL; + case 2: return data.media.Image.Size.LARGE; + default: throw new AssertionError("invalid case: " + s); + } + } + + public data.media.MediaContent shallowReverse(MediaContent mc) + { + return new data.media.MediaContent(reverseMedia(mc.getMedia()), + Collections.emptyList()); + } +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/cks/Cks.java b/jvm-serializers-tpc/src/main/java/serializers/cks/Cks.java new file mode 100644 index 0000000..34dd696 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/cks/Cks.java @@ -0,0 +1,145 @@ +package serializers.cks; + +import cks.value.data.Maybe; +import serializers.cks.media.*; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import data.media.MediaTransformer; + +public class Cks +{ + // ------------------------------------------------------------ + // Transformers + + public static final MediaTransformer mediaTransformer = new MediaTransformer() + { + @Override + public MediaContent[] resultArray(int size) { return new MediaContent[size]; } + + // ---------------------------------------------------------- + // Forward + + public MediaContent forward(data.media.MediaContent mc) + { + ArrayList images = new ArrayList(); + for (data.media.Image image : mc.images) { + images.add(forwardImage(image)); + } + + return new MediaContent(images, forwardMedia(mc.media)); + } + + private Media forwardMedia(data.media.Media media) + { + return new Media( + media.uri, + media.title != null ? Maybe.Just(media.title) : Maybe.Nothing(), + media.width, + media.height, + media.format, + media.duration, + media.size, + media.hasBitrate ? Maybe.Just(media.bitrate) : Maybe.Nothing(), + new ArrayList(media.persons), + forwardPlayer(media.player), + media.copyright != null ? Maybe.Just(media.copyright) : Maybe.Nothing() + ); + } + + public Media.Player forwardPlayer(data.media.Media.Player p) + { + switch (p) { + case JAVA: return Media.Player.Java_.mk(); + case FLASH: return Media.Player.Flash_.mk(); + default: + throw new AssertionError("invalid case: " + p); + } + } + + private Image forwardImage(data.media.Image image) + { + return new Image( + image.uri, + image.title != null ? Maybe.Just(image.title) : Maybe.Nothing(), + image.width, + image.height, + forwardSize(image.size) + ); + } + + public Image.Size forwardSize(data.media.Image.Size s) + { + switch (s) { + case SMALL: return Image.Size.Small_.mk(); + case LARGE: return Image.Size.Large_.mk(); + default: + throw new AssertionError("invalid case: " + s); + } + } + + // ---------------------------------------------------------- + // Reverse + + public data.media.MediaContent reverse(MediaContent mc) + { + List images = new ArrayList(mc.images.size()); + + for (Image image : mc.images) { + images.add(reverseImage(image)); + } + + return new data.media.MediaContent(reverseMedia(mc.media), images); + } + + private data.media.Media reverseMedia(Media media) + { + // Media + return new data.media.Media( + media.uri, + media.title.get(null), + media.width, + media.height, + media.format, + media.duration, + media.size, + media.bitrate.get(0), + media.bitrate.isJust(), + new ArrayList(media.persons), + reversePlayer(media.player), + media.copyright.get(null) + ); + } + + public data.media.Media.Player reversePlayer(Media.Player p) + { + if (p instanceof Media.Player.Java_) return data.media.Media.Player.JAVA; + if (p instanceof Media.Player.Flash_) return data.media.Media.Player.FLASH; + throw new AssertionError("invalid case: " + p); + } + + private data.media.Image reverseImage(Image image) + { + return new data.media.Image( + image.uri, + image.title.get(null), + image.width, + image.height, + reverseSize(image.size)); + } + + public data.media.Image.Size reverseSize(Image.Size s) + { + if (s instanceof Image.Size.Small_) return data.media.Image.Size.SMALL; + if (s instanceof Image.Size.Large_) return data.media.Image.Size.LARGE; + throw new AssertionError("invalid case: " + s); + } + + public data.media.MediaContent shallowReverse(MediaContent mc) + { + return new data.media.MediaContent(reverseMedia(mc.media), Collections.emptyList()); + } + }; +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/cks/CksBinary.java b/jvm-serializers-tpc/src/main/java/serializers/cks/CksBinary.java new file mode 100644 index 0000000..c368c9f --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/cks/CksBinary.java @@ -0,0 +1,59 @@ +package serializers.cks; + +import java.io.InputStream; +import java.io.OutputStream; + +import serializers.*; +import serializers.cks.media.MediaContent; + +public class CksBinary +{ + public static void register(TestGroups groups) + { + groups.media.add(Cks.mediaTransformer, MediaSerializer, + new SerFeatures( + SerFormat.MISC, + SerGraph.FLAT_TREE, + SerClass.CLASSES_KNOWN, + "" + ) + ); + } + + // ------------------------------------------------------------ + // Serializers + + public static final Serializer MediaSerializer = new Serializer() + { + public MediaContent deserialize(byte[] array) throws Exception + { + return MediaContent._BinaryReader.readFromByteArray(array); + } + + public byte[] serialize(MediaContent content) throws Exception + { + return MediaContent._BinaryWriter.writeToByteArray(content); + } + + public String getName () + { + return "cks"; + } + + public MediaContent[] deserializeItems(InputStream in, int numberOfItems) throws Exception + { + MediaContent[] result = new MediaContent[numberOfItems]; + for (int i = 0; i < numberOfItems; ++i) { + result[i] = MediaContent._BinaryReader.readFromStream(in); + } + return result; + } + + public void serializeItems(MediaContent[] items, OutputStream out) throws Exception + { + for (MediaContent item : items) { + MediaContent._BinaryWriter.write(out, item); + } + } + }; +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/cks/CksText.java b/jvm-serializers-tpc/src/main/java/serializers/cks/CksText.java new file mode 100644 index 0000000..787046d --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/cks/CksText.java @@ -0,0 +1,69 @@ +package serializers.cks; + +import java.io.*; + +import serializers.Serializer; +import serializers.TestGroups; +import serializers.cks.media.MediaContent; + +public class CksText +{ + public static void register(TestGroups groups) + { + groups.media.add(Cks.mediaTransformer, MediaSerializer, "cks"); + } + + // ------------------------------------------------------------ + // Serializers + + private final static byte[] FOUR_ATS = "@@@@".getBytes(); + + public static final Serializer MediaSerializer = new Serializer() + { + + public MediaContent deserialize(byte[] array) throws Exception + { + return MediaContent._TextReader.readFromByteArray(array); + } + + public byte[] serialize(MediaContent content) throws Exception + { + return MediaContent._TextWriter.writeToByteArray(content); + } + + public String getName () + { + return "cks-text"; + } + + // Note: code below is inefficient and ugly; but we need just for bootstrapping and + // it's never included in measurements. + + public MediaContent[] deserializeItems(InputStream in, int numberOfItems) throws Exception + { + MediaContent[] result = new MediaContent[numberOfItems]; + // very inefficient; but performance of CKS is never compared, hence no worries + byte[] bytes = readAll(in); + String text = new String(bytes, "UTF-8"); + String[] parts = text.split("@@@@"); + if (parts.length != numberOfItems) { + throw new IOException("Expected "+numberOfItems+", found "+parts.length+" CKS segments"); + } + for (int i = 0; i < numberOfItems; ++i) { + result[i] = MediaContent._TextReader.read(new StringReader(parts[i])); + } + return result; + } + + public void serializeItems(MediaContent[] items, OutputStream out) throws Exception + { + for (int i = 0, len = items.length; i < len; ++i) { + if (i > 0) { + out.write(FOUR_ATS); + } + MediaContent._TextWriter.write(out, items[i]); + } + } + }; +} + diff --git a/jvm-serializers-tpc/src/main/java/serializers/dslplatform/DSLPlatform.java b/jvm-serializers-tpc/src/main/java/serializers/dslplatform/DSLPlatform.java new file mode 100644 index 0000000..9e40ab5 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/dslplatform/DSLPlatform.java @@ -0,0 +1,279 @@ +package serializers.dslplatform; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import serializers.SerClass; +import serializers.SerFeatures; +import serializers.SerFormat; +import serializers.SerGraph; +import serializers.Serializer; +import serializers.TestGroups; + +import serializers.dslplatform.full.*; +import serializers.dslplatform.minified.*; +import serializers.dslplatform.shared.*; + +import com.dslplatform.json.JsonReader; +import com.dslplatform.json.JsonWriter; + +import data.media.MediaTransformer; + +/** + * A test harness for DSL Platform (http://dsl-platform.com) generated classes. + * + * Uses pregenerated classes (the schema is in {@code schema/media.dsl}). + */ +public class DSLPlatform { + + public static void register(final TestGroups groups) { + groups.media.add(new DSLPlatformFullMediaTransformer(), new DSLPlatformFullSerializer(), new SerFeatures( + SerFormat.JSON, SerGraph.FLAT_TREE, SerClass.CLASSES_KNOWN, "Serializes all properties with exact names.")); + groups.media.add(new DSLPlatformMinifiedMediaTransformer(), new DSLPlatformMinifiedSerializer(), new SerFeatures( + SerFormat.JSON, SerGraph.FLAT_TREE, SerClass.CLASSES_KNOWN, + "JSON with minified property names and without default values.")); + } + + static class DSLPlatformFullSerializer extends Serializer { + private static JsonWriter writer = new JsonWriter(); + private final char[] tmp = new char[64]; + + @Override + public String getName() { + return "json/dsl-platform"; + } + + @Override + public MediaContentFull deserialize(final byte[] array) throws Exception { + return (MediaContentFull) MediaContentFull.deserialize(new JsonReader(array, null, tmp)); + } + + @Override + public byte[] serialize(final MediaContentFull content) throws Exception { + writer.reset(); + content.serialize(writer, false); + return writer.toByteArray(); + } + } + + static class DSLPlatformMinifiedSerializer extends Serializer { + private static JsonWriter writer = new JsonWriter(); + private final char[] tmp = new char[64]; + + @Override + public String getName() { + return "minified-json/dsl-platform"; + } + + @Override + public MediaContentMinified deserialize(final byte[] array) throws Exception { + return (MediaContentMinified) MediaContentMinified.deserialize(new JsonReader(array, null, tmp)); + } + + @Override + public byte[] serialize(final MediaContentMinified content) throws Exception { + writer.reset(); + content.serialize(writer, true); + return writer.toByteArray(); + } + } + + + static Player forward(final data.media.Media.Player player) { + return player == data.media.Media.Player.JAVA + ? Player.JAVA + : Player.FLASH; + } + + static Size forward(final data.media.Image.Size size) { + return size == data.media.Image.Size.SMALL + ? Size.SMALL + : Size.LARGE; + } + + static data.media.Media.Player reverse(final Player player) { + return player == Player.JAVA + ? data.media.Media.Player.JAVA + : data.media.Media.Player.FLASH; + } + + static data.media.Image.Size reverse(final Size size) { + return size == Size.SMALL + ? data.media.Image.Size.SMALL + : data.media.Image.Size.LARGE; + } + + + static final class DSLPlatformFullMediaTransformer extends MediaTransformer { + @Override + public MediaContentFull[] resultArray(final int size) { + return new MediaContentFull[size]; + } + + @Override + public MediaContentFull forward(final data.media.MediaContent commonMediaContent) { + return new MediaContentFull(forward(commonMediaContent.media), forward(commonMediaContent.images)); + } + + private static MediaFull forward(final data.media.Media media) { + return new MediaFull( + media.uri, + media.title, + media.width, + media.height, + media.format, + media.duration, + media.size, + media.bitrate, + media.persons, + DSLPlatform.forward(media.player), + media.copyright); + } + + private static List forward(final List images) { + final ArrayList forwardedImgs = new ArrayList(images.size()); + for (final data.media.Image image : images) { + forwardedImgs.add(forward(image)); + } + return forwardedImgs; + } + + private static ImageFull forward(final data.media.Image image) { + return new ImageFull( + image.uri, + image.title, + image.width, + image.height, + DSLPlatform.forward(image.size)); + } + + @Override + public data.media.MediaContent reverse(final MediaContentFull mc) { + return new data.media.MediaContent(reverse(mc.getMedia()), reverse(mc.getImages())); + } + + private static data.media.Media reverse(final MediaFull media) { + return new data.media.Media( + media.getUri(), + media.getTitle(), + media.getWidth(), + media.getHeight(), + media.getFormat(), + media.getDuration(), + media.getSize(), + media.getBitrate(), + media.getBitrate() != 0, + media.getPersons(), + DSLPlatform.reverse(media.getPlayer()), + media.getCopyright()); + } + private static List reverse(final List images) { + final ArrayList reversed = new ArrayList(images.size()); + for (final ImageFull image : images) { + reversed.add(reverse(image)); + } + return reversed; + } + + private static data.media.Image reverse(final ImageFull image) { + return new data.media.Image( + image.getUri(), + image.getTitle(), + image.getWidth(), + image.getHeight(), + DSLPlatform.reverse(image.getSize())); + } + + @Override + public data.media.MediaContent shallowReverse(final MediaContentFull mc) { + return new data.media.MediaContent(reverse(mc.getMedia()), Collections. emptyList()); + } + } + + static final class DSLPlatformMinifiedMediaTransformer extends MediaTransformer { + @Override + public MediaContentMinified[] resultArray(final int size) { + return new MediaContentMinified[size]; + } + + @Override + public MediaContentMinified forward(final data.media.MediaContent commonMediaContent) { + return new MediaContentMinified(forward(commonMediaContent.media), forward(commonMediaContent.images)); + } + + private static MediaMinified forward(final data.media.Media media) { + return new MediaMinified( + media.uri, + media.title, + media.width, + media.height, + media.format, + media.duration, + media.size, + media.bitrate, + media.persons, + DSLPlatform.forward(media.player), + media.copyright); + } + + private static List forward(final List images) { + final ArrayList forwardedImgs = new ArrayList(images.size()); + for (final data.media.Image image : images) { + forwardedImgs.add(forward(image)); + } + return forwardedImgs; + } + + private static ImageMinified forward(final data.media.Image image) { + return new ImageMinified( + image.uri, + image.title, + image.width, + image.height, + DSLPlatform.forward(image.size)); + } + + @Override + public data.media.MediaContent reverse(final MediaContentMinified mc) { + return new data.media.MediaContent(reverse(mc.getMedia()), reverse(mc.getImages())); + } + + private static data.media.Media reverse(final MediaMinified media) { + return new data.media.Media( + media.getUri(), + media.getTitle(), + media.getWidth(), + media.getHeight(), + media.getFormat(), + media.getDuration(), + media.getSize(), + media.getBitrate(), + media.getBitrate() != 0, + media.getPersons(), + DSLPlatform.reverse(media.getPlayer()), + media.getCopyright()); + } + private static List reverse(final List images) { + final ArrayList reversed = new ArrayList(images.size()); + for (final ImageMinified image : images) { + reversed.add(reverse(image)); + } + return reversed; + } + + private static data.media.Image reverse(final ImageMinified image) { + return new data.media.Image( + image.getUri(), + image.getTitle(), + image.getWidth(), + image.getHeight(), + DSLPlatform.reverse(image.getSize())); + } + + @Override + public data.media.MediaContent shallowReverse(final MediaContentMinified mc) { + return new data.media.MediaContent(reverse(mc.getMedia()), Collections. emptyList()); + } + } +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/jackson/AsArrayIntrospector.java b/jvm-serializers-tpc/src/main/java/serializers/jackson/AsArrayIntrospector.java new file mode 100644 index 0000000..48d753d --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/jackson/AsArrayIntrospector.java @@ -0,0 +1,29 @@ +package serializers.jackson; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.databind.introspect.Annotated; +import com.fasterxml.jackson.databind.introspect.AnnotatedClass; +import com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector; + +/** + * Helper class used to force conditional "as-array" serialization + * without requiring value classes to be annotated. + */ +class AsArrayIntrospector extends JacksonAnnotationIntrospector +{ + private static final long serialVersionUID = 1L; + + @Override + public JsonFormat.Value findFormat(Annotated ann) { + // 2.4 frowns upon trying to use this for Enums, so avoid those + // also, limit to just claiming classes (POJOs) require it, not properties + if (ann instanceof AnnotatedClass) { + AnnotatedClass ac = (AnnotatedClass) ann; + if (ac.getAnnotated().isEnum()) { + return null; + } + return new JsonFormat.Value("", JsonFormat.Shape.ARRAY, "", ""); + } + return null; + } +} \ No newline at end of file diff --git a/jvm-serializers-tpc/src/main/java/serializers/jackson/BaseJacksonDataBind.java b/jvm-serializers-tpc/src/main/java/serializers/jackson/BaseJacksonDataBind.java new file mode 100644 index 0000000..26a6e97 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/jackson/BaseJacksonDataBind.java @@ -0,0 +1,48 @@ +package serializers.jackson; + +import java.io.*; + +import com.fasterxml.jackson.core.*; +import com.fasterxml.jackson.databind.JavaType; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.ObjectReader; +import com.fasterxml.jackson.databind.ObjectWriter; + +public abstract class BaseJacksonDataBind extends BaseJacksonDriver +{ + protected final JavaType type; + protected final ObjectMapper mapper; + protected final ObjectReader reader; + protected final ObjectWriter writer; + + protected BaseJacksonDataBind(String name, Class clazz, ObjectMapper mapper) + { + super(name); + type = mapper.getTypeFactory().constructType(clazz); + this.mapper = mapper; + reader = mapper.reader(type); + writer = mapper.writerFor(type); + } + + protected BaseJacksonDataBind(String name, JavaType type, + ObjectMapper mapper, ObjectReader reader, ObjectWriter writer) + { + super(name); + this.type = type; + this.mapper = mapper; + this.reader = reader; + this.writer = writer; + } + + protected final JsonParser constructParser(byte[] data) throws IOException { + return mapper.getFactory().createParser(data, 0, data.length); + } + + protected final JsonParser constructParser(InputStream in) throws IOException { + return mapper.getFactory().createParser(in); + } + + protected final JsonGenerator constructGenerator(OutputStream out) throws IOException { + return mapper.getFactory().createGenerator(out, JsonEncoding.UTF8); + } +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/jackson/BaseJacksonDriver.java b/jvm-serializers-tpc/src/main/java/serializers/jackson/BaseJacksonDriver.java new file mode 100644 index 0000000..aa9ea4a --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/jackson/BaseJacksonDriver.java @@ -0,0 +1,36 @@ +package serializers.jackson; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; + +import serializers.Serializer; + +abstract class BaseJacksonDriver extends Serializer +{ + protected final String name; + + protected BaseJacksonDriver(String n) + { + name = n; + } + + @Override + public final String getName() { + return name; + } + + @Override + public abstract byte[] serialize(T data) throws IOException; + + @Override + public abstract T deserialize(byte[] array) throws IOException; + + // // Future extensions for testing performance for item sequences + + @Override + public abstract void serializeItems(T[] items, OutputStream out) throws Exception; + + @Override + public abstract T[] deserializeItems(InputStream in, int numberOfItems) throws IOException; +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/jackson/JacksonAvroDatabind.java b/jvm-serializers-tpc/src/main/java/serializers/jackson/JacksonAvroDatabind.java new file mode 100644 index 0000000..f107f7e --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/jackson/JacksonAvroDatabind.java @@ -0,0 +1,36 @@ +package serializers.jackson; + +import serializers.*; +import serializers.avro.Avro; + +import com.fasterxml.jackson.databind.JavaType; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.ObjectReader; +import com.fasterxml.jackson.databind.ObjectWriter; +import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.dataformat.avro.AvroFactory; +import com.fasterxml.jackson.dataformat.avro.AvroSchema; + +import data.media.MediaContent; + +public class JacksonAvroDatabind +{ + public static void register(TestGroups groups) + { + ObjectMapper mapper = new ObjectMapper(new AvroFactory()); + mapper.enable(SerializationFeature.WRITE_ENUMS_USING_INDEX); + JavaType type = mapper.constructType(MediaContent.class); + AvroSchema schema = new AvroSchema(Avro.Media.sMediaContent); + ObjectReader reader = mapper.reader(type).with(schema); + ObjectWriter writer = mapper.writerFor(type).with(schema); + groups.media.add(JavaBuiltIn.mediaTransformer, new StdJacksonDataBind + ("avro/jackson/databind", type, mapper, reader, writer), + new SerFeatures( + SerFormat.JSON, + SerGraph.FLAT_TREE, + SerClass.ZERO_KNOWLEDGE, + "" + ) + ); + } +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/jackson/JacksonBsonDatabind.java b/jvm-serializers-tpc/src/main/java/serializers/jackson/JacksonBsonDatabind.java new file mode 100644 index 0000000..b0fa120 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/jackson/JacksonBsonDatabind.java @@ -0,0 +1,114 @@ +package serializers.jackson; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; + +import data.media.MediaContent; + +import com.fasterxml.jackson.core.*; +import com.fasterxml.jackson.databind.*; + +import serializers.*; + +import de.undercouch.bson4jackson.BsonFactory; +import de.undercouch.bson4jackson.BsonModule; + +/** + * This serializer uses bson4jackson in full automated data binding mode, which + * can handle typical Java POJOs (esp. beans; otherwise may need to annotate + * to configure) + */ +public class JacksonBsonDatabind +{ + public static void register(TestGroups groups) + { + JsonFactory f = new BsonFactory(); + ObjectMapper mapper = new ObjectMapper(f); + mapper.registerModule(new BsonModule()); + groups.media.add(JavaBuiltIn.mediaTransformer, + new DataBindBase( + "bson/jackson/databind", MediaContent.class, mapper), + new SerFeatures( + SerFormat.BIN_CROSSLANG, + SerGraph.FLAT_TREE, + SerClass.CLASSES_KNOWN, + "" + ) + ); + } + + public final static class DataBindBase extends Serializer + { + protected final String name; + protected final JavaType type; + protected final ObjectMapper mapper; + protected final ObjectReader objectReader; + protected final ObjectWriter objectWriter; + + public DataBindBase(String name, Class clazz, ObjectMapper mapper) + { + this.name = name; + type = mapper.constructType(clazz); + this.mapper = mapper; + objectReader = mapper.reader(type); + objectWriter = mapper.writerFor(type); + } + + @Override + public final String getName() { + return name; + } + + protected final JsonParser constructParser(byte[] data) throws IOException { + return mapper.getFactory().createParser(data, 0, data.length); + } + + protected final JsonParser constructParser(InputStream in) throws IOException { + return mapper.getFactory().createParser(in); + } + + protected final JsonGenerator constructGenerator(OutputStream out) throws IOException { + return mapper.getFactory().createGenerator(out, JsonEncoding.UTF8); + } + + @Override + public byte[] serialize(T data) throws IOException + { + return objectWriter.writeValueAsBytes(data); + } + + @Override + @SuppressWarnings("unchecked") + public T deserialize(byte[] array) throws IOException + { + return (T) objectReader.readValue(array, 0, array.length); + } + + // // Future extensions for testing performance for item sequences + + @Override + public void serializeItems(T[] items, OutputStream out) throws IOException + { + JsonGenerator generator = constructGenerator(out); + // JSON allows simple sequences, so: + for (int i = 0, len = items.length; i < len; ++i) { + mapper.writeValue(generator, items[i]); + } + generator.close(); + } + + @Override + @SuppressWarnings("unchecked") + public T[] deserializeItems(InputStream in, int numberOfItems) throws IOException + { + T[] result = (T[]) new Object[numberOfItems]; + JsonParser parser = constructParser(in); + for (int i = 0; i < numberOfItems; ++i) { + result[i] = (T) mapper.readValue(parser, type); + } + parser.close(); + return result; + } + } +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/jackson/JacksonCBORDatabind.java b/jvm-serializers-tpc/src/main/java/serializers/jackson/JacksonCBORDatabind.java new file mode 100644 index 0000000..203328f --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/jackson/JacksonCBORDatabind.java @@ -0,0 +1,42 @@ +package serializers.jackson; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.dataformat.cbor.*; + +import serializers.JavaBuiltIn; +import serializers.SerClass; +import serializers.SerFeatures; +import serializers.SerFormat; +import serializers.SerGraph; +import serializers.TestGroups; +import data.media.MediaContent; + +public class JacksonCBORDatabind +{ + public static void register(TestGroups groups) { // Jackson Smile defaults: share names, not values + register(groups, true, false); + } + + public static void register(TestGroups groups, boolean sharedNames, boolean sharedValues) + { + CBORFactory factory = new CBORFactory(); + // no point in using enum names with binary format, so: + ObjectMapper mapper = new ObjectMapper(factory); + groups.media.add(JavaBuiltIn.mediaTransformer, + new StdJacksonDataBind("cbor/jackson/databind", MediaContent.class, mapper), + new SerFeatures(SerFormat.BIN_CROSSLANG, + SerGraph.FLAT_TREE, + SerClass.ZERO_KNOWLEDGE, + "" + )); + + groups.media.add(JavaBuiltIn.mediaTransformer, + new JacksonJsonManual("cbor/jackson/manual", factory), + new SerFeatures(SerFormat.BIN_CROSSLANG, + SerGraph.FLAT_TREE, + SerClass.MANUAL_OPT, + "" + )); + } + +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/jackson/JacksonJrDatabind.java b/jvm-serializers-tpc/src/main/java/serializers/jackson/JacksonJrDatabind.java new file mode 100644 index 0000000..e1574ec --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/jackson/JacksonJrDatabind.java @@ -0,0 +1,76 @@ +package serializers.jackson; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.lang.reflect.Array; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.jr.ob.JSON; + +import data.media.MediaContent; +import serializers.*; + +public class JacksonJrDatabind +{ + public static void register(TestGroups groups) { + groups.media.add(JavaBuiltIn.mediaTransformer, new JrSerializer(MediaContent.class), + new SerFeatures( + SerFormat.JSON, + SerGraph.FLAT_TREE, + SerClass.ZERO_KNOWLEDGE, + "" + ) + ); + } + + public final static class JrSerializer extends Serializer + { + private final Class type; + private final JSON json; + + protected JrSerializer(Class t) + { + type = t; + json = JSON.std; + } + + @Override + public String getName() { return "json/jackson-jr/databind"; } + + @Override + public T deserialize(byte[] array) throws Exception { + return json.beanFrom(type, array); + } + + @Override + public byte[] serialize(T content) throws Exception { + return json.asBytes(content); + } + + @Override + public final void serializeItems(T[] items, OutputStream out) throws IOException + { + JsonGenerator g = json.getStreamingFactory().createGenerator(out); + // JSON allows simple sequences, so: + for (int i = 0, len = items.length; i < len; ++i) { + json.write(items[i], g); + } + g.close(); + } + + @Override + public T[] deserializeItems(InputStream in, int numberOfItems) throws IOException + { + @SuppressWarnings("unchecked") + T[] result = (T[]) Array.newInstance(type, numberOfItems); + JsonParser p = json.getStreamingFactory().createParser(in); + for (int i = 0; i < numberOfItems; ++i) { + result[i] = json.beanFrom(type, p); + } + p.close(); + return result; + } + } +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/jackson/JacksonJsonDatabind.java b/jvm-serializers-tpc/src/main/java/serializers/jackson/JacksonJsonDatabind.java new file mode 100644 index 0000000..6523e74 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/jackson/JacksonJsonDatabind.java @@ -0,0 +1,29 @@ +package serializers.jackson; + +import data.media.MediaContent; +import serializers.*; + +import com.fasterxml.jackson.databind.*; + +/** + * This serializer uses Jackson in full automated data binding mode, which + * can handle typical Java POJOs (esp. beans; otherwise may need to annotate + * to configure) + */ +public class JacksonJsonDatabind +{ + public static void register(TestGroups groups) + { + ObjectMapper mapper = new ObjectMapper(); + // note: could also force static typing; left out to keep defaults + groups.media.add(JavaBuiltIn.mediaTransformer, + new StdJacksonDataBind("json/jackson/databind", MediaContent.class, mapper), + new SerFeatures( + SerFormat.JSON, + SerGraph.FLAT_TREE, + SerClass.ZERO_KNOWLEDGE, + "" + ) + ); + } +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/jackson/JacksonJsonManual.java b/jvm-serializers-tpc/src/main/java/serializers/jackson/JacksonJsonManual.java new file mode 100644 index 0000000..5571044 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/jackson/JacksonJsonManual.java @@ -0,0 +1,459 @@ +package serializers.jackson; + +import data.media.*; +import static data.media.FieldMapping.*; + +import java.io.*; +import java.util.ArrayList; +import java.util.List; + +import com.fasterxml.jackson.core.*; +import com.fasterxml.jackson.core.io.SerializedString; + +import serializers.*; + +/** + * "Hand-written" version of Jackson-based codec. Not optimized for compactness, + * but code is relatively simple monkey code even if bit verbose. + */ +public class JacksonJsonManual extends BaseJacksonDriver +{ + protected final static SerializedString FIELD_IMAGES = new SerializedString(FULL_FIELD_NAME_IMAGES); + + protected final static SerializedString FIELD_MEDIA = new SerializedString(FULL_FIELD_NAME_MEDIA); + protected final static SerializedString FIELD_PLAYER = new SerializedString(FULL_FIELD_NAME_PLAYER); + + protected final static SerializedString FIELD_URI = new SerializedString(FULL_FIELD_NAME_URI); + protected final static SerializedString FIELD_TITLE = new SerializedString(FULL_FIELD_NAME_TITLE); + protected final static SerializedString FIELD_WIDTH = new SerializedString(FULL_FIELD_NAME_WIDTH); + protected final static SerializedString FIELD_HEIGHT = new SerializedString(FULL_FIELD_NAME_HEIGHT); + protected final static SerializedString FIELD_FORMAT = new SerializedString(FULL_FIELD_NAME_FORMAT); + protected final static SerializedString FIELD_DURATION = new SerializedString(FULL_FIELD_NAME_DURATION); + protected final static SerializedString FIELD_SIZE = new SerializedString(FULL_FIELD_NAME_SIZE); + protected final static SerializedString FIELD_BITRATE = new SerializedString(FULL_FIELD_NAME_BITRATE); + protected final static SerializedString FIELD_COPYRIGHT = new SerializedString(FULL_FIELD_NAME_COPYRIGHT); + protected final static SerializedString FIELD_PERSONS = new SerializedString(FULL_FIELD_NAME_PERSONS); + + public static void register(TestGroups groups) + { + JsonFactory factory = new JsonFactory(); + groups.media.add(JavaBuiltIn.mediaTransformer, new JacksonJsonManual("json/jackson/manual",factory), + new SerFeatures(SerFormat.JSON, + SerGraph.FLAT_TREE, + SerClass.MANUAL_OPT, + "" + ) + ); + } + + private final JsonFactory _factory; + + public JacksonJsonManual(String name, JsonFactory jsonFactory) + { + super(name); + _factory = jsonFactory; + } + + @SuppressWarnings("resource") + @Override + public final byte[] serialize(MediaContent content) throws IOException + { + ByteArrayOutputStream baos = outputStream(content); + JsonGenerator generator = constructGenerator(baos); + writeMediaContent(generator, content); + generator.close(); + return baos.toByteArray(); + } + + @Override + public final MediaContent deserialize(byte[] array) throws IOException + { + JsonParser parser = constructParser(array); + MediaContent mc = readMediaContent(parser); + parser.close(); + return mc; + } + + @Override + public final void serializeItems(MediaContent[] items, OutputStream out) throws IOException + { + JsonGenerator generator = constructGenerator(out); + // JSON allows simple sequences, so: + for (int i = 0, len = items.length; i < len; ++i) { + writeMediaContent(generator, items[i]); + } + generator.close(); + } + + @Override + public MediaContent[] deserializeItems(InputStream in, int numberOfItems) throws IOException + { + MediaContent[] result = new MediaContent[numberOfItems]; + JsonParser parser = constructParser(in); + for (int i = 0; i < numberOfItems; ++i) { + result[i] = readMediaContent(parser); + } + parser.close(); + return result; + } + + // // // Internal methods + + protected JsonParser constructParser(byte[] data) throws IOException { + return _factory.createParser(data, 0, data.length); + } + + protected JsonParser constructParser(InputStream in) throws IOException { + return _factory.createParser(in); + } + + protected JsonGenerator constructGenerator(OutputStream baos) throws IOException { + return _factory.createGenerator(baos, JsonEncoding.UTF8); + } + + ////////////////////////////////////////////////// + // Serialization + ////////////////////////////////////////////////// + + protected void writeMediaContent(JsonGenerator generator, MediaContent content) throws IOException + { + generator.writeStartObject(); + generator.writeFieldName(FIELD_MEDIA); + writeMedia(generator, content.media); + generator.writeFieldName(FIELD_IMAGES); + generator.writeStartArray(); + for (Image i : content.images) { + writeImage(generator, i); + } + generator.writeEndArray(); + generator.writeEndObject(); + } + + private void writeMedia(JsonGenerator generator, Media media) throws IOException + { + generator.writeStartObject(); + generator.writeFieldName(FIELD_PLAYER); + generator.writeString(media.player.name()); + generator.writeFieldName(FIELD_URI); + generator.writeString(media.uri); + if (media.title != null) { + generator.writeFieldName(FIELD_TITLE); + generator.writeString(media.title); + } + generator.writeFieldName(FIELD_WIDTH); + generator.writeNumber(media.width); + generator.writeFieldName(FIELD_HEIGHT); + generator.writeNumber(media.height); + generator.writeFieldName(FIELD_FORMAT); + generator.writeString(media.format); + generator.writeFieldName(FIELD_DURATION); + generator.writeNumber(media.duration); + generator.writeFieldName(FIELD_SIZE); + generator.writeNumber(media.size); + if (media.hasBitrate) { + generator.writeFieldName(FIELD_BITRATE); + generator.writeNumber(media.bitrate); + } + if (media.copyright != null) { + generator.writeFieldName(FIELD_COPYRIGHT); + generator.writeString(media.copyright); + } + generator.writeFieldName(FIELD_PERSONS); + generator.writeStartArray(); + for (String person : media.persons) { + generator.writeString(person); + } + generator.writeEndArray(); + generator.writeEndObject(); + } + + private void writeImage(JsonGenerator generator, Image image) throws IOException + { + generator.writeStartObject(); + generator.writeFieldName(FIELD_URI); + generator.writeString(image.uri); + if (image.title != null) { + generator.writeFieldName(FIELD_TITLE); + generator.writeString(image.title); + } + generator.writeFieldName(FIELD_WIDTH); + generator.writeNumber(image.width); + generator.writeFieldName(FIELD_HEIGHT); + generator.writeNumber(image.height); + generator.writeFieldName(FIELD_SIZE); + generator.writeString(image.size.name()); + generator.writeEndObject(); + } + + ////////////////////////////////////////////////// + // Deserialization + ////////////////////////////////////////////////// + + protected MediaContent readMediaContent(JsonParser parser) throws IOException + { + MediaContent mc = new MediaContent(); + if (parser.nextToken() != JsonToken.START_OBJECT) { + reportIllegal(parser, JsonToken.START_OBJECT); + } + // first fast version when field-order is as expected + if (parser.nextFieldName(FIELD_MEDIA)) { + mc.media = readMedia(parser); + if (parser.nextFieldName(FIELD_IMAGES)) { + mc.images = readImages(parser); + parser.nextToken(); + verifyCurrent(parser, JsonToken.END_OBJECT); + return mc; + } + } + + // and fallback if order was changed + for (; parser.getCurrentToken() == JsonToken.FIELD_NAME; parser.nextToken()) { + String field = parser.getCurrentName(); + Integer I = fullFieldToIndex.get(field); + if (I != null) { + switch (I) { + case FIELD_IX_MEDIA: + mc.media = readMedia(parser); + continue; + case FIELD_IX_IMAGES: + mc.images = readImages(parser); + continue; + } + } + throw new IllegalStateException("Unexpected field '"+field+"'"); + } + verifyCurrent(parser, JsonToken.END_OBJECT); + + if (mc.media == null) throw new IllegalStateException("Missing field: " + FIELD_MEDIA); + if (mc.images == null) mc.images = new ArrayList(); + + return mc; + } + + private Media readMedia(JsonParser parser) throws IOException + { + if (parser.nextToken() != JsonToken.START_OBJECT) { + reportIllegal(parser, JsonToken.START_OBJECT); + } + Media media = new Media(); + boolean haveWidth = false; + boolean haveHeight = false; + boolean haveDuration = false; + boolean haveSize = false; + + // As with above, first fast path + if (parser.nextFieldName(FIELD_PLAYER)) { + media.player = Media.Player.find(parser.nextTextValue()); + if (parser.nextFieldName(FIELD_URI)) { + media.uri = parser.nextTextValue(); + if (parser.nextFieldName(FIELD_TITLE)) { + media.title = parser.nextTextValue(); + if (parser.nextFieldName(FIELD_WIDTH)) { + haveWidth = true; + media.width = parser.nextIntValue(-1); + if (parser.nextFieldName(FIELD_HEIGHT)) { + haveHeight = true; + media.height = parser.nextIntValue(-1); + if (parser.nextFieldName(FIELD_FORMAT)) { + media.format = parser.nextTextValue(); + if (parser.nextFieldName(FIELD_DURATION)) { + haveDuration = true; + media.duration = parser.nextLongValue(-1L); + if (parser.nextFieldName(FIELD_SIZE)) { + haveSize = true; + media.size = parser.nextLongValue(-1L); + if (parser.nextFieldName(FIELD_BITRATE)) { + media.bitrate = parser.nextIntValue(-1); + media.hasBitrate = true; + if (parser.nextFieldName(FIELD_COPYRIGHT)) { + media.copyright = parser.nextTextValue(); + if (parser.nextFieldName(FIELD_PERSONS)) { + media.persons = readPersons(parser); + parser.nextToken(); + verifyCurrent(parser, JsonToken.END_OBJECT); + return media; + } + } + } + } + } + } + } + } + } + } + } + + // and if something reorder or missing, general loop: + + for (; parser.getCurrentToken() == JsonToken.FIELD_NAME; parser.nextToken()) { + String field = parser.getCurrentName(); + Integer I = fullFieldToIndex.get(field); + if (I != null) { + switch (I) { + case FIELD_IX_PLAYER: + media.player = Media.Player.find(parser.nextTextValue()); + continue; + case FIELD_IX_URI: + media.uri = parser.nextTextValue(); + continue; + case FIELD_IX_TITLE: + media.title = parser.nextTextValue(); + continue; + case FIELD_IX_WIDTH: + media.width = parser.nextIntValue(-1); + haveWidth = true; + continue; + case FIELD_IX_HEIGHT: + media.height = parser.nextIntValue(-1); + haveHeight = true; + continue; + case FIELD_IX_FORMAT: + media.format = parser.nextTextValue(); + continue; + case FIELD_IX_DURATION: + media.duration = parser.nextLongValue(-1L); + haveDuration = true; + continue; + case FIELD_IX_SIZE: + media.size = parser.nextLongValue(-1L); + haveSize = true; + continue; + case FIELD_IX_BITRATE: + media.bitrate = parser.nextIntValue(-1); + media.hasBitrate = true; + continue; + case FIELD_IX_PERSONS: + media.persons = readPersons(parser); + continue; + case FIELD_IX_COPYRIGHT: + media.copyright = parser.nextTextValue(); + continue; + } + } + throw new IllegalStateException("Unexpected field '"+field+"'"); + } + verifyCurrent(parser, JsonToken.END_OBJECT); + + if (media.uri == null) throw new IllegalStateException("Missing field: " + FIELD_URI); + if (!haveWidth) throw new IllegalStateException("Missing field: " + FIELD_WIDTH); + if (!haveHeight) throw new IllegalStateException("Missing field: " + FIELD_HEIGHT); + if (media.format == null) throw new IllegalStateException("Missing field: " + FIELD_FORMAT); + if (!haveDuration) throw new IllegalStateException("Missing field: " + FIELD_DURATION); + if (!haveSize) throw new IllegalStateException("Missing field: " + FIELD_SIZE); + if (media.persons == null) media.persons = new ArrayList(); + if (media.player == null) throw new IllegalStateException("Missing field: " + FIELD_PLAYER); + + return media; + } + + private List readImages(JsonParser parser) throws IOException + { + if (parser.nextToken() != JsonToken.START_ARRAY) { + reportIllegal(parser, JsonToken.START_ARRAY); + } + List images = new ArrayList(); + while (parser.nextToken() == JsonToken.START_OBJECT) { + images.add(readImage(parser)); + } + verifyCurrent(parser, JsonToken.END_ARRAY); + return images; + } + + private List readPersons(JsonParser parser) throws IOException + { + if (parser.nextToken() != JsonToken.START_ARRAY) { + reportIllegal(parser, JsonToken.START_ARRAY); + } + List persons = new ArrayList(); + String str; + while ((str = parser.nextTextValue()) != null) { + persons.add(str); + } + verifyCurrent(parser, JsonToken.END_ARRAY); + return persons; + } + + private Image readImage(JsonParser parser) throws IOException + { + boolean haveWidth = false; + boolean haveHeight = false; + Image image = new Image(); + if (parser.nextFieldName(FIELD_URI)) { + image.uri = parser.nextTextValue(); + if (parser.nextFieldName(FIELD_TITLE)) { + image.title = parser.nextTextValue(); + if (parser.nextFieldName(FIELD_WIDTH)) { + image.width = parser.nextIntValue(-1); + haveWidth = true; + if (parser.nextFieldName(FIELD_HEIGHT)) { + image.height = parser.nextIntValue(-1); + haveHeight = true; + if (parser.nextFieldName(FIELD_SIZE)) { + image.size = Image.Size.valueOf(parser.nextTextValue()); + parser.nextToken(); + verifyCurrent(parser, JsonToken.END_OBJECT); + return image; + } + } + } + } + } + + for (; parser.getCurrentToken() == JsonToken.FIELD_NAME; parser.nextToken()) { + String field = parser.getCurrentName(); + // read value token (or START_ARRAY) + parser.nextToken(); + Integer I = fullFieldToIndex.get(field); + if (I != null) { + switch (I) { + case FIELD_IX_URI: + image.uri = parser.getText(); + continue; + case FIELD_IX_TITLE: + image.title = parser.getText(); + continue; + case FIELD_IX_WIDTH: + image.width = parser.getIntValue(); + haveWidth = true; + continue; + case FIELD_IX_HEIGHT: + image.height = parser.getIntValue(); + haveHeight = true; + continue; + case FIELD_IX_SIZE: + image.size = Image.Size.valueOf(parser.getText()); + continue; + } + } + throw new IllegalStateException("Unexpected field '"+field+"'"); + } + + if (image.uri == null) throw new IllegalStateException("Missing field: " + FIELD_URI); + if (!haveWidth) throw new IllegalStateException("Missing field: " + FIELD_WIDTH); + if (!haveHeight) throw new IllegalStateException("Missing field: " + FIELD_HEIGHT); + if (image.size == null) throw new IllegalStateException("Missing field: " + FIELD_SIZE); + + verifyCurrent(parser, JsonToken.END_OBJECT); + + return image; + } + + private final void verifyCurrent(JsonParser parser, JsonToken expToken) throws IOException + { + if (parser.getCurrentToken() != expToken) { + reportIllegal(parser, expToken); + } + } + + private void reportIllegal(JsonParser parser, JsonToken expToken) throws IOException + { + JsonToken curr = parser.getCurrentToken(); + String msg = "Expected token "+expToken+"; got "+curr; + if (curr == JsonToken.FIELD_NAME) { + msg += " (current field name '"+parser.getCurrentName()+"')"; + } + msg += ", location: "+parser.getTokenLocation(); + throw new IllegalStateException(msg); + } +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/jackson/JacksonJsonTree.java b/jvm-serializers-tpc/src/main/java/serializers/jackson/JacksonJsonTree.java new file mode 100644 index 0000000..7675b2d --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/jackson/JacksonJsonTree.java @@ -0,0 +1,184 @@ +package serializers.jackson; + +import java.io.*; +import java.util.ArrayList; +import java.util.List; + +import com.fasterxml.jackson.core.*; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.ObjectNode; + +import serializers.*; + +import data.media.Image; +import data.media.Media; +import data.media.MediaContent; + +/** + * Driver that uses Jackson for manual tree processing (to/from byte[]). + */ +public class JacksonJsonTree extends BaseJacksonDataBind +{ + public static void register(TestGroups groups) + { + groups.media.add(JavaBuiltIn.mediaTransformer, new JacksonJsonTree( + "json/jackson/tree",new ObjectMapper()), + new SerFeatures( + SerFormat.JSON, + SerGraph.FLAT_TREE, + SerClass.MANUAL_OPT, + "" + ) + ); + } + + public JacksonJsonTree(String name, ObjectMapper mapper) { + super(name, MediaContent.class, mapper); + } + + @Override + public MediaContent deserialize(byte[] array) throws IOException + { + return readMediaContent(mapper.readTree(new ByteArrayInputStream(array))); + } + + @Override + public byte[] serialize(MediaContent mediaContent) throws IOException + { + JsonNode root = asTree(mediaContent, mapper.createObjectNode()); + return mapper.writeValueAsBytes(root); + } + + @Override + public void serializeItems(MediaContent[] items, OutputStream out) throws IOException + { + JsonGenerator generator = constructGenerator(out); + // JSON allows simple sequences, so: + for (int i = 0, len = items.length; i < len; ++i) { + mapper.writeValue(generator, asTree(items[i], mapper.createObjectNode())); + } + generator.close(); + } + + @Override + public MediaContent[] deserializeItems(InputStream in, int numberOfItems) throws IOException + { + JsonParser parser = constructParser(in); + MediaContent[] result = new MediaContent[numberOfItems]; + for (int i = 0; i < numberOfItems; ++i) { + result[i] = readMediaContent((JsonNode)mapper.readTree(parser)); + } + parser.close(); + return result; + } + + // // // Methods for deserializing using intermediate Tree representation + + protected static Image readImage(JsonNode node) + { + Image image = new Image(); + image.height = node.get("height").intValue(); + image.size = Image.Size.valueOf(node.get("size").textValue()); + image.title = node.get("title").textValue(); + image.uri = node.get("uri").textValue(); + image.width = node.get("width").intValue(); + return image; + } + + protected static List readImages(ArrayNode imagesNode) + { + int size = imagesNode.size(); + List images = new ArrayList(size); + for (JsonNode image : imagesNode) { + images.add(readImage(image)); + } + return images; + } + + protected static MediaContent readMediaContent(JsonNode root) throws IOException + { + MediaContent mediaContent = new MediaContent(); + mediaContent.media = readMedia(root.get("media")); + mediaContent.images = readImages((ArrayNode) root.get("images")); + return mediaContent; + } + + protected static Media readMedia(JsonNode node) + { + Media media = new Media(); + JsonNode bitrate = node.get("bitrate"); + if (bitrate != null && !bitrate.isNull()) { + media.bitrate = bitrate.intValue(); + media.hasBitrate = true; + } + media.copyright = node.path("copyright").textValue(); + media.duration = node.path("duration").longValue(); + media.format = node.path("format").textValue(); + media.height = node.path("height").intValue(); + media.player = Media.Player.valueOf(node.get("player").textValue()); + ArrayNode personsArrayNode = (ArrayNode) node.get("persons"); + int size = personsArrayNode.size(); + List persons = new ArrayList(size); + for (JsonNode person : personsArrayNode) { + persons.add(person.textValue()); + } + media.persons = persons; + media.size = node.get("size").intValue(); + media.title = node.get("title").textValue(); + media.uri = node.get("uri").textValue(); + media.width = node.get("width").intValue(); + return media; + } + + // // // Methods for serializing using intermediate Tree representation + + protected static JsonNode asTree(MediaContent mediaContent, ObjectNode node) throws IOException + { + addMedia(mediaContent.media, node.putObject("media")); + addImages(mediaContent.images, node.putArray("images")); + return node; + } + + protected static ObjectNode addImage(Image image, ObjectNode node) + { + node.put("height", image.height); + node.put("size", image.size.name()); + node.put("title", image.title); + node.put("uri", image.uri); + node.put("width", image.width); + return node; + } + + protected static ArrayNode addImages(List images, ArrayNode node) + { + for (Image image : images) { + addImage(image, node.addObject()); + } + return node; + } + + protected static ObjectNode addMedia(Media media, ObjectNode node) + { + if (media.hasBitrate) { + node.put("bitrate", media.bitrate); + } + node.put("copyright", media.copyright); + node.put("duration", media.duration); + node.put("format", media.format); + node.put("height", media.height); + ArrayNode persons = node.arrayNode(); + for (String person : media.persons) { + persons.add(person); + } + node.set("persons", persons); + node.put("player", media.player.name()); + node.put("size", media.size); + node.put("title", media.title); + node.put("uri", media.uri); + node.put("width", media.width); + return node; + } +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/jackson/JacksonSmileDatabind.java b/jvm-serializers-tpc/src/main/java/serializers/jackson/JacksonSmileDatabind.java new file mode 100644 index 0000000..29f50d8 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/jackson/JacksonSmileDatabind.java @@ -0,0 +1,39 @@ +package serializers.jackson; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; + +import com.fasterxml.jackson.dataformat.smile.*; + +import serializers.*; + +import data.media.MediaContent; + +public class JacksonSmileDatabind +{ + public static void register(TestGroups groups) { // Jackson Smile defaults: share names, not values + register(groups, true, false); + } + + public static void register(TestGroups groups, boolean sharedNames, boolean sharedValues) + { + SmileFactory factory = new SmileFactory(); + factory.configure(SmileGenerator.Feature.CHECK_SHARED_NAMES, sharedNames); + factory.configure(SmileGenerator.Feature.CHECK_SHARED_STRING_VALUES, sharedValues); + // no point in using enum names with binary format, so: + ObjectMapper mapper = new ObjectMapper(factory); + mapper.enable(SerializationFeature.WRITE_ENUMS_USING_INDEX); + + groups.media.add(JavaBuiltIn.mediaTransformer, + new StdJacksonDataBind("smile/jackson/databind", + MediaContent.class, mapper), + new SerFeatures( + SerFormat.BINARY, + SerGraph.FLAT_TREE, + SerClass.ZERO_KNOWLEDGE, + "" + ) + ); + } + +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/jackson/JacksonSmileManual.java b/jvm-serializers-tpc/src/main/java/serializers/jackson/JacksonSmileManual.java new file mode 100644 index 0000000..3792957 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/jackson/JacksonSmileManual.java @@ -0,0 +1,28 @@ +package serializers.jackson; + +import com.fasterxml.jackson.dataformat.smile.*; + +import serializers.*; + +public class JacksonSmileManual +{ + public static void register(TestGroups groups) { // Jackson Smile defaults: share names, not values + register(groups, true, false); + } + + public static void register(TestGroups groups, boolean sharedNames, boolean sharedValues) + { + SmileFactory factory = new SmileFactory(); + factory.configure(SmileGenerator.Feature.CHECK_SHARED_NAMES, sharedNames); + factory.configure(SmileGenerator.Feature.CHECK_SHARED_STRING_VALUES, sharedValues); + groups.media.add(JavaBuiltIn.mediaTransformer, new JacksonJsonManual("smile/jackson/manual", factory), + new SerFeatures( + SerFormat.BINARY, + SerGraph.FLAT_TREE, + SerClass.MANUAL_OPT, + "" + ) + ); + } + +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/jackson/JacksonWithAfterburner.java b/jvm-serializers-tpc/src/main/java/serializers/jackson/JacksonWithAfterburner.java new file mode 100644 index 0000000..c11792f --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/jackson/JacksonWithAfterburner.java @@ -0,0 +1,72 @@ +package serializers.jackson; + +import serializers.JavaBuiltIn; +import serializers.SerClass; +import serializers.SerFeatures; +import serializers.SerFormat; +import serializers.SerGraph; +import serializers.TestGroups; + +import com.fasterxml.jackson.core.JsonFactory; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.dataformat.cbor.CBORFactory; +import com.fasterxml.jackson.dataformat.smile.SmileFactory; +import com.fasterxml.jackson.dataformat.smile.SmileGenerator; +import com.fasterxml.jackson.module.afterburner.AfterburnerModule; + +import data.media.MediaContent; + +/** + * Class for registering variants of Jackson-based tests that use Afterburner + * for generating byte code to avoid use of Reflection for calling methods + * and constructing objects. + */ +public class JacksonWithAfterburner +{ + final static String STD_DESC = "uses bytecode generation to reduce overhead"; + + public static void registerAll(TestGroups groups) + { + registerJSON(groups); + registerSmile(groups); + registerCBOR(groups); + } + + public static void registerJSON(TestGroups groups) + { + ObjectMapper mapper = new ObjectMapper(new JsonFactory()); + mapper.registerModule(new AfterburnerModule()); + groups.media.add(JavaBuiltIn.mediaTransformer, + new StdJacksonDataBind("json/jackson+afterburner/databind", MediaContent.class, mapper), + new SerFeatures(SerFormat.BINARY, SerGraph.FLAT_TREE, SerClass.ZERO_KNOWLEDGE, STD_DESC)); + } + + public static void registerCBOR(TestGroups groups) + { + ObjectMapper mapper = new ObjectMapper(new CBORFactory()); + mapper.registerModule(new AfterburnerModule()); + groups.media.add(JavaBuiltIn.mediaTransformer, + new StdJacksonDataBind("cbor/jackson+afterburner/databind", MediaContent.class, mapper), + new SerFeatures(SerFormat.BINARY, SerGraph.FLAT_TREE, SerClass.ZERO_KNOWLEDGE, STD_DESC)); + } + + public static void registerSmile(TestGroups groups) { + // use defaults: shared names, not values (but set explicitly just in case) + // sharing can reduce size, but also adds some processing overhead -- typically name sharing + // cheap, value sharing bit more expensive; hence the defaults + registerSmile(groups, true, false); + } + + public static void registerSmile(TestGroups groups, boolean shareNames, boolean shareValues) + { + SmileFactory f = new SmileFactory(); + f.configure(SmileGenerator.Feature.CHECK_SHARED_NAMES, shareNames); + f.configure(SmileGenerator.Feature.CHECK_SHARED_STRING_VALUES, shareValues); + ObjectMapper smileMapper = new ObjectMapper(f); + + smileMapper.registerModule(new AfterburnerModule()); + groups.media.add(JavaBuiltIn.mediaTransformer, + new StdJacksonDataBind("smile/jackson+afterburner/databind", MediaContent.class, smileMapper), + new SerFeatures(SerFormat.BINARY, SerGraph.FLAT_TREE, SerClass.ZERO_KNOWLEDGE, STD_DESC)); + } +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/jackson/JacksonWithColumnsDatabind.java b/jvm-serializers-tpc/src/main/java/serializers/jackson/JacksonWithColumnsDatabind.java new file mode 100644 index 0000000..d6213c6 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/jackson/JacksonWithColumnsDatabind.java @@ -0,0 +1,51 @@ +package serializers.jackson; + +import serializers.*; + +import com.fasterxml.jackson.databind.*; + +import data.media.MediaContent; + +/** + * Codec(s) for serializing logical JSON content as JSON Array instead + * of the usual JSON Object; this condenses data size significantly and + * typically improves performance similarly. + */ +public class JacksonWithColumnsDatabind +{ + private final static String STD_DESC = "uses positional (column) layout to eliminate use of names"; + + public static void registerAll(TestGroups groups) + { + registerJSON(groups); + registerSmile(groups); + registerCBOR(groups); + } + + public static void registerCBOR(TestGroups groups) + { + ObjectMapper cborMapper = new ObjectMapper(new com.fasterxml.jackson.dataformat.cbor.CBORFactory()); + cborMapper.setAnnotationIntrospector(new AsArrayIntrospector()); + groups.media.add(JavaBuiltIn.mediaTransformer, + new StdJacksonDataBind("cbor-col/jackson/databind", MediaContent.class, cborMapper), + new SerFeatures(SerFormat.JSON,SerGraph.FLAT_TREE,SerClass.ZERO_KNOWLEDGE,STD_DESC)); + } + + public static void registerJSON(TestGroups groups) + { + ObjectMapper jsonMapper = new ObjectMapper(); + jsonMapper.setAnnotationIntrospector(new AsArrayIntrospector()); + groups.media.add(JavaBuiltIn.mediaTransformer, + new StdJacksonDataBind("json-col/jackson/databind", MediaContent.class, jsonMapper), + new SerFeatures(SerFormat.JSON,SerGraph.FLAT_TREE,SerClass.ZERO_KNOWLEDGE,STD_DESC)); + } + + public static void registerSmile(TestGroups groups) + { + ObjectMapper smileMapper = new ObjectMapper(new com.fasterxml.jackson.dataformat.smile.SmileFactory()); + smileMapper.setAnnotationIntrospector(new AsArrayIntrospector()); + groups.media.add(JavaBuiltIn.mediaTransformer, + new StdJacksonDataBind("smile-col/jackson/databind", MediaContent.class, smileMapper), + new SerFeatures(SerFormat.JSON,SerGraph.FLAT_TREE,SerClass.ZERO_KNOWLEDGE,STD_DESC)); + } +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/jackson/JacksonXmlDatabind.java b/jvm-serializers-tpc/src/main/java/serializers/jackson/JacksonXmlDatabind.java new file mode 100644 index 0000000..667d75b --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/jackson/JacksonXmlDatabind.java @@ -0,0 +1,34 @@ +package serializers.jackson; + +import serializers.*; + +import com.fasterxml.aalto.stax.InputFactoryImpl; +import com.fasterxml.aalto.stax.OutputFactoryImpl; + +import com.fasterxml.jackson.dataformat.xml.*; + +import data.media.MediaContent; + +/** + * Test for handling XML using "jackson-xml-databind" codec + * (https://github.com/FasterXML/jackson-xml-databind) + * with Aalto Stax XML parser. + */ +public class JacksonXmlDatabind +{ + public static void register(TestGroups groups) + { + XmlMapper mapper = new XmlMapper(new XmlFactory(null, + new InputFactoryImpl(), new OutputFactoryImpl())); + groups.media.add(JavaBuiltIn.mediaTransformer, + new StdJacksonDataBind("xml/jackson/databind", + MediaContent.class, mapper), + new SerFeatures( + SerFormat.XML, + SerGraph.FLAT_TREE, + SerClass.ZERO_KNOWLEDGE, + "" + ) + ); + } +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/jackson/JacksonYAMLDatabind.java b/jvm-serializers-tpc/src/main/java/serializers/jackson/JacksonYAMLDatabind.java new file mode 100644 index 0000000..591c1e7 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/jackson/JacksonYAMLDatabind.java @@ -0,0 +1,26 @@ +package serializers.jackson; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; + +import serializers.*; + +import data.media.MediaContent; + +public class JacksonYAMLDatabind +{ + public static void register(TestGroups groups) + { + ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); + groups.media.add(JavaBuiltIn.mediaTransformer, + new StdJacksonDataBind("yaml/jackson/databind", + MediaContent.class, mapper), + new SerFeatures( + SerFormat.JSON, + SerGraph.FULL_GRAPH, + SerClass.ZERO_KNOWLEDGE, + "" + ) + ); + } +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/jackson/StdJacksonDataBind.java b/jvm-serializers-tpc/src/main/java/serializers/jackson/StdJacksonDataBind.java new file mode 100644 index 0000000..be12368 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/jackson/StdJacksonDataBind.java @@ -0,0 +1,63 @@ +package serializers.jackson; + +import java.io.*; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; + +import com.fasterxml.jackson.databind.JavaType; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.ObjectReader; +import com.fasterxml.jackson.databind.ObjectWriter; + +public final class StdJacksonDataBind extends BaseJacksonDataBind +{ + public StdJacksonDataBind(String name, Class clazz, ObjectMapper mapper) { + super(name, clazz, mapper); + } + + public StdJacksonDataBind(String name, JavaType type, + ObjectMapper mapper, ObjectReader reader, ObjectWriter writer) + { + super(name, type, mapper, reader, writer); + } + + @Override + public byte[] serialize(T data) throws IOException + { + return writer.writeValueAsBytes(data); + } + + @Override + @SuppressWarnings("unchecked") + public T deserialize(byte[] array) throws IOException + { + return (T) reader.readValue(array, 0, array.length); + } + + // // Future extensions for testing performance for item sequences + + @Override + public void serializeItems(T[] items, OutputStream out) throws IOException + { + JsonGenerator generator = constructGenerator(out); + // JSON allows simple sequences, so: + for (int i = 0, len = items.length; i < len; ++i) { + writer.writeValue(generator, items[i]); + } + generator.close(); + } + + @Override + @SuppressWarnings("unchecked") + public T[] deserializeItems(InputStream in, int numberOfItems) throws IOException + { + T[] result = (T[]) new Object[numberOfItems]; + JsonParser parser = constructParser(in); + for (int i = 0; i < numberOfItems; ++i) { + result[i] = (T) reader.readValue(parser, type); + } + parser.close(); + return result; + } +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/java/Image.java b/jvm-serializers-tpc/src/main/java/serializers/java/Image.java new file mode 100644 index 0000000..16a8142 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/java/Image.java @@ -0,0 +1,131 @@ +package serializers.java; + +import java.io.Serializable; + +import com.twolattes.json.Entity; +import com.twolattes.json.Value; + +import data.media.FieldMapping; + +@Entity +public class Image implements Serializable +{ + private static final long serialVersionUID = 1L; + + public enum Size + { + SMALL, LARGE + } + + private @Value(name=FieldMapping.FULL_FIELD_NAME_URI) String _uri; + private @Value(name=FieldMapping.FULL_FIELD_NAME_TITLE) String _title; + private @Value(name=FieldMapping.FULL_FIELD_NAME_WIDTH) int _width; + private @Value(name=FieldMapping.FULL_FIELD_NAME_HEIGHT) int _height; + private @Value(name=FieldMapping.FULL_FIELD_NAME_SIZE, ordinal = true) Size _size; + + public Image(){} + + public Image (int height, String title, String uri, int width, Size size) + { + super(); + _height = height; + _title = title; + _uri = uri; + _width = width; + _size = size; + } + + public String getUri () + { + return _uri; + } + + public void setUri (String uri) + { + _uri = uri; + } + + public String getTitle () + { + return _title; + } + + public void setTitle (String title) + { + _title = title; + } + + public int getWidth () + { + return _width; + } + + public void setWidth (int width) + { + _width = width; + } + + public int getHeight () + { + return _height; + } + + public void setHeight (int height) + { + _height = height; + } + + public Size getSize () + { + return _size; + } + + public void setSize (Size size) + { + this._size = size; + } + + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + _height; + result = prime * result + ((_size == null) ? 0 : _size.hashCode()); + result = prime * result + ((_title == null) ? 0 : _title.hashCode()); + result = prime * result + ((_uri == null) ? 0 : _uri.hashCode()); + result = prime * result + _width; + return result; + } + + public boolean equals( Object obj ) { + if ( this == obj ) return true; + if ( obj == null ) return false; + if ( getClass() != obj.getClass() ) return false; + Image other = (Image)obj; + if ( _height != other._height ) return false; + if ( _size == null ) { + if ( other._size != null ) return false; + } else if ( !_size.equals(other._size) ) return false; + if ( _title == null ) { + if ( other._title != null ) return false; + } else if ( !_title.equals(other._title) ) return false; + if ( _uri == null ) { + if ( other._uri != null ) return false; + } else if ( !_uri.equals(other._uri) ) return false; + if ( _width != other._width ) return false; + return true; + } + + @Override + public String toString() + { + StringBuilder sb = new StringBuilder(); + sb.append("[Image "); + sb.append("width=").append(_width); + sb.append(", height=").append(_height); + sb.append(", uri=").append(_uri); + sb.append(", title=").append(_title); + sb.append(", size=").append(_size); + sb.append("]"); + return sb.toString(); + } +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/java/Media.java b/jvm-serializers-tpc/src/main/java/serializers/java/Media.java new file mode 100644 index 0000000..fa85c39 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/java/Media.java @@ -0,0 +1,245 @@ +package serializers.java; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +import com.twolattes.json.Entity; +import com.twolattes.json.Value; + +@Entity +public class Media implements Serializable +{ + private static final long serialVersionUID = 1L; + + public enum Player + { + JAVA, FLASH + } + + // Note: MUST use names from StdMediaSerializer (FIELD_NAME_xxx) + + private @Value(name = "pl", ordinal = true) Player _player; + private @Value(name = "ul") String _uri; + private @Value(name = "tl") String _title; + private @Value(name = "wd") int _width; + private @Value(name = "hg") int _height; + private @Value(name = "fr") String _format; + private @Value(name = "dr") long _duration; + private @Value(name = "sz") long _size; + private @Value(name = "br") int _bitrate; + private @Value(name = "pr") List _persons; + private @Value(name = "c") String _copyright; + + public Media(){} + + public Media (String copyright, + String format, + Player player, + String title, + String uri, + long duration, + long size, + int height, + int width, + int bitrate) + { + _copyright = copyright; + _duration = duration; + _format = format; + _height = height; + _player = player; + _size = size; + _title = title; + _uri = uri; + _width = width; + _bitrate = bitrate; + } + + public Player getPlayer () + { + return _player; + } + + public void setPlayer (Player player) + { + _player = player; + } + + public String getUri () + { + return _uri; + } + + public void setUri (String uri) + { + _uri = uri; + } + + public String getTitle () + { + return _title; + } + + public void setTitle (String title) + { + _title = title; + } + + public int getWidth () + { + return _width; + } + + public void setWidth (int width) + { + _width = width; + } + + public int getHeight () + { + return _height; + } + + public void setHeight (int height) + { + _height = height; + } + + public String getFormat () + { + return _format; + } + + public void setFormat (String format) + { + _format = format; + } + + public long getDuration () + { + return _duration; + } + + public void setDuration (long duration) + { + _duration = duration; + } + + public long getSize () + { + return _size; + } + + public void setSize (long size) + { + _size = size; + } + + public int getBitrate () + { + return _bitrate; + } + + public void setBitrate (int bitrate) + { + this._bitrate = bitrate; + } + + public List getPersons () + { + return _persons; + } + + public void setPersons(List p) + { + _persons = p; + } + + public void addToPerson (String person) + { + if (null == _persons) + { + _persons = new ArrayList(); + } + _persons.add(person); + } + + public String getCopyright () + { + return _copyright; + } + + public void setCopyright (String copyright) + { + _copyright = copyright; + } + + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + _bitrate; + result = prime * result + ((_copyright == null) ? 0 : _copyright.hashCode()); + result = prime * result + (int)(_duration ^ (_duration >>> 32)); + result = prime * result + ((_format == null) ? 0 : _format.hashCode()); + result = prime * result + _height; + result = prime * result + ((_persons == null) ? 0 : _persons.hashCode()); + result = prime * result + ((_player == null) ? 0 : _player.hashCode()); + result = prime * result + (int)(_size ^ (_size >>> 32)); + result = prime * result + ((_title == null) ? 0 : _title.hashCode()); + result = prime * result + ((_uri == null) ? 0 : _uri.hashCode()); + result = prime * result + _width; + return result; + } + + public boolean equals( Object obj ) { + if ( this == obj ) return true; + if ( obj == null ) return false; + if ( getClass() != obj.getClass() ) return false; + Media other = (Media)obj; + if ( _bitrate != other._bitrate ) return false; + if ( _copyright == null ) { + if ( other._copyright != null ) return false; + } else if ( !_copyright.equals(other._copyright) ) return false; + if ( _duration != other._duration ) return false; + if ( _format == null ) { + if ( other._format != null ) return false; + } else if ( !_format.equals(other._format) ) return false; + if ( _height != other._height ) return false; + if ( _persons == null ) { + if ( other._persons != null ) return false; + } else if ( !_persons.equals(other._persons) ) return false; + if ( _player == null ) { + if ( other._player != null ) return false; + } else if ( !_player.equals(other._player) ) return false; + if ( _size != other._size ) return false; + if ( _title == null ) { + if ( other._title != null ) return false; + } else if ( !_title.equals(other._title) ) return false; + if ( _uri == null ) { + if ( other._uri != null ) return false; + } else if ( !_uri.equals(other._uri) ) return false; + if ( _width != other._width ) return false; + return true; + } + + @Override + public String toString() + { + StringBuilder sb = new StringBuilder(); + sb.append("[Media "); + sb.append("width=").append(_width); + sb.append(", height=").append(_height); + sb.append(", duration=").append(_duration); + sb.append(", size=").append(_size); + sb.append(", bitrate=").append(_bitrate); + sb.append(", player=").append(_player); + sb.append(", uri=").append(_uri); + sb.append(", title=").append(_title); + sb.append(", format=").append(_format); + sb.append(", persons=").append(_persons); + sb.append(", copyright=").append(_copyright); + sb.append("]"); + return sb.toString(); + } +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/java/MediaContent.java b/jvm-serializers-tpc/src/main/java/serializers/java/MediaContent.java new file mode 100644 index 0000000..797a722 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/java/MediaContent.java @@ -0,0 +1,85 @@ +package serializers.java; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +import com.twolattes.json.Entity; +import com.twolattes.json.Value; + +import data.media.FieldMapping; + +@Entity +public class MediaContent implements Serializable +{ + private static final long serialVersionUID = 1L; + + private @Value(name = FieldMapping.FULL_FIELD_NAME_IMAGES) List _images; + private @Value(name = FieldMapping.FULL_FIELD_NAME_MEDIA) Media _media; + + public MediaContent() { } + + public MediaContent (Media media) + { + _media = media; + } + + public List getImages() { return _images; } + public void setImages(List i) { _images = i; } + + public void addImage (Image image) + { + if(_images == null) + { + _images = new ArrayList(); + } + _images.add(image); + } + + public int imageCount() { return _images.size(); } + + public Image getImage (int i) + { + return _images.get(i); + } + + public Media getMedia () + { + return _media; + } + + public void setMedia(Media m) { _media = m; } + + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((_images == null) ? 0 : _images.hashCode()); + result = prime * result + ((_media == null) ? 0 : _media.hashCode()); + return result; + } + + public boolean equals( Object obj ) { + if ( this == obj ) return true; + if ( obj == null ) return false; + if ( getClass() != obj.getClass() ) return false; + MediaContent other = (MediaContent)obj; + if ( _images == null ) { + if ( other._images != null ) return false; + } else if ( !_images.equals(other._images) ) return false; + if ( _media == null ) { + if ( other._media != null ) return false; + } else if ( !_media.equals(other._media) ) return false; + return true; + } + + @Override + public String toString() + { + StringBuilder sb = new StringBuilder(); + sb.append("[MediaContent: "); + sb.append("media=").append(_media); + sb.append(", images=").append(_images); + sb.append("]"); + return sb.toString(); + } +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/javaxjson/JavaxJsonStream.java b/jvm-serializers-tpc/src/main/java/serializers/javaxjson/JavaxJsonStream.java new file mode 100644 index 0000000..c0594e7 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/javaxjson/JavaxJsonStream.java @@ -0,0 +1,311 @@ +package serializers.javaxjson; + +import static data.media.FieldMapping.*; + +import java.io.*; +import java.util.*; + +import javax.json.spi.*; +import javax.json.stream.*; +import javax.json.stream.JsonParser.Event; + +import org.apache.activemq.util.buffer.ByteArrayInputStream; + +import serializers.*; +import data.media.*; + +/** + * Base class for benchmark using the streaming capabilities of javax.json. + *

+ * Code is based of JacksonJsonManual; first copy/pasted then modified to fit + * javax.json classes. There was a "fast" path version, but given that there's + * no optimization possible with the API (no nextFieldName like there is in + * Jackson), the only overhead we have here is the mapping between field name + * and index. + */ +public abstract class JavaxJsonStream extends Serializer { + private final JsonProvider json; + + public JavaxJsonStream(JsonProvider json) { + this.json = json; + } + + @Override + public final byte[] serialize(MediaContent content) throws IOException { + ByteArrayOutputStream baos = outputStream(content); + JsonGenerator generator = constructGenerator(baos); + writeMediaContent(generator, content); + generator.close(); + return baos.toByteArray(); + } + + @Override + public final MediaContent deserialize(byte[] array) throws IOException { + JsonParser parser = constructParser(array); + MediaContent mc = readMediaContent(parser); + parser.close(); + return mc; + } + + private JsonGenerator constructGenerator(ByteArrayOutputStream baos) { + return json.createGenerator(baos); + } + + private JsonParser constructParser(byte[] array) { + return json.createParser(new ByteArrayInputStream(array)); + } + + ////////////////////////////////////////////////// + // Serialization + ////////////////////////////////////////////////// + + protected void writeMediaContent(JsonGenerator generator, MediaContent content) throws IOException { + generator.writeStartObject(); + generator.writeStartObject(FULL_FIELD_NAME_MEDIA); + writeMedia(generator, content.media); + generator.writeStartArray(FULL_FIELD_NAME_IMAGES); + for (Image i : content.images) { + writeImage(generator, i); + } + generator.writeEnd(); + generator.writeEnd(); + } + + private void writeMedia(JsonGenerator generator, Media media) throws IOException { + generator.write(FULL_FIELD_NAME_PLAYER, media.player.name()); + generator.write(FULL_FIELD_NAME_URI, media.uri); + if (media.title != null) { + generator.write(FULL_FIELD_NAME_TITLE, media.title); + } + generator.write(FULL_FIELD_NAME_WIDTH, media.width); + generator.write(FULL_FIELD_NAME_HEIGHT, media.height); + generator.write(FULL_FIELD_NAME_FORMAT, media.format); + generator.write(FULL_FIELD_NAME_DURATION, media.duration); + generator.write(FULL_FIELD_NAME_SIZE, media.size); + if (media.hasBitrate) { + generator.write(FULL_FIELD_NAME_BITRATE, media.bitrate); + } + if (media.copyright != null) { + generator.write(FULL_FIELD_NAME_COPYRIGHT, media.copyright); + } + generator.writeStartArray(FULL_FIELD_NAME_PERSONS); + for (String person : media.persons) { + generator.write(person); + } + generator.writeEnd(); + generator.writeEnd(); + } + + private void writeImage(JsonGenerator generator, Image image) throws IOException { + generator.writeStartObject(); + generator.write(FULL_FIELD_NAME_URI, image.uri); + if (image.title != null) { + generator.write(FULL_FIELD_NAME_TITLE, image.title); + } + generator.write(FULL_FIELD_NAME_WIDTH, image.width); + generator.write(FULL_FIELD_NAME_HEIGHT, image.height); + generator.write(FULL_FIELD_NAME_SIZE, image.size.name()); + generator.writeEnd(); + } + + ////////////////////////////////////////////////// + // Deserialization + ////////////////////////////////////////////////// + + protected MediaContent readMediaContent(JsonParser parser) throws IOException { + MediaContent mc = new MediaContent(); + Event current; + if ((current = parser.next()) != Event.START_OBJECT) { + reportIllegal(parser, current, Event.START_OBJECT); + } + while ((current = parser.next()) == Event.KEY_NAME) { + String field = parser.getString(); + Integer I = fullFieldToIndex.get(field); + if (I != null) { + switch (I) { + case FIELD_IX_MEDIA: + mc.media = readMedia(parser); + continue; + case FIELD_IX_IMAGES: + mc.images = readImages(parser); + continue; + } + } + throw new IllegalStateException("Unexpected field '" + field + "'"); + } + verifyCurrent(parser, current, Event.END_OBJECT); + + if (mc.media == null) throw new IllegalStateException("Missing field: " + FULL_FIELD_NAME_MEDIA); + if (mc.images == null) mc.images = new ArrayList(); + + return mc; + } + + private Media readMedia(JsonParser parser) throws IOException { + Event current; + if ((current = parser.next()) != Event.START_OBJECT) { + reportIllegal(parser, current, Event.START_OBJECT); + } + Media media = new Media(); + boolean haveWidth = false; + boolean haveHeight = false; + boolean haveDuration = false; + boolean haveSize = false; + + while ((current = parser.next()) == Event.KEY_NAME) { + String field = parser.getString(); + Integer I = fullFieldToIndex.get(field); + if (I != null) { + switch (I) { + case FIELD_IX_PLAYER: + current = parser.next(); + media.player = Media.Player.find(parser.getString()); + continue; + case FIELD_IX_URI: + current = parser.next(); + media.uri = parser.getString(); + continue; + case FIELD_IX_TITLE: + current = parser.next(); + media.title = parser.getString(); + continue; + case FIELD_IX_WIDTH: + current = parser.next(); + media.width = parser.getInt(); + haveWidth = true; + continue; + case FIELD_IX_HEIGHT: + current = parser.next(); + media.height = parser.getInt(); + haveHeight = true; + continue; + case FIELD_IX_FORMAT: + current = parser.next(); + media.format = parser.getString(); + continue; + case FIELD_IX_DURATION: + current = parser.next(); + media.duration = parser.getInt(); + haveDuration = true; + continue; + case FIELD_IX_SIZE: + current = parser.next(); + media.size = parser.getInt(); + haveSize = true; + continue; + case FIELD_IX_BITRATE: + current = parser.next(); + media.bitrate = parser.getInt(); + media.hasBitrate = true; + continue; + case FIELD_IX_PERSONS: + media.persons = readPersons(parser); + continue; + case FIELD_IX_COPYRIGHT: + current = parser.next(); + media.copyright = parser.getString(); + continue; + } + } + throw new IllegalStateException("Unexpected field '" + field + "'"); + } + verifyCurrent(parser, current, Event.END_OBJECT); + + if (media.uri == null) throw new IllegalStateException("Missing field: " + FULL_FIELD_NAME_URI); + if (!haveWidth) throw new IllegalStateException("Missing field: " + FULL_FIELD_NAME_WIDTH); + if (!haveHeight) throw new IllegalStateException("Missing field: " + FULL_FIELD_NAME_HEIGHT); + if (media.format == null) throw new IllegalStateException("Missing field: " + FULL_FIELD_NAME_FORMAT); + if (!haveDuration) throw new IllegalStateException("Missing field: " + FULL_FIELD_NAME_DURATION); + if (!haveSize) throw new IllegalStateException("Missing field: " + FULL_FIELD_NAME_SIZE); + if (media.persons == null) media.persons = new ArrayList(); + if (media.player == null) throw new IllegalStateException("Missing field: " + FULL_FIELD_NAME_PLAYER); + + return media; + } + + private List readImages(JsonParser parser) throws IOException { + Event current; + if ((current = parser.next()) != Event.START_ARRAY) { + reportIllegal(parser, current, Event.START_ARRAY); + } + List images = new ArrayList(); + while ((current = parser.next()) == Event.START_OBJECT) { + images.add(readImage(parser)); + } + verifyCurrent(parser, current, Event.END_ARRAY); + return images; + } + + private List readPersons(JsonParser parser) throws IOException { + Event current; + if ((current = parser.next()) != Event.START_ARRAY) { + reportIllegal(parser, current, Event.START_ARRAY); + } + List persons = new ArrayList(); + while ((current = parser.next()) == Event.VALUE_STRING) { + persons.add(parser.getString()); + } + verifyCurrent(parser, current, Event.END_ARRAY); + return persons; + } + + private Image readImage(JsonParser parser) throws IOException { + Event current; + boolean haveWidth = false; + boolean haveHeight = false; + Image image = new Image(); + + while ((current = parser.next()) == Event.KEY_NAME) { + String field = parser.getString(); + // read value token (or START_ARRAY) + current = parser.next(); + Integer I = fullFieldToIndex.get(field); + if (I != null) { + switch (I) { + case FIELD_IX_URI: + image.uri = parser.getString(); + continue; + case FIELD_IX_TITLE: + image.title = parser.getString(); + continue; + case FIELD_IX_WIDTH: + image.width = parser.getInt(); + haveWidth = true; + continue; + case FIELD_IX_HEIGHT: + image.height = parser.getInt(); + haveHeight = true; + continue; + case FIELD_IX_SIZE: + image.size = Image.Size.valueOf(parser.getString()); + continue; + } + } + throw new IllegalStateException("Unexpected field '" + field + "'"); + } + + if (image.uri == null) throw new IllegalStateException("Missing field: " + FULL_FIELD_NAME_URI); + if (!haveWidth) throw new IllegalStateException("Missing field: " + FULL_FIELD_NAME_WIDTH); + if (!haveHeight) throw new IllegalStateException("Missing field: " + FULL_FIELD_NAME_HEIGHT); + if (image.size == null) throw new IllegalStateException("Missing field: " + FULL_FIELD_NAME_SIZE); + + verifyCurrent(parser, current, Event.END_OBJECT); + + return image; + } + + private final void verifyCurrent(JsonParser parser, Event current, Event expToken) throws IOException { + if (current != expToken) { + reportIllegal(parser, current, expToken); + } + } + + private void reportIllegal(JsonParser parser, Event current, Event expToken) throws IOException { + String msg = "Expected token " + expToken + "; got " + current; + if (current == Event.KEY_NAME) { + msg += " (current field name '" + parser.getString() + "')"; + } + msg += ", location: " + parser.getLocation(); + throw new IllegalStateException(msg); + } +} \ No newline at end of file diff --git a/jvm-serializers-tpc/src/main/java/serializers/javaxjson/JavaxJsonStreamGlassfish.java b/jvm-serializers-tpc/src/main/java/serializers/javaxjson/JavaxJsonStreamGlassfish.java new file mode 100644 index 0000000..6425d93 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/javaxjson/JavaxJsonStreamGlassfish.java @@ -0,0 +1,29 @@ +package serializers.javaxjson; + +import org.glassfish.json.*; + +import serializers.*; + +public class JavaxJsonStreamGlassfish extends JavaxJsonStream { + private static final JsonProviderImpl JSON = new JsonProviderImpl(); + + public JavaxJsonStreamGlassfish() { + super(JSON); + } + + @Override + public String getName() { + return "json/javax-stream/glassfish"; + } + + public static void register(TestGroups groups) { + groups.media.add(JavaBuiltIn.mediaTransformer, new JavaxJsonStreamGlassfish(), + new SerFeatures( + SerFormat.JSON, + SerGraph.FLAT_TREE, + SerClass.MANUAL_OPT, + "" + ) + ); + } +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/javaxjson/JavaxJsonTransformer.java b/jvm-serializers-tpc/src/main/java/serializers/javaxjson/JavaxJsonTransformer.java new file mode 100644 index 0000000..88424f6 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/javaxjson/JavaxJsonTransformer.java @@ -0,0 +1,131 @@ +package serializers.javaxjson; + +import static data.media.FieldMapping.*; + +import java.util.*; + +import javax.json.*; +import javax.json.spi.*; + +import serializers.*; +import data.media.*; + +public class JavaxJsonTransformer extends Transformer { + private final JsonProvider json; + + public JavaxJsonTransformer(JsonProvider json) { + this.json = json; + } + + @Override + public JsonStructure forward(MediaContent content) { + Media media = content.media; + JsonObjectBuilder mediaJson = json.createObjectBuilder(); + mediaJson.add(FULL_FIELD_NAME_BITRATE, media.bitrate); + if(media.copyright == null ){ + mediaJson.add(FULL_FIELD_NAME_COPYRIGHT, JsonValue.NULL); + } else{ + mediaJson.add(FULL_FIELD_NAME_COPYRIGHT, media.copyright); + } + + mediaJson.add(FULL_FIELD_NAME_DURATION, media.duration); + mediaJson.add(FULL_FIELD_NAME_FORMAT, media.format); + mediaJson.add(FULL_FIELD_NAME_HEIGHT, media.height); + JsonArrayBuilder personsJson = json.createArrayBuilder(); + for (String person : media.persons) { + personsJson.add(person); + } + mediaJson.add(FULL_FIELD_NAME_PERSONS, personsJson); + mediaJson.add(FULL_FIELD_NAME_PLAYER, media.player.name()); + mediaJson.add(FULL_FIELD_NAME_SIZE, media.size); + mediaJson.add(FULL_FIELD_NAME_TITLE, media.title); + mediaJson.add(FULL_FIELD_NAME_URI, media.uri); + mediaJson.add(FULL_FIELD_NAME_WIDTH, media.width); + JsonArrayBuilder imagesJson = json.createArrayBuilder(); + for (Image image : content.images) { + JsonObjectBuilder imageJson = json.createObjectBuilder(); + imageJson.add(FULL_FIELD_NAME_TITLE, image.title); + imageJson.add(FULL_FIELD_NAME_URI, image.uri); + imageJson.add(FULL_FIELD_NAME_HEIGHT, image.height); + imageJson.add(FULL_FIELD_NAME_WIDTH, image.width); + imageJson.add(FULL_FIELD_NAME_SIZE, image.size.name()); + imagesJson.add(imageJson); + } + JsonObjectBuilder contentJson = json.createObjectBuilder(); + contentJson.add(FULL_FIELD_NAME_MEDIA, mediaJson); + contentJson.add(FULL_FIELD_NAME_IMAGES, imagesJson); + return contentJson.build(); + } + + @Override + public MediaContent reverse(JsonStructure content) { + return extractContent(content); + } + + private MediaContent extractContent(JsonStructure content) { + JsonObject mediaContentJson = (JsonObject) content; + MediaContent mc = new MediaContent(); + JsonObject mediaJson = mediaContentJson.getJsonObject(FULL_FIELD_NAME_MEDIA); + Media media = new Media(); + media.player = Media.Player.find(mediaJson.getString(FULL_FIELD_NAME_PLAYER)); + media.uri = getStringProperty(mediaJson, FULL_FIELD_NAME_URI); + media.title = getStringProperty(mediaJson, FULL_FIELD_NAME_TITLE); + media.width = getIntProperty(mediaJson, FULL_FIELD_NAME_WIDTH); + media.height = getIntProperty(mediaJson, FULL_FIELD_NAME_HEIGHT); + media.format = getStringProperty(mediaJson, FULL_FIELD_NAME_FORMAT); + media.duration = getIntProperty(mediaJson, FULL_FIELD_NAME_DURATION); + media.size = getIntProperty(mediaJson, FULL_FIELD_NAME_SIZE); + media.bitrate = getIntProperty(mediaJson, FULL_FIELD_NAME_BITRATE); + media.hasBitrate = true; + media.copyright = getStringProperty(mediaJson, FULL_FIELD_NAME_COPYRIGHT); + JsonArray personsJson = getCheckedArrayProperty(mediaJson, FULL_FIELD_NAME_PERSONS); + List persons = new ArrayList(); + for (JsonValue value : personsJson) { + persons.add(value.toString()); + } + media.persons = persons; + mc.media = media; + JsonArray imagesJson = getCheckedArrayProperty(mediaContentJson, FULL_FIELD_NAME_IMAGES); + List images = new ArrayList(); + for (JsonValue value : imagesJson) { + Image image = new Image(); + JsonObject imageJson = (JsonObject) value; + image.uri = getStringProperty(imageJson, FULL_FIELD_NAME_URI); + image.title = getStringProperty(imageJson, FULL_FIELD_NAME_TITLE); + image.width = getIntProperty(imageJson, FULL_FIELD_NAME_WIDTH); + image.height = getIntProperty(imageJson, FULL_FIELD_NAME_HEIGHT); + image.size = Image.Size.valueOf(getStringProperty(imageJson, FULL_FIELD_NAME_SIZE)); + images.add(image); + } + mc.images = images; + return mc; + } + + private JsonArray getCheckedArrayProperty(JsonObject mediaJson, String fullFieldNamePersons) { + return mediaJson.getJsonArray(fullFieldNamePersons); + } + + private int getIntProperty(JsonObject mediaJson, String fullFieldNameWidth) { + return mediaJson.getInt(fullFieldNameWidth); + } + + private String getStringProperty(JsonObject mediaJson, String fullFieldNameUri) { + if(mediaJson.isNull(fullFieldNameUri)) return null; + return mediaJson.getString(fullFieldNameUri); + } + + @Override + public MediaContent shallowReverse(JsonStructure a) { + throw new UnsupportedOperationException("Not implemented"); + } + + @Override + public MediaContent[] sourceArray(int size) { + return new MediaContent[size]; + } + + @Override + public JsonStructure[] resultArray(int size) { + return new JsonStructure[size]; + } +} \ No newline at end of file diff --git a/jvm-serializers-tpc/src/main/java/serializers/javaxjson/JavaxJsonTree.java b/jvm-serializers-tpc/src/main/java/serializers/javaxjson/JavaxJsonTree.java new file mode 100644 index 0000000..b45cb3c --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/javaxjson/JavaxJsonTree.java @@ -0,0 +1,34 @@ +package serializers.javaxjson; + +import java.io.*; + +import javax.json.*; +import javax.json.spi.*; + +import serializers.*; + +/** + * Base class for javax.json benchmark using the tree model intermediate + */ +public abstract class JavaxJsonTree extends Serializer { + private final JsonProvider json; + + public JavaxJsonTree(JsonProvider json) { + this.json = json; + } + + @Override + public JsonStructure deserialize(byte[] array) throws Exception { + return json.createReader(new ByteArrayInputStream(array)).read(); + } + + @Override + public byte[] serialize(JsonStructure content) throws Exception { + ByteArrayOutputStream outputStream = outputStream(content); + JsonWriter writer = json.createWriter(outputStream); + writer.write(content); + writer.close(); + return outputStream.toByteArray(); + } + +} \ No newline at end of file diff --git a/jvm-serializers-tpc/src/main/java/serializers/javaxjson/JavaxJsonTreeGlassfish.java b/jvm-serializers-tpc/src/main/java/serializers/javaxjson/JavaxJsonTreeGlassfish.java new file mode 100644 index 0000000..2cc3f53 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/javaxjson/JavaxJsonTreeGlassfish.java @@ -0,0 +1,29 @@ +package serializers.javaxjson; + +import org.glassfish.json.*; + +import serializers.*; + +public class JavaxJsonTreeGlassfish extends JavaxJsonTree { + private static final JsonProviderImpl JSON = new JsonProviderImpl(); + + public JavaxJsonTreeGlassfish() { + super(JSON); + } + + @Override + public String getName() { + return "json/javax-tree/glassfish"; + } + + public static void register(TestGroups groups) { + groups.media.add(new JavaxJsonTransformer(JSON), new JavaxJsonTreeGlassfish(), + new SerFeatures( + SerFormat.JSON, + SerGraph.FLAT_TREE, + SerClass.ZERO_KNOWLEDGE, + "" + ) + ); + } +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/json/FastJSONDatabind.java b/jvm-serializers-tpc/src/main/java/serializers/json/FastJSONDatabind.java new file mode 100644 index 0000000..aa5ab9f --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/json/FastJSONDatabind.java @@ -0,0 +1,62 @@ +package serializers.json; + +import java.io.*; + +import serializers.*; + +import data.media.MediaContent; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.serializer.SerializerFeature; +import com.alibaba.fastjson.parser.Feature; + +/** + * This serializer uses FastJSON [http://code.alibabatech.com/wiki/display/FastJSON] for JSON data binding. + */ +public class FastJSONDatabind +{ + public static void register(TestGroups groups) + { + groups.media.add(JavaBuiltIn.mediaTransformer, + new GenericSerializer("json/fastjson/databind", MediaContent.class), + new SerFeatures( + SerFormat.JSON, + SerGraph.FLAT_TREE, + SerClass.ZERO_KNOWLEDGE, + "" + ) + ); + } + + static class GenericSerializer extends Serializer + { + private final String name; + private final Class type; + + public GenericSerializer(String name, Class clazz) + { + this.name = name; + type = clazz; + } + + @Override + public String getName() + { + return name; + } + + @SuppressWarnings("unchecked") + @Override + public T deserialize(byte[] array) throws Exception + { + // fastjson can parse from byte array, yay: + return (T) JSON.parseObject(array, type, Feature.DisableCircularReferenceDetect); + } + + @Override + public byte[] serialize(T data) throws IOException + { + return JSON.toJSONBytes(data, SerializerFeature.WriteEnumUsingToString,SerializerFeature.DisableCircularReferenceDetect); + } + } +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/json/FlexjsonDatabind.java b/jvm-serializers-tpc/src/main/java/serializers/json/FlexjsonDatabind.java new file mode 100644 index 0000000..46a26f0 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/json/FlexjsonDatabind.java @@ -0,0 +1,57 @@ +package serializers.json; + +import java.io.*; + +import serializers.*; + +import data.media.MediaContent; +import flexjson.JSONDeserializer; +import flexjson.JSONSerializer; + +/** + * This serializer uses Flexjson for data binding. + * http://flexjson.sourceforge.net + */ +public class FlexjsonDatabind +{ + public static void register(TestGroups groups) + { + groups.media.add(JavaBuiltIn.mediaTransformer, + new GenericSerializer("json/flexjson/databind", MediaContent.class), + new SerFeatures( + SerFormat.JSON, + SerGraph.FULL_GRAPH, + SerClass.ZERO_KNOWLEDGE, + "" + ) + ); + } + + static class GenericSerializer extends Serializer + { + private final String name; + private final Class type; + + public GenericSerializer(String name, Class clazz) + { + this.name = name; + type = clazz; + } + + public String getName() + { + return name; + } + + public T deserialize(byte[] array) throws Exception + { + return new JSONDeserializer().deserialize(new String(array, "UTF-8"), type); + } + + public byte[] serialize(T data) throws IOException + { + String jsonString = new JSONSerializer().exclude("*.class").deepSerialize(data); + return jsonString.getBytes("UTF-8"); + } + } +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/json/JsonArgoTree.java b/jvm-serializers-tpc/src/main/java/serializers/json/JsonArgoTree.java new file mode 100644 index 0000000..1bd658c --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/json/JsonArgoTree.java @@ -0,0 +1,206 @@ +package serializers.json; + +import static argo.jdom.JsonNodeFactories.aJsonArray; +import static argo.jdom.JsonNodeFactories.aJsonNull; +import static argo.jdom.JsonNodeFactories.aJsonNumber; +import static argo.jdom.JsonNodeFactories.aJsonObject; +import static argo.jdom.JsonNodeFactories.aJsonString; +import static argo.jdom.JsonNodeType.NULL; +import static java.lang.Integer.parseInt; +import static java.lang.Long.parseLong; +import static java.util.Arrays.asList; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import serializers.*; + +import argo.format.CompactJsonFormatter; +import argo.format.JsonFormatter; +import argo.jdom.JdomParser; +import argo.jdom.JsonField; +import argo.jdom.JsonNode; +import argo.jdom.JsonStringNode; +import data.media.Image; +import data.media.Media; +import data.media.MediaContent; + +/** + * Driver that uses Argo [http://argo.sourceforge.net], with manual tree processing. + * + * Implementation provided by Mark Slater, admin and committer on the Argo project. + */ +public class JsonArgoTree +{ + public static void register(TestGroups groups) + { + groups.media.add(JavaBuiltIn.mediaTransformer, + new ManualTreeSerializer("json/argo/manual-tree"), + new SerFeatures( + SerFormat.JSON, + SerGraph.FLAT_TREE, + SerClass.MANUAL_OPT, + "" + ) + ); + } + + static class ManualTreeSerializer extends Serializer + { + private final String name; + + public ManualTreeSerializer(String name) + { + this.name = name; + } + + public String getName() + { + return name; + } + + public MediaContent deserialize(byte[] array) throws Exception + { + String mediaContentJsonInput = new String(array, "UTF-8"); + return readMediaContent(mediaContentJsonInput); + } + + public byte[] serialize(MediaContent mediaContent) throws IOException + { + return writeMediaContent(mediaContent).getBytes("UTF-8"); + } + + private static final JsonFormatter JSON_FORMATTER = new CompactJsonFormatter(); + private static final JdomParser JDOM_PARSER = new JdomParser(); + + private static final JsonStringNode MEDIA_KEY = aJsonString("media"); + private static final JsonStringNode IMAGES_KEY = aJsonString("images"); + private static final JsonStringNode URI_KEY = aJsonString("uri"); + private static final JsonStringNode WIDTH_KEY = aJsonString("width"); + private static final JsonStringNode HEIGHT_KEY = aJsonString("height"); + private static final JsonStringNode SIZE_KEY = aJsonString("size"); + private static final JsonStringNode COPYRIGHT_KEY = aJsonString("copyright"); + private static final JsonStringNode DURATION_KEY = aJsonString("duration"); + private static final JsonStringNode TITLE_KEY = aJsonString("title"); + private static final JsonStringNode PLAYER_KEY = aJsonString("player"); + private static final JsonStringNode FORMAT_KEY = aJsonString("format"); + private static final JsonStringNode PERSONS_KEY = aJsonString("persons"); + private static final JsonStringNode BIT_RATE_KEY = aJsonString("bitrate"); + + private String writeMediaContent(MediaContent mediaContent) + { + return JSON_FORMATTER.format( + aJsonObject( + new JsonField(MEDIA_KEY, createMediaObject(mediaContent.media)), + new JsonField(IMAGES_KEY, createImagesArray(mediaContent.images)) + )); + } + + private JsonNode createImagesArray(List images) + { + List jsonNodes = new ArrayList(images.size() * 2); + for (Image image : images) + { + jsonNodes.add(aJsonObject( + new JsonField(HEIGHT_KEY, aJsonNumber(String.valueOf(image.height))), + new JsonField(SIZE_KEY, aJsonString(image.size.name())), + new JsonField(TITLE_KEY, aJsonString(image.title)), + new JsonField(URI_KEY, aJsonString(image.uri)), + new JsonField(WIDTH_KEY, aJsonNumber(String.valueOf(image.width))) + )); + } + return aJsonArray(jsonNodes); + } + + private JsonNode createMediaObject(Media media) + { + List persons = new ArrayList(media.persons.size() * 2); + for (String person : media.persons) + { + persons.add(aJsonString(person)); + } + JsonNode value = media.copyright == null ? aJsonNull() : aJsonString(media.copyright); + List jsonFields = new ArrayList(asList( + new JsonField(URI_KEY, aJsonString(media.uri)), + new JsonField(TITLE_KEY, aJsonString(media.title)), + new JsonField(WIDTH_KEY, aJsonNumber(String.valueOf(media.width))), + new JsonField(HEIGHT_KEY, aJsonNumber(String.valueOf(media.height))), + new JsonField(FORMAT_KEY, aJsonString(media.format)), + new JsonField(DURATION_KEY, aJsonNumber(String.valueOf(media.duration))), + new JsonField(SIZE_KEY, aJsonNumber(String.valueOf(media.size))), + new JsonField(PLAYER_KEY, aJsonString(media.player.name())), + new JsonField(COPYRIGHT_KEY, value), + new JsonField(PERSONS_KEY, aJsonArray(persons)) + )); + if (media.hasBitrate) + { + jsonFields.add(new JsonField(BIT_RATE_KEY, aJsonNumber(String.valueOf(media.bitrate)))); + } + return aJsonObject(jsonFields); + } + + MediaContent readMediaContent(String mediaContentJsonInput) throws Exception + { + MediaContent mediaContent = new MediaContent(); + Map fields = JDOM_PARSER.parse(mediaContentJsonInput).getFields(); + mediaContent.media = readMedia(fields.get(MEDIA_KEY)); + mediaContent.images = readImages(fields.get(IMAGES_KEY)); + return mediaContent; + } + + private Media readMedia(JsonNode jsonNode) + { + Media media = new Media(); + Map fields = jsonNode.getFields(); + media.copyright = getValueOrNull(fields.get(COPYRIGHT_KEY)); + media.duration = parseLong(fields.get(DURATION_KEY).getText()); + media.format = getValueOrNull(fields.get(FORMAT_KEY)); + media.player = Media.Player.valueOf(fields.get(PLAYER_KEY).getText()); + media.title = getValueOrNull(fields.get(TITLE_KEY)); + media.uri = getValueOrNull(fields.get(URI_KEY)); + media.size = parseLong(fields.get(SIZE_KEY).getText()); + media.height = parseInt(fields.get(HEIGHT_KEY).getText()); + media.width = parseInt(fields.get(WIDTH_KEY).getText()); + + List personNodesElements = fields.get(PERSONS_KEY).getElements(); + List persons = new ArrayList(personNodesElements.size() * 2); + for (JsonNode personNode : personNodesElements) + { + persons.add(personNode.getText()); + } + media.persons = persons; + JsonNode bitRate = fields.get(BIT_RATE_KEY); + if (bitRate != null && bitRate.getType() != NULL) + { + media.bitrate = parseInt(bitRate.getText()); + media.hasBitrate = true; + } + return media; + } + + private static String getValueOrNull(JsonNode textNode) + { + return textNode.getType() == NULL ? null : textNode.getText(); + } + + private List readImages(JsonNode node) + { + List elements = node.getElements(); + List images = new ArrayList(elements.size() * 2); + for (JsonNode jsonNode : elements) + { + Map fields = jsonNode.getFields(); + images.add(new Image( + fields.get(URI_KEY).getText(), + fields.get(TITLE_KEY).getText(), + parseInt(fields.get(WIDTH_KEY).getText()), + parseInt(fields.get(HEIGHT_KEY).getText()), + Image.Size.valueOf(fields.get(SIZE_KEY).getText()) + )); + } + return images; + } + } +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/json/JsonDotOrgManualTree.java b/jvm-serializers-tpc/src/main/java/serializers/json/JsonDotOrgManualTree.java new file mode 100644 index 0000000..1000315 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/json/JsonDotOrgManualTree.java @@ -0,0 +1,215 @@ +package serializers.json; + +import java.io.StringWriter; +import java.util.ArrayList; +import java.util.List; + +import org.json.JSONArray; +import org.json.JSONObject; +import org.json.JSONWriter; + +import serializers.*; + +import data.media.Image; +import data.media.Media; +import data.media.MediaContent; + +/** + * Driver that uses the json.org reference JSON implementation in Java, with semi-manual parsing. + */ +public class JsonDotOrgManualTree +{ + public static void register(TestGroups groups) + { + groups.media.add(JavaBuiltIn.mediaTransformer, + new ManualTreeSerializer("json/org.json/manual-tree"), + new SerFeatures( + SerFormat.JSON, + SerGraph.FLAT_TREE, + SerClass.MANUAL_OPT, + "" + ) + ); + } + + static class ManualTreeSerializer extends Serializer + { + private final String name; + + public ManualTreeSerializer(String name) + { + this.name = name; + } + + public String getName() + { + return name; + } + + public MediaContent deserialize(byte[] array) throws Exception + { + String mediaContentJsonInput = new String(array, "UTF-8"); + return readMediaContent(mediaContentJsonInput); + } + + public byte[] serialize(MediaContent mediaContent) throws Exception + { + StringWriter writer = new StringWriter(); + writeMediaContent(new JSONWriter(writer), mediaContent); + writer.flush(); + return writer.toString().getBytes("UTF-8"); + } + + static Media readMedia(String mediaJsonInput) throws Exception + { + JSONObject mediaJsonObject = new JSONObject(mediaJsonInput); + return readMedia(mediaJsonObject); + } + + static Media readMedia(JSONObject mediaJsonObject) throws Exception + { + Media media = new Media(); + Object bitrate = mediaJsonObject.get("bitrate"); + if (bitrate != null && bitrate instanceof Integer) + { + media.bitrate = ((Integer) bitrate).intValue(); + media.hasBitrate = true; + } + Object copyright = mediaJsonObject.get("copyright"); + if (copyright != null && !JSONObject.NULL.equals(copyright)) + { + media.copyright = (String) mediaJsonObject.get("copyright"); + } + media.duration = ((Integer) mediaJsonObject.get("duration")).longValue(); + media.format = (String) mediaJsonObject.get("format"); + media.height = ((Integer) mediaJsonObject.get("height")).intValue(); + List persons = new ArrayList(); + JSONArray personsJsonArray = (JSONArray) mediaJsonObject.get("persons"); + for (int i = 0, size = personsJsonArray.length(); i < size; i++) + { + persons.add((String) personsJsonArray.get(i)); + } + media.persons = persons; + media.player = Media.Player.valueOf((String) mediaJsonObject.get("player")); + media.size = ((Integer) mediaJsonObject.get("size")).longValue(); + media.title = (String) mediaJsonObject.get("title"); + media.uri = (String) mediaJsonObject.get("uri"); + media.width = ((Integer) mediaJsonObject.get("width")).intValue(); + return media; + } + + static MediaContent readMediaContent(String mediaContentJsonInput) throws Exception + { + JSONObject mediaContentJsonObject = new JSONObject(mediaContentJsonInput); + MediaContent mediaContent = new MediaContent(); + mediaContent.images = readImages((JSONArray) mediaContentJsonObject.get("images")); + mediaContent.media = readMedia((JSONObject) mediaContentJsonObject.get("media")); + return mediaContent; + } + + static Image readImage(String imageJsonInput) throws Exception + { + JSONObject imageJsonObject = new JSONObject(imageJsonInput); + return readImage(imageJsonObject); + } + + static Image readImage(JSONObject imageJsonObject) throws Exception + { + Image image = new Image(); + image.height = ((Integer) imageJsonObject.get("height")).intValue(); + image.size = Image.Size.valueOf((String) imageJsonObject.get("size")); + image.title = (String) imageJsonObject.get("title"); + image.uri = (String) imageJsonObject.get("uri"); + image.width = ((Integer) imageJsonObject.get("width")).intValue(); + return image; + } + + static List readImages(String imagesJsonInput) throws Exception + { + JSONArray imagesJsonArray = new JSONArray(imagesJsonInput); + return readImages(imagesJsonArray); + } + + static List readImages(JSONArray imagesJsonArray) throws Exception + { + int size = imagesJsonArray.length(); + List images = new ArrayList(size); + for (int i = 0; i < size; i++) + { + images.add(readImage((JSONObject) imagesJsonArray.get(i))); + } + return images; + } + + static void writeJsonObject(JSONWriter jsonWriter, Media media) throws Exception + { + jsonWriter.object(); + if (media.hasBitrate) + { + jsonWriter.key("bitrate").value(media.bitrate); + } + jsonWriter.key("copyright").value(media.copyright); + jsonWriter.key("duration").value(media.duration); + jsonWriter.key("format").value(media.format); + jsonWriter.key("height").value(media.height); + JSONArray personsJsonArray = new JSONArray(); + for (int i = 0, size = media.persons.size(); i < size; i++) + { + personsJsonArray.put(media.persons.get(i)); + } + jsonWriter.key("persons").value(personsJsonArray); + jsonWriter.key("player").value(media.player.name()); + jsonWriter.key("size").value(media.size); + jsonWriter.key("title").value(media.title); + jsonWriter.key("uri").value(media.uri); + jsonWriter.key("width").value(media.width); + jsonWriter.endObject(); + } + + static void writeMedia(JSONWriter jsonWriter, Media media) throws Exception + { + writeJsonObject(jsonWriter, media); + } + + static void writeImage(JSONWriter jsonWriter, Image image) throws Exception + { + writeJsonObject(jsonWriter, image); + } + + static void writeJsonObject(JSONWriter jsonWriter, Image image) throws Exception + { + jsonWriter.object(); + jsonWriter.key("height").value(image.height); + jsonWriter.key("size").value(image.size.name()); + jsonWriter.key("title").value(image.title); + jsonWriter.key("uri").value(image.uri); + jsonWriter.key("width").value(image.width); + jsonWriter.endObject(); + } + + static void writeMediaContent(JSONWriter jsonWriter, MediaContent mediaContent) throws Exception + { + jsonWriter.object(); + jsonWriter.key("media"); + writeJsonObject(jsonWriter, mediaContent.media); + jsonWriter.key("images"); + writeJsonArray(jsonWriter, mediaContent.images); + jsonWriter.endObject(); + } + + static void writeJsonArray(JSONWriter jsonWriter, List images) throws Exception + { + jsonWriter.array(); + for (Image image : images) + { + writeJsonObject(jsonWriter, image); + } + jsonWriter.endArray(); + } + + static void writeImages(JSONWriter jsonWriter, List images) throws Exception + { + writeJsonArray(jsonWriter, images); + } + } +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/json/JsonGsonDatabind.java b/jvm-serializers-tpc/src/main/java/serializers/json/JsonGsonDatabind.java new file mode 100644 index 0000000..b820672 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/json/JsonGsonDatabind.java @@ -0,0 +1,59 @@ +package serializers.json; + +import java.io.*; + +import serializers.*; + +import data.media.MediaContent; + +/** + * This serializer uses Google-gson for data binding. + * to configure) + */ +public class JsonGsonDatabind +{ + public static void register(TestGroups groups) + { + groups.media.add(JavaBuiltIn.mediaTransformer, + new GenericSerializer("json/gson/databind", MediaContent.class), + new SerFeatures( + SerFormat.JSON, + SerGraph.FLAT_TREE, + SerClass.ZERO_KNOWLEDGE, + "" + ) + ); + } + + // ------------------------------------------------------------ + // Serializer (just one) + + static class GenericSerializer extends Serializer + { + private final com.google.gson.Gson _gson = new com.google.gson.Gson(); + private final String name; + private final Class type; + + public GenericSerializer(String name, Class clazz) + { + this.name = name; + type = clazz; + } + + public String getName() { return name; } + + public T deserialize(byte[] array) throws Exception + { + T result = _gson.fromJson(new String(array, "UTF-8"), type); + return result; + } + + public byte[] serialize(T data) throws IOException + { + StringWriter w = new StringWriter(); + _gson.toJson(data, w); + w.flush(); + return w.toString().getBytes("UTF-8"); + } + } +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/json/JsonGsonManual.java b/jvm-serializers-tpc/src/main/java/serializers/json/JsonGsonManual.java new file mode 100644 index 0000000..091f494 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/json/JsonGsonManual.java @@ -0,0 +1,337 @@ +package serializers.json; + +import static data.media.FieldMapping.*; + +import java.io.*; +import java.util.ArrayList; +import java.util.List; + +import serializers.*; + +import com.google.gson.stream.*; + +import data.media.Image; +import data.media.Media; +import data.media.MediaContent; + +/** + * Driver that uses the new streaming parser of GSON, with fully + * manual data binding for optimal performance. + */ +public class JsonGsonManual +{ + public static void register(TestGroups groups) + { + groups.media.add(JavaBuiltIn.mediaTransformer, + new ManualSerializer("json/gson/manual"), + new SerFeatures( + SerFormat.JSON, + SerGraph.FLAT_TREE, + SerClass.MANUAL_OPT, + "" + ) + ); + } + + // ------------------------------------------------------------ + // Serializer (just one) + + static class ManualSerializer extends Serializer + { + private final String name; + + public ManualSerializer(String name) { + this.name = name; + } + + public String getName() { return name; } + + public MediaContent deserialize(byte[] array) throws Exception + { + Reader r = new StringReader(new String(array, "UTF-8")); + JsonReader reader = new JsonReader(r); + MediaContent content = readMediaContent(reader); + r.close(); + return content; + } + + public byte[] serialize(MediaContent data) throws IOException + { + StringWriter w = new StringWriter(); + JsonWriter writer = new JsonWriter(w); + writeMediaContent(writer, data); + writer.close(); + w.flush(); + return w.toString().getBytes("UTF-8"); + } + + // // // Read methods + + protected MediaContent readMediaContent(JsonReader parser) throws IOException + { + MediaContent mc = new MediaContent(); + if (parser.peek() != JsonToken.BEGIN_OBJECT) { + reportIllegal(parser, JsonToken.BEGIN_OBJECT); + } + parser.beginObject(); + + // loop for main-level fields + JsonToken t; + + while ((t = parser.peek()) != JsonToken.END_OBJECT) { + if (t != JsonToken.NAME) { + reportIllegal(parser, JsonToken.NAME); + } + String field = parser.nextName(); + Integer I = fullFieldToIndex.get(field); + if (I != null) { + switch (I) { + case FIELD_IX_MEDIA: + mc.media = readMedia(parser); + continue; + case FIELD_IX_IMAGES: + if (parser.peek() != JsonToken.BEGIN_ARRAY) { + reportIllegal(parser, JsonToken.BEGIN_ARRAY); + } + parser.beginArray(); + List images = new ArrayList(); + while (parser.peek() == JsonToken.BEGIN_OBJECT) { + parser.beginObject(); + images.add(readImage(parser)); + } + parser.endArray(); + mc.images = images; + continue; + } + } + throw new IllegalStateException("Unexpected field '"+field+"'"); + } + parser.endObject(); + + if (mc.media == null) throw new IllegalStateException("Missing field: " + FULL_FIELD_NAME_MEDIA); + if (mc.images == null) mc.images = new ArrayList(); + + return mc; + } + + private Media readMedia(JsonReader parser) throws IOException + { + if (parser.peek() != JsonToken.BEGIN_OBJECT) { + reportIllegal(parser, JsonToken.BEGIN_OBJECT); + } + parser.beginObject(); + Media media = new Media(); + JsonToken t; + + boolean haveWidth = false; + boolean haveHeight = false; + boolean haveDuration = false; + boolean haveSize = false; + + while ((t = parser.peek()) != JsonToken.END_OBJECT) { + if (t != JsonToken.NAME) { + reportIllegal(parser, JsonToken.NAME); + } + // read value token (or BEGIN_ARRAY) + String field = parser.nextName(); + Integer I = fullFieldToIndex.get(field); + if (I != null) { + switch (I) { + case FIELD_IX_PLAYER: + media.player = Media.Player.valueOf(parser.nextString()); + continue; + case FIELD_IX_URI: + media.uri = parser.nextString(); + continue; + case FIELD_IX_TITLE: + media.title = parser.nextString(); + continue; + case FIELD_IX_WIDTH: + media.width = parser.nextInt(); + haveWidth = true; + continue; + case FIELD_IX_HEIGHT: + media.height = parser.nextInt(); + haveHeight = true; + continue; + case FIELD_IX_FORMAT: + media.format = parser.nextString(); + continue; + case FIELD_IX_DURATION: + media.duration = parser.nextLong(); + haveDuration = true; + continue; + case FIELD_IX_SIZE: + media.size = parser.nextLong(); + haveSize = true; + continue; + case FIELD_IX_BITRATE: + media.bitrate = parser.nextInt(); + media.hasBitrate = true; + continue; + case FIELD_IX_PERSONS: + if (parser.peek() != JsonToken.BEGIN_ARRAY) { + reportIllegal(parser, JsonToken.BEGIN_ARRAY); + } + parser.beginArray(); + List persons = new ArrayList(); + while (parser.peek() != JsonToken.END_ARRAY) { + persons.add(parser.nextString()); + } + parser.endArray(); + media.persons = persons; + continue; + case FIELD_IX_COPYRIGHT: + media.copyright = parser.nextString(); + continue; + } + } + throw new IllegalStateException("Unexpected field '"+field+"'"); + } + + parser.endObject(); + + if (media.uri == null) throw new IllegalStateException("Missing field: " + FULL_FIELD_NAME_URI); + if (!haveWidth) throw new IllegalStateException("Missing field: " + FULL_FIELD_NAME_WIDTH); + if (!haveHeight) throw new IllegalStateException("Missing field: " + FULL_FIELD_NAME_HEIGHT); + if (media.format == null) throw new IllegalStateException("Missing field: " + FULL_FIELD_NAME_FORMAT); + if (!haveDuration) throw new IllegalStateException("Missing field: " + FULL_FIELD_NAME_DURATION); + if (!haveSize) throw new IllegalStateException("Missing field: " + FULL_FIELD_NAME_SIZE); + if (media.persons == null) media.persons = new ArrayList(); + if (media.player == null) throw new IllegalStateException("Missing field: " + FULL_FIELD_NAME_PLAYER); + + return media; + } + + private Image readImage(JsonReader parser) throws IOException + { + JsonToken t; + Image image = new Image(); + + boolean haveWidth = false; + boolean haveHeight = false; + + while ((t = parser.peek()) != JsonToken.END_OBJECT) { + if (t != JsonToken.NAME) { + reportIllegal(parser, JsonToken.NAME); + } + String field = parser.nextName(); + Integer I = fullFieldToIndex.get(field); + if (I != null) { + switch (I) { + case FIELD_IX_URI: + image.uri = parser.nextString(); + continue; + case FIELD_IX_TITLE: + image.title = parser.nextString(); + continue; + case FIELD_IX_WIDTH: + image.width = parser.nextInt(); + haveWidth = true; + continue; + case FIELD_IX_HEIGHT: + image.height = parser.nextInt(); + haveHeight = true; + continue; + case FIELD_IX_SIZE: + image.size = Image.Size.valueOf(parser.nextString()); + continue; + } + } + throw new IllegalStateException("Unexpected field '"+field+"'"); + } + parser.endObject(); + + if (image.uri == null) throw new IllegalStateException("Missing field: " + FULL_FIELD_NAME_URI); + if (!haveWidth) throw new IllegalStateException("Missing field: " + FULL_FIELD_NAME_WIDTH); + if (!haveHeight) throw new IllegalStateException("Missing field: " + FULL_FIELD_NAME_HEIGHT); + if (image.size == null) throw new IllegalStateException("Missing field: " + FULL_FIELD_NAME_SIZE); + + return image; + } + + private void reportIllegal(JsonReader parser, JsonToken expToken) + throws IOException + { + JsonToken curr = parser.peek(); + String msg = "Expected token "+expToken+"; got "+curr; + if (curr == JsonToken.NAME) { + msg += " (current field name '"+parser.nextName()+"')"; + } + throw new IllegalStateException(msg); + } + + // // // Write methods + + protected void writeMediaContent(JsonWriter writer, MediaContent content) throws IOException + { + writer.beginObject(); + writeMedia(writer, content.media); + writer.name(FULL_FIELD_NAME_IMAGES); + writer.beginArray(); + for (Image i : content.images) { + writeImage(writer, i); + } + writer.endArray(); + writer.endObject(); + } + + private void writeMedia(JsonWriter writer, Media media) throws IOException + { + writer.name(FULL_FIELD_NAME_MEDIA); + writer.beginObject(); + writeStringField(writer, FULL_FIELD_NAME_PLAYER, media.player.name()); + writeStringField(writer, FULL_FIELD_NAME_URI, media.uri); + if (media.title != null) { + writeStringField(writer, FULL_FIELD_NAME_TITLE, media.title); + } + writeIntField(writer, FULL_FIELD_NAME_WIDTH, media.width); + writeIntField(writer, FULL_FIELD_NAME_HEIGHT, media.height); + writeStringField(writer, FULL_FIELD_NAME_FORMAT, media.format); + writeLongField(writer, FULL_FIELD_NAME_DURATION, media.duration); + writeLongField(writer, FULL_FIELD_NAME_SIZE, media.size); + if (media.hasBitrate) { + writeIntField(writer, FULL_FIELD_NAME_BITRATE, media.bitrate); + } + if (media.copyright != null) { + writeStringField(writer, FULL_FIELD_NAME_COPYRIGHT, media.copyright); + } + writer.name(FULL_FIELD_NAME_PERSONS); + writer.beginArray(); + for (String person : media.persons) { + writer.value(person); + } + writer.endArray(); + writer.endObject(); + } + + private void writeStringField(JsonWriter writer, String field, String value) throws IOException { + writer.name(field); + writer.value(value); + } + + private void writeIntField(JsonWriter writer, String field, int value) throws IOException { + writer.name(field); + writer.value(value); + } + + private void writeLongField(JsonWriter writer, String field, long value) throws IOException { + writer.name(field); + writer.value(value); + } + + private void writeImage(JsonWriter writer, Image image) throws IOException + { + writer.beginObject(); + writeStringField(writer, FULL_FIELD_NAME_URI, image.uri); + if (image.title != null) { + writeStringField(writer, FULL_FIELD_NAME_TITLE, image.title); + } + writeIntField(writer, FULL_FIELD_NAME_WIDTH, image.width); + writeIntField(writer, FULL_FIELD_NAME_HEIGHT, image.height); + writeStringField(writer, FULL_FIELD_NAME_SIZE, image.size.name()); + writer.endObject(); + } + + } +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/json/JsonGsonTree.java b/jvm-serializers-tpc/src/main/java/serializers/json/JsonGsonTree.java new file mode 100644 index 0000000..62fe3a3 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/json/JsonGsonTree.java @@ -0,0 +1,222 @@ +package serializers.json; + +import java.io.StringWriter; +import java.io.Writer; +import java.util.ArrayList; +import java.util.List; + +import serializers.*; + +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import com.google.gson.JsonPrimitive; + +import data.media.Image; +import data.media.Media; +import data.media.MediaContent; + +/** + * Driver that uses Gson for manual tree processing. + */ +public class JsonGsonTree +{ + public static void register(TestGroups groups) + { + groups.media.add(JavaBuiltIn.mediaTransformer, + new SemiManualSerializer("json/gson/manual-tree"), + new SerFeatures( + SerFormat.JSON, + SerGraph.FLAT_TREE, + SerClass.MANUAL_OPT, + "" + ) + ); + } + + static class SemiManualSerializer extends Serializer + { + private final String name; + private final JsonParser parser = new JsonParser(); + + public SemiManualSerializer(String name) + { + this.name = name; + } + + public String getName() + { + return name; + } + + public MediaContent deserialize(byte[] array) throws Exception + { + String mediaContentJsonInput = new String(array, "UTF-8"); + return readMediaContent(parser, mediaContentJsonInput); + } + + public byte[] serialize(MediaContent mediaContent) throws Exception + { + StringWriter writer = new StringWriter(); + writeMediaContent(writer, mediaContent); + writer.flush(); + return writer.toString().getBytes("UTF-8"); + } + + private static Image readImage(JsonParser parser, String imageJsonInput) + { + JsonObject imageJsonObject = parser.parse(imageJsonInput).getAsJsonObject(); + return readImage(imageJsonObject); + } + + private static Image readImage(JsonObject imageJsonObject) + { + Image image = new Image(); + image.height = imageJsonObject.get("height").getAsInt(); + image.size = Image.Size.valueOf(imageJsonObject.get("size").getAsString()); + image.title = imageJsonObject.get("title").getAsString(); + image.uri = imageJsonObject.get("uri").getAsString(); + image.width = imageJsonObject.get("width").getAsInt(); + return image; + } + + private static MediaContent readMediaContent(JsonParser parser, String mediaContentJsonInput) throws Exception + { + JsonObject mediaContentJsonObject = parser.parse(mediaContentJsonInput).getAsJsonObject(); + MediaContent mediaContent = new MediaContent(); + mediaContent.images = readImages(mediaContentJsonObject.get("images").getAsJsonArray()); + mediaContent.media = readMedia(mediaContentJsonObject.get("media").getAsJsonObject()); + return mediaContent; + } + + private static Media readMedia(JsonParser parser, String mediaJsonInput) + { + JsonObject mediaJsonObject = parser.parse(mediaJsonInput).getAsJsonObject(); + return readMedia(mediaJsonObject); + } + + private static Media readMedia(JsonObject mediaJsonObject) + { + Media media = new Media(); + JsonElement bitrate = mediaJsonObject.get("bitrate"); + if (bitrate != null && !bitrate.isJsonNull()) + { + media.bitrate = bitrate.getAsInt(); + media.hasBitrate = true; + } + JsonElement copyright = mediaJsonObject.get("copyright"); + if (copyright != null && !copyright.isJsonNull()) + { + media.copyright = copyright.getAsString(); + } + media.duration = mediaJsonObject.get("duration").getAsLong(); + media.format = mediaJsonObject.get("format").getAsString(); + media.height = mediaJsonObject.get("height").getAsInt(); + media.player = Media.Player.valueOf(mediaJsonObject.get("player").getAsString()); + JsonArray personsJsonArray = mediaJsonObject.get("persons").getAsJsonArray(); + int size = personsJsonArray.size(); + List persons = new ArrayList(size); + for (JsonElement person : personsJsonArray) + { + persons.add(person.getAsString()); + } + media.persons = persons; + media.size = mediaJsonObject.get("size").getAsInt(); + media.title = mediaJsonObject.get("title").getAsString(); + media.uri = mediaJsonObject.get("uri").getAsString(); + media.width = mediaJsonObject.get("width").getAsInt(); + return media; + } + + private static List readImages(JsonParser parser, String imagesJsonInput) throws Exception + { + JsonArray imagesJsonArray = parser.parse(imagesJsonInput).getAsJsonArray(); + return readImages(imagesJsonArray); + } + + private static List readImages(JsonArray imagesJsonArray) + { + int size = imagesJsonArray.size(); + List images = new ArrayList(size); + for (JsonElement image : imagesJsonArray) + { + images.add(readImage(image.getAsJsonObject())); + } + return images; + } + + private static JsonObject createJsonObject(Image image) + { + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("height", image.height); + jsonObject.addProperty("size", image.size.name()); + jsonObject.addProperty("title", image.title); + jsonObject.addProperty("uri", image.uri); + jsonObject.addProperty("width", image.width); + return jsonObject; + } + + private static JsonObject createJsonObject(Media media) + { + JsonObject jsonObject = new JsonObject(); + if (media.hasBitrate) + { + jsonObject.addProperty("bitrate", media.bitrate); + } + jsonObject.addProperty("copyright", media.copyright); + jsonObject.addProperty("duration", media.duration); + jsonObject.addProperty("format", media.format); + jsonObject.addProperty("height", media.height); + int size = media.persons.size(); + JsonArray personsJsonArray = new JsonArray(); + for (int i = 0; i < size; i++) + { + personsJsonArray.add(new JsonPrimitive(media.persons.get(i))); + } + jsonObject.add("persons", personsJsonArray); + jsonObject.addProperty("player", media.player.name()); + jsonObject.addProperty("size", media.size); + jsonObject.addProperty("title", media.title); + jsonObject.addProperty("uri", media.uri); + jsonObject.addProperty("width", media.width); + return jsonObject; + } + + private static void writeMedia(StringWriter writer, Media media) + { + JsonObject jsonObject = createJsonObject(media); + writer.write(jsonObject.toString()); + } + + private static void writeMediaContent(Writer writer, MediaContent mediaContent) throws Exception + { + JsonObject jsonObject = new JsonObject(); + jsonObject.add("media", createJsonObject(mediaContent.media)); + jsonObject.add("images", createJsonArray(mediaContent.images)); + writer.write(jsonObject.toString()); + } + + private static void writeImage(Writer writer, Image image) throws Exception + { + JsonObject jsonObject = createJsonObject(image); + writer.write(jsonObject.toString()); + } + + private static JsonArray createJsonArray(List images) + { + JsonArray jsonArray = new JsonArray(); + for (Image image : images) + { + jsonArray.add(createJsonObject(image)); + } + return jsonArray; + } + + private static void writeImages(Writer writer, List images) throws Exception + { + JsonArray jsonArray = createJsonArray(images); + writer.write(jsonArray.toString()); + } + } +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/json/JsonLibJsonDatabind.java b/jvm-serializers-tpc/src/main/java/serializers/json/JsonLibJsonDatabind.java new file mode 100644 index 0000000..21c99ee --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/json/JsonLibJsonDatabind.java @@ -0,0 +1,116 @@ +package serializers.json; + +import java.io.*; +import java.util.ArrayList; +import java.util.List; + +import serializers.*; + +import data.media.Image; +import data.media.Media; +import data.media.MediaContent; + +/** + * This serializer uses JSON-lib [http://json-lib.sourceforge.net] for JSON data binding. + */ +public class JsonLibJsonDatabind +{ + public static void register(TestGroups groups) + { + groups.media.add(JavaBuiltIn.mediaTransformer, + new GenericSerializer("json/json-lib/databind", MediaContent.class), + new SerFeatures( + SerFormat.JSON, + SerGraph.FLAT_TREE, + SerClass.ZERO_KNOWLEDGE, + "" + ) + ); + } + + static class GenericSerializer extends Serializer + { + private final String name; + private final Class type; + // private final net.sf.ezmorph.MorpherRegistry _morpherRegistry; + private final net.sf.json.JsonConfig _jsonConfig; + + public GenericSerializer(String name, Class clazz) + { + this.name = name; + type = clazz; + + net.sf.ezmorph.MorpherRegistry _morpherRegistry = net.sf.json.util.JSONUtils.getMorpherRegistry(); + _morpherRegistry.registerMorpher(new net.sf.json.util.EnumMorpher(Media.Player.class)); + _morpherRegistry.registerMorpher(new net.sf.json.util.EnumMorpher(Image.Size.class)); + // "preferred" approach with BeanMorpher causes excessive info logging + // net.sf.ezmorph.Morpher imageMorpher = new net.sf.ezmorph.bean.BeanMorpher(Image.class, _morpherRegistry); + // _morpherRegistry.registerMorpher(imageMorpher); + + _jsonConfig = new net.sf.json.JsonConfig(); + _jsonConfig.setRootClass(type); + + // else JSON null is turned into empty string, which fails equality tests + _jsonConfig.registerDefaultValueProcessor(String.class, + new net.sf.json.processors.DefaultValueProcessor() + { + @Override + public Object getDefaultValue(Class type) + { + return net.sf.json.JSONNull.getInstance(); + } + }); + } + + public String getName() + { + return name; + } + + @SuppressWarnings("unchecked") + public T deserialize(byte[] array) throws Exception + { + String jsonInput = new String(array, "UTF-8"); + net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(jsonInput); + T result = (T) net.sf.json.JSONObject.toBean(jsonObject, _jsonConfig); + + // JSON-lib cannot deserialize into a list of a custom type, when the list is a member of something. + // Instead, JSON-lib populates the list with MorphDynaBeans, which can be transformed to the target type. + MediaContent mediaContent = (MediaContent) result; + int size = mediaContent.images.size(); + List replacementImages = new ArrayList (size); + for (int i = 0; i < size; i++) + { + // "preferred" approach with BeanMorpher causes excessive info logging -- TODO: figure out how to config + // Object image = mediaContent.images.get(i); + // replacementImages.add((Image)_morpherRegistry.morph(Image.class, image)); + + // alternate approach, still using JSON-lib components to transform data + Object o = mediaContent.images.get(i); + net.sf.ezmorph.bean.MorphDynaBean image = (net.sf.ezmorph.bean.MorphDynaBean) o; + net.sf.json.JSONObject imageJsonObject = net.sf.json.JSONObject.fromObject(image); + Image replacementImage = (Image) net.sf.json.JSONObject.toBean(imageJsonObject, Image.class); + + // a slightly "manual" approach (?) that is about 10% faster, but isn't it cheating? + //Image replacementImage = new Image(); + //replacementImage.height = (Integer) image.get("height"); + //replacementImage.size = Image.Size.valueOf((String) image.get("size")); + //replacementImage.title = (String) image.get("title"); + //replacementImage.uri = (String) image.get("uri"); + //replacementImage.width = (Integer) image.get("width"); + + replacementImages.add(replacementImage); + } + mediaContent.images = replacementImages; + return result; + } + + public byte[] serialize(T data) throws IOException + { + StringWriter w = new StringWriter(); + net.sf.json.JSONSerializer.toJSON(data, _jsonConfig).write(w); + w.flush(); + return w.toString().getBytes("UTF-8"); + } + } +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/json/JsonPathDeserializerOnly.java b/jvm-serializers-tpc/src/main/java/serializers/json/JsonPathDeserializerOnly.java new file mode 100644 index 0000000..8a40931 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/json/JsonPathDeserializerOnly.java @@ -0,0 +1,235 @@ +package serializers.json; + +import java.io.StringWriter; +import java.io.Writer; +import java.util.ArrayList; +import java.util.List; + +import org.json.simple.JSONArray; +import org.json.simple.JSONObject; + +import serializers.*; + +import com.jayway.jsonpath.JsonPath; + +import data.media.Image; +import data.media.Media; +import data.media.MediaContent; + +/** + * Driver that uses JsonPath [http://code.google.com/p/json-path/], with JSONPath parsing. + * Uses JSON.simple for serialization. + */ +public class JsonPathDeserializerOnly +{ + public static void register(TestGroups groups) + { + groups.media.add(JavaBuiltIn.mediaTransformer, + new SemiManualSerializer("json/jsonpath/manual"), + new SerFeatures( + SerFormat.JSON, + SerGraph.FLAT_TREE, + SerClass.MANUAL_OPT, + "" + ) + ); + } + + static class SemiManualSerializer extends Serializer + { + private final String name; + + public SemiManualSerializer(String name) + { + this.name = name; + } + + public String getName() + { + return name; + } + + public MediaContent deserialize(byte[] array) throws Exception + { + String mediaContentJsonInput = new String(array, "UTF-8"); + return readMediaContent(mediaContentJsonInput); + } + + public byte[] serialize(MediaContent mediaContent) throws Exception + { + StringWriter writer = new StringWriter(); + writeMediaContent(writer, mediaContent); + writer.flush(); + return writer.toString().getBytes("UTF-8"); + } + + @SuppressWarnings("unchecked") + private static JSONObject createJsonObject(Media media) + { + JSONObject jsonObject = new JSONObject(); + if (media.hasBitrate) + { + jsonObject.put("bitrate", media.bitrate); + } + jsonObject.put("copyright", media.copyright); + jsonObject.put("duration", media.duration); + jsonObject.put("format", media.format); + jsonObject.put("height", media.height); + int size = media.persons.size(); + JSONArray personsJsonArray = new JSONArray(); + for (int i = 0; i < size; i++) + { + personsJsonArray.add(media.persons.get(i)); + } + jsonObject.put("persons", personsJsonArray); + jsonObject.put("player", media.player.name()); + jsonObject.put("size", media.size); + jsonObject.put("title", media.title); + jsonObject.put("uri", media.uri); + jsonObject.put("width", media.width); + return jsonObject; + } + + private static void writeMedia(Writer writer, Media media) throws Exception + { + JSONObject jsonObject = createJsonObject(media); + jsonObject.writeJSONString(writer); + } + + @SuppressWarnings("unchecked") + private static JSONObject createJsonObject(Image image) + { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("height", image.height); + jsonObject.put("size", image.size.name()); + jsonObject.put("title", image.title); + jsonObject.put("uri", image.uri); + jsonObject.put("width", image.width); + return jsonObject; + } + + private static void writeImage(Writer writer, Image image) throws Exception + { + JSONObject jsonObject = createJsonObject(image); + jsonObject.writeJSONString(writer); + } + + private static void writeImages(Writer writer, List images) throws Exception + { + JSONArray jsonArray = createJsonArray(images); + jsonArray.writeJSONString(writer); + } + + @SuppressWarnings("unchecked") + private static JSONArray createJsonArray(List images) + { + JSONArray jsonArray = new JSONArray(); + for (Image image : images) + { + jsonArray.add(createJsonObject(image)); + } + return jsonArray; + } + + @SuppressWarnings("unchecked") + static void writeMediaContent(Writer writer, MediaContent mediaContent) throws Exception + { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("media", createJsonObject(mediaContent.media)); + jsonObject.put("images", createJsonArray(mediaContent.images)); + jsonObject.writeJSONString(writer); + } + + private static Media readMedia(String mediaJsonInput) throws Exception + { + Media media = new Media(); + Object bitrate = JsonPath.read(mediaJsonInput, "$.bitrate"); + if (bitrate != null && bitrate instanceof Long) + { + media.bitrate = ((Long) bitrate).intValue(); + media.hasBitrate = true; + } + media.copyright = JsonPath.read(mediaJsonInput, "$.copyright"); + media.duration = (Long) JsonPath.read(mediaJsonInput, "$.duration"); + media.format = JsonPath.read(mediaJsonInput, "$.format"); + media.height = ((Long) JsonPath.read(mediaJsonInput, "$.height")).intValue(); + List persons = JsonPath.read(mediaJsonInput, "$.persons[*]"); + media.persons = persons; + media.player = Media.Player.valueOf((String) JsonPath.read(mediaJsonInput, "$.player")); + media.size = (Long) JsonPath.read(mediaJsonInput, "$.size"); + media.title = JsonPath.read(mediaJsonInput, "$.title"); + media.uri = JsonPath.read(mediaJsonInput, "$.uri"); + media.width = ((Long) JsonPath.read(mediaJsonInput, "$.width")).intValue(); + return media; + } + + private static Image readImage(String imageJsonInput) throws Exception + { + Image image = new Image(); + image.height = ((Long) JsonPath.read(imageJsonInput, "$.height")).intValue(); + image.size = Image.Size.valueOf((String) JsonPath.read(imageJsonInput, "$.size")); + image.title = JsonPath.read(imageJsonInput, "$.title"); + image.uri = JsonPath.read(imageJsonInput, "$.uri"); + image.width = ((Long) JsonPath.read(imageJsonInput, "$.width")).intValue(); + return image; + } + + private static Image readImage(JSONObject jsonObject) + { + Image image = new Image(); + image.height = ((Long) JsonPath.read(jsonObject, "$.height")).intValue(); + image.size = Image.Size.valueOf((String) JsonPath.read(jsonObject, "$.size")); + image.title = JsonPath.read(jsonObject, "$.title"); + image.uri = JsonPath.read(jsonObject, "$.uri"); + image.width = ((Long) JsonPath.read(jsonObject, "$.width")).intValue(); + return image; + } + + private static List readImages(String imagesJsonInput) throws Exception + { + JSONArray imagesJsonArray = (JSONArray) JsonPath.read(imagesJsonInput, "$[*]"); + return readImages(imagesJsonArray); + } + + private static List readImages(JSONArray imagesJsonArray) throws Exception + { + int size = imagesJsonArray.size(); + List images = new ArrayList(size); + for (int i = 0; i < size; i++) + { + images.add(readImage((JSONObject) imagesJsonArray.get(i))); + } + return images; + } + + private static MediaContent readMediaContent(String mediaContentJsonInput) throws Exception + { + MediaContent mediaContent = new MediaContent(); + Media media = new Media(); + Object bitrate = JsonPath.read(mediaContentJsonInput, "$.media.bitrate"); + if (bitrate != null && bitrate instanceof Long) + { + media.bitrate = ((Long) bitrate).intValue(); + media.hasBitrate = true; + } + media.copyright = JsonPath.read(mediaContentJsonInput, "$.media.copyright"); + media.duration = (Long) JsonPath.read(mediaContentJsonInput, "$.media.duration"); + media.format = JsonPath.read(mediaContentJsonInput, "$.media.format"); + media.height = ((Long) JsonPath.read(mediaContentJsonInput, "$.media.height")).intValue(); + List persons = JsonPath.read(mediaContentJsonInput, "$.media.persons[*]"); + media.persons = persons; + media.player = Media.Player.valueOf((String) JsonPath.read(mediaContentJsonInput, "$.media.player")); + media.size = (Long) JsonPath.read(mediaContentJsonInput, "$.media.size"); + media.title = JsonPath.read(mediaContentJsonInput, "$.media.title"); + media.uri = JsonPath.read(mediaContentJsonInput, "$.media.uri"); + media.width = ((Long) JsonPath.read(mediaContentJsonInput, "$.media.width")).intValue(); + + JSONArray imagesJsonArray = (JSONArray) JsonPath.read(mediaContentJsonInput, "$.images[*]"); + List images = readImages(imagesJsonArray); + + mediaContent.media = media; + mediaContent.images = images; + return mediaContent; + } + } +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/json/JsonSimpleManualTree.java b/jvm-serializers-tpc/src/main/java/serializers/json/JsonSimpleManualTree.java new file mode 100644 index 0000000..5471d14 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/json/JsonSimpleManualTree.java @@ -0,0 +1,222 @@ +package serializers.json; + +import java.io.IOException; +import java.io.StringWriter; +import java.io.Writer; +import java.util.ArrayList; +import java.util.List; + +import org.json.simple.JSONArray; +import org.json.simple.JSONObject; +import org.json.simple.parser.JSONParser; + +import serializers.*; + +import data.media.Image; +import data.media.Media; +import data.media.MediaContent; + +/** + * Driver that uses JSON.simple [http://code.google.com/p/json-simple/], with manual tree parsing. + */ +public class JsonSimpleManualTree +{ + public static void register(TestGroups groups) + { + groups.media.add(JavaBuiltIn.mediaTransformer, + new ManualTreeSerializer("json/json.simple/manual-tree"), + new SerFeatures( + SerFormat.JSON, + SerGraph.FLAT_TREE, + SerClass.MANUAL_OPT, + "fst in unshared mode with preregistered classes" + ) + ); + + } + + static class ManualTreeSerializer extends Serializer + { + private final String name; + private final JSONParser parser; + + public ManualTreeSerializer(String name) + { + this.name = name; + parser = new JSONParser(); + } + + public String getName() + { + return name; + } + + public MediaContent deserialize(byte[] array) throws Exception + { + String mediaContentJsonInput = new String(array, "UTF-8"); + return readMediaContent(parser, mediaContentJsonInput); + } + + public byte[] serialize(MediaContent mediaContent) throws IOException + { + StringWriter writer = new StringWriter(); + writeMediaContent(writer, mediaContent); + writer.flush(); + return writer.toString().getBytes("UTF-8"); + } + + static Media readMedia(JSONParser parser, String mediaJsonInput) throws Exception + { + JSONObject mediaJsonObject = (JSONObject) parser.parse(mediaJsonInput); + return readMedia(parser, mediaJsonObject); + } + + static Media readMedia(JSONParser parser, JSONObject mediaJsonObject) throws Exception + { + Media media = new Media(); + Object bitrate = mediaJsonObject.get("bitrate"); + if (bitrate != null && bitrate instanceof Long) + { + media.bitrate = ((Long) bitrate).intValue(); + media.hasBitrate = true; + } + media.copyright = (String) mediaJsonObject.get("copyright"); + media.duration = ((Long) mediaJsonObject.get("duration")).longValue(); + media.format = (String) mediaJsonObject.get("format"); + media.height = ((Long) mediaJsonObject.get("height")).intValue(); + List persons = new ArrayList(); + JSONArray personsJsonArray = (JSONArray) mediaJsonObject.get("persons"); + for (int i = 0, size = personsJsonArray.size(); i < size; i++) + { + persons.add((String) personsJsonArray.get(i)); + } + media.persons = persons; + media.player = Media.Player.valueOf((String) mediaJsonObject.get("player")); + media.size = ((Long) mediaJsonObject.get("size")).longValue(); + media.title = (String) mediaJsonObject.get("title"); + media.uri = (String) mediaJsonObject.get("uri"); + media.width = ((Long) mediaJsonObject.get("width")).intValue(); + return media; + } + + static MediaContent readMediaContent(JSONParser parser, String mediaContentJsonInput) throws Exception + { + JSONObject mediaContentJsonObject = (JSONObject) parser.parse(mediaContentJsonInput); + MediaContent mediaContent = new MediaContent(); + mediaContent.images = readImages(parser, (JSONArray) mediaContentJsonObject.get("images")); + mediaContent.media = readMedia(parser, (JSONObject) mediaContentJsonObject.get("media")); + return mediaContent; + } + + static Image readImage(JSONParser parser, String imageJsonInput) throws Exception + { + JSONObject imageJsonObject = (JSONObject) parser.parse(imageJsonInput); + return readImage(parser, imageJsonObject); + } + + static Image readImage(JSONParser parser, JSONObject imageJsonObject) throws Exception + { + Image image = new Image(); + image.height = ((Long) imageJsonObject.get("height")).intValue(); + image.size = Image.Size.valueOf((String) imageJsonObject.get("size")); + image.title = (String) imageJsonObject.get("title"); + image.uri = (String) imageJsonObject.get("uri"); + image.width = ((Long) imageJsonObject.get("width")).intValue(); + return image; + } + + static List readImages(JSONParser parser, String imagesJsonInput) throws Exception + { + JSONArray imagesJsonArray = (JSONArray) parser.parse(imagesJsonInput); + return readImages(parser, imagesJsonArray); + } + + static List readImages(JSONParser parser, JSONArray imagesJsonArray) throws Exception + { + int size = imagesJsonArray.size(); + List images = new ArrayList(size); + for (int i = 0; i < size; i++) + { + images.add(readImage(parser, (JSONObject) imagesJsonArray.get(i))); + } + return images; + } + + @SuppressWarnings("unchecked") + static JSONObject createJsonObject(Media media) + { + JSONObject jsonObject = new JSONObject(); + if (media.hasBitrate) + { + jsonObject.put("bitrate", media.bitrate); + } + jsonObject.put("copyright", media.copyright); + jsonObject.put("duration", media.duration); + jsonObject.put("format", media.format); + jsonObject.put("height", media.height); + int size = media.persons.size(); + JSONArray personsJsonArray = new JSONArray(); + for (int i = 0; i < size; i++) + { + personsJsonArray.add(media.persons.get(i)); + } + jsonObject.put("persons", personsJsonArray); + jsonObject.put("player", media.player.name()); + jsonObject.put("size", media.size); + jsonObject.put("title", media.title); + jsonObject.put("uri", media.uri); + jsonObject.put("width", media.width); + return jsonObject; + } + + static void writeMedia(Writer writer, Media media) throws Exception + { + JSONObject jsonObject = createJsonObject(media); + jsonObject.writeJSONString(writer); + } + + static void writeImage(Writer writer, Image image) throws Exception + { + JSONObject jsonObject = createJsonObject(image); + jsonObject.writeJSONString(writer); + } + + @SuppressWarnings("unchecked") + static JSONObject createJsonObject(Image image) + { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("height", image.height); + jsonObject.put("size", image.size.name()); + jsonObject.put("title", image.title); + jsonObject.put("uri", image.uri); + jsonObject.put("width", image.width); + return jsonObject; + } + + @SuppressWarnings("unchecked") + static void writeMediaContent(Writer writer, MediaContent mediaContent) throws IOException + { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("media", createJsonObject(mediaContent.media)); + jsonObject.put("images", createJsonArray(mediaContent.images)); + jsonObject.writeJSONString(writer); + } + + @SuppressWarnings("unchecked") + static JSONArray createJsonArray(List images) + { + JSONArray jsonArray = new JSONArray(); + for (Image image : images) + { + jsonArray.add(createJsonObject(image)); + } + return jsonArray; + } + + static void writeImages(Writer writer, List images) throws Exception + { + JSONArray jsonArray = createJsonArray(images); + jsonArray.writeJSONString(writer); + } + } +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/json/JsonSimpleWithContentHandler.java b/jvm-serializers-tpc/src/main/java/serializers/json/JsonSimpleWithContentHandler.java new file mode 100644 index 0000000..c785a09 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/json/JsonSimpleWithContentHandler.java @@ -0,0 +1,313 @@ +package serializers.json; + +import java.io.IOException; +import java.io.StringWriter; +import java.io.Writer; +import java.util.ArrayList; +import java.util.List; + +import org.json.simple.JSONArray; +import org.json.simple.JSONObject; +import org.json.simple.parser.ContentHandler; +import org.json.simple.parser.JSONParser; +import org.json.simple.parser.ParseException; + +import serializers.*; + +import data.media.Image; +import data.media.Media; +import data.media.MediaContent; + +/** + * Driver that uses JSON.simple [http://code.google.com/p/json-simple/], with manual parsing with a ContentHandler. + */ +public class JsonSimpleWithContentHandler +{ + public static void register(TestGroups groups) + { + groups.media.add(JavaBuiltIn.mediaTransformer, + new SemiManualSerializer("json/json.simple/manual"), + new SerFeatures( + SerFormat.JSON, + SerGraph.FLAT_TREE, + SerClass.MANUAL_OPT, + "" + ) + ); + } + + static class SemiManualSerializer extends Serializer + { + private final String name; + private final JSONParser parser; + private final MediaContentTransformer transformer; + + public SemiManualSerializer(String name) + { + this.name = name; + this.parser = new JSONParser(); + this.transformer = new MediaContentTransformer(); + } + + public String getName() + { + return name; + } + + public MediaContent deserialize(byte[] array) throws Exception + { + String mediaContentJsonInput = new String(array, "UTF-8"); + return readMediaContent(parser, transformer, mediaContentJsonInput); + } + + public byte[] serialize(MediaContent mediaContent) throws Exception + { + StringWriter writer = new StringWriter(); + writeMediaContent(writer, mediaContent); + writer.flush(); + return writer.toString().getBytes("UTF-8"); + } + + private static MediaContent readMediaContent(JSONParser parser, MediaContentTransformer transformer, String mediaContentJsonInput) throws Exception + { + parser.parse(mediaContentJsonInput, transformer); + return transformer.getResult(); + } + + @SuppressWarnings("unchecked") + private static JSONObject createJsonObject(Media media) + { + JSONObject jsonObject = new JSONObject(); + if (media.hasBitrate) + { + jsonObject.put("bitrate", media.bitrate); + } + jsonObject.put("copyright", media.copyright); + jsonObject.put("duration", media.duration); + jsonObject.put("format", media.format); + jsonObject.put("height", media.height); + int size = media.persons.size(); + JSONArray personsJsonArray = new JSONArray(); + for (int i = 0; i < size; i++) + { + personsJsonArray.add(media.persons.get(i)); + } + jsonObject.put("persons", personsJsonArray); + jsonObject.put("player", media.player.name()); + jsonObject.put("size", media.size); + jsonObject.put("title", media.title); + jsonObject.put("uri", media.uri); + jsonObject.put("width", media.width); + return jsonObject; + } + + @SuppressWarnings("unchecked") + private static JSONObject createJsonObject(Image image) + { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("height", image.height); + jsonObject.put("size", image.size.name()); + jsonObject.put("title", image.title); + jsonObject.put("uri", image.uri); + jsonObject.put("width", image.width); + return jsonObject; + } + + @SuppressWarnings("unchecked") + private static void writeMediaContent(Writer writer, MediaContent mediaContent) throws Exception + { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("media", createJsonObject(mediaContent.media)); + jsonObject.put("images", createJsonArray(mediaContent.images)); + jsonObject.writeJSONString(writer); + } + + @SuppressWarnings("unchecked") + private static JSONArray createJsonArray(List images) + { + JSONArray jsonArray = new JSONArray(); + for (Image image : images) + { + jsonArray.add(createJsonObject(image)); + } + return jsonArray; + } + + private static class MediaContentTransformer implements ContentHandler + { + private static enum State + { + INIT, READING_MEDIA_CONTENT, FINAL, + READING_MEDIA, + READING_MEDIA_URI, READING_MEDIA_TITLE, READING_MEDIA_WIDTH, READING_MEDIA_HEIGHT, READING_MEDIA_FORMAT, + READING_MEDIA_DURATION, READING_MEDIA_SIZE, READING_MEDIA_BITRATE, + READING_MEDIA_PERSONS, READING_MEDIA_PERSON, + READING_MEDIA_PLAYER, READING_MEDIA_COPYRIGHT, + FINISHED_MEDIA, + READING_IMAGES, FINISHED_IMAGES, + READING_IMAGE, + READING_IMAGE_URI, READING_IMAGE_TITLE, READING_IMAGE_WIDTH, READING_IMAGE_HEIGHT, READING_IMAGE_SIZE, + FINISHED_IMAGE + } + + private State state; + private final MediaContent mediaContent = new MediaContent(); + private Image image; + + public MediaContent getResult() + { + return mediaContent; + } + + @Override + public void startJSON() throws ParseException, IOException + { + state = State.INIT; + } + + @Override + public void endJSON() throws ParseException, IOException + { + throw new RuntimeException("unexpected state transition"); + } + + @Override + public boolean startObject() throws ParseException, IOException + { + switch (state) + { + case INIT: state = State.READING_MEDIA_CONTENT; return true; + case READING_MEDIA: mediaContent.media = new Media(); return true; + case READING_IMAGE: + case FINISHED_IMAGE: image = new Image(); mediaContent.images.add(image); state = State.READING_IMAGE; return true; + default: throw new RuntimeException("unexpected state transition"); + } + } + + @Override + public boolean endObject() throws ParseException, IOException + { + switch (state) + { + case READING_MEDIA: state = State.FINISHED_MEDIA; return true; + case READING_IMAGE: image = null; state = State.FINISHED_IMAGE; return true; + case FINISHED_MEDIA: + case FINISHED_IMAGES: state = State.FINAL; return false; + default: throw new RuntimeException("unexpected state transition"); + } + } + + @Override + public boolean startObjectEntry(String key) throws ParseException, IOException + { + switch (state) + { + case READING_MEDIA_CONTENT: + case FINISHED_IMAGES: + if ("media".equals(key)) {state = State.READING_MEDIA; return true;} + case FINISHED_MEDIA: + if ("images".equals(key)) {state = State.READING_IMAGES; return true;} + throw new RuntimeException("unexpected state transition"); + case READING_MEDIA: + if ("uri".equals(key)) {state = State.READING_MEDIA_URI; return true;} + if ("title".equals(key)) {state = State.READING_MEDIA_TITLE; return true;} + if ("width".equals(key)) {state = State.READING_MEDIA_WIDTH; return true;} + if ("height".equals(key)) {state = State.READING_MEDIA_HEIGHT; return true;} + if ("format".equals(key)) {state = State.READING_MEDIA_FORMAT; return true;} + if ("duration".equals(key)) {state = State.READING_MEDIA_DURATION; return true;} + if ("size".equals(key)) {state = State.READING_MEDIA_SIZE; return true;} + if ("bitrate".equals(key)) {state = State.READING_MEDIA_BITRATE; return true;} + if ("persons".equals(key)) {state = State.READING_MEDIA_PERSONS; return true;} + if ("player".equals(key)) {state = State.READING_MEDIA_PLAYER; return true;} + if ("copyright".equals(key)) {state = State.READING_MEDIA_COPYRIGHT; return true;} + throw new RuntimeException("unexpected state transition"); + case READING_IMAGE: + if ("uri".equals(key)) {state = State.READING_IMAGE_URI; return true;} + if ("title".equals(key)) {state = State.READING_IMAGE_TITLE; return true;} + if ("width".equals(key)) {state = State.READING_IMAGE_WIDTH; return true;} + if ("height".equals(key)) {state = State.READING_IMAGE_HEIGHT; return true;} + if ("size".equals(key)) {state = State.READING_IMAGE_SIZE; return true;} + default: throw new RuntimeException("unexpected state transition"); + } + } + + @Override + public boolean endObjectEntry() throws ParseException, IOException + { + switch (state) + { + case READING_MEDIA: return true; + case FINISHED_MEDIA: return true; + case READING_IMAGE: return true; + case FINISHED_IMAGES: return true; + default: throw new RuntimeException("unexpected state transition"); + } + } + + @Override + public boolean startArray() throws ParseException, IOException + { + switch (state) + { + case READING_MEDIA_PERSONS: mediaContent.media.persons = new ArrayList(); state = State.READING_MEDIA_PERSON; return true; + case READING_IMAGES: mediaContent.images = new ArrayList(); state = State.READING_IMAGE; return true; + default: throw new RuntimeException("unexpected state transition"); + } + } + + @Override + public boolean endArray() throws ParseException, IOException + { + switch (state) + { + case READING_MEDIA_PERSON: state = State.READING_MEDIA; return true; + case FINISHED_IMAGE: state = State.FINISHED_IMAGES; return true; + default: throw new RuntimeException("unexpected state transition"); + } + } + + @Override + public boolean primitive(Object value) throws ParseException, IOException + { + switch (state) + { + case READING_MEDIA_URI: mediaContent.media.uri = readString(value); state = State.READING_MEDIA; return true; + case READING_MEDIA_TITLE: mediaContent.media.title = readString(value); state = State.READING_MEDIA; return true; + case READING_MEDIA_WIDTH: mediaContent.media.width = readInt(value); state = State.READING_MEDIA; return true; + case READING_MEDIA_HEIGHT: mediaContent.media.height = readInt(value); state = State.READING_MEDIA; return true; + case READING_MEDIA_FORMAT: mediaContent.media.format = readString(value); state = State.READING_MEDIA; return true; + case READING_MEDIA_DURATION: mediaContent.media.duration = readLong(value); state = State.READING_MEDIA; return true; + case READING_MEDIA_SIZE: mediaContent.media.size = readLong(value); state = State.READING_MEDIA; return true; + case READING_MEDIA_BITRATE: mediaContent.media.bitrate = readInt(value); mediaContent.media.hasBitrate = value != null; state = State.READING_MEDIA; return true; + case READING_MEDIA_PERSON: mediaContent.media.persons.add(readString(value)); return true; + case READING_MEDIA_PLAYER: mediaContent.media.player = Media.Player.valueOf(readString(value)); state = State.READING_MEDIA; return true; + case READING_MEDIA_COPYRIGHT: mediaContent.media.copyright = readString(value); state = State.READING_MEDIA; return true; + case READING_IMAGE_URI: image.uri = readString(value); state = State.READING_IMAGE; return true; + case READING_IMAGE_TITLE: image.title = readString(value); state = State.READING_IMAGE; return true; + case READING_IMAGE_WIDTH: image.width = readInt(value); state = State.READING_IMAGE; return true; + case READING_IMAGE_HEIGHT: image.height = readInt(value); state = State.READING_IMAGE; return true; + case READING_IMAGE_SIZE: image.size = Image.Size.valueOf(readString(value)); state = State.READING_IMAGE; return true; + default: throw new RuntimeException("unexpected state transition"); + } + } + + private static int readInt(Object value) + { + if (value == null) return 0; + return ((Long) value).intValue(); + } + + private static long readLong(Object value) + { + if (value == null) return 0; + return ((Long) value).longValue(); + } + + private static String readString(Object value) + { + if (value == null) return null; + return (String) value; + } + } + } +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/json/JsonSmartManualTree.java b/jvm-serializers-tpc/src/main/java/serializers/json/JsonSmartManualTree.java new file mode 100644 index 0000000..d0df187 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/json/JsonSmartManualTree.java @@ -0,0 +1,217 @@ +package serializers.json; + +import java.io.IOException; +import java.io.StringWriter; +import java.io.Writer; +import java.util.ArrayList; +import java.util.List; + +import serializers.*; + +import net.minidev.json.JSONArray; +import net.minidev.json.JSONObject; +import net.minidev.json.parser.JSONParser; + +import data.media.Image; +import data.media.Media; +import data.media.MediaContent; + +/** + * Driver that uses json-smart [http://code.google.com/p/json-smart/], with manual tree parsing. + */ +public class JsonSmartManualTree +{ + public static void register(TestGroups groups) + { + groups.media.add(JavaBuiltIn.mediaTransformer, + new ManualTreeSerializer("json/json-smart/manual-tree"), + new SerFeatures( + SerFormat.JSON, + SerGraph.FLAT_TREE, + SerClass.MANUAL_OPT, + "" + ) + ); + } + + static class ManualTreeSerializer extends Serializer + { + private final String name; + private final JSONParser parser; + + public ManualTreeSerializer(String name) + { + this.name = name; + parser = new JSONParser(JSONParser.MODE_RFC4627); + } + + public String getName() + { + return name; + } + + public MediaContent deserialize(byte[] array) throws Exception + { + String mediaContentJsonInput = new String(array, "UTF-8"); + return readMediaContent(parser, mediaContentJsonInput); + } + + public byte[] serialize(MediaContent mediaContent) throws IOException + { + StringWriter writer = new StringWriter(); + writeMediaContent(writer, mediaContent); + writer.flush(); + return writer.toString().getBytes("UTF-8"); + } + + static Media readMedia(JSONParser parser, String mediaJsonInput) throws Exception + { + JSONObject mediaJsonObject = (JSONObject) parser.parse(mediaJsonInput); + return readMedia(parser, mediaJsonObject); + } + + static Media readMedia(JSONParser parser, JSONObject mediaJsonObject) throws Exception + { + Media media = new Media(); + Object bitrate = mediaJsonObject.get("bitrate"); + if (bitrate != null && bitrate instanceof Integer) + { + media.bitrate = ((Integer) bitrate).intValue(); + media.hasBitrate = true; + } + media.copyright = (String) mediaJsonObject.get("copyright"); + media.duration = ((Integer) mediaJsonObject.get("duration")).longValue(); + media.format = (String) mediaJsonObject.get("format"); + media.height = ((Integer) mediaJsonObject.get("height")).intValue(); + List persons = new ArrayList(); + JSONArray personsJsonArray = (JSONArray) mediaJsonObject.get("persons"); + for (int i = 0, size = personsJsonArray.size(); i < size; i++) + { + persons.add((String) personsJsonArray.get(i)); + } + media.persons = persons; + media.player = Media.Player.valueOf((String) mediaJsonObject.get("player")); + media.size = ((Integer) mediaJsonObject.get("size")).longValue(); + media.title = (String) mediaJsonObject.get("title"); + media.uri = (String) mediaJsonObject.get("uri"); + media.width = ((Integer) mediaJsonObject.get("width")).intValue(); + return media; + } + + static MediaContent readMediaContent(JSONParser parser, String mediaContentJsonInput) throws Exception + { + JSONObject mediaContentJsonObject = (JSONObject) parser.parse(mediaContentJsonInput); + MediaContent mediaContent = new MediaContent(); + mediaContent.images = readImages(parser, (JSONArray) mediaContentJsonObject.get("images")); + mediaContent.media = readMedia(parser, (JSONObject) mediaContentJsonObject.get("media")); + return mediaContent; + } + + static Image readImage(JSONParser parser, String imageJsonInput) throws Exception + { + JSONObject imageJsonObject = (JSONObject) parser.parse(imageJsonInput); + return readImage(parser, imageJsonObject); + } + + static Image readImage(JSONParser parser, JSONObject imageJsonObject) throws Exception + { + Image image = new Image(); + image.height = ((Integer) imageJsonObject.get("height")).intValue(); + image.size = Image.Size.valueOf((String) imageJsonObject.get("size")); + image.title = (String) imageJsonObject.get("title"); + image.uri = (String) imageJsonObject.get("uri"); + image.width = ((Integer) imageJsonObject.get("width")).intValue(); + return image; + } + + static List readImages(JSONParser parser, String imagesJsonInput) throws Exception + { + JSONArray imagesJsonArray = (JSONArray) parser.parse(imagesJsonInput); + return readImages(parser, imagesJsonArray); + } + + static List readImages(JSONParser parser, JSONArray imagesJsonArray) throws Exception + { + int size = imagesJsonArray.size(); + List images = new ArrayList (size); + for (int i = 0; i < size; i++) + { + images.add(readImage(parser, (JSONObject) imagesJsonArray.get(i))); + } + return images; + } + + static JSONObject createJsonObject(Media media) + { + JSONObject jsonObject = new JSONObject(); + if (media.hasBitrate) + { + jsonObject.put("bitrate", media.bitrate); + } + jsonObject.put("copyright", media.copyright); + jsonObject.put("duration", media.duration); + jsonObject.put("format", media.format); + jsonObject.put("height", media.height); + int size = media.persons.size(); + JSONArray personsJsonArray = new JSONArray(); + for (int i = 0; i < size; i++) + { + personsJsonArray.add(media.persons.get(i)); + } + jsonObject.put("persons", personsJsonArray); + jsonObject.put("player", media.player.name()); + jsonObject.put("size", media.size); + jsonObject.put("title", media.title); + jsonObject.put("uri", media.uri); + jsonObject.put("width", media.width); + return jsonObject; + } + + static void writeMedia(Writer writer, Media media) throws Exception + { + JSONObject jsonObject = createJsonObject(media); + jsonObject.writeJSONString(writer); + } + + static void writeImage(Writer writer, Image image) throws Exception + { + JSONObject jsonObject = createJsonObject(image); + jsonObject.writeJSONString(writer); + } + + static JSONObject createJsonObject(Image image) + { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("height", image.height); + jsonObject.put("size", image.size.name()); + jsonObject.put("title", image.title); + jsonObject.put("uri", image.uri); + jsonObject.put("width", image.width); + return jsonObject; + } + + static void writeMediaContent(Writer writer, MediaContent mediaContent) throws IOException + { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("media", createJsonObject(mediaContent.media)); + jsonObject.put("images", createJsonArray(mediaContent.images)); + jsonObject.writeJSONString(writer); + } + + static JSONArray createJsonArray(List images) + { + JSONArray jsonArray = new JSONArray(); + for (Image image : images) + { + jsonArray.add(createJsonObject(image)); + } + return jsonArray; + } + + static void writeImages(Writer writer, List images) throws Exception + { + JSONArray jsonArray = createJsonArray(images); + jsonArray.writeJSONString(writer); + } + } +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/json/JsonSvensonDatabind.java b/jvm-serializers-tpc/src/main/java/serializers/json/JsonSvensonDatabind.java new file mode 100644 index 0000000..89cb5e9 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/json/JsonSvensonDatabind.java @@ -0,0 +1,64 @@ +package serializers.json; + +import java.io.*; + +import serializers.*; + +import data.media.Image; +import data.media.MediaContent; + +/** + * This serializer uses svenson for JSON data binding. + */ +public class JsonSvensonDatabind +{ + public static void register(TestGroups groups) + { + groups.media.add(JavaBuiltIn.mediaTransformer, + new GenericSerializer("json/svenson/databind", MediaContent.class), + new SerFeatures( + SerFormat.JSON, + SerGraph.FLAT_TREE, + SerClass.MANUAL_OPT, + "" + ) + ); + } + + static class GenericSerializer extends Serializer + { + private final org.svenson.JSONParser _jsonParser; + private final org.svenson.JSON _jsonWriter; + private final String name; + private final Class type; + + public GenericSerializer(String name, Class clazz) + { + this.name = name; + type = clazz; + + _jsonParser = org.svenson.JSONParser.defaultJSONParser(); + _jsonParser.addTypeHint(".images[]", Image.class); + _jsonWriter = org.svenson.JSON.defaultJSON(); + } + + @Override + public String getName() + { + return name; + } + + @Override + public T deserialize(byte[] array) throws Exception + { + return _jsonParser.parse(type, new String(array, "UTF-8")); + } + + @Override + public byte[] serialize(T data) throws IOException + { + String result = _jsonWriter.forValue(data); + return result.getBytes(); + } + } +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/json/JsonTwoLattes.java b/jvm-serializers-tpc/src/main/java/serializers/json/JsonTwoLattes.java new file mode 100644 index 0000000..7e72409 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/json/JsonTwoLattes.java @@ -0,0 +1,50 @@ +package serializers.json; + +import java.io.*; +import java.nio.charset.Charset; + +import serializers.Serializer; +import serializers.TestGroups; + +import com.twolattes.json.Json; +import com.twolattes.json.Marshaller; +import com.twolattes.json.TwoLattes; + +public class JsonTwoLattes +{ + public static void register(TestGroups groups) + { + // TODO: Need classes with @Entity and @Value annotations. + //groups.media.add(JavaBuiltIn.MediaTransformer, new GenericSerializer(MediaContent.class)); + } + + // ------------------------------------------------------------ + // Serializer (just one class) + + public static final class GenericSerializer extends Serializer + { + public String getName() { return "json/twolattes/databind"; } + + private final Marshaller _marshaller; + private final Charset _charset = Charset.forName("UTF-8"); + + public GenericSerializer(Class clazz) + { + _marshaller = TwoLattes.createMarshaller(clazz); + } + + + public T deserialize(byte[] array) throws Exception { + String str = new String(array, _charset.toString()); + return _marshaller.unmarshall((Json.Object) Json.read( + new StringReader(str))); + } + + public byte[] serialize(T content) throws Exception { + StringWriter sw = new StringWriter(); + _marshaller.marshall(content).write(sw); + sw.flush(); + return sw.toString().getBytes(_charset.toString()); + } + } +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/json/JsonijJpath.java b/jvm-serializers-tpc/src/main/java/serializers/json/JsonijJpath.java new file mode 100644 index 0000000..5b2058b --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/json/JsonijJpath.java @@ -0,0 +1,215 @@ +package serializers.json; + +import java.io.IOException; +import java.io.StringWriter; +import java.util.ArrayList; +import java.util.List; + +import serializers.*; + +import jsonij.json.JPath; +import jsonij.json.JSON; +import jsonij.json.JSONMarshaler; +import jsonij.json.JSONParser; +import jsonij.json.Value; +import jsonij.json.JSON.Array; +import data.media.Image; +import data.media.Media; +import data.media.MediaContent; + +/** + * Driver that uses JSONiJ [http://projects.plural.cc/projects/jsonij], with JPath parsing. + */ +public class JsonijJpath +{ + public static void register(TestGroups groups) + { + groups.media.add(JavaBuiltIn.mediaTransformer, + new SemiManualSerializer("json/jsonij/manual-jpath"), + new SerFeatures( + SerFormat.JSON, + SerGraph.FLAT_TREE, + SerClass.MANUAL_OPT, + "" + ) + ); + } + + static class SemiManualSerializer extends Serializer + { + private final String name; + + public SemiManualSerializer(String name) + { + this.name = name; + } + + public String getName() + { + return name; + } + + public MediaContent deserialize(byte[] array) throws Exception + { + String mediaContentJsonInput = new String(array, "UTF-8"); + return readMediaContent(mediaContentJsonInput); + } + + public byte[] serialize(MediaContent mediaContent) throws IOException + { + StringWriter writer = new StringWriter(); + writeMediaContent(writer, mediaContent); + writer.flush(); + return writer.toString().getBytes("UTF-8"); + } + + @SuppressWarnings({ "unchecked" }) + static MediaContent readMediaContent(String mediaContentJsonInput) throws Exception + { + MediaContent mediaContent = new MediaContent(); + JSON json = JSON.parse(mediaContentJsonInput); + + Media media = new Media(); + Value bitrate = JPath.parse("/media/bitrate").evaluate(json); + if (bitrate != null && !bitrate.isNull()) + { + media.bitrate = bitrate.getInt(); + media.hasBitrate = true; + } + Value copyright = JPath.parse("/media/copyright").evaluate(json); + if (copyright != null && !copyright.isNull()) + { + media.copyright = copyright.getString(); + } + media.duration = JPath.parse("/media/duration").evaluate(json).getNumber().longValue(); + media.format = JPath.parse("/media/format").evaluate(json).getString(); + media.height = JPath.parse("/media/height").evaluate(json).getInt(); + JSON.Array personValues = (JSON.Array) JPath.parse("/media/persons").evaluate(json); + int size = personValues.size(); + List persons = new ArrayList(size); + for (int i = 0; i < size; i++) + { + persons.add(personValues.get(i).getString()); + } + media.persons = persons; + media.player = Media.Player.valueOf(JPath.parse("/media/player").evaluate(json).getString()); + media.size = JPath.parse("/media/size").evaluate(json).getNumber().longValue(); + media.title = JPath.parse("/media/title").evaluate(json).getString(); + media.uri = JPath.parse("/media/uri").evaluate(json).getString(); + media.width = JPath.parse("/media/width").evaluate(json).getInt(); + + JSON.Array imageValues = (JSON.Array) JPath.parse("/images").evaluate(json); + List images = readImages(imageValues); + + mediaContent.media = media; + mediaContent.images = images; + return mediaContent; + } + + @SuppressWarnings({ "unchecked" }) + static List readImages(String imagesJsonInput) throws Exception + { + JSONParser parser = new JSONParser(); + JSON.Array imageValues = (JSON.Array) parser.parse(imagesJsonInput); + return readImages(imageValues); + } + + @SuppressWarnings("rawtypes") + static List readImages(Array imageValues) throws Exception + { + int size = imageValues.size(); + List images = new ArrayList(size); + for (int i = 0; i < size; i++) + { + JSON.Object imageJsonObject = (JSON.Object) imageValues.get(i); + Image image = readImage(imageJsonObject); + images.add(image); + } + return images; + } + + @SuppressWarnings("unchecked") + static Media readMedia(String mediaJsonInput) throws Exception + { + JSON json = JSON.parse(mediaJsonInput); + + Media media = new Media(); + Value bitrate = JPath.parse("/bitrate").evaluate(json); + if (bitrate != null && !bitrate.isNull()) + { + media.bitrate = bitrate.getInt(); + media.hasBitrate = true; + } + Value copyright = JPath.parse("/copyright").evaluate(json); + if (copyright != null && !copyright.isNull()) + { + media.copyright = copyright.getString(); + } + media.duration = JPath.parse("/duration").evaluate(json).getNumber().longValue(); + media.format = JPath.parse("/format").evaluate(json).getString(); + media.height = JPath.parse("/height").evaluate(json).getInt(); + JSON.Array personValues = (JSON.Array) JPath.parse("/persons").evaluate(json); + int size = personValues.size(); + List persons = new ArrayList(size); + for (int i = 0; i < size; i++) + { + persons.add(personValues.get(i).getString()); + } + media.persons = persons; + media.player = Media.Player.valueOf(JPath.parse("/player").evaluate(json).getString()); + media.size = JPath.parse("/size").evaluate(json).getNumber().longValue(); + media.title = JPath.parse("/title").evaluate(json).getString(); + media.uri = JPath.parse("/uri").evaluate(json).getString(); + media.width = JPath.parse("/width").evaluate(json).getInt(); + return media; + } + + static Image readImage(String imageJsonInput) throws Exception + { + Image image = new Image(); + JSON json = JSON.parse(imageJsonInput); + image.height = JPath.parse("/height").evaluate(json).getInt(); + image.size = Image.Size.valueOf(JPath.parse("/size").evaluate(json).getString()); + image.title = JPath.parse("/title").evaluate(json).getString(); + image.uri = JPath.parse("/uri").evaluate(json).getString(); + image.width = JPath.parse("/width").evaluate(json).getInt(); + return image; + } + + @SuppressWarnings("rawtypes") + static Image readImage(JSON.Object imageJsonObject) throws Exception + { + Image image = new Image(); + image.height = JPath.parse("/height").evaluate(imageJsonObject).getInt(); + image.size = Image.Size.valueOf(JPath.parse("/size").evaluate(imageJsonObject).getString()); + image.title = JPath.parse("/title").evaluate(imageJsonObject).getString(); + image.uri = JPath.parse("/uri").evaluate(imageJsonObject).getString(); + image.width = JPath.parse("/width").evaluate(imageJsonObject).getInt(); + return image; + } + + static void writeMedia(StringWriter writer, Media media) + { + JSON json = JSONMarshaler.marshalObject(media); + writer.write(json.toJSON()); + } + + static void writeImage(StringWriter writer, Image image) + { + JSON json = JSONMarshaler.marshalObject(image); + writer.write(json.toJSON()); + } + + static void writeImages(StringWriter writer, List images) + { + JSON json = JSONMarshaler.marshalObject(images); + writer.write(json.toJSON()); + } + + static void writeMediaContent(StringWriter writer, MediaContent mediaContent) + { + JSON json = JSONMarshaler.marshalObject(mediaContent); + writer.write(json.toJSON()); + } + } +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/json/JsonijManualTree.java b/jvm-serializers-tpc/src/main/java/serializers/json/JsonijManualTree.java new file mode 100644 index 0000000..e3e5048 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/json/JsonijManualTree.java @@ -0,0 +1,190 @@ +package serializers.json; + +import java.io.IOException; +import java.io.StringWriter; +import java.util.ArrayList; +import java.util.List; + +import serializers.*; + +import jsonij.json.JSON; +import jsonij.json.JSONMarshaler; +import jsonij.json.JSONParser; +import jsonij.json.Value; +import data.media.Image; +import data.media.Media; +import data.media.MediaContent; + +/** + * Driver that uses JSONiJ [http://projects.plural.cc/projects/jsonij], with manual tree processing. + */ +public class JsonijManualTree +{ + public static void register(TestGroups groups) + { + groups.media.add(JavaBuiltIn.mediaTransformer, + new ManualTreeSerializer("json/jsonij/manual-tree"), + new SerFeatures( + SerFormat.JSON, + SerGraph.FLAT_TREE, + SerClass.MANUAL_OPT, + "" + ) + ); + } + + static class ManualTreeSerializer extends Serializer + { + private final String name; + + public ManualTreeSerializer(String name) + { + this.name = name; + } + + public String getName() + { + return name; + } + + public MediaContent deserialize(byte[] array) throws Exception + { + String mediaContentJsonInput = new String(array, "UTF-8"); + return readMediaContent(mediaContentJsonInput); + } + + public byte[] serialize(MediaContent mediaContent) throws IOException + { + StringWriter writer = new StringWriter(); + writeMediaContent(writer, mediaContent); + writer.flush(); + return writer.toString().getBytes("UTF-8"); + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + static MediaContent readMediaContent(String mediaContentJsonInput) throws Exception + { + JSONParser parser = new JSONParser(); + JSON.Object mediaContentJsonObject = (JSON.Object) parser.parse(mediaContentJsonInput); + + JSON.Object mediaJsonObject = (JSON.Object) mediaContentJsonObject.get("media"); + Media media = readMedia(mediaJsonObject); + + JSON.Array imageValues = (JSON.Array) mediaContentJsonObject.get("images"); + List images = readImages(imageValues); + + MediaContent mediaContent = new MediaContent(); + mediaContent.media = media; + mediaContent.images = images; + return mediaContent; + } + + @SuppressWarnings({ "unchecked" }) + static List readImages(String imagesJsonInput) throws Exception + { + JSONParser parser = new JSONParser(); + JSON.Array imageValues = (JSON.Array) parser.parse(imagesJsonInput); + return readImages(imageValues); + } + + @SuppressWarnings("rawtypes") + static List readImages(JSON.Array imageValues) throws Exception + { + int size = imageValues.size(); + List images = new ArrayList(size); + for (int i = 0; i < size; i++) + { + JSON.Object imageJsonObject = (JSON.Object) imageValues.get(i); + Image image = readImage(imageJsonObject); + images.add(image); + } + return images; + } + + @SuppressWarnings("rawtypes") + static Image readImage(String imageJsonInput) throws Exception + { + JSONParser parser = new JSONParser(); + JSON.Object imageJsonObject = (JSON.Object) parser.parse(imageJsonInput); + return readImage(imageJsonObject); + } + + @SuppressWarnings("rawtypes") + static Image readImage(JSON.Object imageJsonObject) throws Exception + { + Image image = new Image(); + image.height = imageJsonObject.get("height").getInt(); + image.size = Image.Size.valueOf(imageJsonObject.get("size").getString()); + image.title = imageJsonObject.get("title").getString(); + image.uri = imageJsonObject.get("uri").getString(); + image.width = imageJsonObject.get("width").getInt(); + return image; + } + + @SuppressWarnings({ "rawtypes" }) + static Media readMedia(String mediaJsonInput) throws Exception + { + JSONParser parser = new JSONParser(); + JSON.Object mediaJsonObject = (JSON.Object) parser.parse(mediaJsonInput); + return readMedia(mediaJsonObject); + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + static Media readMedia(JSON.Object mediaJsonObject) + { + Media media = new Media(); + Value bitrate = mediaJsonObject.get("bitrate"); + if (bitrate != null && !bitrate.isNull()) + { + media.bitrate = bitrate.getInt(); + media.hasBitrate = true; + } + Value copyright = mediaJsonObject.get("copyright"); + if (copyright != null && !copyright.isNull()) + { + media.copyright = copyright.getString(); + } + media.duration = mediaJsonObject.get("duration").getNumber().longValue(); + media.format = mediaJsonObject.get("format").getString(); + media.height = mediaJsonObject.get("height").getInt(); + JSON.Array personValues = (JSON.Array) mediaJsonObject.get("persons"); + int size = personValues.size(); + List persons = new ArrayList(size); + for (int i = 0; i < size; i++) + { + persons.add(personValues.get(i).getString()); + } + media.persons = persons; + media.player = Media.Player.valueOf(mediaJsonObject.get("player").getString()); + media.size = mediaJsonObject.get("size").getNumber().longValue(); + media.title = mediaJsonObject.get("title").getString(); + media.uri = mediaJsonObject.get("uri").getString(); + media.width = mediaJsonObject.get("width").getInt(); + return media; + } + + static void writeMedia(StringWriter writer, Media media) + { + JSON json = JSONMarshaler.marshalObject(media); + writer.write(json.toJSON()); + } + + static void writeImage(StringWriter writer, Image image) + { + JSON json = JSONMarshaler.marshalObject(image); + writer.write(json.toJSON()); + } + + static void writeImages(StringWriter writer, List images) + { + JSON json = JSONMarshaler.marshalObject(images); + writer.write(json.toJSON()); + } + + static void writeMediaContent(StringWriter writer, MediaContent mediaContent) + { + JSON json = JSONMarshaler.marshalObject(mediaContent); + writer.write(json.toJSON()); + } + } +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/kryo/Kryo.java b/jvm-serializers-tpc/src/main/java/serializers/kryo/Kryo.java new file mode 100644 index 0000000..f36a66e --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/kryo/Kryo.java @@ -0,0 +1,326 @@ + +package serializers.kryo; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.ArrayList; +import java.util.List; + +import serializers.JavaBuiltIn; +import serializers.SerClass; +import serializers.SerFeatures; +import serializers.SerFormat; +import serializers.SerGraph; +import serializers.Serializer; +import serializers.TestGroup; +import serializers.TestGroups; +import serializers.Transformer; + +import com.esotericsoftware.kryo.io.Input; +import com.esotericsoftware.kryo.io.Output; +import com.esotericsoftware.kryo.serializers.CollectionSerializer; +import com.esotericsoftware.kryo.serializers.FieldSerializer; +import com.esotericsoftware.kryo.serializers.FieldSerializer.CachedField; + +import data.media.Image; +import data.media.Image.Size; +import data.media.Media; +import data.media.MediaContent; + +public class Kryo { + + public static void register (TestGroups groups) { + register(groups.media, JavaBuiltIn.mediaTransformer, MediaTypeHandler); + } + + private static void register (TestGroup group, Transformer transformer, TypeHandler handler) { + group.add(transformer, new DefaultSerializer(handler, true, "kryo-serializer"), + new SerFeatures(SerFormat.BINARY, + SerGraph.FULL_GRAPH, + SerClass.ZERO_KNOWLEDGE, + "default") ); + group.add(transformer, new DefaultSerializer(handler, false, "kryo-flat"), + new SerFeatures( + SerFormat.BINARY, + SerGraph.FLAT_TREE, + SerClass.ZERO_KNOWLEDGE, + "default, no shared refs")); + group.add(transformer, new BasicSerializer(handler, "kryo-flat-pre"), + new SerFeatures(SerFormat.BINARY, + SerGraph.FLAT_TREE, + SerClass.CLASSES_KNOWN, + "no shared refs, preregistered classes")); + group.add(transformer, new OptimizedSerializer(handler), + new SerFeatures(SerFormat.BINARY, + SerGraph.FLAT_TREE, + SerClass.MANUAL_OPT, + "manually optimized")); + group.add(transformer, new CustomSerializer(handler), + new SerFeatures( SerFormat.BINARY, + SerGraph.FLAT_TREE, + SerClass.MANUAL_OPT, + "manually optimized")); + } + + // ------------------------------------------------------------ + // Serializers + + /** This is the most basic Kryo usage. Don't register anything go. */ + public static class DefaultSerializer extends Serializer { + final com.esotericsoftware.kryo.Kryo kryo; + + private final String name; + private final byte[] buffer = new byte[BUFFER_SIZE]; + private final Output output = new Output(buffer, -1); + private final Input input = new Input(buffer); + private final Class type; + boolean shared; + + public DefaultSerializer (TypeHandler handler,boolean shared, String name) { + this.name = name; + this.type = handler.type; + this.shared = shared; + this.kryo = new com.esotericsoftware.kryo.Kryo(); + kryo.setReferences(shared); + kryo.setRegistrationRequired(false); + } + + @SuppressWarnings("unchecked") + public T deserialize (byte[] array) { + input.setBuffer(array); + return (T) kryo.readObject(input, type); + } + + public byte[] serialize (T content) { + output.setBuffer(buffer, -1); + kryo.writeObject(output, content); + return output.toBytes(); + } + + public void serializeItems (T[] items, OutputStream outStream) throws Exception { + output.setOutputStream(outStream); + for (int i = 0, n = items.length; i < n; ++i) { + kryo.writeClassAndObject(output, items[i]); + } + output.flush(); + } + + @SuppressWarnings("unchecked") + public T[] deserializeItems (InputStream inStream, int numberOfItems) throws IOException { + input.setInputStream(inStream); + MediaContent[] result = new MediaContent[numberOfItems]; + for (int i = 0; i < numberOfItems; ++i) { + result[i] = (MediaContent) kryo.readClassAndObject(input); + } + return (T[])result; + } + + public final String getName () { + return name; + } + } + + /** This is slightly advanced Kryo usage. Just register the classes and go. */ + public static class BasicSerializer extends Serializer { + private final Class type; + final com.esotericsoftware.kryo.Kryo kryo; + + private final String name; + private final byte[] buffer = new byte[BUFFER_SIZE]; + private final Output output = new Output(buffer, -1); + private final Input input = new Input(buffer); + + public BasicSerializer (TypeHandler handler, String name) { + this.type = handler.type; + this.kryo = new com.esotericsoftware.kryo.Kryo(); + kryo.setReferences(false); + kryo.setRegistrationRequired(true); + this.name = name; + handler.register(this.kryo); + } + + public T deserialize (byte[] array) { + input.setBuffer(array); + return kryo.readObject(input, type); + } + + public byte[] serialize (T content) { + output.setBuffer(buffer, -1); + kryo.writeObject(output, content); + return output.toBytes(); + } + + public void serializeItems (T[] items, OutputStream outStream) throws Exception { + output.setOutputStream(outStream); + for (int i = 0, n = items.length; i < n; ++i) { + kryo.writeObject(output, items[i]); + } + output.flush(); + } + + @SuppressWarnings("unchecked") + public T[] deserializeItems (InputStream inStream, int numberOfItems) throws IOException { + input.setInputStream(inStream); + MediaContent[] result = new MediaContent[numberOfItems]; + for (int i = 0; i < numberOfItems; ++i) { + result[i] = kryo.readObject(input, MediaContent.class); + } + return (T[])result; + } + + @Override + public final String getName () { + return name; + } + } + + /** This shows how to configure individual Kryo serializersto reduce the serialized bytes. */ + public static class OptimizedSerializer extends BasicSerializer { + public OptimizedSerializer (TypeHandler handler) { + super(handler, "kryo-opt"); + handler.optimize(this.kryo); + } + } + + /** This shows how to use hand written serialization code with Kryo, while still leveraging Kryo for most of the work. A + * serializer for each class can be implemented, as it is here, or the classes to be serialized can implement an interface and + * host their own serialization code (similar to java.io.Externalizable). */ + public static class CustomSerializer extends BasicSerializer { + public CustomSerializer (TypeHandler handler) { + super(handler, "kryo-manual"); + handler.registerCustom(this.kryo); + } + } + + // ------------------------------------------------------------ + + public static abstract class TypeHandler { + public final Class type; + + protected TypeHandler (Class type) { + this.type = type; + } + + public abstract void register (com.esotericsoftware.kryo.Kryo kryo); + + public abstract void optimize (com.esotericsoftware.kryo.Kryo kryo); + + public abstract void registerCustom (com.esotericsoftware.kryo.Kryo kryo); + } + + // ------------------------------------------------------------ + // Media + + public static final TypeHandler MediaTypeHandler = new TypeHandler(MediaContent.class) { + public void register (com.esotericsoftware.kryo.Kryo kryo) { + kryo.register(ArrayList.class); + kryo.register(MediaContent.class); + kryo.register(Media.Player.class); + kryo.register(Media.class); + kryo.register(Image.Size.class); + kryo.register(Image.class); + } + + @SuppressWarnings("rawtypes") + public void optimize (com.esotericsoftware.kryo.Kryo kryo) { + FieldSerializer imageSerializer = (FieldSerializer)kryo.getSerializer(Image.class); + imageSerializer.setFieldsCanBeNull(false); + imageSerializer.getField("title").setCanBeNull(true); + + FieldSerializer mediaContentSerializer = (FieldSerializer)kryo.getSerializer(MediaContent.class); + mediaContentSerializer.setFieldsCanBeNull(false); + + CachedField imagesField = mediaContentSerializer.getField("images"); + CollectionSerializer imagesSerializer = new CollectionSerializer(); + imagesSerializer.setElementsCanBeNull(false); + imagesField.setClass(ArrayList.class, imagesSerializer); + + FieldSerializer mediaSerializer = new FieldSerializer(kryo, Media.class); + mediaSerializer.setFieldsCanBeNull(false); + mediaSerializer.getField("title").setCanBeNull(true); + mediaSerializer.getField("copyright").setCanBeNull(true); + + CachedField mediaField = mediaContentSerializer.getField("media"); + mediaField.setClass(Media.class, mediaSerializer); + + CachedField personsField = mediaSerializer.getField("persons"); + CollectionSerializer personsSerializer = new CollectionSerializer(); + personsSerializer.setElementsCanBeNull(false); + personsField.setClass(ArrayList.class, personsSerializer); + } + + public void registerCustom (com.esotericsoftware.kryo.Kryo kryo) { + kryo.register(Image.class, new ImageSerializer()); + kryo.register(MediaContent.class, new MediaContentSerializer(kryo)); + kryo.register(Media.class, new MediaSerializer(kryo)); + } + }; + + static class MediaContentSerializer extends com.esotericsoftware.kryo.Serializer { + private CollectionSerializer _imagesSerializer; + + public MediaContentSerializer (com.esotericsoftware.kryo.Kryo kryo) { + _imagesSerializer = new CollectionSerializer(); + _imagesSerializer.setElementsCanBeNull(false); + } + + public MediaContent read (com.esotericsoftware.kryo.Kryo kryo, Input input, Class type) { + final Media media = kryo.readObject(input, Media.class); + @SuppressWarnings("unchecked") + final List images = (List)kryo.readObject(input, ArrayList.class, _imagesSerializer); + return new MediaContent(media, images); + } + + public void write (com.esotericsoftware.kryo.Kryo kryo, Output output, MediaContent obj) { + kryo.writeObject(output, obj.media); + kryo.writeObject(output, obj.images, _imagesSerializer); + } + } + + static class MediaSerializer extends com.esotericsoftware.kryo.Serializer { + private final CollectionSerializer _personsSerializer; + + public MediaSerializer (final com.esotericsoftware.kryo.Kryo kryo) { + _personsSerializer = new CollectionSerializer(); + _personsSerializer.setElementsCanBeNull(false); + } + + @SuppressWarnings("unchecked") + public Media read (com.esotericsoftware.kryo.Kryo kryo, Input input, Class type) { + return new Media(input.readString(), input.readString(), input.readInt(true), input.readInt(true), input.readString(), + input.readLong(true), input.readLong(true), input.readInt(true), input.readBoolean(), (List)kryo.readObject( + input, ArrayList.class, _personsSerializer), kryo.readObject(input, Media.Player.class), input.readString()); + } + + public void write (com.esotericsoftware.kryo.Kryo kryo, Output output, Media obj) { + output.writeString(obj.uri); + output.writeString(obj.title); + output.writeInt(obj.width, true); + output.writeInt(obj.height, true); + output.writeString(obj.format); + output.writeLong(obj.duration, true); + output.writeLong(obj.size, true); + output.writeInt(obj.bitrate, true); + output.writeBoolean(obj.hasBitrate); + kryo.writeObject(output, obj.persons, _personsSerializer); + kryo.writeObject(output, obj.player); + output.writeString(obj.copyright); + } + } + + static class ImageSerializer extends com.esotericsoftware.kryo.Serializer { + public Image read (com.esotericsoftware.kryo.Kryo kryo, Input input, Class type) { + return new Image(input.readString(), input.readString(), input.readInt(true), input.readInt(true), kryo.readObject( + input, Size.class)); + } + + public void write (com.esotericsoftware.kryo.Kryo kryo, Output output, Image obj) { + output.writeString(obj.uri); + output.writeString(obj.title); + output.writeInt(obj.width, true); + output.writeInt(obj.height, true); + kryo.writeObject(output, obj.size); + } + } +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/msgpack/ImageSizeTemplate.java b/jvm-serializers-tpc/src/main/java/serializers/msgpack/ImageSizeTemplate.java new file mode 100644 index 0000000..51bf7fe --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/msgpack/ImageSizeTemplate.java @@ -0,0 +1,15 @@ +package serializers.msgpack; + +import org.msgpack.template.OrdinalEnumTemplate; +import org.msgpack.template.Template; + +import data.media.Image; +import data.media.Image.Size; + +final class ImageSizeTemplate extends OrdinalEnumTemplate { + static final Template INSTANCE = new ImageSizeTemplate(Image.Size.class); + + public ImageSizeTemplate(Class targetClass) { + super(targetClass); + } + } \ No newline at end of file diff --git a/jvm-serializers-tpc/src/main/java/serializers/msgpack/ImageTemplate.java b/jvm-serializers-tpc/src/main/java/serializers/msgpack/ImageTemplate.java new file mode 100644 index 0000000..1a758a8 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/msgpack/ImageTemplate.java @@ -0,0 +1,44 @@ +package serializers.msgpack; + +import java.io.IOException; + +import org.msgpack.packer.Packer; +import org.msgpack.template.AbstractTemplate; +import org.msgpack.template.NotNullableTemplate; +import org.msgpack.template.Template; +import org.msgpack.template.Templates; +import org.msgpack.unpacker.Unpacker; + +import data.media.Image; +import data.media.Image.Size; + +final class ImageTemplate extends AbstractTemplate { + static final Template INSTANCE = new ImageTemplate(); + static final Template imageSizeTemplate = + new NotNullableTemplate(ImageSizeTemplate.INSTANCE); + + @Override + public void write(Packer packer, Image v, boolean required) throws IOException { + packer.writeArrayBegin(5); + Templates.TString.write(packer, v.uri, true); + Templates.TString.write(packer, v.title, false); + Templates.TInteger.write(packer, v.width, true); + Templates.TInteger.write(packer, v.height, true); + imageSizeTemplate.write(packer, v.size); + packer.writeArrayEnd(); + } + + @Override + public Image read(Unpacker unpacker, Image to, boolean required) throws IOException { + unpacker.readArrayBegin(); + to = new Image( + Templates.TString.read(unpacker, null, true), + Templates.TString.read(unpacker, null, false), + Templates.TInteger.read(unpacker, null, true), + Templates.TInteger.read(unpacker, null, true), + imageSizeTemplate.read(unpacker, null, true) + ); + unpacker.readArrayEnd(); + return to; + } + } \ No newline at end of file diff --git a/jvm-serializers-tpc/src/main/java/serializers/msgpack/MediaContentTemplate.java b/jvm-serializers-tpc/src/main/java/serializers/msgpack/MediaContentTemplate.java new file mode 100644 index 0000000..3fb442a --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/msgpack/MediaContentTemplate.java @@ -0,0 +1,43 @@ +package serializers.msgpack; + +import java.io.IOException; +import java.util.List; + +import org.msgpack.packer.Packer; +import org.msgpack.template.AbstractTemplate; +import org.msgpack.template.ListTemplate; +import org.msgpack.template.NotNullableTemplate; +import org.msgpack.template.Template; +import org.msgpack.unpacker.Unpacker; + +import data.media.Image; +import data.media.Media; +import data.media.MediaContent; + +final class MediaContentTemplate extends AbstractTemplate { + static final Template INSTANCE = new MediaContentTemplate(); + static final Template mediaTemplate = new NotNullableTemplate(MediaTemplate.INSTANCE); + @SuppressWarnings({ "rawtypes", "unchecked" }) + static final Template> imageListTemplate = + new NotNullableTemplate>(new ListTemplate( + new NotNullableTemplate(ImageTemplate.INSTANCE))); + + @Override + public void write(Packer packer, MediaContent v, boolean required) throws IOException { + packer.writeArrayBegin(2); + mediaTemplate.write(packer, v.media, true); + imageListTemplate.write(packer, v.images, true); + packer.writeArrayEnd(); + } + + @Override + public MediaContent read(Unpacker unpacker, MediaContent to, boolean required) throws IOException { + unpacker.readArrayBegin(); + to = new MediaContent( + mediaTemplate.read(unpacker, null, true), + imageListTemplate.read(unpacker, null, true) + ); + unpacker.readArrayEnd(); + return to; + } + } \ No newline at end of file diff --git a/jvm-serializers-tpc/src/main/java/serializers/msgpack/MediaContentTypeHandler.java b/jvm-serializers-tpc/src/main/java/serializers/msgpack/MediaContentTypeHandler.java new file mode 100644 index 0000000..ec9b484 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/msgpack/MediaContentTypeHandler.java @@ -0,0 +1,31 @@ +package serializers.msgpack; + +import org.msgpack.MessagePack; +import org.msgpack.template.NotNullableTemplate; +import org.msgpack.template.Template; + +import data.media.Image; +import data.media.Media; +import data.media.MediaContent; + +public final class MediaContentTypeHandler extends TypeHandler { + protected MediaContentTypeHandler() { + super(MediaContent.class); + } + + @Override + public void register(MessagePack msgpack) { + msgpack.register(Image.Size.class); + msgpack.register(Image.class); + msgpack.register(Media.Player.class); + msgpack.register(Media.class); + msgpack.register(MediaContent.class); + } + + static final Template mediaContentTemplate = new NotNullableTemplate(MediaContentTemplate.INSTANCE); + + @Override + public void registerManually(MessagePack msgpack) { + msgpack.register(MediaContent.class, mediaContentTemplate); + } +} \ No newline at end of file diff --git a/jvm-serializers-tpc/src/main/java/serializers/msgpack/MediaPlayerTemplate.java b/jvm-serializers-tpc/src/main/java/serializers/msgpack/MediaPlayerTemplate.java new file mode 100644 index 0000000..8b89c01 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/msgpack/MediaPlayerTemplate.java @@ -0,0 +1,12 @@ +package serializers.msgpack; + +import org.msgpack.template.OrdinalEnumTemplate; +//import org.msgpack.template.Template; + +import data.media.Media; + +final class MediaPlayerTemplate extends OrdinalEnumTemplate { + public MediaPlayerTemplate() { + super(Media.Player.class); + } + } \ No newline at end of file diff --git a/jvm-serializers-tpc/src/main/java/serializers/msgpack/MediaTemplate.java b/jvm-serializers-tpc/src/main/java/serializers/msgpack/MediaTemplate.java new file mode 100644 index 0000000..c468194 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/msgpack/MediaTemplate.java @@ -0,0 +1,59 @@ +package serializers.msgpack; + +import java.io.IOException; +import java.util.List; + +import org.msgpack.packer.Packer; +import org.msgpack.template.*; +import org.msgpack.unpacker.Unpacker; + +import data.media.Media; + +final class MediaTemplate extends AbstractTemplate { + static final Template INSTANCE = new MediaTemplate(); + static final Template mediaPlayerTemplate = + new NotNullableTemplate(new MediaPlayerTemplate()); + @SuppressWarnings({ "rawtypes", "unchecked" }) + static final Template> personsTemplate = + new NotNullableTemplate>(new ListTemplate( + new NotNullableTemplate(StringTemplate.getInstance()))); + + @Override + public void write(Packer packer, Media v, boolean required) throws IOException { + packer.writeArrayBegin(12); + Templates.TString.write(packer, v.uri, true); + Templates.TString.write(packer, v.title, false); + Templates.TInteger.write(packer, v.width, true); + Templates.TInteger.write(packer, v.height, true); + Templates.TString.write(packer, v.format, true); + Templates.TLong.write(packer, v.duration, true); + Templates.TLong.write(packer, v.size, true); + Templates.TInteger.write(packer, v.bitrate, true); + Templates.TBoolean.write(packer, v.hasBitrate, true); + personsTemplate.write(packer, v.persons, true); + mediaPlayerTemplate.write(packer, v.player, true); + Templates.TString.write(packer, v.copyright, false); + packer.writeArrayEnd(); + } + + @Override + public Media read(Unpacker unpacker, Media to, boolean required) throws IOException { + unpacker.readArrayBegin(); + to = new Media( + Templates.TString.read(unpacker, null, true), + Templates.TString.read(unpacker, null, false), + Templates.TInteger.read(unpacker, null, true), + Templates.TInteger.read(unpacker, null, true), + Templates.TString.read(unpacker, null, true), + Templates.TLong.read(unpacker, null, true), + Templates.TLong.read(unpacker, null, true), + Templates.TInteger.read(unpacker, null, true), + Templates.TBoolean.read(unpacker, null, true), + personsTemplate.read(unpacker, null, true), + mediaPlayerTemplate.read(unpacker, null, true), + Templates.TString.read(unpacker, null, false) + ); + unpacker.readArrayEnd(); + return to; + } + } \ No newline at end of file diff --git a/jvm-serializers-tpc/src/main/java/serializers/msgpack/MsgPack.java b/jvm-serializers-tpc/src/main/java/serializers/msgpack/MsgPack.java new file mode 100644 index 0000000..f118714 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/msgpack/MsgPack.java @@ -0,0 +1,31 @@ +package serializers.msgpack; + +import org.msgpack.MessagePack; + +import serializers.*; + +public class MsgPack +{ + private final static String DESC = + "uses positional (column) layout (instead of Maps std impl uses) to eliminate use of names"; + + public static void register(TestGroups groups) { + register(groups.media, JavaBuiltIn.mediaTransformer); + } + + @SuppressWarnings("unchecked") + private static void register(TestGroup group, Transformer transformer) { + MessagePack msgpack = new MessagePack(); + TypeHandler h = (TypeHandler) new MediaContentTypeHandler(); + h.register(msgpack); + group.add(transformer, new MsgPackSerializer("msgpack/databind", h, msgpack), + new SerFeatures(SerFormat.BIN_CROSSLANG, SerGraph.FLAT_TREE, SerClass.CLASSES_KNOWN, DESC)); + + msgpack = new MessagePack(); + h = (TypeHandler) new MediaContentTypeHandler(); + h.registerManually(msgpack); + + group.add(transformer, new MsgPackSerializer("msgpack/manual", h, msgpack), + new SerFeatures( SerFormat.BIN_CROSSLANG,SerGraph.FLAT_TREE,SerClass.MANUAL_OPT, DESC)); + } +} \ No newline at end of file diff --git a/jvm-serializers-tpc/src/main/java/serializers/msgpack/MsgPackSerializer.java b/jvm-serializers-tpc/src/main/java/serializers/msgpack/MsgPackSerializer.java new file mode 100644 index 0000000..7792a19 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/msgpack/MsgPackSerializer.java @@ -0,0 +1,40 @@ +package serializers.msgpack; + +import org.msgpack.MessagePack; +import org.msgpack.packer.BufferPacker; +import org.msgpack.unpacker.BufferUnpacker; + +import serializers.Serializer; + +public class MsgPackSerializer extends Serializer { + protected final String name; + protected final Class type; + private final BufferPacker packer; + private final BufferUnpacker unpacker; + + public MsgPackSerializer(String name, TypeHandler handler, MessagePack msgpack) { + this.name = name; + type = handler.type; + packer = msgpack.createBufferPacker(BUFFER_SIZE); + unpacker = msgpack.createBufferUnpacker(); + } + + @Override + public byte[] serialize(T content) throws Exception { + packer.write(content); + byte[] array = packer.toByteArray(); + packer.clear(); + return array; + } + + @Override + public T deserialize(byte[] array) throws Exception { + unpacker.wrap(array); + return unpacker.read(type); + } + + @Override + public String getName() { + return name; + } +} \ No newline at end of file diff --git a/jvm-serializers-tpc/src/main/java/serializers/msgpack/TypeHandler.java b/jvm-serializers-tpc/src/main/java/serializers/msgpack/TypeHandler.java new file mode 100644 index 0000000..983b6bf --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/msgpack/TypeHandler.java @@ -0,0 +1,15 @@ +package serializers.msgpack; + +import org.msgpack.MessagePack; + +abstract class TypeHandler { + public final Class type; + + protected TypeHandler(Class type) { + this.type = type; + } + + public abstract void register(final MessagePack msgpack); + + public abstract void registerManually(final MessagePack msgpack); +} \ No newline at end of file diff --git a/jvm-serializers-tpc/src/main/java/serializers/protobuf/ActiveMQProtobuf.java b/jvm-serializers-tpc/src/main/java/serializers/protobuf/ActiveMQProtobuf.java new file mode 100644 index 0000000..8aa52ad --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/protobuf/ActiveMQProtobuf.java @@ -0,0 +1,195 @@ +package serializers.protobuf; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import data.media.MediaTransformer; + +import serializers.*; +import serializers.activemq.media.MediaContentHolder.Image; +import serializers.activemq.media.MediaContentHolder.Media; +import serializers.activemq.media.MediaContentHolder.MediaContent; +import serializers.activemq.media.MediaContentHolder.Image.ImageBean; +import serializers.activemq.media.MediaContentHolder.Image.Size; +import serializers.activemq.media.MediaContentHolder.Media.MediaBean; +import serializers.activemq.media.MediaContentHolder.Media.Player; +import serializers.activemq.media.MediaContentHolder.MediaContent.MediaContentBean; +import serializers.activemq.media.MediaContentHolder.MediaContent.MediaContentBuffer; + +public class ActiveMQProtobuf +{ + public static void register(TestGroups groups) + { + groups.media.add(mediaTransformer, MediaSerializer, + new SerFeatures( + SerFormat.BIN_CROSSLANG, + SerGraph.FLAT_TREE, + SerClass.CLASSES_KNOWN, + "" + ) + ); + } + + // ------------------------------------------------------------ + // Serializers + + public static final Serializer MediaSerializer = new Serializer() + { + public MediaContent deserialize(byte[] array) throws Exception + { + return MediaContentBuffer.parseUnframed(array); + } + + public byte[] serialize(MediaContent content) + { + return content.freeze().toUnframedByteArray(); + } + + public String getName() + { + return "protobuf/activemq+alt"; + } + }; + + // ------------------------------------------------------------ + // Transformers + + public static final MediaTransformer mediaTransformer = new MediaTransformer() + { + @Override + public MediaContent[] resultArray(int size) { return new MediaContent[size]; } + + // ---------------------------------------------------------- + // Forward + + public MediaContent forward(data.media.MediaContent mc) + { + MediaContentBean cb = new MediaContentBean(); + + cb.setMedia(forwardMedia(mc.media)); + for (data.media.Image image : mc.images) { + cb.addImage(forwardImage(image)); + } + + return cb; + } + + private Media forwardMedia(data.media.Media media) + { + // Media + MediaBean mb = new MediaBean(); + mb.setUri(media.uri); + if (media.title != null) mb.setTitle(media.title); + mb.setWidth(media.width); + mb.setHeight(media.height); + mb.setFormat(media.format); + mb.setDuration(media.duration); + mb.setSize(media.size); + if (media.hasBitrate) mb.setBitrate(media.bitrate); + for (String person : media.persons) { + mb.addPerson(person); + } + mb.setPlayer(forwardPlayer(media.player)); + if (media.copyright != null) mb.setCopyright(media.copyright); + + return mb; + } + + public Player forwardPlayer(data.media.Media.Player p) + { + switch (p) { + case JAVA: return Player.JAVA; + case FLASH: return Player.FLASH; + default: + throw new AssertionError("invalid case: " + p); + } + } + + private Image forwardImage(data.media.Image image) + { + ImageBean ib = new ImageBean(); + ib.setUri(image.uri); + if (image.title != null) ib.setTitle(image.title); + ib.setWidth(image.width); + ib.setHeight(image.height); + ib.setSize(forwardSize(image.size)); + return ib; + } + + public Size forwardSize(data.media.Image.Size s) + { + switch (s) { + case SMALL: return Size.SMALL; + case LARGE: return Size.LARGE; + default: + throw new AssertionError("invalid case: " + s); + } + } + + // ---------------------------------------------------------- + // Reverse + + public data.media.MediaContent reverse(MediaContent mc) + { + List images = new ArrayList(mc.getImageCount()); + + for (Image image : mc.getImageList()) { + images.add(reverseImage(image)); + } + + return new data.media.MediaContent(reverseMedia(mc.getMedia()), images); + } + + private data.media.Media reverseMedia(Media media) + { + // Media + return new data.media.Media( + media.getUri(), + media.hasTitle() ? media.getTitle() : null, + media.getWidth(), + media.getHeight(), + media.getFormat(), + media.getDuration(), + media.getSize(), + media.hasBitrate() ? media.getBitrate() : 0, + media.hasBitrate(), + new ArrayList(media.getPersonList()), + reversePlayer(media.getPlayer()), + media.hasCopyright() ? media.getCopyright() : null + ); + } + + public data.media.Media.Player reversePlayer(Player p) + { + if (p == Player.JAVA) return data.media.Media.Player.JAVA; + if (p == Player.FLASH) return data.media.Media.Player.FLASH; + throw new AssertionError("invalid case: " + p); + } + + private data.media.Image reverseImage(Image image) + { + return new data.media.Image( + image.getUri(), + image.hasTitle() ? image.getTitle() : null, + image.getWidth(), + image.getHeight(), + reverseSize(image.getSize())); + } + + public data.media.Image.Size reverseSize(Size s) + { + switch (s) { + case SMALL: return data.media.Image.Size.SMALL; + case LARGE: return data.media.Image.Size.LARGE; + default: + throw new AssertionError("invalid case: " + s); + } + } + + public data.media.MediaContent shallowReverse(MediaContent mc) + { + return new data.media.MediaContent(reverseMedia(mc.getMedia()), Collections.emptyList()); + } + }; +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/protobuf/Protobuf.java b/jvm-serializers-tpc/src/main/java/serializers/protobuf/Protobuf.java new file mode 100644 index 0000000..d75edbf --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/protobuf/Protobuf.java @@ -0,0 +1,221 @@ +package serializers.protobuf; + +import static serializers.protobuf.media.MediaContentHolder.*; + +import java.io.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import data.media.MediaTransformer; + +import serializers.*; + +/** + *

+ * Note on stream test case: as per [http://code.google.com/apis/protocolbuffers/docs/techniques.html] + * we will have to external framing; we just use very simple length prefix, which should work + * reasonably well. + */ +public class Protobuf +{ + public static void register(TestGroups groups) { + groups.media.add(new Transformer(), new PBSerializer(), + new SerFeatures( + SerFormat.BIN_CROSSLANG, + SerGraph.FLAT_TREE, + SerClass.CLASSES_KNOWN, + "" + ) + ); + } + + // ------------------------------------------------------------ + // Serializers + + static final class PBSerializer extends Serializer + { + public String getName() { return "protobuf"; } + + @Override + public MediaContent deserialize (byte[] array) throws Exception { + return MediaContent.parseFrom(array); + } + + @Override + public byte[] serialize(MediaContent content) { + return content.toByteArray(); + } + + @Override + public final void serializeItems(MediaContent[] items, OutputStream out0) throws IOException + { + DataOutputStream out = new DataOutputStream(out0); + for (MediaContent item : items) { + byte[] data = item.toByteArray(); + out.writeInt(data.length); + out.write(data); + } + // should we write end marker (length of 0) or not? For now, omit it + out.flush(); + } + + @Override + public MediaContent[] deserializeItems(InputStream in0, int numberOfItems) throws IOException + { + DataInputStream in = new DataInputStream(in0); + MediaContent[] result = new MediaContent[numberOfItems]; + for (int i = 0; i < numberOfItems; ++i) { + int len = in.readInt(); + byte[] data = new byte[len]; + in.readFully(data); + result[i] = MediaContent.parseFrom(data); + } + return result; + } + } + + // ------------------------------------------------------------ + // Transformers + + static final class Transformer extends MediaTransformer + { + @Override + public MediaContent[] resultArray(int size) { return new MediaContent[size]; } + + // ---------------------------------------------------------- + // Forward + + public MediaContent forward(data.media.MediaContent mc) + { + MediaContent.Builder cb = MediaContent.newBuilder(); + + cb.setMedia(forwardMedia(mc.media)); + for (data.media.Image image : mc.images) { + cb.addImage(forwardImage(image)); + } + + return cb.build(); + } + + private Media forwardMedia(data.media.Media media) + { + // Media + Media.Builder mb = Media.newBuilder(); + mb.setUri(media.uri); + if (media.title != null) mb.setTitle(media.title); + mb.setWidth(media.width); + mb.setHeight(media.height); + mb.setFormat(media.format); + mb.setDuration(media.duration); + mb.setSize(media.size); + if (media.hasBitrate) mb.setBitrate(media.bitrate); + for (String person : media.persons) { + mb.addPerson(person); + } + mb.setPlayer(forwardPlayer(media.player)); + if (media.copyright != null) mb.setCopyright(media.copyright); + + return mb.build(); + } + + public Media.Player forwardPlayer(data.media.Media.Player p) + { + switch (p) { + case JAVA: return Media.Player.JAVA; + case FLASH: return Media.Player.FLASH; + default: + throw new AssertionError("invalid case: " + p); + } + } + + private Image forwardImage(data.media.Image image) + { + Image.Builder ib = Image.newBuilder(); + ib.setUri(image.uri); + if (image.title != null) ib.setTitle(image.title); + ib.setWidth(image.width); + ib.setHeight(image.height); + ib.setSize(forwardSize(image.size)); + return ib.build(); + } + + public Image.Size forwardSize(data.media.Image.Size s) + { + switch (s) { + case SMALL: return Image.Size.SMALL; + case LARGE: return Image.Size.LARGE; + default: + throw new AssertionError("invalid case: " + s); + } + } + + // ---------------------------------------------------------- + // Reverse + + public data.media.MediaContent reverse(MediaContent mc) + { + List images = new ArrayList(mc.getImageCount()); + + for (Image image : mc.getImageList()) { + images.add(reverseImage(image)); + } + + return new data.media.MediaContent(reverseMedia(mc.getMedia()), images); + } + + private data.media.Media reverseMedia(Media media) + { + // Media + return new data.media.Media( + media.getUri(), + media.hasTitle() ? media.getTitle() : null, + media.getWidth(), + media.getHeight(), + media.getFormat(), + media.getDuration(), + media.getSize(), + media.hasBitrate() ? media.getBitrate() : 0, + media.hasBitrate(), + new ArrayList(media.getPersonList()), + reversePlayer(media.getPlayer()), + media.hasCopyright() ? media.getCopyright() : null + ); + } + + public data.media.Media.Player reversePlayer(Media.Player p) + { + switch (p) { + case JAVA: return data.media.Media.Player.JAVA; + case FLASH: return data.media.Media.Player.FLASH; + default: + throw new AssertionError("invalid case: " + p); + } + } + + private data.media.Image reverseImage(Image image) + { + return new data.media.Image( + image.getUri(), + image.hasTitle() ? image.getTitle() : null, + image.getWidth(), + image.getHeight(), + reverseSize(image.getSize())); + } + + public data.media.Image.Size reverseSize(Image.Size s) + { + switch (s) { + case SMALL: return data.media.Image.Size.SMALL; + case LARGE: return data.media.Image.Size.LARGE; + default: + throw new AssertionError("invalid case: " + s); + } + } + + public data.media.MediaContent shallowReverse(MediaContent mc) + { + return new data.media.MediaContent(reverseMedia(mc.getMedia()), Collections.emptyList()); + } + } +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/protobuf/ProtobufJson.java b/jvm-serializers-tpc/src/main/java/serializers/protobuf/ProtobufJson.java new file mode 100644 index 0000000..dc2b36b --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/protobuf/ProtobufJson.java @@ -0,0 +1,43 @@ +package serializers.protobuf; + +import serializers.*; +import serializers.protobuf.media.MediaContentHolder.MediaContent; + +import java.io.IOException; +import java.nio.charset.Charset; + +import com.google.protobuf.JsonFormat; + +public class ProtobufJson +{ + public static void register(TestGroups groups) { + groups.media.add(new Protobuf.Transformer(), new JsonSerializer(), + new SerFeatures( + SerFormat.JSON, + SerGraph.FLAT_TREE, + SerClass.CLASSES_KNOWN, + "" + ) + ); + } + + private static final Charset _charset = Charset.forName("UTF-8"); + + static final class JsonSerializer extends Serializer + { + public MediaContent deserialize (byte[] array) throws Exception + { + MediaContent.Builder builder = MediaContent.newBuilder(); + JsonFormat.merge(new String(array, _charset.name()), builder); + return builder.build(); + } + + public byte[] serialize(MediaContent content) throws IOException { + return JsonFormat.printToString(content).getBytes(_charset.name()); + } + + public String getName () { + return "json/protobuf"; + } + } +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/protostuff/Protostuff.java b/jvm-serializers-tpc/src/main/java/serializers/protostuff/Protostuff.java new file mode 100644 index 0000000..04297e4 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/protostuff/Protostuff.java @@ -0,0 +1,842 @@ +package serializers.protostuff; + +import java.io.IOException; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import com.dyuproject.protostuff.GraphIOUtil; +import com.dyuproject.protostuff.Input; +import com.dyuproject.protostuff.LinkedBuffer; +import com.dyuproject.protostuff.Output; +import com.dyuproject.protostuff.ProtobufIOUtil; +import com.dyuproject.protostuff.ProtostuffIOUtil; +import com.dyuproject.protostuff.Schema; +import com.dyuproject.protostuff.runtime.RuntimeSchema; + +import data.media.MediaTransformer; + +import serializers.*; +import serializers.protostuff.media.MediaContent; +import serializers.protostuff.media.Media; +import serializers.protostuff.media.Image; + +public final class Protostuff +{ + + public static void register(TestGroups groups) + { + // generated code + groups.media.add(mediaTransformer, ProtostuffMediaSerializer, + new SerFeatures( + SerFormat.BINARY, + SerGraph.FLAT_TREE, + SerClass.CLASSES_KNOWN, + "generated code" + ) + ); + + // manual (hand-coded schema, no autoboxing) + groups.media.add(JavaBuiltIn.mediaTransformer, ProtostuffManualMediaSerializer, + new SerFeatures( + SerFormat.BINARY, + SerGraph.FLAT_TREE, + SerClass.MANUAL_OPT, + "manual" + ) + ); + + // runtime (reflection) + groups.media.add(JavaBuiltIn.mediaTransformer, ProtostuffRuntimeMediaSerializer, + new SerFeatures( + SerFormat.BINARY, + SerGraph.FLAT_TREE, + SerClass.ZERO_KNOWLEDGE, + "reflection" + ) + ); + + // protobuf serialization + generated code + groups.media.add(mediaTransformer, ProtobufMediaSerializer, + new SerFeatures( + SerFormat.BIN_CROSSLANG, + SerGraph.FLAT_TREE, + SerClass.CLASSES_KNOWN, + "protobuf + generated code" + ) + ); + + // protobuf serialization + runtime + groups.media.add(JavaBuiltIn.mediaTransformer, ProtobufRuntimeMediaSerializer, + new SerFeatures( + SerFormat.BIN_CROSSLANG, + SerGraph.FLAT_TREE, + SerClass.ZERO_KNOWLEDGE, + "protobuf + reflection" + ) + ); + + // graph + groups.media.add(mediaTransformer, ProtostuffGraphMediaSerializer, + new SerFeatures( + SerFormat.BINARY, + SerGraph.FULL_GRAPH, + SerClass.CLASSES_KNOWN, + "graph + generated code" + ) + ); + + groups.media.add(JavaBuiltIn.mediaTransformer, ProtostuffGraphRuntimeMediaSerializer, + new SerFeatures( + SerFormat.BINARY, + SerGraph.FULL_GRAPH, + SerClass.ZERO_KNOWLEDGE, + "graph + reflection" + ) + ); + + // exclude protostuff-graph-manual + /*groups.media.add(JavaBuiltIn.mediaTransformer, ProtostuffGraphManualMediaSerializer, + new SerFeatures( + SerFormat.BINARY, + SerGraph.FULL_GRAPH, + SerClass.MANUAL_OPT, + "graph + manual" + ) + );*/ + } + + public static final Serializer ProtostuffMediaSerializer = + new Serializer() + { + final LinkedBuffer buffer = LinkedBuffer.allocate(BUFFER_SIZE); + + public MediaContent deserialize(byte[] array) throws Exception + { + final MediaContent mc = new MediaContent(); + ProtostuffIOUtil.mergeFrom(array, mc, mc.cachedSchema()); + return mc; + } + + public byte[] serialize(MediaContent content) throws Exception + { + try + { + return ProtostuffIOUtil.toByteArray(content, content.cachedSchema(), buffer); + } + finally + { + buffer.clear(); + } + } + + public String getName() + { + return "protostuff"; + } + + }; + + public static final Serializer ProtobufMediaSerializer = + new Serializer() + { + final LinkedBuffer buffer = LinkedBuffer.allocate(BUFFER_SIZE); + + public MediaContent deserialize(byte[] array) throws Exception + { + final MediaContent mc = new MediaContent(); + ProtobufIOUtil.mergeFrom(array, mc, mc.cachedSchema()); + return mc; + } + + public byte[] serialize(MediaContent content) throws Exception + { + try + { + return ProtobufIOUtil.toByteArray(content, content.cachedSchema(), buffer); + } + finally + { + buffer.clear(); + } + } + + public String getName() + { + return "protobuf/protostuff"; + } + + }; + + public static final Serializer ProtostuffRuntimeMediaSerializer = + new Serializer() + { + + final Schema schema = RuntimeSchema.getSchema(data.media.MediaContent.class); + final LinkedBuffer buffer = LinkedBuffer.allocate(BUFFER_SIZE); + + public data.media.MediaContent deserialize(byte[] array) throws Exception + { + data.media.MediaContent mc = new data.media.MediaContent(); + ProtostuffIOUtil.mergeFrom(array, mc, schema); + return mc; + } + + public byte[] serialize(data.media.MediaContent content) throws Exception + { + try + { + return ProtostuffIOUtil.toByteArray(content, schema, buffer); + } + finally + { + buffer.clear(); + } + } + + public String getName() + { + return "protostuff-runtime"; + } + + }; + + public static final Serializer ProtobufRuntimeMediaSerializer = + new Serializer() + { + + final Schema schema = RuntimeSchema.getSchema(data.media.MediaContent.class); + final LinkedBuffer buffer = LinkedBuffer.allocate(BUFFER_SIZE); + + public data.media.MediaContent deserialize(byte[] array) throws Exception + { + data.media.MediaContent mc = new data.media.MediaContent(); + ProtobufIOUtil.mergeFrom(array, mc, schema); + return mc; + } + + public byte[] serialize(data.media.MediaContent content) throws Exception + { + try + { + return ProtobufIOUtil.toByteArray(content, schema, buffer); + } + finally + { + buffer.clear(); + } + } + + public String getName() + { + return "protobuf/protostuff-runtime"; + } + + }; + + public static final Serializer ProtostuffManualMediaSerializer = + new Serializer() + { + final LinkedBuffer buffer = LinkedBuffer.allocate(BUFFER_SIZE); + + public data.media.MediaContent deserialize(byte[] array) throws Exception + { + data.media.MediaContent mc = new data.media.MediaContent(); + ProtostuffIOUtil.mergeFrom(array, mc, MEDIA_CONTENT_SCHEMA); + return mc; + } + + public byte[] serialize(data.media.MediaContent content) throws Exception + { + try + { + return ProtostuffIOUtil.toByteArray(content, MEDIA_CONTENT_SCHEMA, buffer); + } + finally + { + buffer.clear(); + } + } + + public String getName() + { + return "protostuff-manual"; + } + + }; + + public static final Serializer ProtostuffGraphMediaSerializer = + new Serializer() + { + final LinkedBuffer buffer = LinkedBuffer.allocate(BUFFER_SIZE); + + public MediaContent deserialize(byte[] array) throws Exception + { + final MediaContent mc = new MediaContent(); + GraphIOUtil.mergeFrom(array, mc, mc.cachedSchema()); + return mc; + } + + public byte[] serialize(MediaContent content) throws Exception + { + try + { + return GraphIOUtil.toByteArray(content, content.cachedSchema(), buffer); + } + finally + { + buffer.clear(); + } + } + + public String getName() + { + return "protostuff-graph"; + } + }; + + public static final Serializer ProtostuffGraphManualMediaSerializer = + new Serializer() + { + final LinkedBuffer buffer = LinkedBuffer.allocate(BUFFER_SIZE); + + public data.media.MediaContent deserialize(byte[] array) throws Exception + { + data.media.MediaContent mc = new data.media.MediaContent(); + GraphIOUtil.mergeFrom(array, mc, MEDIA_CONTENT_SCHEMA); + return mc; + } + + public byte[] serialize(data.media.MediaContent content) throws Exception + { + try + { + return GraphIOUtil.toByteArray(content, MEDIA_CONTENT_SCHEMA, buffer); + } + finally + { + buffer.clear(); + } + } + + public String getName() + { + return "protostuff-graph-manual"; + } + + }; + + public static final Serializer ProtostuffGraphRuntimeMediaSerializer = + new Serializer() + { + final LinkedBuffer buffer = LinkedBuffer.allocate(BUFFER_SIZE); + final Schema schema = RuntimeSchema.getSchema(data.media.MediaContent.class); + + public data.media.MediaContent deserialize(byte[] array) throws Exception + { + data.media.MediaContent mc = new data.media.MediaContent(); + GraphIOUtil.mergeFrom(array, mc, schema); + return mc; + } + + public byte[] serialize(data.media.MediaContent content) throws Exception + { + try + { + return GraphIOUtil.toByteArray(content, schema, buffer); + } + finally + { + buffer.clear(); + } + } + + public String getName() + { + return "protostuff-graph-runtime"; + } + + }; + + static final Schema MEDIA_CONTENT_SCHEMA = new Schema() + { + // schema methods + + public data.media.MediaContent newMessage() + { + return new data.media.MediaContent(); + } + + public Class typeClass() + { + return data.media.MediaContent.class; + } + + public String messageName() + { + return data.media.MediaContent.class.getSimpleName(); + } + + public String messageFullName() + { + return data.media.MediaContent.class.getName(); + } + + public boolean isInitialized(data.media.MediaContent message) + { + return true; + } + + public void mergeFrom(Input input, data.media.MediaContent message) throws IOException + { + for(int number = input.readFieldNumber(this);; number = input.readFieldNumber(this)) + { + switch(number) + { + case 0: + return; + case 1: + if(message.images == null) + message.images = new ArrayList(); + message.images.add(input.mergeObject(null, IMAGE_SCHEMA)); + break; + + case 2: + message.media = input.mergeObject(message.media, MEDIA_SCHEMA); + break; + + default: + input.handleUnknownField(number, this); + } + } + } + + + public void writeTo(Output output, data.media.MediaContent message) throws IOException + { + for(data.media.Image image : message.images) + output.writeObject(1, image, IMAGE_SCHEMA, true); + + output.writeObject(2, message.media, MEDIA_SCHEMA, false); + + } + + public String getFieldName(int number) + { + switch(number) + { + case 1: return "image"; + case 2: return "media"; + default: return null; + } + } + + public int getFieldNumber(String name) + { + final Integer number = fieldMap.get(name); + return number == null ? 0 : number.intValue(); + } + + final java.util.HashMap fieldMap = new java.util.HashMap(); + { + fieldMap.put("image", 1); + fieldMap.put("media", 2); + } + }; + + static final Schema MEDIA_SCHEMA = new Schema() + { + // schema methods + + public data.media.Media newMessage() + { + return new data.media.Media(); + } + + public Class typeClass() + { + return data.media.Media.class; + } + + public String messageName() + { + return data.media.Media.class.getSimpleName(); + } + + public String messageFullName() + { + return data.media.Media.class.getName(); + } + + public boolean isInitialized(data.media.Media message) + { + return true; + } + + public void mergeFrom(Input input, data.media.Media message) throws IOException + { + for(int number = input.readFieldNumber(this);; number = input.readFieldNumber(this)) + { + switch(number) + { + case 0: + return; + case 1: + message.uri = input.readString(); + break; + case 2: + message.title = input.readString(); + break; + case 3: + message.width = input.readInt32(); + break; + case 4: + message.height = input.readInt32(); + break; + case 5: + message.format = input.readString(); + break; + case 6: + message.duration = input.readInt64(); + break; + case 7: + message.size = input.readInt64(); + break; + case 8: + message.bitrate = input.readInt32(); + message.hasBitrate = true; + break; + case 9: + if(message.persons == null) + message.persons = new ArrayList(); + message.persons.add(input.readString()); + break; + case 10: + message.player = data.media.Media.Player.values()[input.readEnum()]; + break; + case 11: + message.copyright = input.readString(); + break; + default: + input.handleUnknownField(number, this); + } + } + } + + + public void writeTo(Output output, data.media.Media message) throws IOException + { + output.writeString(1, message.uri, false); + + if(message.title != null) + output.writeString(2, message.title, false); + + output.writeInt32(3, message.width, false); + + output.writeInt32(4, message.height, false); + + output.writeString(5, message.format, false); + + output.writeInt64(6, message.duration, false); + + output.writeInt64(7, message.size, false); + + if(message.hasBitrate) + output.writeInt32(8, message.bitrate, false); + + for(String person : message.persons) + { + output.writeString(9, person, true); + } + + output.writeEnum(10, message.player.ordinal(), false); + + if(message.copyright != null) + output.writeString(11, message.copyright, false); + } + + public String getFieldName(int number) + { + switch(number) + { + case 1: return "uri"; + case 2: return "title"; + case 3: return "width"; + case 4: return "height"; + case 5: return "format"; + case 6: return "duration"; + case 7: return "size"; + case 8: return "bitrate"; + case 9: return "person"; + case 10: return "player"; + case 11: return "copyright"; + default: return null; + } + } + + public int getFieldNumber(String name) + { + final Integer number = fieldMap.get(name); + return number == null ? 0 : number.intValue(); + } + + final java.util.HashMap fieldMap = new java.util.HashMap(); + { + fieldMap.put("uri", 1); + fieldMap.put("title", 2); + fieldMap.put("width", 3); + fieldMap.put("height", 4); + fieldMap.put("format", 5); + fieldMap.put("duration", 6); + fieldMap.put("size", 7); + fieldMap.put("bitrate", 8); + fieldMap.put("person", 9); + fieldMap.put("player", 10); + fieldMap.put("copyright", 11); + } + }; + + static final Schema IMAGE_SCHEMA = new Schema() + { + // schema methods + + public data.media.Image newMessage() + { + return new data.media.Image(); + } + + public Class typeClass() + { + return data.media.Image.class; + } + + public String messageName() + { + return data.media.Image.class.getSimpleName(); + } + + public String messageFullName() + { + return data.media.Image.class.getName(); + } + + public boolean isInitialized(data.media.Image message) + { + return true; + } + + public void mergeFrom(Input input, data.media.Image message) throws IOException + { + for(int number = input.readFieldNumber(this);; number = input.readFieldNumber(this)) + { + switch(number) + { + case 0: + return; + case 1: + message.uri = input.readString(); + break; + case 2: + message.title = input.readString(); + break; + case 3: + message.width = input.readInt32(); + break; + case 4: + message.height = input.readInt32(); + break; + case 5: + message.size = data.media.Image.Size.values()[input.readEnum()]; + break; + default: + input.handleUnknownField(number, this); + } + } + } + + + public void writeTo(Output output, data.media.Image message) throws IOException + { + output.writeString(1, message.uri, false); + + if(message.title != null) + output.writeString(2, message.title, false); + + output.writeInt32(3, message.width, false); + + output.writeInt32(4, message.height, false); + + output.writeEnum(5, message.size.ordinal(), false); + } + + public String getFieldName(int number) + { + switch(number) + { + case 1: return "uri"; + case 2: return "title"; + case 3: return "width"; + case 4: return "height"; + case 5: return "size"; + default: return null; + } + } + + public int getFieldNumber(String name) + { + final Integer number = fieldMap.get(name); + return number == null ? 0 : number.intValue(); + } + + final java.util.HashMap fieldMap = new java.util.HashMap(); + { + fieldMap.put("uri", 1); + fieldMap.put("title", 2); + fieldMap.put("width", 3); + fieldMap.put("height", 4); + fieldMap.put("size", 5); + } + }; + + public static final MediaTransformer mediaTransformer = new MediaTransformer() + { + @Override + public MediaContent[] resultArray(int size) { return new MediaContent[size]; } + + // ---------------------------------------------------------- + // Forward + + public MediaContent forward(data.media.MediaContent mc) + { + MediaContent cb = new MediaContent(forwardMedia(mc.media)); + ArrayList ims = new ArrayList(mc.images.size()); + for (data.media.Image image : mc.images) { + ims.add(forwardImage(image)); + } + + return cb.setImageList(ims); + } + + private Media forwardMedia(data.media.Media media) + { + // Media + return new Media( + media.uri, + media.width, + media.height, + media.format, + media.duration, + media.size, + forwardPlayer(media.player) + ) + .setTitle(media.title) + .setBitrate(media.hasBitrate ? media.bitrate : null) + .setPersonList(new ArrayList(media.persons)) + .setCopyright(media.copyright); + } + + public Media.Player forwardPlayer(data.media.Media.Player p) + { + switch (p) { + case JAVA: return Media.Player.JAVA; + case FLASH: return Media.Player.FLASH; + default: + throw new AssertionError("invalid case: " + p); + } + } + + private Image forwardImage(data.media.Image image) + { + return new Image( + image.uri, + image.width, + image.height, + forwardSize(image.size) + ) + .setTitle(image.title); + } + + public Image.Size forwardSize(data.media.Image.Size s) + { + switch (s) { + case SMALL: return Image.Size.SMALL; + case LARGE: return Image.Size.LARGE; + default: + throw new AssertionError("invalid case: " + s); + } + } + + // ---------------------------------------------------------- + // Reverse + + public data.media.MediaContent reverse(MediaContent mc) + { + List ims = mc.getImageList(); + List images = new ArrayList(ims.size()); + + for (Image image : ims) { + images.add(reverseImage(image)); + } + + return new data.media.MediaContent(reverseMedia(mc.getMedia()), images); + } + + private data.media.Media reverseMedia(Media media) + { + + Integer bitRate = media.getBitrate(); + // Media + return new data.media.Media( + media.getUri(), + media.getTitle(), + media.getWidth(), + media.getHeight(), + media.getFormat(), + media.getDuration(), + media.getSize(), + bitRate == null ? 0 : bitRate, + bitRate != null, + new ArrayList(media.getPersonList()), + reversePlayer(media.getPlayer()), + media.getCopyright() + ); + } + + public data.media.Media.Player reversePlayer(Media.Player p) + { + switch (p) { + case JAVA: return data.media.Media.Player.JAVA; + case FLASH: return data.media.Media.Player.FLASH; + default: + throw new AssertionError("invalid case: " + p); + } + } + + private data.media.Image reverseImage(Image image) + { + return new data.media.Image( + image.getUri(), + image.getTitle(), + image.getWidth(), + image.getHeight(), + reverseSize(image.getSize())); + } + + public data.media.Image.Size reverseSize(Image.Size s) + { + switch (s) { + case SMALL: return data.media.Image.Size.SMALL; + case LARGE: return data.media.Image.Size.LARGE; + default: + throw new AssertionError("invalid case: " + s); + } + } + + public data.media.MediaContent shallowReverse(MediaContent mc) + { + return new data.media.MediaContent(reverseMedia(mc.getMedia()), Collections.emptyList()); + } + }; + +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/protostuff/ProtostuffJson.java b/jvm-serializers-tpc/src/main/java/serializers/protostuff/ProtostuffJson.java new file mode 100644 index 0000000..f49c273 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/protostuff/ProtostuffJson.java @@ -0,0 +1,255 @@ +package serializers.protostuff; + +import static serializers.protostuff.Protostuff.MEDIA_CONTENT_SCHEMA; + +import com.dyuproject.protostuff.LinkedBuffer; +import com.dyuproject.protostuff.JsonIOUtil; +import com.dyuproject.protostuff.JsonXIOUtil; +import com.dyuproject.protostuff.Schema; +import com.dyuproject.protostuff.runtime.RuntimeSchema; + +import serializers.*; +import serializers.protostuff.media.MediaContent; + +/** + * @author David Yu + * @created Oct 26, 2009 + */ + +public final class ProtostuffJson +{ + + public static void register(TestGroups groups) + { + // manual (hand-coded schema, no autoboxing) + groups.media.add(JavaBuiltIn.mediaTransformer, JsonManualMediaSerializer, + new SerFeatures( + SerFormat.JSON, + SerGraph.FLAT_TREE, + SerClass.MANUAL_OPT, + "json + manual" + ) + ); + // runtime (reflection) + groups.media.add(JavaBuiltIn.mediaTransformer, JsonRuntimeMediaSerializer, + new SerFeatures( + SerFormat.JSON, + SerGraph.FLAT_TREE, + SerClass.ZERO_KNOWLEDGE, + "json + reflection" + ) + ); + + /* protostuff has too many entries + + // generated code + groups.media.add(Protostuff.mediaTransformer, JsonMediaSerializer, + new SerFeatures( + SerFormat.JSON, + SerGraph.FLAT_TREE, + SerClass.CLASSES_KNOWN, + "json + generated code" + ) + ); + + // generated code, numeric + groups.media.add(Protostuff.mediaTransformer, JsonMediaSerializerNumeric, + new SerFeatures( + SerFormat.JSON, + SerGraph.FLAT_TREE, + SerClass.CLASSES_KNOWN, + "json + numeric + generated code" + ) + ); + + // manual, numeric (hand-coded schema, no autoboxing) + groups.media.add(JavaBuiltIn.mediaTransformer, JsonManualMediaSerializerNumeric, + new SerFeatures( + SerFormat.JSON, + SerGraph.FLAT_TREE, + SerClass.MANUAL_OPT, + "json + numeric + manual" + ) + ); + + // runtime, numeric (reflection) + groups.media.add(JavaBuiltIn.mediaTransformer, JsonRuntimeMediaSerializerNumeric, + new SerFeatures( + SerFormat.JSON, + SerGraph.FLAT_TREE, + SerClass.ZERO_KNOWLEDGE, + "json + numeric + reflection" + ) + ); + */ + } + + public static final Serializer JsonMediaSerializer = + new Serializer() + { + + public MediaContent deserialize(byte[] array) throws Exception + { + MediaContent mc = new MediaContent(); + JsonIOUtil.mergeFrom(array, mc, mc.cachedSchema(), false); + return mc; + } + + public byte[] serialize(MediaContent content) throws Exception + { + return JsonIOUtil.toByteArray(content, content.cachedSchema(), false); + } + + public String getName() + { + return "json/protostuff"; + } + + }; + + public static final Serializer JsonMediaSerializerNumeric = + new Serializer() + { + + final LinkedBuffer buffer = LinkedBuffer.allocate(512); + + public MediaContent deserialize(byte[] array) throws Exception + { + MediaContent mc = new MediaContent(); + JsonIOUtil.mergeFrom(array, mc, mc.cachedSchema(), true); + return mc; + } + + public byte[] serialize(MediaContent content) throws Exception + { + try + { + return JsonXIOUtil.toByteArray(content, content.cachedSchema(), true, buffer); + } + finally + { + buffer.clear(); + } + } + + public String getName() + { + return "json/protostuff+numeric"; + } + + }; + + public static final Serializer JsonRuntimeMediaSerializer = + new Serializer() + { + + final Schema schema = RuntimeSchema.getSchema(data.media.MediaContent.class); + + public data.media.MediaContent deserialize(byte[] array) throws Exception + { + data.media.MediaContent mc = new data.media.MediaContent(); + JsonIOUtil.mergeFrom(array, mc, schema, false); + return mc; + } + + public byte[] serialize(data.media.MediaContent content) throws Exception + { + return JsonIOUtil.toByteArray(content, schema, false); + } + + public String getName() + { + return "json/protostuff-runtime"; + } + + }; + + public static final Serializer JsonRuntimeMediaSerializerNumeric = + new Serializer() + { + + final LinkedBuffer buffer = LinkedBuffer.allocate(512); + + final Schema schema = RuntimeSchema.getSchema(data.media.MediaContent.class); + + public data.media.MediaContent deserialize(byte[] array) throws Exception + { + data.media.MediaContent mc = new data.media.MediaContent(); + JsonIOUtil.mergeFrom(array, mc, schema, true); + return mc; + } + + public byte[] serialize(data.media.MediaContent content) throws Exception + { + try + { + return JsonXIOUtil.toByteArray(content, schema, true, buffer); + } + finally + { + buffer.clear(); + } + } + + public String getName() + { + return "json/protostuff-runtime+numeric"; + } + + }; + + public static final Serializer JsonManualMediaSerializer = + new Serializer() + { + + public data.media.MediaContent deserialize(byte[] array) throws Exception + { + data.media.MediaContent mc = new data.media.MediaContent(); + JsonIOUtil.mergeFrom(array, mc, MEDIA_CONTENT_SCHEMA, false); + return mc; + } + + public byte[] serialize(data.media.MediaContent content) throws Exception + { + return JsonIOUtil.toByteArray(content, MEDIA_CONTENT_SCHEMA, false); + } + + public String getName() + { + return "json/protostuff-manual"; + } + + }; + + public static final Serializer JsonManualMediaSerializerNumeric = + new Serializer() + { + + final LinkedBuffer buffer = LinkedBuffer.allocate(512); + + public data.media.MediaContent deserialize(byte[] array) throws Exception + { + data.media.MediaContent mc = new data.media.MediaContent(); + JsonIOUtil.mergeFrom(array, mc, MEDIA_CONTENT_SCHEMA, true); + return mc; + } + + public byte[] serialize(data.media.MediaContent content) throws Exception + { + try + { + return JsonXIOUtil.toByteArray(content, MEDIA_CONTENT_SCHEMA, true, buffer); + } + finally + { + buffer.clear(); + } + } + + public String getName() + { + return "json/protostuff-manual+numeric"; + } + + }; +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/protostuff/ProtostuffSmile.java b/jvm-serializers-tpc/src/main/java/serializers/protostuff/ProtostuffSmile.java new file mode 100644 index 0000000..1c20238 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/protostuff/ProtostuffSmile.java @@ -0,0 +1,125 @@ +package serializers.protostuff; + +import static serializers.protostuff.Protostuff.MEDIA_CONTENT_SCHEMA; + +import com.dyuproject.protostuff.Schema; +import com.dyuproject.protostuff.SmileIOUtil; +import com.dyuproject.protostuff.runtime.RuntimeSchema; + +import serializers.*; +import serializers.protostuff.media.MediaContent; + +/** + * @author David Yu + * @created Jan 18, 2011 + */ + +public final class ProtostuffSmile +{ + + public static void register(TestGroups groups) + { + // manual (hand-coded schema, no autoboxing) + groups.media.add(JavaBuiltIn.mediaTransformer, SmileManualMediaSerializer, + new SerFeatures( + SerFormat.BINARY, + SerGraph.FLAT_TREE, + SerClass.MANUAL_OPT, + "smile + manual" + ) + ); + // runtime (reflection) + groups.media.add(JavaBuiltIn.mediaTransformer, SmileRuntimeMediaSerializer, + new SerFeatures( + SerFormat.BINARY, + SerGraph.FLAT_TREE, + SerClass.ZERO_KNOWLEDGE, + "smile + reflection" + ) + ); + + /* protostuff has too many entries + + // generated code + groups.media.add(Protostuff.mediaTransformer, SmileMediaSerializer, + new SerFeatures( + SerFormat.BINARY, + SerGraph.FLAT_TREE, + SerClass.CLASSES_KNOWN, + "smile + generated code" + ) + ); + */ + } + + public static final Serializer SmileMediaSerializer = + new Serializer() + { + + public MediaContent deserialize(byte[] array) throws Exception + { + final MediaContent mc = new MediaContent(); + SmileIOUtil.mergeFrom(array, mc, mc.cachedSchema(), false); + return mc; + } + + public byte[] serialize(MediaContent content) throws Exception + { + return SmileIOUtil.toByteArray(content, content.cachedSchema(), false); + } + + public String getName() + { + return "smile/protostuff"; + } + + }; + + public static final Serializer SmileRuntimeMediaSerializer = + new Serializer() + { + + final Schema schema = RuntimeSchema.getSchema(data.media.MediaContent.class); + + public data.media.MediaContent deserialize(byte[] array) throws Exception + { + final data.media.MediaContent mc = new data.media.MediaContent(); + SmileIOUtil.mergeFrom(array, mc, schema, false); + return mc; + } + + public byte[] serialize(data.media.MediaContent content) throws Exception + { + return SmileIOUtil.toByteArray(content, schema, false); + } + + public String getName() + { + return "smile/protostuff-runtime"; + } + + }; + + public static final Serializer SmileManualMediaSerializer = + new Serializer() + { + + public data.media.MediaContent deserialize(byte[] array) throws Exception + { + final data.media.MediaContent mc = new data.media.MediaContent(); + SmileIOUtil.mergeFrom(array, mc, MEDIA_CONTENT_SCHEMA, false); + return mc; + } + + public byte[] serialize(data.media.MediaContent content) throws Exception + { + return SmileIOUtil.toByteArray(content, MEDIA_CONTENT_SCHEMA, false); + } + + public String getName() + { + return "smile/protostuff-manual"; + } + + }; +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/protostuff/ProtostuffXml.java b/jvm-serializers-tpc/src/main/java/serializers/protostuff/ProtostuffXml.java new file mode 100644 index 0000000..463b5aa --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/protostuff/ProtostuffXml.java @@ -0,0 +1,112 @@ +package serializers.protostuff; + +import static serializers.protostuff.Protostuff.MEDIA_CONTENT_SCHEMA; + +import com.dyuproject.protostuff.XmlIOUtil; +import com.dyuproject.protostuff.Schema; +import com.dyuproject.protostuff.runtime.RuntimeSchema; + +import serializers.*; +import serializers.protostuff.media.MediaContent; + +public final class ProtostuffXml +{ + + public static void register(TestGroups groups) + { + // manual (hand-coded schema, no autoboxing) + groups.media.add(JavaBuiltIn.mediaTransformer, XmlManualMediaSerializer, + new SerFeatures( + SerFormat.XML, + SerGraph.FLAT_TREE, + SerClass.MANUAL_OPT, + "" + ) + ); + // runtime (reflection) + groups.media.add(JavaBuiltIn.mediaTransformer, XmlRuntimeMediaSerializer, + new SerFeatures( + SerFormat.XML, + SerGraph.FLAT_TREE, + SerClass.ZERO_KNOWLEDGE, + "" + ) + ); + + /* protostuff has too many entries + + // generated code + groups.media.add(Protostuff.MediaTransformer, XmlMediaSerializer);*/ + } + + public static final Serializer XmlMediaSerializer = + new Serializer() + { + + public MediaContent deserialize(byte[] array) throws Exception + { + MediaContent mc = new MediaContent(); + XmlIOUtil.mergeFrom(array, mc, mc.cachedSchema()); + return mc; + } + + public byte[] serialize(MediaContent content) throws Exception + { + return XmlIOUtil.toByteArray(content, content.cachedSchema()); + } + + public String getName() + { + return "xml/protostuff"; + } + + }; + + public static final Serializer XmlRuntimeMediaSerializer = + new Serializer() + { + + final Schema schema = RuntimeSchema.getSchema(data.media.MediaContent.class); + + public data.media.MediaContent deserialize(byte[] array) throws Exception + { + data.media.MediaContent mc = new data.media.MediaContent(); + XmlIOUtil.mergeFrom(array, mc, schema); + return mc; + } + + public byte[] serialize(data.media.MediaContent content) throws Exception + { + return XmlIOUtil.toByteArray(content, schema); + } + + public String getName() + { + return "xml/protostuff-runtime"; + } + + }; + + public static final Serializer XmlManualMediaSerializer = + new Serializer() + { + + public data.media.MediaContent deserialize(byte[] array) throws Exception + { + data.media.MediaContent mc = new data.media.MediaContent(); + XmlIOUtil.mergeFrom(array, mc, MEDIA_CONTENT_SCHEMA); + return mc; + } + + public byte[] serialize(data.media.MediaContent content) throws Exception + { + return XmlIOUtil.toByteArray(content, MEDIA_CONTENT_SCHEMA); + } + + public String getName() + { + return "xml/protostuff-manual"; + } + + }; +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/scala/media/Image.scala b/jvm-serializers-tpc/src/main/java/serializers/scala/media/Image.scala new file mode 100644 index 0000000..b32ff62 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/scala/media/Image.scala @@ -0,0 +1,16 @@ +package serializers.scala.media + +case class Image( + uri: String, + title: Option[String], + width: Int, + height: Int, + size: Image.Size) extends Serializable + +object Image { + sealed abstract class Size + object Size { + case object Small extends Size + case object Large extends Size + } +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/scala/media/Media.scala b/jvm-serializers-tpc/src/main/java/serializers/scala/media/Media.scala new file mode 100644 index 0000000..14ae6a9 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/scala/media/Media.scala @@ -0,0 +1,22 @@ +package serializers.scala.media + +case class Media ( + val uri: String, + val title: Option[String], + val width: Int, + val height: Int, + val format: String, + val duration: Long, + val size: Long, + val bitrate: Option[Int], + val persons: List[String], + val player: Media.Player, + val copyright: Option[String]) extends Serializable + +object Media { + sealed abstract class Player + object Player { + case object Java extends Media.Player + case object Flash extends Media.Player + } +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/scala/media/MediaContent.scala b/jvm-serializers-tpc/src/main/java/serializers/scala/media/MediaContent.scala new file mode 100644 index 0000000..34fb6c3 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/scala/media/MediaContent.scala @@ -0,0 +1,3 @@ +package serializers.scala.media + +case class MediaContent (val media: Media, val images: List[Image]) extends Serializable diff --git a/jvm-serializers-tpc/src/main/java/serializers/stephenerialization/Image.java b/jvm-serializers-tpc/src/main/java/serializers/stephenerialization/Image.java new file mode 100644 index 0000000..ca5f1d2 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/stephenerialization/Image.java @@ -0,0 +1,142 @@ +package serializers.stephenerialization; + +import static data.ReprUtil.repr; + +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; + +import com.enragedginger.stephenerialization.StephenerializationLookupService; +import com.enragedginger.stephenerialization.StephenerializationService; +import com.enragedginger.stephenerialization.annotations.Stephenerializable; +import com.enragedginger.stephenerialization.annotations.Stephenerialize; + +@Stephenerializable(version = 20121225) +public class Image implements java.io.Serializable +{ + private static final long serialVersionUID = 1L; + + public enum Size { + SMALL, LARGE + } + + @Stephenerialize(minVersion = 20121225, priority = 1) + public String uri; + @Stephenerialize(minVersion = 20121225, priority = 2) + public String title; // Can be null + @Stephenerialize(minVersion = 20121225, priority = 3) + public int width; + @Stephenerialize(minVersion = 20121225, priority = 4) + public int height; + @Stephenerialize(minVersion = 20121225, priority = 5) + public Size size; + + public Image() {} + + public Image (String uri, String title, int width, int height, Size size) { + this.height = height; + this.title = title; + this.uri = uri; + this.width = width; + this.size = size; + } + + @Override + public boolean equals(Object o) + { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + Image image = (Image) o; + + if (height != image.height) return false; + if (width != image.width) return false; + if (size != image.size) return false; + if (title != null ? !title.equals(image.title) : image.title != null) return false; + if (uri != null ? !uri.equals(image.uri) : image.uri != null) return false; + + return true; + } + + @Override + public int hashCode() + { + int result = uri != null ? uri.hashCode() : 0; + result = 31 * result + (title != null ? title.hashCode() : 0); + result = 31 * result + width; + result = 31 * result + height; + result = 31 * result + (size != null ? size.hashCode() : 0); + return result; + } + + public String toString () { + StringBuilder sb = new StringBuilder(); + sb.append("[Image "); + sb.append("uri=").append(repr(uri)); + sb.append(", title=").append(repr(title)); + sb.append(", width=").append(width); + sb.append(", height=").append(height); + sb.append(", size=").append(size); + sb.append("]"); + return sb.toString(); + } + + public void setUri(String uri) { + this.uri = uri; + } + + public void setTitle(String title) { + this.title = title; + } + + public void setWidth(int width) { + this.width = width; + } + + public void setHeight(int height) { + this.height = height; + } + + public void setSize(Size size) { + this.size = size; + } + + public String getUri() { + return uri; + } + + public String getTitle() { + return title; + } + + public int getWidth() { + return width; + } + + public int getHeight() { + return height; + } + + public Size getSize() { + return size; + } + + /** + * Writes this object out to the stream using Stephenerialization. + * @param streamer The output stream to use. + */ + private void writeObject(ObjectOutputStream streamer) { + ImageStephenerializer.stephenerialize(this, streamer); + /*final StephenerializationService service = StephenerializationLookupService.lookup(); + service.stephenerialize(this, streamer, Image.class);*/ + } + + /** + * Reads this object from the stream using Stephenerialization. + * @param streamer The input stream to use. + */ + private void readObject(ObjectInputStream streamer) { + ImageStephenerializer.destephenerialize(this, streamer); + /*final StephenerializationService service = StephenerializationLookupService.lookup(); + service.destephenerialize(this, streamer, Image.class);*/ + } +} \ No newline at end of file diff --git a/jvm-serializers-tpc/src/main/java/serializers/stephenerialization/Media.java b/jvm-serializers-tpc/src/main/java/serializers/stephenerialization/Media.java new file mode 100644 index 0000000..c026a55 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/stephenerialization/Media.java @@ -0,0 +1,256 @@ +package serializers.stephenerialization; + +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.util.List; + +import com.enragedginger.stephenerialization.StephenerializationLookupService; +import com.enragedginger.stephenerialization.StephenerializationService; +import com.enragedginger.stephenerialization.annotations.Stephenerializable; +import com.enragedginger.stephenerialization.annotations.Stephenerialize; + +import static data.ReprUtil.repr; + +@Stephenerializable(version = 20121225) +public class Media implements java.io.Serializable { + + private static final long serialVersionUID = 1L; + + public enum Player { + JAVA, FLASH; + + public static Player find(String str) { + if (str == "JAVA") return JAVA; + if (str == "FLASH") return FLASH; + if ("JAVA".equals(str)) return JAVA; + if ("FLASH".equals(str)) return FLASH; + String desc = (str == null) ? "NULL" : String.format("'%s'", str); + throw new IllegalArgumentException("No Player value of "+desc); + } + } + + @Stephenerialize(minVersion = 20121225, priority = 1) + public String uri; + @Stephenerialize(minVersion = 20121225, priority = 2) + public String title; // Can be unset. + @Stephenerialize(minVersion = 20121225, priority = 3) + public int width; + @Stephenerialize(minVersion = 20121225, priority = 4) + public int height; + @Stephenerialize(minVersion = 20121225, priority = 5) + public String format; + @Stephenerialize(minVersion = 20121225, priority = 6) + public long duration; + @Stephenerialize(minVersion = 20121225, priority = 7) + public long size; + @Stephenerialize(minVersion = 20121225, priority = 8) + public int bitrate; // Can be unset. + + @Stephenerialize(minVersion = 20121225, priority = 9) + public boolean hasBitrate; + + @Stephenerialize(minVersion = 20121225, priority = 10) + public List persons; + + @Stephenerialize(minVersion = 20121225, priority = 11) + public Player player; + + @Stephenerialize(minVersion = 20121225, priority = 12) + public String copyright; // Can be unset. + + public Media() {} + + public Media(String uri, String title, int width, int height, String format, long duration, long size, int bitrate, boolean hasBitrate, List persons, Player player, String copyright) + { + this.uri = uri; + this.title = title; + this.width = width; + this.height = height; + this.format = format; + this.duration = duration; + this.size = size; + this.bitrate = bitrate; + this.hasBitrate = hasBitrate; + this.persons = persons; + this.player = player; + this.copyright = copyright; + } + + @Override + public boolean equals(Object o) + { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + Media media = (Media) o; + + if (bitrate != media.bitrate) return false; + if (duration != media.duration) return false; + if (hasBitrate != media.hasBitrate) return false; + if (height != media.height) return false; + if (size != media.size) return false; + if (width != media.width) return false; + if (copyright != null ? !copyright.equals(media.copyright) : media.copyright != null) return false; + if (format != null ? !format.equals(media.format) : media.format != null) return false; + if (persons != null ? !persons.equals(media.persons) : media.persons != null) return false; + if (player != media.player) return false; + if (title != null ? !title.equals(media.title) : media.title != null) return false; + if (uri != null ? !uri.equals(media.uri) : media.uri != null) return false; + + return true; + } + + @Override + public int hashCode() + { + int result = uri != null ? uri.hashCode() : 0; + result = 31 * result + (title != null ? title.hashCode() : 0); + result = 31 * result + width; + result = 31 * result + height; + result = 31 * result + (format != null ? format.hashCode() : 0); + result = 31 * result + (int) (duration ^ (duration >>> 32)); + result = 31 * result + (int) (size ^ (size >>> 32)); + result = 31 * result + bitrate; + result = 31 * result + (hasBitrate ? 1 : 0); + result = 31 * result + (persons != null ? persons.hashCode() : 0); + result = 31 * result + (player != null ? player.hashCode() : 0); + result = 31 * result + (copyright != null ? copyright.hashCode() : 0); + return result; + } + + public String toString () { + StringBuilder sb = new StringBuilder(); + sb.append("[Media "); + sb.append("uri=").append(repr(uri)); + sb.append(", title=").append(repr(title)); + sb.append(", width=").append(width); + sb.append(", height=").append(height); + sb.append(", format=").append(repr(format)); + sb.append(", duration=").append(duration); + sb.append(", size=").append(size); + sb.append(", hasBitrate=").append(hasBitrate); + sb.append(", bitrate=").append(String.valueOf(bitrate)); + sb.append(", persons=").append(repr(persons)); + sb.append(", player=").append(player); + sb.append(", copyright=").append(repr(copyright)); + sb.append("]"); + return sb.toString(); + } + + public void setUri(String uri) { + this.uri = uri; + } + + public void setTitle(String title) { + this.title = title; + } + + public void setWidth(int width) { + this.width = width; + } + + public void setHeight(int height) { + this.height = height; + } + + public void setFormat(String format) { + this.format = format; + } + + public void setDuration(long duration) { + this.duration = duration; + } + + public void setSize(long size) { + this.size = size; + } + + public void setBitrate(int bitrate) { + this.bitrate = bitrate; + this.hasBitrate = true; + } + + public void setPersons(List persons) { + this.persons = persons; + } + + public void setPlayer(Player player) { + this.player = player; + } + + public void setCopyright(String copyright) { + this.copyright = copyright; + } + + public String getUri() { + return uri; + } + + public String getTitle() { + return title; + } + + public int getWidth() { + return width; + } + + public int getHeight() { + return height; + } + + public String getFormat() { + return format; + } + + public long getDuration() { + return duration; + } + + public long getSize() { + return size; + } + + public int getBitrate() { + return bitrate; + } + + public List getPersons() { + return persons; + } + + public Player getPlayer() { + return player; + } + + public String getCopyright() { + return copyright; + } + + public boolean isHasBitrate() { + return hasBitrate; + } + + public void setHasBitrate(boolean hasBitrate) { + this.hasBitrate = hasBitrate; + } + + /** + * Writes this object out to the stream using Stephenerialization. + * @param streamer The output stream to use. + */ + private void writeObject(ObjectOutputStream streamer) { + MediaStephenerializer.stephenerialize(this, streamer); + /*final StephenerializationService service = StephenerializationLookupService.lookup(); + service.stephenerialize(this, streamer, Media.class);*/ + } + + /** + * Reads this object from the stream using Stephenerialization. + * @param streamer The input stream to use. + */ + private void readObject(ObjectInputStream streamer) { + MediaStephenerializer.destephenerialize(this, streamer); + /*final StephenerializationService service = StephenerializationLookupService.lookup(); + service.destephenerialize(this, streamer, Media.class);*/ + } +} \ No newline at end of file diff --git a/jvm-serializers-tpc/src/main/java/serializers/stephenerialization/MediaContent.java b/jvm-serializers-tpc/src/main/java/serializers/stephenerialization/MediaContent.java new file mode 100644 index 0000000..587154d --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/stephenerialization/MediaContent.java @@ -0,0 +1,96 @@ +package serializers.stephenerialization; + +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.util.List; + +import com.enragedginger.stephenerialization.StephenerializationLookupService; +import com.enragedginger.stephenerialization.StephenerializationService; +import com.enragedginger.stephenerialization.annotations.Stephenerializable; +import com.enragedginger.stephenerialization.annotations.Stephenerialize; + +@Stephenerializable(version = 20121225) +public class MediaContent implements java.io.Serializable +{ + + private static final long serialVersionUID = 1L; + + @Stephenerialize(minVersion = 20121225, priority = 1) + public Media media; + @Stephenerialize(minVersion = 20121225, priority = 2) + public List images; + + public MediaContent() {} + + public MediaContent (Media media, List images) { + this.media = media; + this.images = images; + } + + @Override + public boolean equals(Object o) + { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + MediaContent that = (MediaContent) o; + + if (images != null ? !images.equals(that.images) : that.images != null) return false; + if (media != null ? !media.equals(that.media) : that.media != null) return false; + + return true; + } + + @Override + public int hashCode() + { + int result = media != null ? media.hashCode() : 0; + result = 31 * result + (images != null ? images.hashCode() : 0); + return result; + } + + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("[MediaContent: "); + sb.append("media=").append(media); + sb.append(", images=").append(images); + sb.append("]"); + return sb.toString(); + } + + public void setMedia(Media media) { + this.media = media; + } + + public void setImages(List images) { + this.images = images; + } + + public Media getMedia() { + return media; + } + + public List getImages() { + return images; + } + + /** + * Writes this object out to the stream using Stephenerialization. + * @param streamer The output stream to use. + */ + private void writeObject(ObjectOutputStream streamer) { + MediaContentStephenerializer.stephenerialize(this, streamer); + /*final StephenerializationService service = StephenerializationLookupService.lookup(); + service.stephenerialize(this, streamer, MediaContent.class);*/ + } + + /** + * Reads this object from the stream using Stephenerialization. + * @param streamer The input stream to use. + */ + private void readObject(ObjectInputStream streamer) { + MediaContentStephenerializer.destephenerialize(this, streamer); + /*final StephenerializationService service = StephenerializationLookupService.lookup(); + service.destephenerialize(this, streamer, MediaContent.class);*/ + } +} \ No newline at end of file diff --git a/jvm-serializers-tpc/src/main/java/serializers/wobly/Wobly.java b/jvm-serializers-tpc/src/main/java/serializers/wobly/Wobly.java new file mode 100644 index 0000000..9dc4f1e --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/wobly/Wobly.java @@ -0,0 +1,32 @@ +package serializers.wobly; + +import serializers.SerClass; +import serializers.SerFeatures; +import serializers.SerFormat; +import serializers.SerGraph; +import serializers.TestGroups; +import serializers.wobly.compact.WoblyCompactUtils; +import serializers.wobly.simple.WoblySimpleUtils; + +public class Wobly { + public static void register(TestGroups groups) + { + groups.media.add(new WoblySimpleUtils.WoblyTransformer(), new WoblySimpleUtils.WoblySerializer(), + new SerFeatures( + SerFormat.BINARY, + SerGraph.FLAT_TREE, + SerClass.MANUAL_OPT, + "" + ) + ); + groups.media.add(new WoblyCompactUtils.WoblyTransformer(), new WoblyCompactUtils.WoblySerializer(), + new SerFeatures( + SerFormat.BINARY, + SerGraph.FLAT_TREE, + SerClass.MANUAL_OPT, + "" + ) + ); + } + +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/wobly/compact/WImage.java b/jvm-serializers-tpc/src/main/java/serializers/wobly/compact/WImage.java new file mode 100644 index 0000000..dc48fcd --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/wobly/compact/WImage.java @@ -0,0 +1,197 @@ +package serializers.wobly.compact; + +import com.wowd.wobly.WoblyUtils.Format; +import com.wowd.wobly.WoblyImpl; +import com.wowd.wobly.annotations.WoblyField; +import com.wowd.wobly.annotations.WoblyTypeOptions; + +import data.media.Image.Size; + + + +@WoblyTypeOptions(specialFormat = Format.BYTES_SIZE_COMPRESSED) +public class WImage extends WoblyImpl +{ + + @WoblyField(id = -1, required = true) + String uri; + @WoblyField(id = 0) + String title; + @WoblyField(id = -2, required = true, specialFormat = Format.NUMBER_COMPRESSED) + int width; + @WoblyField(id = -3, required = true, specialFormat = Format.NUMBER_COMPRESSED) + int height; + @WoblyField(id = -4, required = true) + Size size; + + public WImage(String uri, String title, int width, int height, Size size) + { + this.uri = uri; + this.title = title; + this.width = width; + this.height = height; + this.size = size; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + height; + result = prime * result + ((size == null) ? 0 : size.hashCode()); + result = prime * result + ((title == null) ? 0 : title.hashCode()); + result = prime * result + ((uri == null) ? 0 : uri.hashCode()); + result = prime * result + width; + return result; + } + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + WImage other = (WImage) obj; + if (height != other.height) + return false; + if (size != other.size) + return false; + if (title == null) { + if (other.title != null) + return false; + } else if (!title.equals(other.title)) + return false; + if (uri == null) { + if (other.uri != null) + return false; + } else if (!uri.equals(other.uri)) + return false; + if (width != other.width) + return false; + return true; + } + + + + //-------------- WOBLY AUTO GENERATED CODE FOR SERIALIZATION ---------- + //--------------------------------------------------------------------- + + public static final com.wowd.wobly.WoblyReader objectReader = new com.wowd.wobly.WoblyReaderImpl() { + @Override + public WImage readObject(java.nio.ByteBuffer buf) + { + return read(buf); + }}; + @Override + public void write(final java.nio.ByteBuffer buf) { + try { + int startPositionMark = buf.position(); + buf.position(buf.position()+1); + int unknownsCounter = 0; + if (unknownFields == null) + unknownsCounter = Integer.MAX_VALUE; + { + com.wowd.wobly.WoblyUtils.Buffers.putVInt(buf,this.size.ordinal()); + } + { + com.wowd.wobly.WoblyUtils.Buffers.putVInt(buf,this.height); + } + { + com.wowd.wobly.WoblyUtils.Buffers.putVInt(buf,this.width); + } + { + com.wowd.wobly.WoblyUtils.Buffers.putStringUTF8(buf, this.uri, true); + } + + unknownsCounter = writeUnknownsUpTo(unknownsCounter, 0, buf); + if (this.title != null) { + buf.put((byte)7); + com.wowd.wobly.WoblyUtils.Buffers.putStringUTF8(buf, this.title, true); + } + writeUnknownsUpTo(unknownsCounter, Integer.MAX_VALUE, buf); + com.wowd.wobly.WoblyUtils.Buffers.appendVariableSize(buf, startPositionMark); + } catch (com.wowd.wobly.exceptions.WoblyWriteException e) { + throw e; + } catch (java.lang.Throwable t) { + throw new com.wowd.wobly.exceptions.WoblyWriteException(t); + } + } + private WImage(final java.nio.ByteBuffer buf) { + + { + this.size = Size.values()[com.wowd.wobly.WoblyUtils.Buffers.getVInt(buf)]; + } + + { + this.height = com.wowd.wobly.WoblyUtils.Buffers.getVInt(buf); + } + + { + this.width = com.wowd.wobly.WoblyUtils.Buffers.getVInt(buf); + } + + { + this.uri = com.wowd.wobly.WoblyUtils.Buffers.getStringUTF8(buf, true); + } + int tag = com.wowd.wobly.WoblyUtils.Buffers.getVIntOrMax(buf); + + tag = readUnknownsUpTo(tag, 0, buf); + if (com.wowd.wobly.WoblyUtils.getIDFromTag(tag) > 0) + this.title = null; + else { + this.title = com.wowd.wobly.WoblyUtils.Buffers.getStringUTF8(buf, true); + tag = com.wowd.wobly.WoblyUtils.Buffers.getVIntOrMax(buf); + } + readUnknownsUpTo(tag, Integer.MAX_VALUE, buf); + } + @com.wowd.wobly.annotations.ReadStatic + public static WImage read(java.nio.ByteBuffer buf) { + try { + int size = com.wowd.wobly.WoblyUtils.Buffers.getVInt(buf); + int originalLimit = buf.limit(); + int newLimit = buf.position() + size; + if (newLimit > originalLimit) + throw new com.wowd.wobly.exceptions.WoblyReadException(newLimit + " " + originalLimit); + buf.limit(newLimit); + WImage object = new WImage(buf); + buf.limit(originalLimit); + return object; + } catch (com.wowd.wobly.exceptions.WoblyReadException e) { + throw e; + } catch (java.lang.Throwable t) { + throw new com.wowd.wobly.exceptions.WoblyReadException(t); + } + } + public static WImage read(byte[] buf) { + return read(java.nio.ByteBuffer.wrap(buf)); + } + @Override + public int getSize() { + int size = 0; + { + size += com.wowd.wobly.WoblyUtils.Buffers.sizeVInt(this.size.ordinal()); + } + { + size += com.wowd.wobly.WoblyUtils.Buffers.sizeVInt(this.height); + } + { + size += com.wowd.wobly.WoblyUtils.Buffers.sizeVInt(this.width); + } + { + size += com.wowd.wobly.WoblyUtils.Buffers.sizeStringUTF8(this.uri, true); + } + if (this.title != null) { + size += 1; + size += com.wowd.wobly.WoblyUtils.Buffers.sizeStringUTF8(this.title, true); + } + if (unknownFields != null) + for (com.wowd.wobly.unknown.UnknownField uf : unknownFields) + size += uf.getSize(); + size += com.wowd.wobly.WoblyUtils.Buffers.sizeVInt(size); + return size; + } + + //--------------------------------------------------------------------- + //-------------- END OF AUTO GENERATED CODE FOR SERIALIZATION --------- +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/wobly/compact/WMedia.java b/jvm-serializers-tpc/src/main/java/serializers/wobly/compact/WMedia.java new file mode 100644 index 0000000..a027e4b --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/wobly/compact/WMedia.java @@ -0,0 +1,346 @@ +package serializers.wobly.compact; + +import java.util.List; + +import com.wowd.wobly.WoblyUtils.Format; +import com.wowd.wobly.WoblyImpl; +import com.wowd.wobly.annotations.WoblyField; +import com.wowd.wobly.annotations.WoblyTypeOptions; + +import data.media.Media.Player; + +@WoblyTypeOptions(specialFormat = Format.BYTES_SIZE_COMPRESSED) +public class WMedia extends WoblyImpl +{ + @WoblyField(id = -1, required = true) + String uri; + @WoblyField(id = 0, specialFormat = Format.BYTES_SIZE_COMPRESSED) + String title; + @WoblyField(id = -2, required = true, specialFormat = Format.NUMBER_COMPRESSED) + int width; + @WoblyField(id = -3, required = true, specialFormat = Format.NUMBER_COMPRESSED) + int height; + @WoblyField(id = -4, required = true) + String format; + @WoblyField(id = -5, required = true, specialFormat = Format.NUMBER_COMPRESSED) + long duration; + @WoblyField(id = -6, required = true, specialFormat = Format.NUMBER_COMPRESSED) + long size; + @WoblyField(id = 1) + int bitrate; + @WoblyField(id = 2, specialFormat = Format.BYTES_SIZE_COMPRESSED) + List persons; + @WoblyField(id = -7, required = true) + Player player; + @WoblyField(id = 3) + String copyright; + + public WMedia(String uri, String title, int width, int height, String format, long duration, long size, int bitrate, + List persons, Player player, String copyright) + { + this.uri = uri; + this.title = title; + this.width = width; + this.height = height; + this.format = format; + this.duration = duration; + this.size = size; + this.bitrate = bitrate; + this.persons = persons; + this.player = player; + this.copyright = copyright; + } + + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + bitrate; + result = prime * result + + ((copyright == null) ? 0 : copyright.hashCode()); + result = prime * result + (int) (duration ^ (duration >>> 32)); + result = prime * result + ((format == null) ? 0 : format.hashCode()); + result = prime * result + height; + result = prime * result + ((persons == null) ? 0 : persons.hashCode()); + result = prime * result + ((player == null) ? 0 : player.hashCode()); + result = prime * result + (int) (size ^ (size >>> 32)); + result = prime * result + ((title == null) ? 0 : title.hashCode()); + result = prime * result + ((uri == null) ? 0 : uri.hashCode()); + result = prime * result + width; + return result; + } + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + WMedia other = (WMedia) obj; + if (bitrate != other.bitrate) + return false; + if (copyright == null) { + if (other.copyright != null) + return false; + } else if (!copyright.equals(other.copyright)) + return false; + if (duration != other.duration) + return false; + if (format == null) { + if (other.format != null) + return false; + } else if (!format.equals(other.format)) + return false; + if (height != other.height) + return false; + if (persons == null) { + if (other.persons != null) + return false; + } else if (!persons.equals(other.persons)) + return false; + if (player != other.player) + return false; + if (size != other.size) + return false; + if (title == null) { + if (other.title != null) + return false; + } else if (!title.equals(other.title)) + return false; + if (uri == null) { + if (other.uri != null) + return false; + } else if (!uri.equals(other.uri)) + return false; + if (width != other.width) + return false; + return true; + } + + //-------------- WOBLY AUTO GENERATED CODE FOR SERIALIZATION ---------- + //--------------------------------------------------------------------- + + public static final com.wowd.wobly.WoblyReader objectReader = new com.wowd.wobly.WoblyReaderImpl() { + @Override + public WMedia readObject(java.nio.ByteBuffer buf) + { + return read(buf); + }}; + @Override + public void write(final java.nio.ByteBuffer buf) { + try { + int startPositionMark = buf.position(); + buf.position(buf.position()+1); + int unknownsCounter = 0; + if (unknownFields == null) + unknownsCounter = Integer.MAX_VALUE; + { + com.wowd.wobly.WoblyUtils.Buffers.putVInt(buf,this.player.ordinal()); + } + { + com.wowd.wobly.WoblyUtils.Buffers.putVLong(buf,this.size); + } + { + com.wowd.wobly.WoblyUtils.Buffers.putVLong(buf,this.duration); + } + { + com.wowd.wobly.WoblyUtils.Buffers.putStringUTF8(buf, this.format, true); + } + { + com.wowd.wobly.WoblyUtils.Buffers.putVInt(buf,this.height); + } + { + com.wowd.wobly.WoblyUtils.Buffers.putVInt(buf,this.width); + } + { + com.wowd.wobly.WoblyUtils.Buffers.putStringUTF8(buf, this.uri, true); + } + + unknownsCounter = writeUnknownsUpTo(unknownsCounter, 0, buf); + if (this.title != null) { + buf.put((byte)7); + com.wowd.wobly.WoblyUtils.Buffers.putStringUTF8(buf, this.title, true); + } + + unknownsCounter = writeUnknownsUpTo(unknownsCounter, 1, buf); + if (this.bitrate != 0) { + buf.put((byte)10); + buf.putInt(this.bitrate); + } + + unknownsCounter = writeUnknownsUpTo(unknownsCounter, 2, buf); + if ((this.persons != null) && (this.persons.size() > 0)) { + buf.put((byte)23); + int startFieldMark = buf.position(); + buf.position(buf.position()+1); + com.wowd.wobly.WoblyUtils.Buffers.putVInt(buf, this.persons.size()); + for (String v1 : this.persons) { + com.wowd.wobly.WoblyUtils.Buffers.putStringUTF8(buf, v1, true); + } + com.wowd.wobly.WoblyUtils.Buffers.appendVariableSize(buf, startFieldMark); + } + + unknownsCounter = writeUnknownsUpTo(unknownsCounter, 3, buf); + if (this.copyright != null) { + buf.put((byte)31); + com.wowd.wobly.WoblyUtils.Buffers.putStringUTF8(buf, this.copyright, true); + } + writeUnknownsUpTo(unknownsCounter, Integer.MAX_VALUE, buf); + com.wowd.wobly.WoblyUtils.Buffers.appendVariableSize(buf, startPositionMark); + } catch (com.wowd.wobly.exceptions.WoblyWriteException e) { + throw e; + } catch (java.lang.Throwable t) { + throw new com.wowd.wobly.exceptions.WoblyWriteException(t); + } + } + private WMedia(final java.nio.ByteBuffer buf) { + + { + this.player = Player.values()[com.wowd.wobly.WoblyUtils.Buffers.getVInt(buf)]; + } + + { + this.size = com.wowd.wobly.WoblyUtils.Buffers.getVLong(buf); + } + + { + this.duration = com.wowd.wobly.WoblyUtils.Buffers.getVLong(buf); + } + + { + this.format = com.wowd.wobly.WoblyUtils.Buffers.getStringUTF8(buf, true); + } + + { + this.height = com.wowd.wobly.WoblyUtils.Buffers.getVInt(buf); + } + + { + this.width = com.wowd.wobly.WoblyUtils.Buffers.getVInt(buf); + } + + { + this.uri = com.wowd.wobly.WoblyUtils.Buffers.getStringUTF8(buf, true); + } + int tag = com.wowd.wobly.WoblyUtils.Buffers.getVIntOrMax(buf); + + tag = readUnknownsUpTo(tag, 0, buf); + if (com.wowd.wobly.WoblyUtils.getIDFromTag(tag) > 0) + this.title = null; + else { + this.title = com.wowd.wobly.WoblyUtils.Buffers.getStringUTF8(buf, true); + tag = com.wowd.wobly.WoblyUtils.Buffers.getVIntOrMax(buf); + } + + tag = readUnknownsUpTo(tag, 1, buf); + if (com.wowd.wobly.WoblyUtils.getIDFromTag(tag) > 1) + this.bitrate = 0; + else { + this.bitrate = buf.getInt(); + tag = com.wowd.wobly.WoblyUtils.Buffers.getVIntOrMax(buf); + } + + tag = readUnknownsUpTo(tag, 2, buf); + if (com.wowd.wobly.WoblyUtils.getIDFromTag(tag) > 2) + this.persons = new java.util.ArrayList(1); + else { + com.wowd.wobly.WoblyUtils.Buffers.getVInt(buf); //read size + int size1 = com.wowd.wobly.WoblyUtils.Buffers.getVInt(buf); + this.persons = new java.util.ArrayList(size1); + for (int i1 = 0; i1 < size1; i1++) { + String tmp1; + tmp1 = com.wowd.wobly.WoblyUtils.Buffers.getStringUTF8(buf, true); + this.persons.add(tmp1); + } + tag = com.wowd.wobly.WoblyUtils.Buffers.getVIntOrMax(buf); + } + + tag = readUnknownsUpTo(tag, 3, buf); + if (com.wowd.wobly.WoblyUtils.getIDFromTag(tag) > 3) + this.copyright = null; + else { + this.copyright = com.wowd.wobly.WoblyUtils.Buffers.getStringUTF8(buf, true); + tag = com.wowd.wobly.WoblyUtils.Buffers.getVIntOrMax(buf); + } + readUnknownsUpTo(tag, Integer.MAX_VALUE, buf); + } + @com.wowd.wobly.annotations.ReadStatic + public static WMedia read(java.nio.ByteBuffer buf) { + try { + int size = com.wowd.wobly.WoblyUtils.Buffers.getVInt(buf); + int originalLimit = buf.limit(); + int newLimit = buf.position() + size; + if (newLimit > originalLimit) + throw new com.wowd.wobly.exceptions.WoblyReadException(newLimit + " " + originalLimit); + buf.limit(newLimit); + WMedia object = new WMedia(buf); + buf.limit(originalLimit); + return object; + } catch (com.wowd.wobly.exceptions.WoblyReadException e) { + throw e; + } catch (java.lang.Throwable t) { + throw new com.wowd.wobly.exceptions.WoblyReadException(t); + } + } + public static WMedia read(byte[] buf) { + return read(java.nio.ByteBuffer.wrap(buf)); + } + @Override + public int getSize() { + int size = 0; + { + size += com.wowd.wobly.WoblyUtils.Buffers.sizeVInt(this.player.ordinal()); + } + { + size += com.wowd.wobly.WoblyUtils.Buffers.sizeVLong(this.size); + } + { + size += com.wowd.wobly.WoblyUtils.Buffers.sizeVLong(this.duration); + } + { + size += com.wowd.wobly.WoblyUtils.Buffers.sizeStringUTF8(this.format, true); + } + { + size += com.wowd.wobly.WoblyUtils.Buffers.sizeVInt(this.height); + } + { + size += com.wowd.wobly.WoblyUtils.Buffers.sizeVInt(this.width); + } + { + size += com.wowd.wobly.WoblyUtils.Buffers.sizeStringUTF8(this.uri, true); + } + if (this.title != null) { + size += 1; + size += com.wowd.wobly.WoblyUtils.Buffers.sizeStringUTF8(this.title, true); + } + if (this.bitrate != 0) { + size += 1; + size += 4; + } + if ((this.persons != null) && (this.persons.size() > 0)) { + size += 1; + int helpSize = size; + size += com.wowd.wobly.WoblyUtils.Buffers.sizeVInt(this.persons.size()); + for (String v1 : this.persons) { + size += com.wowd.wobly.WoblyUtils.Buffers.sizeStringUTF8(v1, true); + } + size += com.wowd.wobly.WoblyUtils.Buffers.sizeVInt(size-helpSize); + } + if (this.copyright != null) { + size += 1; + size += com.wowd.wobly.WoblyUtils.Buffers.sizeStringUTF8(this.copyright, true); + } + if (unknownFields != null) + for (com.wowd.wobly.unknown.UnknownField uf : unknownFields) + size += uf.getSize(); + size += com.wowd.wobly.WoblyUtils.Buffers.sizeVInt(size); + return size; + } + + //--------------------------------------------------------------------- + //-------------- END OF AUTO GENERATED CODE FOR SERIALIZATION --------- +} + + diff --git a/jvm-serializers-tpc/src/main/java/serializers/wobly/compact/WMediaContent.java b/jvm-serializers-tpc/src/main/java/serializers/wobly/compact/WMediaContent.java new file mode 100644 index 0000000..2f352cb --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/wobly/compact/WMediaContent.java @@ -0,0 +1,135 @@ +package serializers.wobly.compact; + +import java.util.List; + +import com.wowd.wobly.UnmodifiableWoblyImpl; +import com.wowd.wobly.WoblyUtils.Format; +import com.wowd.wobly.annotations.WoblyField; +import com.wowd.wobly.annotations.WoblyTypeOptions; + +@WoblyTypeOptions(unmodifiable = true, specialFormat = Format.NO_SIZE_FIELD) +public class WMediaContent extends UnmodifiableWoblyImpl +{ + @WoblyField(id = -1, required = true, specialFormat = Format.BYTES_SIZE_COMPRESSED) + List images; + + @WoblyField(id = -2, required = true) + WMedia media; + + public WMediaContent(List images, WMedia media) + { + this.images = images; + this.media = media; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((images == null) ? 0 : images.hashCode()); + result = prime * result + ((media == null) ? 0 : media.hashCode()); + return result; + } + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + WMediaContent other = (WMediaContent) obj; + if (images == null) { + if (other.images != null) + return false; + } else if (!images.equals(other.images)) + return false; + if (media == null) { + if (other.media != null) + return false; + } else if (!media.equals(other.media)) + return false; + return true; + } + + //-------------- WOBLY AUTO GENERATED CODE FOR SERIALIZATION ---------- + //--------------------------------------------------------------------- + + public static final com.wowd.wobly.WoblyReader objectReader = new com.wowd.wobly.WoblyReaderImpl() { + @Override + public WMediaContent readObject(java.nio.ByteBuffer buf) + { + return read(buf); + }}; + @Override + public void write(final java.nio.ByteBuffer buf) { + try { + { + this.media.write(buf); + } + { + int startFieldMark = buf.position(); + buf.position(buf.position()+1); + com.wowd.wobly.WoblyUtils.Buffers.putVInt(buf, this.images.size()); + for (WImage v1 : this.images) { + v1.write(buf); + } + com.wowd.wobly.WoblyUtils.Buffers.appendVariableSize(buf, startFieldMark); + } + } catch (com.wowd.wobly.exceptions.WoblyWriteException e) { + throw e; + } catch (java.lang.Throwable t) { + throw new com.wowd.wobly.exceptions.WoblyWriteException(t); + } + } + private WMediaContent(final java.nio.ByteBuffer buf) { + + { + this.media = WMedia.read(buf); + } + + { + com.wowd.wobly.WoblyUtils.Buffers.getVInt(buf); //read size + int size1 = com.wowd.wobly.WoblyUtils.Buffers.getVInt(buf); + this.images = new java.util.ArrayList(size1); + for (int i1 = 0; i1 < size1; i1++) { + WImage tmp1; + tmp1 = WImage.read(buf); + this.images.add(tmp1); + } + } + } + @com.wowd.wobly.annotations.ReadStatic + public static WMediaContent read(java.nio.ByteBuffer buf) { + try { + WMediaContent object = new WMediaContent(buf); + return object; + } catch (com.wowd.wobly.exceptions.WoblyReadException e) { + throw e; + } catch (java.lang.Throwable t) { + throw new com.wowd.wobly.exceptions.WoblyReadException(t); + } + } + public static WMediaContent read(byte[] buf) { + return read(java.nio.ByteBuffer.wrap(buf)); + } + @Override + public int getSize() { + int size = 0; + { + size += this.media.getSize(); + } + { + int helpSize = size; + size += com.wowd.wobly.WoblyUtils.Buffers.sizeVInt(this.images.size()); + for (WImage v1 : this.images) { + size += v1.getSize(); + } + size += com.wowd.wobly.WoblyUtils.Buffers.sizeVInt(size-helpSize); + } + return size; + } + + //--------------------------------------------------------------------- + //-------------- END OF AUTO GENERATED CODE FOR SERIALIZATION --------- +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/wobly/compact/WoblyCompactUtils.java b/jvm-serializers-tpc/src/main/java/serializers/wobly/compact/WoblyCompactUtils.java new file mode 100644 index 0000000..1245b65 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/wobly/compact/WoblyCompactUtils.java @@ -0,0 +1,81 @@ +package serializers.wobly.compact; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import data.media.Image; +import data.media.Media; +import data.media.MediaContent; +import data.media.MediaTransformer; + +import serializers.Serializer; + +public class WoblyCompactUtils { + public static WMedia forwardMedia(Media a) { + return new WMedia(a.uri, a.title, a.width, a.height, a.format, a.duration, a.size, a.bitrate, a.persons, a.player, a.copyright); + } + public static Media reverseMedia(WMedia a) { + return new Media(a.uri, a.title, a.width, a.height, a.format, a.duration, a.size, a.bitrate, true, a.persons, a.player, a.copyright); + } + public static WImage forwardImage(Image a) { + return new WImage(a.uri, a.title, a.width, a.height, a.size); + } + public static Image reverseImage(WImage a) { + return new Image(a.uri, a.title, a.width, a.height, a.size); + } + public static List forwardImages(List a) { + ArrayList images = new ArrayList(a.size()); + for (Image image : a) { + images.add(forwardImage(image)); + } + return images; + } + public static List reverseImages(List a) { + ArrayList images = new ArrayList(a.size()); + for (WImage image : a) { + images.add(reverseImage(image)); + } + return images; + } + + public static final class WoblyTransformer extends MediaTransformer { + @Override + public WMediaContent[] resultArray(int size) { return new WMediaContent[size]; } + + @Override + public WMediaContent forward(MediaContent a) { + return new WMediaContent(forwardImages(a.images), forwardMedia(a.media)); + } + + @Override + public MediaContent reverse(WMediaContent a) { + return new MediaContent(reverseMedia(a.media), reverseImages(a.images)); + } + + @Override + public MediaContent shallowReverse(WMediaContent a) { + return new MediaContent(reverseMedia(a.media), Collections.emptyList()); + } + } + public static final class WoblySerializer extends Serializer + { + @Override + public WMediaContent deserialize(byte[] array) + throws Exception { + return WMediaContent.read(array); + } + + @Override + public byte[] serialize(WMediaContent content) + throws Exception { + return content.toByteArray(); + } + + @Override + public String getName() { + return "wobly-compact"; + } + } + +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/wobly/simple/WImage.java b/jvm-serializers-tpc/src/main/java/serializers/wobly/simple/WImage.java new file mode 100644 index 0000000..7a90fa8 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/wobly/simple/WImage.java @@ -0,0 +1,194 @@ +package serializers.wobly.simple; + +import com.wowd.wobly.WoblyUtils.Format; +import com.wowd.wobly.WoblyImpl; +import com.wowd.wobly.annotations.WoblyField; +import com.wowd.wobly.annotations.WoblyTypeOptions; + +import data.media.Image.Size; + +@WoblyTypeOptions(specialFormat = Format.BYTES_SIZE_COMPRESSED) +public class WImage extends WoblyImpl +{ + @WoblyField(id = -1, required = true) + String uri; + @WoblyField(id = 0) + String title; + @WoblyField(id = -2, required = true) + int width; + @WoblyField(id = -3, required = true) + int height; + @WoblyField(id = -4, required = true) + Size size; + + public WImage(String uri, String title, int width, int height, Size size) + { + this.uri = uri; + this.title = title; + this.width = width; + this.height = height; + this.size = size; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + height; + result = prime * result + ((size == null) ? 0 : size.hashCode()); + result = prime * result + ((title == null) ? 0 : title.hashCode()); + result = prime * result + ((uri == null) ? 0 : uri.hashCode()); + result = prime * result + width; + return result; + } + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + WImage other = (WImage) obj; + if (height != other.height) + return false; + if (size != other.size) + return false; + if (title == null) { + if (other.title != null) + return false; + } else if (!title.equals(other.title)) + return false; + if (uri == null) { + if (other.uri != null) + return false; + } else if (!uri.equals(other.uri)) + return false; + if (width != other.width) + return false; + return true; + } + + + + //-------------- WOBLY AUTO GENERATED CODE FOR SERIALIZATION ---------- + //--------------------------------------------------------------------- + + public static final com.wowd.wobly.WoblyReader objectReader = new com.wowd.wobly.WoblyReaderImpl() { + @Override + public WImage readObject(java.nio.ByteBuffer buf) + { + return read(buf); + }}; + @Override + public void write(final java.nio.ByteBuffer buf) { + try { + int startPositionMark = buf.position(); + buf.position(buf.position()+1); + int unknownsCounter = 0; + if (unknownFields == null) + unknownsCounter = Integer.MAX_VALUE; + { + com.wowd.wobly.WoblyUtils.Buffers.putVInt(buf,this.size.ordinal()); + } + { + buf.putInt(this.height); + } + { + buf.putInt(this.width); + } + { + com.wowd.wobly.WoblyUtils.Buffers.putStringUTF8(buf, this.uri, true); + } + + unknownsCounter = writeUnknownsUpTo(unknownsCounter, 0, buf); + if (this.title != null) { + buf.put((byte)7); + com.wowd.wobly.WoblyUtils.Buffers.putStringUTF8(buf, this.title, true); + } + writeUnknownsUpTo(unknownsCounter, Integer.MAX_VALUE, buf); + com.wowd.wobly.WoblyUtils.Buffers.appendVariableSize(buf, startPositionMark); + } catch (com.wowd.wobly.exceptions.WoblyWriteException e) { + throw e; + } catch (java.lang.Throwable t) { + throw new com.wowd.wobly.exceptions.WoblyWriteException(t); + } + } + private WImage(final java.nio.ByteBuffer buf) { + + { + this.size = Size.values()[com.wowd.wobly.WoblyUtils.Buffers.getVInt(buf)]; + } + + { + this.height = buf.getInt(); + } + + { + this.width = buf.getInt(); + } + + { + this.uri = com.wowd.wobly.WoblyUtils.Buffers.getStringUTF8(buf, true); + } + int tag = com.wowd.wobly.WoblyUtils.Buffers.getVIntOrMax(buf); + + tag = readUnknownsUpTo(tag, 0, buf); + if (com.wowd.wobly.WoblyUtils.getIDFromTag(tag) > 0) + this.title = null; + else { + this.title = com.wowd.wobly.WoblyUtils.Buffers.getStringUTF8(buf, true); + tag = com.wowd.wobly.WoblyUtils.Buffers.getVIntOrMax(buf); + } + readUnknownsUpTo(tag, Integer.MAX_VALUE, buf); + } + @com.wowd.wobly.annotations.ReadStatic + public static WImage read(java.nio.ByteBuffer buf) { + try { + int size = com.wowd.wobly.WoblyUtils.Buffers.getVInt(buf); + int originalLimit = buf.limit(); + int newLimit = buf.position() + size; + if (newLimit > originalLimit) + throw new com.wowd.wobly.exceptions.WoblyReadException(newLimit + " " + originalLimit); + buf.limit(newLimit); + WImage object = new WImage(buf); + buf.limit(originalLimit); + return object; + } catch (com.wowd.wobly.exceptions.WoblyReadException e) { + throw e; + } catch (java.lang.Throwable t) { + throw new com.wowd.wobly.exceptions.WoblyReadException(t); + } + } + public static WImage read(byte[] buf) { + return read(java.nio.ByteBuffer.wrap(buf)); + } + @Override + public int getSize() { + int size = 0; + { + size += com.wowd.wobly.WoblyUtils.Buffers.sizeVInt(this.size.ordinal()); + } + { + size += 4; + } + { + size += 4; + } + { + size += com.wowd.wobly.WoblyUtils.Buffers.sizeStringUTF8(this.uri, true); + } + if (this.title != null) { + size += 1; + size += com.wowd.wobly.WoblyUtils.Buffers.sizeStringUTF8(this.title, true); + } + if (unknownFields != null) + for (com.wowd.wobly.unknown.UnknownField uf : unknownFields) + size += uf.getSize(); + size += com.wowd.wobly.WoblyUtils.Buffers.sizeVInt(size); + return size; + } + + //--------------------------------------------------------------------- + //-------------- END OF AUTO GENERATED CODE FOR SERIALIZATION --------- +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/wobly/simple/WMedia.java b/jvm-serializers-tpc/src/main/java/serializers/wobly/simple/WMedia.java new file mode 100644 index 0000000..c1ebf8a --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/wobly/simple/WMedia.java @@ -0,0 +1,346 @@ +package serializers.wobly.simple; + +import java.util.List; + +import com.wowd.wobly.WoblyUtils.Format; +import com.wowd.wobly.WoblyImpl; +import com.wowd.wobly.annotations.WoblyField; +import com.wowd.wobly.annotations.WoblyTypeOptions; + +import data.media.Media.Player; + +@WoblyTypeOptions(specialFormat = Format.BYTES_SIZE_COMPRESSED) +public class WMedia extends WoblyImpl +{ + @WoblyField(id = -1, required = true) + String uri; + @WoblyField(id = 0) + String title; + @WoblyField(id = -2, required = true) + int width; + @WoblyField(id = -3, required = true) + int height; + @WoblyField(id = -4, required = true, specialFormat = Format.BYTES_SIZE_COMPRESSED) + String format; + @WoblyField(id = -5, required = true) + long duration; + @WoblyField(id = -6, required = true) + long size; + @WoblyField(id = 1) + int bitrate; + @WoblyField(id = 2) + List persons; + @WoblyField(id = -7, required = true) + Player player; + @WoblyField(id = 3) + String copyright; + + public WMedia(String uri, String title, int width, int height, String format, long duration, long size, int bitrate, + List persons, Player player, String copyright) + { + this.uri = uri; + this.title = title; + this.width = width; + this.height = height; + this.format = format; + this.duration = duration; + this.size = size; + this.bitrate = bitrate; + this.persons = persons; + this.player = player; + this.copyright = copyright; + } + + + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + bitrate; + result = prime * result + + ((copyright == null) ? 0 : copyright.hashCode()); + result = prime * result + (int) (duration ^ (duration >>> 32)); + result = prime * result + ((format == null) ? 0 : format.hashCode()); + result = prime * result + height; + result = prime * result + ((persons == null) ? 0 : persons.hashCode()); + result = prime * result + ((player == null) ? 0 : player.hashCode()); + result = prime * result + (int) (size ^ (size >>> 32)); + result = prime * result + ((title == null) ? 0 : title.hashCode()); + result = prime * result + ((uri == null) ? 0 : uri.hashCode()); + result = prime * result + width; + return result; + } + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + WMedia other = (WMedia) obj; + if (bitrate != other.bitrate) + return false; + if (copyright == null) { + if (other.copyright != null) + return false; + } else if (!copyright.equals(other.copyright)) + return false; + if (duration != other.duration) + return false; + if (format == null) { + if (other.format != null) + return false; + } else if (!format.equals(other.format)) + return false; + if (height != other.height) + return false; + if (persons == null) { + if (other.persons != null) + return false; + } else if (!persons.equals(other.persons)) + return false; + if (player != other.player) + return false; + if (size != other.size) + return false; + if (title == null) { + if (other.title != null) + return false; + } else if (!title.equals(other.title)) + return false; + if (uri == null) { + if (other.uri != null) + return false; + } else if (!uri.equals(other.uri)) + return false; + if (width != other.width) + return false; + return true; + } + + //-------------- WOBLY AUTO GENERATED CODE FOR SERIALIZATION ---------- + //--------------------------------------------------------------------- + + public static final com.wowd.wobly.WoblyReader objectReader = new com.wowd.wobly.WoblyReaderImpl() { + @Override + public WMedia readObject(java.nio.ByteBuffer buf) + { + return read(buf); + }}; + @Override + public void write(final java.nio.ByteBuffer buf) { + try { + int startPositionMark = buf.position(); + buf.position(buf.position()+1); + int unknownsCounter = 0; + if (unknownFields == null) + unknownsCounter = Integer.MAX_VALUE; + { + com.wowd.wobly.WoblyUtils.Buffers.putVInt(buf,this.player.ordinal()); + } + { + buf.putLong(this.size); + } + { + buf.putLong(this.duration); + } + { + com.wowd.wobly.WoblyUtils.Buffers.putStringUTF8(buf, this.format, true); + } + { + buf.putInt(this.height); + } + { + buf.putInt(this.width); + } + { + com.wowd.wobly.WoblyUtils.Buffers.putStringUTF8(buf, this.uri, true); + } + + unknownsCounter = writeUnknownsUpTo(unknownsCounter, 0, buf); + if (this.title != null) { + buf.put((byte)7); + com.wowd.wobly.WoblyUtils.Buffers.putStringUTF8(buf, this.title, true); + } + + unknownsCounter = writeUnknownsUpTo(unknownsCounter, 1, buf); + if (this.bitrate != 0) { + buf.put((byte)10); + buf.putInt(this.bitrate); + } + + unknownsCounter = writeUnknownsUpTo(unknownsCounter, 2, buf); + if ((this.persons != null) && (this.persons.size() > 0)) { + buf.put((byte)22); + int startFieldMark = buf.position(); + buf.position(buf.position()+4); + com.wowd.wobly.WoblyUtils.Buffers.putVInt(buf, this.persons.size()); + for (String v1 : this.persons) { + com.wowd.wobly.WoblyUtils.Buffers.putStringUTF8(buf, v1, true); + } + buf.putInt(startFieldMark, buf.position() - startFieldMark - 4); + } + + unknownsCounter = writeUnknownsUpTo(unknownsCounter, 3, buf); + if (this.copyright != null) { + buf.put((byte)31); + com.wowd.wobly.WoblyUtils.Buffers.putStringUTF8(buf, this.copyright, true); + } + writeUnknownsUpTo(unknownsCounter, Integer.MAX_VALUE, buf); + com.wowd.wobly.WoblyUtils.Buffers.appendVariableSize(buf, startPositionMark); + } catch (com.wowd.wobly.exceptions.WoblyWriteException e) { + throw e; + } catch (java.lang.Throwable t) { + throw new com.wowd.wobly.exceptions.WoblyWriteException(t); + } + } + private WMedia(final java.nio.ByteBuffer buf) { + + { + this.player = Player.values()[com.wowd.wobly.WoblyUtils.Buffers.getVInt(buf)]; + } + + { + this.size = buf.getLong(); + } + + { + this.duration = buf.getLong(); + } + + { + this.format = com.wowd.wobly.WoblyUtils.Buffers.getStringUTF8(buf, true); + } + + { + this.height = buf.getInt(); + } + + { + this.width = buf.getInt(); + } + + { + this.uri = com.wowd.wobly.WoblyUtils.Buffers.getStringUTF8(buf, true); + } + int tag = com.wowd.wobly.WoblyUtils.Buffers.getVIntOrMax(buf); + + tag = readUnknownsUpTo(tag, 0, buf); + if (com.wowd.wobly.WoblyUtils.getIDFromTag(tag) > 0) + this.title = null; + else { + this.title = com.wowd.wobly.WoblyUtils.Buffers.getStringUTF8(buf, true); + tag = com.wowd.wobly.WoblyUtils.Buffers.getVIntOrMax(buf); + } + + tag = readUnknownsUpTo(tag, 1, buf); + if (com.wowd.wobly.WoblyUtils.getIDFromTag(tag) > 1) + this.bitrate = 0; + else { + this.bitrate = buf.getInt(); + tag = com.wowd.wobly.WoblyUtils.Buffers.getVIntOrMax(buf); + } + + tag = readUnknownsUpTo(tag, 2, buf); + if (com.wowd.wobly.WoblyUtils.getIDFromTag(tag) > 2) + this.persons = new java.util.ArrayList(1); + else { + buf.getInt(); //read size + int size1 = com.wowd.wobly.WoblyUtils.Buffers.getVInt(buf); + this.persons = new java.util.ArrayList(size1); + for (int i1 = 0; i1 < size1; i1++) { + String tmp1; + tmp1 = com.wowd.wobly.WoblyUtils.Buffers.getStringUTF8(buf, true); + this.persons.add(tmp1); + } + tag = com.wowd.wobly.WoblyUtils.Buffers.getVIntOrMax(buf); + } + + tag = readUnknownsUpTo(tag, 3, buf); + if (com.wowd.wobly.WoblyUtils.getIDFromTag(tag) > 3) + this.copyright = null; + else { + this.copyright = com.wowd.wobly.WoblyUtils.Buffers.getStringUTF8(buf, true); + tag = com.wowd.wobly.WoblyUtils.Buffers.getVIntOrMax(buf); + } + readUnknownsUpTo(tag, Integer.MAX_VALUE, buf); + } + @com.wowd.wobly.annotations.ReadStatic + public static WMedia read(java.nio.ByteBuffer buf) { + try { + int size = com.wowd.wobly.WoblyUtils.Buffers.getVInt(buf); + int originalLimit = buf.limit(); + int newLimit = buf.position() + size; + if (newLimit > originalLimit) + throw new com.wowd.wobly.exceptions.WoblyReadException(newLimit + " " + originalLimit); + buf.limit(newLimit); + WMedia object = new WMedia(buf); + buf.limit(originalLimit); + return object; + } catch (com.wowd.wobly.exceptions.WoblyReadException e) { + throw e; + } catch (java.lang.Throwable t) { + throw new com.wowd.wobly.exceptions.WoblyReadException(t); + } + } + public static WMedia read(byte[] buf) { + return read(java.nio.ByteBuffer.wrap(buf)); + } + @Override + public int getSize() { + int size = 0; + { + size += com.wowd.wobly.WoblyUtils.Buffers.sizeVInt(this.player.ordinal()); + } + { + size += 8; + } + { + size += 8; + } + { + size += com.wowd.wobly.WoblyUtils.Buffers.sizeStringUTF8(this.format, true); + } + { + size += 4; + } + { + size += 4; + } + { + size += com.wowd.wobly.WoblyUtils.Buffers.sizeStringUTF8(this.uri, true); + } + if (this.title != null) { + size += 1; + size += com.wowd.wobly.WoblyUtils.Buffers.sizeStringUTF8(this.title, true); + } + if (this.bitrate != 0) { + size += 1; + size += 4; + } + if ((this.persons != null) && (this.persons.size() > 0)) { + size += 1; + size += 4; + size += com.wowd.wobly.WoblyUtils.Buffers.sizeVInt(this.persons.size()); + for (String v1 : this.persons) { + size += com.wowd.wobly.WoblyUtils.Buffers.sizeStringUTF8(v1, true); + } + } + if (this.copyright != null) { + size += 1; + size += com.wowd.wobly.WoblyUtils.Buffers.sizeStringUTF8(this.copyright, true); + } + if (unknownFields != null) + for (com.wowd.wobly.unknown.UnknownField uf : unknownFields) + size += uf.getSize(); + size += com.wowd.wobly.WoblyUtils.Buffers.sizeVInt(size); + return size; + } + + //--------------------------------------------------------------------- + //-------------- END OF AUTO GENERATED CODE FOR SERIALIZATION --------- +} + + diff --git a/jvm-serializers-tpc/src/main/java/serializers/wobly/simple/WMediaContent.java b/jvm-serializers-tpc/src/main/java/serializers/wobly/simple/WMediaContent.java new file mode 100644 index 0000000..0de4b0e --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/wobly/simple/WMediaContent.java @@ -0,0 +1,135 @@ +package serializers.wobly.simple; + +import java.util.List; + +import com.wowd.wobly.UnmodifiableWoblyImpl; +import com.wowd.wobly.WoblyUtils.Format; +import com.wowd.wobly.annotations.WoblyField; +import com.wowd.wobly.annotations.WoblyTypeOptions; + +@WoblyTypeOptions(unmodifiable = true, specialFormat = Format.NO_SIZE_FIELD) +public class WMediaContent extends UnmodifiableWoblyImpl +{ + @WoblyField(id = -1, required = true) + List images; + + @WoblyField(id = -2, required = true) + WMedia media; + + + public WMediaContent(List images, WMedia media) + { + this.images = images; + this.media = media; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((images == null) ? 0 : images.hashCode()); + result = prime * result + ((media == null) ? 0 : media.hashCode()); + return result; + } + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + WMediaContent other = (WMediaContent) obj; + if (images == null) { + if (other.images != null) + return false; + } else if (!images.equals(other.images)) + return false; + if (media == null) { + if (other.media != null) + return false; + } else if (!media.equals(other.media)) + return false; + return true; + } + + //-------------- WOBLY AUTO GENERATED CODE FOR SERIALIZATION ---------- + //--------------------------------------------------------------------- + + public static final com.wowd.wobly.WoblyReader objectReader = new com.wowd.wobly.WoblyReaderImpl() { + @Override + public WMediaContent readObject(java.nio.ByteBuffer buf) + { + return read(buf); + }}; + @Override + public void write(final java.nio.ByteBuffer buf) { + try { + { + this.media.write(buf); + } + { + int startFieldMark = buf.position(); + buf.position(buf.position()+4); + com.wowd.wobly.WoblyUtils.Buffers.putVInt(buf, this.images.size()); + for (WImage v1 : this.images) { + v1.write(buf); + } + buf.putInt(startFieldMark, buf.position() - startFieldMark - 4); + } + } catch (com.wowd.wobly.exceptions.WoblyWriteException e) { + throw e; + } catch (java.lang.Throwable t) { + throw new com.wowd.wobly.exceptions.WoblyWriteException(t); + } + } + private WMediaContent(final java.nio.ByteBuffer buf) { + + { + this.media = WMedia.read(buf); + } + + { + buf.getInt(); //read size + int size1 = com.wowd.wobly.WoblyUtils.Buffers.getVInt(buf); + this.images = new java.util.ArrayList(size1); + for (int i1 = 0; i1 < size1; i1++) { + WImage tmp1; + tmp1 = WImage.read(buf); + this.images.add(tmp1); + } + } + } + @com.wowd.wobly.annotations.ReadStatic + public static WMediaContent read(java.nio.ByteBuffer buf) { + try { + WMediaContent object = new WMediaContent(buf); + return object; + } catch (com.wowd.wobly.exceptions.WoblyReadException e) { + throw e; + } catch (java.lang.Throwable t) { + throw new com.wowd.wobly.exceptions.WoblyReadException(t); + } + } + public static WMediaContent read(byte[] buf) { + return read(java.nio.ByteBuffer.wrap(buf)); + } + @Override + public int getSize() { + int size = 0; + { + size += this.media.getSize(); + } + { + size += 4; + size += com.wowd.wobly.WoblyUtils.Buffers.sizeVInt(this.images.size()); + for (WImage v1 : this.images) { + size += v1.getSize(); + } + } + return size; + } + + //--------------------------------------------------------------------- + //-------------- END OF AUTO GENERATED CODE FOR SERIALIZATION --------- +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/wobly/simple/WoblySimpleUtils.java b/jvm-serializers-tpc/src/main/java/serializers/wobly/simple/WoblySimpleUtils.java new file mode 100644 index 0000000..104b0be --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/wobly/simple/WoblySimpleUtils.java @@ -0,0 +1,80 @@ +package serializers.wobly.simple; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import serializers.Serializer; +import data.media.Image; +import data.media.Media; +import data.media.MediaContent; +import data.media.MediaTransformer; + +public class WoblySimpleUtils { + public static WMedia forwardMedia(Media a) { + return new WMedia(a.uri, a.title, a.width, a.height, a.format, a.duration, a.size, a.bitrate, a.persons, a.player, a.copyright); + } + public static Media reverseMedia(WMedia a) { + return new Media(a.uri, a.title, a.width, a.height, a.format, a.duration, a.size, a.bitrate, true, a.persons, a.player, a.copyright); + } + public static WImage forwardImage(Image a) { + return new WImage(a.uri, a.title, a.width, a.height, a.size); + } + public static Image reverseImage(WImage a) { + return new Image(a.uri, a.title, a.width, a.height, a.size); + } + public static List forwardImages(List a) { + ArrayList images = new ArrayList(a.size()); + for (Image image : a) { + images.add(forwardImage(image)); + } + return images; + } + public static List reverseImages(List a) { + ArrayList images = new ArrayList(a.size()); + for (WImage image : a) { + images.add(reverseImage(image)); + } + return images; + } + + public static final class WoblyTransformer extends MediaTransformer + { + @Override + public WMediaContent[] resultArray(int size) { return new WMediaContent[size]; } + + @Override + public WMediaContent forward(MediaContent a) { + return new WMediaContent(forwardImages(a.images), forwardMedia(a.media)); + } + + @Override + public MediaContent reverse(WMediaContent a) { + return new MediaContent(reverseMedia(a.media), reverseImages(a.images)); + } + + @Override + public MediaContent shallowReverse(WMediaContent a) { + return new MediaContent(reverseMedia(a.media), Collections.emptyList()); + } + } + public static final class WoblySerializer extends Serializer + { + @Override + public WMediaContent deserialize(byte[] array) + throws Exception { + return WMediaContent.read(array); + } + + @Override + public byte[] serialize(WMediaContent content) + throws Exception { + return content.toByteArray(); + } + + @Override + public String getName() { + return "wobly"; + } + } +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/xml/BaseStaxMediaSerializer.java b/jvm-serializers-tpc/src/main/java/serializers/xml/BaseStaxMediaSerializer.java new file mode 100644 index 0000000..228b72c --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/xml/BaseStaxMediaSerializer.java @@ -0,0 +1,73 @@ +package serializers.xml; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.InputStream; +import java.io.OutputStream; + +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; +import javax.xml.stream.XMLStreamWriter; + +import serializers.Serializer; +import data.media.MediaContent; + +public abstract class BaseStaxMediaSerializer extends Serializer +{ + private final StaxSerializer _serializer = new StaxSerializer(); + + private final StaxDeserializer _deserializer; + + protected BaseStaxMediaSerializer(boolean workingGetElementText) + { + _deserializer = new StaxDeserializer(workingGetElementText); + } + + protected XMLStreamReader createReader(byte[] input) throws XMLStreamException { + return createReader(new ByteArrayInputStream(input)); + } + protected abstract XMLStreamReader createReader(InputStream in) throws XMLStreamException; + protected abstract XMLStreamWriter createWriter(OutputStream output) throws XMLStreamException; + + // // Public API + + @Override + public MediaContent deserialize (byte[] array) throws XMLStreamException + { + XMLStreamReader parser = createReader(array); + MediaContent content = _deserializer.readDocument(parser); + parser.close(); + return content; + } + + @Override + public MediaContent[] deserializeItems(InputStream in, int numberOfItems) throws XMLStreamException + { + XMLStreamReader parser = createReader(in); + MediaContent[] result = _deserializer.readDocument(parser, numberOfItems); + parser.close(); + return result; + } + + @Override + public byte[] serialize(MediaContent content) throws Exception + { + ByteArrayOutputStream baos = outputStream(content); + XMLStreamWriter writer = createWriter(baos); + _serializer.writeDocument(writer, content); + writer.flush(); + writer.close(); + return baos.toByteArray(); + } + + @Override + public final void serializeItems(MediaContent[] items, OutputStream out) throws XMLStreamException + { + // XML requires single root, so add bogus "stream" + XMLStreamWriter writer = createWriter(out); + _serializer.writeDocument(writer, items); + writer.flush(); + writer.close(); + } + + } \ No newline at end of file diff --git a/jvm-serializers-tpc/src/main/java/serializers/xml/ExiExificient.java b/jvm-serializers-tpc/src/main/java/serializers/xml/ExiExificient.java new file mode 100644 index 0000000..d01cab6 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/xml/ExiExificient.java @@ -0,0 +1,241 @@ +package serializers.xml; + +import java.io.*; + +import javax.xml.namespace.NamespaceContext; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; +import javax.xml.stream.XMLStreamWriter; + +import com.siemens.ct.exi.EXIFactory; +import com.siemens.ct.exi.api.stream.StAXDecoder; +import com.siemens.ct.exi.api.stream.StAXEncoder; +import com.siemens.ct.exi.helpers.DefaultEXIFactory; + +import serializers.*; + +public class ExiExificient +{ + public static void register(TestGroups groups) + { + groups.media.add(JavaBuiltIn.mediaTransformer, new ExificientSerializer(), + new SerFeatures( + SerFormat.XML, + SerGraph.UNKNOWN, + SerClass.ZERO_KNOWLEDGE, + "" + ) + ); + } + + public static final class ExificientSerializer extends BaseStaxMediaSerializer + { + private final static EXIFactory _exiFactory = DefaultEXIFactory.newInstance(); + + public ExificientSerializer() { + // as of 0.9.1, getElementText() not implemented. Boo. + super(false); + } + + @Override + public String getName() { return "xml/exi-manual"; } + + @Override + protected XMLStreamReader createReader(InputStream in) throws XMLStreamException { + try { + StAXDecoder dec = new StAXDecoder(_exiFactory); + dec.setInputStream(in); + return dec; + } catch (Exception e) { + throw new XMLStreamException(e); + } + } + + @Override + protected XMLStreamWriter createWriter(OutputStream out) throws XMLStreamException { + try { + StAXEncoder enc = new StAXEncoder(_exiFactory); + enc.setOutputStream(out); + // Hmmmmmh. And why does it not implement XMLStreamWriter?! + return new WriterWrapper(enc); + } catch (Exception e) { + throw new XMLStreamException(e); + } + } + } + + final static class WriterWrapper implements XMLStreamWriter + { + private final StAXEncoder _encoder; + + public WriterWrapper(StAXEncoder enc) { _encoder = enc; } + + @Override + public void close() throws XMLStreamException { } + + @Override + public void flush() throws XMLStreamException { } + + @Override + public NamespaceContext getNamespaceContext() { + return null; + } + + @Override + public String getPrefix(String arg0) throws XMLStreamException { + return null; + } + + @Override + public Object getProperty(String arg0) throws IllegalArgumentException { + return null; + } + + @Override + public void setDefaultNamespace(String arg0) throws XMLStreamException { + } + + @Override + public void setNamespaceContext(NamespaceContext arg0) + throws XMLStreamException + { + } + + @Override + public void setPrefix(String arg0, String arg1) throws XMLStreamException { } + + @Override + public void writeAttribute(String localName, String value) throws XMLStreamException { + _encoder.writeAttribute("", "", localName, value); + } + + @Override + public void writeAttribute(String nsURI, String localName, String value) + throws XMLStreamException { + _encoder.writeAttribute("", nsURI, localName, value); + } + + @Override + public void writeAttribute(String prefix, String nsURI, String localName, String value) + throws XMLStreamException { + _encoder.writeAttribute(prefix, nsURI, localName, value); + } + + @Override + public void writeCData(String data) throws XMLStreamException { + _encoder.writeCData(data); + } + + @Override + public void writeCharacters(String text) throws XMLStreamException { + _encoder.writeCharacters(text); + } + + @Override + public void writeCharacters(char[] text, int start, int len) + throws XMLStreamException { + _encoder.writeCharacters(text, start, len); + } + + @Override + public void writeComment(String text) throws XMLStreamException { + _encoder.writeComment(text); + } + + @Override + public void writeDTD(String stuff) throws XMLStreamException { + _encoder.writeDTD(stuff); + } + + @Override + public void writeDefaultNamespace(String arg0) + throws XMLStreamException { + // NOP + } + + @Override + public void writeEmptyElement(String localName) throws XMLStreamException { + _encoder.writeStartElement("", "", localName); + _encoder.writeEndElement(); + } + + @Override + public void writeEmptyElement(String nsURI, String localName) + throws XMLStreamException { + _encoder.writeStartElement("", localName, nsURI); + _encoder.writeEndElement(); + } + + @Override + public void writeEmptyElement(String prefix, String localName, String nsURI) + throws XMLStreamException { + _encoder.writeStartElement(prefix, localName, nsURI); + _encoder.writeEndElement(); + } + + @Override + public void writeEndDocument() throws XMLStreamException { + _encoder.writeEndDocument(); + } + + @Override + public void writeEndElement() throws XMLStreamException { + _encoder.writeEndElement(); + } + + @Override + public void writeEntityRef(String name) throws XMLStreamException { + _encoder.writeEntityRef(name); + } + + @Override + public void writeNamespace(String arg0, String arg1) + throws XMLStreamException { + // NOP + } + + @Override + public void writeProcessingInstruction(String target) throws XMLStreamException { + _encoder.writeProcessingInstruction(target); + } + + @Override + public void writeProcessingInstruction(String target, String data) throws XMLStreamException { + _encoder.writeProcessingInstruction(target, data); + } + + @Override + public void writeStartDocument() throws XMLStreamException { + _encoder.writeStartDocument(); + } + + @Override + public void writeStartDocument(String arg0) throws XMLStreamException { + _encoder.writeStartDocument(); + } + + @Override + public void writeStartDocument(String arg0, String arg1) throws XMLStreamException { + _encoder.writeStartDocument(); + } + + @Override + public void writeStartElement(String localName) throws XMLStreamException { + _encoder.writeStartElement("", localName, ""); + } + + @Override + public void writeStartElement(String nsURI, String localName) + throws XMLStreamException { + _encoder.writeStartElement("", localName, nsURI); + } + + @Override + public void writeStartElement(String prefix, String localName, String nsURI) + throws XMLStreamException + { + _encoder.writeStartElement(prefix, localName, nsURI); + } + + } +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/xml/Jaxb.java b/jvm-serializers-tpc/src/main/java/serializers/xml/Jaxb.java new file mode 100644 index 0000000..947f57e --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/xml/Jaxb.java @@ -0,0 +1,67 @@ +package serializers.xml; + +import data.media.MediaContent; +import serializers.*; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; + +public class Jaxb extends Serializer +{ + public static void register(TestGroups groups) + { + groups.media.add(JavaBuiltIn.mediaTransformer, + new Jaxb<>("xml/JAXB", MediaContent.class), + new SerFeatures( + SerFormat.XML, + SerGraph.FULL_GRAPH, + SerClass.CLASSES_KNOWN, + "" + ) + ); + } + + private final String name; + private final JAXBContext jaxbContext; + + @SuppressWarnings("UnusedParameters") + public Jaxb(String name, Class clazz) + { + this.name = name; + try { + jaxbContext = JAXBContext.newInstance(MediaContent.class); + } catch (JAXBException e) { + throw new IllegalStateException(e); + } + } + + @Override + public String getName() { return name; } + + @Override + public byte[] serialize(T data) throws IOException + { + ByteArrayOutputStream baos = outputStream(data); + try { + jaxbContext.createMarshaller().marshal(data, baos); + } catch (Exception e) { + throw new IOException(e); + } + return baos.toByteArray(); + } + + @Override + public T deserialize(byte[] data) throws Exception + { + try { + @SuppressWarnings("unchecked") + T result = (T) jaxbContext.createUnmarshaller().unmarshal(new ByteArrayInputStream(data)); + return result; + } catch (Exception e) { + throw new IOException(e); + } + } +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/xml/JaxbAalto.java b/jvm-serializers-tpc/src/main/java/serializers/xml/JaxbAalto.java new file mode 100644 index 0000000..d84a62c --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/xml/JaxbAalto.java @@ -0,0 +1,83 @@ +package serializers.xml; + +import com.fasterxml.aalto.stax.InputFactoryImpl; +import com.fasterxml.aalto.stax.OutputFactoryImpl; +import data.media.MediaContent; +import serializers.*; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLOutputFactory; +import javax.xml.stream.XMLStreamReader; +import javax.xml.stream.XMLStreamWriter; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; + +public class JaxbAalto extends Serializer +{ + public static void register(TestGroups groups) + { + groups.media.add(JavaBuiltIn.mediaTransformer, + new JaxbAalto<>("xml/JAXB/aalto", MediaContent.class, + new InputFactoryImpl(), new OutputFactoryImpl()), + new SerFeatures( + SerFormat.XML, + SerGraph.FULL_GRAPH, + SerClass.CLASSES_KNOWN, + "" + ) + ); + } + + private final String name; + private final XMLInputFactory inputFactory; + private final XMLOutputFactory outputFactory; + private final JAXBContext jaxbContext; + + @SuppressWarnings("UnusedParameters") + public JaxbAalto(String name, Class clazz, + XMLInputFactory inputF, XMLOutputFactory outputF) + { + this.name = name; + inputFactory = inputF; + outputFactory = outputF; + try { + jaxbContext = JAXBContext.newInstance(MediaContent.class); + } catch (JAXBException e) { + throw new IllegalStateException(e); + } + } + + @Override + public String getName() { return name; } + + @Override + public byte[] serialize(T data) throws IOException + { + ByteArrayOutputStream baos = outputStream(data); + try { + XMLStreamWriter sw = outputFactory.createXMLStreamWriter(baos, "UTF-8"); + jaxbContext.createMarshaller().marshal(data, sw); + sw.close(); + } catch (Exception e) { + throw new IOException(e); + } + return baos.toByteArray(); + } + + @Override + public T deserialize(byte[] data) throws Exception + { + try { + XMLStreamReader sr = inputFactory.createXMLStreamReader(new ByteArrayInputStream(data)); + @SuppressWarnings("unchecked") + T result = (T) jaxbContext.createUnmarshaller().unmarshal(sr); + sr.close(); + return result; + } catch (Exception e) { + throw new IOException(e); + } + } +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/xml/StaxDeserializer.java b/jvm-serializers-tpc/src/main/java/serializers/xml/StaxDeserializer.java new file mode 100644 index 0000000..33f7586 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/xml/StaxDeserializer.java @@ -0,0 +1,199 @@ +package serializers.xml; + +import static data.media.FieldMapping.FULL_FIELD_NAME_BITRATE; +import static data.media.FieldMapping.FULL_FIELD_NAME_COPYRIGHT; +import static data.media.FieldMapping.FULL_FIELD_NAME_DURATION; +import static data.media.FieldMapping.FULL_FIELD_NAME_FORMAT; +import static data.media.FieldMapping.FULL_FIELD_NAME_HEIGHT; +import static data.media.FieldMapping.FULL_FIELD_NAME_IMAGES; +import static data.media.FieldMapping.FULL_FIELD_NAME_MEDIA; +import static data.media.FieldMapping.FULL_FIELD_NAME_PERSONS; +import static data.media.FieldMapping.FULL_FIELD_NAME_PLAYER; +import static data.media.FieldMapping.FULL_FIELD_NAME_SIZE; +import static data.media.FieldMapping.FULL_FIELD_NAME_TITLE; +import static data.media.FieldMapping.FULL_FIELD_NAME_URI; +import static data.media.FieldMapping.FULL_FIELD_NAME_WIDTH; + +import java.util.ArrayList; +import java.util.List; + +import javax.xml.stream.*; + +import data.media.Image; +import data.media.Media; +import data.media.MediaContent; + +public class StaxDeserializer +{ + protected final boolean _workingGetElementText; + + public StaxDeserializer(boolean workingGetElementText) + { + _workingGetElementText = workingGetElementText; + } + + public final MediaContent readDocument(XMLStreamReader parser) throws XMLStreamException + { + return readMediaContent(parser); + } + + public final MediaContent[] readDocument(XMLStreamReader parser, int items) throws XMLStreamException + { + MediaContent[] result = new MediaContent[items]; + searchTag(parser, XmlStax.STREAM_ROOT); + for (int i = 0; i < items; ++i) { + result[i] = readMediaContent(parser); + } + // and should have closing tag at this point + if (parser.nextTag() != XMLStreamConstants.END_ELEMENT) { + throw new IllegalStateException("Expected closing tag, got: "+parser.getEventType()); + } + if (!XmlStax.STREAM_ROOT.equals(parser.getLocalName())) { + throw new IllegalStateException("Expected closing , got "); + } + return result; + } + + private MediaContent readMediaContent(XMLStreamReader parser) throws XMLStreamException + { + searchTag(parser, "mc"); + Media media = readMedia(parser); + List images = new ArrayList(); + if (parser.nextTag() != XMLStreamConstants.START_ELEMENT) { + throw new IllegalStateException("Expected , no START_ELEMENT encountered but "+parser.getEventType()); + } + do { + if (!FULL_FIELD_NAME_IMAGES.equals(parser.getLocalName())) { + throw new IllegalStateException("Expected <"+FULL_FIELD_NAME_IMAGES+">, got <"+parser.getLocalName()+">"); + } + images.add(readImage(parser)); + } while (parser.nextTag() == XMLStreamConstants.START_ELEMENT); + // and should have closing at this point + if (!"mc".equals(parser.getLocalName())) { + throw new IllegalStateException("Expected closing , got "); + } + return new MediaContent(media, images); + } + + private Image readImage (XMLStreamReader parser) throws XMLStreamException + { + Image image = new Image(); + image.uri = readElement(parser, FULL_FIELD_NAME_URI); + image.title = readElement(parser, FULL_FIELD_NAME_TITLE); + image.width = Integer.parseInt(readElement(parser, FULL_FIELD_NAME_WIDTH)); + image.height = Integer.parseInt(readElement(parser, FULL_FIELD_NAME_HEIGHT)); + image.size = imageSize(readElement(parser, FULL_FIELD_NAME_SIZE)); + // need to match close tag + if (parser.nextTag() != XMLStreamConstants.END_ELEMENT) { + throw new IllegalStateException("Expected closing "); + } + return image; + } + + private Image.Size imageSize(String value) { + if (value == null) { + throw new IllegalStateException("Missing 'size' value for Image (null)"); + } + return Image.Size.valueOf(value); + } + + + private Media readMedia (XMLStreamReader parser) throws XMLStreamException + { + Media media = new Media(); + media.player = Media.Player.valueOf(readElement(parser, FULL_FIELD_NAME_PLAYER)); + media.uri = readElement(parser, FULL_FIELD_NAME_URI); + media.title = readElementMaybe(parser, FULL_FIELD_NAME_TITLE); + media.width = Integer.parseInt(readElement(parser, FULL_FIELD_NAME_WIDTH)); + media.height = Integer.parseInt(readElement(parser, FULL_FIELD_NAME_HEIGHT)); + media.format = readElement(parser, FULL_FIELD_NAME_FORMAT); + media.duration = Long.parseLong(readElement(parser, FULL_FIELD_NAME_DURATION)); + media.size = Long.parseLong(readElement(parser, FULL_FIELD_NAME_SIZE)); + String bitrateString = readElement(parser, FULL_FIELD_NAME_BITRATE); + if (bitrateString != null) { + media.hasBitrate = true; + media.bitrate = Integer.parseInt(bitrateString); + } + media.copyright = readElementMaybe(parser, FULL_FIELD_NAME_COPYRIGHT); + + searchTag(parser, FULL_FIELD_NAME_PERSONS); + List persons = new ArrayList(); + do { + persons.add(_getElementText(parser)); + } while (parser.nextTag() == XMLStreamConstants.START_ELEMENT + && FULL_FIELD_NAME_PERSONS.equals(parser.getLocalName())); + if (!FULL_FIELD_NAME_MEDIA.equals(parser.getLocalName())) { + throw new IllegalStateException("Expected closing , got "); + } + media.persons = persons; + return media; + } + + private String readElementMaybe(XMLStreamReader parser, String string) throws XMLStreamException + { + if (parser.getEventType() != XMLStreamConstants.START_ELEMENT) { + while (parser.next() != XMLStreamConstants.START_ELEMENT) { } + } + return (parser.getLocalName().equals(string)) ? _getElementText(parser) : null; + } + + private String readElement(XMLStreamReader parser, String string) throws XMLStreamException + { + // If not at START_ELEMENT, find one (usually called when at END_ELEMENT) + if (parser.getEventType() != XMLStreamConstants.START_ELEMENT) { + while (parser.next() != XMLStreamConstants.START_ELEMENT) { } + } + while (true) { + if (parser.getLocalName().equals(string)) { + return _getElementText(parser); + } + while (parser.next() != XMLStreamConstants.START_ELEMENT) { } + } + } + + protected void searchTag(XMLStreamReader parser, String string) throws XMLStreamException + { + // may already be located at the start element + if (parser.getEventType() == XMLStreamConstants.START_ELEMENT + && parser.getLocalName().equals(string)) { + return; + } + while (true) { + if (parser.nextTag() == XMLStreamConstants.START_ELEMENT + && parser.getLocalName().equals(string)) { + return; + } + } + } + + private final String _getElementText(XMLStreamReader parser) throws XMLStreamException + { + if (_workingGetElementText) { + return parser.getElementText(); + } + + /* This is not optimal if there are more than two segments; but really + * it should not matter -- impls SHOULD implement getElementText() properly + * so this is just a fallback. Also, unlikely we'll get more than one segment + * in most cases. + */ + + String text = null; + int t; + + while (parser.hasNext()) { + t = parser.next(); + if (t == XMLStreamConstants.END_ELEMENT) { + break; + } + if (t == XMLStreamConstants.CHARACTERS || t == XMLStreamConstants.CDATA) { + if (text == null) { + text = parser.getText(); + } else { + text += parser.getText(); + } + } + } + return (text == null) ? "" : text; + } +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/xml/StaxSerializer.java b/jvm-serializers-tpc/src/main/java/serializers/xml/StaxSerializer.java new file mode 100644 index 0000000..911edd2 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/xml/StaxSerializer.java @@ -0,0 +1,92 @@ +package serializers.xml; + +import static data.media.FieldMapping.FULL_FIELD_NAME_BITRATE; +import static data.media.FieldMapping.FULL_FIELD_NAME_COPYRIGHT; +import static data.media.FieldMapping.FULL_FIELD_NAME_DURATION; +import static data.media.FieldMapping.FULL_FIELD_NAME_FORMAT; +import static data.media.FieldMapping.FULL_FIELD_NAME_HEIGHT; +import static data.media.FieldMapping.FULL_FIELD_NAME_IMAGES; +import static data.media.FieldMapping.FULL_FIELD_NAME_MEDIA; +import static data.media.FieldMapping.FULL_FIELD_NAME_PERSONS; +import static data.media.FieldMapping.FULL_FIELD_NAME_PLAYER; +import static data.media.FieldMapping.FULL_FIELD_NAME_SIZE; +import static data.media.FieldMapping.FULL_FIELD_NAME_TITLE; +import static data.media.FieldMapping.FULL_FIELD_NAME_URI; +import static data.media.FieldMapping.FULL_FIELD_NAME_WIDTH; + +import javax.xml.stream.*; + +import data.media.Image; +import data.media.Media; +import data.media.MediaContent; + +public class StaxSerializer +{ + public void writeDocument(XMLStreamWriter writer, MediaContent content) + throws XMLStreamException + { + writer.writeStartDocument("UTF-8", "1.0"); + writeMediaContent(writer, content); + writer.writeEndDocument(); + } + + public void writeDocument(XMLStreamWriter writer, MediaContent[] items) + throws XMLStreamException + { + writer.writeStartDocument("UTF-8", "1.0"); + writer.writeStartElement(XmlStax.STREAM_ROOT); + for (MediaContent item : items) { + writeMediaContent(writer, item); + } + writer.writeEndElement(); + writer.writeEndDocument(); + } + + private void writeMediaContent(XMLStreamWriter writer, MediaContent content) + throws XMLStreamException + { + writer.writeStartElement("mc"); + writeMedia(writer, content.media); + for (Image image : content.images) { + writeImage(writer, image); + } + writer.writeEndElement(); + } + + private void writeImage (XMLStreamWriter writer, Image image) throws XMLStreamException + { + writer.writeStartElement(FULL_FIELD_NAME_IMAGES); + writeElement(writer, FULL_FIELD_NAME_URI, image.uri); + if (image.title != null) writeElement(writer, FULL_FIELD_NAME_TITLE, image.title); + writeElement(writer, FULL_FIELD_NAME_WIDTH, String.valueOf(image.width)); + writeElement(writer, FULL_FIELD_NAME_HEIGHT, String.valueOf(image.height)); + writeElement(writer, FULL_FIELD_NAME_SIZE, image.size.name()); + writer.writeEndElement(); + } + + private void writeElement(XMLStreamWriter writer, String name, String value) throws XMLStreamException + { + writer.writeStartElement(name); + writer.writeCharacters(value); + writer.writeEndElement(); + } + + private void writeMedia (XMLStreamWriter writer, Media media) throws XMLStreamException + { + writer.writeStartElement(FULL_FIELD_NAME_MEDIA); + writeElement(writer, FULL_FIELD_NAME_PLAYER, media.player.name()); + writeElement(writer, FULL_FIELD_NAME_URI, media.uri); + if (media.title != null) writeElement(writer, FULL_FIELD_NAME_TITLE, media.title); + writeElement(writer, FULL_FIELD_NAME_WIDTH, String.valueOf(media.width)); + writeElement(writer, FULL_FIELD_NAME_HEIGHT, String.valueOf(media.height)); + writeElement(writer, FULL_FIELD_NAME_FORMAT, media.format); + writeElement(writer, FULL_FIELD_NAME_DURATION, String.valueOf(media.duration)); + writeElement(writer, FULL_FIELD_NAME_SIZE, String.valueOf(media.size)); + if (media.hasBitrate) writeElement(writer, FULL_FIELD_NAME_BITRATE, String.valueOf(media.bitrate)); + if (media.copyright != null) writeElement(writer, FULL_FIELD_NAME_COPYRIGHT, media.copyright); + for (String person : media.persons) { + writeElement(writer, FULL_FIELD_NAME_PERSONS, person); + } + writer.writeEndElement(); + } +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/xml/XmlJavolution.java b/jvm-serializers-tpc/src/main/java/serializers/xml/XmlJavolution.java new file mode 100644 index 0000000..79fe7d4 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/xml/XmlJavolution.java @@ -0,0 +1,203 @@ +package serializers.xml; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.util.ArrayList; +import java.util.List; + +import serializers.*; + +import javolution.text.CharArray; +import javolution.xml.XMLBinding; +import javolution.xml.XMLFormat; +import javolution.xml.XMLObjectReader; +import javolution.xml.XMLObjectWriter; +import javolution.xml.stream.XMLStreamException; + +import data.media.*; +import static data.media.FieldMapping.*; + +public class XmlJavolution +{ + public final static String ROOT_ELEMENT = "mc"; + + public static void register(TestGroups groups) + { + groups.media.add(JavaBuiltIn.mediaTransformer, new JavolutionSerializer(MediaBinding, MediaContent.class), + new SerFeatures( + SerFormat.XML, + SerGraph.FLAT_TREE, + SerClass.MANUAL_OPT, + "" + ) + ); + // commented-out by dyu: use the non-abbreviated version + //groups.media.add(JavaBuiltIn.MediaTransformer, new JavolutionSerializer("-abbrev", MediaBindingAbbreviated, MediaContent.class)); + } + + private static final class JavolutionSerializer extends Serializer + { + private final XMLBinding binding; + private final Class clazz; + + public JavolutionSerializer(XMLBinding binding, Class clazz) + { + this.binding = binding; + this.clazz = clazz; + } + + @Override + public String getName() { return "xml/javolution/manual"; } + + @Override + public T deserialize(byte[] array) throws Exception + { + XMLObjectReader reader = XMLObjectReader.newInstance(new ByteArrayInputStream(array)).setBinding(binding); + try { + return reader.read(ROOT_ELEMENT, clazz); + } finally { + reader.close(); + } + } + + @Override + public byte[] serialize(T content) throws Exception + { + ByteArrayOutputStream baos = outputStream(content); + XMLObjectWriter writer = XMLObjectWriter.newInstance(baos).setBinding(binding); + writer.write(content, ROOT_ELEMENT, clazz); + writer.close(); + baos.close(); + return baos.toByteArray(); + } + } + + @SuppressWarnings("serial") + private static final XMLBinding MediaBinding = new XMLBinding() + { + { + setAlias(MediaContent.class, ROOT_ELEMENT); + setAlias(Image.class, FULL_FIELD_NAME_IMAGES); + setAlias(Media.class, FULL_FIELD_NAME_MEDIA); + setAlias(String.class, "str"); + } + + private XMLFormat toGeneric(XMLFormat specific) + { + @SuppressWarnings("unchecked") + XMLFormat generic = (XMLFormat) specific; + return generic; + } + + // silly javolution does not use generics properly.... + @SuppressWarnings("unchecked") + @Override + public XMLFormat getFormat(Class cls) throws XMLStreamException + { + if (MediaContent.class.equals(cls)) + return toGeneric(MediaContentConverter); + if (Media.class.equals(cls)) + return toGeneric(MediaConverter); + if (Image.class.equals(cls)) + return toGeneric(ImageConverter); + return super.getFormat(cls); + } + + private final XMLFormat ImageConverter = new XMLFormat(null) + { + @Override + public void write(Image image, XMLFormat.OutputElement xml) throws XMLStreamException + { + xml.setAttribute(FULL_FIELD_NAME_URI, image.uri); + xml.setAttribute(FULL_FIELD_NAME_TITLE, image.title); + xml.setAttribute(FULL_FIELD_NAME_WIDTH, image.width); + xml.setAttribute(FULL_FIELD_NAME_HEIGHT, image.height); + xml.setAttribute(FULL_FIELD_NAME_SIZE, image.size.ordinal()); + } + + @Override + public void read(XMLFormat.InputElement xml, Image image) throws XMLStreamException + { + image.uri = xml.getAttribute(FULL_FIELD_NAME_URI).toString(); + image.title = xml.getAttribute(FULL_FIELD_NAME_TITLE, (String) null); + image.width = xml.getAttribute(FULL_FIELD_NAME_WIDTH).toInt(); + image.height = xml.getAttribute(FULL_FIELD_NAME_HEIGHT).toInt(); + image.size = Image.Size.values()[xml.getAttribute(FULL_FIELD_NAME_SIZE, 0)]; + } + }; + + private final XMLFormat MediaConverter = new XMLFormat(null) + { + @Override + public void write(Media media, XMLFormat.OutputElement xml) throws XMLStreamException + { + xml.setAttribute(FULL_FIELD_NAME_URI, media.uri); + xml.setAttribute(FULL_FIELD_NAME_TITLE, media.title); + xml.setAttribute(FULL_FIELD_NAME_WIDTH, media.width); + xml.setAttribute(FULL_FIELD_NAME_HEIGHT, media.height); + xml.setAttribute(FULL_FIELD_NAME_FORMAT, media.format); + xml.setAttribute(FULL_FIELD_NAME_DURATION, media.duration); + xml.setAttribute(FULL_FIELD_NAME_SIZE, media.size); + if (media.hasBitrate) xml.setAttribute(FULL_FIELD_NAME_BITRATE, media.bitrate); + xml.setAttribute(FULL_FIELD_NAME_PLAYER, media.player.ordinal()); + xml.setAttribute(FULL_FIELD_NAME_COPYRIGHT, media.copyright); + + for (String p : media.persons) { + xml.add(p); + } + } + + @Override + public void read(XMLFormat.InputElement xml, Media media) throws XMLStreamException + { + media.uri = xml.getAttribute(FULL_FIELD_NAME_URI).toString(); + media.title = xml.getAttribute(FULL_FIELD_NAME_TITLE, (String) null); + media.width = xml.getAttribute(FULL_FIELD_NAME_WIDTH).toInt(); + media.height = xml.getAttribute(FULL_FIELD_NAME_HEIGHT).toInt(); + media.format = xml.getAttribute(FULL_FIELD_NAME_FORMAT).toString(); + media.duration = xml.getAttribute(FULL_FIELD_NAME_DURATION).toLong(); + media.size = xml.getAttribute(FULL_FIELD_NAME_SIZE).toLong(); + CharArray caBitrate = xml.getAttribute(FULL_FIELD_NAME_BITRATE); + media.hasBitrate = (caBitrate != null); + if (caBitrate != null) media.bitrate = caBitrate.toInt(); + media.player = Media.Player.values()[xml.getAttribute(FULL_FIELD_NAME_PLAYER, 0)]; + media.copyright = xml.getAttribute(FULL_FIELD_NAME_COPYRIGHT, (String) null); + + List persons = new ArrayList(); + while (xml.hasNext()) { + persons.add((String)xml.getNext()); + } + media.persons = persons; + } + }; + + private final XMLFormat MediaContentConverter = new XMLFormat(null) + { + @Override + public void write(MediaContent content, XMLFormat.OutputElement xml) throws XMLStreamException + { + xml.add(content.media); + for (Image image : content.images) { + xml.add(image); + } + } + + @Override + public MediaContent newInstance(java.lang.Class cls, XMLFormat.InputElement xml) throws XMLStreamException + { + Media media = (Media) xml.getNext(); + List images = new ArrayList(); + while (xml.hasNext()) { + images.add((Image) xml.getNext()); + } + return new MediaContent(media, images); + } + + @Override + public void read(javolution.xml.XMLFormat.InputElement arg0, MediaContent arg1) + { + // Do nothing; Object loaded by newInstance; + } + }; + }; +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/xml/XmlStax.java b/jvm-serializers-tpc/src/main/java/serializers/xml/XmlStax.java new file mode 100644 index 0000000..28ac2cb --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/xml/XmlStax.java @@ -0,0 +1,113 @@ +package serializers.xml; + +import java.io.*; + +import javax.xml.stream.*; + +import serializers.*; + +/** + * Codec that works with standard full Stax implementations, where + * we have Stax input and output factories. + */ +public class XmlStax +{ + /** + * Since XML streams must still have a single root, we'll use + * this as the tag + */ + public final static String STREAM_ROOT = "stream"; + + public static final Handler[] HANDLERS = new Handler[] { + new Handler("woodstox", + new com.ctc.wstx.stax.WstxInputFactory(), + new com.ctc.wstx.stax.WstxOutputFactory()), + new Handler("aalto", + new com.fasterxml.aalto.stax.InputFactoryImpl(), + new com.fasterxml.aalto.stax.OutputFactoryImpl()), + new Handler("fastinfo", + new com.sun.xml.fastinfoset.stax.factory.StAXInputFactory(), + new com.sun.xml.fastinfoset.stax.factory.StAXOutputFactory()), + }; + + public static void register(TestGroups groups, boolean woodstox, boolean aalto, boolean fastinfoset) + { + if (woodstox) { + groups.media.add(JavaBuiltIn.mediaTransformer, new StaxMediaSerializer(HANDLERS[0]), + new SerFeatures( + SerFormat.XML, + SerGraph.UNKNOWN, + SerClass.MANUAL_OPT, + "" + ) + ); + + } + if (aalto) { + groups.media.add(JavaBuiltIn.mediaTransformer, new StaxMediaSerializer(HANDLERS[1]), + new SerFeatures( + SerFormat.XML, + SerGraph.UNKNOWN, + SerClass.MANUAL_OPT, + "" + ) + ); + } + if (fastinfoset) { + groups.media.add(JavaBuiltIn.mediaTransformer, new StaxMediaSerializer(HANDLERS[2]), + new SerFeatures( + SerFormat.XML, + SerGraph.UNKNOWN, + SerClass.MANUAL_OPT, + "" + ) + ); + } + } + + // ------------------------------------------------------------------- + // Implementations + + public static final class Handler + { + protected final String name; + protected final XMLInputFactory inFactory; + protected final XMLOutputFactory outFactory; + + protected Handler(String name, XMLInputFactory inFactory, XMLOutputFactory outFactory) + { + this.name = name; + this.inFactory = inFactory; + this.outFactory = outFactory; + } + } + + // ------------------------------------------------------------------- + // Serializers + + // Serializer for full Stax implementations + public static final class StaxMediaSerializer extends BaseStaxMediaSerializer + { + private final Handler handler; + + public StaxMediaSerializer(Handler handler) + { + // yes, standard implementations better implement it correctly + super(true); + this.handler = handler; + } + + @Override + public String getName() { return "xml/"+handler.name+"-manual"; } + + @Override + protected XMLStreamReader createReader(InputStream in) throws XMLStreamException { + return handler.inFactory.createXMLStreamReader(in); + } + + @Override + protected XMLStreamWriter createWriter(OutputStream out) throws XMLStreamException { + return handler.outFactory.createXMLStreamWriter(out, "UTF-8"); + } + } +} diff --git a/jvm-serializers-tpc/src/main/java/serializers/xml/XmlXStream.java b/jvm-serializers-tpc/src/main/java/serializers/xml/XmlXStream.java new file mode 100644 index 0000000..34e04c1 --- /dev/null +++ b/jvm-serializers-tpc/src/main/java/serializers/xml/XmlXStream.java @@ -0,0 +1,424 @@ +package serializers.xml; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; + +import com.thoughtworks.xstream.converters.Converter; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.converters.UnmarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import com.thoughtworks.xstream.io.xml.StaxDriver; +import com.thoughtworks.xstream.io.xml.XppDriver; + +import data.media.Image; +import data.media.Media; +import data.media.MediaContent; +import data.media.Media.Player; +import data.media.Image.Size; + +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLOutputFactory; + +import serializers.*; + +import java.io.Writer; +import java.util.ArrayList; +import java.util.List; + +import com.thoughtworks.xstream.io.xml.CompactWriter; + +@SuppressWarnings("rawtypes") +public class XmlXStream +{ + public static void register(TestGroups groups) + { + // The default XStream serializer. + // commented-out by dyu: the perf of the default sux. + /*groups.media.add(JavaBuiltIn.MediaTransformer, new ConverterSerializer("xml/xstream", + new com.thoughtworks.xstream.XStream(new XppDriver() { + public HierarchicalStreamWriter createWriter(Writer out) { + //return new PrettyPrintWriter(out, xmlFriendlyReplacer()); + return new CompactWriter(out, xmlFriendlyReplacer()); + } + }), EmptyConfiguration));*/ + + groups.media.add(JavaBuiltIn.mediaTransformer, new ConverterSerializer("xml/xstream+c", + new com.thoughtworks.xstream.XStream(new XppDriver() { + public HierarchicalStreamWriter createWriter(Writer out) { + //return new PrettyPrintWriter(out, xmlFriendlyReplacer()); + return new CompactWriter(out, xmlFriendlyReplacer()); + } + }), MediaConfiguration), + new SerFeatures( + SerFormat.XML, + SerGraph.FLAT_TREE, + SerClass.ZERO_KNOWLEDGE, + "" + ) + ); + + // commented-out by dyu: use the non-abbreviated version + /*groups.media.add(JavaBuiltIn.MediaTransformer, new ConverterSerializer("xml/xstream+c-abbrev", + new com.thoughtworks.xstream.XStream(new XppDriver() { + public HierarchicalStreamWriter createWriter(Writer out) { + //return new PrettyPrintWriter(out, xmlFriendlyReplacer()); + return new CompactWriter(out, xmlFriendlyReplacer()); + } + }), MediaConfigurationAbbreviated));*/ + + // Adapt each of the STAX handlers to use XStream + for (XmlStax.Handler h : XmlStax.HANDLERS) { + // TODO: This doesn't work yet. Need to properly handle optional fields in readMedia/readImage. + // commented-out by dyu: use the non-abbreviated version (+c) because the perf of the default sux. + //groups.media.add(JavaBuiltIn.MediaTransformer, XStream.mkStaxSerializer(h, "", EmptyConfiguration)); + groups.media.add(JavaBuiltIn.mediaTransformer, XmlXStream.mkStaxSerializer(h, "+c", MediaConfiguration), + new SerFeatures( + SerFormat.XML, + SerGraph.FLAT_TREE, + SerClass.MANUAL_OPT, + "" + ) + ); + //groups.media.add(JavaBuiltIn.MediaTransformer, XStream.mkStaxSerializer(h, "+c-abbrev", MediaConfigurationAbbreviated)); + } + } + + private static ConverterSerializer mkStaxSerializer(final XmlStax.Handler handler, String suffix, Configuration config) + { + return new ConverterSerializer("xml/xstream" + suffix + "-" + handler.name, + new com.thoughtworks.xstream.XStream(new StaxDriver() { + public XMLInputFactory getInputFactory() { return handler.inFactory; } + public XMLOutputFactory getOutputFactory() { return handler.outFactory; } + }), config); + } + + public static final class ConverterSerializer extends Serializer + { + private String name; + private com.thoughtworks.xstream.XStream xstream; + + public ConverterSerializer(String name, com.thoughtworks.xstream.XStream xstream, Configuration config) + { + this.name = name; + this.xstream = xstream; + + config.run(xstream); + } + + public String getName() { return name; } + + public T deserialize(byte[] array) throws Exception + { + @SuppressWarnings("unchecked") + T value = (T) xstream.fromXML(new ByteArrayInputStream(array)); + return value; + } + + public byte[] serialize(T content) throws IOException + { + ByteArrayOutputStream baos = outputStream(content); + xstream.toXML(content, baos); + return baos.toByteArray(); + } + } + + public static abstract class Configuration + { + public abstract void run(com.thoughtworks.xstream.XStream xstream); + } + + // ----------------------------------------------------------------------- + // Serializer: Media + + public static final Configuration EmptyConfiguration = new Configuration() + { + public void run(com.thoughtworks.xstream.XStream xstream) {} + }; + + public static final Configuration MediaConfiguration = new MediaConfiguration(); + public static class MediaConfiguration extends Configuration + { + public void run(com.thoughtworks.xstream.XStream xstream) + { + xstream.alias("Image", Image.class); + xstream.registerConverter(new ImageConverter()); + + xstream.alias("Media", Media.class); + xstream.registerConverter(new MediaConverter()); + + xstream.alias("MediaContent", MediaContent.class); + xstream.registerConverter(new MediaContentConverter()); + } + + private static class MediaContentConverter implements Converter + { + public void marshal(Object obj, HierarchicalStreamWriter writer, MarshallingContext context) + { + MediaContent content = (MediaContent) obj; + writer.startNode("Media"); + context.convertAnother(content.media); + writer.endNode(); + for (Image image : content.images) { + writer.startNode("Image"); + context.convertAnother(image); + writer.endNode(); + } + } + + public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) + { + reader.moveDown(); + Media media = (Media) context.convertAnother(null, Media.class); + reader.moveUp(); + + List images = new ArrayList(); + while (reader.hasMoreChildren()) { + reader.moveDown(); + images.add((Image) context.convertAnother(images, Image.class)); + reader.moveUp(); + } + + return new MediaContent(media, images); + } + + @Override + public boolean canConvert(Class arg0) + { + return MediaContent.class.equals(arg0); + } + } + + private static class ImageConverter implements Converter + { + public void marshal(Object obj, HierarchicalStreamWriter writer, MarshallingContext context) + { + Image image = (Image) obj; + writer.addAttribute("uri", image.uri); + if (image.title != null) writer.addAttribute("title", image.title); + writer.addAttribute("width", String.valueOf(image.width)); + writer.addAttribute("height", String.valueOf(image.height)); + writer.addAttribute("size", String.valueOf(image.size.ordinal())); + } + + public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) + { + Image image = new Image(); + image.uri = reader.getAttribute("uri"); + image.title = reader.getAttribute("title"); + image.width = Integer.valueOf(reader.getAttribute("width")); + image.height = Integer.valueOf(reader.getAttribute("height")); + image.size = Size.values()[Integer.valueOf(reader.getAttribute("size"))]; + return image; + } + + @Override + public boolean canConvert(Class arg0) + { + return Image.class.equals(arg0); + } + } + + private static class MediaConverter implements Converter + { + public void marshal(Object obj, HierarchicalStreamWriter writer, MarshallingContext context) + { + Media media = (Media) obj; + writer.addAttribute("player", String.valueOf(media.player.ordinal())); + writer.addAttribute("uri", media.uri); + if (media.title != null) writer.addAttribute("title", media.title); + writer.addAttribute("width", String.valueOf(media.width)); + writer.addAttribute("height", String.valueOf(media.height)); + writer.addAttribute("format", media.format); + writer.addAttribute("duration", String.valueOf(media.duration)); + writer.addAttribute("size", String.valueOf(media.size)); + if (media.hasBitrate) writer.addAttribute("bitrate", String.valueOf(media.bitrate)); + if (media.copyright != null) writer.addAttribute("copyright", media.copyright); + for (String p : media.persons) + { + writer.startNode("person"); + writer.setValue(p); + writer.endNode(); + } + } + + public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) + { + Media media = new Media(); + media.player = Player.values()[Integer.valueOf(reader.getAttribute("player"))]; + media.uri = reader.getAttribute("uri"); + media.title = reader.getAttribute("title"); + media.width = Integer.valueOf(reader.getAttribute("width")); + media.height = Integer.valueOf(reader.getAttribute("height")); + media.format = reader.getAttribute("format"); + media.duration = Long.valueOf(reader.getAttribute("duration")); + media.size = Long.valueOf(reader.getAttribute("size")); + String stringBitrate = reader.getAttribute("bitrate"); + if (stringBitrate != null) { + media.hasBitrate = true; + media.bitrate = Integer.valueOf(stringBitrate); + } + media.copyright = reader.getAttribute("copyright"); + List persons = new ArrayList(); + while (reader.hasMoreChildren()) + { + reader.moveDown(); + persons.add(reader.getValue()); + reader.moveUp(); + } + media.persons = persons; + return media; + } + + @Override + public boolean canConvert(Class arg0) + { + return Media.class.equals(arg0); + } + } + }; + + public static final Configuration MediaConfigurationAbbreviated = new MediaConfigurationAbbreviated(); + public static class MediaConfigurationAbbreviated extends Configuration + { + public void run(com.thoughtworks.xstream.XStream xstream) + { + xstream.alias("im", Image.class); + xstream.registerConverter(new ImageConverter()); + + xstream.alias("md", Media.class); + xstream.registerConverter(new MediaConverter()); + + xstream.alias("mc", MediaContent.class); + xstream.registerConverter(new MediaContentConverter()); + } + + private static class MediaContentConverter implements Converter + { + public void marshal(Object obj, HierarchicalStreamWriter writer, MarshallingContext context) + { + MediaContent content = (MediaContent) obj; + writer.startNode("md"); + context.convertAnother(content.media); + writer.endNode(); + for (Image image : content.images) { + writer.startNode("im"); + context.convertAnother(image); + writer.endNode(); + } + } + + public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) + { + reader.moveDown(); + Media media = (Media) context.convertAnother(null, Media.class); + reader.moveUp(); + + List images = new ArrayList(); + while (reader.hasMoreChildren()) { + reader.moveDown(); + images.add((Image) context.convertAnother(images, Image.class)); + reader.moveUp(); + } + + return new MediaContent(media, images); + } + + @Override + public boolean canConvert(Class arg0) + { + return MediaContent.class.equals(arg0); + } + } + + private static class ImageConverter implements Converter + { + public void marshal(Object obj, HierarchicalStreamWriter writer, MarshallingContext context) + { + Image image = (Image) obj; + writer.addAttribute("ul", image.uri); + if (image.title != null) writer.addAttribute("tl", image.title); + writer.addAttribute("wd", String.valueOf(image.width)); + writer.addAttribute("hg", String.valueOf(image.height)); + writer.addAttribute("sz", String.valueOf(image.size.ordinal())); + } + + public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) + { + Image image = new Image(); + image.uri = reader.getAttribute("ul"); + image.title = reader.getAttribute("tl"); + image.width = Integer.valueOf(reader.getAttribute("wd")); + image.height = Integer.valueOf(reader.getAttribute("hg")); + image.size = Size.values()[Integer.valueOf(reader.getAttribute("sz"))]; + return image; + } + + @Override + public boolean canConvert(Class arg0) + { + return Image.class.equals(arg0); + } + + } + + private static class MediaConverter implements Converter + { + public void marshal(Object obj, HierarchicalStreamWriter writer, MarshallingContext context) + { + Media media = (Media) obj; + writer.addAttribute("pl", String.valueOf(media.player.ordinal())); + writer.addAttribute("ul", media.uri); + if (media.title != null) writer.addAttribute("tl", media.title); + writer.addAttribute("wd", String.valueOf(media.width)); + writer.addAttribute("hg", String.valueOf(media.height)); + writer.addAttribute("fr", media.format); + writer.addAttribute("dr", String.valueOf(media.duration)); + writer.addAttribute("sz", String.valueOf(media.size)); + if (media.hasBitrate) writer.addAttribute("br", String.valueOf(media.bitrate)); + if (media.copyright != null) writer.addAttribute("cp", media.copyright); + for (String p : media.persons) + { + writer.startNode("pr"); + writer.setValue(p); + writer.endNode(); + } + } + + public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) + { + Media media = new Media(); + media.player = Player.values()[Integer.valueOf(reader.getAttribute("pl"))]; + media.uri = reader.getAttribute("ul"); + media.title = reader.getAttribute("tl"); + media.width = Integer.valueOf(reader.getAttribute("wd")); + media.height = Integer.valueOf(reader.getAttribute("hg")); + media.format = reader.getAttribute("fr"); + media.duration = Long.valueOf(reader.getAttribute("dr")); + media.size = Long.valueOf(reader.getAttribute("sz")); + String stringBitrate = reader.getAttribute("br"); + if (stringBitrate != null) { + media.hasBitrate = true; + media.bitrate = Integer.valueOf(stringBitrate); + } + media.copyright = reader.getAttribute("cp"); + List persons = new ArrayList(); + while (reader.hasMoreChildren()) + { + reader.moveDown(); + persons.add(reader.getValue()); + reader.moveUp(); + } + media.persons = persons; + return media; + } + + @Override + public boolean canConvert(Class arg0) + { + return Media.class.equals(arg0); + } + } + }; +} diff --git a/jvm-serializers-tpc/src/main/resources/media.1.cks b/jvm-serializers-tpc/src/main/resources/media.1.cks new file mode 100644 index 0000000..549efd5 --- /dev/null +++ b/jvm-serializers-tpc/src/main/resources/media.1.cks @@ -0,0 +1,33 @@ +// The standard test value. +{ + Media = { + Uri = "http://javaone.com/keynote.mpg" + Title = Set: "Javaone Keynote" + Width = 640 + Height = 480 + Format = "video/mpg4" + Duration = 18000000 // half hour in milliseconds + Size = 58982400 // bitrate * duration in seconds / 8 bits per byte + Bitrate = Set: 262144 // 256k + Persons = ["Bill Gates", "Steve Jobs"] + Player = Java + Copyright = None + } + + Images = [ + { + Uri = "http://javaone.com/keynote_large.jpg" + Title = Set: "Javaone Keynote" + Width = 1024 + Height = 768 + Size = Large + } + { + Uri = "http://javaone.com/keynote_small.jpg" + Title = Set: "Javaone Keynote" + Width = 320 + Height = 240 + Size = Small + } + ] +} diff --git a/jvm-serializers-tpc/src/main/resources/media.1.cks-result.txt b/jvm-serializers-tpc/src/main/resources/media.1.cks-result.txt new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/jvm-serializers-tpc/src/main/resources/media.1.cks-result.txt @@ -0,0 +1 @@ + diff --git a/jvm-serializers-tpc/src/main/resources/media.2.cks b/jvm-serializers-tpc/src/main/resources/media.2.cks new file mode 100644 index 0000000..5349c8f --- /dev/null +++ b/jvm-serializers-tpc/src/main/resources/media.2.cks @@ -0,0 +1,41 @@ +// A test value where everything is different from media.1.cks. +// This is mainly used to check if the serializers are "honest". +{ + Media = { + Uri = "http://javaone.com/keynote.ogg" + Title = None + Width = 641 + Height = 481 + Format = "video/theora" + Duration = 18000001 + Size = 58982401 + Bitrate = None + Persons = ["Bill Gates, Jr.", "Steven Jobs"] + Player = Flash + Copyright = Set: "2009, Scooby Doo" + } + + Images = [ + { + Uri = "http://javaone.com/keynote_huge.jpg" + Title = Set: "Javaone Keynote" + Width = 32000 + Height = 24000 + Size = Large + } + { + Uri = "http://javaone.com/keynote_large.jpg" + Title = None + Width = 1024 + Height = 768 + Size = Large + } + { + Uri = "http://javaone.com/keynote_small.jpg" + Title = None + Width = 320 + Height = 240 + Size = Small + } + ] +} diff --git a/jvm-serializers-tpc/src/main/resources/media.3.cks b/jvm-serializers-tpc/src/main/resources/media.3.cks new file mode 100644 index 0000000..14c202f --- /dev/null +++ b/jvm-serializers-tpc/src/main/resources/media.3.cks @@ -0,0 +1,33 @@ +// Long strings. +{ + Media = { + Uri = "http://javaone.com/keynote.mpglkajldfjlskajdflkjslfjdslfjldjfljsdfljsdlfjsljfldjfldjals;djfasldjf;alskdjf;aslkdjf;asdjf;laskdjflsjdalfjd;alksjdfl;jsa;lfdja;slkdjf;alsjfd;lajsfl;dj" + Title = Set: "Javaone Keynotelkajldfjlskajdflkjslfjdslfjldjfljsdfljsdlfjsljfldjfldjals;djfasldjf;alskdjf;aslkdjf;asdjf;laskdjflsjdalfjd;alksjdfl;jsa;lfdja;slkdjf;alsjfd;lajsfl;dj" + Width = 640 + Height = 480 + Format = "video/mpg4lkajldfjlskajdflkjslfjdslfjldjfljsdfljsdlfjsljfldjfldjals;djfasldjf;alskdjf;aslkdjf;asdjf;laskdjflsjdalfjd;alksjdfl;jsa;lfdja;slkdjf;alsjfd;lajsfl;dj" + Duration = 18000000 // half hour in milliseconds + Size = 58982400 // bitrate * duration in seconds / 8 bits per byte + Bitrate = Set: 262144 // 256k + Persons = ["Bill Gateslkajldfjlskajdflkjslfjdslfjldjfljsdfljsdlfjsljfldjfldjals;djfasldjf;alskdjf;aslkdjf;asdjf;laskdjflsjdalfjd;alksjdfl;jsa;lfdja;slkdjf;alsjfd;lajsfl;dj", "Steve Jobslkajldfjlskajdflkjslfjdslfjldjfljsdfljsdlfjsljfldjfldjals;djfasldjf;alskdjf;aslkdjf;asdjf;laskdjflsjdalfjd;alksjdfl;jsa;lfdja;slkdjf;alsjfd;lajsfl;dj"] + Player = Java + Copyright = None + } + + Images = [ + { + Uri = "http://javaone.com/keynote_large.jpglkajldfjlskajdflkjslfjdslfjldjfljsdfljsdlfjsljfldjfldjals;djfasldjf;alskdjf;aslkdjf;asdjf;laskdjflsjdalfjd;alksjdfl;jsa;lfdja;slkdjf;alsjfd;lajsfl;dj" + Title = Set: "Javaone Keynotelkajldfjlskajdflkjslfjdslfjldjfljsdfljsdlfjsljfldjfldjals;djfasldjf;alskdjf;aslkdjf;asdjf;laskdjflsjdalfjd;alksjdfl;jsa;lfdja;slkdjf;alsjfd;lajsfl;dj" + Width = 1024 + Height = 768 + Size = Large + } + { + Uri = "http://javaone.com/keynote_small.jpglkajldfjlskajdflkjslfjdslfjldjfljsdfljsdlfjsljfldjfldjals;djfasldjf;alskdjf;aslkdjf;asdjf;laskdjflsjdalfjd;alksjdfl;jsa;lfdja;slkdjf;alsjfd;lajsfl;dj" + Title = Set: "Javaone Keynotelkajldfjlskajdflkjslfjdslfjldjfljsdfljsdlfjsljfldjfldjals;djfasldjf;alskdjf;aslkdjf;asdjf;laskdjflsjdalfjd;alksjdfl;jsa;lfdja;slkdjf;alsjfd;lajsfl;dj" + Width = 320 + Height = 240 + Size = Small + } + ] +} diff --git a/jvm-serializers-tpc/src/main/resources/media.4.cks b/jvm-serializers-tpc/src/main/resources/media.4.cks new file mode 100644 index 0000000..8b1ce8d --- /dev/null +++ b/jvm-serializers-tpc/src/main/resources/media.4.cks @@ -0,0 +1,33 @@ +// Short strings. +{ + Media = { + Uri = "g" + Title = Set: "J" + Width = 640 + Height = 480 + Format = "v" + Duration = 18000000 // half hour in milliseconds + Size = 58982400 // bitrate * duration in seconds / 8 bits per byte + Bitrate = Set: 262144 // 256k + Persons = ["B", "S"] + Player = Java + Copyright = None + } + + Images = [ + { + Uri = "h" + Title = Set: "J" + Width = 1024 + Height = 768 + Size = Large + } + { + Uri = "h" + Title = Set: "J" + Width = 320 + Height = 240 + Size = Small + } + ] +} diff --git a/jvm-serializers-tpc/src/test/java/jvm-serializers/tpc/AppTest.java b/jvm-serializers-tpc/src/test/java/jvm-serializers/tpc/AppTest.java new file mode 100644 index 0000000..8ea4a50 --- /dev/null +++ b/jvm-serializers-tpc/src/test/java/jvm-serializers/tpc/AppTest.java @@ -0,0 +1,38 @@ +package jvm-serializers.tpc; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +/** + * Unit test for simple App. + */ +public class AppTest + extends TestCase +{ + /** + * Create the test case + * + * @param testName name of the test case + */ + public AppTest( String testName ) + { + super( testName ); + } + + /** + * @return the suite of tests being tested + */ + public static Test suite() + { + return new TestSuite( AppTest.class ); + } + + /** + * Rigourous Test :-) + */ + public void testApp() + { + assertTrue( true ); + } +} diff --git a/jvmserjmh/src/test/java/jmvser/MyBenchmarkTest.java b/jvmserjmh/src/test/java/jmvser/MyBenchmarkTest.java new file mode 100644 index 0000000..848d921 --- /dev/null +++ b/jvmserjmh/src/test/java/jmvser/MyBenchmarkTest.java @@ -0,0 +1,11 @@ +package jmvser; + +/** + * Created by jim on 2/4/16. + */ +public class MyBenchmarkTest { + + + @junit.Test public void testThing(){} + +} \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..3123fe0 --- /dev/null +++ b/pom.xml @@ -0,0 +1,23 @@ + + + 4.0.0 + jvm-serializers + jvm-serializers-parent + pom + 1.0-SNAPSHOT + jvm-serializers-parentjvm-serializers Terraformed... by jim@psychosynthintelligence... on x86_64 x86_64 GNU/Linux... for protowar,scala_media_container,tpc... + http://psychosynthintelligenceHEAD + + + junit + junit + 3.8.1 + test + + + + jvm-serializers-protowar + jvm-serializers-scala_media_container + jvm-serializers-tpc + + \ No newline at end of file diff --git a/src/main/repository/aalto/aalto-gpl/0.9.5/aalto-gpl-0.9.5.jar b/src/main/repository/aalto/aalto-gpl/0.9.5/aalto-gpl-0.9.5.jar new file mode 100644 index 0000000..ce3be26 Binary files /dev/null and b/src/main/repository/aalto/aalto-gpl/0.9.5/aalto-gpl-0.9.5.jar differ diff --git a/src/main/repository/aalto/aalto-gpl/0.9.5/aalto-gpl-0.9.5.pom b/src/main/repository/aalto/aalto-gpl/0.9.5/aalto-gpl-0.9.5.pom new file mode 100644 index 0000000..e1a7f38 --- /dev/null +++ b/src/main/repository/aalto/aalto-gpl/0.9.5/aalto-gpl-0.9.5.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + aalto + aalto-gpl + 0.9.5 + POM was created from install:install-file + diff --git a/src/main/repository/aalto/aalto-gpl/maven-metadata-local.xml b/src/main/repository/aalto/aalto-gpl/maven-metadata-local.xml new file mode 100644 index 0000000..51b712f --- /dev/null +++ b/src/main/repository/aalto/aalto-gpl/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + aalto + aalto-gpl + + 0.9.5 + + 0.9.5 + + 20160204075924 + + diff --git a/src/main/repository/activemq/activemq-protobuf/1.1-SNAPSHOT/activemq-protobuf-1.1-SNAPSHOT.jar b/src/main/repository/activemq/activemq-protobuf/1.1-SNAPSHOT/activemq-protobuf-1.1-SNAPSHOT.jar new file mode 100644 index 0000000..49eded1 Binary files /dev/null and b/src/main/repository/activemq/activemq-protobuf/1.1-SNAPSHOT/activemq-protobuf-1.1-SNAPSHOT.jar differ diff --git a/src/main/repository/activemq/activemq-protobuf/1.1-SNAPSHOT/activemq-protobuf-1.1-SNAPSHOT.pom b/src/main/repository/activemq/activemq-protobuf/1.1-SNAPSHOT/activemq-protobuf-1.1-SNAPSHOT.pom new file mode 100644 index 0000000..2367ed9 --- /dev/null +++ b/src/main/repository/activemq/activemq-protobuf/1.1-SNAPSHOT/activemq-protobuf-1.1-SNAPSHOT.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + activemq + activemq-protobuf + 1.1-SNAPSHOT + POM was created from install:install-file + diff --git a/src/main/repository/activemq/activemq-protobuf/1.1-SNAPSHOT/maven-metadata-local.xml b/src/main/repository/activemq/activemq-protobuf/1.1-SNAPSHOT/maven-metadata-local.xml new file mode 100644 index 0000000..ee0ea8f --- /dev/null +++ b/src/main/repository/activemq/activemq-protobuf/1.1-SNAPSHOT/maven-metadata-local.xml @@ -0,0 +1,24 @@ + + + activemq + activemq-protobuf + 1.1-SNAPSHOT + + + true + + 20160204075922 + + + jar + 1.1-SNAPSHOT + 20160204075922 + + + pom + 1.1-SNAPSHOT + 20160204075922 + + + + diff --git a/src/main/repository/activemq/activemq-protobuf/maven-metadata-local.xml b/src/main/repository/activemq/activemq-protobuf/maven-metadata-local.xml new file mode 100644 index 0000000..4009791 --- /dev/null +++ b/src/main/repository/activemq/activemq-protobuf/maven-metadata-local.xml @@ -0,0 +1,11 @@ + + + activemq + activemq-protobuf + + + 1.1-SNAPSHOT + + 20160204075922 + + diff --git a/src/main/repository/activemq/activemq-util/6.0-SNAPSHOT/activemq-util-6.0-SNAPSHOT.jar b/src/main/repository/activemq/activemq-util/6.0-SNAPSHOT/activemq-util-6.0-SNAPSHOT.jar new file mode 100644 index 0000000..264fa85 Binary files /dev/null and b/src/main/repository/activemq/activemq-util/6.0-SNAPSHOT/activemq-util-6.0-SNAPSHOT.jar differ diff --git a/src/main/repository/activemq/activemq-util/6.0-SNAPSHOT/activemq-util-6.0-SNAPSHOT.pom b/src/main/repository/activemq/activemq-util/6.0-SNAPSHOT/activemq-util-6.0-SNAPSHOT.pom new file mode 100644 index 0000000..1590cc3 --- /dev/null +++ b/src/main/repository/activemq/activemq-util/6.0-SNAPSHOT/activemq-util-6.0-SNAPSHOT.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + activemq + activemq-util + 6.0-SNAPSHOT + POM was created from install:install-file + diff --git a/src/main/repository/activemq/activemq-util/6.0-SNAPSHOT/maven-metadata-local.xml b/src/main/repository/activemq/activemq-util/6.0-SNAPSHOT/maven-metadata-local.xml new file mode 100644 index 0000000..f998238 --- /dev/null +++ b/src/main/repository/activemq/activemq-util/6.0-SNAPSHOT/maven-metadata-local.xml @@ -0,0 +1,24 @@ + + + activemq + activemq-util + 6.0-SNAPSHOT + + + true + + 20160204075920 + + + jar + 6.0-SNAPSHOT + 20160204075920 + + + pom + 6.0-SNAPSHOT + 20160204075920 + + + + diff --git a/src/main/repository/activemq/activemq-util/maven-metadata-local.xml b/src/main/repository/activemq/activemq-util/maven-metadata-local.xml new file mode 100644 index 0000000..4023b8f --- /dev/null +++ b/src/main/repository/activemq/activemq-util/maven-metadata-local.xml @@ -0,0 +1,11 @@ + + + activemq + activemq-util + + + 6.0-SNAPSHOT + + 20160204075920 + + diff --git a/src/main/repository/asm/asm-commons/3.2/asm-commons-3.2.jar b/src/main/repository/asm/asm-commons/3.2/asm-commons-3.2.jar new file mode 100644 index 0000000..8dfed0a Binary files /dev/null and b/src/main/repository/asm/asm-commons/3.2/asm-commons-3.2.jar differ diff --git a/src/main/repository/asm/asm-commons/3.2/asm-commons-3.2.pom b/src/main/repository/asm/asm-commons/3.2/asm-commons-3.2.pom new file mode 100644 index 0000000..f09d95e --- /dev/null +++ b/src/main/repository/asm/asm-commons/3.2/asm-commons-3.2.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + asm + asm-commons + 3.2 + POM was created from install:install-file + diff --git a/src/main/repository/asm/asm-commons/maven-metadata-local.xml b/src/main/repository/asm/asm-commons/maven-metadata-local.xml new file mode 100644 index 0000000..87c02ea --- /dev/null +++ b/src/main/repository/asm/asm-commons/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + asm + asm-commons + + 3.2 + + 3.2 + + 20160204075924 + + diff --git a/src/main/repository/avro/avro-compiler/1.7.2/avro-compiler-1.7.2.jar b/src/main/repository/avro/avro-compiler/1.7.2/avro-compiler-1.7.2.jar new file mode 100644 index 0000000..b3467f7 Binary files /dev/null and b/src/main/repository/avro/avro-compiler/1.7.2/avro-compiler-1.7.2.jar differ diff --git a/src/main/repository/avro/avro-compiler/1.7.2/avro-compiler-1.7.2.pom b/src/main/repository/avro/avro-compiler/1.7.2/avro-compiler-1.7.2.pom new file mode 100644 index 0000000..6c20b98 --- /dev/null +++ b/src/main/repository/avro/avro-compiler/1.7.2/avro-compiler-1.7.2.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + avro + avro-compiler + 1.7.2 + POM was created from install:install-file + diff --git a/src/main/repository/avro/avro-compiler/maven-metadata-local.xml b/src/main/repository/avro/avro-compiler/maven-metadata-local.xml new file mode 100644 index 0000000..5c09891 --- /dev/null +++ b/src/main/repository/avro/avro-compiler/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + avro + avro-compiler + + 1.7.2 + + 1.7.2 + + 20160204075924 + + diff --git a/src/main/repository/avro/avro-tools/1.7.2/avro-tools-1.7.2.jar b/src/main/repository/avro/avro-tools/1.7.2/avro-tools-1.7.2.jar new file mode 100644 index 0000000..b253095 Binary files /dev/null and b/src/main/repository/avro/avro-tools/1.7.2/avro-tools-1.7.2.jar differ diff --git a/src/main/repository/avro/avro-tools/1.7.2/avro-tools-1.7.2.pom b/src/main/repository/avro/avro-tools/1.7.2/avro-tools-1.7.2.pom new file mode 100644 index 0000000..59a0b68 --- /dev/null +++ b/src/main/repository/avro/avro-tools/1.7.2/avro-tools-1.7.2.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + avro + avro-tools + 1.7.2 + POM was created from install:install-file + diff --git a/src/main/repository/avro/avro-tools/maven-metadata-local.xml b/src/main/repository/avro/avro-tools/maven-metadata-local.xml new file mode 100644 index 0000000..fe7afc2 --- /dev/null +++ b/src/main/repository/avro/avro-tools/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + avro + avro-tools + + 1.7.2 + + 1.7.2 + + 20160204075928 + + diff --git a/src/main/repository/commons/commons-beanutils/1.8.3/commons-beanutils-1.8.3.jar b/src/main/repository/commons/commons-beanutils/1.8.3/commons-beanutils-1.8.3.jar new file mode 100644 index 0000000..218510b Binary files /dev/null and b/src/main/repository/commons/commons-beanutils/1.8.3/commons-beanutils-1.8.3.jar differ diff --git a/src/main/repository/commons/commons-beanutils/1.8.3/commons-beanutils-1.8.3.pom b/src/main/repository/commons/commons-beanutils/1.8.3/commons-beanutils-1.8.3.pom new file mode 100644 index 0000000..069c030 --- /dev/null +++ b/src/main/repository/commons/commons-beanutils/1.8.3/commons-beanutils-1.8.3.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + commons + commons-beanutils + 1.8.3 + POM was created from install:install-file + diff --git a/src/main/repository/commons/commons-beanutils/maven-metadata-local.xml b/src/main/repository/commons/commons-beanutils/maven-metadata-local.xml new file mode 100644 index 0000000..2a37819 --- /dev/null +++ b/src/main/repository/commons/commons-beanutils/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + commons + commons-beanutils + + 1.8.3 + + 1.8.3 + + 20160204075937 + + diff --git a/src/main/repository/commons/commons-codec/1.3/commons-codec-1.3.jar b/src/main/repository/commons/commons-codec/1.3/commons-codec-1.3.jar new file mode 100644 index 0000000..957b675 Binary files /dev/null and b/src/main/repository/commons/commons-codec/1.3/commons-codec-1.3.jar differ diff --git a/src/main/repository/commons/commons-codec/1.3/commons-codec-1.3.pom b/src/main/repository/commons/commons-codec/1.3/commons-codec-1.3.pom new file mode 100644 index 0000000..4785283 --- /dev/null +++ b/src/main/repository/commons/commons-codec/1.3/commons-codec-1.3.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + commons + commons-codec + 1.3 + POM was created from install:install-file + diff --git a/src/main/repository/commons/commons-codec/maven-metadata-local.xml b/src/main/repository/commons/commons-codec/maven-metadata-local.xml new file mode 100644 index 0000000..fd48d38 --- /dev/null +++ b/src/main/repository/commons/commons-codec/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + commons + commons-codec + + 1.3 + + 1.3 + + 20160204075934 + + diff --git a/src/main/repository/commons/commons-collections/3.2.1/commons-collections-3.2.1.jar b/src/main/repository/commons/commons-collections/3.2.1/commons-collections-3.2.1.jar new file mode 100644 index 0000000..c35fa1f Binary files /dev/null and b/src/main/repository/commons/commons-collections/3.2.1/commons-collections-3.2.1.jar differ diff --git a/src/main/repository/commons/commons-collections/3.2.1/commons-collections-3.2.1.pom b/src/main/repository/commons/commons-collections/3.2.1/commons-collections-3.2.1.pom new file mode 100644 index 0000000..da653de --- /dev/null +++ b/src/main/repository/commons/commons-collections/3.2.1/commons-collections-3.2.1.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + commons + commons-collections + 3.2.1 + POM was created from install:install-file + diff --git a/src/main/repository/commons/commons-collections/maven-metadata-local.xml b/src/main/repository/commons/commons-collections/maven-metadata-local.xml new file mode 100644 index 0000000..10fe5e0 --- /dev/null +++ b/src/main/repository/commons/commons-collections/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + commons + commons-collections + + 3.2.1 + + 3.2.1 + + 20160204075938 + + diff --git a/src/main/repository/commons/commons-httpclient/3.1/commons-httpclient-3.1.jar b/src/main/repository/commons/commons-httpclient/3.1/commons-httpclient-3.1.jar new file mode 100644 index 0000000..7c59774 Binary files /dev/null and b/src/main/repository/commons/commons-httpclient/3.1/commons-httpclient-3.1.jar differ diff --git a/src/main/repository/commons/commons-httpclient/3.1/commons-httpclient-3.1.pom b/src/main/repository/commons/commons-httpclient/3.1/commons-httpclient-3.1.pom new file mode 100644 index 0000000..648ecbe --- /dev/null +++ b/src/main/repository/commons/commons-httpclient/3.1/commons-httpclient-3.1.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + commons + commons-httpclient + 3.1 + POM was created from install:install-file + diff --git a/src/main/repository/commons/commons-httpclient/maven-metadata-local.xml b/src/main/repository/commons/commons-httpclient/maven-metadata-local.xml new file mode 100644 index 0000000..5b657e3 --- /dev/null +++ b/src/main/repository/commons/commons-httpclient/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + commons + commons-httpclient + + 3.1 + + 3.1 + + 20160204075938 + + diff --git a/src/main/repository/commons/commons-lang/2.4/commons-lang-2.4.jar b/src/main/repository/commons/commons-lang/2.4/commons-lang-2.4.jar new file mode 100644 index 0000000..532939e Binary files /dev/null and b/src/main/repository/commons/commons-lang/2.4/commons-lang-2.4.jar differ diff --git a/src/main/repository/commons/commons-lang/2.4/commons-lang-2.4.pom b/src/main/repository/commons/commons-lang/2.4/commons-lang-2.4.pom new file mode 100644 index 0000000..47327f2 --- /dev/null +++ b/src/main/repository/commons/commons-lang/2.4/commons-lang-2.4.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + commons + commons-lang + 2.4 + POM was created from install:install-file + diff --git a/src/main/repository/commons/commons-lang/maven-metadata-local.xml b/src/main/repository/commons/commons-lang/maven-metadata-local.xml new file mode 100644 index 0000000..9746028 --- /dev/null +++ b/src/main/repository/commons/commons-lang/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + commons + commons-lang + + 2.4 + + 2.4 + + 20160204075940 + + diff --git a/src/main/repository/commons/commons-logging/1.1.1/commons-logging-1.1.1.jar b/src/main/repository/commons/commons-logging/1.1.1/commons-logging-1.1.1.jar new file mode 100644 index 0000000..8758a96 Binary files /dev/null and b/src/main/repository/commons/commons-logging/1.1.1/commons-logging-1.1.1.jar differ diff --git a/src/main/repository/commons/commons-logging/1.1.1/commons-logging-1.1.1.pom b/src/main/repository/commons/commons-logging/1.1.1/commons-logging-1.1.1.pom new file mode 100644 index 0000000..819990e --- /dev/null +++ b/src/main/repository/commons/commons-logging/1.1.1/commons-logging-1.1.1.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + commons + commons-logging + 1.1.1 + POM was created from install:install-file + diff --git a/src/main/repository/commons/commons-logging/maven-metadata-local.xml b/src/main/repository/commons/commons-logging/maven-metadata-local.xml new file mode 100644 index 0000000..1ae5df1 --- /dev/null +++ b/src/main/repository/commons/commons-logging/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + commons + commons-logging + + 1.1.1 + + 1.1.1 + + 20160204075937 + + diff --git a/src/main/repository/deprecated/FastInfoset/1.2.6/FastInfoset-1.2.6.jar b/src/main/repository/deprecated/FastInfoset/1.2.6/FastInfoset-1.2.6.jar new file mode 100644 index 0000000..a9ac6ed Binary files /dev/null and b/src/main/repository/deprecated/FastInfoset/1.2.6/FastInfoset-1.2.6.jar differ diff --git a/src/main/repository/deprecated/FastInfoset/1.2.6/FastInfoset-1.2.6.pom b/src/main/repository/deprecated/FastInfoset/1.2.6/FastInfoset-1.2.6.pom new file mode 100644 index 0000000..d1b3614 --- /dev/null +++ b/src/main/repository/deprecated/FastInfoset/1.2.6/FastInfoset-1.2.6.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + deprecated + FastInfoset + 1.2.6 + POM was created from install:install-file + diff --git a/src/main/repository/deprecated/FastInfoset/maven-metadata-local.xml b/src/main/repository/deprecated/FastInfoset/maven-metadata-local.xml new file mode 100644 index 0000000..fac4a71 --- /dev/null +++ b/src/main/repository/deprecated/FastInfoset/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + deprecated + FastInfoset + + 1.2.6 + + 1.2.6 + + 20160204075921 + + diff --git a/src/main/repository/deprecated/argo/2.10/argo-2.10.jar b/src/main/repository/deprecated/argo/2.10/argo-2.10.jar new file mode 100644 index 0000000..2258f05 Binary files /dev/null and b/src/main/repository/deprecated/argo/2.10/argo-2.10.jar differ diff --git a/src/main/repository/deprecated/argo/2.10/argo-2.10.pom b/src/main/repository/deprecated/argo/2.10/argo-2.10.pom new file mode 100644 index 0000000..0a95375 --- /dev/null +++ b/src/main/repository/deprecated/argo/2.10/argo-2.10.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + deprecated + argo + 2.10 + POM was created from install:install-file + diff --git a/src/main/repository/deprecated/argo/maven-metadata-local.xml b/src/main/repository/deprecated/argo/maven-metadata-local.xml new file mode 100644 index 0000000..8bc6661 --- /dev/null +++ b/src/main/repository/deprecated/argo/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + deprecated + argo + + 2.10 + + 2.10 + + 20160204075922 + + diff --git a/src/main/repository/deprecated/asm/4.0/asm-4.0.jar b/src/main/repository/deprecated/asm/4.0/asm-4.0.jar new file mode 100644 index 0000000..6d63075 Binary files /dev/null and b/src/main/repository/deprecated/asm/4.0/asm-4.0.jar differ diff --git a/src/main/repository/deprecated/asm/4.0/asm-4.0.pom b/src/main/repository/deprecated/asm/4.0/asm-4.0.pom new file mode 100644 index 0000000..a822104 --- /dev/null +++ b/src/main/repository/deprecated/asm/4.0/asm-4.0.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + deprecated + asm + 4.0 + POM was created from install:install-file + diff --git a/src/main/repository/deprecated/asm/maven-metadata-local.xml b/src/main/repository/deprecated/asm/maven-metadata-local.xml new file mode 100644 index 0000000..918c84e --- /dev/null +++ b/src/main/repository/deprecated/asm/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + deprecated + asm + + 4.0 + + 4.0 + + 20160204075924 + + diff --git a/src/main/repository/deprecated/avro/1.7.2/avro-1.7.2.jar b/src/main/repository/deprecated/avro/1.7.2/avro-1.7.2.jar new file mode 100644 index 0000000..f86aef9 Binary files /dev/null and b/src/main/repository/deprecated/avro/1.7.2/avro-1.7.2.jar differ diff --git a/src/main/repository/deprecated/avro/1.7.2/avro-1.7.2.pom b/src/main/repository/deprecated/avro/1.7.2/avro-1.7.2.pom new file mode 100644 index 0000000..3690a32 --- /dev/null +++ b/src/main/repository/deprecated/avro/1.7.2/avro-1.7.2.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + deprecated + avro + 1.7.2 + POM was created from install:install-file + diff --git a/src/main/repository/deprecated/avro/maven-metadata-local.xml b/src/main/repository/deprecated/avro/maven-metadata-local.xml new file mode 100644 index 0000000..cf5ae28 --- /dev/null +++ b/src/main/repository/deprecated/avro/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + deprecated + avro + + 1.7.2 + + 1.7.2 + + 20160204075922 + + diff --git a/src/main/repository/deprecated/bson4jackson/2.3.0/bson4jackson-2.3.0.jar b/src/main/repository/deprecated/bson4jackson/2.3.0/bson4jackson-2.3.0.jar new file mode 100644 index 0000000..e79addf Binary files /dev/null and b/src/main/repository/deprecated/bson4jackson/2.3.0/bson4jackson-2.3.0.jar differ diff --git a/src/main/repository/deprecated/bson4jackson/2.3.0/bson4jackson-2.3.0.pom b/src/main/repository/deprecated/bson4jackson/2.3.0/bson4jackson-2.3.0.pom new file mode 100644 index 0000000..8146ae1 --- /dev/null +++ b/src/main/repository/deprecated/bson4jackson/2.3.0/bson4jackson-2.3.0.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + deprecated + bson4jackson + 2.3.0 + POM was created from install:install-file + diff --git a/src/main/repository/deprecated/bson4jackson/maven-metadata-local.xml b/src/main/repository/deprecated/bson4jackson/maven-metadata-local.xml new file mode 100644 index 0000000..407ea70 --- /dev/null +++ b/src/main/repository/deprecated/bson4jackson/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + deprecated + bson4jackson + + 2.3.0 + + 2.3.0 + + 20160204075925 + + diff --git a/src/main/repository/deprecated/cakoose-util/1.0-SNAPSHOT/cakoose-util-1.0-SNAPSHOT.jar b/src/main/repository/deprecated/cakoose-util/1.0-SNAPSHOT/cakoose-util-1.0-SNAPSHOT.jar new file mode 100644 index 0000000..babfc6f Binary files /dev/null and b/src/main/repository/deprecated/cakoose-util/1.0-SNAPSHOT/cakoose-util-1.0-SNAPSHOT.jar differ diff --git a/src/main/repository/deprecated/cakoose-util/1.0-SNAPSHOT/cakoose-util-1.0-SNAPSHOT.pom b/src/main/repository/deprecated/cakoose-util/1.0-SNAPSHOT/cakoose-util-1.0-SNAPSHOT.pom new file mode 100644 index 0000000..901f0ca --- /dev/null +++ b/src/main/repository/deprecated/cakoose-util/1.0-SNAPSHOT/cakoose-util-1.0-SNAPSHOT.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + deprecated + cakoose-util + 1.0-SNAPSHOT + POM was created from install:install-file + diff --git a/src/main/repository/deprecated/cakoose-util/1.0-SNAPSHOT/maven-metadata-local.xml b/src/main/repository/deprecated/cakoose-util/1.0-SNAPSHOT/maven-metadata-local.xml new file mode 100644 index 0000000..62c74d5 --- /dev/null +++ b/src/main/repository/deprecated/cakoose-util/1.0-SNAPSHOT/maven-metadata-local.xml @@ -0,0 +1,24 @@ + + + deprecated + cakoose-util + 1.0-SNAPSHOT + + + true + + 20160204075925 + + + jar + 1.0-SNAPSHOT + 20160204075925 + + + pom + 1.0-SNAPSHOT + 20160204075925 + + + + diff --git a/src/main/repository/deprecated/cakoose-util/maven-metadata-local.xml b/src/main/repository/deprecated/cakoose-util/maven-metadata-local.xml new file mode 100644 index 0000000..d5b417d --- /dev/null +++ b/src/main/repository/deprecated/cakoose-util/maven-metadata-local.xml @@ -0,0 +1,11 @@ + + + deprecated + cakoose-util + + + 1.0-SNAPSHOT + + 20160204075925 + + diff --git a/src/main/repository/deprecated/cks-core/1.0-SNAPSHOT/cks-core-1.0-SNAPSHOT.jar b/src/main/repository/deprecated/cks-core/1.0-SNAPSHOT/cks-core-1.0-SNAPSHOT.jar new file mode 100644 index 0000000..cf630b7 Binary files /dev/null and b/src/main/repository/deprecated/cks-core/1.0-SNAPSHOT/cks-core-1.0-SNAPSHOT.jar differ diff --git a/src/main/repository/deprecated/cks-core/1.0-SNAPSHOT/cks-core-1.0-SNAPSHOT.pom b/src/main/repository/deprecated/cks-core/1.0-SNAPSHOT/cks-core-1.0-SNAPSHOT.pom new file mode 100644 index 0000000..270a2ba --- /dev/null +++ b/src/main/repository/deprecated/cks-core/1.0-SNAPSHOT/cks-core-1.0-SNAPSHOT.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + deprecated + cks-core + 1.0-SNAPSHOT + POM was created from install:install-file + diff --git a/src/main/repository/deprecated/cks-core/1.0-SNAPSHOT/maven-metadata-local.xml b/src/main/repository/deprecated/cks-core/1.0-SNAPSHOT/maven-metadata-local.xml new file mode 100644 index 0000000..9da746c --- /dev/null +++ b/src/main/repository/deprecated/cks-core/1.0-SNAPSHOT/maven-metadata-local.xml @@ -0,0 +1,24 @@ + + + deprecated + cks-core + 1.0-SNAPSHOT + + + true + + 20160204075934 + + + jar + 1.0-SNAPSHOT + 20160204075934 + + + pom + 1.0-SNAPSHOT + 20160204075934 + + + + diff --git a/src/main/repository/deprecated/cks-core/maven-metadata-local.xml b/src/main/repository/deprecated/cks-core/maven-metadata-local.xml new file mode 100644 index 0000000..585e2e4 --- /dev/null +++ b/src/main/repository/deprecated/cks-core/maven-metadata-local.xml @@ -0,0 +1,11 @@ + + + deprecated + cks-core + + + 1.0-SNAPSHOT + + 20160204075934 + + diff --git a/src/main/repository/deprecated/cks-text-reader/1.0-SNAPSHOT/cks-text-reader-1.0-SNAPSHOT.jar b/src/main/repository/deprecated/cks-text-reader/1.0-SNAPSHOT/cks-text-reader-1.0-SNAPSHOT.jar new file mode 100644 index 0000000..6f7664a Binary files /dev/null and b/src/main/repository/deprecated/cks-text-reader/1.0-SNAPSHOT/cks-text-reader-1.0-SNAPSHOT.jar differ diff --git a/src/main/repository/deprecated/cks-text-reader/1.0-SNAPSHOT/cks-text-reader-1.0-SNAPSHOT.pom b/src/main/repository/deprecated/cks-text-reader/1.0-SNAPSHOT/cks-text-reader-1.0-SNAPSHOT.pom new file mode 100644 index 0000000..7803276 --- /dev/null +++ b/src/main/repository/deprecated/cks-text-reader/1.0-SNAPSHOT/cks-text-reader-1.0-SNAPSHOT.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + deprecated + cks-text-reader + 1.0-SNAPSHOT + POM was created from install:install-file + diff --git a/src/main/repository/deprecated/cks-text-reader/1.0-SNAPSHOT/maven-metadata-local.xml b/src/main/repository/deprecated/cks-text-reader/1.0-SNAPSHOT/maven-metadata-local.xml new file mode 100644 index 0000000..3bfdf36 --- /dev/null +++ b/src/main/repository/deprecated/cks-text-reader/1.0-SNAPSHOT/maven-metadata-local.xml @@ -0,0 +1,24 @@ + + + deprecated + cks-text-reader + 1.0-SNAPSHOT + + + true + + 20160204075932 + + + jar + 1.0-SNAPSHOT + 20160204075932 + + + pom + 1.0-SNAPSHOT + 20160204075932 + + + + diff --git a/src/main/repository/deprecated/cks-text-reader/maven-metadata-local.xml b/src/main/repository/deprecated/cks-text-reader/maven-metadata-local.xml new file mode 100644 index 0000000..dc78fd2 --- /dev/null +++ b/src/main/repository/deprecated/cks-text-reader/maven-metadata-local.xml @@ -0,0 +1,11 @@ + + + deprecated + cks-text-reader + + + 1.0-SNAPSHOT + + 20160204075932 + + diff --git a/src/main/repository/deprecated/cks-text-writer/1.0-SNAPSHOT/cks-text-writer-1.0-SNAPSHOT.jar b/src/main/repository/deprecated/cks-text-writer/1.0-SNAPSHOT/cks-text-writer-1.0-SNAPSHOT.jar new file mode 100644 index 0000000..b0fda79 Binary files /dev/null and b/src/main/repository/deprecated/cks-text-writer/1.0-SNAPSHOT/cks-text-writer-1.0-SNAPSHOT.jar differ diff --git a/src/main/repository/deprecated/cks-text-writer/1.0-SNAPSHOT/cks-text-writer-1.0-SNAPSHOT.pom b/src/main/repository/deprecated/cks-text-writer/1.0-SNAPSHOT/cks-text-writer-1.0-SNAPSHOT.pom new file mode 100644 index 0000000..87256e4 --- /dev/null +++ b/src/main/repository/deprecated/cks-text-writer/1.0-SNAPSHOT/cks-text-writer-1.0-SNAPSHOT.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + deprecated + cks-text-writer + 1.0-SNAPSHOT + POM was created from install:install-file + diff --git a/src/main/repository/deprecated/cks-text-writer/1.0-SNAPSHOT/maven-metadata-local.xml b/src/main/repository/deprecated/cks-text-writer/1.0-SNAPSHOT/maven-metadata-local.xml new file mode 100644 index 0000000..cbe9cbc --- /dev/null +++ b/src/main/repository/deprecated/cks-text-writer/1.0-SNAPSHOT/maven-metadata-local.xml @@ -0,0 +1,24 @@ + + + deprecated + cks-text-writer + 1.0-SNAPSHOT + + + true + + 20160204075932 + + + jar + 1.0-SNAPSHOT + 20160204075932 + + + pom + 1.0-SNAPSHOT + 20160204075932 + + + + diff --git a/src/main/repository/deprecated/cks-text-writer/maven-metadata-local.xml b/src/main/repository/deprecated/cks-text-writer/maven-metadata-local.xml new file mode 100644 index 0000000..14b4423 --- /dev/null +++ b/src/main/repository/deprecated/cks-text-writer/maven-metadata-local.xml @@ -0,0 +1,11 @@ + + + deprecated + cks-text-writer + + + 1.0-SNAPSHOT + + 20160204075932 + + diff --git a/src/main/repository/deprecated/cks-tool/1.0-SNAPSHOT/cks-tool-1.0-SNAPSHOT.jar b/src/main/repository/deprecated/cks-tool/1.0-SNAPSHOT/cks-tool-1.0-SNAPSHOT.jar new file mode 100644 index 0000000..566dbeb Binary files /dev/null and b/src/main/repository/deprecated/cks-tool/1.0-SNAPSHOT/cks-tool-1.0-SNAPSHOT.jar differ diff --git a/src/main/repository/deprecated/cks-tool/1.0-SNAPSHOT/cks-tool-1.0-SNAPSHOT.pom b/src/main/repository/deprecated/cks-tool/1.0-SNAPSHOT/cks-tool-1.0-SNAPSHOT.pom new file mode 100644 index 0000000..ff1cd50 --- /dev/null +++ b/src/main/repository/deprecated/cks-tool/1.0-SNAPSHOT/cks-tool-1.0-SNAPSHOT.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + deprecated + cks-tool + 1.0-SNAPSHOT + POM was created from install:install-file + diff --git a/src/main/repository/deprecated/cks-tool/1.0-SNAPSHOT/maven-metadata-local.xml b/src/main/repository/deprecated/cks-tool/1.0-SNAPSHOT/maven-metadata-local.xml new file mode 100644 index 0000000..425faa1 --- /dev/null +++ b/src/main/repository/deprecated/cks-tool/1.0-SNAPSHOT/maven-metadata-local.xml @@ -0,0 +1,24 @@ + + + deprecated + cks-tool + 1.0-SNAPSHOT + + + true + + 20160204075931 + + + jar + 1.0-SNAPSHOT + 20160204075931 + + + pom + 1.0-SNAPSHOT + 20160204075931 + + + + diff --git a/src/main/repository/deprecated/cks-tool/maven-metadata-local.xml b/src/main/repository/deprecated/cks-tool/maven-metadata-local.xml new file mode 100644 index 0000000..00a7def --- /dev/null +++ b/src/main/repository/deprecated/cks-tool/maven-metadata-local.xml @@ -0,0 +1,11 @@ + + + deprecated + cks-tool + + + 1.0-SNAPSHOT + + 20160204075931 + + diff --git a/src/main/repository/deprecated/dsl-clc/1.0-SNAPSHOT/dsl-clc-1.0-SNAPSHOT.jar b/src/main/repository/deprecated/dsl-clc/1.0-SNAPSHOT/dsl-clc-1.0-SNAPSHOT.jar new file mode 100644 index 0000000..5a26075 Binary files /dev/null and b/src/main/repository/deprecated/dsl-clc/1.0-SNAPSHOT/dsl-clc-1.0-SNAPSHOT.jar differ diff --git a/src/main/repository/deprecated/dsl-clc/1.0-SNAPSHOT/dsl-clc-1.0-SNAPSHOT.pom b/src/main/repository/deprecated/dsl-clc/1.0-SNAPSHOT/dsl-clc-1.0-SNAPSHOT.pom new file mode 100644 index 0000000..38b8931 --- /dev/null +++ b/src/main/repository/deprecated/dsl-clc/1.0-SNAPSHOT/dsl-clc-1.0-SNAPSHOT.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + deprecated + dsl-clc + 1.0-SNAPSHOT + POM was created from install:install-file + diff --git a/src/main/repository/deprecated/dsl-clc/1.0-SNAPSHOT/maven-metadata-local.xml b/src/main/repository/deprecated/dsl-clc/1.0-SNAPSHOT/maven-metadata-local.xml new file mode 100644 index 0000000..66c7bfc --- /dev/null +++ b/src/main/repository/deprecated/dsl-clc/1.0-SNAPSHOT/maven-metadata-local.xml @@ -0,0 +1,24 @@ + + + deprecated + dsl-clc + 1.0-SNAPSHOT + + + true + + 20160204075939 + + + jar + 1.0-SNAPSHOT + 20160204075939 + + + pom + 1.0-SNAPSHOT + 20160204075939 + + + + diff --git a/src/main/repository/deprecated/dsl-clc/maven-metadata-local.xml b/src/main/repository/deprecated/dsl-clc/maven-metadata-local.xml new file mode 100644 index 0000000..a234134 --- /dev/null +++ b/src/main/repository/deprecated/dsl-clc/maven-metadata-local.xml @@ -0,0 +1,11 @@ + + + deprecated + dsl-clc + + + 1.0-SNAPSHOT + + 20160204075939 + + diff --git a/src/main/repository/deprecated/ezmorph/1.0.6/ezmorph-1.0.6.jar b/src/main/repository/deprecated/ezmorph/1.0.6/ezmorph-1.0.6.jar new file mode 100644 index 0000000..30fad12 Binary files /dev/null and b/src/main/repository/deprecated/ezmorph/1.0.6/ezmorph-1.0.6.jar differ diff --git a/src/main/repository/deprecated/ezmorph/1.0.6/ezmorph-1.0.6.pom b/src/main/repository/deprecated/ezmorph/1.0.6/ezmorph-1.0.6.pom new file mode 100644 index 0000000..afde94c --- /dev/null +++ b/src/main/repository/deprecated/ezmorph/1.0.6/ezmorph-1.0.6.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + deprecated + ezmorph + 1.0.6 + POM was created from install:install-file + diff --git a/src/main/repository/deprecated/ezmorph/maven-metadata-local.xml b/src/main/repository/deprecated/ezmorph/maven-metadata-local.xml new file mode 100644 index 0000000..b1b0081 --- /dev/null +++ b/src/main/repository/deprecated/ezmorph/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + deprecated + ezmorph + + 1.0.6 + + 1.0.6 + + 20160204075943 + + diff --git a/src/main/repository/deprecated/flexjson/2.1/flexjson-2.1.jar b/src/main/repository/deprecated/flexjson/2.1/flexjson-2.1.jar new file mode 100644 index 0000000..aeedb7a Binary files /dev/null and b/src/main/repository/deprecated/flexjson/2.1/flexjson-2.1.jar differ diff --git a/src/main/repository/deprecated/flexjson/2.1/flexjson-2.1.pom b/src/main/repository/deprecated/flexjson/2.1/flexjson-2.1.pom new file mode 100644 index 0000000..8ceef84 --- /dev/null +++ b/src/main/repository/deprecated/flexjson/2.1/flexjson-2.1.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + deprecated + flexjson + 2.1 + POM was created from install:install-file + diff --git a/src/main/repository/deprecated/flexjson/maven-metadata-local.xml b/src/main/repository/deprecated/flexjson/maven-metadata-local.xml new file mode 100644 index 0000000..755d2ab --- /dev/null +++ b/src/main/repository/deprecated/flexjson/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + deprecated + flexjson + + 2.1 + + 2.1 + + 20160204075946 + + diff --git a/src/main/repository/deprecated/fst/1.42/fst-1.42.jar b/src/main/repository/deprecated/fst/1.42/fst-1.42.jar new file mode 100644 index 0000000..141e884 Binary files /dev/null and b/src/main/repository/deprecated/fst/1.42/fst-1.42.jar differ diff --git a/src/main/repository/deprecated/fst/1.42/fst-1.42.pom b/src/main/repository/deprecated/fst/1.42/fst-1.42.pom new file mode 100644 index 0000000..faffccd --- /dev/null +++ b/src/main/repository/deprecated/fst/1.42/fst-1.42.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + deprecated + fst + 1.42 + POM was created from install:install-file + diff --git a/src/main/repository/deprecated/fst/maven-metadata-local.xml b/src/main/repository/deprecated/fst/maven-metadata-local.xml new file mode 100644 index 0000000..5cb724d --- /dev/null +++ b/src/main/repository/deprecated/fst/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + deprecated + fst + + 1.42 + + 1.42 + + 20160204075946 + + diff --git a/src/main/repository/deprecated/gson/2.2.2/gson-2.2.2.jar b/src/main/repository/deprecated/gson/2.2.2/gson-2.2.2.jar new file mode 100644 index 0000000..f2108e0 Binary files /dev/null and b/src/main/repository/deprecated/gson/2.2.2/gson-2.2.2.jar differ diff --git a/src/main/repository/deprecated/gson/2.2.2/gson-2.2.2.pom b/src/main/repository/deprecated/gson/2.2.2/gson-2.2.2.pom new file mode 100644 index 0000000..51f75ed --- /dev/null +++ b/src/main/repository/deprecated/gson/2.2.2/gson-2.2.2.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + deprecated + gson + 2.2.2 + POM was created from install:install-file + diff --git a/src/main/repository/deprecated/gson/maven-metadata-local.xml b/src/main/repository/deprecated/gson/maven-metadata-local.xml new file mode 100644 index 0000000..2f2690b --- /dev/null +++ b/src/main/repository/deprecated/gson/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + deprecated + gson + + 2.2.2 + + 2.2.2 + + 20160204075943 + + diff --git a/src/main/repository/deprecated/hessian/4.0.7/hessian-4.0.7.jar b/src/main/repository/deprecated/hessian/4.0.7/hessian-4.0.7.jar new file mode 100644 index 0000000..78d149e Binary files /dev/null and b/src/main/repository/deprecated/hessian/4.0.7/hessian-4.0.7.jar differ diff --git a/src/main/repository/deprecated/hessian/4.0.7/hessian-4.0.7.pom b/src/main/repository/deprecated/hessian/4.0.7/hessian-4.0.7.pom new file mode 100644 index 0000000..eaf3924 --- /dev/null +++ b/src/main/repository/deprecated/hessian/4.0.7/hessian-4.0.7.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + deprecated + hessian + 4.0.7 + POM was created from install:install-file + diff --git a/src/main/repository/deprecated/hessian/maven-metadata-local.xml b/src/main/repository/deprecated/hessian/maven-metadata-local.xml new file mode 100644 index 0000000..c8fc513 --- /dev/null +++ b/src/main/repository/deprecated/hessian/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + deprecated + hessian + + 4.0.7 + + 4.0.7 + + 20160204075951 + + diff --git a/src/main/repository/deprecated/javassist/3.15.0-GA/javassist-3.15.0-GA.jar b/src/main/repository/deprecated/javassist/3.15.0-GA/javassist-3.15.0-GA.jar new file mode 100644 index 0000000..5af8eae Binary files /dev/null and b/src/main/repository/deprecated/javassist/3.15.0-GA/javassist-3.15.0-GA.jar differ diff --git a/src/main/repository/deprecated/javassist/3.15.0-GA/javassist-3.15.0-GA.pom b/src/main/repository/deprecated/javassist/3.15.0-GA/javassist-3.15.0-GA.pom new file mode 100644 index 0000000..7cc8c7d --- /dev/null +++ b/src/main/repository/deprecated/javassist/3.15.0-GA/javassist-3.15.0-GA.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + deprecated + javassist + 3.15.0-GA + POM was created from install:install-file + diff --git a/src/main/repository/deprecated/javassist/maven-metadata-local.xml b/src/main/repository/deprecated/javassist/maven-metadata-local.xml new file mode 100644 index 0000000..ba983f0 --- /dev/null +++ b/src/main/repository/deprecated/javassist/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + deprecated + javassist + + 3.15.0-GA + + 3.15.0-GA + + 20160204075955 + + diff --git a/src/main/repository/deprecated/javax.json/1.0-b06/javax.json-1.0-b06.jar b/src/main/repository/deprecated/javax.json/1.0-b06/javax.json-1.0-b06.jar new file mode 100644 index 0000000..9c1376b Binary files /dev/null and b/src/main/repository/deprecated/javax.json/1.0-b06/javax.json-1.0-b06.jar differ diff --git a/src/main/repository/deprecated/javax.json/1.0-b06/javax.json-1.0-b06.pom b/src/main/repository/deprecated/javax.json/1.0-b06/javax.json-1.0-b06.pom new file mode 100644 index 0000000..18290d3 --- /dev/null +++ b/src/main/repository/deprecated/javax.json/1.0-b06/javax.json-1.0-b06.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + deprecated + javax.json + 1.0-b06 + POM was created from install:install-file + diff --git a/src/main/repository/deprecated/javax.json/maven-metadata-local.xml b/src/main/repository/deprecated/javax.json/maven-metadata-local.xml new file mode 100644 index 0000000..d00af52 --- /dev/null +++ b/src/main/repository/deprecated/javax.json/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + deprecated + javax.json + + 1.0-b06 + + 1.0-b06 + + 20160204075956 + + diff --git a/src/main/repository/deprecated/javolution/5.5.1/javolution-5.5.1.jar b/src/main/repository/deprecated/javolution/5.5.1/javolution-5.5.1.jar new file mode 100644 index 0000000..7ac80ea Binary files /dev/null and b/src/main/repository/deprecated/javolution/5.5.1/javolution-5.5.1.jar differ diff --git a/src/main/repository/deprecated/javolution/5.5.1/javolution-5.5.1.pom b/src/main/repository/deprecated/javolution/5.5.1/javolution-5.5.1.pom new file mode 100644 index 0000000..7c89344 --- /dev/null +++ b/src/main/repository/deprecated/javolution/5.5.1/javolution-5.5.1.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + deprecated + javolution + 5.5.1 + POM was created from install:install-file + diff --git a/src/main/repository/deprecated/javolution/maven-metadata-local.xml b/src/main/repository/deprecated/javolution/maven-metadata-local.xml new file mode 100644 index 0000000..ffdeba8 --- /dev/null +++ b/src/main/repository/deprecated/javolution/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + deprecated + javolution + + 5.5.1 + + 5.5.1 + + 20160204075957 + + diff --git a/src/main/repository/deprecated/json/0.19-tpc/json-0.19-tpc.jar b/src/main/repository/deprecated/json/0.19-tpc/json-0.19-tpc.jar new file mode 100644 index 0000000..ac2f28b Binary files /dev/null and b/src/main/repository/deprecated/json/0.19-tpc/json-0.19-tpc.jar differ diff --git a/src/main/repository/deprecated/json/0.19-tpc/json-0.19-tpc.pom b/src/main/repository/deprecated/json/0.19-tpc/json-0.19-tpc.pom new file mode 100644 index 0000000..3528ae7 --- /dev/null +++ b/src/main/repository/deprecated/json/0.19-tpc/json-0.19-tpc.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + deprecated + json + 0.19-tpc + POM was created from install:install-file + diff --git a/src/main/repository/deprecated/json/maven-metadata-local.xml b/src/main/repository/deprecated/json/maven-metadata-local.xml new file mode 100644 index 0000000..9280503 --- /dev/null +++ b/src/main/repository/deprecated/json/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + deprecated + json + + 0.19-tpc + + 0.19-tpc + + 20160204075958 + + diff --git a/src/main/repository/deprecated/json_simple/1.1/json_simple-1.1.jar b/src/main/repository/deprecated/json_simple/1.1/json_simple-1.1.jar new file mode 100644 index 0000000..f395f41 Binary files /dev/null and b/src/main/repository/deprecated/json_simple/1.1/json_simple-1.1.jar differ diff --git a/src/main/repository/deprecated/json_simple/1.1/json_simple-1.1.pom b/src/main/repository/deprecated/json_simple/1.1/json_simple-1.1.pom new file mode 100644 index 0000000..d8beaad --- /dev/null +++ b/src/main/repository/deprecated/json_simple/1.1/json_simple-1.1.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + deprecated + json_simple + 1.1 + POM was created from install:install-file + diff --git a/src/main/repository/deprecated/json_simple/maven-metadata-local.xml b/src/main/repository/deprecated/json_simple/maven-metadata-local.xml new file mode 100644 index 0000000..70ba69c --- /dev/null +++ b/src/main/repository/deprecated/json_simple/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + deprecated + json_simple + + 1.1 + + 1.1 + + 20160204080001 + + diff --git a/src/main/repository/deprecated/jsonij/0.2.7/jsonij-0.2.7.jar b/src/main/repository/deprecated/jsonij/0.2.7/jsonij-0.2.7.jar new file mode 100644 index 0000000..6056c12 Binary files /dev/null and b/src/main/repository/deprecated/jsonij/0.2.7/jsonij-0.2.7.jar differ diff --git a/src/main/repository/deprecated/jsonij/0.2.7/jsonij-0.2.7.pom b/src/main/repository/deprecated/jsonij/0.2.7/jsonij-0.2.7.pom new file mode 100644 index 0000000..ecdd961 --- /dev/null +++ b/src/main/repository/deprecated/jsonij/0.2.7/jsonij-0.2.7.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + deprecated + jsonij + 0.2.7 + POM was created from install:install-file + diff --git a/src/main/repository/deprecated/jsonij/maven-metadata-local.xml b/src/main/repository/deprecated/jsonij/maven-metadata-local.xml new file mode 100644 index 0000000..538bbfa --- /dev/null +++ b/src/main/repository/deprecated/jsonij/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + deprecated + jsonij + + 0.2.7 + + 0.2.7 + + 20160204080004 + + diff --git a/src/main/repository/deprecated/jsonpath/2011.06.23/jsonpath-2011.06.23.jar b/src/main/repository/deprecated/jsonpath/2011.06.23/jsonpath-2011.06.23.jar new file mode 100644 index 0000000..9863431 Binary files /dev/null and b/src/main/repository/deprecated/jsonpath/2011.06.23/jsonpath-2011.06.23.jar differ diff --git a/src/main/repository/deprecated/jsonpath/2011.06.23/jsonpath-2011.06.23.pom b/src/main/repository/deprecated/jsonpath/2011.06.23/jsonpath-2011.06.23.pom new file mode 100644 index 0000000..dc4d749 --- /dev/null +++ b/src/main/repository/deprecated/jsonpath/2011.06.23/jsonpath-2011.06.23.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + deprecated + jsonpath + 2011.06.23 + POM was created from install:install-file + diff --git a/src/main/repository/deprecated/jsonpath/maven-metadata-local.xml b/src/main/repository/deprecated/jsonpath/maven-metadata-local.xml new file mode 100644 index 0000000..97ef7ae --- /dev/null +++ b/src/main/repository/deprecated/jsonpath/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + deprecated + jsonpath + + 2011.06.23 + + 2011.06.23 + + 20160204080002 + + diff --git a/src/main/repository/deprecated/kryo/2.23.0/kryo-2.23.0.jar b/src/main/repository/deprecated/kryo/2.23.0/kryo-2.23.0.jar new file mode 100644 index 0000000..ac8e3b0 Binary files /dev/null and b/src/main/repository/deprecated/kryo/2.23.0/kryo-2.23.0.jar differ diff --git a/src/main/repository/deprecated/kryo/2.23.0/kryo-2.23.0.pom b/src/main/repository/deprecated/kryo/2.23.0/kryo-2.23.0.pom new file mode 100644 index 0000000..a96f7c4 --- /dev/null +++ b/src/main/repository/deprecated/kryo/2.23.0/kryo-2.23.0.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + deprecated + kryo + 2.23.0 + POM was created from install:install-file + diff --git a/src/main/repository/deprecated/kryo/maven-metadata-local.xml b/src/main/repository/deprecated/kryo/maven-metadata-local.xml new file mode 100644 index 0000000..6eb8fe6 --- /dev/null +++ b/src/main/repository/deprecated/kryo/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + deprecated + kryo + + 2.23.0 + + 2.23.0 + + 20160204080003 + + diff --git a/src/main/repository/deprecated/libthrift/1.0-SNAPSHOT/libthrift-1.0-SNAPSHOT.jar b/src/main/repository/deprecated/libthrift/1.0-SNAPSHOT/libthrift-1.0-SNAPSHOT.jar new file mode 100644 index 0000000..7792526 Binary files /dev/null and b/src/main/repository/deprecated/libthrift/1.0-SNAPSHOT/libthrift-1.0-SNAPSHOT.jar differ diff --git a/src/main/repository/deprecated/libthrift/1.0-SNAPSHOT/libthrift-1.0-SNAPSHOT.pom b/src/main/repository/deprecated/libthrift/1.0-SNAPSHOT/libthrift-1.0-SNAPSHOT.pom new file mode 100644 index 0000000..5ec739d --- /dev/null +++ b/src/main/repository/deprecated/libthrift/1.0-SNAPSHOT/libthrift-1.0-SNAPSHOT.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + deprecated + libthrift + 1.0-SNAPSHOT + POM was created from install:install-file + diff --git a/src/main/repository/deprecated/libthrift/1.0-SNAPSHOT/maven-metadata-local.xml b/src/main/repository/deprecated/libthrift/1.0-SNAPSHOT/maven-metadata-local.xml new file mode 100644 index 0000000..524609a --- /dev/null +++ b/src/main/repository/deprecated/libthrift/1.0-SNAPSHOT/maven-metadata-local.xml @@ -0,0 +1,24 @@ + + + deprecated + libthrift + 1.0-SNAPSHOT + + + true + + 20160204080003 + + + jar + 1.0-SNAPSHOT + 20160204080003 + + + pom + 1.0-SNAPSHOT + 20160204080003 + + + + diff --git a/src/main/repository/deprecated/libthrift/maven-metadata-local.xml b/src/main/repository/deprecated/libthrift/maven-metadata-local.xml new file mode 100644 index 0000000..5aa14b5 --- /dev/null +++ b/src/main/repository/deprecated/libthrift/maven-metadata-local.xml @@ -0,0 +1,11 @@ + + + deprecated + libthrift + + + 1.0-SNAPSHOT + + 20160204080003 + + diff --git a/src/main/repository/deprecated/log4j/1.2.8/log4j-1.2.8.jar b/src/main/repository/deprecated/log4j/1.2.8/log4j-1.2.8.jar new file mode 100644 index 0000000..493a3cc Binary files /dev/null and b/src/main/repository/deprecated/log4j/1.2.8/log4j-1.2.8.jar differ diff --git a/src/main/repository/deprecated/log4j/1.2.8/log4j-1.2.8.pom b/src/main/repository/deprecated/log4j/1.2.8/log4j-1.2.8.pom new file mode 100644 index 0000000..a76460d --- /dev/null +++ b/src/main/repository/deprecated/log4j/1.2.8/log4j-1.2.8.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + deprecated + log4j + 1.2.8 + POM was created from install:install-file + diff --git a/src/main/repository/deprecated/log4j/maven-metadata-local.xml b/src/main/repository/deprecated/log4j/maven-metadata-local.xml new file mode 100644 index 0000000..94b9cf6 --- /dev/null +++ b/src/main/repository/deprecated/log4j/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + deprecated + log4j + + 1.2.8 + + 1.2.8 + + 20160204080005 + + diff --git a/src/main/repository/deprecated/mongo/2.4/mongo-2.4.jar b/src/main/repository/deprecated/mongo/2.4/mongo-2.4.jar new file mode 100644 index 0000000..d1e4322 Binary files /dev/null and b/src/main/repository/deprecated/mongo/2.4/mongo-2.4.jar differ diff --git a/src/main/repository/deprecated/mongo/2.4/mongo-2.4.pom b/src/main/repository/deprecated/mongo/2.4/mongo-2.4.pom new file mode 100644 index 0000000..93ac73d --- /dev/null +++ b/src/main/repository/deprecated/mongo/2.4/mongo-2.4.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + deprecated + mongo + 2.4 + POM was created from install:install-file + diff --git a/src/main/repository/deprecated/mongo/maven-metadata-local.xml b/src/main/repository/deprecated/mongo/maven-metadata-local.xml new file mode 100644 index 0000000..7cc1704 --- /dev/null +++ b/src/main/repository/deprecated/mongo/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + deprecated + mongo + + 2.4 + + 2.4 + + 20160204080004 + + diff --git a/src/main/repository/deprecated/msgpack/0.6.9/msgpack-0.6.9.jar b/src/main/repository/deprecated/msgpack/0.6.9/msgpack-0.6.9.jar new file mode 100644 index 0000000..e912932 Binary files /dev/null and b/src/main/repository/deprecated/msgpack/0.6.9/msgpack-0.6.9.jar differ diff --git a/src/main/repository/deprecated/msgpack/0.6.9/msgpack-0.6.9.pom b/src/main/repository/deprecated/msgpack/0.6.9/msgpack-0.6.9.pom new file mode 100644 index 0000000..40f2c3c --- /dev/null +++ b/src/main/repository/deprecated/msgpack/0.6.9/msgpack-0.6.9.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + deprecated + msgpack + 0.6.9 + POM was created from install:install-file + diff --git a/src/main/repository/deprecated/msgpack/maven-metadata-local.xml b/src/main/repository/deprecated/msgpack/maven-metadata-local.xml new file mode 100644 index 0000000..bf52d25 --- /dev/null +++ b/src/main/repository/deprecated/msgpack/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + deprecated + msgpack + + 0.6.9 + + 0.6.9 + + 20160204080006 + + diff --git a/src/main/repository/deprecated/objenesis/1.2/objenesis-1.2.jar b/src/main/repository/deprecated/objenesis/1.2/objenesis-1.2.jar new file mode 100644 index 0000000..45cb641 Binary files /dev/null and b/src/main/repository/deprecated/objenesis/1.2/objenesis-1.2.jar differ diff --git a/src/main/repository/deprecated/objenesis/1.2/objenesis-1.2.pom b/src/main/repository/deprecated/objenesis/1.2/objenesis-1.2.pom new file mode 100644 index 0000000..379be93 --- /dev/null +++ b/src/main/repository/deprecated/objenesis/1.2/objenesis-1.2.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + deprecated + objenesis + 1.2 + POM was created from install:install-file + diff --git a/src/main/repository/deprecated/objenesis/maven-metadata-local.xml b/src/main/repository/deprecated/objenesis/maven-metadata-local.xml new file mode 100644 index 0000000..123b0a5 --- /dev/null +++ b/src/main/repository/deprecated/objenesis/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + deprecated + objenesis + + 1.2 + + 1.2 + + 20160204080006 + + diff --git a/src/main/repository/deprecated/obser/0.9.0-SNAPSHOT/maven-metadata-local.xml b/src/main/repository/deprecated/obser/0.9.0-SNAPSHOT/maven-metadata-local.xml new file mode 100644 index 0000000..197f68c --- /dev/null +++ b/src/main/repository/deprecated/obser/0.9.0-SNAPSHOT/maven-metadata-local.xml @@ -0,0 +1,24 @@ + + + deprecated + obser + 0.9.0-SNAPSHOT + + + true + + 20160204080009 + + + jar + 0.9.0-SNAPSHOT + 20160204080009 + + + pom + 0.9.0-SNAPSHOT + 20160204080009 + + + + diff --git a/src/main/repository/deprecated/obser/0.9.0-SNAPSHOT/obser-0.9.0-SNAPSHOT.jar b/src/main/repository/deprecated/obser/0.9.0-SNAPSHOT/obser-0.9.0-SNAPSHOT.jar new file mode 100644 index 0000000..22e2519 Binary files /dev/null and b/src/main/repository/deprecated/obser/0.9.0-SNAPSHOT/obser-0.9.0-SNAPSHOT.jar differ diff --git a/src/main/repository/deprecated/obser/0.9.0-SNAPSHOT/obser-0.9.0-SNAPSHOT.pom b/src/main/repository/deprecated/obser/0.9.0-SNAPSHOT/obser-0.9.0-SNAPSHOT.pom new file mode 100644 index 0000000..13a39fc --- /dev/null +++ b/src/main/repository/deprecated/obser/0.9.0-SNAPSHOT/obser-0.9.0-SNAPSHOT.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + deprecated + obser + 0.9.0-SNAPSHOT + POM was created from install:install-file + diff --git a/src/main/repository/deprecated/obser/maven-metadata-local.xml b/src/main/repository/deprecated/obser/maven-metadata-local.xml new file mode 100644 index 0000000..ce544de --- /dev/null +++ b/src/main/repository/deprecated/obser/maven-metadata-local.xml @@ -0,0 +1,11 @@ + + + deprecated + obser + + + 0.9.0-SNAPSHOT + + 20160204080009 + + diff --git a/src/main/repository/deprecated/paranamer/1.5/paranamer-1.5.jar b/src/main/repository/deprecated/paranamer/1.5/paranamer-1.5.jar new file mode 100644 index 0000000..d530fec Binary files /dev/null and b/src/main/repository/deprecated/paranamer/1.5/paranamer-1.5.jar differ diff --git a/src/main/repository/deprecated/paranamer/1.5/paranamer-1.5.pom b/src/main/repository/deprecated/paranamer/1.5/paranamer-1.5.pom new file mode 100644 index 0000000..3cb46d3 --- /dev/null +++ b/src/main/repository/deprecated/paranamer/1.5/paranamer-1.5.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + deprecated + paranamer + 1.5 + POM was created from install:install-file + diff --git a/src/main/repository/deprecated/paranamer/maven-metadata-local.xml b/src/main/repository/deprecated/paranamer/maven-metadata-local.xml new file mode 100644 index 0000000..11a7133 --- /dev/null +++ b/src/main/repository/deprecated/paranamer/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + deprecated + paranamer + + 1.5 + + 1.5 + + 20160204080008 + + diff --git a/src/main/repository/deprecated/reflectasm/1.05/reflectasm-1.05.jar b/src/main/repository/deprecated/reflectasm/1.05/reflectasm-1.05.jar new file mode 100644 index 0000000..697f70a Binary files /dev/null and b/src/main/repository/deprecated/reflectasm/1.05/reflectasm-1.05.jar differ diff --git a/src/main/repository/deprecated/reflectasm/1.05/reflectasm-1.05.pom b/src/main/repository/deprecated/reflectasm/1.05/reflectasm-1.05.pom new file mode 100644 index 0000000..c992f3a --- /dev/null +++ b/src/main/repository/deprecated/reflectasm/1.05/reflectasm-1.05.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + deprecated + reflectasm + 1.05 + POM was created from install:install-file + diff --git a/src/main/repository/deprecated/reflectasm/maven-metadata-local.xml b/src/main/repository/deprecated/reflectasm/maven-metadata-local.xml new file mode 100644 index 0000000..fb85db7 --- /dev/null +++ b/src/main/repository/deprecated/reflectasm/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + deprecated + reflectasm + + 1.05 + + 1.05 + + 20160204080011 + + diff --git a/src/main/repository/deprecated/sbinary_2.11/0.4.3-SNAPSHOT/maven-metadata-local.xml b/src/main/repository/deprecated/sbinary_2.11/0.4.3-SNAPSHOT/maven-metadata-local.xml new file mode 100644 index 0000000..b59c49e --- /dev/null +++ b/src/main/repository/deprecated/sbinary_2.11/0.4.3-SNAPSHOT/maven-metadata-local.xml @@ -0,0 +1,24 @@ + + + deprecated + sbinary_2.11 + 0.4.3-SNAPSHOT + + + true + + 20160204080010 + + + jar + 0.4.3-SNAPSHOT + 20160204080010 + + + pom + 0.4.3-SNAPSHOT + 20160204080010 + + + + diff --git a/src/main/repository/deprecated/sbinary_2.11/0.4.3-SNAPSHOT/sbinary_2.11-0.4.3-SNAPSHOT.jar b/src/main/repository/deprecated/sbinary_2.11/0.4.3-SNAPSHOT/sbinary_2.11-0.4.3-SNAPSHOT.jar new file mode 100644 index 0000000..4cc89f9 Binary files /dev/null and b/src/main/repository/deprecated/sbinary_2.11/0.4.3-SNAPSHOT/sbinary_2.11-0.4.3-SNAPSHOT.jar differ diff --git a/src/main/repository/deprecated/sbinary_2.11/0.4.3-SNAPSHOT/sbinary_2.11-0.4.3-SNAPSHOT.pom b/src/main/repository/deprecated/sbinary_2.11/0.4.3-SNAPSHOT/sbinary_2.11-0.4.3-SNAPSHOT.pom new file mode 100644 index 0000000..8939147 --- /dev/null +++ b/src/main/repository/deprecated/sbinary_2.11/0.4.3-SNAPSHOT/sbinary_2.11-0.4.3-SNAPSHOT.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + deprecated + sbinary_2.11 + 0.4.3-SNAPSHOT + POM was created from install:install-file + diff --git a/src/main/repository/deprecated/sbinary_2.11/maven-metadata-local.xml b/src/main/repository/deprecated/sbinary_2.11/maven-metadata-local.xml new file mode 100644 index 0000000..81963b0 --- /dev/null +++ b/src/main/repository/deprecated/sbinary_2.11/maven-metadata-local.xml @@ -0,0 +1,11 @@ + + + deprecated + sbinary_2.11 + + + 0.4.3-SNAPSHOT + + 20160204080010 + + diff --git a/src/main/repository/deprecated/scala-library_2.11.2/1.0-SNAPSHOT/maven-metadata-local.xml b/src/main/repository/deprecated/scala-library_2.11.2/1.0-SNAPSHOT/maven-metadata-local.xml new file mode 100644 index 0000000..9b19dd9 --- /dev/null +++ b/src/main/repository/deprecated/scala-library_2.11.2/1.0-SNAPSHOT/maven-metadata-local.xml @@ -0,0 +1,24 @@ + + + deprecated + scala-library_2.11.2 + 1.0-SNAPSHOT + + + true + + 20160204080011 + + + jar + 1.0-SNAPSHOT + 20160204080011 + + + pom + 1.0-SNAPSHOT + 20160204080011 + + + + diff --git a/src/main/repository/deprecated/scala-library_2.11.2/1.0-SNAPSHOT/scala-library_2.11.2-1.0-SNAPSHOT.jar b/src/main/repository/deprecated/scala-library_2.11.2/1.0-SNAPSHOT/scala-library_2.11.2-1.0-SNAPSHOT.jar new file mode 100644 index 0000000..65a17d0 Binary files /dev/null and b/src/main/repository/deprecated/scala-library_2.11.2/1.0-SNAPSHOT/scala-library_2.11.2-1.0-SNAPSHOT.jar differ diff --git a/src/main/repository/deprecated/scala-library_2.11.2/1.0-SNAPSHOT/scala-library_2.11.2-1.0-SNAPSHOT.pom b/src/main/repository/deprecated/scala-library_2.11.2/1.0-SNAPSHOT/scala-library_2.11.2-1.0-SNAPSHOT.pom new file mode 100644 index 0000000..781b28c --- /dev/null +++ b/src/main/repository/deprecated/scala-library_2.11.2/1.0-SNAPSHOT/scala-library_2.11.2-1.0-SNAPSHOT.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + deprecated + scala-library_2.11.2 + 1.0-SNAPSHOT + POM was created from install:install-file + diff --git a/src/main/repository/deprecated/scala-library_2.11.2/maven-metadata-local.xml b/src/main/repository/deprecated/scala-library_2.11.2/maven-metadata-local.xml new file mode 100644 index 0000000..bffb536 --- /dev/null +++ b/src/main/repository/deprecated/scala-library_2.11.2/maven-metadata-local.xml @@ -0,0 +1,11 @@ + + + deprecated + scala-library_2.11.2 + + + 1.0-SNAPSHOT + + 20160204080011 + + diff --git a/src/main/repository/deprecated/scala-reflect_2.11.2/1.0-SNAPSHOT/maven-metadata-local.xml b/src/main/repository/deprecated/scala-reflect_2.11.2/1.0-SNAPSHOT/maven-metadata-local.xml new file mode 100644 index 0000000..6027544 --- /dev/null +++ b/src/main/repository/deprecated/scala-reflect_2.11.2/1.0-SNAPSHOT/maven-metadata-local.xml @@ -0,0 +1,24 @@ + + + deprecated + scala-reflect_2.11.2 + 1.0-SNAPSHOT + + + true + + 20160204080013 + + + jar + 1.0-SNAPSHOT + 20160204080013 + + + pom + 1.0-SNAPSHOT + 20160204080013 + + + + diff --git a/src/main/repository/deprecated/scala-reflect_2.11.2/1.0-SNAPSHOT/scala-reflect_2.11.2-1.0-SNAPSHOT.jar b/src/main/repository/deprecated/scala-reflect_2.11.2/1.0-SNAPSHOT/scala-reflect_2.11.2-1.0-SNAPSHOT.jar new file mode 100644 index 0000000..db3bbd5 Binary files /dev/null and b/src/main/repository/deprecated/scala-reflect_2.11.2/1.0-SNAPSHOT/scala-reflect_2.11.2-1.0-SNAPSHOT.jar differ diff --git a/src/main/repository/deprecated/scala-reflect_2.11.2/1.0-SNAPSHOT/scala-reflect_2.11.2-1.0-SNAPSHOT.pom b/src/main/repository/deprecated/scala-reflect_2.11.2/1.0-SNAPSHOT/scala-reflect_2.11.2-1.0-SNAPSHOT.pom new file mode 100644 index 0000000..a7df9ba --- /dev/null +++ b/src/main/repository/deprecated/scala-reflect_2.11.2/1.0-SNAPSHOT/scala-reflect_2.11.2-1.0-SNAPSHOT.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + deprecated + scala-reflect_2.11.2 + 1.0-SNAPSHOT + POM was created from install:install-file + diff --git a/src/main/repository/deprecated/scala-reflect_2.11.2/maven-metadata-local.xml b/src/main/repository/deprecated/scala-reflect_2.11.2/maven-metadata-local.xml new file mode 100644 index 0000000..b78f1f0 --- /dev/null +++ b/src/main/repository/deprecated/scala-reflect_2.11.2/maven-metadata-local.xml @@ -0,0 +1,11 @@ + + + deprecated + scala-reflect_2.11.2 + + + 1.0-SNAPSHOT + + 20160204080013 + + diff --git a/src/main/repository/deprecated/snakeyaml/1.1/snakeyaml-1.1.jar b/src/main/repository/deprecated/snakeyaml/1.1/snakeyaml-1.1.jar new file mode 100644 index 0000000..012718d Binary files /dev/null and b/src/main/repository/deprecated/snakeyaml/1.1/snakeyaml-1.1.jar differ diff --git a/src/main/repository/deprecated/snakeyaml/1.1/snakeyaml-1.1.pom b/src/main/repository/deprecated/snakeyaml/1.1/snakeyaml-1.1.pom new file mode 100644 index 0000000..6b2b6eb --- /dev/null +++ b/src/main/repository/deprecated/snakeyaml/1.1/snakeyaml-1.1.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + deprecated + snakeyaml + 1.1 + POM was created from install:install-file + diff --git a/src/main/repository/deprecated/snakeyaml/maven-metadata-local.xml b/src/main/repository/deprecated/snakeyaml/maven-metadata-local.xml new file mode 100644 index 0000000..0561b4b --- /dev/null +++ b/src/main/repository/deprecated/snakeyaml/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + deprecated + snakeyaml + + 1.1 + + 1.1 + + 20160204080012 + + diff --git a/src/main/repository/deprecated/stephenerialization/3.0.0/stephenerialization-3.0.0.jar b/src/main/repository/deprecated/stephenerialization/3.0.0/stephenerialization-3.0.0.jar new file mode 100644 index 0000000..b5ce61d Binary files /dev/null and b/src/main/repository/deprecated/stephenerialization/3.0.0/stephenerialization-3.0.0.jar differ diff --git a/src/main/repository/deprecated/stephenerialization/3.0.0/stephenerialization-3.0.0.pom b/src/main/repository/deprecated/stephenerialization/3.0.0/stephenerialization-3.0.0.pom new file mode 100644 index 0000000..0fa939b --- /dev/null +++ b/src/main/repository/deprecated/stephenerialization/3.0.0/stephenerialization-3.0.0.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + deprecated + stephenerialization + 3.0.0 + POM was created from install:install-file + diff --git a/src/main/repository/deprecated/stephenerialization/maven-metadata-local.xml b/src/main/repository/deprecated/stephenerialization/maven-metadata-local.xml new file mode 100644 index 0000000..52debd6 --- /dev/null +++ b/src/main/repository/deprecated/stephenerialization/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + deprecated + stephenerialization + + 3.0.0 + + 3.0.0 + + 20160204080013 + + diff --git a/src/main/repository/deprecated/svenson/1.4.0/svenson-1.4.0.jar b/src/main/repository/deprecated/svenson/1.4.0/svenson-1.4.0.jar new file mode 100644 index 0000000..5a4701e Binary files /dev/null and b/src/main/repository/deprecated/svenson/1.4.0/svenson-1.4.0.jar differ diff --git a/src/main/repository/deprecated/svenson/1.4.0/svenson-1.4.0.pom b/src/main/repository/deprecated/svenson/1.4.0/svenson-1.4.0.pom new file mode 100644 index 0000000..c9a71a4 --- /dev/null +++ b/src/main/repository/deprecated/svenson/1.4.0/svenson-1.4.0.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + deprecated + svenson + 1.4.0 + POM was created from install:install-file + diff --git a/src/main/repository/deprecated/svenson/maven-metadata-local.xml b/src/main/repository/deprecated/svenson/maven-metadata-local.xml new file mode 100644 index 0000000..f0b188d --- /dev/null +++ b/src/main/repository/deprecated/svenson/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + deprecated + svenson + + 1.4.0 + + 1.4.0 + + 20160204080012 + + diff --git a/src/main/repository/deprecated/trove/1.0.2/trove-1.0.2.jar b/src/main/repository/deprecated/trove/1.0.2/trove-1.0.2.jar new file mode 100644 index 0000000..ac62eb3 Binary files /dev/null and b/src/main/repository/deprecated/trove/1.0.2/trove-1.0.2.jar differ diff --git a/src/main/repository/deprecated/trove/1.0.2/trove-1.0.2.pom b/src/main/repository/deprecated/trove/1.0.2/trove-1.0.2.pom new file mode 100644 index 0000000..386125f --- /dev/null +++ b/src/main/repository/deprecated/trove/1.0.2/trove-1.0.2.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + deprecated + trove + 1.0.2 + POM was created from install:install-file + diff --git a/src/main/repository/deprecated/trove/maven-metadata-local.xml b/src/main/repository/deprecated/trove/maven-metadata-local.xml new file mode 100644 index 0000000..2a76722 --- /dev/null +++ b/src/main/repository/deprecated/trove/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + deprecated + trove + + 1.0.2 + + 1.0.2 + + 20160204080014 + + diff --git a/src/main/repository/deprecated/velocity/1.7-dep/velocity-1.7-dep.jar b/src/main/repository/deprecated/velocity/1.7-dep/velocity-1.7-dep.jar new file mode 100644 index 0000000..c99aecf Binary files /dev/null and b/src/main/repository/deprecated/velocity/1.7-dep/velocity-1.7-dep.jar differ diff --git a/src/main/repository/deprecated/velocity/1.7-dep/velocity-1.7-dep.pom b/src/main/repository/deprecated/velocity/1.7-dep/velocity-1.7-dep.pom new file mode 100644 index 0000000..e956ba4 --- /dev/null +++ b/src/main/repository/deprecated/velocity/1.7-dep/velocity-1.7-dep.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + deprecated + velocity + 1.7-dep + POM was created from install:install-file + diff --git a/src/main/repository/deprecated/velocity/1.7/velocity-1.7.jar b/src/main/repository/deprecated/velocity/1.7/velocity-1.7.jar new file mode 100644 index 0000000..ae936d3 Binary files /dev/null and b/src/main/repository/deprecated/velocity/1.7/velocity-1.7.jar differ diff --git a/src/main/repository/deprecated/velocity/1.7/velocity-1.7.pom b/src/main/repository/deprecated/velocity/1.7/velocity-1.7.pom new file mode 100644 index 0000000..614ddc8 --- /dev/null +++ b/src/main/repository/deprecated/velocity/1.7/velocity-1.7.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + deprecated + velocity + 1.7 + POM was created from install:install-file + diff --git a/src/main/repository/deprecated/velocity/maven-metadata-local.xml b/src/main/repository/deprecated/velocity/maven-metadata-local.xml new file mode 100644 index 0000000..2c9ba3c --- /dev/null +++ b/src/main/repository/deprecated/velocity/maven-metadata-local.xml @@ -0,0 +1,13 @@ + + + deprecated + velocity + + 1.7 + + 1.7-dep + 1.7 + + 20160204080014 + + diff --git a/src/main/repository/deprecated/xpp3_min/1.1.4c/xpp3_min-1.1.4c.jar b/src/main/repository/deprecated/xpp3_min/1.1.4c/xpp3_min-1.1.4c.jar new file mode 100644 index 0000000..813a9a8 Binary files /dev/null and b/src/main/repository/deprecated/xpp3_min/1.1.4c/xpp3_min-1.1.4c.jar differ diff --git a/src/main/repository/deprecated/xpp3_min/1.1.4c/xpp3_min-1.1.4c.pom b/src/main/repository/deprecated/xpp3_min/1.1.4c/xpp3_min-1.1.4c.pom new file mode 100644 index 0000000..c123154 --- /dev/null +++ b/src/main/repository/deprecated/xpp3_min/1.1.4c/xpp3_min-1.1.4c.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + deprecated + xpp3_min + 1.1.4c + POM was created from install:install-file + diff --git a/src/main/repository/deprecated/xpp3_min/maven-metadata-local.xml b/src/main/repository/deprecated/xpp3_min/maven-metadata-local.xml new file mode 100644 index 0000000..50a3a5a --- /dev/null +++ b/src/main/repository/deprecated/xpp3_min/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + deprecated + xpp3_min + + 1.1.4c + + 1.1.4c + + 20160204080014 + + diff --git a/src/main/repository/deprecated/xstream/1.3.1/xstream-1.3.1.jar b/src/main/repository/deprecated/xstream/1.3.1/xstream-1.3.1.jar new file mode 100644 index 0000000..4ef4219 Binary files /dev/null and b/src/main/repository/deprecated/xstream/1.3.1/xstream-1.3.1.jar differ diff --git a/src/main/repository/deprecated/xstream/1.3.1/xstream-1.3.1.pom b/src/main/repository/deprecated/xstream/1.3.1/xstream-1.3.1.pom new file mode 100644 index 0000000..d2a7518 --- /dev/null +++ b/src/main/repository/deprecated/xstream/1.3.1/xstream-1.3.1.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + deprecated + xstream + 1.3.1 + POM was created from install:install-file + diff --git a/src/main/repository/deprecated/xstream/maven-metadata-local.xml b/src/main/repository/deprecated/xstream/maven-metadata-local.xml new file mode 100644 index 0000000..6641e1c --- /dev/null +++ b/src/main/repository/deprecated/xstream/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + deprecated + xstream + + 1.3.1 + + 1.3.1 + + 20160204080014 + + diff --git a/src/main/repository/dsl/dsl-json/0.9.0/dsl-json-0.9.0.jar b/src/main/repository/dsl/dsl-json/0.9.0/dsl-json-0.9.0.jar new file mode 100644 index 0000000..1d30612 Binary files /dev/null and b/src/main/repository/dsl/dsl-json/0.9.0/dsl-json-0.9.0.jar differ diff --git a/src/main/repository/dsl/dsl-json/0.9.0/dsl-json-0.9.0.pom b/src/main/repository/dsl/dsl-json/0.9.0/dsl-json-0.9.0.pom new file mode 100644 index 0000000..7e8a3b1 --- /dev/null +++ b/src/main/repository/dsl/dsl-json/0.9.0/dsl-json-0.9.0.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + dsl + dsl-json + 0.9.0 + POM was created from install:install-file + diff --git a/src/main/repository/dsl/dsl-json/maven-metadata-local.xml b/src/main/repository/dsl/dsl-json/maven-metadata-local.xml new file mode 100644 index 0000000..de0a29f --- /dev/null +++ b/src/main/repository/dsl/dsl-json/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + dsl + dsl-json + + 0.9.0 + + 0.9.0 + + 20160204075940 + + diff --git a/src/main/repository/exi/exi-exificient/0.9.1/exi-exificient-0.9.1.jar b/src/main/repository/exi/exi-exificient/0.9.1/exi-exificient-0.9.1.jar new file mode 100644 index 0000000..4cea0b0 Binary files /dev/null and b/src/main/repository/exi/exi-exificient/0.9.1/exi-exificient-0.9.1.jar differ diff --git a/src/main/repository/exi/exi-exificient/0.9.1/exi-exificient-0.9.1.pom b/src/main/repository/exi/exi-exificient/0.9.1/exi-exificient-0.9.1.pom new file mode 100644 index 0000000..252d7fd --- /dev/null +++ b/src/main/repository/exi/exi-exificient/0.9.1/exi-exificient-0.9.1.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + exi + exi-exificient + 0.9.1 + POM was created from install:install-file + diff --git a/src/main/repository/exi/exi-exificient/maven-metadata-local.xml b/src/main/repository/exi/exi-exificient/maven-metadata-local.xml new file mode 100644 index 0000000..d01adf9 --- /dev/null +++ b/src/main/repository/exi/exi-exificient/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + exi + exi-exificient + + 0.9.1 + + 0.9.1 + + 20160204075945 + + diff --git a/src/main/repository/jackson-dataformat/jackson-dataformat-avro/2.5.0/jackson-dataformat-avro-2.5.0.jar b/src/main/repository/jackson-dataformat/jackson-dataformat-avro/2.5.0/jackson-dataformat-avro-2.5.0.jar new file mode 100644 index 0000000..6130ac8 Binary files /dev/null and b/src/main/repository/jackson-dataformat/jackson-dataformat-avro/2.5.0/jackson-dataformat-avro-2.5.0.jar differ diff --git a/src/main/repository/jackson-dataformat/jackson-dataformat-avro/2.5.0/jackson-dataformat-avro-2.5.0.pom b/src/main/repository/jackson-dataformat/jackson-dataformat-avro/2.5.0/jackson-dataformat-avro-2.5.0.pom new file mode 100644 index 0000000..a8693dd --- /dev/null +++ b/src/main/repository/jackson-dataformat/jackson-dataformat-avro/2.5.0/jackson-dataformat-avro-2.5.0.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + jackson-dataformat + jackson-dataformat-avro + 2.5.0 + POM was created from install:install-file + diff --git a/src/main/repository/jackson-dataformat/jackson-dataformat-avro/maven-metadata-local.xml b/src/main/repository/jackson-dataformat/jackson-dataformat-avro/maven-metadata-local.xml new file mode 100644 index 0000000..2d10089 --- /dev/null +++ b/src/main/repository/jackson-dataformat/jackson-dataformat-avro/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + jackson-dataformat + jackson-dataformat-avro + + 2.5.0 + + 2.5.0 + + 20160204075952 + + diff --git a/src/main/repository/jackson-dataformat/jackson-dataformat-cbor/2.5.0/jackson-dataformat-cbor-2.5.0.jar b/src/main/repository/jackson-dataformat/jackson-dataformat-cbor/2.5.0/jackson-dataformat-cbor-2.5.0.jar new file mode 100644 index 0000000..4a44be0 Binary files /dev/null and b/src/main/repository/jackson-dataformat/jackson-dataformat-cbor/2.5.0/jackson-dataformat-cbor-2.5.0.jar differ diff --git a/src/main/repository/jackson-dataformat/jackson-dataformat-cbor/2.5.0/jackson-dataformat-cbor-2.5.0.pom b/src/main/repository/jackson-dataformat/jackson-dataformat-cbor/2.5.0/jackson-dataformat-cbor-2.5.0.pom new file mode 100644 index 0000000..6d30b76 --- /dev/null +++ b/src/main/repository/jackson-dataformat/jackson-dataformat-cbor/2.5.0/jackson-dataformat-cbor-2.5.0.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + jackson-dataformat + jackson-dataformat-cbor + 2.5.0 + POM was created from install:install-file + diff --git a/src/main/repository/jackson-dataformat/jackson-dataformat-cbor/maven-metadata-local.xml b/src/main/repository/jackson-dataformat/jackson-dataformat-cbor/maven-metadata-local.xml new file mode 100644 index 0000000..e919bc6 --- /dev/null +++ b/src/main/repository/jackson-dataformat/jackson-dataformat-cbor/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + jackson-dataformat + jackson-dataformat-cbor + + 2.5.0 + + 2.5.0 + + 20160204075954 + + diff --git a/src/main/repository/jackson-dataformat/jackson-dataformat-smile/2.5.0/jackson-dataformat-smile-2.5.0.jar b/src/main/repository/jackson-dataformat/jackson-dataformat-smile/2.5.0/jackson-dataformat-smile-2.5.0.jar new file mode 100644 index 0000000..0e1a835 Binary files /dev/null and b/src/main/repository/jackson-dataformat/jackson-dataformat-smile/2.5.0/jackson-dataformat-smile-2.5.0.jar differ diff --git a/src/main/repository/jackson-dataformat/jackson-dataformat-smile/2.5.0/jackson-dataformat-smile-2.5.0.pom b/src/main/repository/jackson-dataformat/jackson-dataformat-smile/2.5.0/jackson-dataformat-smile-2.5.0.pom new file mode 100644 index 0000000..705e227 --- /dev/null +++ b/src/main/repository/jackson-dataformat/jackson-dataformat-smile/2.5.0/jackson-dataformat-smile-2.5.0.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + jackson-dataformat + jackson-dataformat-smile + 2.5.0 + POM was created from install:install-file + diff --git a/src/main/repository/jackson-dataformat/jackson-dataformat-smile/maven-metadata-local.xml b/src/main/repository/jackson-dataformat/jackson-dataformat-smile/maven-metadata-local.xml new file mode 100644 index 0000000..dd667fa --- /dev/null +++ b/src/main/repository/jackson-dataformat/jackson-dataformat-smile/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + jackson-dataformat + jackson-dataformat-smile + + 2.5.0 + + 2.5.0 + + 20160204075953 + + diff --git a/src/main/repository/jackson-dataformat/jackson-dataformat-xml/2.5.0/jackson-dataformat-xml-2.5.0.jar b/src/main/repository/jackson-dataformat/jackson-dataformat-xml/2.5.0/jackson-dataformat-xml-2.5.0.jar new file mode 100644 index 0000000..ff73aa4 Binary files /dev/null and b/src/main/repository/jackson-dataformat/jackson-dataformat-xml/2.5.0/jackson-dataformat-xml-2.5.0.jar differ diff --git a/src/main/repository/jackson-dataformat/jackson-dataformat-xml/2.5.0/jackson-dataformat-xml-2.5.0.pom b/src/main/repository/jackson-dataformat/jackson-dataformat-xml/2.5.0/jackson-dataformat-xml-2.5.0.pom new file mode 100644 index 0000000..f8d4515 --- /dev/null +++ b/src/main/repository/jackson-dataformat/jackson-dataformat-xml/2.5.0/jackson-dataformat-xml-2.5.0.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + jackson-dataformat + jackson-dataformat-xml + 2.5.0 + POM was created from install:install-file + diff --git a/src/main/repository/jackson-dataformat/jackson-dataformat-xml/maven-metadata-local.xml b/src/main/repository/jackson-dataformat/jackson-dataformat-xml/maven-metadata-local.xml new file mode 100644 index 0000000..ba7f4ac --- /dev/null +++ b/src/main/repository/jackson-dataformat/jackson-dataformat-xml/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + jackson-dataformat + jackson-dataformat-xml + + 2.5.0 + + 2.5.0 + + 20160204075954 + + diff --git a/src/main/repository/jackson-dataformat/jackson-dataformat-yaml/2.5.0/jackson-dataformat-yaml-2.5.0.jar b/src/main/repository/jackson-dataformat/jackson-dataformat-yaml/2.5.0/jackson-dataformat-yaml-2.5.0.jar new file mode 100644 index 0000000..fe4199f Binary files /dev/null and b/src/main/repository/jackson-dataformat/jackson-dataformat-yaml/2.5.0/jackson-dataformat-yaml-2.5.0.jar differ diff --git a/src/main/repository/jackson-dataformat/jackson-dataformat-yaml/2.5.0/jackson-dataformat-yaml-2.5.0.pom b/src/main/repository/jackson-dataformat/jackson-dataformat-yaml/2.5.0/jackson-dataformat-yaml-2.5.0.pom new file mode 100644 index 0000000..fe149b4 --- /dev/null +++ b/src/main/repository/jackson-dataformat/jackson-dataformat-yaml/2.5.0/jackson-dataformat-yaml-2.5.0.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + jackson-dataformat + jackson-dataformat-yaml + 2.5.0 + POM was created from install:install-file + diff --git a/src/main/repository/jackson-dataformat/jackson-dataformat-yaml/maven-metadata-local.xml b/src/main/repository/jackson-dataformat/jackson-dataformat-yaml/maven-metadata-local.xml new file mode 100644 index 0000000..cc7e7c8 --- /dev/null +++ b/src/main/repository/jackson-dataformat/jackson-dataformat-yaml/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + jackson-dataformat + jackson-dataformat-yaml + + 2.5.0 + + 2.5.0 + + 20160204075956 + + diff --git a/src/main/repository/jackson-jr/jackson-jr-objects/2.5.0/jackson-jr-objects-2.5.0.jar b/src/main/repository/jackson-jr/jackson-jr-objects/2.5.0/jackson-jr-objects-2.5.0.jar new file mode 100644 index 0000000..f5b48f8 Binary files /dev/null and b/src/main/repository/jackson-jr/jackson-jr-objects/2.5.0/jackson-jr-objects-2.5.0.jar differ diff --git a/src/main/repository/jackson-jr/jackson-jr-objects/2.5.0/jackson-jr-objects-2.5.0.pom b/src/main/repository/jackson-jr/jackson-jr-objects/2.5.0/jackson-jr-objects-2.5.0.pom new file mode 100644 index 0000000..7a02d8f --- /dev/null +++ b/src/main/repository/jackson-jr/jackson-jr-objects/2.5.0/jackson-jr-objects-2.5.0.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + jackson-jr + jackson-jr-objects + 2.5.0 + POM was created from install:install-file + diff --git a/src/main/repository/jackson-jr/jackson-jr-objects/maven-metadata-local.xml b/src/main/repository/jackson-jr/jackson-jr-objects/maven-metadata-local.xml new file mode 100644 index 0000000..fc8cd1c --- /dev/null +++ b/src/main/repository/jackson-jr/jackson-jr-objects/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + jackson-jr + jackson-jr-objects + + 2.5.0 + + 2.5.0 + + 20160204075957 + + diff --git a/src/main/repository/jackson-module/jackson-module-afterburner/2.5.0/jackson-module-afterburner-2.5.0.jar b/src/main/repository/jackson-module/jackson-module-afterburner/2.5.0/jackson-module-afterburner-2.5.0.jar new file mode 100644 index 0000000..2322c4d Binary files /dev/null and b/src/main/repository/jackson-module/jackson-module-afterburner/2.5.0/jackson-module-afterburner-2.5.0.jar differ diff --git a/src/main/repository/jackson-module/jackson-module-afterburner/2.5.0/jackson-module-afterburner-2.5.0.pom b/src/main/repository/jackson-module/jackson-module-afterburner/2.5.0/jackson-module-afterburner-2.5.0.pom new file mode 100644 index 0000000..58a52e1 --- /dev/null +++ b/src/main/repository/jackson-module/jackson-module-afterburner/2.5.0/jackson-module-afterburner-2.5.0.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + jackson-module + jackson-module-afterburner + 2.5.0 + POM was created from install:install-file + diff --git a/src/main/repository/jackson-module/jackson-module-afterburner/maven-metadata-local.xml b/src/main/repository/jackson-module/jackson-module-afterburner/maven-metadata-local.xml new file mode 100644 index 0000000..ad8f7ed --- /dev/null +++ b/src/main/repository/jackson-module/jackson-module-afterburner/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + jackson-module + jackson-module-afterburner + + 2.5.0 + + 2.5.0 + + 20160204075954 + + diff --git a/src/main/repository/jackson/jackson-all/1.9.6/jackson-all-1.9.6.jar b/src/main/repository/jackson/jackson-all/1.9.6/jackson-all-1.9.6.jar new file mode 100644 index 0000000..df87026 Binary files /dev/null and b/src/main/repository/jackson/jackson-all/1.9.6/jackson-all-1.9.6.jar differ diff --git a/src/main/repository/jackson/jackson-all/1.9.6/jackson-all-1.9.6.pom b/src/main/repository/jackson/jackson-all/1.9.6/jackson-all-1.9.6.pom new file mode 100644 index 0000000..caaca0e --- /dev/null +++ b/src/main/repository/jackson/jackson-all/1.9.6/jackson-all-1.9.6.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + jackson + jackson-all + 1.9.6 + POM was created from install:install-file + diff --git a/src/main/repository/jackson/jackson-all/maven-metadata-local.xml b/src/main/repository/jackson/jackson-all/maven-metadata-local.xml new file mode 100644 index 0000000..6382a31 --- /dev/null +++ b/src/main/repository/jackson/jackson-all/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + jackson + jackson-all + + 1.9.6 + + 1.9.6 + + 20160204075949 + + diff --git a/src/main/repository/jackson/jackson-annotations/2.5.0/jackson-annotations-2.5.0.jar b/src/main/repository/jackson/jackson-annotations/2.5.0/jackson-annotations-2.5.0.jar new file mode 100644 index 0000000..6252131 Binary files /dev/null and b/src/main/repository/jackson/jackson-annotations/2.5.0/jackson-annotations-2.5.0.jar differ diff --git a/src/main/repository/jackson/jackson-annotations/2.5.0/jackson-annotations-2.5.0.pom b/src/main/repository/jackson/jackson-annotations/2.5.0/jackson-annotations-2.5.0.pom new file mode 100644 index 0000000..b07f79e --- /dev/null +++ b/src/main/repository/jackson/jackson-annotations/2.5.0/jackson-annotations-2.5.0.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + jackson + jackson-annotations + 2.5.0 + POM was created from install:install-file + diff --git a/src/main/repository/jackson/jackson-annotations/maven-metadata-local.xml b/src/main/repository/jackson/jackson-annotations/maven-metadata-local.xml new file mode 100644 index 0000000..634b916 --- /dev/null +++ b/src/main/repository/jackson/jackson-annotations/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + jackson + jackson-annotations + + 2.5.0 + + 2.5.0 + + 20160204075951 + + diff --git a/src/main/repository/jackson/jackson-core/2.5.0/jackson-core-2.5.0.jar b/src/main/repository/jackson/jackson-core/2.5.0/jackson-core-2.5.0.jar new file mode 100644 index 0000000..e8ca122 Binary files /dev/null and b/src/main/repository/jackson/jackson-core/2.5.0/jackson-core-2.5.0.jar differ diff --git a/src/main/repository/jackson/jackson-core/2.5.0/jackson-core-2.5.0.pom b/src/main/repository/jackson/jackson-core/2.5.0/jackson-core-2.5.0.pom new file mode 100644 index 0000000..3d7207c --- /dev/null +++ b/src/main/repository/jackson/jackson-core/2.5.0/jackson-core-2.5.0.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + jackson + jackson-core + 2.5.0 + POM was created from install:install-file + diff --git a/src/main/repository/jackson/jackson-core/maven-metadata-local.xml b/src/main/repository/jackson/jackson-core/maven-metadata-local.xml new file mode 100644 index 0000000..114cd02 --- /dev/null +++ b/src/main/repository/jackson/jackson-core/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + jackson + jackson-core + + 2.5.0 + + 2.5.0 + + 20160204075950 + + diff --git a/src/main/repository/jackson/jackson-databind/2.5.0/jackson-databind-2.5.0.jar b/src/main/repository/jackson/jackson-databind/2.5.0/jackson-databind-2.5.0.jar new file mode 100644 index 0000000..8e4a594 Binary files /dev/null and b/src/main/repository/jackson/jackson-databind/2.5.0/jackson-databind-2.5.0.jar differ diff --git a/src/main/repository/jackson/jackson-databind/2.5.0/jackson-databind-2.5.0.pom b/src/main/repository/jackson/jackson-databind/2.5.0/jackson-databind-2.5.0.pom new file mode 100644 index 0000000..45f03a0 --- /dev/null +++ b/src/main/repository/jackson/jackson-databind/2.5.0/jackson-databind-2.5.0.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + jackson + jackson-databind + 2.5.0 + POM was created from install:install-file + diff --git a/src/main/repository/jackson/jackson-databind/maven-metadata-local.xml b/src/main/repository/jackson/jackson-databind/maven-metadata-local.xml new file mode 100644 index 0000000..548ca08 --- /dev/null +++ b/src/main/repository/jackson/jackson-databind/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + jackson + jackson-databind + + 2.5.0 + + 2.5.0 + + 20160204075950 + + diff --git a/src/main/repository/jboss-marshalling/jboss-marshalling-osgi/1.3.15.GA/jboss-marshalling-osgi-1.3.15.GA.jar b/src/main/repository/jboss-marshalling/jboss-marshalling-osgi/1.3.15.GA/jboss-marshalling-osgi-1.3.15.GA.jar new file mode 100644 index 0000000..0cfdbe0 Binary files /dev/null and b/src/main/repository/jboss-marshalling/jboss-marshalling-osgi/1.3.15.GA/jboss-marshalling-osgi-1.3.15.GA.jar differ diff --git a/src/main/repository/jboss-marshalling/jboss-marshalling-osgi/1.3.15.GA/jboss-marshalling-osgi-1.3.15.GA.pom b/src/main/repository/jboss-marshalling/jboss-marshalling-osgi/1.3.15.GA/jboss-marshalling-osgi-1.3.15.GA.pom new file mode 100644 index 0000000..3564f3f --- /dev/null +++ b/src/main/repository/jboss-marshalling/jboss-marshalling-osgi/1.3.15.GA/jboss-marshalling-osgi-1.3.15.GA.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + jboss-marshalling + jboss-marshalling-osgi + 1.3.15.GA + POM was created from install:install-file + diff --git a/src/main/repository/jboss-marshalling/jboss-marshalling-osgi/maven-metadata-local.xml b/src/main/repository/jboss-marshalling/jboss-marshalling-osgi/maven-metadata-local.xml new file mode 100644 index 0000000..2b66296 --- /dev/null +++ b/src/main/repository/jboss-marshalling/jboss-marshalling-osgi/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + jboss-marshalling + jboss-marshalling-osgi + + 1.3.15.GA + + 1.3.15.GA + + 20160204075958 + + diff --git a/src/main/repository/jboss/jboss-serialization/1.0.3.GA/jboss-serialization-1.0.3.GA.jar b/src/main/repository/jboss/jboss-serialization/1.0.3.GA/jboss-serialization-1.0.3.GA.jar new file mode 100644 index 0000000..c15c60d Binary files /dev/null and b/src/main/repository/jboss/jboss-serialization/1.0.3.GA/jboss-serialization-1.0.3.GA.jar differ diff --git a/src/main/repository/jboss/jboss-serialization/1.0.3.GA/jboss-serialization-1.0.3.GA.pom b/src/main/repository/jboss/jboss-serialization/1.0.3.GA/jboss-serialization-1.0.3.GA.pom new file mode 100644 index 0000000..a9d2f3a --- /dev/null +++ b/src/main/repository/jboss/jboss-serialization/1.0.3.GA/jboss-serialization-1.0.3.GA.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + jboss + jboss-serialization + 1.0.3.GA + POM was created from install:install-file + diff --git a/src/main/repository/jboss/jboss-serialization/maven-metadata-local.xml b/src/main/repository/jboss/jboss-serialization/maven-metadata-local.xml new file mode 100644 index 0000000..db04054 --- /dev/null +++ b/src/main/repository/jboss/jboss-serialization/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + jboss + jboss-serialization + + 1.0.3.GA + + 1.0.3.GA + + 20160204075957 + + diff --git a/src/main/repository/jopt/jopt-simple/3.2/jopt-simple-3.2.jar b/src/main/repository/jopt/jopt-simple/3.2/jopt-simple-3.2.jar new file mode 100644 index 0000000..5637362 Binary files /dev/null and b/src/main/repository/jopt/jopt-simple/3.2/jopt-simple-3.2.jar differ diff --git a/src/main/repository/jopt/jopt-simple/3.2/jopt-simple-3.2.pom b/src/main/repository/jopt/jopt-simple/3.2/jopt-simple-3.2.pom new file mode 100644 index 0000000..cc82510 --- /dev/null +++ b/src/main/repository/jopt/jopt-simple/3.2/jopt-simple-3.2.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + jopt + jopt-simple + 3.2 + POM was created from install:install-file + diff --git a/src/main/repository/jopt/jopt-simple/maven-metadata-local.xml b/src/main/repository/jopt/jopt-simple/maven-metadata-local.xml new file mode 100644 index 0000000..5d519df --- /dev/null +++ b/src/main/repository/jopt/jopt-simple/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + jopt + jopt-simple + + 3.2 + + 3.2 + + 20160204075959 + + diff --git a/src/main/repository/json/json-lib/2.4-jdk15/json-lib-2.4-jdk15.jar b/src/main/repository/json/json-lib/2.4-jdk15/json-lib-2.4-jdk15.jar new file mode 100644 index 0000000..68d4f3b Binary files /dev/null and b/src/main/repository/json/json-lib/2.4-jdk15/json-lib-2.4-jdk15.jar differ diff --git a/src/main/repository/json/json-lib/2.4-jdk15/json-lib-2.4-jdk15.pom b/src/main/repository/json/json-lib/2.4-jdk15/json-lib-2.4-jdk15.pom new file mode 100644 index 0000000..e1f3d67 --- /dev/null +++ b/src/main/repository/json/json-lib/2.4-jdk15/json-lib-2.4-jdk15.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + json + json-lib + 2.4-jdk15 + POM was created from install:install-file + diff --git a/src/main/repository/json/json-lib/maven-metadata-local.xml b/src/main/repository/json/json-lib/maven-metadata-local.xml new file mode 100644 index 0000000..458c4c4 --- /dev/null +++ b/src/main/repository/json/json-lib/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + json + json-lib + + 2.4-jdk15 + + 2.4-jdk15 + + 20160204080000 + + diff --git a/src/main/repository/json/json-smart/1.0.8/json-smart-1.0.8.jar b/src/main/repository/json/json-smart/1.0.8/json-smart-1.0.8.jar new file mode 100644 index 0000000..0016ecf Binary files /dev/null and b/src/main/repository/json/json-smart/1.0.8/json-smart-1.0.8.jar differ diff --git a/src/main/repository/json/json-smart/1.0.8/json-smart-1.0.8.pom b/src/main/repository/json/json-smart/1.0.8/json-smart-1.0.8.pom new file mode 100644 index 0000000..d0a6047 --- /dev/null +++ b/src/main/repository/json/json-smart/1.0.8/json-smart-1.0.8.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + json + json-smart + 1.0.8 + POM was created from install:install-file + diff --git a/src/main/repository/json/json-smart/maven-metadata-local.xml b/src/main/repository/json/json-smart/maven-metadata-local.xml new file mode 100644 index 0000000..0f5d4fd --- /dev/null +++ b/src/main/repository/json/json-smart/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + json + json-smart + + 1.0.8 + + 1.0.8 + + 20160204080003 + + diff --git a/src/main/repository/json/org/json.org-ref/2011.06.21/json.org-ref-2011.06.21.jar b/src/main/repository/json/org/json.org-ref/2011.06.21/json.org-ref-2011.06.21.jar new file mode 100644 index 0000000..c8039bf Binary files /dev/null and b/src/main/repository/json/org/json.org-ref/2011.06.21/json.org-ref-2011.06.21.jar differ diff --git a/src/main/repository/json/org/json.org-ref/2011.06.21/json.org-ref-2011.06.21.pom b/src/main/repository/json/org/json.org-ref/2011.06.21/json.org-ref-2011.06.21.pom new file mode 100644 index 0000000..ef8240e --- /dev/null +++ b/src/main/repository/json/org/json.org-ref/2011.06.21/json.org-ref-2011.06.21.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + json.org + json.org-ref + 2011.06.21 + POM was created from install:install-file + diff --git a/src/main/repository/json/org/json.org-ref/maven-metadata-local.xml b/src/main/repository/json/org/json.org-ref/maven-metadata-local.xml new file mode 100644 index 0000000..4933f83 --- /dev/null +++ b/src/main/repository/json/org/json.org-ref/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + json.org + json.org-ref + + 2011.06.21 + + 2011.06.21 + + 20160204075959 + + diff --git a/src/main/repository/minlog/minlog-none/1.2/minlog-none-1.2.jar b/src/main/repository/minlog/minlog-none/1.2/minlog-none-1.2.jar new file mode 100644 index 0000000..50bd8d2 Binary files /dev/null and b/src/main/repository/minlog/minlog-none/1.2/minlog-none-1.2.jar differ diff --git a/src/main/repository/minlog/minlog-none/1.2/minlog-none-1.2.pom b/src/main/repository/minlog/minlog-none/1.2/minlog-none-1.2.pom new file mode 100644 index 0000000..1d0dd0d --- /dev/null +++ b/src/main/repository/minlog/minlog-none/1.2/minlog-none-1.2.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + minlog + minlog-none + 1.2 + POM was created from install:install-file + diff --git a/src/main/repository/minlog/minlog-none/maven-metadata-local.xml b/src/main/repository/minlog/minlog-none/maven-metadata-local.xml new file mode 100644 index 0000000..c8f5077 --- /dev/null +++ b/src/main/repository/minlog/minlog-none/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + minlog + minlog-none + + 1.2 + + 1.2 + + 20160204080005 + + diff --git a/src/main/repository/protobuf/protobuf-java/2.3.0/protobuf-java-2.3.0.jar b/src/main/repository/protobuf/protobuf-java/2.3.0/protobuf-java-2.3.0.jar new file mode 100644 index 0000000..e9a8edd Binary files /dev/null and b/src/main/repository/protobuf/protobuf-java/2.3.0/protobuf-java-2.3.0.jar differ diff --git a/src/main/repository/protobuf/protobuf-java/2.3.0/protobuf-java-2.3.0.pom b/src/main/repository/protobuf/protobuf-java/2.3.0/protobuf-java-2.3.0.pom new file mode 100644 index 0000000..3ff4cfa --- /dev/null +++ b/src/main/repository/protobuf/protobuf-java/2.3.0/protobuf-java-2.3.0.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + protobuf + protobuf-java + 2.3.0 + POM was created from install:install-file + diff --git a/src/main/repository/protobuf/protobuf-java/maven-metadata-local.xml b/src/main/repository/protobuf/protobuf-java/maven-metadata-local.xml new file mode 100644 index 0000000..df5daf2 --- /dev/null +++ b/src/main/repository/protobuf/protobuf-java/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + protobuf + protobuf-java + + 2.3.0 + + 2.3.0 + + 20160204080009 + + diff --git a/src/main/repository/protostuff/protostuff-api/1.0.1/protostuff-api-1.0.1.jar b/src/main/repository/protostuff/protostuff-api/1.0.1/protostuff-api-1.0.1.jar new file mode 100644 index 0000000..e7b1add Binary files /dev/null and b/src/main/repository/protostuff/protostuff-api/1.0.1/protostuff-api-1.0.1.jar differ diff --git a/src/main/repository/protostuff/protostuff-api/1.0.1/protostuff-api-1.0.1.pom b/src/main/repository/protostuff/protostuff-api/1.0.1/protostuff-api-1.0.1.pom new file mode 100644 index 0000000..e552d76 --- /dev/null +++ b/src/main/repository/protostuff/protostuff-api/1.0.1/protostuff-api-1.0.1.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + protostuff + protostuff-api + 1.0.1 + POM was created from install:install-file + diff --git a/src/main/repository/protostuff/protostuff-api/maven-metadata-local.xml b/src/main/repository/protostuff/protostuff-api/maven-metadata-local.xml new file mode 100644 index 0000000..8bc245d --- /dev/null +++ b/src/main/repository/protostuff/protostuff-api/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + protostuff + protostuff-api + + 1.0.1 + + 1.0.1 + + 20160204080008 + + diff --git a/src/main/repository/protostuff/protostuff-collectionschema/1.0.1/protostuff-collectionschema-1.0.1.jar b/src/main/repository/protostuff/protostuff-collectionschema/1.0.1/protostuff-collectionschema-1.0.1.jar new file mode 100644 index 0000000..1db0174 Binary files /dev/null and b/src/main/repository/protostuff/protostuff-collectionschema/1.0.1/protostuff-collectionschema-1.0.1.jar differ diff --git a/src/main/repository/protostuff/protostuff-collectionschema/1.0.1/protostuff-collectionschema-1.0.1.pom b/src/main/repository/protostuff/protostuff-collectionschema/1.0.1/protostuff-collectionschema-1.0.1.pom new file mode 100644 index 0000000..082358f --- /dev/null +++ b/src/main/repository/protostuff/protostuff-collectionschema/1.0.1/protostuff-collectionschema-1.0.1.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + protostuff + protostuff-collectionschema + 1.0.1 + POM was created from install:install-file + diff --git a/src/main/repository/protostuff/protostuff-collectionschema/maven-metadata-local.xml b/src/main/repository/protostuff/protostuff-collectionschema/maven-metadata-local.xml new file mode 100644 index 0000000..34f8232 --- /dev/null +++ b/src/main/repository/protostuff/protostuff-collectionschema/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + protostuff + protostuff-collectionschema + + 1.0.1 + + 1.0.1 + + 20160204080007 + + diff --git a/src/main/repository/protostuff/protostuff-compiler/1.0.1-jarjar/protostuff-compiler-1.0.1-jarjar.jar b/src/main/repository/protostuff/protostuff-compiler/1.0.1-jarjar/protostuff-compiler-1.0.1-jarjar.jar new file mode 100644 index 0000000..7f9ebb9 Binary files /dev/null and b/src/main/repository/protostuff/protostuff-compiler/1.0.1-jarjar/protostuff-compiler-1.0.1-jarjar.jar differ diff --git a/src/main/repository/protostuff/protostuff-compiler/1.0.1-jarjar/protostuff-compiler-1.0.1-jarjar.pom b/src/main/repository/protostuff/protostuff-compiler/1.0.1-jarjar/protostuff-compiler-1.0.1-jarjar.pom new file mode 100644 index 0000000..959ee7e --- /dev/null +++ b/src/main/repository/protostuff/protostuff-compiler/1.0.1-jarjar/protostuff-compiler-1.0.1-jarjar.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + protostuff + protostuff-compiler + 1.0.1-jarjar + POM was created from install:install-file + diff --git a/src/main/repository/protostuff/protostuff-compiler/maven-metadata-local.xml b/src/main/repository/protostuff/protostuff-compiler/maven-metadata-local.xml new file mode 100644 index 0000000..bfd9731 --- /dev/null +++ b/src/main/repository/protostuff/protostuff-compiler/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + protostuff + protostuff-compiler + + 1.0.1-jarjar + + 1.0.1-jarjar + + 20160204080009 + + diff --git a/src/main/repository/protostuff/protostuff-core/1.0.1/protostuff-core-1.0.1.jar b/src/main/repository/protostuff/protostuff-core/1.0.1/protostuff-core-1.0.1.jar new file mode 100644 index 0000000..7eebc4c Binary files /dev/null and b/src/main/repository/protostuff/protostuff-core/1.0.1/protostuff-core-1.0.1.jar differ diff --git a/src/main/repository/protostuff/protostuff-core/1.0.1/protostuff-core-1.0.1.pom b/src/main/repository/protostuff/protostuff-core/1.0.1/protostuff-core-1.0.1.pom new file mode 100644 index 0000000..1543d86 --- /dev/null +++ b/src/main/repository/protostuff/protostuff-core/1.0.1/protostuff-core-1.0.1.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + protostuff + protostuff-core + 1.0.1 + POM was created from install:install-file + diff --git a/src/main/repository/protostuff/protostuff-core/maven-metadata-local.xml b/src/main/repository/protostuff/protostuff-core/maven-metadata-local.xml new file mode 100644 index 0000000..38b85a9 --- /dev/null +++ b/src/main/repository/protostuff/protostuff-core/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + protostuff + protostuff-core + + 1.0.1 + + 1.0.1 + + 20160204080008 + + diff --git a/src/main/repository/protostuff/protostuff-json/1.0.1/protostuff-json-1.0.1.jar b/src/main/repository/protostuff/protostuff-json/1.0.1/protostuff-json-1.0.1.jar new file mode 100644 index 0000000..8e41bd5 Binary files /dev/null and b/src/main/repository/protostuff/protostuff-json/1.0.1/protostuff-json-1.0.1.jar differ diff --git a/src/main/repository/protostuff/protostuff-json/1.0.1/protostuff-json-1.0.1.pom b/src/main/repository/protostuff/protostuff-json/1.0.1/protostuff-json-1.0.1.pom new file mode 100644 index 0000000..9d26b41 --- /dev/null +++ b/src/main/repository/protostuff/protostuff-json/1.0.1/protostuff-json-1.0.1.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + protostuff + protostuff-json + 1.0.1 + POM was created from install:install-file + diff --git a/src/main/repository/protostuff/protostuff-json/maven-metadata-local.xml b/src/main/repository/protostuff/protostuff-json/maven-metadata-local.xml new file mode 100644 index 0000000..aa05097 --- /dev/null +++ b/src/main/repository/protostuff/protostuff-json/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + protostuff + protostuff-json + + 1.0.1 + + 1.0.1 + + 20160204080010 + + diff --git a/src/main/repository/protostuff/protostuff-runtime/1.0.1/protostuff-runtime-1.0.1.jar b/src/main/repository/protostuff/protostuff-runtime/1.0.1/protostuff-runtime-1.0.1.jar new file mode 100644 index 0000000..0a1cdf0 Binary files /dev/null and b/src/main/repository/protostuff/protostuff-runtime/1.0.1/protostuff-runtime-1.0.1.jar differ diff --git a/src/main/repository/protostuff/protostuff-runtime/1.0.1/protostuff-runtime-1.0.1.pom b/src/main/repository/protostuff/protostuff-runtime/1.0.1/protostuff-runtime-1.0.1.pom new file mode 100644 index 0000000..67ee89e --- /dev/null +++ b/src/main/repository/protostuff/protostuff-runtime/1.0.1/protostuff-runtime-1.0.1.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + protostuff + protostuff-runtime + 1.0.1 + POM was created from install:install-file + diff --git a/src/main/repository/protostuff/protostuff-runtime/maven-metadata-local.xml b/src/main/repository/protostuff/protostuff-runtime/maven-metadata-local.xml new file mode 100644 index 0000000..cc048a9 --- /dev/null +++ b/src/main/repository/protostuff/protostuff-runtime/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + protostuff + protostuff-runtime + + 1.0.1 + + 1.0.1 + + 20160204080009 + + diff --git a/src/main/repository/protostuff/protostuff-xml/1.0.1/protostuff-xml-1.0.1.jar b/src/main/repository/protostuff/protostuff-xml/1.0.1/protostuff-xml-1.0.1.jar new file mode 100644 index 0000000..cf7a282 Binary files /dev/null and b/src/main/repository/protostuff/protostuff-xml/1.0.1/protostuff-xml-1.0.1.jar differ diff --git a/src/main/repository/protostuff/protostuff-xml/1.0.1/protostuff-xml-1.0.1.pom b/src/main/repository/protostuff/protostuff-xml/1.0.1/protostuff-xml-1.0.1.pom new file mode 100644 index 0000000..b8b8f5f --- /dev/null +++ b/src/main/repository/protostuff/protostuff-xml/1.0.1/protostuff-xml-1.0.1.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + protostuff + protostuff-xml + 1.0.1 + POM was created from install:install-file + diff --git a/src/main/repository/protostuff/protostuff-xml/maven-metadata-local.xml b/src/main/repository/protostuff/protostuff-xml/maven-metadata-local.xml new file mode 100644 index 0000000..4284406 --- /dev/null +++ b/src/main/repository/protostuff/protostuff-xml/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + protostuff + protostuff-xml + + 1.0.1 + + 1.0.1 + + 20160204080011 + + diff --git a/src/main/repository/scala/scala-xml_2.11/1.0.2/scala-xml_2.11-1.0.2.jar b/src/main/repository/scala/scala-xml_2.11/1.0.2/scala-xml_2.11-1.0.2.jar new file mode 100644 index 0000000..2e9b8df Binary files /dev/null and b/src/main/repository/scala/scala-xml_2.11/1.0.2/scala-xml_2.11-1.0.2.jar differ diff --git a/src/main/repository/scala/scala-xml_2.11/1.0.2/scala-xml_2.11-1.0.2.pom b/src/main/repository/scala/scala-xml_2.11/1.0.2/scala-xml_2.11-1.0.2.pom new file mode 100644 index 0000000..79c3c55 --- /dev/null +++ b/src/main/repository/scala/scala-xml_2.11/1.0.2/scala-xml_2.11-1.0.2.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + scala + scala-xml_2.11 + 1.0.2 + POM was created from install:install-file + diff --git a/src/main/repository/scala/scala-xml_2.11/maven-metadata-local.xml b/src/main/repository/scala/scala-xml_2.11/maven-metadata-local.xml new file mode 100644 index 0000000..f0b84bb --- /dev/null +++ b/src/main/repository/scala/scala-xml_2.11/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + scala + scala-xml_2.11 + + 1.0.2 + + 1.0.2 + + 20160204080011 + + diff --git a/src/main/repository/slf4j/slf4j-api/1.5.10/slf4j-api-1.5.10.jar b/src/main/repository/slf4j/slf4j-api/1.5.10/slf4j-api-1.5.10.jar new file mode 100644 index 0000000..a40adda Binary files /dev/null and b/src/main/repository/slf4j/slf4j-api/1.5.10/slf4j-api-1.5.10.jar differ diff --git a/src/main/repository/slf4j/slf4j-api/1.5.10/slf4j-api-1.5.10.pom b/src/main/repository/slf4j/slf4j-api/1.5.10/slf4j-api-1.5.10.pom new file mode 100644 index 0000000..f1146a4 --- /dev/null +++ b/src/main/repository/slf4j/slf4j-api/1.5.10/slf4j-api-1.5.10.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + slf4j + slf4j-api + 1.5.10 + POM was created from install:install-file + diff --git a/src/main/repository/slf4j/slf4j-api/maven-metadata-local.xml b/src/main/repository/slf4j/slf4j-api/maven-metadata-local.xml new file mode 100644 index 0000000..f5b4de0 --- /dev/null +++ b/src/main/repository/slf4j/slf4j-api/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + slf4j + slf4j-api + + 1.5.10 + + 1.5.10 + + 20160204080012 + + diff --git a/src/main/repository/slf4j/slf4j-nop/1.5.10/slf4j-nop-1.5.10.jar b/src/main/repository/slf4j/slf4j-nop/1.5.10/slf4j-nop-1.5.10.jar new file mode 100644 index 0000000..7779045 Binary files /dev/null and b/src/main/repository/slf4j/slf4j-nop/1.5.10/slf4j-nop-1.5.10.jar differ diff --git a/src/main/repository/slf4j/slf4j-nop/1.5.10/slf4j-nop-1.5.10.pom b/src/main/repository/slf4j/slf4j-nop/1.5.10/slf4j-nop-1.5.10.pom new file mode 100644 index 0000000..f398064 --- /dev/null +++ b/src/main/repository/slf4j/slf4j-nop/1.5.10/slf4j-nop-1.5.10.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + slf4j + slf4j-nop + 1.5.10 + POM was created from install:install-file + diff --git a/src/main/repository/slf4j/slf4j-nop/maven-metadata-local.xml b/src/main/repository/slf4j/slf4j-nop/maven-metadata-local.xml new file mode 100644 index 0000000..1615916 --- /dev/null +++ b/src/main/repository/slf4j/slf4j-nop/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + slf4j + slf4j-nop + + 1.5.10 + + 1.5.10 + + 20160204080012 + + diff --git a/src/main/repository/stax/stax-api/1.0.1/stax-api-1.0.1.jar b/src/main/repository/stax/stax-api/1.0.1/stax-api-1.0.1.jar new file mode 100644 index 0000000..d9a1665 Binary files /dev/null and b/src/main/repository/stax/stax-api/1.0.1/stax-api-1.0.1.jar differ diff --git a/src/main/repository/stax/stax-api/1.0.1/stax-api-1.0.1.pom b/src/main/repository/stax/stax-api/1.0.1/stax-api-1.0.1.pom new file mode 100644 index 0000000..db016e8 --- /dev/null +++ b/src/main/repository/stax/stax-api/1.0.1/stax-api-1.0.1.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + stax + stax-api + 1.0.1 + POM was created from install:install-file + diff --git a/src/main/repository/stax/stax-api/maven-metadata-local.xml b/src/main/repository/stax/stax-api/maven-metadata-local.xml new file mode 100644 index 0000000..8aecf71 --- /dev/null +++ b/src/main/repository/stax/stax-api/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + stax + stax-api + + 1.0.1 + + 1.0.1 + + 20160204080012 + + diff --git a/src/main/repository/stax2/stax2-api/3.0.1/stax2-api-3.0.1.jar b/src/main/repository/stax2/stax2-api/3.0.1/stax2-api-3.0.1.jar new file mode 100644 index 0000000..08f2cc4 Binary files /dev/null and b/src/main/repository/stax2/stax2-api/3.0.1/stax2-api-3.0.1.jar differ diff --git a/src/main/repository/stax2/stax2-api/3.0.1/stax2-api-3.0.1.pom b/src/main/repository/stax2/stax2-api/3.0.1/stax2-api-3.0.1.pom new file mode 100644 index 0000000..f7d2207 --- /dev/null +++ b/src/main/repository/stax2/stax2-api/3.0.1/stax2-api-3.0.1.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + stax2 + stax2-api + 3.0.1 + POM was created from install:install-file + diff --git a/src/main/repository/stax2/stax2-api/maven-metadata-local.xml b/src/main/repository/stax2/stax2-api/maven-metadata-local.xml new file mode 100644 index 0000000..7167ca1 --- /dev/null +++ b/src/main/repository/stax2/stax2-api/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + stax2 + stax2-api + + 3.0.1 + + 3.0.1 + + 20160204080013 + + diff --git a/src/main/repository/wobly/wobly-core/1.0/wobly-core-1.0.jar b/src/main/repository/wobly/wobly-core/1.0/wobly-core-1.0.jar new file mode 100644 index 0000000..7ede5f7 Binary files /dev/null and b/src/main/repository/wobly/wobly-core/1.0/wobly-core-1.0.jar differ diff --git a/src/main/repository/wobly/wobly-core/1.0/wobly-core-1.0.pom b/src/main/repository/wobly/wobly-core/1.0/wobly-core-1.0.pom new file mode 100644 index 0000000..2173bfc --- /dev/null +++ b/src/main/repository/wobly/wobly-core/1.0/wobly-core-1.0.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + wobly + wobly-core + 1.0 + POM was created from install:install-file + diff --git a/src/main/repository/wobly/wobly-core/maven-metadata-local.xml b/src/main/repository/wobly/wobly-core/maven-metadata-local.xml new file mode 100644 index 0000000..80f585e --- /dev/null +++ b/src/main/repository/wobly/wobly-core/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + wobly + wobly-core + + 1.0 + + 1.0 + + 20160204080014 + + diff --git a/src/main/repository/woodstox-core/woodstox-core-asl/4.0.7/woodstox-core-asl-4.0.7.jar b/src/main/repository/woodstox-core/woodstox-core-asl/4.0.7/woodstox-core-asl-4.0.7.jar new file mode 100644 index 0000000..b49b90e Binary files /dev/null and b/src/main/repository/woodstox-core/woodstox-core-asl/4.0.7/woodstox-core-asl-4.0.7.jar differ diff --git a/src/main/repository/woodstox-core/woodstox-core-asl/4.0.7/woodstox-core-asl-4.0.7.pom b/src/main/repository/woodstox-core/woodstox-core-asl/4.0.7/woodstox-core-asl-4.0.7.pom new file mode 100644 index 0000000..5a18ffd --- /dev/null +++ b/src/main/repository/woodstox-core/woodstox-core-asl/4.0.7/woodstox-core-asl-4.0.7.pom @@ -0,0 +1,9 @@ + + + 4.0.0 + woodstox-core + woodstox-core-asl + 4.0.7 + POM was created from install:install-file + diff --git a/src/main/repository/woodstox-core/woodstox-core-asl/maven-metadata-local.xml b/src/main/repository/woodstox-core/woodstox-core-asl/maven-metadata-local.xml new file mode 100644 index 0000000..acc4182 --- /dev/null +++ b/src/main/repository/woodstox-core/woodstox-core-asl/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + woodstox-core + woodstox-core-asl + + 4.0.7 + + 4.0.7 + + 20160204080014 + + diff --git a/tpc/src/serializers/SerGraph.java b/tpc/src/serializers/SerGraph.java index 0cb0a65..dfe2a8d 100644 --- a/tpc/src/serializers/SerGraph.java +++ b/tpc/src/serializers/SerGraph.java @@ -31,5 +31,5 @@ public enum SerGraph { * capable of read/write fully linked object graphs with reference restauration */ FULL_GRAPH, - UNKNOWN + UNKNOWN } diff --git a/tpc/support/intellij/Main.iml b/tpc/support/intellij/Main.iml deleted file mode 100644 index a0e5316..0000000 --- a/tpc/support/intellij/Main.iml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - -