KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > snipsnap > serialization > SerializerFactory


1 package org.snipsnap.serialization;
2
3 import org.snipsnap.serialization.rdf.RDFSerializer;
4 import org.snipsnap.serialization.rdf.DAMLSerializer;
5
6 public class SerializerFactory {
7
8   private SerializerFactory() {
9   }
10
11   // constants:
12
public final static int RDF_10 = 1;
13   public final static int DAML_OIL = 2;
14
15   public static Serializer createSerializer(int outputFormat) throws UnknownFormatException {
16     Serializer ser = null;
17     switch (outputFormat) {
18       case RDF_10:
19         ser = new RDFSerializer(outputFormat);
20         break;
21       case DAML_OIL:
22         ser = new DAMLSerializer(outputFormat);
23         break;
24       default:
25         String JavaDoc msg = "Sorry, no Serializer available for the given output format: " + outputFormat;
26         throw new UnknownFormatException(msg);
27     }
28     return ser;
29   }
30 }
31
Popular Tags