comparison artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultArtifactSerializer.java @ 87:0f48188a6e02

Added some javadoc to the artifactdatabase module. Not done yet. artifacts/trunk@839 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Fri, 26 Mar 2010 11:40:28 +0000
parents 48d1a9a082c2
children e27cf9c84eb8
comparison
equal deleted inserted replaced
86:b2e0cb83631c 87:0f48188a6e02
15 import java.util.zip.GZIPInputStream; 15 import java.util.zip.GZIPInputStream;
16 16
17 import org.apache.log4j.Logger; 17 import org.apache.log4j.Logger;
18 18
19 /** 19 /**
20 * Default implementation of the ArtifactSerializer interface.
21 * It uses serialized Java objects which are gzipped and
22 * turned into bytes.
23 *
20 * @author <a href="mailto:sascha.teichmann@intevation.de">Sascha L. Teichmann</a> 24 * @author <a href="mailto:sascha.teichmann@intevation.de">Sascha L. Teichmann</a>
21 */ 25 */
22 public class DefaultArtifactSerializer 26 public class DefaultArtifactSerializer
23 implements ArtifactSerializer 27 implements ArtifactSerializer
24 { 28 {
25 private static Logger logger = 29 private static Logger logger =
26 Logger.getLogger(DefaultArtifactSerializer.class); 30 Logger.getLogger(DefaultArtifactSerializer.class);
27 31
32 /**
33 * Static instance to avoid repeated creation of Serializers.
34 */
28 public static final ArtifactSerializer INSTANCE = 35 public static final ArtifactSerializer INSTANCE =
29 new DefaultArtifactSerializer(); 36 new DefaultArtifactSerializer();
30 37
38 /**
39 * Default constructor.
40 */
31 public DefaultArtifactSerializer() { 41 public DefaultArtifactSerializer() {
32 } 42 }
33 43
34 public Artifact fromBytes(byte [] bytes) { 44 public Artifact fromBytes(byte [] bytes) {
35 45
81 logger.error(ioe.getLocalizedMessage(), ioe); 91 logger.error(ioe.getLocalizedMessage(), ioe);
82 throw new RuntimeException(ioe); 92 throw new RuntimeException(ioe);
83 } 93 }
84 } 94 }
85 95
96 /**
97 * Wraps an input stream into an object input stream. You may
98 * overwrite this to get a more specialized deserializer.
99 * @param is The raw input stream
100 * @return An instance of a subclass of ObjectInputStream.
101 * @throws IOException Thrown if something went wrong during
102 * creation of the object input stream.
103 */
86 protected ObjectInputStream getObjectInputStream(InputStream is) 104 protected ObjectInputStream getObjectInputStream(InputStream is)
87 throws IOException 105 throws IOException
88 { 106 {
89 return new ObjectInputStream(is); 107 return new ObjectInputStream(is);
90 } 108 }
91 109
110 /**
111 * Wraps an output stream into an object output stream. You may
112 * overwrite this to get a more specialized serializer.
113 * @param os the raw output stream.
114 * @return An instance of a subclass of ObjectOutputStream.
115 * @throws IOException Thrown if something went wrong during
116 * creation of the object output stream.
117 */
92 protected ObjectOutputStream getObjectOutputStream(OutputStream os) 118 protected ObjectOutputStream getObjectOutputStream(OutputStream os)
93 throws IOException 119 throws IOException
94 { 120 {
95 return new ObjectOutputStream(os); 121 return new ObjectOutputStream(os);
96 } 122 }
97 } 123 }
98 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8: 124 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org