001: /*
002: * LICENSE INFORMATION
003: * Copyright 2005-2007 by FZI (http://www.fzi.de).
004: * Licensed under a BSD license (http://www.opensource.org/licenses/bsd-license.php)
005: * <OWNER> = Max Völkel
006: * <ORGANIZATION> = FZI Forschungszentrum Informatik Karlsruhe, Karlsruhe, Germany
007: * <YEAR> = 2007
008: *
009: * Project information at http://semweb4j.org/rdf2go
010: */
011: package org.ontoware.rdf2go.model;
012:
013: import java.io.IOException;
014: import java.io.InputStream;
015: import java.io.OutputStream;
016: import java.io.Reader;
017: import java.io.Writer;
018: import java.net.URL;
019:
020: import org.ontoware.rdf2go.exception.ModelRuntimeException;
021: import org.ontoware.rdf2go.exception.SyntaxNotSupportedException;
022:
023: /**
024: * Defines reading and writing to and from readers/writers and streams.
025: *
026: * The default syntax for ModelSets is TRiX.
027: *
028: * @author voelkel
029: *
030: */
031: public interface ModelSetIO {
032:
033: // ///////////////////////////////
034: // read/write
035:
036: /**
037: * Read from Reader assuming to read a TRiX stream in UTF8 encoding.
038: *
039: * All Models are created with the corresponding names as defined in the
040: * TRiX stream as needed.
041: *
042: * For more info on TRiX read:
043: * http://www.hpl.hp.com/techreports/2003/HPL-2003-268.html
044: *
045: * @param in
046: * the input to read
047: * @throws IOException
048: * on IOErrors
049: * @throws ModelRuntimeException
050: * on RDF serialization errors or model errors
051: */
052: void readFrom(Reader in) throws IOException, ModelRuntimeException;
053:
054: /**
055: * Reads assuming the given syntax. Encoding defaults to UTF8.
056: *
057: * All Models are created with the corresponding names as defined in the
058: * TRiX stream as needed.
059: *
060: * @param in
061: * the input to read
062: * @param syntax
063: * syntax to use
064: * @throws IOException
065: * on IOErrors
066: * @throws ModelRuntimeException
067: * on RDF serialisation errors or model errors
068: * @throws SyntaxNotSupportedException
069: * if adapter can't handle the given syntax
070: */
071: void readFrom(Reader in, Syntax syntax) throws IOException,
072: ModelRuntimeException, SyntaxNotSupportedException;
073:
074: /**
075: * Reads assuming the given syntax. Encoding defaults to UTF8.
076: *
077: * All Models are created with the corresponding names as defined in the
078: * TRiX stream as needed.
079: *
080: * @param in
081: * the input to read
082: * @param syntax
083: * syntax to use
084: * @param baseURI
085: * baseURI to use
086: * @throws IOException
087: * on IOErrors
088: * @throws ModelRuntimeException
089: * on RDF serialisation errors or model errors
090: * @throws SyntaxNotSupportedException
091: * if adapter can't handle the given syntax
092: */
093: void readFrom(Reader in, Syntax syntax, URL baseURI)
094: throws IOException, ModelRuntimeException,
095: SyntaxNotSupportedException;
096:
097: /**
098: * Read from InputStream assuming to read an RDF/XML stream.
099: *
100: * All Models are created with the corresponding names as defined in the
101: * TRiX stream as needed.
102: *
103: * For more info on TRiX read:
104: * http://www.hpl.hp.com/techreports/2003/HPL-2003-268.html
105: *
106: * @param in
107: * the input to read
108: * @throws IOException
109: * on IOErrors
110: * @throws ModelRuntimeException
111: * on RDF serialisation errors or model errors
112: */
113: void readFrom(InputStream in) throws IOException,
114: ModelRuntimeException;
115:
116: /**
117: * Reads assuming the given syntax. Encoding defaults to UTF8.
118: *
119: * All Models are created with the corresponding names as defined in the
120: * TRiX stream as needed.
121: *
122: * @param in
123: * the input to read
124: * @param syntax
125: * syntax to use
126: * @throws IOException
127: * on IOErrors
128: * @throws ModelRuntimeException
129: * on RDF serialisation errors or model errors
130: * @throws SyntaxNotSupportedException
131: * if adapter can't handle the given syntax
132: */
133: void readFrom(InputStream reader, Syntax syntax)
134: throws IOException, ModelRuntimeException,
135: SyntaxNotSupportedException;
136:
137: /**
138: * Reads assuming the given syntax. Encoding defaults to UTF8.
139: *
140: * All Models are created with the corresponding names as defined in the
141: * TRiX stream as needed.
142: *
143: * @param in
144: * the input to read
145: * @param syntax
146: * syntax to use
147: * @param baseURI
148: * base URI to use
149: * @throws IOException
150: * on IOErrors
151: * @throws ModelRuntimeException
152: * on RDF serialisation errors or model errors
153: * @throws SyntaxNotSupportedException
154: * if adapter can't handle the given syntax
155: */
156: void readFrom(InputStream reader, Syntax syntax, URL baseURI)
157: throws IOException, ModelRuntimeException,
158: SyntaxNotSupportedException;
159:
160: /**
161: * Write to writer in UTF8 and TRiX. For more info on TRiX read:
162: * http://www.hpl.hp.com/techreports/2003/HPL-2003-268.html
163: *
164: * @param out
165: * the output to write to
166: * @throws IOException
167: * on IOErrors
168: * @throws ModelRuntimeException
169: * on RDF serialization errors or model errors
170: */
171: void writeTo(Writer out) throws IOException, ModelRuntimeException;
172:
173: /**
174: * Write the model to the passed writer, using the passed syntax.
175: *
176: * @param out
177: * the output to write to
178: * @param syntax
179: * syntax to use
180: * @throws IOException
181: * on IOErrors
182: * @throws ModelRuntimeException
183: * on RDF serialization errors or model errors
184: * @throws SyntaxNotSupportedException
185: * if adapter can't handle the given syntax
186: */
187: void writeTo(Writer out, Syntax syntax) throws IOException,
188: ModelRuntimeException, SyntaxNotSupportedException;
189:
190: /**
191: * Writing a TRiX stream in UTF8 encoding For more info on TRiX read:
192: * http://www.hpl.hp.com/techreports/2003/HPL-2003-268.html
193: *
194: * @param out
195: * the output to write to
196: * @throws IOException
197: * on IOErrors
198: * @throws ModelRuntimeException
199: * on RDF serialization errors or model errors
200: */
201: void writeTo(OutputStream out) throws IOException,
202: ModelRuntimeException;
203:
204: /**
205: * Write the model to the passed writer, using the passed syntax.
206: *
207: * @param out
208: * the output to write to
209: * @param syntax
210: * syntax to use
211: * @throws IOException
212: * on IOErrors
213: * @throws ModelRuntimeException
214: * on RDF serialization errors or model errors
215: * @throws SyntaxNotSupportedException
216: * if adapter can't handle the given syntax
217: */
218: void writeTo(OutputStream out, Syntax syntax) throws IOException,
219: ModelRuntimeException, SyntaxNotSupportedException;
220:
221: /**
222: * Convenience method to export a ModelSet to a String in a given syntax.
223: * @param syntax
224: * @return a String, containing the ModelSet content in the given syntax.
225: * @throws SyntaxNotSupportedException if the syntax is not supported
226: */
227: String serialize(Syntax syntax) throws SyntaxNotSupportedException;
228: }
|