001: package org.ontoware.rdf2go.model;
002:
003: import java.io.IOException;
004: import java.io.InputStream;
005: import java.io.OutputStream;
006: import java.io.Reader;
007: import java.io.Writer;
008: import java.net.URL;
009:
010: import org.ontoware.rdf2go.exception.ModelRuntimeException;
011: import org.ontoware.rdf2go.exception.SyntaxNotSupportedException;
012:
013: public interface ModelIO {
014:
015: // /////////////////
016: // IO
017:
018: /**
019: * Read from Reader assuming in UTF8 encoding. Models are read with a
020: * default syntax of RDF/XML
021: *
022: * @param in
023: * the input to read
024: * @throws IOException
025: * on IOErrors
026: * @throws ModelRuntimeException
027: * on RDF serialization errors or model errors
028: */
029: void readFrom(Reader in) throws IOException, ModelRuntimeException;
030:
031: /**
032: * Reads assuming the given syntax. Encoding defaults to UTF8. When reading
033: * TRiX into a Model, the context URI is ignored.
034: *
035: * @param in
036: * the input to read
037: * @param syntax
038: * syntax to use
039: * @throws IOException
040: * on IOErrors
041: * @throws ModelRuntimeException
042: * on RDF serialization errors or model errors
043: */
044: void readFrom(Reader in, Syntax syntax) throws IOException,
045: ModelRuntimeException;
046:
047: /**
048: * FIXME comment
049: * @param in
050: * @param syntax
051: * @param baseURI
052: * @throws IOException
053: * @throws ModelRuntimeException
054: */
055: void readFrom(Reader in, Syntax syntax, URL baseURI)
056: throws IOException, ModelRuntimeException;
057:
058: /**
059: * Read from InputStream assuming to read an RDF/XML stream.
060: *
061: * @param in
062: * the input to read
063: * @throws IOException
064: * on IOErrors
065: * @throws ModelRuntimeException
066: * on RDF serialization errors or model errors
067: */
068: void readFrom(InputStream in) throws IOException,
069: ModelRuntimeException;
070:
071: /**
072: * Reads assuming the given syntax. Encoding defaults to UTF8.
073: *
074: * @param in
075: * the input to read
076: * @param syntax
077: * syntax to use
078: * @throws IOException
079: * on IOErrors
080: * @throws ModelRuntimeException
081: * on RDF serialization errors or model errors
082: */
083: void readFrom(InputStream reader, Syntax syntax)
084: throws IOException, ModelRuntimeException;
085:
086: /**
087: * FIXME comment
088: * @param reader
089: * @param syntax
090: * @param baseURI
091: * @throws IOException
092: * @throws ModelRuntimeException
093: */
094: void readFrom(InputStream reader, Syntax syntax, URL baseURI)
095: throws IOException, ModelRuntimeException;
096:
097: /**
098: * Writing an RDF/XML stream in UTF8 encoding
099: *
100: * @param out
101: * the output to write to
102: * @throws IOException
103: * on IOErrors
104: * @throws ModelRuntimeException
105: * on RDF serialization errors or model errors
106: */
107: void writeTo(Writer out) throws IOException, ModelRuntimeException;
108:
109: /**
110: * Write the model to the passed writer, using the passed syntax.
111: *
112: * @param out
113: * the output to write to
114: * @param syntax
115: * syntax to use
116: * @throws IOException
117: * on IOErrors
118: * @throws ModelRuntimeException
119: * on RDF serialization errors or model errors
120: */
121: void writeTo(Writer out, Syntax syntax) throws IOException,
122: ModelRuntimeException;
123:
124: /**
125: * Writing an RDF/XML stream in UTF8 encoding
126: *
127: * @param out
128: * the output to write to
129: * @throws IOException
130: * on IOErrors
131: * @throws ModelRuntimeException
132: * on RDF serialization errors or model errors
133: */
134: void writeTo(OutputStream out) throws IOException,
135: ModelRuntimeException;
136:
137: /**
138: * Write the model to the passed writer, using the passed syntax.
139: *
140: * @param out
141: * the output to write to
142: * @param syntax
143: * syntax to use
144: * @throws IOException
145: * on IOErrors
146: * @throws ModelRuntimeException
147: * on RDF serialization errors or model errors
148: */
149: void writeTo(OutputStream out, Syntax syntax) throws IOException,
150: ModelRuntimeException;
151:
152: /**
153: * Convenience method to export a Model to a String in a given syntax.
154: *
155: * @param syntax
156: * @return a String, containing the Model content in the given syntax.
157: * @throws SyntaxNotSupportedException
158: * if the syntax is not supported
159: */
160: String serialize(Syntax syntax) throws SyntaxNotSupportedException;
161:
162: }
|