My favorites | Sign in
Project Home Wiki Issues Source
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package serializers;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

import serializers.scala.Image;
import serializers.scala.Media;
import serializers.scala.MediaContent;
import serializers.scala.Player;
import serializers.scala.Size;



public class ScalaSerializer implements ObjectSerializer<MediaContent>
{
public int expectedSize = 0;

public MediaContent deserialize (byte[] array) throws Exception
{
ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(array));
try
{
return (MediaContent)ois.readObject();
}
finally
{
ois.close();
}
}

public byte[] serialize(MediaContent content) throws IOException, Exception
{
ByteArrayOutputStream baos = new ByteArrayOutputStream(expectedSize);
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(content);
oos.close();
byte[] array = baos.toByteArray();
expectedSize = array.length;
return array;
}

public MediaContent create()
{
Media media = new Media("http://javaone.com/keynote.mpg", "Javaone Keynote", 0, 0, "video/mpg4", 1234567, 123, 0, Player.JAVA());
media.addPerson("Bill Gates");
media.addPerson("Steve Jobs");

Image image1 = new Image("http://javaone.com/keynote_large.jpg", "Javaone Keynote", 0, 0, Size.LARGE());

Image image2 = new Image("http://javaone.com/keynote_thumbnail.jpg", "Javaone Keynote", 0, 0, Size.SMALL());

MediaContent content = new MediaContent(media);
content.addImage(image1);
content.addImage(image2);

return content;
}

public String getName ()
{
return "scala";
}
}

Change log

r126 by bl...@orcaware.com on Jan 24, 2010   Diff
Use svn_apply_autoprops to apply a
standard set of Subversion properties to
all files.  The 'svn:eol-style' is set to
'native' and 'svn:keywords' is set
to 'HeadURL Id LastChangedBy
LastChangedDate LastChangedRevision'.
Go to: 

Older revisions

r87 by nathan.sweet on Oct 4, 2009   Diff
Updated data to match other tests.
r48 by eishay on Mar 26, 2009   Diff
try to make the benchmark more fair by
letting the serializer create its own
streams
r31 by tsaloranta on Mar 20, 2009   Diff
Minor general optimization, will now
reuse ByteArrayOutputStream (to reduce
unnecessary overhead). Also added
Aalto XML/Stax parser.

All revisions of this file

File info

Size: 1755 bytes, 66 lines

File properties

svn:eol-style
native
svn:keywords
HeadURL Id LastChangedBy LastChangedD...Revision
Powered by Google Project Hosting