This is an automated email from the ASF dual-hosted git repository. andy pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/jena.git
commit dbabe19f0457735af57996330b689c89d8f510e1 Author: Andy Seaborne <[email protected]> AuthorDate: Mon Nov 10 17:10:34 2025 +0000 GH-3580: Deprecated Model.writer(Writer) and Model.write(OutputStream) --- .../java/org/apache/jena/ontology/OntModel.java | 34 ------------------- .../apache/jena/ontology/impl/OntModelImpl.java | 4 --- .../main/java/org/apache/jena/rdf/model/Model.java | 30 ++++++----------- .../org/apache/jena/rdf/model/impl/ModelCom.java | 13 -------- .../apache/jena/ontology/impl/TestOntModel.java | 6 ++-- .../apache/jena/ontapi/impl/OntGraphModelImpl.java | 13 -------- .../java/org/apache/jena/ontapi/model/IOModel.java | 39 ---------------------- 7 files changed, 13 insertions(+), 126 deletions(-) diff --git a/jena-core/src/main/java/org/apache/jena/ontology/OntModel.java b/jena-core/src/main/java/org/apache/jena/ontology/OntModel.java index dc9129c7c2..914f8e8927 100644 --- a/jena-core/src/main/java/org/apache/jena/ontology/OntModel.java +++ b/jena-core/src/main/java/org/apache/jena/ontology/OntModel.java @@ -124,7 +124,6 @@ public interface OntModel */ public ExtendedIterator<OntProperty> listOntProperties(); - /** * <p>Answer an iterator over all of the ontology properties in this model, including * object properties, datatype properties, annotation properties, etc. This method @@ -1503,22 +1502,6 @@ public interface OntModel // output operations - /** - * <p>Write the model as an XML document. - * It is often better to use an OutputStream rather than a Writer, since this - * will avoid character encoding errors. - * <strong>Note:</strong> This method is adapted for the ontology - * model to write out only the base model (which contains the asserted data). To write - * all triples, including imported data and inferred triples, use - * {@link #writeAll( Writer, String, String ) writeAll }. - * </p> - * - * @param writer A writer to which the XML will be written - * @return this model - */ - @Override - public Model write( Writer writer ) ; - /** * <p>Write a serialized representation of a model in a specified language. * It is often better to use an OutputStream rather than a Writer, since this @@ -1561,23 +1544,6 @@ public interface OntModel @Override public Model write( Writer writer, String lang, String base ); - /** - * <p>Write a serialization of this model as an XML document. - * <strong>Note:</strong> This method is adapted for the ontology - * model to write out only the base model (which contains the asserted data). To write - * all triples, including imported data and inferred triples, use - * {@link #writeAll( OutputStream, String, String ) writeAll }. - * </p> - * <p>The language in which to write the model is specified by the - * <code>lang</code> argument. Predefined values are "RDF/XML", - * "RDF/XML-ABBREV", "N-TRIPLE" and "TURTLE". The default value is - * represented by <code>null</code> is "RDF/XML".</p> - * @param out The output stream to which the XML will be written - * @return This model - */ - @Override - public Model write( OutputStream out ); - /** * <p>Write a serialized representation of this model in a specified language. * <strong>Note:</strong> This method is adapted for the ontology diff --git a/jena-core/src/main/java/org/apache/jena/ontology/impl/OntModelImpl.java b/jena-core/src/main/java/org/apache/jena/ontology/impl/OntModelImpl.java index 1f0fee6d2f..9376937cf9 100644 --- a/jena-core/src/main/java/org/apache/jena/ontology/impl/OntModelImpl.java +++ b/jena-core/src/main/java/org/apache/jena/ontology/impl/OntModelImpl.java @@ -2586,15 +2586,11 @@ public class OntModelImpl extends ModelCom implements OntModel // output operations - delegate to base model - @Override - public Model write( Writer writer ) { return getBaseModel().write( writer, "RDF/XML" ); } @Override public Model write( Writer writer, String lang ) { return getBaseModel().write( writer, lang ); } @Override public Model write( Writer writer, String lang, String base ) { return getBaseModel().write( writer, lang, base ); } @Override - public Model write( OutputStream out ) { return getBaseModel().write( out , "RDF/XML"); } - @Override public Model write( OutputStream out, String lang ) { return getBaseModel().write( out, lang ); } @Override public Model write( OutputStream out, String lang, String base) { return getBaseModel().write( out, lang, base ); } diff --git a/jena-core/src/main/java/org/apache/jena/rdf/model/Model.java b/jena-core/src/main/java/org/apache/jena/rdf/model/Model.java index 898c14d341..aaa026f7d5 100644 --- a/jena-core/src/main/java/org/apache/jena/rdf/model/Model.java +++ b/jena-core/src/main/java/org/apache/jena/rdf/model/Model.java @@ -547,18 +547,12 @@ public interface Model // output operations /** - * <p>Write the model as an XML document. - * It is often better to use an OutputStream rather than a Writer, since this - * will avoid character encoding errors. - * </p> - * - * @param writer A writer to which the XML will be written - * @return this model - * @deprecated Prefer {@link #write(OutputStream, String)} and specify the language. + * <p>Write a serialization of this model as an XML document.s</p> + * @deprecated Use {@code write(Writer, "RDF/XML")} */ - @Deprecated - public Model write( Writer writer ) ; - + @Deprecated(forRemoval = true) + public default Model write(Writer writer) { return write(writer, "RDF/XML"); } + /** * <p>Write a serialized representation of a model in a specified language. * It is often better to use an OutputStream rather than a Writer, since this @@ -593,16 +587,12 @@ public interface Model /** - * <p>Write a serialization of this model as an XML document. - * </p> - * <p>The language in which to write the model is specified by the - * <code>lang</code> argument. Predefined values are "RDF/XML", - * "RDF/XML-ABBREV", "N-TRIPLE" and "N3". The default value is - * represented by <code>null</code> is "RDF/XML".</p> - * @param out The output stream to which the XML will be written - * @return This model + * <p>Write a serialization of this model as an XML document.s</p> + * @deprecated Use {@code write(OutputStream, "RDF/XML")} */ - public Model write(OutputStream out) ; + @Deprecated(forRemoval = true) + + public default Model write(OutputStream out) { return write(out, "RDF/XML"); } /** * <p>Write a serialized representation of this model in a specified language. diff --git a/jena-core/src/main/java/org/apache/jena/rdf/model/impl/ModelCom.java b/jena-core/src/main/java/org/apache/jena/rdf/model/impl/ModelCom.java index e83f47b8f3..bd1eae67fe 100644 --- a/jena-core/src/main/java/org/apache/jena/rdf/model/impl/ModelCom.java +++ b/jena-core/src/main/java/org/apache/jena/rdf/model/impl/ModelCom.java @@ -235,13 +235,6 @@ public class ModelCom extends EnhGraph implements Model, PrefixMapping, Lock return writerFactory.getWriter(lang); } - @SuppressWarnings("deprecation") - @Override - public Model write(Writer writer) { - getWriter(null).write(this, writer, ""); - return this; - } - @Override public Model write(Writer writer, String lang) { getWriter(lang).write(this, writer, ""); @@ -254,12 +247,6 @@ public class ModelCom extends EnhGraph implements Model, PrefixMapping, Lock return this; } - @Override - public Model write(OutputStream writer) { - getWriter(null).write(this, writer, ""); - return this; - } - @Override public Model write(OutputStream writer, String lang) { getWriter(lang).write(this, writer, ""); diff --git a/jena-core/src/test/java/org/apache/jena/ontology/impl/TestOntModel.java b/jena-core/src/test/java/org/apache/jena/ontology/impl/TestOntModel.java index ca7bcb3006..f7eadcde19 100644 --- a/jena-core/src/test/java/org/apache/jena/ontology/impl/TestOntModel.java +++ b/jena-core/src/test/java/org/apache/jena/ontology/impl/TestOntModel.java @@ -147,7 +147,7 @@ public class TestOntModel // write to a stream ByteArrayOutputStream out = new ByteArrayOutputStream(); - m.write( out ); + m.write( out, "RDF/XML" ); String s = out.toString(); ByteArrayInputStream in = new ByteArrayInputStream( s.getBytes() ); @@ -192,7 +192,7 @@ public class TestOntModel om.add( statement( om, "ping http://spoo.spoo.com/spoo#pang pilly" ) ); om.add( statement( om, "gg " + OWL.getURI() + "hh ii" ) ); StringWriter sw = new StringWriter(); - om.write( sw ); + om.write( sw , "RDF/XML"); String s = sw.getBuffer().toString(); assertTrue( s.indexOf( "xmlns:spoo=\"http://spoo.spoo.com/spoo#\"" ) > 0 ); assertTrue( s.indexOf( "xmlns:owl=\"" + OWL.getURI() + "\"" ) > 0 ); @@ -220,7 +220,7 @@ public class TestOntModel // write to a stream StringWriter out = new StringWriter(); - m.write( out ); + m.write( out, "RDF/XML"); String s = out.toString(); diff --git a/jena-ontapi/src/main/java/org/apache/jena/ontapi/impl/OntGraphModelImpl.java b/jena-ontapi/src/main/java/org/apache/jena/ontapi/impl/OntGraphModelImpl.java index c5cd5892be..1566edffbe 100644 --- a/jena-ontapi/src/main/java/org/apache/jena/ontapi/impl/OntGraphModelImpl.java +++ b/jena-ontapi/src/main/java/org/apache/jena/ontapi/impl/OntGraphModelImpl.java @@ -1535,13 +1535,6 @@ public class OntGraphModelImpl extends ModelCom implements OntModel, OntEnhGraph return this; } - @SuppressWarnings("deprecation") - @Override - public OntGraphModelImpl write(Writer writer) { - getBaseModel().write(writer); - return this; - } - @Override public OntGraphModelImpl write(Writer writer, String lang) { getBaseModel().write(writer, lang); @@ -1554,12 +1547,6 @@ public class OntGraphModelImpl extends ModelCom implements OntModel, OntEnhGraph return this; } - @Override - public OntGraphModelImpl write(OutputStream out) { - getBaseModel().write(out); - return this; - } - @Override public OntGraphModelImpl write(OutputStream out, String lang) { getBaseModel().write(out, lang); diff --git a/jena-ontapi/src/main/java/org/apache/jena/ontapi/model/IOModel.java b/jena-ontapi/src/main/java/org/apache/jena/ontapi/model/IOModel.java index 2033601bf7..5a648c1576 100644 --- a/jena-ontapi/src/main/java/org/apache/jena/ontapi/model/IOModel.java +++ b/jena-ontapi/src/main/java/org/apache/jena/ontapi/model/IOModel.java @@ -55,27 +55,6 @@ interface IOModel<R extends Model> extends Model { @Override R read(String url, String base, String lang); - /** - * Writes a serialized representation of a model in a specified language. - * <strong>Note(1):</strong> this method is adapted for the ontology - * model to write out only the base model (which contains the asserted data). - * To write all triples, including imported data and inferred triples, use - * {@link #writeAll(Writer, String, String) writeAll }. - * <strong>Note(2):</strong> it is often better to use an {@code OutputStream} rather than a {@code Writer}, - * since this will avoid character encoding errors. - * <p> - * The language in which to write the model is specified by the {@code lang} argument. - * Some of the supported formats are "RDF/XML", "RDF/XML-ABBREV", "N-TRIPLE", "TURTLE". - * See {@link org.apache.jena.riot.Lang Lang} for all supported formats. - * The default value, represented by {@code null}, is "RDF/XML". - * - * @param writer the output writer - * @return this model - */ - @Deprecated - @Override - R write(Writer writer); - /** * Writes a serialized representation of a model in a specified language. * <strong>Note(1):</strong> this method is adapted for the ontology @@ -120,24 +99,6 @@ interface IOModel<R extends Model> extends Model { @Override R write(Writer writer, String lang, String base); - /** - * Writes a serialized representation of a model in a specified language. - * <strong>Note:</strong> this method is adapted for the ontology - * model to write out only the base model (which contains the asserted data). - * To write all triples, including imported data and inferred triples, use - * {@link #writeAll(OutputStream, String, String) writeAll }. - * <p> - * The language in which to write the model is specified by the {@code lang} argument. - * Some of the supported formats are "RDF/XML", "RDF/XML-ABBREV", "N-TRIPLE", "TURTLE". - * See {@link org.apache.jena.riot.Lang Lang} for all supported formats. - * The default value, represented by {@code null}, is "RDF/XML". - * - * @param out tre output stream to which the RDF is written - * @return this model - */ - @Override - R write(OutputStream out); - /** * Writes a serialized representation of a model in a specified language. * <strong>Note:</strong> this method is adapted for the ontology
