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 6ff87850a3aa4fb7b9ec76918e240acdead11e41 Author: Andy Seaborne <[email protected]> AuthorDate: Mon Nov 10 12:01:15 2025 +0000 GH-3580: Remove deprecated classes, methods and constants (jena-core) --- .../jena/riot/lang/rdfxml/ReaderRDFXML_ARP1.java | 4 +- .../jena/riot/lang/rdfxml/rrx/ParserRRX_SAX.java | 3 +- .../lang/rdfxml/rrx_stax_ev/ParserRRX_StAX_EV.java | 3 +- .../lang/rdfxml/rrx_stax_sr/ParserRRX_StAX_SR.java | 3 +- .../org/apache/jena/riot/writer/WriterTriX.java | 4 +- .../java/org/apache/jena/sparql/expr/ExprNode.java | 11 +- .../apache/jena/sparql/lang/arq/ARQParserBase.java | 4 +- .../org/apache/jena/sparql/util/ModelUtils.java | 78 --------- .../java/org/apache/jena/assembler/Assembler.java | 4 +- .../java/org/apache/jena/datatypes/TypeMapper.java | 12 +- .../apache/jena/datatypes/xsd/impl/RDFjson.java | 6 - .../jena/datatypes/xsd/impl/XMLLiteralType.java | 9 +- .../src/main/java/org/apache/jena/graph/Node.java | 8 - .../java/org/apache/jena/graph/NodeFactory.java | 43 ----- .../apache/jena/graph/impl/CollectionGraph.java | 95 ----------- .../org/apache/jena/graph/impl/LiteralLabel.java | 9 +- .../org/apache/jena/graph/langtag/LangTags.java | 48 ------ .../main/java/org/apache/jena/irix/Chars3986.java | 22 --- .../java/org/apache/jena/langtagx/LangTagX.java | 7 - .../java/org/apache/jena/rdf/model/Literal.java | 4 - .../main/java/org/apache/jena/rdf/model/Model.java | 10 -- .../org/apache/jena/rdf/model/ModelFactory.java | 2 +- .../apache/jena/rdfxml/xmlinput1/RDFXMLReader.java | 9 +- .../jena/rdfxml/xmlinput1/XMLLiteralTypeARP1.java | 148 ---------------- .../jena/rdfxml/xmloutput/impl/SplitRDFXML.java | 1 - .../apache/jena/shared/impl/PrefixMappingImpl.java | 13 -- .../org/apache/jena/util/IteratorCollection.java | 71 -------- .../java/org/apache/jena/util/ModelCollector.java | 89 ---------- .../java/org/apache/jena/util/MonitorGraph.java | 98 ----------- .../java/org/apache/jena/util/MonitorModel.java | 80 --------- .../main/java/org/apache/jena/util/SplitIRI.java | 8 +- .../main/java/org/apache/jena/util/Tokenizer.java | 29 ---- .../main/java/org/apache/jena/vocabulary/OWL1.java | 172 ------------------- .../main/java/org/apache/jena/vocabulary/RDF.java | 47 ----- .../apache/jena/datatypes/TestRDFXMLiteral.java | 11 +- .../java/org/apache/jena/util/TS3_coreutil.java | 3 - .../apache/jena/util/TestIteratorCollection.java | 132 -------------- .../org/apache/jena/util/TestModelCollector.java | 139 --------------- .../java/org/apache/jena/util/TestMonitors.java | 190 --------------------- 39 files changed, 40 insertions(+), 1589 deletions(-) diff --git a/jena-arq/src/main/java/org/apache/jena/riot/lang/rdfxml/ReaderRDFXML_ARP1.java b/jena-arq/src/main/java/org/apache/jena/riot/lang/rdfxml/ReaderRDFXML_ARP1.java index 7dc869976c..8151ee9a14 100644 --- a/jena-arq/src/main/java/org/apache/jena/riot/lang/rdfxml/ReaderRDFXML_ARP1.java +++ b/jena-arq/src/main/java/org/apache/jena/riot/lang/rdfxml/ReaderRDFXML_ARP1.java @@ -28,7 +28,6 @@ import org.apache.jena.atlas.logging.Log; import org.apache.jena.atlas.web.ContentType; import org.apache.jena.datatypes.RDFDatatype ; import org.apache.jena.datatypes.TypeMapper ; -import org.apache.jena.datatypes.xsd.impl.XMLLiteralType; import org.apache.jena.graph.Node ; import org.apache.jena.graph.Triple ; import org.apache.jena.irix.IRIs; @@ -41,6 +40,7 @@ import org.apache.jena.riot.system.FactoryRDF; import org.apache.jena.riot.system.ParserProfile; import org.apache.jena.riot.system.StreamRDF; import org.apache.jena.sparql.util.Context; +import org.apache.jena.vocabulary.RDF; import org.xml.sax.SAXException ; import org.xml.sax.SAXParseException ; @@ -224,7 +224,7 @@ public class ReaderRDFXML_ARP1 implements ReaderRIOT return parserProfile.createLangLiteral(lit.toString(), lit.getLang(), -1, -1); if (lit.isWellFormedXML()) { - return parserProfile.createTypedLiteral(lit.toString(), XMLLiteralType.rdfXMLLiteral, -1, -1); + return parserProfile.createTypedLiteral(lit.toString(), RDF.dtXMLLiteral, -1, -1); } RDFDatatype dt = TypeMapper.getInstance().getSafeTypeByName(dtURI); diff --git a/jena-arq/src/main/java/org/apache/jena/riot/lang/rdfxml/rrx/ParserRRX_SAX.java b/jena-arq/src/main/java/org/apache/jena/riot/lang/rdfxml/rrx/ParserRRX_SAX.java index 46a46f3ae0..128b0a9db9 100644 --- a/jena-arq/src/main/java/org/apache/jena/riot/lang/rdfxml/rrx/ParserRRX_SAX.java +++ b/jena-arq/src/main/java/org/apache/jena/riot/lang/rdfxml/rrx/ParserRRX_SAX.java @@ -33,7 +33,6 @@ import org.apache.jena.atlas.lib.Cache; import org.apache.jena.atlas.lib.CacheFactory; import org.apache.jena.atlas.lib.EscapeStr; import org.apache.jena.datatypes.RDFDatatype; -import org.apache.jena.datatypes.xsd.impl.XMLLiteralType; import org.apache.jena.graph.Node; import org.apache.jena.graph.NodeFactory; import org.apache.jena.graph.Triple; @@ -95,7 +94,7 @@ class ParserRRX_SAX private static final String rdfAboutEachPrefix = "aboutEachPrefix"; private static final String rdfBagID = "bagID"; - private static final RDFDatatype rdfXmlLiteralDT = XMLLiteralType.rdfXMLLiteral; + private static final RDFDatatype rdfXmlLiteralDT = RDF.dtXMLLiteral; // LN = Local name. private static final String xmlBaseLN = "base"; diff --git a/jena-arq/src/main/java/org/apache/jena/riot/lang/rdfxml/rrx_stax_ev/ParserRRX_StAX_EV.java b/jena-arq/src/main/java/org/apache/jena/riot/lang/rdfxml/rrx_stax_ev/ParserRRX_StAX_EV.java index 66c6720e7b..ee67534365 100644 --- a/jena-arq/src/main/java/org/apache/jena/riot/lang/rdfxml/rrx_stax_ev/ParserRRX_StAX_EV.java +++ b/jena-arq/src/main/java/org/apache/jena/riot/lang/rdfxml/rrx_stax_ev/ParserRRX_StAX_EV.java @@ -35,7 +35,6 @@ import org.apache.jena.atlas.lib.Cache; import org.apache.jena.atlas.lib.CacheFactory; import org.apache.jena.atlas.lib.EscapeStr; import org.apache.jena.datatypes.RDFDatatype; -import org.apache.jena.datatypes.xsd.impl.XMLLiteralType; import org.apache.jena.graph.Node; import org.apache.jena.graph.NodeFactory; import org.apache.jena.graph.Triple; @@ -845,7 +844,7 @@ class ParserRRX_StAX_EV { //NamespaceContext nsCxt = startElt.getNamespaceContext(); String text = xmlLiteralAccumulateText(startElt); - Node object = literalDatatype(text, XMLLiteralType.rdfXMLLiteral, startElt.getLocation()); + Node object = literalDatatype(text, RDF.dtXMLLiteral, startElt.getLocation()); emitter.emit(subject, property, object, startElt.getLocation()); // Skip trailer then end property tag. XMLEvent event = peekEvent(); diff --git a/jena-arq/src/main/java/org/apache/jena/riot/lang/rdfxml/rrx_stax_sr/ParserRRX_StAX_SR.java b/jena-arq/src/main/java/org/apache/jena/riot/lang/rdfxml/rrx_stax_sr/ParserRRX_StAX_SR.java index 6c46da0af3..06107b0bb2 100644 --- a/jena-arq/src/main/java/org/apache/jena/riot/lang/rdfxml/rrx_stax_sr/ParserRRX_StAX_SR.java +++ b/jena-arq/src/main/java/org/apache/jena/riot/lang/rdfxml/rrx_stax_sr/ParserRRX_StAX_SR.java @@ -37,7 +37,6 @@ import org.apache.jena.atlas.lib.Cache; import org.apache.jena.atlas.lib.CacheFactory; import org.apache.jena.atlas.lib.EscapeStr; import org.apache.jena.datatypes.RDFDatatype; -import org.apache.jena.datatypes.xsd.impl.XMLLiteralType; import org.apache.jena.graph.Node; import org.apache.jena.graph.NodeFactory; import org.apache.jena.graph.Triple; @@ -812,7 +811,7 @@ class ParserRRX_StAX_SR { private int parseTypeLiteral(Node subject, Node property, Emitter emitter, Location location) { String text = xmlLiteralAccumulateText(); - Node object = literalDatatype(text, XMLLiteralType.rdfXMLLiteral, location); + Node object = literalDatatype(text, RDF.dtXMLLiteral, location); emitter.emit(subject, property, object, location); return END_ELEMENT; } diff --git a/jena-arq/src/main/java/org/apache/jena/riot/writer/WriterTriX.java b/jena-arq/src/main/java/org/apache/jena/riot/writer/WriterTriX.java index b8ac070ebe..c25bda1eb6 100644 --- a/jena-arq/src/main/java/org/apache/jena/riot/writer/WriterTriX.java +++ b/jena-arq/src/main/java/org/apache/jena/riot/writer/WriterTriX.java @@ -22,7 +22,6 @@ import java.io.OutputStream; import java.io.Writer; import org.apache.jena.atlas.io.IndentedWriter; -import org.apache.jena.datatypes.xsd.impl.XMLLiteralType; import org.apache.jena.graph.Graph; import org.apache.jena.riot.Lang; import org.apache.jena.riot.WriterDatasetRIOT; @@ -34,6 +33,7 @@ import org.apache.jena.riot.system.RiotLib; import org.apache.jena.riot.system.StreamRDFOps; import org.apache.jena.sparql.core.DatasetGraph; import org.apache.jena.sparql.util.Context; +import org.apache.jena.vocabulary.RDF; /** Write TriX. * See {@link TriX} for details. @@ -43,7 +43,7 @@ import org.apache.jena.sparql.util.Context; * @see StreamWriterTriX */ public class WriterTriX implements WriterDatasetRIOT, WriterGraphRIOT { - private static String rdfXMLLiteral = XMLLiteralType.rdfXMLLiteral.getURI(); + private static String rdfXMLLiteral = RDF.dtXMLLiteral.getURI(); // Common pattern. @Override diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/expr/ExprNode.java b/jena-arq/src/main/java/org/apache/jena/sparql/expr/ExprNode.java index f1b5639db2..9ec462eeb1 100644 --- a/jena-arq/src/main/java/org/apache/jena/sparql/expr/ExprNode.java +++ b/jena-arq/src/main/java/org/apache/jena/sparql/expr/ExprNode.java @@ -53,19 +53,10 @@ public abstract class ExprNode implements Expr } } - /** @deprecated Unnecessary - to be removed */ - @Deprecated(forRemoval = true) - public boolean isExpr() { return true; } - /** @deprecated Unnecessary - to be removed */ - @Deprecated(forRemoval = true) - public final Expr getExpr() { return this; } - - // --- interface Constraint - @Override public abstract NodeValue eval(Binding binding, FunctionEnv env); - // Theer are some overrides of this method for simple cases including + // There are some overrides of this method for simple cases including // NodeValue ( = "ExprConstant") // ExprVar @Override diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/lang/arq/ARQParserBase.java b/jena-arq/src/main/java/org/apache/jena/sparql/lang/arq/ARQParserBase.java index 89a63304d0..106a749e7b 100644 --- a/jena-arq/src/main/java/org/apache/jena/sparql/lang/arq/ARQParserBase.java +++ b/jena-arq/src/main/java/org/apache/jena/sparql/lang/arq/ARQParserBase.java @@ -139,8 +139,6 @@ public class ARQParserBase extends SPARQLParserBase // the following function checks whether the given lexical form is // well formed but, in the current case, we already know that it is // not well formed. - @SuppressWarnings("deprecation") - Node n = NodeFactory.createLiteral(lexicalForm, cdtDatatype); - return n; + return NodeFactory.createLiteralDT(lexicalForm, cdtDatatype); } } diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/util/ModelUtils.java b/jena-arq/src/main/java/org/apache/jena/sparql/util/ModelUtils.java index f7e581547a..c1925a1a93 100644 --- a/jena-arq/src/main/java/org/apache/jena/sparql/util/ModelUtils.java +++ b/jena-arq/src/main/java/org/apache/jena/sparql/util/ModelUtils.java @@ -18,22 +18,13 @@ package org.apache.jena.sparql.util; -import java.util.Iterator; - -import org.apache.jena.atlas.iterator.Iter; import org.apache.jena.graph.Node; -import org.apache.jena.graph.Triple; import org.apache.jena.query.QueryException; import org.apache.jena.rdf.model.Model; import org.apache.jena.rdf.model.RDFNode; -import org.apache.jena.rdf.model.Statement; -import org.apache.jena.rdf.model.StmtIterator; import org.apache.jena.rdf.model.impl.LiteralImpl; import org.apache.jena.rdf.model.impl.ResourceImpl; -import org.apache.jena.rdf.model.impl.StmtIteratorImpl; import org.apache.jena.sparql.ARQInternalErrorException; -import org.apache.jena.util.ModelCollector; -import org.apache.jena.util.iterator.ClosableIterator; public class ModelUtils { @@ -72,73 +63,4 @@ public class ModelUtils public static RDFNode convertGraphNodeToRDFNode(Node node) { return convertGraphNodeToRDFNode(node, null); } - - /** - * @deprecated Use {@link Model#asStatement(Triple)}. - */ - @Deprecated(forRemoval = true) - public static Statement tripleToStatement(Model model, Triple t) { - if ( model == null ) - throw new ARQInternalErrorException("Attempt to create statement with null model"); - - Node sNode = t.getSubject(); - Node pNode = t.getPredicate(); - Node oNode = t.getObject(); - - if (!NodeUtils.isValidAsRDF(sNode, pNode, oNode)) return null; - - return model.asStatement(t); - } - - /** - * Determines whether a valid Statement can be formed from the given Subject, Predicate and Object - * <p> - * This function reflects the fact that the {@link Triple} API is flexible in allowing any Node type in any position (including non-RDF node types like Variable) - * and as such not all Triples can be safely converted into Statements - * </p> - * @param s Subject - * @param p Predicate - * @param o Object - * @return True if a valid Statement can be formed - * - * @deprecated Use {@link NodeUtils#isValidAsRDF(Node, Node, Node)}. - */ - @Deprecated(forRemoval = true) - public static boolean isValidAsStatement(Node s, Node p, Node o) { - return NodeUtils.isValidAsRDF(s, p, o); - } - - /** - * @deprecated Use {@link NodeUtils#isValidAsRDF(Node, Node, Node)}. - */ - @Deprecated(forRemoval = true) - public static StmtIterator triplesToStatements(final Iterator<Triple> it, final Model refModel) { - return new StmtIteratorImpl(Iter.map(it, refModel::asStatement)) { - // Make sure to close the incoming iterator - @Override - public void close() { - if ( it instanceof ClosableIterator<? > ) { - ((ClosableIterator<? >)it).close(); - } else { - Iter.close(it); - } - } - }; - } - - /** @deprecated To be removed. */ - @Deprecated(forRemoval = true) - public static ModelCollector intersectCollector() { - return new ModelCollector.IntersectionModelCollector(); - } - - /** @deprecated To be removed. */ - @Deprecated(forRemoval = true) - public static ModelCollector unionCollector() { - return new ModelCollector.UnionModelCollector(); - } -// -// public static Iterator<Triple> statementsToTriples(final Iterator<Statement> it) { -// return Iter.onClose(Iter.map(it, Statement::asTriple), ()->Iter.close(it)); -// } } diff --git a/jena-core/src/main/java/org/apache/jena/assembler/Assembler.java b/jena-core/src/main/java/org/apache/jena/assembler/Assembler.java index 79e18c0f27..9307a7dd01 100644 --- a/jena-core/src/main/java/org/apache/jena/assembler/Assembler.java +++ b/jena-core/src/main/java/org/apache/jena/assembler/Assembler.java @@ -77,7 +77,7 @@ public interface Assembler { public static final Assembler infModel = ConstAssembler.infModel(); - /** @deprecated Use org.apache.hena.ontapi */ + /** @deprecated Use org.apache.jena.ontapi */ @Deprecated(forRemoval=true) public static final Assembler ontModel = ConstAssembler.ontModel(); @@ -89,7 +89,7 @@ public interface Assembler { public static final Assembler unionModel = ConstAssembler.unionModel(); - /** @deprecated Use org.apache.hena.ontapi */ + /** @deprecated Use org.apache.jena.ontapi */ @Deprecated(forRemoval=true) public static final Assembler ontModelSpec = ConstAssembler.ontModelSpec(); diff --git a/jena-core/src/main/java/org/apache/jena/datatypes/TypeMapper.java b/jena-core/src/main/java/org/apache/jena/datatypes/TypeMapper.java index 821df17ae5..dc2ce4a79d 100644 --- a/jena-core/src/main/java/org/apache/jena/datatypes/TypeMapper.java +++ b/jena-core/src/main/java/org/apache/jena/datatypes/TypeMapper.java @@ -24,8 +24,8 @@ import java.util.Iterator; import java.util.concurrent.ConcurrentHashMap; import org.apache.jena.datatypes.xsd.XSDDatatype ; -import org.apache.jena.datatypes.xsd.impl.*; import org.apache.jena.shared.impl.JenaParameters ; +import org.apache.jena.vocabulary.RDF; /** * The TypeMapper provides a global registry of known datatypes. @@ -66,11 +66,11 @@ public class TypeMapper { static { reset() ; } public static void reset() { theTypeMap = new TypeMapper(); - theTypeMap.registerDatatype(RDFLangString.rdfLangString) ; - theTypeMap.registerDatatype(RDFDirLangString.rdfDirLangString) ; - theTypeMap.registerDatatype(RDFjson.rdfJSON); - theTypeMap.registerDatatype(XMLLiteralType.rdfXMLLiteral); - theTypeMap.registerDatatype(RDFhtml.rdfHTML); + theTypeMap.registerDatatype(RDF.dtLangString) ; + theTypeMap.registerDatatype(RDF.dtDirLangString); + theTypeMap.registerDatatype(RDF.dtRDFJSON); + theTypeMap.registerDatatype(RDF.dtXMLLiteral); + theTypeMap.registerDatatype(RDF.dtRDFHTML); XSDDatatype.loadXSDSimpleTypes(theTypeMap); // add primitive types diff --git a/jena-core/src/main/java/org/apache/jena/datatypes/xsd/impl/RDFjson.java b/jena-core/src/main/java/org/apache/jena/datatypes/xsd/impl/RDFjson.java index 9d8a4c6831..20cd86cc49 100644 --- a/jena-core/src/main/java/org/apache/jena/datatypes/xsd/impl/RDFjson.java +++ b/jena-core/src/main/java/org/apache/jena/datatypes/xsd/impl/RDFjson.java @@ -41,12 +41,6 @@ public class RDFjson extends BaseDatatype implements RDFDatatype { */ public static final RDFDatatype rdfJSON = new RDFjson(); - /** - * @deprecated Prefer {@link #rdfJsonURI}. - */ - @Deprecated - public static String RDFjson = rdfJsonURI; - /** * Test where an {@link RDFDatatype} is that for {@code rdf:XMLLiteral}. */ diff --git a/jena-core/src/main/java/org/apache/jena/datatypes/xsd/impl/XMLLiteralType.java b/jena-core/src/main/java/org/apache/jena/datatypes/xsd/impl/XMLLiteralType.java index 6f2a3d89d0..41c7b02fda 100644 --- a/jena-core/src/main/java/org/apache/jena/datatypes/xsd/impl/XMLLiteralType.java +++ b/jena-core/src/main/java/org/apache/jena/datatypes/xsd/impl/XMLLiteralType.java @@ -64,18 +64,11 @@ public class XMLLiteralType extends BaseDatatype implements RDFDatatype { public static String XMLLiteralTypeURI = "http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral"; /** - * Singleton instance of the rdf:XMLLIteral datatype. + * Singleton instance of the rdf:XMLLiteral datatype. * Prefer {@link RDF#dtXMLLiteral} in applications. */ public static final RDFDatatype rdfXMLLiteral = new XMLLiteralType(); - /** - * Singleton instance (legacy name) - * @deprecated Prefer the constant {@link #rdfXMLLiteral} or {@link RDF#dtXMLLiteral} - */ - @Deprecated - public static final RDFDatatype theXMLLiteralType = rdfXMLLiteral; - private static final String xmlWrapperTagName = "xml-literal-fragment"; private static final String xmlWrapperTagStart = "<"+xmlWrapperTagName+">"; private static final String xmlWrapperTagEnd = "</"+xmlWrapperTagName+">"; diff --git a/jena-core/src/main/java/org/apache/jena/graph/Node.java b/jena-core/src/main/java/org/apache/jena/graph/Node.java index 2f34f2ed71..e249cb4c59 100644 --- a/jena-core/src/main/java/org/apache/jena/graph/Node.java +++ b/jena-core/src/main/java/org/apache/jena/graph/Node.java @@ -120,14 +120,6 @@ public abstract class Node implements Serializable { public boolean isTripleTerm() { return false; } - /** - * Answer true iff this node is an "triple node" (RDF-star) - * @deprecated use {@link #isTripleTerm} - */ - @Deprecated(forRemoval = true) - public boolean isNodeTriple() - { return isTripleTerm(); } - /** * Answer true iff this node is an "graph node" (N3 formula). This is not related * to named graphs. diff --git a/jena-core/src/main/java/org/apache/jena/graph/NodeFactory.java b/jena-core/src/main/java/org/apache/jena/graph/NodeFactory.java index 4556d1e4e6..c919787098 100644 --- a/jena-core/src/main/java/org/apache/jena/graph/NodeFactory.java +++ b/jena-core/src/main/java/org/apache/jena/graph/NodeFactory.java @@ -83,12 +83,6 @@ public class NodeFactory { return new Node_Literal( lit ); } - /** @deprecated Use {@link #createLiteralString} */ - @Deprecated(forRemoval = true) - public static Node createLiteral(String string) { - return createLiteralString(string); - } - /* * Make literal which is a string (xsd:string) */ @@ -97,19 +91,6 @@ public class NodeFactory { return new Node_Literal(string); } - /** - * Make a literal with specified language. The lexical form must not be null. - * - * @param string the lexical form of the literal - * @param lang the optional language tag - * - * @deprecated Use {@link #createLiteralLang(String, String)}. - */ - @Deprecated(forRemoval = true) - public static Node createLiteral(String string, String lang) { - return createLiteralLang(string, lang); - } - /** * Make a literal with specified language. The lexical form must not be null. * <p> @@ -284,12 +265,6 @@ public class NodeFactory { return textDir; } - /** @deprecated Use {@link #createLiteralDT(String, RDFDatatype)} */ - @Deprecated - public static Node createLiteral(String lex, RDFDatatype dtype) { - return createLiteralDT(lex, dtype); - } - /** * Build a typed literal node from its lexical form. * @@ -338,24 +313,6 @@ public class NodeFactory { return new Node_Triple(triple); } - /** - * Create a triple term (RDF-star) - * @deprecated Use {@link #createTripleTerm(Node, Node, Node)} - */ - @Deprecated - public static Node createTripleNode(Node s, Node p, Node o) { - return createTripleTerm(s, p, o); - } - - /** - * Create a triple node (RDF-star) - * @deprecated Use {@link #createTripleTerm(Triple)} - */ - @Deprecated - public static Node createTripleNode(Triple triple) { - return createTripleTerm(triple); - } - /** Create a graph node. This is an N3-formula; it is not a named graph (see "quad") */ public static Node createGraphNode(Graph graph) { return new Node_Graph(graph); diff --git a/jena-core/src/main/java/org/apache/jena/graph/impl/CollectionGraph.java b/jena-core/src/main/java/org/apache/jena/graph/impl/CollectionGraph.java deleted file mode 100644 index 74288a4a2c..0000000000 --- a/jena-core/src/main/java/org/apache/jena/graph/impl/CollectionGraph.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.jena.graph.impl; - -import java.util.Collection ; -import java.util.HashSet ; -import java.util.Set ; - -import org.apache.jena.graph.Node ; -import org.apache.jena.graph.Triple ; -import org.apache.jena.util.iterator.ExtendedIterator ; - -/** - * A simple graph implementation that wraps a collection of triples. - * - * This is intended to be used in places where a graph is required but - * iteration is the only expected operation. All graph operations are supported - * but many are not efficient and will be slow on large collections. In these - * cases a memory based graph will be more efficient. - * <p> - * This implementation: - * <ul> - * <li> - * Does not support deleting triples from the iterator - * </li></ul> - * @deprecated To be removed. - */ -@Deprecated(forRemoval = true) -public class CollectionGraph extends GraphBase -{ - static boolean tripleContained(Triple patternTriple, Triple dataTriple) { - return equalNode(patternTriple.getSubject(), dataTriple.getSubject()) - && equalNode(patternTriple.getPredicate(), dataTriple.getPredicate()) - && equalNode(patternTriple.getObject(), dataTriple.getObject()); - } - - private static boolean equalNode(Node m, Node n) { - return (m == null) || (m == Node.ANY) || m.equals(n); - } - - // the collection - private final Collection<Triple> triples; - private final boolean uniqueOnly; - - /** - * Construct an empty graph using an empty HashSet. Iterator deletion is - * supported. - */ - public CollectionGraph() { - this(new HashSet<>()); - } - - /** - * Construct a graph from a collection. Iterator deletion is not supported. - * - * @param triples The collection of triples. - */ - public CollectionGraph(final Collection<Triple> triples) { - this.triples = triples; - this.uniqueOnly = triples instanceof Set; - } - - @Override - protected ExtendedIterator<Triple> graphBaseFind(final Triple m) { - ExtendedIterator<Triple> iter = SimpleEventManager.notifyingRemove(this, triples.iterator()); - return iter.filterKeep(t -> tripleContained(m, t)); - } - - @Override - public void performAdd(final Triple t) { - if ( uniqueOnly || !triples.contains(t) ) { - triples.add(t); - } - } - - @Override - public void performDelete(final Triple t) { - triples.remove(t); - } -} diff --git a/jena-core/src/main/java/org/apache/jena/graph/impl/LiteralLabel.java b/jena-core/src/main/java/org/apache/jena/graph/impl/LiteralLabel.java index 1f8310ad86..5013242f17 100644 --- a/jena-core/src/main/java/org/apache/jena/graph/impl/LiteralLabel.java +++ b/jena-core/src/main/java/org/apache/jena/graph/impl/LiteralLabel.java @@ -28,9 +28,6 @@ import org.apache.jena.atlas.lib.InternalErrorException; import org.apache.jena.datatypes.DatatypeFormatException; import org.apache.jena.datatypes.RDFDatatype; import org.apache.jena.datatypes.xsd.XSDDatatype; -import org.apache.jena.datatypes.xsd.impl.RDFhtml; -import org.apache.jena.datatypes.xsd.impl.RDFjson; -import org.apache.jena.datatypes.xsd.impl.XMLLiteralType; import org.apache.jena.graph.TextDirection; import org.apache.jena.shared.JenaException; import org.apache.jena.shared.PrefixMapping; @@ -419,9 +416,9 @@ final public class LiteralLabel { * Therefore getValueHashCode is the same as hashCode(); */ private boolean indexingValueIsSelf() { - return dtype == XMLLiteralType.rdfXMLLiteral || - dtype == RDFjson.rdfJSON || - dtype == RDFhtml.rdfHTML ; + return dtype == RDF.dtXMLLiteral || + dtype == RDF.dtRDFJSON || + dtype == RDF.dtRDFHTML; } /** diff --git a/jena-core/src/main/java/org/apache/jena/graph/langtag/LangTags.java b/jena-core/src/main/java/org/apache/jena/graph/langtag/LangTags.java deleted file mode 100644 index a52239516a..0000000000 --- a/jena-core/src/main/java/org/apache/jena/graph/langtag/LangTags.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.jena.graph.langtag; - -/** - * Functions on language tag strings - * @deprecated use org.apache.jena.langtag.LangTags - */ -@Deprecated(forRemoval = true) -public class LangTags { - - /** - * Format language tag. - * This is the system-wide policy for formatting language tags. - * @deprecated use org.apache.jena.langtag.LangTags#formatLangtag(String) - */ - @Deprecated(forRemoval=true) - public static String formatLangtag(String input) { - return org.apache.jena.langtag.LangTags.format(input); - } - - /** - * Format an language tag assumed to be valid. - * This code only deals with langtags by the string length of the subtags. - * <a href="https://datatracker.ietf.org/doc/html/rfc5646#section-2.1.1">RFC 5646 section 2.1.1</a> - * @deprecated use org.apache.jena.langtag.LangTags#basicFormat(String) - */ - @Deprecated(forRemoval=true) - public static String basicFormat(String string) { - return org.apache.jena.langtag.LangTags.basicFormat(string); - } -} diff --git a/jena-core/src/main/java/org/apache/jena/irix/Chars3986.java b/jena-core/src/main/java/org/apache/jena/irix/Chars3986.java deleted file mode 100644 index 78c53b6b97..0000000000 --- a/jena-core/src/main/java/org/apache/jena/irix/Chars3986.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.jena.irix; - -@Deprecated(forRemoval = true) -public class Chars3986 extends org.apache.jena.rfc3986.Chars3986 {} diff --git a/jena-core/src/main/java/org/apache/jena/langtagx/LangTagX.java b/jena-core/src/main/java/org/apache/jena/langtagx/LangTagX.java index 6685031dcf..a6b57d38de 100644 --- a/jena-core/src/main/java/org/apache/jena/langtagx/LangTagX.java +++ b/jena-core/src/main/java/org/apache/jena/langtagx/LangTagX.java @@ -80,13 +80,6 @@ public class LangTagX { } } - /** @deprecated Use {@link #formatLanguageTag(String)} */ - @Deprecated(forRemoval = true) - public static String canonical(String langTagStr) { - // Only for transition support. - return formatLanguageTag(langTagStr); - } - /** * Check a string is valid as a language tag. * This function returns true or false and does not throw an exception. diff --git a/jena-core/src/main/java/org/apache/jena/rdf/model/Literal.java b/jena-core/src/main/java/org/apache/jena/rdf/model/Literal.java index f8ceee7e5a..775d8c84a5 100644 --- a/jena-core/src/main/java/org/apache/jena/rdf/model/Literal.java +++ b/jena-core/src/main/java/org/apache/jena/rdf/model/Literal.java @@ -175,10 +175,6 @@ public interface Literal extends RDFNode { */ public String getLanguage(); - /** @deprecated Use {@link #getBaseDirection()} */ - @Deprecated - public default String getTextDirection() { return getBaseDirection(); } - /** * If a base direction is defined for this literal return it * 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 0ac128457a..898c14d341 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 @@ -210,16 +210,6 @@ public interface Model */ public Resource createResource( String uri ) ; - /** - * Create a resource that represents a statement. - * This is in support of RDF 1.2 triple terms. - * @deprecated Use {@link #createStatementTerm} - */ - @Deprecated(forRemoval = true) - public default RDFNode createResource( Statement statement ) { - return createStatementTerm(statement); - } - /** * Create an RDFNode for a statement. * This is in support of RDF 1.2 triple terms. diff --git a/jena-core/src/main/java/org/apache/jena/rdf/model/ModelFactory.java b/jena-core/src/main/java/org/apache/jena/rdf/model/ModelFactory.java index 0400a3eeb2..ff481ec050 100644 --- a/jena-core/src/main/java/org/apache/jena/rdf/model/ModelFactory.java +++ b/jena-core/src/main/java/org/apache/jena/rdf/model/ModelFactory.java @@ -22,8 +22,8 @@ import java.util.Set ; import org.apache.jena.assembler.Assembler ; import org.apache.jena.assembler.AssemblerHelp ; -import org.apache.jena.graph.GraphMemFactory ; import org.apache.jena.graph.Graph ; +import org.apache.jena.graph.GraphMemFactory ; import org.apache.jena.graph.compose.Union ; import org.apache.jena.ontology.OntModel ; import org.apache.jena.ontology.OntModelSpec ; diff --git a/jena-core/src/main/java/org/apache/jena/rdfxml/xmlinput1/RDFXMLReader.java b/jena-core/src/main/java/org/apache/jena/rdfxml/xmlinput1/RDFXMLReader.java index 4d39162f87..882e857eb3 100644 --- a/jena-core/src/main/java/org/apache/jena/rdfxml/xmlinput1/RDFXMLReader.java +++ b/jena-core/src/main/java/org/apache/jena/rdfxml/xmlinput1/RDFXMLReader.java @@ -19,12 +19,14 @@ package org.apache.jena.rdfxml.xmlinput1; import java.io.*; -import java.net.*; +import java.net.HttpURLConnection; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.URLConnection; import java.util.Locale ; import org.apache.jena.datatypes.RDFDatatype ; import org.apache.jena.datatypes.TypeMapper ; -import org.apache.jena.datatypes.xsd.impl.XMLLiteralType; import org.apache.jena.graph.* ; import org.apache.jena.irix.*; import org.apache.jena.rdf.model.Model ; @@ -36,6 +38,7 @@ import org.apache.jena.shared.DoesNotExistException ; import org.apache.jena.shared.JenaException ; import org.apache.jena.shared.UnknownPropertyException ; import org.apache.jena.shared.WrappedIOException ; +import org.apache.jena.vocabulary.RDF; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.SAXNotRecognizedException; @@ -144,7 +147,7 @@ public class RDFXMLReader implements RDFReaderI, ARPErrorNumbers { return NodeFactory.createLiteralLang(lit.toString(), lit.getLang()); if (lit.isWellFormedXML()) { - return NodeFactory.createLiteral(lit.toString(), null, XMLLiteralType.rdfXMLLiteral); + return NodeFactory.createLiteral(lit.toString(), null, RDF.dtXMLLiteral); } RDFDatatype dt = TypeMapper.getInstance().getSafeTypeByName(dtURI); diff --git a/jena-core/src/main/java/org/apache/jena/rdfxml/xmlinput1/XMLLiteralTypeARP1.java b/jena-core/src/main/java/org/apache/jena/rdfxml/xmlinput1/XMLLiteralTypeARP1.java deleted file mode 100644 index 82a27f0356..0000000000 --- a/jena-core/src/main/java/org/apache/jena/rdfxml/xmlinput1/XMLLiteralTypeARP1.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.jena.rdfxml.xmlinput1; - -import java.io.IOException ; -import java.io.StringReader ; - -import org.apache.jena.datatypes.BaseDatatype; -import org.apache.jena.datatypes.DatatypeFormatException ; -import org.apache.jena.datatypes.RDFDatatype; -import org.apache.jena.datatypes.xsd.impl.XMLLiteralType; -import org.apache.jena.shared.BrokenException ; -import org.xml.sax.ErrorHandler ; -import org.xml.sax.SAXException ; -import org.xml.sax.SAXParseException ; - -/** - * Builtin data type to represent XMLLiteral (i.e. items created - * by use of <code>rdf:parsetype='literal'</code>. - * Version of rdf:XMLLiteral using ARP1 and hence has RDF1.0 semantics for the value space - */ -@Deprecated(forRemoval=true, since="5.0.0") -public class XMLLiteralTypeARP1 extends BaseDatatype implements RDFDatatype { - - public static final RDFDatatype dtRDF10 = new XMLLiteralTypeARP1(XMLLiteralType.XMLLiteralTypeURI); - - private XMLLiteralTypeARP1(String uri) { - super(uri); - } - - /** - * Convert a serialize a value of this datatype out - * to lexical form. - */ - @Override - public String unparse(Object value) { - return value.toString(); - } - - /** - * Parse a lexical form of this datatype to a value - * @throws DatatypeFormatException if the lexical form is not legal - */ - @Override - public Object parse(String lexicalForm) throws DatatypeFormatException { - if ( !isValid(lexicalForm)) - throw new DatatypeFormatException("Bad rdf:XMLLiteral"); - return lexicalForm; - } - - /** - * Test whether the given string is a legal lexical form - * of this datatype. - */ - @Override - public boolean isValid(final String lexicalForm) { - /* - * To check the lexical form we construct - * a dummy RDF/XML document and parse it with - * ARP. ARP performs an exclusive canonicalization, - * the dummy document has exactly one triple. - * If the lexicalForm is valid then the resulting - * literal found by ARP is unchanged. - * All other scenarios are either impossible - * or occur because the lexical form is invalid. - */ - final boolean status[] = new boolean[]{false,false,false}; - // status[0] true on error or other reason to know that this is not well-formed - // status[1] true once first triple found - // status[2] the result (good if status[1] and not status[0]). - - ARP arp = new ARP(); - - arp.getHandlers().setErrorHandler(new ErrorHandler(){ - @Override - public void fatalError(SAXParseException e){ - status[0] = true; - } - @Override - public void error(SAXParseException e){ - status[0] = true; - } - @Override - public void warning(SAXParseException e){ - status[0] = true; - } - }); - arp.getHandlers().setStatementHandler(new StatementHandler(){ - @Override - public void statement(AResource a, AResource b, ALiteral l){ - /* this method is invoked exactly once - * while parsing the dummy document. - * The l argument is in exclusive canonical XML and - * corresponds to where the lexical form has been - * in the dummy document. The lexical form is valid - * iff it is unchanged. - */ - if (status[1] || !l.isWellFormedXML()) { - status[0] = true; - } - //throw new BrokenException("plain literal in XMLLiteral code."); - status[1] = true; - status[2] = l.toString().equals(lexicalForm); - } - @Override - public void statement(AResource a, AResource b, AResource l){ - status[0] = true; - //throw new BrokenException("resource valued RDF/XML in XMLLiteral code."); - } - }); - try { - - arp.load(new StringReader( - "<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>\n" - +"<rdf:Description><rdf:value rdf:parseType='Literal'>" - +lexicalForm+"</rdf:value>\n" - +"</rdf:Description></rdf:RDF>" - )); - - } - catch (IOException ioe){ - throw new BrokenException(ioe); - } - catch (SAXException s){ - return false; - } - - - return (!status[0])&&status[1]&&status[2]; - } - -} diff --git a/jena-core/src/main/java/org/apache/jena/rdfxml/xmloutput/impl/SplitRDFXML.java b/jena-core/src/main/java/org/apache/jena/rdfxml/xmloutput/impl/SplitRDFXML.java index 687c198d15..056ef995cb 100644 --- a/jena-core/src/main/java/org/apache/jena/rdfxml/xmloutput/impl/SplitRDFXML.java +++ b/jena-core/src/main/java/org/apache/jena/rdfxml/xmloutput/impl/SplitRDFXML.java @@ -66,5 +66,4 @@ class SplitRDFXML { int i = splitXML10(string); return string.substring(i); } - } diff --git a/jena-core/src/main/java/org/apache/jena/shared/impl/PrefixMappingImpl.java b/jena-core/src/main/java/org/apache/jena/shared/impl/PrefixMappingImpl.java index 6a3e31e6d5..ec338d90d3 100644 --- a/jena-core/src/main/java/org/apache/jena/shared/impl/PrefixMappingImpl.java +++ b/jena-core/src/main/java/org/apache/jena/shared/impl/PrefixMappingImpl.java @@ -128,19 +128,6 @@ public class PrefixMappingImpl implements PrefixMapping throw new PrefixMapping.IllegalPrefixException(prefix); } - /** - * Test whether a URI is "nice" for RDF/XML (ends in a non-NCName character according to XML 1.0). - * @deprecated To be removed. - */ - @Deprecated - public static boolean isNiceURI(String uri) { - // Not used in Jena anymore. - if ( uri.equals("") ) - return false; - char last = uri.charAt(uri.length() - 1); - return !org.apache.jena.util.XMLChar.isNCName(last); - } - /** * Add the bindings of other to our own. We defer to the general case because we * have to ensure the URIs are checked. diff --git a/jena-core/src/main/java/org/apache/jena/util/IteratorCollection.java b/jena-core/src/main/java/org/apache/jena/util/IteratorCollection.java deleted file mode 100644 index 08e5e8c302..0000000000 --- a/jena-core/src/main/java/org/apache/jena/util/IteratorCollection.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.jena.util; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -import org.apache.jena.atlas.iterator.Iter; -import org.apache.jena.util.iterator.NiceIterator ; - - -/** - * @deprecated Use {@link Iter#toList(Iterator)} and {@link Iter#toSet(Iterator)} - */ -@Deprecated(forRemoval = true) -public class IteratorCollection - { - /** - Only static methods here - the class cannot be instantiated. - */ - private IteratorCollection() - {} - - /** - Answer the elements of the given iterator as a set. The iterator is consumed - by the operation. Even if an exception is thrown, the iterator will be closed. - @param i the iterator to convert - @return A set of the members of i - */ - public static <T> Set<T> iteratorToSet( Iterator<? extends T> i ) - { - Set<T> result = CollectionFactory.createHashedSet(); - try { i.forEachRemaining(result::add); } - finally { NiceIterator.close( i ); } - return result; - } - - /** - Answer the elements of the given iterator as a list, in the order that they - arrived from the iterator. The iterator is consumed by this operation: - even if an exception is thrown, the iterator will be closed. - @param it the iterator to convert - @return a list of the elements of <code>it</code>, in order - */ - public static <T> List<T> iteratorToList( Iterator<? extends T> it ) - { - List<T> result = new ArrayList<>(); - try { it.forEachRemaining(result::add); } - finally { NiceIterator.close( it ); } - return result; - } - - } diff --git a/jena-core/src/main/java/org/apache/jena/util/ModelCollector.java b/jena-core/src/main/java/org/apache/jena/util/ModelCollector.java deleted file mode 100644 index f838e53777..0000000000 --- a/jena-core/src/main/java/org/apache/jena/util/ModelCollector.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.jena.util; - -import java.util.function.BiConsumer; -import java.util.function.BinaryOperator; -import java.util.function.Supplier; - -import org.apache.jena.atlas.lib.IdentityFinishCollector.UnorderedIdentityFinishCollector; -import org.apache.jena.rdf.model.Model; -import org.apache.jena.rdf.model.ModelFactory; - -/** - * @deprecated To be removed. - */ -@Deprecated(forRemoval = true) -public abstract class ModelCollector implements UnorderedIdentityFinishCollector<Model, Model> { - - @Override - public Supplier<Model> supplier() { - return ModelFactory::createDefaultModel; - } - - public ConcurrentModelCollector concurrent() { - return new ConcurrentModelCollector(this); - } - - public static class ConcurrentModelCollector extends ModelCollector - implements ConcurrentUnorderedIdentityFinishCollector<Model, Model> { - - private final ModelCollector collector; - - public ConcurrentModelCollector(ModelCollector col) { - this.collector = col; - } - - @Override - public BiConsumer<Model, Model> accumulator() { - return (m1, m2) -> m2.executeInTxn(() -> m1.executeInTxn(() -> collector.accumulator().accept(m1, m2))); - } - - @Override - public BinaryOperator<Model> combiner() { - return (m1, m2) -> m2.calculateInTxn(() -> m1.calculateInTxn(() -> collector.combiner().apply(m1, m2))); - } - } - - public static class UnionModelCollector extends ModelCollector { - - @Override - public BinaryOperator<Model> combiner() { - return ModelFactory::createUnion; - } - - @Override - public BiConsumer<Model, Model> accumulator() { - return Model::add; - } - } - - public static class IntersectionModelCollector extends ModelCollector { - - @Override - public BinaryOperator<Model> combiner() { - return Model::intersection; - } - - @Override - public BiConsumer<Model, Model> accumulator() { - return (m1, m2) -> m1.remove(m1.difference(m2)); - } - } -} diff --git a/jena-core/src/main/java/org/apache/jena/util/MonitorGraph.java b/jena-core/src/main/java/org/apache/jena/util/MonitorGraph.java deleted file mode 100644 index 8e0afb54c3..0000000000 --- a/jena-core/src/main/java/org/apache/jena/util/MonitorGraph.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.jena.util; - -import java.util.*; - -import org.apache.jena.graph.* ; -import org.apache.jena.graph.impl.* ; - -/** - * Graph wrapper which provides normal access to an underlying graph but - * also maintains a snapshot of the triples it was last known to contain. - * A snapshot action - * causes the set of changes between this and the previous snapshot to - * be calculated and the cache updated. The snapshot process will also - * fire change notification. - * - * @deprecated Do not use - to be removed. - */ -@Deprecated(forRemoval = true) -public class MonitorGraph extends WrappedGraph { - - /** The last known snapshot, a set of triples */ - protected Set<Triple> snapshot = new HashSet<>(); - - /** Constructor, wrap the given graph with a state monitor */ - public MonitorGraph(Graph g) { - super(g); - } - - /** - * Compute the differences between the current monitored graph and the last - * snapshot. The changes will also be forwarded to any listeners. - * Then take a new snapshot. - * @param additions a place in which the set of newly added triples should be noted, can be null - * @param deletions a place in which the set of newly deleted triples should be noted, can be null - */ - public void snapshot(List<Triple> additions, List<Triple> deletions) { - boolean listening = getEventManager().listening(); - boolean wantAdditions = listening || additions != null; - boolean wantDeletions = listening || deletions != null; - - List<Triple> additionsTemp = (additions != null) ? additions : new ArrayList<>(); - List<Triple> deletionsTemp = (deletions != null) ? deletions : new ArrayList<>(); - Set<Triple> deletionsTempSet = (wantDeletions) ? new HashSet<>() : null; - - if (wantAdditions || wantDeletions) { - if (wantDeletions) { - deletionsTempSet.addAll(snapshot); - } - for (Iterator<Triple> i = base.find(Node.ANY, Node.ANY, Node.ANY); i.hasNext(); ) { - Triple triple = i.next(); - if (wantAdditions && ! snapshot.contains(triple)) { - additionsTemp.add(triple); - } - if (wantDeletions) { - deletionsTempSet.remove(triple); - } - } - } - if (deletions != null) { - // We use a set for performance computing in deletions but specify a list - // for the method signature for compatibility with listeners - deletionsTemp.addAll(deletionsTempSet); - } - - if (listening) { - getEventManager().notifyAddList(this, additionsTemp); - getEventManager().notifyDeleteList(this, deletionsTemp); - } - - // Update shapshot - // In somecases applying the already computed changes may be cheaper, could optmize - // this based on relative sizes if it becomes an issue. - snapshot.clear(); - for (Iterator<Triple> i = base.find(Node.ANY, Node.ANY, Node.ANY); i.hasNext(); ) { - snapshot.add(i.next()); - } - - } - -} diff --git a/jena-core/src/main/java/org/apache/jena/util/MonitorModel.java b/jena-core/src/main/java/org/apache/jena/util/MonitorModel.java deleted file mode 100644 index 881f518cea..0000000000 --- a/jena-core/src/main/java/org/apache/jena/util/MonitorModel.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.jena.util; - -import java.util.*; - -import org.apache.jena.graph.Triple ; -import org.apache.jena.rdf.model.* ; -import org.apache.jena.rdf.model.impl.ModelCom ; - -/** - * Model wrapper which provides normal access to an underlying model but - * also maintains a snapshot of the triples it was last known to contain. - * A snapshot action - * causes the set of changes between this and the previous snapshot to - * be calculated and the cache updated. The snapshot process will also - * fire change notification. - * - * @deprecated Do not use - to be removed. - */ -@Deprecated(forRemoval = true) -public class MonitorModel extends ModelCom { - - /** - * Create a monitor over the given underlying base model. - */ - public MonitorModel(Model base) { - super(new MonitorGraph(base.getGraph())); - } - - /** - * Compute the differences between the current monitored graph and the last - * snapshot. The changes will also be forwarded to any listeners. - * Then take a new snapshot. - * @param additions a place in which the set of newly added statements should be noted, can be null - * @param deletions a place in which the set of newly deleted statements should be noted, can be null - */ - public void snapshot(List<Statement> additions, List<Statement> deletions) { - List<Triple> additionsTemp = (additions != null) ? new ArrayList<>() : null; - List<Triple> deletionsTemp = (deletions != null) ? new ArrayList<>() : null; - ((MonitorGraph)getGraph()).snapshot(additionsTemp, deletionsTemp); - if (additions != null) { - for ( Triple anAdditionsTemp : additionsTemp ) - { - additions.add( this.asStatement( anAdditionsTemp ) ); - } - } - if (deletions != null) { - for ( Triple aDeletionsTemp : deletionsTemp ) - { - deletions.add( this.asStatement( aDeletionsTemp ) ); - } - } - } - - /** - * Compute the differences between the current monitored graph and the last - * snapshot, forward any changes to registered listeners, then take a new snapshot. - */ - public void snapshot() { - snapshot(null, null); - } - -} diff --git a/jena-core/src/main/java/org/apache/jena/util/SplitIRI.java b/jena-core/src/main/java/org/apache/jena/util/SplitIRI.java index c620914ae4..6652ab4d5d 100644 --- a/jena-core/src/main/java/org/apache/jena/util/SplitIRI.java +++ b/jena-core/src/main/java/org/apache/jena/util/SplitIRI.java @@ -273,8 +273,8 @@ public class SplitIRI } /** - * Split point, according to XML 1.0 qname rules. - * This is the longest XML 1.0 NCName at the end of the uri. + * Split point, according to XML 1.1 qname rules. + * This is the longest XML 1.1 NCName at the end of the uri. * Return a split at the end of the string if there is no match * (e.g. the URI string ends in '/' or '#'). */ @@ -473,6 +473,10 @@ public class SplitIRI return j; } + /** + * splitXML with local stricter XML 1.0 rules (only single Java characters) + * Retained as a record of previous split handling. + */ private static int splitNamespaceXML10(String uri) { // The original code. char ch; diff --git a/jena-core/src/main/java/org/apache/jena/util/Tokenizer.java b/jena-core/src/main/java/org/apache/jena/util/Tokenizer.java deleted file mode 100644 index ce2e13aeb7..0000000000 --- a/jena-core/src/main/java/org/apache/jena/util/Tokenizer.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.jena.util; - -/** - * @deprecated Use {@link SimpleTokenizer}. - */ -@Deprecated(forRemoval = true) -public class Tokenizer extends SimpleTokenizer { - public Tokenizer(String str, String delim, String literalDelim, boolean returnDelims) { - super(str, delim, literalDelim, returnDelims); - } -} diff --git a/jena-core/src/main/java/org/apache/jena/vocabulary/OWL1.java b/jena-core/src/main/java/org/apache/jena/vocabulary/OWL1.java index 9de6915ca6..bb2a1f3fa7 100644 --- a/jena-core/src/main/java/org/apache/jena/vocabulary/OWL1.java +++ b/jena-core/src/main/java/org/apache/jena/vocabulary/OWL1.java @@ -157,177 +157,5 @@ public class OWL1 { // Vocabulary individuals /////////////////////////// - /** - * OWL constants are used during Jena initialization. - * <p> - * If that initialization is triggered by touching the OWL class, - * then the constants are null. - * <p> - * So for these cases, call this helper class: Init.function() - */ - @Deprecated - public static class Init { - // JENA-1294 - // Version that calculate the constant when called. - public static Property maxCardinality() { - return property("maxCardinality"); - } - - public static Property versionInfo() { - return property("versionInfo"); - } - - public static Property equivalentClass() { - return property("equivalentClass"); - } - - public static Property distinctMembers() { - return property("distinctMembers"); - } - - public static Property oneOf() { - return property("oneOf"); - } - - public static Property sameAs() { - return property("sameAs"); - } - - public static Property incompatibleWith() { - return property("incompatibleWith"); - } - - public static Property minCardinality() { - return property("minCardinality"); - } - - public static Property complementOf() { - return property("complementOf"); - } - - public static Property onProperty() { - return property("onProperty"); - } - - public static Property equivalentProperty() { - return property("equivalentProperty"); - } - - public static Property inverseOf() { - return property("inverseOf"); - } - - public static Property backwardCompatibleWith() { - return property("backwardCompatibleWith"); - } - - public static Property differentFrom() { - return property("differentFrom"); - } - - public static Property priorVersion() { - return property("priorVersion"); - } - - public static Property imports() { - return property("imports"); - } - - public static Property allValuesFrom() { - return property("allValuesFrom"); - } - - public static Property unionOf() { - return property("unionOf"); - } - - public static Property hasValue() { - return property("hasValue"); - } - - public static Property someValuesFrom() { - return property("someValuesFrom"); - } - - public static Property disjointWith() { - return property("disjointWith"); - } - - public static Property cardinality() { - return property("cardinality"); - } - - public static Property intersectionOf() { - return property("intersectionOf"); - } - - public static Resource Thing() { - return resource("Thing"); - } - - public static Resource DataRange() { - return resource("DataRange"); - } - - public static Resource Ontology() { - return resource("Ontology"); - } - - public static Resource DeprecatedClass() { - return resource("DeprecatedClass"); - } - - public static Resource AllDifferent() { - return resource("AllDifferent"); - } - - public static Resource DatatypeProperty() { - return resource("DatatypeProperty"); - } - - public static Resource SymmetricProperty() { - return resource("SymmetricProperty"); - } - - public static Resource TransitiveProperty() { - return resource("TransitiveProperty"); - } - - public static Resource DeprecatedProperty() { - return resource("DeprecatedProperty"); - } - - public static Resource AnnotationProperty() { - return resource("AnnotationProperty"); - } - - public static Resource Restriction() { - return resource("Restriction"); - } - - public static Resource Class() { - return resource("Class"); - } - - public static Resource OntologyProperty() { - return resource("OntologyProperty"); - } - - public static Resource ObjectProperty() { - return resource("ObjectProperty"); - } - - public static Resource FunctionalProperty() { - return resource("FunctionalProperty"); - } - - public static Resource InverseFunctionalProperty() { - return resource("InverseFunctionalProperty"); - } - - public static Resource Nothing() { - return resource("Nothing"); - } - } } diff --git a/jena-core/src/main/java/org/apache/jena/vocabulary/RDF.java b/jena-core/src/main/java/org/apache/jena/vocabulary/RDF.java index 2af1f0ddee..be0e341b83 100644 --- a/jena-core/src/main/java/org/apache/jena/vocabulary/RDF.java +++ b/jena-core/src/main/java/org/apache/jena/vocabulary/RDF.java @@ -130,53 +130,6 @@ public class RDF { public static final RDFDatatype dtRDFJSON = RDFjson.rdfJSON; public static final RDFDatatype dtRDFHTML = RDFhtml.rdfHTML; - @Deprecated(forRemoval = true) - private static class Init { - // This should not be needed anymore. - public static Resource Alt() { return resource( "Alt" ); } - public static Resource Bag() { return resource( "Bag" ); } - - // This was a due to a Java8 bug : https://bugzilla.redhat.com/show_bug.cgi?id=1423421 - // Can't have a method name ending in "Property" - it crashes the javadoc generation. - // https://bugzilla.redhat.com/show_bug.cgi?id=1423421 ==> - // https://bugs.openjdk.java.net/browse/JDK-8061305 - - /** @deprecated Use {@link #Property()} */ - @Deprecated(forRemoval = true) - public static Resource _Property() { return resource( "Property" ); } - - public static Resource Property() { return resource( "Property" ); } - public static Resource Seq() { return resource( "Seq" ); } - public static Resource Statement() { return resource( "Statement" ); } - public static Resource List() { return resource( "List" ); } - public static Resource nil() { return resource( "nil" ); } - public static Resource PlainLiteral() { return resource("PlainLiteral"); } - public static Property first() { return property( "first" ); } - public static Property rest() { return property( "rest" ); } - public static Property subject() { return property( "subject" ); } - public static Property predicate() { return property( "predicate" ); } - public static Property object() { return property( "object" ); } - public static Property type() { return property( "type" ); } - public static Property value() { return property( "value" ); } - public static Property langRange() { return property( "langRange" ); } - - public static Resource langString() { return ResourceFactory.createResource(dtLangString().getURI()); } - public static Resource dirLangString() { return ResourceFactory.createResource(dtDirLangString().getURI()); } - public static Resource HTML() { return ResourceFactory.createResource(dtRDFHTML().getURI()); } - public static Resource xmlLiteral() { return ResourceFactory.createResource(dtXMLLiteral().getURI()); } - public static Resource JSON() { return ResourceFactory.createResource(dtRDFJSON().getURI()) ; } - - public static Resource CompoundLiteral() { return resource( "CompoundLiteral" ); } - public static Property language() { return property( "language" ); } - public static Property direction() { return property( "direction" ); } - - public static RDFDatatype dtLangString() { return RDFLangString.rdfLangString; } - public static RDFDatatype dtDirLangString() { return RDFDirLangString.rdfDirLangString; } - public static RDFDatatype dtXMLLiteral() { return XMLLiteralType.rdfXMLLiteral; } - public static RDFDatatype dtRDFJSON() { return RDFjson.rdfJSON; } - public static RDFDatatype dtRDFHTML() { return RDFhtml.rdfHTML; } - } - /** * The main items of RDF vocabulary, but at the Node level, parked inside a nested * class so that there's a simple way to refer to them. diff --git a/jena-core/src/test/java/org/apache/jena/datatypes/TestRDFXMLiteral.java b/jena-core/src/test/java/org/apache/jena/datatypes/TestRDFXMLiteral.java index 372707af26..a281c2ffef 100644 --- a/jena-core/src/test/java/org/apache/jena/datatypes/TestRDFXMLiteral.java +++ b/jena-core/src/test/java/org/apache/jena/datatypes/TestRDFXMLiteral.java @@ -18,12 +18,13 @@ package org.apache.jena.datatypes; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; + +import org.junit.Test; -import org.apache.jena.datatypes.xsd.impl.XMLLiteralType; import org.apache.jena.graph.Node; import org.apache.jena.graph.NodeFactory; -import org.junit.Test; +import org.apache.jena.vocabulary.RDF; public class TestRDFXMLiteral { // Different RDF terms with the same value. @@ -66,8 +67,8 @@ public class TestRDFXMLiteral { // ---- private static void test(String lex1, String lex2, boolean javaEquals, boolean sameTerm, boolean sameValue) { - Node n1 = NodeFactory.createLiteralDT(lex1, XMLLiteralType.rdfXMLLiteral); - Node n2 = NodeFactory.createLiteralDT(lex2, XMLLiteralType.rdfXMLLiteral); + Node n1 = NodeFactory.createLiteralDT(lex1, RDF.dtXMLLiteral); + Node n2 = NodeFactory.createLiteralDT(lex2, RDF.dtXMLLiteral); assertEquals(javaEquals, n1.equals(n2)); assertEquals(sameTerm, n1.sameTermAs(n2)); assertEquals(sameValue, n1.sameValueAs(n2)); diff --git a/jena-core/src/test/java/org/apache/jena/util/TS3_coreutil.java b/jena-core/src/test/java/org/apache/jena/util/TS3_coreutil.java index 382407ae30..ab47e1e1ed 100644 --- a/jena-core/src/test/java/org/apache/jena/util/TS3_coreutil.java +++ b/jena-core/src/test/java/org/apache/jena/util/TS3_coreutil.java @@ -28,11 +28,8 @@ import org.junit.runners.Suite; TestCollectionFactory.class, TestLocationMapper.class, TestFileManager.class, - TestMonitors.class, TestPrintUtil.class, TestPrefixMappingUtils.class, - TestIteratorCollection.class, - TestModelCollector.class, TestSplitIRI_Display.class, TestSplitIRI_XML.class, diff --git a/jena-core/src/test/java/org/apache/jena/util/TestIteratorCollection.java b/jena-core/src/test/java/org/apache/jena/util/TestIteratorCollection.java deleted file mode 100644 index ad043b35fb..0000000000 --- a/jena-core/src/test/java/org/apache/jena/util/TestIteratorCollection.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.jena.util; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -import junit.framework.TestSuite; -import org.apache.jena.graph.test.GraphTestBase; -import org.apache.jena.util.iterator.NullIterator; -import org.apache.jena.util.iterator.SingletonIterator; -import org.apache.jena.util.iterator.WrappedIterator; - -@SuppressWarnings("removal") -public class TestIteratorCollection extends GraphTestBase { - public TestIteratorCollection(String name) { - super(name); - } - - public static TestSuite suite() { - return new TestSuite(TestIteratorCollection.class); - } - - public void testEmptyToEmptySet() { - assertEquals(CollectionFactory.createHashedSet(), IteratorCollection.iteratorToSet(NullIterator.instance())); - } - - public void testSingletonToSingleSet() { - assertEquals(oneSet("single"), IteratorCollection.iteratorToSet(new SingletonIterator<>("single"))); - } - - public void testLotsToSet() { - Object[] elements = new Object[]{"now", "is", "the", "time"}; - Iterator<Object> it = Arrays.asList(elements).iterator(); - assertEquals(setLots(elements), IteratorCollection.iteratorToSet(it)); - } - - public void testCloseForSet() { - testCloseForSet(new Object[]{}); - testCloseForSet(new Object[]{"one"}); - testCloseForSet(new Object[]{"to", "free", "for"}); - testCloseForSet(new Object[]{"another", "one", "plus", Boolean.FALSE}); - testCloseForSet(new Object[]{"the", "king", "is", "in", "his", "counting", "house"}); - } - - protected void testCloseForSet(Object[] objects) { - final boolean[] closed = {false}; - Iterator<Object> iterator = new WrappedIterator<Object>(Arrays.asList(objects).iterator()) { - @Override - public void close() { - super.close(); - closed[0] = true; - } - }; - IteratorCollection.iteratorToSet(iterator); - assertTrue(closed[0]); - } - - public void testEmptyToEmptyList() { - assertEquals(new ArrayList<>(), IteratorCollection.iteratorToList(NullIterator.instance())); - } - - public void testSingletonToSingletonList() { - assertEquals(oneList("just one"), IteratorCollection.iteratorToList(new SingletonIterator<>("just one"))); - } - - public void testLotsToList() { - List<Object> list = Arrays.asList(new Object[]{"to", "be", "or", "not", "to", "be"}); - assertEquals(list, IteratorCollection.iteratorToList(list.iterator())); - } - - public void testCloseForList() { - testCloseForList(new Object[]{}); - testCloseForList(new Object[]{"one"}); - testCloseForList(new Object[]{"to", "free", "for"}); - testCloseForList(new Object[]{"another", "one", "plus", Boolean.FALSE}); - testCloseForList(new Object[]{"the", "king", "is", "in", "his", "counting", "house"}); - } - - protected void testCloseForList(Object[] objects) { - final boolean[] closed = {false}; - Iterator<Object> iterator = new WrappedIterator<Object>(Arrays.asList(objects).iterator()) { - @Override - public void close() { - super.close(); - closed[0] = true; - } - }; - IteratorCollection.iteratorToList(iterator); - assertTrue(closed[0]); - } - - protected Set<Object> oneSet(Object x) { - Set<Object> result = new HashSet<>(); - result.add(x); - return result; - } - - protected Set<Object> setLots(Object[] elements) { - Set<Object> result = new HashSet<>(); - for ( Object element : elements ) { - result.add(element); - } - return result; - } - - protected List<Object> oneList(Object x) { - List<Object> result = new ArrayList<>(); - result.add(x); - return result; - } -} diff --git a/jena-core/src/test/java/org/apache/jena/util/TestModelCollector.java b/jena-core/src/test/java/org/apache/jena/util/TestModelCollector.java deleted file mode 100644 index 9b5704f600..0000000000 --- a/jena-core/src/test/java/org/apache/jena/util/TestModelCollector.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.jena.util; - -import static java.util.Collections.singleton; -import static java.util.stream.Collector.Characteristics.CONCURRENT; -import static java.util.stream.Collector.Characteristics.IDENTITY_FINISH; -import static java.util.stream.Collector.Characteristics.UNORDERED; -import static java.util.stream.Collectors.groupingBy; -import static java.util.stream.Stream.generate; -import static java.util.stream.Stream.iterate; -import static org.apache.jena.graph.NodeFactory.createLiteralByValue; -import static org.apache.jena.rdf.model.ModelFactory.createDefaultModel; -import static org.apache.jena.rdf.model.ModelFactory.createModelForGraph; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.util.List; -import java.util.Set; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.function.Supplier; -import java.util.stream.Collector.Characteristics; -import java.util.stream.Stream; - -import junit.framework.JUnit4TestAdapter; -import org.apache.jena.datatypes.RDFDatatype; -import org.apache.jena.datatypes.TypeMapper; -import org.apache.jena.graph.Node; -import org.apache.jena.graph.NodeFactory; -import org.apache.jena.graph.Triple; -import org.apache.jena.graph.impl.CollectionGraph; -import org.apache.jena.rdf.model.Model; -import org.apache.jena.rdf.model.ModelFactory; -import org.apache.jena.util.ModelCollector.ConcurrentModelCollector; -import org.apache.jena.util.ModelCollector.IntersectionModelCollector; -import org.apache.jena.util.ModelCollector.UnionModelCollector; -import org.junit.Test; - -@SuppressWarnings("removal") -public class TestModelCollector { - - public static junit.framework.Test suite() { - return new JUnit4TestAdapter(TestModelCollector.class); - } - - private static final Model EMPTY_MODEL = ModelFactory.createDefaultModel(); - private static final Node PREDICATE = NodeFactory.createURI("p"); - private static final Node SUBJECT = NodeFactory.createURI("s"); - private static final RDFDatatype INTEGER_TYPE = TypeMapper.getInstance().getTypeByValue(555); - - @Test - public void testCharacteristics() { - Set<Characteristics> characteristics = Set.of(UNORDERED, IDENTITY_FINISH); - assertEquals(characteristics, new UnionModelCollector().characteristics()); - assertEquals(characteristics, new IntersectionModelCollector().characteristics()); - characteristics = Set.of(CONCURRENT, UNORDERED, IDENTITY_FINISH); - assertEquals(characteristics, new ConcurrentModelCollector(null).characteristics()); - } - - Stream<Model> fromTriples(Supplier<Triple> kernel, byte size) { - AtomicInteger count = new AtomicInteger(); - return generate(kernel).collect(groupingBy(x -> count.incrementAndGet() / size)).values().stream().map(CollectionGraph::new) - .map(ModelFactory::createModelForGraph); - } - - private static void test(Stream<Model> data, Model expectedResults, ModelCollector testCollector) { - assertTrue(data.collect(testCollector).isIsomorphicWith(expectedResults)); - } - - @Test - public void unionOfEmptyStreamOfModelsIsEmpty() { - collectors().forEach(this::unionOfEmptyStreamOfModelsIsEmpty); - } - - private void unionOfEmptyStreamOfModelsIsEmpty(ModelCollector testCollector) { - assertTrue(Stream.<Model> empty().collect(testCollector).isEmpty()); - } - - private static List<ModelCollector> collectors() { - return List.of(new UnionModelCollector(), new IntersectionModelCollector()); - } - - @Test - public void unionOfStreamOfEmptyModelsIsEmpty() { - collectors().forEach(this::unionOfStreamOfEmptyModelsIsEmpty); - - } - - private void unionOfStreamOfEmptyModelsIsEmpty(ModelCollector testCollector) { - Stream<Model> models = numbers().limit(10).map(x -> createDefaultModel()); - test(models, EMPTY_MODEL, testCollector); - } - - private Triple sampleFromNum(int i) { - return Triple.create(SUBJECT, PREDICATE, createLiteralByValue(i, INTEGER_TYPE)); - } - - @Test - public void allStatementsPresentInUnionOfDisjointModels() { - ModelCollector testCollector = new UnionModelCollector(); - Model expectedResults = createDefaultModel(); - Stream<Triple> addTestStatementsToRubric = numbers().limit(10).map(this::sampleFromNum) - .peek(t -> expectedResults.add(expectedResults.asStatement(t))); - Stream<Model> models = addTestStatementsToRubric.map(this::intoModel); - test(models, expectedResults, testCollector); - } - - private static Stream<Integer> numbers() { - return generate(new AtomicInteger()::getAndIncrement); - } - - @Test - public void noStatementsPresentInIntersectionOfDisjointModels() { - ModelCollector testCollector = new IntersectionModelCollector(); - Stream<Model> models = iterate(0, i -> i + 1).limit(10).map(this::sampleFromNum).map(this::intoModel); - test(models, EMPTY_MODEL, testCollector); - } - - private Model intoModel(Triple t) { - return createModelForGraph(new CollectionGraph(singleton(t))); - } - -} diff --git a/jena-core/src/test/java/org/apache/jena/util/TestMonitors.java b/jena-core/src/test/java/org/apache/jena/util/TestMonitors.java deleted file mode 100644 index abc0c53d15..0000000000 --- a/jena-core/src/test/java/org/apache/jena/util/TestMonitors.java +++ /dev/null @@ -1,190 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.jena.util; - -import java.util.*; - -import junit.framework.TestCase; -import junit.framework.TestSuite; -import org.apache.jena.graph.*; -import org.apache.jena.graph.test.*; -import org.apache.jena.rdf.model.*; -import org.apache.jena.rdf.model.test.RecordingModelListener; -import org.apache.jena.reasoner.test.TestUtil; - -/** - * Tests for MonitorGraph implementation. - */ -@SuppressWarnings("removal") -public class TestMonitors extends TestCase { - - /** - * Boilerplate for junit - */ - public TestMonitors(String name) { - super(name); - } - - /** - * Boilerplate for junit. This is its own test suite - */ - public static TestSuite suite() { - return new TestSuite(TestMonitors.class); - } - - private static Graph createGraphForTest() { - return GraphMemFactory.createDefaultGraph(); - } - - // constants used in the tests - String NS = "http://jena.hpl.hp.com/test#"; - Node a = NodeCreateUtils.create(NS + "a"); - Node p = NodeCreateUtils.create(NS + "p"); - Triple t1 = Triple.create(a, p, NodeCreateUtils.create(NS + "v1")); - Triple t2 = Triple.create(a, p, NodeCreateUtils.create(NS + "v2")); - Triple t3 = Triple.create(a, p, NodeCreateUtils.create(NS + "v3")); - Triple t4 = Triple.create(a, p, NodeCreateUtils.create(NS + "v4")); - Triple t5 = Triple.create(a, p, NodeCreateUtils.create(NS + "v5")); - Triple t6 = Triple.create(a, p, NodeCreateUtils.create(NS + "v6")); - - /** - * Basic graph level test, no monitoring - */ - public void testBasics() { - Graph base = createGraphForTest(); - MonitorGraph monitor = new MonitorGraph(base); - - // base data - base.add(t1); - base.add(t2); - base.add(t3); - - // Test changes from empty - List<Triple> additions = new ArrayList<>(); - List<Triple> deletions = new ArrayList<>(); - monitor.snapshot(additions, deletions); - TestUtil.assertIteratorValues(this, additions.iterator(), new Object[]{t1, t2, t3}); - TestUtil.assertIteratorValues(this, deletions.iterator(), new Object[]{}); - - // Make some new changes - base.add(t4); - base.add(t5); - base.delete(t1); - base.delete(t2); - - additions.clear(); - deletions.clear(); - monitor.snapshot(additions, deletions); - TestUtil.assertIteratorValues(this, additions.iterator(), new Object[]{t4, t5}); - TestUtil.assertIteratorValues(this, deletions.iterator(), new Object[]{t1, t2}); - TestUtil.assertIteratorValues(this, monitor.find(Node.ANY, Node.ANY, Node.ANY), new Object[]{t3, t4, t5}); - } - - /** - * Monitoring test. - */ - public void testListener() { - Graph base = createGraphForTest(); - MonitorGraph monitor = new MonitorGraph(base); - RecordingListener listener = new RecordingListener(); - monitor.getEventManager().register(listener); - // base data - base.add(t1); - base.add(t2); - base.add(t3); - - listener.has(new Object[]{}); - - // Test changes from empty - List<Triple> additions = new ArrayList<>(); - List<Triple> deletions = new ArrayList<>(); - monitor.snapshot(additions, deletions); - TestUtil.assertIteratorValues(this, additions.iterator(), new Object[]{t1, t2, t3}); - TestUtil.assertIteratorValues(this, deletions.iterator(), new Object[]{}); - - listener.assertHas(new Object[]{"addList", monitor, additions, "deleteList", monitor, deletions}); - listener.clear(); - - // Make some new changes - base.add(t4); - base.add(t5); - base.delete(t1); - base.delete(t2); - - additions.clear(); - deletions.clear(); - monitor.snapshot(additions, deletions); - TestUtil.assertIteratorValues(this, additions.iterator(), new Object[]{t4, t5}); - TestUtil.assertIteratorValues(this, deletions.iterator(), new Object[]{t1, t2}); - TestUtil.assertIteratorValues(this, monitor.find(Node.ANY, Node.ANY, Node.ANY), new Object[]{t3, t4, t5}); - - listener.assertHas(new Object[]{"addList", monitor, additions, "deleteList", monitor, deletions}); - listener.clear(); - } - - /** - * Test model level access - */ - public void testModelMonitor() { - Model base = ModelFactory.createDefaultModel(); - // Constants for model level test - Resource ar = base.createResource(NS + "a"); - Property pr = base.createProperty(NS + "p"); - Statement s1 = base.createStatement(ar, pr, "1"); - Statement s2 = base.createStatement(ar, pr, "2"); - Statement s3 = base.createStatement(ar, pr, "3"); - Statement s4 = base.createStatement(ar, pr, "4"); - Statement s5 = base.createStatement(ar, pr, "5"); - - MonitorModel monitor = new MonitorModel(base); - RecordingModelListener listener = new RecordingModelListener(); - monitor.register(listener); - - // base data - base.add(s1); - base.add(s2); - base.add(s3); - - // Test changes from empty - List<Statement> additions = new ArrayList<>(); - List<Statement> deletions = new ArrayList<>(); - monitor.snapshot(additions, deletions); - TestUtil.assertIteratorValues(this, additions.iterator(), new Object[]{s1, s2, s3}); - TestUtil.assertIteratorValues(this, deletions.iterator(), new Object[]{}); - listener.assertHas(new Object[]{"addList", additions, "removeList", deletions}); - listener.clear(); - - // Make some new changes - base.add(s4); - base.add(s5); - base.remove(s1); - base.remove(s2); - - additions.clear(); - deletions.clear(); - monitor.snapshot(additions, deletions); - TestUtil.assertIteratorValues(this, additions.iterator(), new Object[]{s4, s5}); - TestUtil.assertIteratorValues(this, deletions.iterator(), new Object[]{s1, s2}); - TestUtil.assertIteratorValues(this, monitor.listStatements(), new Object[]{s3, s4, s5}); - - listener.assertHas(new Object[]{"addList", additions, "removeList", deletions}); - listener.clear(); - } - -}
