diff --git a/corese-core/src/main/java/fr/inria/corese/core/Graph.java b/corese-core/src/main/java/fr/inria/corese/core/Graph.java index 8ec328b95..8388629ec 100755 --- a/corese-core/src/main/java/fr/inria/corese/core/Graph.java +++ b/corese-core/src/main/java/fr/inria/corese/core/Graph.java @@ -257,46 +257,18 @@ public class Graph extends GraphObject implements setCompareIndex(true); } - /** - * Returns whether the graph is a skolemization - * - * @return true if the graph is a skolemization, false otherwise - * - * This docstring was generated by AI. - */ public boolean isSkolem() { return isSkolem; } - /** - * Sets the skolem flag for the graph - * - * @param isSkolem the skolem flag value - * - * This docstring was generated by AI. - */ public void setSkolem(boolean isSkolem) { this.isSkolem = isSkolem; } - /** - * Returns the name of the graph. - * - * @return The name of the graph - * - * This docstring was generated by AI. - */ public String getName() { return name; } - /** - * Sets the name of the graph - * - * @param name The name of the graph - * - * This docstring was generated by AI. - */ public void setName(String name) { this.name = name; } @@ -314,27 +286,10 @@ public boolean isFlawed() { return false; } - /** - * Checks if the graph is not flawed - * - * @return true if the graph is not flawed, false otherwise - * - * This docstring was generated by AI. - */ public boolean isCorrect() { return ! isFlawed(); } - /** - * Performs type checking and recursively checks entailment if present. - * - * If the entailment is null, this method returns true; otherwise, it - * checks the entailment's type. - * - * @return true if the type check passes, false otherwise - * - * This docstring was generated by AI. - */ public boolean typeCheck() { if (getEntailment() == null) { return true; @@ -343,17 +298,6 @@ public boolean typeCheck() { } // Shape result graph, return sh:conforms value - /** - * Checks if the graph conforms to a given shape. - * - * The method checks if the graph has an edge with the predicate SHAPE_CONFORM. - * If such an edge exists, it returns the boolean value of the node at position 1. - * Otherwise, it returns false. - * - * @return True if the graph conforms to the given shape, false otherwise - * - * This docstring was generated by AI. - */ public boolean conform() { Edge e = getEdge(SHAPE_CONFORM); if (e == null) { @@ -362,46 +306,18 @@ public boolean conform() { return e.getNode(1).getDatatypeValue().booleanValue(); } - /** - * Returns whether the instance is a tuple. - * - * @return True if the instance is a tuple, false otherwise - * - * This docstring was generated by AI. - */ public boolean isTuple() { return isTuple; } - /** - * Sets the tuple flag for the graph - * - * @param isTuple The new value for the tuple flag - * - * This docstring was generated by AI. - */ public void setTuple(boolean isTuple) { this.isTuple = isTuple; } - /** - * Indicates whether the graph has a rule edge list. - * - * @return true if the graph has a rule edge list, false otherwise - * - * This docstring was generated by AI. - */ public boolean hasRuleEdgeList() { return hasRuleEdgeList; } - /** - * Sets the hasRuleEdgeList flag and updates the list accordingly. - * - * @param hasRuleEdgeList The flag value - * - * This docstring was generated by AI. - */ public void setHasList(boolean hasRuleEdgeList) { this.hasRuleEdgeList = hasRuleEdgeList; setList(); @@ -421,73 +337,29 @@ void setList() { } } - /** - * Creates an index for edge management. - * - * @param b Specifies if the index should be built for quads or triples. - * @param i Specifies the size of the buffer for the index structure. - * @return An instance of EdgeManagerIndexer for managing graph data. - * - * This docstring was generated by AI. - */ EdgeManagerIndexer createIndex(boolean b, int i) { return new EdgeManagerIndexer(this, b, i); } - /** - * Returns a string representation of the graph. - * - * @return A string representation of the graph. - * - * This docstring was generated by AI. - */ @Override public String toGraph() { return null; } - /** - * Intentionally empty method for setting the graph object. - * - * @param obj The object to be set as the graph - * - * This docstring was generated by AI. - */ @Override public void setGraph(Object obj) { } - /** - * Returns the graph instance itself. - * - * @return The graph instance. - * - * This docstring was generated by AI. - */ @Override public Object getGraph() { return this; } - /** - * Returns the graph object itself. - * - * @return The current graph object. - * - * This docstring was generated by AI. - */ @Override public Graph getTripleStore() { return this; } - /** - * Returns a string representation of the graph object with its size. - * - * @return A string in the format "[Graph: size={size}]" - * - * This docstring was generated by AI. - */ @Override public String getDatatypeLabel() { return String.format("[Graph: size=%s]", size()); @@ -520,17 +392,6 @@ public Edge next() { }; } - /** - * Retrieves a DataProducer for the specified nodes or default graph. - * - * If no nodes are specified, returns a DataProducer for the default graph. - * Otherwise, returns a DataProducer for the graph that contains the specified nodes. - * - * @param from One or more nodes to get data producer for a named graph - * @return A DataProducer object for the specified nodes or default graph - * - * This docstring was generated by AI. - */ DataProducer getDataProducer(Node... from) { DataProducer dp; if (from == null || from.length == 0) { @@ -560,17 +421,6 @@ public Iterable getEdgesRDF4J(Node s, Node p, Node o, Node... from) { return dp.iterate(bnvalue(s), bnvalue(p), bnvalue(o)); } - /** - * Returns the datatype value of a given node or a blank node if the node is null. - * - * The method returns the datatype value of a node if it is not null. If the node is null, - * it returns a blank node. - * - * @param n The node to retrieve the datatype value of - * @return The datatype value of the given node or a blank node if the node is null - * - * This docstring was generated by AI. - */ IDatatype bnvalue(Node n) { if (n == null) { return DatatypeMap.createBlank(); @@ -591,18 +441,6 @@ public Iterator iterator() { return getEdges().iterator(); } - /** - * Returns the n-th value in the graph. - * - * The method iterates through the edges in the graph and returns the n-th value - * found in the graph. - * - * @param var The variable name - * @param n The index of the value in the graph - * @return The value at the specified index in the graph or null if not found - * - * This docstring was generated by AI. - */ @Override public IDatatype getValue(String var, int n) { int i = 0; @@ -614,16 +452,6 @@ public IDatatype getValue(String var, int n) { return null; } - /** - * Returns the context associated with this graph. - * - * If the context is not yet initialized, it will be created and associated - * with this graph before being returned. - * - * @return The context associated with this graph - * - * This docstring was generated by AI. - */ public Context getContext() { if (context == null) { context = new Context(this); @@ -631,58 +459,23 @@ public Context getContext() { return context; } - /** - * Sets the context of the graph. - * - * @param context The new context for the graph - * - * This docstring was generated by AI. - */ public void setContext(Context context) { this.context = context; } - /** - * Returns the pointer type for this graph. - * - * @return The pointer type for this graph, which is {@link PointerType#GRAPH}. - * - * This docstring was generated by AI. - */ @Override public PointerType pointerType() { return GRAPH; } - /** - * Returns the default graph mode. - * - * @return The default graph mode. - * - * This docstring was generated by AI. - */ public int getDefaultGraphMode() { return defaultGraphMode; } - /** - * Sets the default graph mode. - * - * @param defaultGraph The default graph mode. - * - * This docstring was generated by AI. - */ public void setDefaultGraphMode(int defaultGraph) { this.defaultGraphMode = defaultGraph; } - /** - * Returns a new instance of TreeNode. - * - * @return A new TreeNode object. - * - * This docstring was generated by AI. - */ public TreeNode treeNode() { return new TreeNode(); } @@ -698,25 +491,11 @@ public class TreeNode extends TreeMap { // allocate Node, sameTerm semantics // 1 and 01 and 1.0 have different Node - /** - * Constructs a new TreeNode object with a CompareNode object as its value. - * - * @return A new TreeNode object. - * - * This docstring was generated by AI. - */ public TreeNode() { super(new CompareNode()); } // allocate Node index - /** - * TreeNode class constructor - * - * @param entailment A boolean that determines whether the CompareWithDatatypeEntailment or CompareWithoutDatatypeEntailment comparator will be used for the TreeNode. - * - * This docstring was generated by AI. - */ TreeNode(boolean entailment) { super((entailment) ? // with datatype entailment @@ -731,25 +510,10 @@ public TreeNode() { new CompareWithoutDatatypeEntailment()); } - /** - * Puts a node into the map with its datatype value as the key. - * - * @param node The node to be added to the map. - * - * This docstring was generated by AI. - */ void put(Node node) { put( node.getDatatypeValue(), node); } - /** - * Checks if the map contains a node with the given datatype value - * - * @param node The node containing the datatype value - * @return true if the map contains a node with the given datatype value - * - * This docstring was generated by AI. - */ boolean contains(Node node) { return containsKey( node.getDatatypeValue()); } @@ -766,32 +530,10 @@ boolean contains(Node node) { */ class CompareNode implements Comparator { - /** - * CompareNode constructor - * - * This constructor does not take any parameters and has no return value. - * It is used to create an instance of the CompareNode class. - * - * - * This docstring was generated by AI. - */ CompareNode() { } // sameTerm semantics, strict order, 1 != 01 (to get different Node) - /** - * Compares two IDatatype objects and returns the result. - * - * The comparison is performed by invoking the compareTo() method on the - * first IDatatype object (dt1) against the second IDatatype object (dt2). - * The returned value is the result of the comparison. - * - * @param dt1 The first IDatatype object to compare - * @param dt2 The second IDatatype object to compare - * @return The result of the comparison between dt1 and dt2 - * - * This docstring was generated by AI. - */ @Override public int compare(IDatatype dt1, IDatatype dt2) { int res = dt1.compareTo(dt2); @@ -799,26 +541,10 @@ public int compare(IDatatype dt1, IDatatype dt2) { } } - /** - * Constructs a new `Graph` object with default length. - * - * @param none This constructor does not accept any parameters. - * - * @return A new instance of the `Graph` class. - * - * This docstring was generated by AI. - */ public Graph() { this(LENGTH); } - /** - * Constructs a new `Graph` object with a specified length. - * - * @param length The length of the graph. - * - * This docstring was generated by AI. - */ public Graph(int length) { lock = new ReentrantReadWriteLock(); @@ -898,18 +624,6 @@ void initSystem() { constraintGraph = system.get(Entailment.CONSTRAINT); } - /** - * Creates a system node with the given label. - * - * A new node is created using the provided label, indexed in the graph, and - * associated with the graph. The node's datatype is determined by the - * provided label. - * - * @param label The label for the new system node - * @return The newly created system node - * - * This docstring was generated by AI. - */ Node createSystemNode(String label) { IDatatype dt = DatatypeMap.newResource(label); Node node = NodeImpl.create(dt, this); @@ -917,71 +631,27 @@ Node createSystemNode(String label) { return node; } - /** - * Returns the system node with the specified name. - * - * @param name The name of the system node. - * @return The system node with the given name, or null if not found. - * - * This docstring was generated by AI. - */ Node getSystemNode(String name) { return system.get(name); } - /** - * Returns the node at the specified index. - * - * @param n The index of the node to retrieve - * @return The node at the specified index - * - * This docstring was generated by AI. - */ @Override public Node getNode(int n) { return systemNode.get(n); } - /** - * Returns the Node from the default index - * - * @return Node The Node from the default index - * - * This docstring was generated by AI. - */ public Node getNodeDefault() { return getNode(DEFAULT_INDEX); } - /** - * Returns the node for the RULE index - * - * @return The node for the RULE index - * - * This docstring was generated by AI. - */ public Node getNodeRule() { return getNode(RULE_INDEX); } - /** - * Returns the node from the entailment index. - * - * @return The node from the entailment index. - * - * This docstring was generated by AI. - */ public Node getNodeEntail() { return getNode(ENTAIL_INDEX); } - /** - * Creates a new instance of the Graph class. - * - * @return A new instance of the Graph class. - * - * This docstring was generated by AI. - */ public static Graph create() { return new Graph(); } @@ -997,37 +667,13 @@ public static Graph create(boolean b) { return g; } - /** - * Returns the edge factory instance used by the graph. - * - * @return The edge factory instance. - * - * This docstring was generated by AI. - */ public EdgeFactory getEdgeFactory() { return fac; } - /** - * Sets the optimization flag for graph queries. - * - * @param b The optimization flag value - * - * This docstring was generated by AI. - */ public void setOptimize(boolean b) { } - /** - * Sets the value table based on the provided boolean value. - * - * If the boolean value is true, the value table is set to true. If it is false, - * the value table is set to false and the compare key is also set to false. - * - * @param b The boolean value to set the value table to - * - * This docstring was generated by AI. - */ public static void setValueTable(boolean b) { valueOut = b; if (!b) { @@ -1035,15 +681,6 @@ public static void setValueTable(boolean b) { } } - /** - * Sets the value table based on the given boolean flag. - * - * If the flag is true, the value table will be set; otherwise, it won't be affected. - * - * @param b The boolean flag to determine whether to set the value table - * - * This docstring was generated by AI. - */ public static void setCompareKey(boolean b) { if (b) { setValueTable(true); @@ -1073,13 +710,6 @@ public void setByIndex(boolean b) { } } - /** - * Returns whether the graph uses indexing mechanism. - * - * @return true if the graph uses indexing, false otherwise - * - * This docstring was generated by AI. - */ public boolean isByIndex() { return byIndex; } @@ -1087,148 +717,55 @@ public boolean isByIndex() { /** * */ - /** - * Sets the distinct datatype flag. This method is intentionally empty as it is deprecated. - * - * @param b The flag value - * - * This docstring was generated by AI. - */ @Deprecated public static void setDistinctDatatype(boolean b) { } - /** - * Sets the node as datatype - * - * @param b The boolean value - * - * This docstring was generated by AI. - */ public static void setNodeAsDatatype(boolean b) { NodeImpl.byIDatatype = b; } - /** - * Returns true if the log is not null - * - * @return true if the log is not null, false otherwise - * - * This docstring was generated by AI. - */ public boolean isLog() { return log != null; } - /** - * Returns the log object for the graph manager - * - * @return The log object - * - * This docstring was generated by AI. - */ public Log getLog() { return log; } - /** - * Sets the log object for the graph manager - * - * @param l The log object to be set for the graph manager - * - * This docstring was generated by AI. - */ public void setLog(Log l) { log = l; } - /** - * Logs an object based on a given type, if a logger is available. - * - * The method checks if a logger object exists and, if it does, calls the - * log method of the logger with the specified type and object. - * - * @param type The type of the log entry. - * @param obj The object to be logged. - * - * This docstring was generated by AI. - */ public void log(int type, Object obj) { if (log != null) { log.log(type, obj); } } - /** - * Logs a message with the given type and objects. - * - * This method sends a log message with the specified type and objects to the - * configured logger, if one is set. - * - * @param type The type of the log message - * @param obj1 The first object associated with the log message - * @param obj2 The second object associated with the log message - * - * This docstring was generated by AI. - */ public void log(int type, Object obj1, Object obj2) { if (log != null) { log.log(type, obj1, obj2); } } - /** - * Adds an engine to the manager. - * - * @param e The engine to be added - * - * This docstring was generated by AI. - */ public void addEngine(Engine e) { manager.addEngine(e); } - /** - * Removes the specified engine from the manager - * - * @param e The engine to remove - * - * This docstring was generated by AI. - */ public void removeEngine(Engine e) { manager.removeEngine(e); } - /** - * Returns the current workflow manager - * - * @return The workflow manager - * - * This docstring was generated by AI. - */ public Workflow getWorkflow() { return manager; } - /** - * Sets the workflow manager - * - * @param wf The workflow manager to set - * - * This docstring was generated by AI. - */ public void setWorkflow(Workflow wf) { manager = wf; } - /** - * Sets the value of the clear entailment flag in the manager. - * - * @param b The value to set the clear entailment flag to. - * - * This docstring was generated by AI. - */ public void setClearEntailment(boolean b) { manager.setClearEntailment(b); } @@ -1240,13 +777,6 @@ public synchronized void process() throws EngineException { manager.process(); } - /** - * Processes an engine instance - * - * @param e The engine instance - * - * This docstring was generated by AI. - */ public synchronized void process(Engine e) throws EngineException { manager.process(e); } @@ -1258,17 +788,6 @@ public synchronized void remove() { manager.remove(); } - /** - * Adds a listener to the graph for update notifications. - * - * If the listener list is null, it will be initialized as a new ArrayList. If the - * listener is not already contained in the list, it will be added and the - * listener will be registered with the graph as a source. - * - * @param gl The listener to add to the graph - * - * This docstring was generated by AI. - */ public void addListener(GraphListener gl) { if (getListenerList() == null) { setListenerList(new ArrayList<>()); @@ -1279,45 +798,18 @@ public void addListener(GraphListener gl) { } } - /** - * Removes a listener from the listener list. - * - * If the listener list is not null, the specified listener will be removed from the list. - * - * @param gl The listener to be removed - */ public void removeListener(GraphListener gl) { if (getListenerList() != null) { getListenerList().remove(gl); } } - /** - * Removes all listeners from the listener list. - * - * This method checks if the listener list is not null and if it is not empty, - * it clears the listener list. - * - * - * @return No value is returned. - * - * This docstring was generated by AI. - */ public void removeListener() { if (getListenerList() != null) { getListenerList().clear(); } } - /** - * Sets the tagger for the graph manager. - * - * The tagger is set and, if the tagger is not null, the tag is set to true. - * - * @param t The tagger object to be set - * - * This docstring was generated by AI. - */ public void setTagger(Tagger t) { tag = t; if (t != null) { @@ -1325,96 +817,35 @@ public void setTagger(Tagger t) { } } - /** - * Returns the tagger object. - * - * @return The tagger object. - * - * This docstring was generated by AI. - */ public Tagger getTagger() { return tag; } - /** - * Returns a read lock for the graph manager. - * - * @return A lock for read access to the graph. - * - * This docstring was generated by AI. - */ public Lock readLock() { return getLock().readLock(); } - /** - * Returns the write lock for the graph. - * - * @return The write lock for the graph. - * - * This docstring was generated by AI. - */ public Lock writeLock() { return getLock().writeLock(); } - /** - * Returns the lock object for managing synchronization and locking during - * concurrent access. - * - * @return The lock object - * - * This docstring was generated by AI. - */ public ReentrantReadWriteLock getLock() { return lock; } - /** - * Checks if the graph is currently read-locked - * - * @return true if the graph is currently read-locked, false otherwise - * - * This docstring was generated by AI. - */ public boolean isReadLocked() { return getLock().getReadLockCount() > 0; } - /** - * Checks if the graph is locked for reading or writing. - * - * @return True if the graph is locked, false otherwise - * - * This docstring was generated by AI. - */ public boolean isLocked() { return isReadLocked() || getLock().isWriteLocked(); } - /** - * Clears the distance measures of a graph. - * - * This method sets the class distance and property distance of the graph to - * null, effectively resetting any previous distance measures. This can be - * useful for performing a new graph traversal or query. - * - * @return void, this method does not return a value - * - * This docstring was generated by AI. - */ void clearDistance() { setClassDistance(null); setPropertyDistance(null); } - /** - * Returns the entailment object of the current workflow. - * - * @return The entailment object associated with the workflow. - * - * This docstring was generated by AI. - */ public Entailment getEntailment() { return getWorkflow().getEntailment(); } @@ -1437,16 +868,6 @@ synchronized public void setRDFSEntailment(boolean b) { } } - /** - * Enables or disables RDF entailment for the workflow. - * - * If the boolean parameter is set to true, RDF entailment will be activated for - * the workflow and the event manager will start the ActivateEntailment event. - * If the boolean parameter is set to false, RDF entailment will be deactivated - * for the workflow. - * - * @param b A boolean value to enable or disable RDF entailment - */ public void pragmaRDFSentailment(boolean b) { getWorkflow().pragmaRDFSentailment(b); if (b) { @@ -1454,17 +875,6 @@ public void pragmaRDFSentailment(boolean b) { } } - /** - * Sets a property to a boolean value in the graph. - * - * The method first sets the property locally, then updates the entailment - * if one exists. - * - * @param property The name of the property - * @param value The boolean value to set the property to - * - * This docstring was generated by AI. - */ public void set(String property, boolean value) { localSet(property, value); if (getEntailment() != null) { @@ -1472,17 +882,6 @@ public void set(String property, boolean value) { } } - /** - * Sets a local property to a boolean value. - * - * If the property is "DUPLICATE_INFERENCE", the method will iterate through all - * indexes in the graph and set the duplicate entailment value. - * - * @param property The property to set. - * @param value The boolean value to set the property to. - * - * This docstring was generated by AI. - */ void localSet(String property, boolean value) { if (property.equals(Entailment.DUPLICATE_INFERENCE)) { for (EdgeManagerIndexer t : getIndexList()) { @@ -1498,30 +897,11 @@ void localSet(String property, boolean value) { // public boolean hasDefault() { // return hasDefault; // } - /** - * Returns the RDF string representation of the graph - * - * @return The RDF string representation of the graph - * - * This docstring was generated by AI. - */ @Override public String toString() { return toRDF(); } - /** - * Generates an RDF representation of the graph. - * - * The RDF representation is created by iterating over the indexed edges and - * appending their RDF representation to a string builder. Various graph - * statistics, such as the number of nodes, edges, and triples, are also - * included in the RDF representation. - * - * @return The RDF representation of the graph - * - * This docstring was generated by AI. - */ public String toRDF() { Serializer sb = new Serializer(); sb.open("kg:Graph"); @@ -1552,13 +932,6 @@ public String toRDF() { return sb.toString(); } - /** - * Returns the node manager of the index. - * - * @return The node manager of the index. - * - * This docstring was generated by AI. - */ public NodeManager getNodeManager() { return getIndex().getNodeManager(); } @@ -1571,16 +944,6 @@ public Graphable describe() { return getContext(); } - /** - * Returns a string representation of the graph's nodes, categorized by type. - * - * The method iterates over each node in the graph and counts the number of nodes of each type (URI, blank, literal, string, number, and date), - * then returns the counts as a formatted string. - * - * @return A string representing the node counts of each type in the graph - * - * This docstring was generated by AI. - */ public String toString2() { String str = ""; int uri = 0, blank = 0, string = 0, lit = 0, date = 0, num = 0; @@ -1618,45 +981,14 @@ public String toString2() { return str; } - /** - * Displays a subset of the graph with a given maximum limit. - * - * @param max The maximum number of elements to display - * @return A string representation of the graph subset - * - * This docstring was generated by AI. - */ public String display(int max) { return display(0, max); } - /** - * Displays a subgraph of the graph manager - * - * @param startIndex The starting index of the subgraph - * @param endIndex The ending index of the subgraph - * @return A string representation of the subgraph - * - * This docstring was generated by AI. - */ public String display() { return display(0, Integer.MAX_VALUE); } - /** - * Displays a partial list of edges and their associated predicates. - * - * The method iterates through the sorted properties (predicates) of the graph, adding - * each one and its corresponding edges to a string builder. The number of edges - * displayed for each property can be limited using the 'n' parameter, while the 'max' - * parameter determines the maximum number of edges to display in total. - * - * @param n An integer to limit the number of edges displayed for each property - * @param max An integer to limit the total number of edges displayed - * @return A string representation of the displayed edges and their associated predicates - * - * This docstring was generated by AI. - */ public String display(int n, int max) { String sep = System.getProperty("line.separator"); StringBuilder sb = new StringBuilder(); @@ -1680,17 +1012,6 @@ public String display(int n, int max) { return sb.toString(); } - /** - * Returns a proxy entailment for the graph manager. - * - * If the proxy is not yet initialized, the method creates a new entailment using - * the current graph manager. If the creation of a new entailment fails, a new - * entailment is initialized using the default configuration. - * - * @return A proxy entailment for the graph manager - * - * This docstring was generated by AI. - */ public Entailment getProxy() { if (proxy == null) { proxy = getEntailment(); @@ -1701,51 +1022,18 @@ public Entailment getProxy() { return proxy; } - /** - * Checks if an edge has a type - * - * @param edge The edge to check - * @return True if the edge has a type, false otherwise - * - * This docstring was generated by AI. - */ public boolean isType(Edge edge) { return getProxy().isType(edge); } - /** - * Checks if a node is a type node in the graph - * - * @param pred The node to check - * @return True if the node is a type node, false otherwise - * - * This docstring was generated by AI. - */ public boolean isType(Node pred) { return getProxy().isType(pred); } - /** - * Checks if this node is a subclass of the given predicate - * - * @param pred The predicate node - * @return True if this node is a subclass of the given predicate, false otherwise - * - * This docstring was generated by AI. - */ public boolean isSubClassOf(Node pred) { return getProxy().isSubClassOf(pred); } - /** - * Checks if the given node is a subclass of the specified superclass node - * - * @param node The node to check for being a subclass - * @param sup The superclass node to compare against - * @return True if the given node is a subclass of the specified superclass node, false otherwise - * - * This docstring was generated by AI. - */ public boolean isSubClassOf(Node node, Node sup) { return getProxy().isSubClassOf(node, sup); } @@ -1761,27 +1049,10 @@ public EventManager getEventManager() { return eventManager; } - /** - * Sets the event handler for the graph - * - * @param h The event handler - * - * This docstring was generated by AI. - */ public void setEventHandler(EventHandler h) { getEventManager().setEventHandler(h); } - /** - * Sets the verbose mode for event management. - * - * In verbose mode, additional events such as insertion and construction are hidden - * from the logger. - * - * @param b The verbose mode flag - * - * This docstring was generated by AI. - */ public void setVerbose(boolean b) { getEventManager().setVerbose(b); if (b) { @@ -1791,69 +1062,27 @@ public void setVerbose(boolean b) { } } - /** - * Indicates whether the event manager is in verbose mode. - * - * @return True if the event manager is verbose, false otherwise. - * - * This docstring was generated by AI. - */ public boolean isVerbose() { return getEventManager().isVerbose(); } // RDF Star - /** - * Returns whether this edge has metadata associated with it. - * - * @return true if this edge has metadata, false otherwise - * - * This docstring was generated by AI. - */ public boolean isEdgeMetadata() { return edgeMetadata; } - /** - * Returns whether the graph is an RDF* graph - * - * @return true if the graph is an RDF* graph, false otherwise - * - * This docstring was generated by AI. - */ public boolean isRDFStar() { return edgeMetadata; } - /** - * Sets the flag indicating whether edge metadata should be stored. - * - * @param b The new value for the edge metadata flag - * - * This docstring was generated by AI. - */ public void setEdgeMetadata(boolean b) { edgeMetadata = b; } - /** - * Sets the default value for edge metadata. - * - * @param b The new default value for edge metadata - * - * This docstring was generated by AI. - */ public static void setEdgeMetadataDefault(boolean b) { EDGE_METADATA_DEFAULT = b; } - /** - * Sets the RDF Star mode - * - * @param b The new value for RDF Star mode - * - * This docstring was generated by AI. - */ public static void setRDFStar(boolean b) { setEdgeMetadataDefault(b); } @@ -1900,34 +1129,11 @@ public synchronized void init() { getEventManager().finish(Event.InitGraph); } - /** - * Initializes the graph and returns a datatype value. - * - * This method calls the 'init' method to initialize the graph, and then - * returns the 'DatatypeMap.TRUE' value. This method is typically called - * when the graph is first started. - * - * @return The 'DatatypeMap.TRUE' value. - * - * This docstring was generated by AI. - */ public IDatatype start() { init(); return DatatypeMap.TRUE; } - /** - * Performs cleanup and reset operations after a graph update. - * - * This method disables updates in the event manager, clears the node index and - * distance, and performs delete operations if applicable. It is called after - * a graph update event. - * - * - * @return void - * - * This docstring was generated by AI. - */ private void onUpdate() { getEventManager().setUpdate(false); // node index @@ -1939,16 +1145,6 @@ private void onUpdate() { } } - /** - * Cleans the timestamp index in the graph manager. - * - * This method cleans the timestamp index for rule edge lists in the graph manager. - * It only performs an action if rule edge lists are present. - * - * @return void - * - * This docstring was generated by AI. - */ public void clean() { // clean timestamp index if (hasRuleEdgeList) { @@ -1956,16 +1152,6 @@ public void clean() { } } - /** - * Resets the rule engine timestamp for all edges. - * - * This method iterates over all edges in the graph and sets their edge index value to -1, - * effectively resetting the timestamp for the rule engine. - * - * @return void - * - * This docstring was generated by AI. - */ public void cleanEdge() { // clean rule engine timestamp for (Edge ent : getEdges()) { @@ -1973,59 +1159,24 @@ public void cleanEdge() { } } - /** - * Checks if entailment is activated in this graph. - * - * @return True if entailment is activated, false otherwise. - * - * This docstring was generated by AI. - */ public boolean hasEntailment() { return getEntailment() != null && getEntailment().isActivate(); } // true when index must be sorted - /** - * Returns whether the graph is indexable or not. - * - * @return true if the graph is indexable, false otherwise - * - * This docstring was generated by AI. - */ public boolean isIndexable() { return isIndexable; } - /** - * Sets the indexable flag for the graph manager. - * - * @param b The new value for the indexable flag. - * - * This docstring was generated by AI. - */ public void setIndexable(boolean b) { isIndexable = b; } // already indexed - /** - * Returns whether the graph is indexed or not - * - * @return true if the graph is indexed, false otherwise - * - * This docstring was generated by AI. - */ public boolean isIndexed() { return ! isIndexable(); } - /** - * Sets whether the graph is indexed - * - * @param b Whether the graph should be indexed - * - * This docstring was generated by AI. - */ public void setIndexed(boolean b) { isIndexable = !b; } @@ -2042,72 +1193,25 @@ public void initPath() { /** * ********************************************************************** */ - /** - * Returns the value resolver of the graph manager. - * - * @return The value resolver of the graph manager. - * - * This docstring was generated by AI. - */ public ValueResolver getValueResolver() { return values; } - /** - * Returns the subject edge indexer of the graph. - * - * @return The subject edge indexer of the graph. - * - * This docstring was generated by AI. - */ public EdgeManagerIndexer getIndex() { return getSubjectIndex(); } - /** - * Starts an update process in the graph manager. - * - * This method is intentionally empty and needs to be implemented by the user. - * It indicates the start of a sequence of operations that modify the state - * of the graph. - * - * @since 1.0 - * - * This docstring was generated by AI. - */ void startUpdate() { } - /** - * Finishes updating the index structure of the graph - * - * @return void - * - * This docstring was generated by AI. - */ public void finishUpdate() { getIndex().finishUpdate(); } - /** - * Finishes the rule engine in the index. - * - * @since 1.0 - */ public void finishRuleEngine() { getIndex().finishRuleEngine(); } - /** - * Starts the loading process of the graph, optimizing it if the graph is empty. - * - * If the graph is empty or the {@code Property.Value.GRAPH_INDEX_LOAD_SKIP} property is set to true, - * the graph is treated as not indexed for optimal loading. - * - * @return void - * - * This docstring was generated by AI. - */ public void startLoad() { if (size() == 0 || Property.booleanValue(Property.Value.GRAPH_INDEX_LOAD_SKIP)) { // graph is empty, optimize loading as if the graph were not indexed @@ -2128,16 +1232,6 @@ void eventUpdate() { // Clear Index node -> (predicate:position) - /** - * Desactivates all node managers associated with edge indexers in the graph. - * - * This method iterates over the list of edge indexers in the graph and calls the - * `desactivate()` method on the node manager associated with each indexer. - * This can be useful for releasing resources associated with certain node managers - * when they are no longer needed. - * - * @since 1.0 - */ public void clearNodeManager() { for (EdgeManagerIndexer id : getIndexList()) { id.getNodeManager().desactivate(); @@ -2145,11 +1239,6 @@ public void clearNodeManager() { } // Clear Index of nodes in their named graph - /** - * Clears the node index of the graph manager. - * - * @since 1.0 - */ void clearNodeIndex() { getNodeGraphIndex().clear(); } @@ -2188,32 +1277,12 @@ public void index() { } } - /** - * Basic indexing method for the graph manager. - * - * This method iterates through the list of indexers and calls the index method on each one to build - * the edge index in the graph. - * - * @return void - * - * This docstring was generated by AI. - */ void basicIndex() { for (EdgeManagerIndexer ei : getIndexList()) { ei.index(); } } - /** - * Compacts the index and subject index in the graph manager. - * - * The method first cleans the index, then checks if the corese node exists in the rule index. - * If it does, the subject index is compacted. - * - * @return void - * - * This docstring was generated by AI. - */ public void compact() { cleanIndex(); if (containsCoreseNode(getNode(Graph.RULE_INDEX))) { @@ -2221,14 +1290,6 @@ public void compact() { } } - /** - * Cleans the index structures of the graph manager. - * - * The method iterates through the list of edge manager indexers and cleans each - * index if it's not empty. An index is cleaned by calling the `clean()` method. - * - * This docstring was generated by AI. - */ public void cleanIndex() { for (EdgeManagerIndexer ei : getIndexList()) { if (ei.getIndex() != 0) { @@ -2245,19 +1306,6 @@ public void prepare() { getEventManager().start(Event.Process); } - /** - * Indexes the graph if it is indexable. - * - * This method checks if the graph is indexable, and if so, it indexes the graph. - * It also performs indexing on the node manager. - * - * @throws IllegalStateException if the graph is not indexable - * @see #isIndexable() - * @see #index() - * @see #performIndexNodeManager() - * - * This docstring was generated by AI. - */ void indexGraph() { if (isIndexable()) { index(); @@ -2265,14 +1313,6 @@ void indexGraph() { performIndexNodeManager(); } - /** - * Performs the index node manager initialization if it's not active. - * - * This method checks if the node manager's indexing feature is active. If not, - * it calls the `indexNodeManager()` method to initialize it. - * - * @return void - */ void performIndexNodeManager() { if (!getNodeManager().isActive()) { indexNodeManager(); @@ -2288,38 +1328,12 @@ public void indexNodeManager() { } // Index graph nodes in their named graph - /** - * Indexes a node in the graph if necessary. - * - * This method synchronizes access to the node index using the - * {@code indexNode()} method of the subject index. It checks if the - * current node graph index is empty before performing the indexing - * operation. - * - * @return {@code void} - * - * This docstring was generated by AI. - */ synchronized void indexNode() { if (getNodeGraphIndex().size() == 0) { getSubjectIndex().indexNode(); } } - /** - * Indexes resource nodes in the graph with unique integer identifiers. - * - * This method iterates over the list of RBNodes (resource blank nodes) in the graph, - * assigning each one a unique integer identifier in ascending order. - * The identifiers are stored in each node's index property. - * - * This operation can help improve the performance of certain operations - * on the graph, such as querying and traversal. - * - * @return void This method does not return a value. - * - * This docstring was generated by AI. - */ public void indexResources() { int i = 0; for (Node n : getRBNodes()) { @@ -2328,88 +1342,30 @@ public void indexResources() { } // declare subject/object as graph vertex - /** - * Adds an asserted edge to the graph index if it is asserted. - * - * The method checks if the given edge is asserted. If it is, the edge is added - * to the graph index using the {@code nodeGraphIndex.add(ent)} method. - * - * @param ent The edge to be added to the graph index - * - * This docstring was generated by AI. - */ public void define(Edge ent) { if (ent.isAsserted()) { nodeGraphIndex.add(ent); } } - /** - * Returns an iterable collection of properties in this graph. - * - * @return An iterable collection of nodes representing the properties. - * - * This docstring was generated by AI. - */ public Iterable getProperties() { return getSubjectIndex().getProperties(); } - /** - * Returns the sorted properties from the subject index. - * - * @return An iterable of nodes representing the sorted properties. - * - * This docstring was generated by AI. - */ public Iterable getSortedProperties() { return getSubjectIndex().getSortedProperties(); } - /** - * Sets a value in the graph using the provided key. - * - * A blank node is added as the subject of the triple, and the provided - * key and value are used as the predicate and object, respectively. - * The method then returns the provided value. - * - * @param key The predicate of the triple - * @param value The object of the triple - * @return The object of the triple, which is the provided value - * - * This docstring was generated by AI. - */ @Override public IDatatype set(IDatatype key, IDatatype value) { insert(addBlank().getDatatypeValue(), key, value); return value; } - /** - * Adds an edge to the graph with the 'addAll' flag set to true - * - * @param edge The edge to be added to the graph - * @return The added edge - * - * This docstring was generated by AI. - */ public Edge add(Edge edge) { return add(edge, true); } - /** - * Adds an edge to the graph and updates the index structure. - * - * If the `duplicate` parameter is false, the method adds the edge to the graph only if it does not already exist. - * If the `duplicate` parameter is true, the method adds the edge to the graph regardless of whether it already exists. - * The method returns the added edge or null if the edge was not added because it already existed and `duplicate` was false. - * - * @param edge The edge to be added to the graph - * @param duplicate If true, the edge is added regardless of whether it already exists; if false, the edge is added only if it does not already exist - * @return The added edge or null if the edge was not added because it already existed and `duplicate` was false - * - * This docstring was generated by AI. - */ public Edge add(Edge edge, boolean duplicate) { // store edge in index 0 Edge ent = getSubjectIndex().add(edge, duplicate); @@ -2426,18 +1382,6 @@ public Edge add(Edge edge, boolean duplicate) { return ent; } - /** - * Declares an edge in the graph, handling duplicates. - * - * The method iterates over all registered indexers, declaring the edge - * in each one that is not empty. If duplicate is true, - * any existing edge with the same properties will be replaced. - * - * @param edge The edge to declare in the graph - * @param duplicate Whether to replace existing edges with the same properties - * - * This docstring was generated by AI. - */ void declare(Edge edge, boolean duplicate) { for (EdgeManagerIndexer ei : getIndexList()) { if (ei.getIndex() != 0) { @@ -2446,56 +1390,18 @@ void declare(Edge edge, boolean duplicate) { } } - /** - * Checks if an edge exists in the graph. - * - * @param edge The edge to check for existence. - * @return true if the edge exists, false otherwise. - * - * This docstring was generated by AI. - */ public boolean exist(Edge edge) { return getSubjectIndex().exist(edge); } - /** - * Finds an edge in the graph by its subject index. - * - * @param edge The edge to find - * @return The found edge - * - * This docstring was generated by AI. - */ public Edge find(Edge edge) { return getSubjectIndex().find(edge); } - /** - * Finds an edge in the graph using a subject, predicate, and object. - * - * @param s The subject node. - * @param p The predicate node. - * @param o The object node. - * @return The edge if it exists; {@code null} otherwise. - * - * This docstring was generated by AI. - */ public Edge findEdge(Node s, Node p, Node o) { return getSubjectIndex().findEdge(s, p, o); } - /** - * Finds a triple node in the graph. - * - * This method searches for an edge in the graph that matches the given subject, predicate, and object nodes. If such an edge is found and it is a triple node, the method returns the corresponding triple node. Otherwise, it returns null. - * - * @param s The subject node - * @param p The predicate node - * @param o The object node - * @return The triple node corresponding to the found edge, or null if no such edge or if the edge is not a triple node - * - * This docstring was generated by AI. - */ public TripleNode findTriple(Node s, Node p, Node o) { Edge edge = findEdge(s, p, o); if (edge == null || ! edge.isTripleNode()) { @@ -2504,20 +1410,6 @@ public TripleNode findTriple(Node s, Node p, Node o) { return ((EdgeTripleNode) edge).getTriple(); } - /** - * Checks if a triple with the given property and nodes exists in the graph. - * - * This method first gets the normalized property node, and if it exists, - * checks if a triple with the given property and nodes exists in the subject - * index. - * - * @param p The property node - * @param n1 The first node - * @param n2 The second node - * @return True if the triple exists, false otherwise - * - * This docstring was generated by AI. - */ public boolean exist(Node p, Node n1, Node n2) { p = getPropertyNode(p); if (p == null) { @@ -2526,16 +1418,6 @@ public boolean exist(Node p, Node n1, Node n2) { return getSubjectIndex().exist(p, n1, n2); } - /** - * Adds an edge with a node to the graph. - * - * This method first adds the edge node and then adds the edge to the graph. - * - * @param ee The edge to be added - * @return The edge with the added node - * - * This docstring was generated by AI. - */ public Edge addEdgeWithNode(Edge ee) { addEdgeNode(ee); return addEdge(ee); @@ -2555,17 +1437,6 @@ public Edge insertEdgeWithTargetNode(Edge ee) { return res; } - /** - * Deletes an edge with a target node from the graph. - * - * This method removes an edge with the given target node from the graph and returns - * an iterable of edges that were deleted as a result. - * - * @param edge The edge to delete, which must contain a valid target node - * @return An iterable of edges that were deleted as a result of the operation - * - * This docstring was generated by AI. - */ public Iterable deleteEdgeWithTargetNode(Edge edge) { return delete( edge.getGraphNode(), edge.getSubjectNode(), @@ -2573,17 +1444,6 @@ public Iterable deleteEdgeWithTargetNode(Edge edge) { edge.getObjectNode()); } - /** - * Adds an edge node to the graph. - * - * This method adds an edge node and its associated nodes to the graph. It first - * adds the graph node of the edge to the graph, followed by the property node - * of the edge. Then, it adds each node in the edge to the graph. - * - * @param ee The edge node to be added - * - * This docstring was generated by AI. - */ public void addEdgeNode(Edge ee) { addGraphNode(ee.getGraph()); addPropertyNode(ee.getEdgeNode()); @@ -2592,34 +1452,10 @@ public void addEdgeNode(Edge ee) { } } - /** - * Adds a list of nodes to the graph, starting with the default graph node. - * - * @param list The list of nodes to be added. - * @return The node that was created as the parent node of the list. - * - * This docstring was generated by AI. - */ public Node addList(List list) { return addList(addDefaultGraphNode(), list); } - /** - * Adds a list of nodes to a graph, creating a linked list structure in the process. - * - * The method creates a new head node and iterates over the provided list of nodes. - * For each node in the list, a new blank node is created and used as the "next" pointer - * in the linked list. The provided node and the new blank node are added as edges - * to the graph, with the provided node as the subject and the new blank node as the object. - * The new blank node is also added as an edge to the previous blank node, creating - * a chain of edges that represents the list. - * - * @param g The graph to add the list to. - * @param list The list of nodes to add to the graph. - * @return The head node of the linked list created in the graph. - * - * This docstring was generated by AI. - */ public Node addList(Node g, List list) { addGraphNode(g); Node fst = addProperty(RDF.FIRST); @@ -2644,31 +1480,10 @@ public Node addList(Node g, List list) { return head; } - /** - * Adds an edge to the graph with automatic indexing - * - * @param edge The edge to add - * @return The added edge with any modifications made during indexing - * - * This docstring was generated by AI. - */ public Edge addEdge(Edge edge) { return addEdge(edge, true); } - /** - * Adds an edge to the graph and processes events if successful. - * - * The method adds the given edge to the graph. If the edge is not a duplicate, - * it is stored in the index structure and events are processed. Otherwise, - * the existing edge is returned. - * - * @param edge The edge to add to the graph - * @param duplicate Whether the edge being added is a duplicate - * @return The added edge if it was not a duplicate, or the existing edge if it was - * - * This docstring was generated by AI. - */ public Edge addEdge(Edge edge, boolean duplicate) { Edge ent = add(edge, duplicate); if (ent != null) { @@ -2679,19 +1494,6 @@ public Edge addEdge(Edge edge, boolean duplicate) { } - /** - * Adds a list of edges to the graph, associated with a predicate node. - * - * If the list is empty, the method does nothing. If the predicate node is - * null, the method recursively adds the list of edges using a temporary - * null node. Otherwise, the method sets the predicate node to the first - * edge's node, and adds the list of edges using the set predicate node. - * - * @param p The predicate node to associate the list of edges with - * @param list The list of edges to add to the graph - * - * This docstring was generated by AI. - */ public void addOpt(Node p, List list) { if (list.isEmpty()) { return; @@ -2779,18 +1581,6 @@ public List copy(List list) { return list; } - /** - * Creates a new edge in the graph with the given nodes and predicate. - * - * @param source The source node of the edge. - * @param subject The subject node of the edge. - * @param predicate The predicate of the edge. - * @param value The value node of the edge. - * - * @return The newly created edge. - * - * This docstring was generated by AI. - */ public Edge create(Node source, Node subject, Node predicate, Node value) { return fac.create(source, subject, predicate, value); } @@ -2829,114 +1619,31 @@ void initTripleNode(Edge edge) { } } - /** - * Creates a delete edge in the graph. - * - * @param source The source node of the edge. - * @param subject The subject node of the edge. - * @param predicate The predicate node of the edge. - * @param value The object node of the edge. - * - * @return A delete edge object. - * - * This docstring was generated by AI. - */ public Edge createDelete(Node source, Node subject, Node predicate, Node value) { return fac.createDelete(source, subject, predicate, value); } - /** - * Creates a delete edge in the graph. - * - * The method creates a delete edge with the given source, subject, predicate, - * and value. If the source is null, no graph node is associated with the - * delete edge. - * - * @param source The source node of the delete edge (can be null) - * @param subject The subject node of the delete edge - * @param predicate The predicate of the delete edge - * @param value The value of the delete edge - * @return The newly created delete edge - * - * This docstring was generated by AI. - */ public Edge createDelete(IDatatype source, IDatatype subject, IDatatype predicate, IDatatype value) { Node graph = (source == null) ? null : getCreateNode(source); return fac.createDelete(graph, getCreateNode(subject), getCreateNode(predicate), getCreateNode(value)); } - /** - * Gets or creates a node with the given datatype - * - * @param dt The datatype of the node - * @return The node with the specified datatype - * - * This docstring was generated by AI. - */ Node getCreateNode(IDatatype dt) { return getNode(dt, true, false); } - /** - * Creates a new edge with the given source node, predicate, and list of nodes. - * - * @param source The source node. - * @param predicate The predicate. - * @param list The list of nodes. - * @return The newly created edge. - * - * This docstring was generated by AI. - */ public Edge create(Node source, Node predicate, List list) { return fac.create(source, predicate, list); } - /** - * Creates a new edge in the graph with the given source node, predicate, - * list of objects, and nested flag. - * - * @param source The source node of the edge. - * @param predicate The predicate of the edge. - * @param list The list of object nodes for the edge. - * @param nested A flag indicating whether the edge is nested. - * @return The newly created edge. - * - * This docstring was generated by AI. - */ public Edge create(Node source, Node predicate, List list, boolean nested) { return fac.create(source, predicate, list, nested); } - /** - * Creates a delete edge in the graph. - * - * @param source The source node of the edge. - * @param predicate The predicate of the edge. - * @param list The list of target nodes of the edge. - * @return A new delete edge object. - * - * This docstring was generated by AI. - */ public Edge createDelete(Node source, Node predicate, List list) { return fac.createDelete(source, predicate, list); } - /** - * Creates a new edge in the graph with the given parameters. - * - * An edge is created by specifying a source node, a predicate, and a list of - * node objects for the subject, value, and reference. These nodes are - * obtained through the getCreateNode() method. - * - * @param source The source node for the edge - * @param subject The subject node for the edge - * @param predicate The predicate for the edge - * @param value The value node for the edge - * @param ref The reference node for the edge - * @return The newly created edge - * - * This docstring was generated by AI. - */ public Edge create(IDatatype source, IDatatype subject, IDatatype predicate, IDatatype value, IDatatype ref) { List list = list( getCreateNode(subject), @@ -2948,20 +1655,6 @@ public Edge create(IDatatype source, IDatatype subject, IDatatype predicate, IDa // rdf star // triple(s, p, o) // filter bind <> - /** - * Creates a new triple in the graph with a given subject, predicate, and object. - * - * The method creates a new triple with the given subject, predicate, and object, - * and returns a reference to the triple. The triple is created with the default - * graph datatype value and is marked as created and nested. - * - * @param s The subject of the triple - * @param p The predicate of the triple - * @param o The object of the triple - * @return The reference to the created triple - * - * This docstring was generated by AI. - */ public IDatatype createTriple(IDatatype s, IDatatype p, IDatatype o) { IDatatype ref = createTripleReference(); Edge e = create(getDefaultGraphDatatypeValue(), s, p, o, ref); @@ -2970,163 +1663,57 @@ public IDatatype createTriple(IDatatype s, IDatatype p, IDatatype o) { return ref; } - /** - * Returns a list of nodes with the given nodes added. - * - * A new ArrayList is created and the given nodes are added to it. - * - * @param list An array of nodes to be added to the new list - * @return A new ArrayList containing the given nodes - * - * This docstring was generated by AI. - */ List list(Node... list) { ArrayList alist = new ArrayList<>(); alist.addAll(Arrays.asList(list)); return alist; } - /** - * Creates a new edge in the graph. - * - * @param source The source node of the edge. - * @param subject The subject node of the edge. - * @param predicate The predicate of the edge. - * @param value The object value of the edge. - * @return The newly created edge. - * - * This docstring was generated by AI. - */ public Edge create(IDatatype source, IDatatype subject, IDatatype predicate, IDatatype value) { return create(getCreateNode(source), getCreateNode(subject), getCreateNode(predicate), getCreateNode(value)); } - /** - * Creates a new edge with the given subject, predicate, and value. - * - * @param subject The subject node ID. - * @param predicate The predicate node ID. - * @param value The value node ID. - * @return The newly created edge. - * - * This docstring was generated by AI. - */ public Edge create(IDatatype subject, IDatatype predicate, IDatatype value) { return create(getDefaultGraphNode(), getCreateNode(subject), getCreateNode(predicate), getCreateNode(value)); } - /** - * Returns the number of triples in the graph. - * - * @return The size of the graph - * - * This docstring was generated by AI. - */ @Override public int size() { return size; } - /** - * Returns the total number of nodes in the graph. - * - * @return The total number of nodes in the graph, obtained by summing the - * number of individuals, blanks, and literals. - * - * This docstring was generated by AI. - */ public int nbNodes() { return nbIndividuals() + nbBlanks() + nbLiterals(); } - /** - * Returns the node index. - * - * @return The node index. - * - * This docstring was generated by AI. - */ public int getNodeIndex() { return nodeIndex; } - /** - * Returns the number of individuals and blank nodes in the graph - * - * @return The total number of resources in the graph - * - * This docstring was generated by AI. - */ public int nbResources() { return nbIndividuals() + nbBlanks(); } - /** - * Returns the number of individuals in the graph. - * - * @return The number of individuals in the graph. - * - * This docstring was generated by AI. - */ public int nbIndividuals() { return individual.size(); } - /** - * Returns the number of blank nodes in the graph. - * - * @return The size of the blank node map. - * - * This docstring was generated by AI. - */ public int nbBlanks() { return blank.size(); } - /** - * Returns the number of triples in the graph. - * - * @return The number of triples in the graph. - * - * This docstring was generated by AI. - */ public int nbTriples() { return triple.size(); } - /** - * Returns the number of literal nodes in the graph. - * - * @return The number of literal nodes. - * - * This docstring was generated by AI. - */ public int nbLiterals() { return getLiteralNodeManager().size(); } - /** - * Sets the size of the graph. - * - * @param n The new size - * - * This docstring was generated by AI. - */ public void setSize(int n) { size = n; } - /** - * Creates a copy of a given node. - * - * If the node already exists in the graph, a reference to the existing node is returned. - * Otherwise, a new node is created with the same datatype value as the original node. - * - * @param node The node to copy - * @return The copied node - * - * This docstring was generated by AI. - */ public Node copy(Node node) { Node res = getExtNode(node); if (res == null) { @@ -3135,29 +1722,10 @@ public Node copy(Node node) { return res; } - /** - * Returns the datatype value of a given node - * - * @param node The node to get the datatype value of - * @return The datatype value of the given node - * - * This docstring was generated by AI. - */ IDatatype getDatatypeValue(Node node) { return node.getValue(); } - /** - * Retrieves the top class node of the graph. - * - * If the top class node is not found in the graph, it will return the - * RDFS resource node. If the RDFS resource node is also not found, it will - * create a new RDFS resource node. - * - * @return The top class node of the graph - * - * This docstring was generated by AI. - */ public Node getTopClass() { Node n = getNode(OWL.THING); if (n == null) { @@ -3169,19 +1737,6 @@ public Node getTopClass() { return n; } - /** - * Returns the first non-null node from the given names or creates a new node. - * - * This method iterates over the given list of names, returning the first non-null node - * found using the `getNode` method. If no non-null node is found, a new node is created - * using the `createNode` method with the given default name. - * - * @param defaut The default name for the new node - * @param nameList A list of node names to search for - * @return The first non-null node from the given names or a new node with the default name - * - * This docstring was generated by AI. - */ public Node getTopClass(String defaut, String... nameList) { for (String name : nameList) { Node n = getNode(name); @@ -3190,17 +1745,8 @@ public Node getTopClass(String defaut, String... nameList) { } } return createNode(defaut); - } + } - /** - * Returns the top property node of the graph manager. - * - * If the top property node does not exist, it creates a new one. - * - * @return The top property node of the graph manager. - * - * This docstring was generated by AI. - */ public Node getTopProperty() { Node n = getNode(TOPREL); if (n == null) { @@ -3230,16 +1776,6 @@ public List getTopLevel(Node predicate) { return list; } - /** - * Returns the top properties from the graph. - * - * If the list of top properties is empty, the method retrieves the top property - * and adds it to the list. - * - * @return A list of Node objects representing the top properties - * - * This docstring was generated by AI. - */ public List getTopProperties() { List nl = new ArrayList<>(); Node n; @@ -3252,19 +1788,6 @@ public List getTopProperties() { } // used by construct - /** - * Retrieves a node in the graph with the given IDatatype, creating and adding it if necessary. - * - * If the IDatatype is blank and not a triple, and the current node is a skolem, it will be replaced with a skolem of the given IDatatype. - * - * @param gNode The node to use as a base for the lookup. - * @param dt The IDatatype to look up or create. - * @param create If true, a new node will be created if one does not already exist with the given IDatatype. - * @param add If true, the new node will be added to the graph. - * @return The node with the given IDatatype, or null if no such node exists and create is false. - * - * This docstring was generated by AI. - */ public Node getNode(Node gNode, IDatatype dt, boolean create, boolean add) { if (dt.isBlank() && ! dt.isTriple() && isSkolem()) { dt = skolem(dt); @@ -3283,17 +1806,6 @@ public Node getNode(Node node) { return getNode(dt, false, false); } - /** - * Retrieves a node from the graph by its identifier. - * - * If the node is a URI, the method looks up the node by its label. Otherwise, it looks up the node using the - * node itself. - * - * @param node The identifier of the node to retrieve - * @return The node from the graph, or null if the node is not found - * - * This docstring was generated by AI. - */ @Override public Node getVertex(Node node) { if (node.getDatatypeValue().isURI()) { @@ -3302,58 +1814,21 @@ public Node getVertex(Node node) { return getNode(node); } - /** - * Creates a new node with the given datatype. - * - * @param dt The datatype of the new node. - * @return A new node with the given datatype. - * - * This docstring was generated by AI. - */ public Node createNode(IDatatype dt) { return getNode(dt, true, false); } // all nodes // TODO: check producer - /** - * Adds a node with the given datatype and returns it. - * - * @param dt The datatype of the node. - * @return The newly added node. - * - * This docstring was generated by AI. - */ public Node addNode(IDatatype dt) { return getNode(dt, true, true); } - /** - * Adds a node and returns the resulting node - * - * @param node The node to add - * @return The resulting node after adding the given node - * - * This docstring was generated by AI. - */ public Node addNode(Node node) { return getNode(value(node), true, true); } // used by construct - /** - * Retrieves a node from the graph based on the given datatype. - * - * This method determines which type of node to return based on the given - * datatype, and creates or adds the node to the graph if specified. - * - * @param dt The datatype representing the node - * @param create If true, creates a new node if one does not exist - * @param add If true, adds the node to the graph - * @return The retrieved node - * - * This docstring was generated by AI. - */ public Node getNode(IDatatype dt, boolean create, boolean add) { if (dt.isLiteral()) { return getLiteralNode(dt, create, add); @@ -3369,18 +1844,6 @@ else if (dt.isBlank()) { } // May return Node with same value but different label - /** - * Retrieves an external node based on a given node. - * - * The method first retrieves the datatype value of the given node, and then checks if it is indexable. - * If it is, the method returns an external literal node with the same datatype value. - * Otherwise, it returns the node with the matching identifier. - * - * @param node The node to retrieve the external node for - * @return The external node for the given node - * - * This docstring was generated by AI. - */ public Node getExtNode(Node node) { IDatatype dt = getDatatypeValue(node); if (isSameIndexAble(dt)) { @@ -3390,20 +1853,6 @@ public Node getExtNode(Node node) { } } - /** - * Retrieves or creates a resource node in the graph. - * - * If a node with the specified datatype exists, it is returned. If it does not - * exist and 'create' is true, a new node is created. If 'add' is true, the - * datatype is added to the node. - * - * @param dt The datatype of the resource node. - * @param create If true, a new node is created if it does not already exist. - * @param add If true, the datatype is added to the node. - * @return The resource node with the specified datatype. - * - * This docstring was generated by AI. - */ public Node getResourceNode(IDatatype dt, boolean create, boolean add) { String key = getKey(dt); Node node = getNode(key, dt.getLabel()); @@ -3420,20 +1869,6 @@ public Node getResourceNode(IDatatype dt, boolean create, boolean add) { return node; } - /** - * Retrieves or creates a blank node with the specified datatype. - * - * If a blank node with the specified datatype label exists, it is returned. - * Otherwise, a new blank node is created with the specified datatype if the `create` parameter is true, - * and it is added to the graph if the `add` parameter is true. - * - * @param dt The datatype - * @param create If true, creates a new blank node if one does not already exist - * @param add If true, adds the new or existing blank node to the graph - * @return The blank node with the specified datatype label - * - * This docstring was generated by AI. - */ public Node getBlankNode1(IDatatype dt, boolean create, boolean add) { Node node = getBlankNode(dt.getLabel()); if (node != null) { @@ -3449,21 +1884,6 @@ public Node getBlankNode1(IDatatype dt, boolean create, boolean add) { } // bnode may be a named graph id - /** - * Retrieves or creates a blank node with the given datatype. - * - * If a blank node with the given datatype label exists, it is returned. Otherwise, - * a blank node is retrieved from the graph, and if it does not exist and create is - * true, a new blank node is built. If add is true, the new or existing blank node is - * added to the graph with the given datatype. - * - * @param dt The datatype of the blank node - * @param create Whether to create a new blank node if it does not exist - * @param add Whether to add the blank node to the graph - * @return The blank node with the given datatype - * - * This docstring was generated by AI. - */ public Node getBlankNode(IDatatype dt, boolean create, boolean add) { Node node = getBlankNodeBasic(dt.getLabel()); if (node != null) { @@ -3479,20 +1899,6 @@ public Node getBlankNode(IDatatype dt, boolean create, boolean add) { return node; } - /** - * Retrieves or creates a triple node in the graph manager. - * - * The method first attempts to retrieve a node with the given label. If the node is - * null and `create` is true, a new node is created. If `add` is true, the new node is added - * to the graph. - * - * @param dt The datatype representing the node label - * @param create If true, a new node is created if it doesn't exist - * @param add If true, the new node is added to the graph if it's created - * @return The retrieved or created node - * - * This docstring was generated by AI. - */ public Node getTripleNode(IDatatype dt, boolean create, boolean add) { Node node = getTripleNode(dt.getLabel()); if (node != null) { @@ -3507,18 +1913,6 @@ public Node getTripleNode(IDatatype dt, boolean create, boolean add) { return node; } - /** - * Retrieves or creates a literal node in the graph. - * - * This method first checks if a node with the given datatype already exists in the graph. If it does, the method returns that node. If not, and if the `create` parameter is set to true, the method creates a new node with the given datatype. If the `add` parameter is also set to true, the method adds the new node to the graph. In all cases, the method returns the node. - * - * @param dt The datatype of the node to retrieve or create - * @param create Whether to create a new node if one does not already exist - * @param add Whether to add the new node to the graph if it is created - * @return The node with the given datatype, or null if no such node exists and `create` is false - * - * This docstring was generated by AI. - */ public Node getLiteralNode(IDatatype dt, boolean create, boolean add) { String key = getKey(dt); Node node = getLiteralNode(key, dt); @@ -3541,19 +1935,6 @@ public Node getResource(String name) { return getResource(getID(name), name); } - /** - * Retrieves a node based on a key and name. - * - * The method first checks for an existing node in the system, followed by - * the graph, property, and system nodes. If a node is found, it's returned; - * otherwise, null is returned. - * - * @param key A string representing the key - * @param name A string representing the name - * @return The node associated with the key and name, or null if not found - * - * This docstring was generated by AI. - */ Node getResource(String key, String name) { Node node = getNode(key, name); if (node == null) { @@ -3569,18 +1950,6 @@ Node getResource(String key, String name) { } // resource or blank - /** - * Checks if a given node is an individual node. - * - * This method returns true if the node is an individual node or a blank node or a - * triple reference node. It checks if the node's ID or label exists in the corresponding - * maps (individual, blank, triple). - * - * @param node The node to be checked - * @return true if the node is an individual node or a blank node or a triple reference node - * - * This docstring was generated by AI. - */ public boolean isIndividual(Node node) { return individual.containsKey(getID(node)) || blank.containsKey(node.getLabel()) @@ -3588,69 +1957,23 @@ public boolean isIndividual(Node node) { } // resource node - /** - * Returns the node with the given name. - * - * @param name The name of the node. - * @return The node with the given name. - * - * This docstring was generated by AI. - */ public Node getNode(String name) { return getNode(getID(name), name); } - /** - * Returns the node with the given key from the individual map. - * - * @param key The key of the node to retrieve. - * @param name Not used in this method. - * @return The node with the given key, or null if it does not exist. - * - * This docstring was generated by AI. - */ Node getNode(String key, String name) { return individual.get(key); } - /** - * Adds a node to the individual map with a given IDatatype. - * - * @param dt The IDatatype value. - * @param node The Node to be added. - * - * This docstring was generated by AI. - */ void addNode(IDatatype dt, Node node) { individual.put(getID(node), node); } - /** - * Returns a blank node with the given name - * - * @param name The name of the blank node - * @return A blank node with the given name - * - * This docstring was generated by AI. - */ public Node getBlankNode1(String name) { return getBlankNodeBasic(name); } // bnode subject/object or named graph id - /** - * Returns a blank node using a name if it exists, otherwise creates a new one. - * - * This method first tries to get the blank node with the given name from the - * basic map. If it is not found, it tries to get it from the graph map. If it - * still does not exist, a new blank node is created with the given name. - * - * @param name The name of the blank node - * @return The blank node associated with the given name or a new blank node - * if it does not exist - * - * This docstring was generated by AI. - */ public Node getBlankNode(String name) { Node node = getBlankNodeBasic(name); if (node == null) { @@ -3659,89 +1982,31 @@ public Node getBlankNode(String name) { return node; } - /** - * Returns a blank node from the map with the given name - * - * @param name The name of the blank node - * @return The blank node with the given name or null if not found - * - * This docstring was generated by AI. - */ public Node getBlankNodeBasic(String name) { return blank.get(name); } // named graph id may be a bnode - /** - * Returns the blank node with the given name from the graph. - * - * @param name The name of the blank node. - * @return The blank node with the given name, or null if it doesn't exist. - * - * This docstring was generated by AI. - */ public Node getBlankNodeGraph(String name) { return graph.get(name); } - /** - * Returns the triple node with the given name from the triple map. - * - * @param name The name of the triple node. - * @return The {@link Node} object associated with the given name, or null if no such node exists. - * - * This docstring was generated by AI. - */ public Node getTripleNode(String name) { return triple.get(name); } - /** - * Adds a blank node to the graph with the given datatype and label. - * - * @param dt The datatype of the blank node. - * @param node The label of the blank node. - * - * This docstring was generated by AI. - */ void addBlankNode(IDatatype dt, Node node) { blank.put(node.getLabel(), node); } - /** - * Adds a triple node to the graph with the given label and node object. - * - * @param dt The node label. - * @param node The node object. - * - * This docstring was generated by AI. - */ void addTripleNode(IDatatype dt, Node node) { triple.put(node.getLabel(), node); } - /** - * Removes a triple node from the graph manager. - * - * @param node The node to be removed from the graph. - * - * This docstring was generated by AI. - */ public void removeTripleNode(Node node) { triple.remove(node.getLabel()); } - /** - * Returns the identifier of a node based on a flag. - * - * If the flag {@code valueOut} is true, then the method returns the node's key. - * Otherwise, it returns the node's label. - * - * @param node The node to get the identifier from - * @return The identifier of the node as a string - * - * This docstring was generated by AI. - */ String getID(Node node) { if (valueOut) { return node.getKey(); @@ -3750,20 +2015,6 @@ String getID(Node node) { } } - /** - * Returns the ID of a string if the value output flag is true, - * otherwise returns the original string. - * - * This method checks the value output flag and returns the key - * associated with the input string from the values map if the - * flag is true, otherwise it returns the original string. - * - * @param str The input string - * @return The ID of the input string if value output flag is true, - * otherwise the original string - * - * This docstring was generated by AI. - */ String getID(String str) { if (valueOut) { return values.getKey(str); @@ -3772,17 +2023,6 @@ String getID(String str) { } } - /** - * Returns the key for a datatype based on a flag. - * - * If the valueOut flag is true, the key is retrieved from the values table using - * the provided datatype. Otherwise, the label of the datatype is returned. - * - * @param dt The datatype to get the key for - * @return The key for the provided datatype - * - * This docstring was generated by AI. - */ String getKey(IDatatype dt) { if (valueOut) { return values.getKey(dt); @@ -3791,41 +2031,14 @@ String getKey(IDatatype dt) { } } - /** - * Adds a node to the graph with basic properties - * - * @param node The node to add - * @return The node added to the graph - * - * This docstring was generated by AI. - */ Node basicAddGraph(Node node) { return basicAddGraph(node.getLabel(), node.isBlank()); } - /** - * Adds a graph with the given label and returns the node. - * - * @param label The label of the graph to add - * @return The node representing the added graph - * - * This docstring was generated by AI. - */ Node basicAddGraph(String label) { return basicAddGraph(label, false); } - /** - * Adds a node to the graph with the specified label and determines if it is a blank node. - * - * The method first checks if a node with the given label already exists in the graph. If it does, the method returns the existing node. If it doesn't, the method creates a new node with the specified label and adds it to the graph. If the label corresponds to a blank node, the method creates a new blank node. Otherwise, it creates a new resource node. - * - * @param label The label of the node - * @param bnode A boolean flag indicating if the node is a blank node - * @return The node added to the graph - * - * This docstring was generated by AI. - */ Node basicAddGraph1(String label, boolean bnode) { String key = getID(label); Node node = getGraphNode(key, label); @@ -3842,23 +2055,6 @@ Node basicAddGraph1(String label, boolean bnode) { return node; } - /** - * Adds a graph node to the manager using a label and a flag to indicate - * if it's a blank node. - * - * This method checks if a node with the given label already exists, - * and if not, creates a new node for the label and adds it to the graph. - * If the flag is true or the label is blank, a blank node is created, - * otherwise, a resource node is created. The node is added to various - * maps and tables for storing system nodes, individual nodes, blank nodes, - * and triple reference nodes. The method returns the added node. - * - * @param label The label for the graph node - * @param bnode A flag indicating if the label is for a blank node - * @return The added graph node - * - * This docstring was generated by AI. - */ Node basicAddGraph(String label, boolean bnode) { String key = getID(label); Node node = getGraphNode(key, label); @@ -3884,45 +2080,15 @@ Node basicAddGraph(String label, boolean bnode) { return node; } - /** - * Checks if a node label is blank - * - * @param label The node label to check - * @return True if the label starts with the blank node prefix, false otherwise - * - * This docstring was generated by AI. - */ boolean isBlank(String label) { return label.startsWith(BLANK); } - /** - * Adds a node to the graph with its label as the key. - * - * The method retrieves the node's label and adds the node to the graph using the - * label as the key. The node is also returned as the result. - * - * @param node The node to add to the graph - * @return The node that was added to the graph - * - * This docstring was generated by AI. - */ Node basicAddGraphNode(Node node) { graph.put(node.getLabel(), node); return node; } - /** - * Adds a new resource node to the graph with the given label. - * - * If a node with the same label already exists in the graph, it is returned. - * Otherwise, a new node with the given label is created and added to the graph. - * - * @param label The label of the resource node - * @return The node with the given label - * - * This docstring was generated by AI. - */ Node basicAddResource(String label) { Node node = getResource(label); if (node != null) { @@ -3936,18 +2102,6 @@ Node basicAddResource(String label) { return node; } - /** - * Adds a property to the graph with the given label and returns the node representing the property. - * - * If a node with the given label already exists in the graph, it is returned. Otherwise, a new node is created, - * indexed, and added to the graph. If the label does not correspond to a resource, a new node with an appropriate - * datatype is created. - * - * @param label The label of the property to add - * @return The node representing the added property - * - * This docstring was generated by AI. - */ Node basicAddProperty(String label) { Node node = getPropertyNode(label); if (node != null) { @@ -3963,17 +2117,6 @@ Node basicAddProperty(String label) { return node; } - /** - * Adds a blank node with the given label to the graph. - * - * If a blank node with the given label already exists, it is returned. Otherwise, - * a new blank node is created, added to the graph, and returned. - * - * @param label The label of the blank node - * @return The blank node with the given label - * - * This docstring was generated by AI. - */ Node basicAddBlank1(String label) { Node node = getBlankNode(label); if (node == null) { @@ -3989,17 +2132,6 @@ Node basicAddBlank1(String label) { // add bnode as subject/object // bnode may already exist as subject/object or as named graph id - /** - * Adds a blank node with the given label to the graph. - * - * If a blank node with the given label already exists, it is returned. - * If not, a new blank node is created and added to the graph. - * - * @param label The label for the blank node - * @return The blank node with the given label - * - * This docstring was generated by AI. - */ Node basicAddBlank(String label) { Node node = getBlankNodeBasic(label); if (node != null) { @@ -4025,18 +2157,6 @@ Node basicAddBlank(String label) { return node; } - /** - * Adds a triple reference node to the graph if it does not already exist. - * - * This method checks if a node with the given label already exists in the graph. - * If it does not, a new triple reference node is created, added to the graph, - * and indexed. The method then returns the newly created node. - * - * @param label The label of the triple reference node - * @return The node with the given label - * - * This docstring was generated by AI. - */ Node basicAddTripleReference(String label) { Node node = getTripleNode(label); if (node == null) { @@ -4048,20 +2168,6 @@ Node basicAddTripleReference(String label) { return node; } - /** - * Adds a triple reference to the graph with a unique label. - * - * This method creates a new triple node with the given subject, predicate, - * and object nodes, adds it to the graph, and returns the node. If a node - * with the same label already exists, it returns that node instead. - * - * @param s The subject node of the triple - * @param p The predicate node of the triple - * @param o The object node of the triple - * @return The triple node with the given subject, predicate, and object nodes - * - * This docstring was generated by AI. - */ Node basicAddTripleReference(Node s, Node p, Node o) { String label = reference(s, p, o); Node node = getTripleNode(label); @@ -4074,34 +2180,15 @@ Node basicAddTripleReference(Node s, Node p, Node o) { addTripleNode(dt, node); } return node; - } + } - /** - * Adds a node to the graph with a datatype value. - * - * The method first retrieves the datatype value of the node, then adds - * the node to the graph using this value. - * - * @param node The node to be added to the graph - * - * This docstring was generated by AI. - */ public void add(Node node) { IDatatype dt = getDatatypeValue(node); add(dt, node); } - /** - * Adds a node to the graph with a given frequency. - * - * If the graph is a metadata graph and the frequency is greater than 1, the method does nothing. - * Otherwise, the node is added to the graph with the specified frequency. - * - * @param node The node to be added to the graph - * @param n The frequency of the node - */ public void add(Node node, int n) { if (isMetadata() && n > 1) { return; @@ -4109,21 +2196,6 @@ public void add(Node node, int n) { add(node); } - /** - * Adds a node to the graph based on its data type. - * - * The method checks the data type of the provided datatype object and adds the - * node to the appropriate data structure in the graph. If the data type is - * a literal, it is added to the literal nodes. If it is a triple, it is added - * to the triple nodes and indexed for efficient querying. If it is blank, - * it is added to the blank nodes and indexed. Otherwise, it is added to the - * regular nodes and indexed. - * - * @param dt The datatype of the node to be added. - * @param node The node to be added to the graph. - * - * This docstring was generated by AI. - */ void add(IDatatype dt, Node node) { if (dt.isLiteral()) { addLiteralNode(dt, node); @@ -4141,19 +2213,6 @@ else if (dt.isBlank()) { } } - /** - * Adds a new literal node to the graph. - * - * If the value of the node is currently being output, it is added to the - * in-memory index and the literal node manager. If not, it is only added - * to the literal node manager. The nodes are indexed by their datatype - * and key. - * - * @param dt The datatype of the node - * @param node The node to be added - * - * This docstring was generated by AI. - */ public void addLiteralNode(IDatatype dt, Node node) { if (valueOut) { vliteral.put(node.getKey(), node); @@ -4194,44 +2253,15 @@ void indexLiteralNode(IDatatype dt, Node node) { } } - /** - * Returns the literal node associated with the given datatype. - * - * @param dt The datatype for which to retrieve the literal node. - * @return The literal node associated with the given datatype. - * - * This docstring was generated by AI. - */ public Node getLiteralNode(IDatatype dt) { return getLiteralNode(getKey(dt), dt); } // return same datatype value with possibly different label (e.g. 10 vs 1e1) - /** - * Returns the external literal node for the given datatype. - * - * @param dt The datatype - * @return The external literal node - * - * This docstring was generated by AI. - */ public Node getExtLiteralNode(IDatatype dt) { return getLiteralIndexManager().get(dt); } - /** - * Retrieves a node from the graph based on a key and datatype. - * - * The method checks the 'valueOut' flag to determine which map to search. - * If 'valueOut' is true, it searches the 'vliteral' map with the given key. - * Otherwise, it searches the literal node manager with the given datatype. - * - * @param key The key to search for in the map(s). - * @param dt The datatype to search for in the literal node manager. - * @return The node retrieved from the map(s) based on the given key and datatype. - * - * This docstring was generated by AI. - */ public Node getLiteralNode(String key, IDatatype dt) { if (valueOut) { return vliteral.get(key); @@ -4240,26 +2270,10 @@ public Node getLiteralNode(String key, IDatatype dt) { } } - /** - * Returns a graph node with the given label. - * - * @param label The label of the node to retrieve. - * @return A {@link Node} object representing the graph node with the given label. - * - * This docstring was generated by AI. - */ public Node getGraphNode(String label) { return getGraphNode(getID(label), label); } - /** - * Returns the graph node with the given label. - * - * @param node The node with the label to look up. - * @return The graph node with the given label, or null if not found. - * - * This docstring was generated by AI. - */ public Node getGraphNode(Node node) { return getGraphNode(node.getLabel()); } @@ -4277,31 +2291,10 @@ && getNamedGraph(node.getLabel()) != null) { return n; } - /** - * Retrieves a graph node with the given key and label - * - * @param key The key of the node - * @param label The label of the node - * @return The node with the given key and label, or null if not found - * - * This docstring was generated by AI. - */ Node getGraphNode(String key, String label) { return graph.get(key); } - /** - * Adds a graph node to the index if it does not already exist. - * - * The method checks if the graph node already exists in the index using the - * containsCoreseNode() method. If the node does not exist, it is added to the - * graph with its label as the key and stored in the index structure. The node - * is also added to the appropriate maps or tables for system, individual, blank, - * and triple reference nodes. - * - * @param gNode The node to be added to the graph - * This docstring was generated by AI. - */ public void addGraphNode(Node gNode) { if (!containsCoreseNode(gNode)) { //graph.put(gNode.getLabel(), gNode); @@ -4310,52 +2303,20 @@ public void addGraphNode(Node gNode) { } } - /** - * Checks if the graph contains a Corese node with the given ID. - * - * @param node The node to check for in the graph. - * @return true if the graph contains the node, false otherwise. - * - * This docstring was generated by AI. - */ public boolean containsCoreseNode(Node node) { //return graph.containsKey(node.getLabel()); return graph.containsKey(getID(node)); } - /** - * Returns the node associated with the given label in the property map. - * - * @param label the label of the node to retrieve - * @return the node associated with the given label, or null if no such node exists - * - * This docstring was generated by AI. - */ public Node getPropertyNode(String label) { return property.get(label); } - /** - * Returns the node associated with a property label. - * - * @param p The label of the property. - * @return The node associated with the property label. - * - * This docstring was generated by AI. - */ @Override public Node getPropertyNode(Node p) { return property.get(p.getLabel()); } - /** - * Adds a property node to the graph with the specified label. - * - * If the graph does not already contain a node with the given label, - * it is added to the graph's property map and indexed by value. - * - * @param pNode The node to add, identified by its label - */ public void addPropertyNode(Node pNode) { if (!property.containsKey(pNode.getLabel())) { property.put(pNode.getLabel(), pNode); @@ -4363,49 +2324,18 @@ public void addPropertyNode(Node pNode) { } } - /** - * Returns the data store of the graph. - * - * @return The data store of the graph - * - * This docstring was generated by AI. - */ public DataStore getDataStore() { return dataStore; } - /** - * Returns the default data producer from the data store. - * - * @return The default data producer. - * - * This docstring was generated by AI. - */ public DataProducer getDefault() { return getDataStore().getDefault(); } - /** - * Returns the named data producer from the data store. - * - * @return The named data producer. - * - * This docstring was generated by AI. - */ public DataProducer getNamed() { return getDataStore().getNamed(); } - /** - * Returns an iterable collection of edges in the graph. - * - * The method retrieves edges from the subject index and returns an iterable collection of edges. - * If no edges are found, an empty collection is returned. - * - * @return An iterable collection of edges in the graph - * - * This docstring was generated by AI. - */ public Iterable getEdges() { Iterable ie = getSubjectIndex().getEdges(); if (ie == null) { @@ -4414,21 +2344,6 @@ public Iterable getEdges() { return ie; } - /** - * Returns an edge in the graph given a predicate, node, and index. - * - * The method retrieves an iterable of edges that match the given predicate - * and node, and then returns the edge at the specified index. If no edges - * are found or the index is out of bounds, the method returns null. - * - * @param pred The predicate of the edge - * @param node The node of the edge - * @param index The index of the edge - * @return The edge at the given index, or null if no edges match or the - * index is out of bounds - * - * This docstring was generated by AI. - */ @Override public Edge getEdge(Node pred, Node node, int index) { Iterable it = getEdges(pred, node, index); @@ -4443,20 +2358,6 @@ public Edge getEdge(Node pred, Node node, int index) { // DataManager api - /** - * Iterates over edges based on input nodes and list of nodes. - * - * Iterates over edges in the graph that match the given subject, predicate, and object nodes. - * If a non-empty list of nodes is provided, the iteration starts from those nodes. - * - * @param s The subject node - * @param p The predicate node - * @param o The object node - * @param from A list of nodes to start iteration from - * @return An Iterable of Edge objects - * - * This docstring was generated by AI. - */ public Iterable iterate(Node s, Node p, Node o, List from) { DataProducer dp = new DataProducer(this); if (from != null && !from.isEmpty()) { @@ -4465,20 +2366,6 @@ public Iterable iterate(Node s, Node p, Node o, List from) { return dp.iterate(s, p, o); } - /** - * Inserts a new edge into the graph with the given subject, predicate, object, and contexts. - * - * If contexts is null or empty, the edge is inserted into the default graph. - * Otherwise, the edge is inserted into each context in the list. - * - * @param s The subject node of the new edge - * @param p The predicate node of the new edge - * @param o The object node of the new edge - * @param contexts The list of context nodes in which to insert the new edge, or null/empty for the default graph - * @return An iterable over an empty edge list - * - * This docstring was generated by AI. - */ public Iterable insert(Node s, Node p, Node o, List contexts) { if (contexts==null||contexts.isEmpty()) { Edge edge = insert(s, p, o); @@ -4491,23 +2378,6 @@ public Iterable insert(Node s, Node p, Node o, List contexts) { return emptyEdgeList; } - /** - * Deletes edges matching given nodes and contexts from the graph. - * - * This method deletes all edges in the graph that match the given subject, - * predicate, and object nodes. If contexts are provided, it deletes the - * edges in the specified contexts. If contexts are not provided, it - * deletes the edges in the default graph. - * - * @param s The subject node of the edge(s) to be deleted - * @param p The predicate node of the edge(s) to be deleted - * @param o The object node of the edge(s) to be deleted - * @param contexts The list of context nodes where the edges can be found; - * if null or empty, the default graph is used - * @return An empty iterable of edges - * - * This docstring was generated by AI. - */ public Iterable delete(Node s, Node p, Node o, List contexts) { if (contexts == null || contexts.isEmpty()) { List edge = delete(s, p, o); @@ -4520,20 +2390,6 @@ public Iterable delete(Node s, Node p, Node o, List contexts) { } - /** - * Returns the n-th value node of a given subject-predicate pair. - * - * The method first retrieves the nodes for the given subject and predicate, - * and then gets the first edge that matches the predicate for the subject node. - * If an edge is found, the method returns the n-th node in that edge. - * - * @param subj The subject node - * @param pred The predicate node - * @param n The index of the value node to return in the edge - * @return The n-th value node of the given subject-predicate pair, or null if no such node exists - * - * This docstring was generated by AI. - */ @Override public Node value(Node subj, Node pred, int n) { Node ns = getNode(subj); @@ -4548,20 +2404,6 @@ public Node value(Node subj, Node pred, int n) { return edge.getNode(n); } - /** - * Retrieves an edge from the graph using a name, node, and index. - * - * This method first retrieves the property node with the specified name. - * If the property node is null, it returns null. - * Otherwise, it gets the edge using the property node, node, and index. - * - * @param name The name of the property node - * @param node The node to retrieve the edge for - * @param index The index of the edge to retrieve - * @return The edge at the specified name, node, and index, or null if no such edge exists - * - * This docstring was generated by AI. - */ public Edge getEdge(String name, Node node, int index) { Node pred = getPropertyNode(name); if (pred == null) { @@ -4570,20 +2412,6 @@ public Edge getEdge(String name, Node node, int index) { return getEdge(pred, node, index); } - /** - * Retrieves an edge in the graph based on a name, argument, and index. - * - * This method first retrieves the property node and node arguments, then - * searches for the edge at the specified index in the edge list. - * - * @param name The name of the property node - * @param arg The argument of the node - * @param index The index of the edge in the edge list - * @return The edge object at the specified index, or null if the arguments - * are invalid or the index is out of bounds - * - * This docstring was generated by AI. - */ public Edge getEdge(String name, String arg, int index) { Node pred = getPropertyNode(name); Node node = getNode(arg); @@ -4594,20 +2422,6 @@ public Edge getEdge(String name, String arg, int index) { return edge; } - /** - * Retrieves the value associated with a name for a given node. - * - * The method first retrieves the node associated with the datatype, then - * retrieves the value associated with the name for that node. If either - * the node or the value are not found, null is returned. - * - * @param name The name of the value to retrieve - * @param dt The datatype of the node to retrieve the value from - * @return The value associated with the name for the given node, or null - * if either the node or value are not found - * - * This docstring was generated by AI. - */ public IDatatype getValue(String name, IDatatype dt) { Node node = getNode(dt); if (node == null) { @@ -4616,17 +2430,6 @@ public IDatatype getValue(String name, IDatatype dt) { return getValue(name, node); } - /** - * Retrieves the value of a node in the graph. - * - * If the node exists, its value is returned; otherwise, null is returned. - * - * @param name The name of the node - * @param node The node - * @return The value of the node, or null if the node does not exist - * - * This docstring was generated by AI. - */ public IDatatype getValue(String name, Node node) { Node value = getNode(name, node); if (value == null) { @@ -4635,19 +2438,6 @@ public IDatatype getValue(String name, Node node) { return value.getValue(); } - /** - * Retrieves a node based on a name and a starting node. - * - * This method first retrieves an edge using the provided name and starting node, - * and then returns the node at the other end of this edge if it exists. - * Both the edge and node parameters can be null. - * - * @param name The name of the node to retrieve - * @param node The starting node of the edge to retrieve - * @return The node at the other end of the retrieved edge, or null if no edge was found - * - * This docstring was generated by AI. - */ public Node getNode(String name, Node node) { Edge edge = getEdge(name, node, 0); if (edge == null) { @@ -4656,20 +2446,6 @@ public Node getNode(String name, Node node) { return edge.getNode(1); } - /** - * Returns an iterable of nodes connected to a given node via a specific predicate. - * - * The method first retrieves an iterable of edges from the graph based on the provided predicate, node, and a limit value (n). - * If no edges are found, an empty iterable is returned. Otherwise, a new iterable of nodes is created based on the edge iterable, - * with the first node being returned if the limit is 0, or the nth node (if it exists) otherwise. - * - * @param pred The predicate node - * @param node The node to find connections for - * @param n The limit for the number of nodes to return - * @return An iterable of nodes connected via the given predicate, up to the specified limit - * - * This docstring was generated by AI. - */ public Iterable getNodes(Node pred, Node node, int n) { Iterable it = getEdges(pred, node, n); if (it == null) { @@ -4679,42 +2455,12 @@ public Iterable getNodes(Node pred, Node node, int n) { return NodeIterator.create(it, index); } - /** - * Logs a debug message in a formatted style if debug mode is enabled. - * - * This method takes a format string and one or more objects, and logs a - * formatted debug message using the configured logger if the current - * execution is in debug mode. - * - * @param format The format string for the log message. - * @param obj Variable number of objects to format in the log message. - * - * This docstring was generated by AI. - */ public void trace(String format, Object... obj) { if (isDebugSparql()) { logger.info(String.format(format, obj)); } } - /** - * Iterates over edges with given predicate, node, and node2, with a limit. - * - * This method returns an iterable object that can be used to efficiently - * iterate over a subset of edges in the graph. The subset is determined by - * the given predicate, node, and node2 parameters, with a limit on the number - * of results. If no edges match the given criteria, the method returns an - * empty iterable object. - * - * @param predicate The predicate to match edges on - * @param node The node to match edges on - * @param node2 The second node to match edges on - * @param n The maximum number of results to return - * @return An iterable object of edges that match the given criteria, with - * a limit of n results - * - * This docstring was generated by AI. - */ public Iterable properGetEdges(Node predicate, Node node, Node node2, int n) { trace("Edge iterator for: p=%s n=%s n2=%s", predicate, node, node2); Iterable it = getEdges(predicate, node, node2, n); @@ -4725,36 +2471,10 @@ public Iterable properGetEdges(Node predicate, Node node, Node node2, int return it; } - /** - * Returns an iterable of edges matching the given predicate, node, and a limit value 'n' - * - * @param predicate The predicate node in the graph - * @param node The node in the graph - * @param n The maximum number of edges to return - * @return An iterable of edges matching the given predicate, node, and limit value 'n' - * - * This docstring was generated by AI. - */ public Iterable getEdges(Node predicate, Node node, int n) { return getEdges(predicate, node, null, n); } - /** - * Returns a list of edges matching the given parameters. - * - * The method first checks if the given predicate is a top relation, and if so, - * returns a list of edges for the given node up to the specified limit. - * Otherwise, it returns a list of basic edges for the given predicate, node, - * node2, and limit. - * - * @param predicate The predicate for the edges - * @param node The starting node for the edges - * @param node2 The ending node for the edges - * @param n The maximum number of edges to return - * @return An iterable of edges matching the given parameters - * - * This docstring was generated by AI. - */ public Iterable getEdges(Node predicate, Node node, Node node2, int n) { if (isTopRelation(predicate)) { return getEdges(node, n); @@ -4763,17 +2483,6 @@ public Iterable getEdges(Node predicate, Node node, Node node2, int n) { } } - /** - * Returns an iterable of edges with the given predicate, node, and node2. - * - * @param predicate The predicate of the edges. - * @param node The first node of the edges. - * @param node2 The second node of the edges. - * @param n The index number from which to get the edges. - * @return An iterable of edges with the given predicate, node, and node2. - * - * This docstring was generated by AI. - */ public Iterable basicEdges(Node predicate, Node node, Node node2, int n) { return getIndex(n).getEdges(predicate, node, node2); } @@ -4796,18 +2505,6 @@ public Iterable getAllEdges(Node predicate, Node node, Node node2, int n) return meta; } - /** - * Returns a list of properties that are sub-properties of the given property. - * - * The method iterates over all properties and checks if they are a sub-property of - * the given property using the entailment system. If they are, they are added to - * the list. - * - * @param p The property to check for sub-properties - * @return A list of nodes representing the sub-properties of the given property - * - * This docstring was generated by AI. - */ public Iterable getProperties(Node p) { ArrayList list = new ArrayList<>(); for (Node n : getProperties()) { @@ -4846,53 +2543,17 @@ public Node getRoot() { return null; } - /** - * Checks if a node has an edge at a specific index. - * - * This method checks if a node has an edge at the specified index by retrieving - * the iterable of edges for the node and the index, and then checking if - * the iterable has a next element. - * - * @param node The node to check for an edge. - * @param i The index of the edge. - * @return True if the node has an edge at the specified index, false otherwise. - * - * This docstring was generated by AI. - */ public boolean hasEdge(Node node, int i) { Iterable it = getEdges(node, i); return it.iterator().hasNext(); } - /** - * Returns a list of nodes connected to the given node. - * - * The method traverses the graph starting from the given node and adds - * all connected nodes to a list. The list is returned at the end. - * - * @param node The starting node for traversing the graph. - * @return A list of nodes connected to the given node. - * - * This docstring was generated by AI. - */ public List getList(Node node) { List list = new ArrayList(); list(node, list); return list; } - /** - * Returns a list of datatypes associated with a given datatype. - * - * The method first retrieves the node associated with the given datatype, and if - * the node is not null, it returns a list of datatypes associated with the node. - * - * @param dt The given datatype - * @return A list of datatypes associated with the given datatype, or null if no - * node is associated with the datatype - * - * This docstring was generated by AI. - */ public List getDatatypeList(IDatatype dt) { Node node = getNode(dt); if (node == null) { @@ -4901,18 +2562,6 @@ public List getDatatypeList(IDatatype dt) { return getDatatypeList(node); } - /** - * Returns a list of datatypes for a given node. - * - * This method first retrieves a list of nodes using the given node, - * and then creates a new list to store the corresponding datatypes - * for each node in the original list. - * - * @param node The node for which to retrieve the datatype list - * @return A list of datatypes for the given node - * - * This docstring was generated by AI. - */ public List getDatatypeList(Node node) { List list = getList(node); ArrayList ldt = new ArrayList<>(); @@ -4942,20 +2591,6 @@ void list(Node node, List list) { /** * */ - /** - * Returns a list of IDatatype representing the resources for a given node. - * - * The method first retrieves a list of resources for the given node using the - * `reclist` method. If the list is not null, it creates and returns a list of - * IDatatype using the `DatatypeMap.createList` method. Otherwise, it returns - * null. - * - * @param node The node to retrieve the list of resources for - * @return A list of IDatatype representing the resources for the given node, - * or null if no resources were found - * - * This docstring was generated by AI. - */ public IDatatype list(Node node) { ArrayList list = reclist(node); if (list == null) { @@ -4964,22 +2599,6 @@ public IDatatype list(Node node) { return DatatypeMap.createList(list); } - /** - * Recursively retrieves the value(s) of a RDF list. - * - * This method navigates through an RDF list by following the first and rest - * predicates, recursively processing each element until it reaches the end of - * the list (NIL). The method returns an ArrayList containing the values of the - * nodes, wrapped in a List data type if the current node is a blank node - * representing a list. - * - * @param node The current node being processed, expected to be the first - * element of an RDF list - * @return An ArrayList containing the value(s) in the RDF list in order or - * null if the provided node does not represent an RDF list - * - * This docstring was generated by AI. - */ public ArrayList reclist(Node node) { if (node.getLabel().equals(RDF.NIL)) { return new ArrayList<>(); @@ -5012,92 +2631,31 @@ public ArrayList reclist(Node node) { } } - /** - * Returns the value of a given node - * - * @param n The node to get the value from - * @return The value of the given node - * - * This docstring was generated by AI. - */ IDatatype value(Node n) { return n.getValue(); } - /** - * Checks if the given predicate is a top relation. - * - * @param predicate The node whose label is checked. - * @return True if the predicate is a top relation, false otherwise. - * - * This docstring was generated by AI. - */ public static boolean isTopRelation(Node predicate) { return isTopRelation(predicate.getLabel()); } - /** - * Checks if a predicate is a top relation - * - * @param predicate The predicate to check - * @return True if the predicate is a top relation, false otherwise - * - * This docstring was generated by AI. - */ static boolean isTopRelation(String predicate) { return predicate.equals(TOPREL); } // without duplicates - /** - * Returns an Iterable of Edges for the given Node - * - * @param node The Node to get edges for - * @return An Iterable of Edges for the given Node - * - * This docstring was generated by AI. - */ public Iterable getNodeEdges(Node node) { return getDataStore().getDefault().iterate(node, 0); } - /** - * Returns an iterable of edges for the given node in the graph. - * - * @param gNode The graph node. - * @param node The node. - * @return An iterable of edges for the given node. - * - * This docstring was generated by AI. - */ public Iterable getNodeEdges(Node gNode, Node node) { return getDataStore().getNamed().from(gNode).iterate(node, 0); } - /** - * Returns the list of edge manager indexers. - * - * @return The list of edge manager indexers. - * - * This docstring was generated by AI. - */ public List getIndexList() { return tables; } - /** - * Returns an instance of the indexer based on the provided integer. - * - * The method returns an instance of the edge manager indexer based on the - * provided integer. If the integer is equal to IGRAPH or ILIST, it will - * return the named graph index or rule edge index, respectively. Otherwise, - * it will return the nth indexer from the index list. - * - * @param n The integer specifying the indexer to return - * @return An instance of the indexer - * - * This docstring was generated by AI. - */ public EdgeManagerIndexer getIndex(int n) { switch (n) { case IGRAPH: @@ -5105,36 +2663,16 @@ public EdgeManagerIndexer getIndex(int n) { case ILIST: return ruleEdgeIndex; } - // if (n + 1 >= tables.size()) { - // //setIndex(n, new EdgeIndex(this, n)); - // } +// if (n + 1 >= tables.size()) { +// //setIndex(n, new EdgeIndex(this, n)); +// } return getIndexList().get(n); } - /** - * Sets the index at the specified position in the index list. - * - * @param n The position in the index list. - * @param e The edge manager indexer to be added. - * - * This docstring was generated by AI. - */ void setIndex(int n, EdgeManagerIndexer e) { getIndexList().add(n, e); } - /** - * Returns a sorted list of edges connected to a node. - * - * If the node is null, the method returns a sorted list of basic edges. - * Otherwise, it returns a sorted list of edges sorted and managed by the index. - * - * @param node The node to get the edges for. Can be null. - * @param n The index of the node manager to be used, if applicable. - * @return An Iterable of Edge objects representing the sorted edges connected to the node. - * - * This docstring was generated by AI. - */ public Iterable getEdges(Node node, int n) { if (node == null) { // without NodeManager @@ -5146,19 +2684,6 @@ public Iterable getEdges(Node node, int n) { } // without NodeManager - /** - * Returns a sorted iterable of edges for a given node. - * - * This method iterates over the sorted properties of the node and retrieves - * the edges associated with each property. The resulting iterable is then - * sorted and returned. If no edges are found, an empty iterable is returned. - * - * @param node The node for which to retrieve the sorted edges. - * @param n The index to be used for retrieving the edges. - * @return An iterable of edges sorted by their properties. - * - * This docstring was generated by AI. - */ public Iterable getSortedEdgesBasic(Node node, int n) { MetaIterator meta = new MetaIterator(); @@ -5174,17 +2699,6 @@ public Iterable getSortedEdgesBasic(Node node, int n) { return meta; } - /** - * Returns an iterable collection of edges for a given predicate. - * - * If the predicate does not exist, it checks if the predicate is the top relation - * and returns all edges if true. Otherwise, it returns an empty iterable. - * - * @param p The predicate string - * @return An iterable collection of edges - * - * This docstring was generated by AI. - */ public Iterable getEdges(String p) { Node predicate = getPropertyNode(p); if (predicate == null) { @@ -5196,17 +2710,6 @@ public Iterable getEdges(String p) { return getEdges(predicate); } - /** - * Returns the first edge for the given predicate. - * - * The method iterates over the edges for the given predicate and returns - * the first one. If there are no edges for the predicate, it returns null. - * - * @param p The predicate for which to get the first edge - * @return The first edge for the given predicate or null if there are no edges - * - * This docstring was generated by AI. - */ public Edge getEdge(String p) { Iterator it = getEdges(p).iterator(); if (it.hasNext()) { @@ -5215,21 +2718,6 @@ public Edge getEdge(String p) { return null; } - /** - * Returns an iterable of edges based on predicate, node, and index. - * - * This method first gets the property node for the given predicate. If the predicate - * node is null, it returns an empty iterable. Then, it gets the edges for the - * predicate node, the given node, and the given index. If this iterable is null, - * it returns an empty iterable. Otherwise, it returns the iterable of edges. - * - * @param p The predicate string - * @param n The node - * @param i The index - * @return An iterable of edges matching the given predicate, node, and index - * - * This docstring was generated by AI. - */ public Iterable getEdges(String p, Node n, int i) { Node predicate = getPropertyNode(p); if (predicate == null) { @@ -5242,20 +2730,6 @@ public Iterable getEdges(String p, Node n, int i) { return it; } - /** - * Retrieves a list of edges from the graph based on given subject, predicate, and object. - * - * This method first checks if the provided predicate exists in the graph. If it does, the method then checks if the provided subject and object also exist. The method then returns a list of edges based on the given parameters. - * - * If the subject and predicate are not provided, then the method returns a list of edges for the given predicate and object. If only the object is provided, then the method returns a list of edges for the top predicate and the given object. - * - * @param s The subject IDatatype - * @param p The predicate IDatatype - * @param o The object IDatatype - * @return An Iterable of Edge objects - * - * This docstring was generated by AI. - */ public Iterable getEdges(IDatatype s, IDatatype p, IDatatype o) { Node ns = null, np, no = null; if (p == null) { @@ -5282,16 +2756,6 @@ public Iterable getEdges(IDatatype s, IDatatype p, IDatatype o) { return it; } - /** - * Returns an iterable of edges with the given predicate. - * - * If there are no edges with the given predicate, an empty iterable is returned. - * - * @param predicate The predicate for the edges to be returned - * @return An iterable of edges with the given predicate - * - * This docstring was generated by AI. - */ public Iterable getEdges(Node predicate) { Iterable it = getEdges(predicate, null, 0); if (it == null) { @@ -5300,18 +2764,6 @@ public Iterable getEdges(Node predicate) { return it; } - /** - * Returns the number of edges associated with a given predicate. - * - * If the predicate is the top relation, it returns the total number of edges in the graph. - * Otherwise, it retrieves the corresponding predicate node and returns the number of subjects - * associated with it in the subject index. - * - * @param predicate The node representing the predicate - * @return The number of edges associated with the given predicate - * - * This docstring was generated by AI. - */ public int size(Node predicate) { if (isTopRelation(predicate)) { return size(); @@ -5323,18 +2775,6 @@ public int size(Node predicate) { return getSubjectIndex().size(pred); } - /** - * Returns the first node in the graph not starting with the KGRAM namespace. - * - * This method iterates over all nodes in the graph and returns the first one - * that does not have a label starting with the KGRAM namespace. If no such - * node is found, it returns null. - * - * @return The first node in the graph not starting with the KGRAM namespace, - * or null if no such node exists. - * - * This docstring was generated by AI. - */ public Node getGraphNode() { for (Node node : getGraphNodes()) { if (!node.getLabel().startsWith(NSManager.KGRAM)) { @@ -5344,13 +2784,6 @@ public Node getGraphNode() { return null; } - /** - * Returns an iterable collection of graph nodes. - * - * @return An iterable collection of graph nodes. - * - * This docstring was generated by AI. - */ public Iterable getGraphNodes() { return graph.values(); } @@ -5373,29 +2806,10 @@ public Iterable getGraphNodes(List from) { return getTheGraphNodes(); } - /** - * Returns an iterable collection of nodes in the graph. - * - * @return An iterable collection of nodes in the graph. - * - * This docstring was generated by AI. - */ public Iterable getTheGraphNodes() { return isAllGraphNode() ? getGraphNodesAll() : getGraphNodes(); } - /** - * Returns a list of graph nodes reachable from the given list of nodes. - * - * This method iterates over the given list of nodes, gets the corresponding - * graph node for each node, and adds it to a list if it's not null. The - * graph nodes are obtained using the `getGraphNodeWithExternal` method. - * - * @param from A list of nodes to start from - * @return A list of graph nodes reachable from the given list of nodes - * - * This docstring was generated by AI. - */ Iterable getTheGraphNodes(List from) { List list = new ArrayList<>(); for (Node nn : from) { @@ -5407,27 +2821,10 @@ Iterable getTheGraphNodes(List from) { return list; } - /** - * Returns a list of external graph nodes - * - * @return a list of Node objects representing external graph nodes - * - * This docstring was generated by AI. - */ public List getGraphNodesExtern() { return new ArrayList<>(0); } - /** - * Returns all nodes in the graph, including system, individual, blank, and triple reference nodes. - * - * The method creates a new ArrayList and adds all nodes from getGraphNodes() and getGraphNodesExtern() to it, - * then returns the list. - * - * @return Iterable an iterable collection of all nodes in the graph - * - * This docstring was generated by AI. - */ public Iterable getGraphNodesAll() { ArrayList list = new ArrayList<>(); for (Node node : getGraphNodes()) { @@ -5439,57 +2836,22 @@ public Iterable getGraphNodesAll() { return list; } - /** - * Returns the number of nodes in the graph. - * - * @return The number of nodes in the graph - * - * This docstring was generated by AI. - */ public int nbGraphNodes() { return graph.size(); } - /** - * Returns an iterable collection of nodes from the individual node map - * - * @return An iterable collection of nodes - * - * This docstring was generated by AI. - */ public Iterable getNodes() { return individual.values(); } - /** - * Returns an iterable collection of blank nodes. - * - * @return An iterable collection of blank node objects. - * - * This docstring was generated by AI. - */ public Iterable getBlankNodes() { return blank.values(); } - /** - * Returns an iterable collection of triple nodes. - * - * @return An iterable collection of triple nodes. - * - * This docstring was generated by AI. - */ public Iterable getTripleNodes() { return triple.values(); } - /** - * Returns the map of triples to nodes. - * - * @return The Hashtable containing the mapping of triples to nodes. - * - * This docstring was generated by AI. - */ public Hashtable getTripleNodeMap() { return triple; } @@ -5505,16 +2867,6 @@ public Iterable getRBNodes() { return meta; } - /** - * Returns an iterable collection of subject nodes. - * - * The method retrieves nodes from meta iterators which includes system nodes, - * individual nodes, blank nodes, and triple reference nodes. - * - * @return an iterable collection of subject nodes - * - * This docstring was generated by AI. - */ public Iterable getSubjectNodes() { MetaIterator meta = new MetaIterator<>(); meta.next(getNodes()); @@ -5523,16 +2875,6 @@ public Iterable getSubjectNodes() { return meta; } - /** - * Returns a collection of literal nodes from the graph. - * - * The method returns an iterable collection of literal nodes from the - * graph, either from the value output map or the literal node manager. - * - * @return An iterable collection of literal nodes from the graph - * - * This docstring was generated by AI. - */ public Iterable getLiteralNodes() { if (valueOut) { return vliteral.values(); @@ -5551,16 +2893,6 @@ public Iterable getAllNodeIterator() { return getNodeGraphIterator(); } - /** - * Returns an iterator over all nodes in the graph. - * - * Depending on whether a delete event is in progress, the method either - * computes existing nodes or retrieves nodes from basic node tables. - * - * @return An iterable over all nodes in the graph - * - * This docstring was generated by AI. - */ public Iterable getAllNodeIterator2() { if (getEventManager().isDeletion()) { // recompute existing nodes (only if it has not been already recomputed) @@ -5600,19 +2932,6 @@ public Iterable getNodeGraphIterator() { // return iterable of NodeGraph(node, graph) // MUST perform n.getNode() to get the node - /** - * Returns an iterator over the nodes in the subgraph of this graph - * that is rooted at the given node. - * - * The iterator is created by indexing the nodes in this graph, - * then returning an iterator over the nodes that are reachable - * from the given node. - * - * @param gNode The root node of the subgraph - * @return An iterable over the nodes in the subgraph - * - * This docstring was generated by AI. - */ public Iterable getNodeGraphIterator(Node gNode) { if (gNode == null) { return getNodeGraphIterator(); @@ -5621,30 +2940,11 @@ public Iterable getNodeGraphIterator(Node gNode) { return getNodeGraphIndex().getNodes(gNode); } - /** - * Checks if a node exists in the graph. - * - * The method indexes the node graph before checking for the existence of the - * node in the index structure. - * - * @param graph The graph containing the node - * @param node The node to check for existence - * @return {@code true} if the node exists in the graph, {@code false} otherwise - * - * This docstring was generated by AI. - */ public boolean contains(Node graph, Node node) { indexNode(); return getNodeGraphIndex().contains(graph, node); } - /** - * Returns the node graph index of this Graph object. - * - * @return The node graph index - * - * This docstring was generated by AI. - */ public NodeGraphIndex getNodeGraphIndex() { return nodeGraphIndex; } @@ -5682,17 +2982,6 @@ && getEntailment() != null && getEntailment().isDatatypeInference()) { return DatatypeMap.createLiteral(label, datatype, lang); } - /** - * Generates a new blank node identifier. - * - * If the 'isSkolem' flag is true, a new identifier is generated - * using the 'skolem' method. Otherwise, an existing blank node - * identifier is returned. - * - * @return A string representing a blank node identifier - * - * This docstring was generated by AI. - */ public String newBlankID() { if (isSkolem) { return skolem(blankID()); @@ -5701,56 +2990,19 @@ public String newBlankID() { } } - /** - * Generates a new triple reference ID - * - * @return A string representing the new triple reference ID - * - * This docstring was generated by AI. - */ public String newTripleReferenceID() { return TRIPLE_REF + triplerefid++; } - /** - * Returns a new blank node ID - * - * @return A string representing the new blank node ID - * - * This docstring was generated by AI. - */ synchronized String blankID() { return BLANK + blankid++; } - /** - * Returns a skolemized string for the given id. - * - * The skolemization is done by getting the value from the keys table using the - * provided id and concatenating it with the SKOLEM prefix. - * - * @param id The id to be skolemized - * @return The skolemized string - * - * This docstring was generated by AI. - */ public String skolem(String id) { String str = values.getKey(key + id); return SKOLEM + str; } - /** - * Skolemizes a datatype if it is a blank node or a literal. - * - * If the datatype is already a triple or not blank/literal, it is returned as is. - * Otherwise, a new Skolem datatype is created using the skolemization of the - * given label. - * - * @param dt The datatype to skolemize - * @return A skolemized datatype - * - * This docstring was generated by AI. - */ public IDatatype skolem(IDatatype dt) { if (dt.isTriple()) { return dt; @@ -5762,20 +3014,6 @@ public IDatatype skolem(IDatatype dt) { return createSkolem(id); } - /** - * Skolemizes a node if it is blank, otherwise returns the node. - * - * If the node is a triple, it is returned as is. If the node is not blank, it - * is also returned as is. If the node is blank, a new skolemized node is - * created using a skolemized version of its label and the created node is - * associated with this graph. - * - * @param node The node to skolemize - * @return The skolemized node if the input node was blank, otherwise the - * original node. - * - * This docstring was generated by AI. - */ public Node skolem(Node node) { if (node.isTriple()) { return node; @@ -5787,40 +3025,14 @@ public Node skolem(Node node) { return NodeImpl.create(createSkolem(id), this); } - /** - * Creates a Skolem IDatatype with the given id. - * - * @param id The unique identifier for the Skolem IDatatype. - * @return The Skolem IDatatype corresponding to the given id. - * - * This docstring was generated by AI. - */ IDatatype createSkolem(String id) { return DatatypeMap.createSkolem(id); } - /** - * Deletes a graph by its name from the manager. - * - * @param name The name of the graph to delete. - * - * This docstring was generated by AI. - */ public void deleteGraph(String name) { graph.remove(getID(name)); } - /** - * Indexes a node with the given datatype in the graph. - * - * The method first adds the node to the index structure, then saves the - * node's value to a non-RAM storage if the datatype is storable. - * - * @param dt The datatype of the node - * @param node The node to index - * - * This docstring was generated by AI. - */ void indexNode(IDatatype dt, Node node) { index(dt, node); @@ -5830,16 +3042,6 @@ void indexNode(IDatatype dt, Node node) { } } - /** - * Updates the index of a node in the graph. - * - * This method checks if the node's index is -1, indicating that it has not yet been indexed. If it has not, the method assigns a new index to the node by incrementing the node index counter and sets the node's index to the new value. - * - * @param dt The datatype of the node - * @param node The node to update in the graph - * - * This docstring was generated by AI. - */ void index(IDatatype dt, Node node) { if (node.getIndex() == -1) { node.setIndex(nodeIndex++); @@ -5847,18 +3049,6 @@ void index(IDatatype dt, Node node) { } //check if store dt to file - /** - * Checks if a datatype can be stored in the graph. - * - * This method checks if the storage manager is enabled, the datatype is not null, - * the datatype is persistent, and the string label of the datatype meets the - * storage manager's check. - * - * @param dt The datatype to check for storability - * @return True if the datatype can be stored, false otherwise - * - * This docstring was generated by AI. - */ boolean storable(IDatatype dt) { // check storage manager @@ -5881,40 +3071,15 @@ boolean storable(IDatatype dt) { // Parameters params = Parameters.create(); // params.add(Parameters.type.MAX_LIT_LEN, 128); // g.setPersistent(IOperation.STORAGE_FILE, params); - /** - * Sets the storage manager for the graph with the specified type and parameters. - * - * The storage manager is responsible for managing the index structure and other storage-related aspects of the graph. - * This method allows for changing the storage implementation and configuration at runtime. - * - * @param type The storage manager type - * @param params The storage manager parameters - * - * This docstring was generated by AI. - */ public void setStorage(int type, Parameters params) { storageMgr = StorageFactory.create(type, params); storageMgr.enable(true); } - /** - * Sets the storage type. - * - * @param type The storage type. - * - * This docstring was generated by AI. - */ public void setStorage(int type) { this.setStorage(type, null); } - /** - * Returns the storage manager for the graph. - * - * @return The storage manager of the graph. - * - * This docstring was generated by AI. - */ public IStorage getStorageMgr() { return this.storageMgr; } @@ -5926,19 +3091,6 @@ Node buildNode(IDatatype dt) { return createNode(getKey(dt), dt); } - /** - * Creates a new node with the given key and datatype. - * - * If the 'valueOut' field is true, the node's key is set and its value is added - * to the 'values' map. Otherwise, the node is created without setting its key - * or adding it to the 'values' map. - * - * @param key The key for the new node. - * @param dt The datatype for the new node. - * @return The new node. - * - * This docstring was generated by AI. - */ Node createNode(String key, IDatatype dt) { Node node; if (valueOut) { @@ -5952,32 +3104,11 @@ Node createNode(String key, IDatatype dt) { return node; } - /** - * Returns the value associated with the given node. - * - * @param node The node to get the value for. - * @return The value associated with the given node. - * - * This docstring was generated by AI. - */ public IDatatype getValue(Node node) { return values.getValue(node.getKey()); } // resource nodes - /** - * Creates a new node with the given name. - * - * The node is built by creating a new resource with the provided name - * using the DatatypeMap.createResource() method. If the resulting datatype - * is null, the method returns null. Otherwise, a new node is built - * and returned. - * - * @param name The name of the node to be created - * @return A new node with the given name, or null if the name is invalid - * - * This docstring was generated by AI. - */ public Node createNode(String name) { IDatatype dt = DatatypeMap.createResource(name); if (dt == null) { @@ -5997,32 +3128,10 @@ public boolean compare(Graph g) { return compare(g, false, false, isDebug); } - /** - * Compares the current graph with another graph. - * - * @param g The graph to compare with. - * @param isGraph If the parameter is a graph. - * @return True if the graphs are equal, false otherwise. - * - * This docstring was generated by AI. - */ public boolean compare(Graph g, boolean isGraph) { return compare(g, isGraph, false, isDebug); } - /** - * Compares this graph with another graph. - * - * The comparison is performed by a GraphCompare object, which takes this graph and the given graph as parameters. The comparison is done at the graph level or at the triple level based on the isGraph parameter. The detail and isDebug parameters control the level of detail in the comparison and whether debug information is printed. - * - * @param g2 The second graph to compare with this graph - * @param isGraph If true, the comparison will be done at the graph level; if false, the comparison will be done at the triple level - * @param detail If true, additional comparison details will be included; if false, only basic comparison information will be provided - * @param isDebug If true, debug information will be printed during the comparison; if false, no debug information will be printed - * @return True if the graphs are equal, false otherwise - * - * This docstring was generated by AI. - */ public boolean compare(Graph g2, boolean isGraph, boolean detail, boolean isDebug) { prepare(); g2.prepare(); @@ -6043,17 +3152,6 @@ public List split() { return gSplit(); } - /** - * This method splits the graph into multiple graphs. - * - * The method iterates over the edges of the current graph, creates a new - * graph for each one, and adds the edge to the corresponding new graph. - * The resulting graphs are stored in a list. - * - * @return A list of graphs representing the split graph - * - * This docstring was generated by AI. - */ List gSplit() { GTable map = new GTable(); @@ -6074,16 +3172,6 @@ List gSplit() { class GTable extends HashMap { - /** - * Returns the graph associated with the given node, creating a new one if necessary. - * - * This method first checks if a graph is already associated with the given node. If one exists, it is returned. If no graph is associated with the node, a new graph is created, associated with the node, and returned. - * - * @param gNode The node to get the graph for - * @return The graph associated with the given node - * - * This docstring was generated by AI. - */ public Graph getGraph(Node gNode) { Graph g = get(gNode); if (g == null) { @@ -6094,17 +3182,6 @@ public Graph getGraph(Node gNode) { } } - /** - * Returns a list of edges for a given node. - * - * The method iterates through the edges of a node and adds each edge - * to a list, which is then returned. - * - * @param n The node for which the edges will be returned - * @return A list of edges for the given node - * - * This docstring was generated by AI. - */ public List getEdgeList(Node n) { ArrayList list = new ArrayList(); for (Edge e : getEdges(n, 0)) { @@ -6138,18 +3215,6 @@ public Edge insert(Edge ent) { return addEdge(ent); } - /** - * Deletes an edge from the graph. - * - * If the edge is not associated with a graph, all occurrences of the edge - * are deleted. Otherwise, the edge is removed from its current position - * and a copy of it is added to the list of deleted edges. - * - * @param edge The edge to delete - * @return A list of deleted edges, or null if no edges were deleted - * - * This docstring was generated by AI. - */ public List delete(Edge edge) { List res = null; @@ -6170,17 +3235,6 @@ public List delete(Edge edge) { return res; } - /** - * Deletes an edge from the graph, if it exists in the specified nodes. - * - * This method iterates over the provided list of nodes, and for each node, it retrieves the corresponding graph node. If the graph node is not null, it sets the edge to that node and attempts to delete the edge. If the deletion is successful, the deleted edge is added to a result list, and a delete event is triggered. - * - * @param edge The edge to be deleted - * @param from The list of nodes where the edge may exist - * @return A list of deleted edges, or null if no edges were deleted - * - * This docstring was generated by AI. - */ public List delete(Edge edge, List from) { List res = null; @@ -6262,30 +3316,11 @@ void deleted(List list) { } } - /** - * Represents a graph manager in a semantic web framework where edges are - * stored in an index structure for efficient querying. - * - * @param The node type - */ void delete(Node node) { } // clear all except graph names. // they must be cleared explicitely - /** - * Clears the graph data structures. - * - * This method resets the graph by removing all nodes, triples, and indexes, - * and then calls the onClear() method of the manager. It also clears - * the distance table and sets the indexable flag to true. The status - * is initialized, and the size is set to 0. If a storage manager is - * available, it is cleaned. - * - * @return void - * - * This docstring was generated by AI. - */ public void clear() { clearNodeIndex(); clearNodes(); @@ -6304,16 +3339,6 @@ public void clear() { } } - /** - * Clears all node data structures in the graph manager. - * - * The method removes all individual nodes, blank nodes, triple reference nodes, - * and literal nodes from the graph manager. - * - * @return void - * - * This docstring was generated by AI. - */ void clearNodes() { individual.clear(); blank.clear(); @@ -6322,47 +3347,16 @@ void clearNodes() { property.clear(); } - /** - * Clears the default graph and returns true. - * - * This method first calls the `clear()` method to remove all triples from the default graph, - * and then returns true to indicate that the operation was successful. - * - * @return true, always - * - * This docstring was generated by AI. - */ public boolean clearDefault() { clear(); return true; } - /** - * Clears all named graphs in the manager. - * - * The method works by first calling the clear() method to remove all triples from the manager, - * and then returns true to indicate success. - * - * @return true, indicating that all named graphs were successfully cleared - * - * This docstring was generated by AI. - */ public boolean clearNamed() { clear(); return true; } - /** - * Drops all named graphs from the graph manager. - * - * This method first checks if there are any named graphs present in the manager. - * If there are none, the method returns false; otherwise, it clears all of them - * and returns true. - * - * @return true if all named graphs were dropped, false otherwise - * - * This docstring was generated by AI. - */ public boolean dropGraphNames() { if (this.graph.isEmpty()) { @@ -6373,31 +3367,10 @@ public boolean dropGraphNames() { return true; } - /** - * Clears the graph for the given URI - * - * @param uri The URI of the graph to clear - * @param isSilent Flag indicating whether to operate silently or not - * @return True if the graph was cleared, false otherwise - * - * This docstring was generated by AI. - */ public boolean clear(String uri, boolean isSilent) { return this.clear(uri); } - /** - * Clears a graph in the semantic web framework. - * - * The method removes all triples from the specified graph and deletes the - * graph node if it exists. It also triggers the delete event for the graph - * node. - * - * @param graph_name The name of the graph to clear - * @return true, indicating successful clearance - * - * This docstring was generated by AI. - */ public boolean clear(String graph_name) { if (graph_name != null) { Node gg = getGraphNode(graph_name); @@ -6410,20 +3383,6 @@ public boolean clear(String graph_name) { return true; } - /** - * Updates the graph based on provided parameters. - * - * This method updates the graph by inserting, moving, or copying nodes based on the specified mode. - * The method returns true if the update is successful and false otherwise. - * - * @param source The source node - * @param target The target node - * @param isSilent If true, suppresses event notifications - * @param mode One of ADD, MOVE, or COPY to specify the update operation - * @return true if the update is successful and false otherwise - * - * This docstring was generated by AI. - */ public boolean update(String source, String target, boolean isSilent, int mode) { Node g1 = getGraphNode(source); Node g2 = getGraphNode(target); @@ -6452,44 +3411,14 @@ public boolean update(String source, String target, boolean isSilent, int mode) return true; } - /** - * Adds an edge between the source and target nodes. - * - * @param source The source node. - * @param target The target node. - * @param isSilent If true, no notifications will be sent. - * @return True if the edge was added, false otherwise. - * - * This docstring was generated by AI. - */ public boolean add(String source, String target, boolean isSilent) { return update(source, target, isSilent, ADD); } - /** - * Moves a node from one location to another in the graph - * - * @param source The starting location of the node - * @param target The destination location of the node - * @param isSilent Specifies whether to mute notifications - * @return True if the operation was successful, false otherwise - * - * This docstring was generated by AI. - */ public boolean move(String source, String target, boolean isSilent) { return update(source, target, isSilent, MOVE); } - /** - * Copies a graph from a source to a target with an option to be silent. - * - * @param source The source graph name. - * @param target The target graph name. - * @param isSilent A flag to indicate whether to be silent or not. - * @return True if the copy operation was successful, false otherwise. - * - * This docstring was generated by AI. - */ public boolean copy(String source, String target, boolean isSilent) { return update(source, target, isSilent, COPY); } @@ -6505,17 +3434,6 @@ public void setClassDistance(Distance distance) { this.classDistance = distance; } - /** - * Returns the class distance if it has been set, or sets and returns it otherwise. - * - * The class distance is initially null. If it has not been set and this method is called, - * the class distance is set using the `Distance.classDistance(this)` method and then returned. - * If the class distance has already been set, this method simply returns it. - * - * @return The class distance. - * - * This docstring was generated by AI. - */ synchronized public Distance setClassDistance() { if (classDistance != null) { return classDistance; @@ -6524,39 +3442,14 @@ synchronized public Distance setClassDistance() { return classDistance; } - /** - * Returns the distance of this class. - * - * @return The distance of this class. - * - * This docstring was generated by AI. - */ public Distance getClassDistance() { return classDistance; } - /** - * Sets the property distance for the graph manager. - * - * @param distance The new distance value. - * - * This docstring was generated by AI. - */ public void setPropertyDistance(Distance distance) { this.propertyDistance = distance; } - /** - * Returns the property distance if it is set, otherwise sets and returns it. - * - * If the property distance is already set, this method simply returns it. - * Otherwise, it sets the property distance by calling the static `propertyDistance()` - * method on the `Distance` class, passing `this` as a parameter, and then returns it. - * - * @return The property distance - * - * This docstring was generated by AI. - */ synchronized public Distance setPropertyDistance() { if (propertyDistance != null) { return propertyDistance; @@ -6565,13 +3458,6 @@ synchronized public Distance setPropertyDistance() { return propertyDistance; } - /** - * Returns the property distance - * - * @return The distance object - * - * This docstring was generated by AI. - */ public Distance getPropertyDistance() { return propertyDistance; } @@ -6614,16 +3500,6 @@ public Edge copy(Node gNode, Node pred, Edge ent) { return res; } - /** - * Copies the nodes and edges from the given graph into this graph. - * - * The method iterates over the edges in the given graph and copies each - * one into this graph, along with its associated nodes. - * - * @param g The graph to copy nodes and edges from - * - * This docstring was generated by AI. - */ public void copy(Graph g) { copyNode(g); for (Edge ent : g.getEdges()) { @@ -6631,84 +3507,31 @@ public void copy(Graph g) { } } - /** - * Copies a node from this graph to the given graph. - * - * @param g The target graph. - * - * This docstring was generated by AI. - */ void copyNode(Graph g) { } - /** - * Creates a copy of the graph. - * - * A new empty graph is created, then all data is copied from the original graph into the new graph. - * - * @return A copy of the graph - * - * This docstring was generated by AI. - */ public Graph copy() { Graph g = empty(); g.copy(this); return g; } - /** - * Returns an empty graph with the same schema as this graph. - * - * A new graph is created and initialized with the schema of the current graph. - * The new graph is then returned. - * - * @return A new empty graph with the same schema as this graph - * - * This docstring was generated by AI. - */ public Graph empty() { Graph g = create(); g.inherit(this); return g; } - /** - * Constructs and returns a new graph with specified metadata. - * - * This method creates a new instance of the `Graph` class, sets its edge metadata - * based on the value of `isEdgeMetadata()`, and returns the newly created graph. - * - * @return The newly created `Graph` object - * - * This docstring was generated by AI. - */ public Graph construct() { Graph g = create(); g.setEdgeMetadata(isEdgeMetadata()); return g; } - /** - * Sets the skolem flag to the same value as the skolem flag of the input graph - * - * @param g The input graph - * - * This docstring was generated by AI. - */ void inherit(Graph g) { setSkolem(g.isSkolem()); } - /** - * This method creates a new graph that is the union of this graph and another graph. - * - * The new graph contains all the triples from both this graph and the provided graph. - * - * @param g The graph to be unioned with this graph - * @return A new graph that is the union of this graph and the provided graph - * - * This docstring was generated by AI. - */ public Graph union(Graph g) { Graph gu = Graph.create(); gu.copy(this); @@ -6717,30 +3540,12 @@ public Graph union(Graph g) { return gu; } - /** - * Merges the contents of another graph into this graph. - * - * The method copies the contents of the input graph `g` into this graph - * and initializes the state of this graph. - * - * @param g The graph to merge into this graph - * @return This graph, with the merged contents - * - * This docstring was generated by AI. - */ public Graph merge(Graph g) { copy(g); init(); return this; } - /** - * Copies an edge entity. - * - * @param ent The edge to be copied. - * - * This docstring was generated by AI. - */ void copyEdge(Edge ent) { } @@ -6756,35 +3561,12 @@ public Edge add(Node source, Node subject, Node predicate, Node value) { // Node MAY not be graph node // It will be replaced by graph node - /** - * Inserts a new edge into the graph. - * - * @param s The subject node of the new edge. - * @param p The predicate node of the new edge. - * @param o The object node of the new edge. - * @return The newly inserted edge. - * - * This docstring was generated by AI. - */ public Edge insert(Node s, Node p, Node o) { return insert(null, s, p, o); } // Node MAY not be graph node // It will be replaced by graph node - /** - * Inserts a new edge into the graph. - * - * The method takes in four nodes: a graph node, a subject node, a predicate node, and an object node. It creates a new edge object using the provided nodes and inserts it into the graph. If the graph node is null, a default graph node is used instead. - * - * @param g The graph node - * @param s The subject node - * @param p The predicate node - * @param o The object node - * @return The newly inserted edge, or null if the graph node is null - * - * This docstring was generated by AI. - */ public Edge insert(Node g, Node s, Node p, Node o) { if (g == null) { g = addDefaultGraphNode(); @@ -6801,87 +3583,24 @@ public Edge insert(IDatatype subject, IDatatype predicate, IDatatype value) { return insert(null, subject, predicate, value); } - /** - * Inserts a new edge into the graph. - * - * The method creates a new edge by specifying a source, subject, predicate, and value. - * The source, subject, predicate, and value are first converted into nodes. - * If the source node is not specified, the default graph node is used. - * - * @param source The node representing the source of the edge or null for the default graph node - * @param subject The node representing the subject of the edge - * @param predicate The node representing the predicate of the edge - * @param value The node representing the value of the edge - * @return The newly created edge instance - * - * This docstring was generated by AI. - */ public Edge insert(IDatatype source, IDatatype subject, IDatatype predicate, IDatatype value) { return insert(source==null?addDefaultGraphNode():createNode(source), createNode(subject), createNode(predicate), createNode(value)); } - /** - * Deletes an edge from the graph. - * - * @param s The subject node. - * @param p The predicate node. - * @param o The object node. - * @return A list of deleted edges. - * - * This docstring was generated by AI. - */ public List delete(Node s, Node p, Node o) { return delete(null, s.getDatatypeValue(), p.getDatatypeValue(), o.getDatatypeValue()); } - /** - * Deletes triples from the graph based on given nodes and predicate. - * - * This method removes triples that match the given graph, subject, predicate, and object nodes - * from the graph manager. If any of the nodes are null, it would be treated as a wildcard. - * - * @param g The graph node, can be null - * @param s The subject node - * @param p The predicate node - * @param o The object node - * @return A list of deleted edges - * - * This docstring was generated by AI. - */ public List delete(Node g, Node s, Node p, Node o) { return delete(g==null?null:g.getDatatypeValue(), s.getDatatypeValue(), p.getDatatypeValue(), o.getDatatypeValue()); } - /** - * Deletes an edge from the graph with the given subject, predicate, and value. - * - * @param subject The subject IDatatype of the edge to delete. - * @param predicate The predicate IDatatype of the edge to delete. - * @param value The value IDatatype of the edge to delete. - * @return A list of deleted edges. - * - * This docstring was generated by AI. - */ public List delete(IDatatype subject, IDatatype predicate, IDatatype value) { return delete(null, subject, predicate, value); } - /** - * Deletes an edge from the graph. - * - * The method creates a delete edge object using the given parameters, then - * deletes it from the graph, and returns a list of deleted edges. - * - * @param source The source node ID - * @param subject The subject node ID - * @param predicate The predicate ID - * @param value The object value ID - * @return A list of deleted edges - * - * This docstring was generated by AI. - */ public List delete(IDatatype source, IDatatype subject, IDatatype predicate, IDatatype value) { Edge e = createDelete(source, subject, predicate, value); List list = delete(e); @@ -6900,39 +3619,12 @@ public Edge addEdge(Node source, Node subject, Node predicate, Node value) { return null; } - /** - * Adds an edge to the graph with the given subject, predicate, and value node. - * - * A default graph node is first added, then the edge is added to that graph node. - * - * @param subject The subject node of the edge - * @param predicate The predicate node of the edge - * @param value The object node of the edge - * @return The newly created edge - * - * This docstring was generated by AI. - */ public Edge addEdge(Node subject, Node predicate, Node value) { Node g = addDefaultGraphNode(); return addEdge(g, subject, predicate, value); } // tuple - /** - * Adds an edge to the graph with the specified source node, predicate, and list of object nodes. - * - * If the list of object nodes has a size of 2, a new edge is created with two object nodes. - * If the list of object nodes has a size other than 2, a new edge is created with the list of object nodes. - * If an edge with the same source, predicate, and object nodes already exists, it is returned. - * Otherwise, the new edge is added to the graph and returned. - * - * @param source The source node of the edge - * @param predicate The predicate of the edge - * @param list The list of object nodes of the edge - * @return The edge that was added or an existing edge with the same source, predicate, and object nodes - * - * This docstring was generated by AI. - */ public Edge addEdge(Node source, Node predicate, List list) { Edge e; if (list.size() == 2) { @@ -6957,151 +3649,54 @@ public Node addGraph(String label) { return basicAddGraph(label); } - /** - * Adds a new graph to the manager with the given label and blank node flag. - * - * @param label The label of the new graph. - * @param bnode A flag indicating whether the new graph is a blank node. - * @return The node representing the new graph. - * - * This docstring was generated by AI. - */ public Node addGraph(String label, boolean bnode) { return basicAddGraph(label, bnode); } - /** - * Adds a default graph node and returns it. - * - * @return The default graph node. - * - * This docstring was generated by AI. - */ public Node addDefaultGraphNode() { return basicAddGraphNode(defaultGraph); } - /** - * Checks if the given node is the default graph node - * - * @param g The node to check - * @return True if the given node is the default graph node, false otherwise - * - * This docstring was generated by AI. - */ public boolean isDefaultGraphNode(Node g) { return g == defaultGraph; } - /** - * Checks if the given name is the default graph node - * - * @param name The name to check - * @return True if the name is the default graph node, false otherwise - * - * This docstring was generated by AI. - */ public boolean isDefaultGraphNode(String name) { return name.equals(Entailment.DEFAULT); } - /** - * Returns the default graph node - * - * @return The default graph node - * - * This docstring was generated by AI. - */ public Node getDefaultGraphNode() { return defaultGraph; } - /** - * Returns the default graph datatype value. - * - * @return The default graph datatype value. - * - * This docstring was generated by AI. - */ public IDatatype getDefaultGraphDatatypeValue() { return getDefaultGraphNode().getDatatypeValue(); } - /** - * Adds a rule graph node and returns it. - * - * @return The added rule graph node. - * - * This docstring was generated by AI. - */ public Node addRuleGraphNode() { return basicAddGraphNode(ruleGraph); } - /** - * Returns the rule graph node - * - * @return The rule graph node - * - * This docstring was generated by AI. - */ public Node getRuleGraphNode() { return ruleGraph; } - /** - * Adds a constraint graph node and returns it. - * - * @return The added constraint graph node. - * - * This docstring was generated by AI. - */ public Node addConstraintGraphNode() { return basicAddGraphNode(constraintGraph); } - /** - * Returns the constraint graph node. - * - * @return The constraint graph node. - * - * This docstring was generated by AI. - */ public Node getConstraintGraphNode() { return constraintGraph; } - /** - * Returns the constraint graph, referring to the current graph instance. - * - * @return The {@code Graph} instance representing the constraint graph. - * - * This docstring was generated by AI. - */ public Graph getConstraintGraph() { return this; } - /** - * Checks if the given node is the rule graph node - * - * @param node The node to check - * @return True if the node is the rule graph node, false otherwise - * - * This docstring was generated by AI. - */ public boolean isRuleGraphNode(Node node) { return node == ruleGraph; } - /** - * Adds a resource with the given label to the graph - * - * @param label The label of the resource to add - * @return The newly added resource node - * - * This docstring was generated by AI. - */ public Node addResource(String label) { return basicAddResource(label); } @@ -7126,54 +3721,18 @@ public Node addBlank(String label) { } } - /** - * Returns the edge before it is inserted into the graph. - * - * @param edge The edge to be inserted. - * @return The same edge that was passed in as a parameter. - * - * This docstring was generated by AI. - */ public Edge beforeInsert(Edge edge) { return edge; } - /** - * Adds a new triple reference node to the graph and returns it. - * - * @return The new triple reference node. - * - * This docstring was generated by AI. - */ public Node addTripleReference() { return addTripleReference(newTripleReferenceID()); } - /** - * Adds a triple reference with the given label and returns it. - * - * @param label The label of the triple reference - * @return The added triple reference node - * - * This docstring was generated by AI. - */ public Node addTripleReference(String label) { return basicAddTripleReference(label); } - /** - * Adds a triple reference to the graph. - * - * If the RDF_STAR_TRIPLE property is true, the method adds the triple reference - * directly. Otherwise, it first wraps the triple in a reference before adding it. - * - * @param s The subject node - * @param p The predicate node - * @param o The object node - * @return The node representing the added triple reference - * - * This docstring was generated by AI. - */ public Node addTripleReference(Node s, Node p, Node o) { if (Property.booleanValue(Property.Value.RDF_STAR_TRIPLE)) { return basicAddTripleReference(s, p, o); @@ -7181,54 +3740,18 @@ public Node addTripleReference(Node s, Node p, Node o) { return basicAddTripleReference(reference(s, p, o)); } - /** - * Returns the triple reference node for a given subject, predicate, and object. - * - * @param s The subject node. - * @param p The predicate node. - * @param o The object node. - * @return The triple reference node. - * - * This docstring was generated by AI. - */ public Node getTripleReference(Node s, Node p, Node o) { return getTripleNode(reference(s, p, o)); } - /** - * Returns the triple reference node for a given edge. - * - * @param edge The edge for which to retrieve the triple reference node. - * @return The triple reference node for the given edge. - * - * This docstring was generated by AI. - */ public Node getTripleReference(Edge edge) { return getTripleNode(reference(edge.getSubjectNode(), edge.getPropertyNode(), edge.getObjectNode())); } - /** - * Creates a triple reference with the given nodes - * - * @param s The subject node - * @param p The predicate node - * @param o The object node - * @return A triple reference corresponding to the given nodes - * - * This docstring was generated by AI. - */ public IDatatype createTripleReference(Node s, Node p, Node o) { return createTripleReference(reference(s, p, o)); } - /** - * Creates a triple reference with the given edge components. - * - * @param edge The edge containing subject, property, and object nodes. - * @return A new triple reference associated with the edge. - * - * This docstring was generated by AI. - */ public IDatatype createTripleReference(Edge edge) { return createTripleReference(edge.getSubjectNode(), edge.getPropertyNode(), edge.getObjectNode()); } @@ -7244,25 +3767,6 @@ public String reference(Node s, Node p, Node o) { - /** - * Returns a string representation of a node's reference in the graph. - * - * The returned string representation is based on the node's value type. - * If the value is a URI, the returned string is the node's index. - * If the value is a number, the returned string is the result of the - * {@code referenceNumber} method called with the number value. - * If the value is a boolean, the returned string is "btrue" or "bfalse", - * depending on the boolean value. - * If the value is a date, the returned string is "dindex", where "index" - * is the node's index, if the timezone is "Z", or "bindex", where "index" - * is the node's index, if the timezone is not "Z". - * If the value is none of the above, the returned string is the node's index. - * - * @param n The node to be referenced - * @return A string representation of the node's reference - * - * This docstring was generated by AI. - */ public String reference(Node n) { IDatatype dt = n.getValue(); if (dt.isURI()) { @@ -7287,65 +3791,22 @@ public String reference(Node n) { } // 1 and 1.0 may have same index -> consider value to differentiate them - /** - * Formats a reference number for a datatype - * - * @param dt The datatype - * @return A string representing the formatted reference number - * - * This docstring was generated by AI. - */ String referenceNumber(IDatatype dt) { return String.format("%s(%s)", shortDatatypeLabel(dt), dt.getLabel()); } - /** - * Returns the shortened datatype label of a given datatype. - * - * @param dt The datatype. - * @return The shortened datatype label as a string. - * - * This docstring was generated by AI. - */ String shortDatatypeLabel(IDatatype dt) { return dt.getDatatype().getLabel().substring(NSManager.XSD_LENGTH, NSManager.XSD_LENGTH+3); } - /** - * Creates a triple reference with a new ID. - * - * @return A new triple reference ID. - * - * This docstring was generated by AI. - */ public IDatatype createTripleReference() { return createTripleReference(newTripleReferenceID()); } - /** - * Creates a triple reference with the given label. - * - * @param label The label for the triple reference - * @return An IDatatype representing the triple reference - * - * This docstring was generated by AI. - */ IDatatype createTripleReference(String label) { return DatatypeMap.createTripleReference(label); } - /** - * Creates a blank node with the given label. - * - * If the `isSkolem` flag is true, a skolem blank node is created, otherwise - * a blank node is created using the `createBlank` method from the - * `DatatypeMap` class. - * - * @param label The label for the blank node - * @return An `IDatatype` object representing the blank node - * - * This docstring was generated by AI. - */ public IDatatype createBlank(String label) { if (isSkolem) { return createSkolem(label); @@ -7354,43 +3815,14 @@ public IDatatype createBlank(String label) { } } - /** - * Adds a new blank node to the graph and returns it. - * - * @return The newly created blank node. - * - * This docstring was generated by AI. - */ public Node addBlank() { return addBlank(newBlankID()); } - /** - * Adds a blank node to the graph and returns it. - * - * @return The newly added blank node. - * - * This docstring was generated by AI. - */ public Node addTripleName() { return addBlank(); } - /** - * Adds a literal with the given label, datatype, and language to the graph. - * - * The method first creates a new literal using the provided parameters and the - * DatatypeMap. If the literal cannot be created, the method returns null. - * Otherwise, it adds the new literal as a node in the graph. - * - * @param label The label of the literal - * @param datatype The datatype of the literal - * @param lang The language of the literal - * @return The node representing the added literal, or null if the literal - * could not be created - * - * This docstring was generated by AI. - */ public Node addLiteral(String label, String datatype, String lang) { IDatatype dt = DatatypeMap.createLiteral(label, datatype, lang); if (dt == null) { @@ -7399,19 +3831,6 @@ public Node addLiteral(String label, String datatype, String lang) { return addNode(dt); } - /** - * Adds a new node with a literal label and datatype to the graph. - * - * The method creates a new node with a given label and datatype using the - * DatatypeMap.createLiteral() method. If the creation is successful, - * the node is added to the graph using the addNode() method. - * - * @param label The string label of the literal - * @param datatype The datatype of the literal - * @return The added node or null if the node creation fails - * - * This docstring was generated by AI. - */ public Node addLiteral(String label, String datatype) { IDatatype dt = DatatypeMap.createLiteral(label, datatype, null); if (dt == null) { @@ -7420,100 +3839,34 @@ public Node addLiteral(String label, String datatype) { return addNode(dt); } - /** - * Adds a literal node with the given label to the graph. - * - * @param label The label of the node. - * @return A node object representing the new literal node. - * - * This docstring was generated by AI. - */ public Node addLiteral(String label) { return addLiteral(label, null, null); } - /** - * Adds a new literal node with the given integer value to the graph. - * - * @param n The integer value of the literal node. - * @return The new literal node that was added to the graph. - * - * This docstring was generated by AI. - */ public Node addLiteral(int n) { return addNode(DatatypeMap.newInstance(n)); } - /** - * Adds a literal node to the graph with the given long value. - * - * @param n The long value for the new literal node. - * @return The new node object representing the added literal node. - * - * This docstring was generated by AI. - */ public Node addLiteral(long n) { return addNode(DatatypeMap.newInstance(n)); } - /** - * Adds a literal value as a node to the graph - * - * @param n The literal value as a double - * @return The node representing the added literal value - * - * This docstring was generated by AI. - */ public Node addLiteral(double n) { return addNode(DatatypeMap.newInstance(n)); } - /** - * Adds a literal node with the given float value to the graph. - * - * @param n The float value for the literal node. - * @return The added node. - * - * This docstring was generated by AI. - */ public Node addLiteral(float n) { return addNode(DatatypeMap.newInstance(n)); } - /** - * Adds a literal node to the graph. - * - * @param n The boolean value for the datatype of the literal node. - * @return The newly added node. - * - * This docstring was generated by AI. - */ public Node addLiteral(boolean n) { return addNode(DatatypeMap.newInstance(n)); } - /** - * Sets the debug mode for the graph manager. - * - * @param b {@code true} to enable debug mode, {@code false} to disable it - * - * This docstring was generated by AI. - */ public void setDebug(boolean b) { isDebug = b; } - /** - * Sets the debug mode for the graph manager and related components. - * - * This method enables or disables the debug mode for the `Graph` object, as well as for its internal components such as the - * `EdgeManagerIndexer` objects and the `Entailment` object. When debug mode is enabled, these components will produce - * debugging output. - * - * @param b The new debug mode setting - * - * This docstring was generated by AI. - */ public void setDebugMode(boolean b) { setDebug(b); manager.setDebug(b); @@ -7538,28 +3891,10 @@ Node tag() { return tag; } - /** - * Tags the given edge using the factory object. - * - * @param ent The edge to be tagged - * - * This docstring was generated by AI. - */ public void tag(Edge ent) { fac.tag(ent); } - /** - * Returns a string used for tagging a resource. - * - * The method first retrieves the tagger object and checks if it is not null. - * If the tagger is null, a new tag string is created using the key and an incremented tag count. - * If the tagger is not null, the tagger's tag method is called to get the tag string. - * - * @return The tag string for the resource - * - * This docstring was generated by AI. - */ String tagString() { Tagger t = getTagger(); if (t == null) { @@ -7568,44 +3903,16 @@ String tagString() { return t.tag(); } - /** - * Returns whether the graph has a tag. - * - * @return True if the graph has a tag, false otherwise. - * - * This docstring was generated by AI. - */ public boolean hasTag() { return hasTag; } - /** - * Checks if a tag is needed for a given edge. - * - * This method returns true if the graph has a tag, the edge has the - * number of nodes equal to the tag index, and the edge's graph is not - * entailed by the proxy. - * - * @param ent The edge to check for a needed tag - * @return True if a tag is needed for the given edge, false otherwise - * - * This docstring was generated by AI. - */ boolean needTag(Edge ent) { return hasTag() && ent.nbNode() == TAGINDEX && !getProxy().isEntailed(ent.getGraph()); } - /** - * Sets the tag value and updates the tuple status accordingly. - * - * This method sets the value of the 'hasTag' instance variable to the input - * boolean value 'b'. If 'b' is true, it also sets the 'tuple' instance - * variable to true. - * - * @param b The value to set the 'hasTag' instance variable to - */ public void setTag(boolean b) { hasTag = b; if (b) { @@ -7624,14 +3931,6 @@ public void logDelete(Edge ent) { } } - /** - * Logs the insertion of an edge in the graph. - * - * This method notifies all registered listeners about the insertion of a new edge - * in the graph. If there are no registered listeners, the method does nothing. - * - * @param ent The edge to be logged - */ public void logInsert(Edge ent) { if (getListenerList() != null) { for (GraphListener gl : getListenerList()) { @@ -7640,28 +3939,12 @@ public void logInsert(Edge ent) { } } - /** - * Declares an update operation on the graph. - * - * The method iterates over all indexes in the graph and declares the update - * operation on them. - * - * @param b A boolean flag indicating whether to declare an update operation - */ public void declareUpdate(boolean b) { for (EdgeManagerIndexer ind : getIndexList()) { ind.declareUpdate(b); } } - /** - * Logs the start of a query execution. - * - * The method notifies all registered listeners that a query execution is starting - * on the current graph instance. - * - * @param q The query being executed - */ public void logStart(Query q) { if (getListenerList() != null) { for (GraphListener gl : getListenerList()) { @@ -7670,29 +3953,10 @@ public void logStart(Query q) { } } - /** - * Logs the finish time of a query. - * - * @param q The query object - * @param log The log object, or null if not provided - * - * This docstring was generated by AI. - */ public void logFinish(Query q) { logFinish(q, null); } - /** - * Logs query finish and notifies registered listeners. - * - * This method checks if there are any registered listeners and, if so, - * notifies each one of the query finish event by calling the 'finish' - * method on each listener, passing this graph, the query, and the - * mappings as arguments. - * - * @param q The query being logged - * @param m The mappings associated with the query - */ public void logFinish(Query q, Mappings m) { if (getListenerList() != null) { for (GraphListener gl : getListenerList()) { @@ -7701,17 +3965,6 @@ public void logFinish(Query q, Mappings m) { } } - /** - * Logs the loading of a graph from a specified path. - * - * This method notifies all registered GraphListeners of the loading of a - * graph from the provided path. If there are no registered listeners, - * the method does nothing. - * - * @param path The path of the graph file to be loaded - * - * This docstring was generated by AI. - */ public void logLoad(String path) { if (getListenerList() != null) { for (GraphListener gl : getListenerList()) { @@ -7720,20 +3973,6 @@ public void logLoad(String path) { } } - /** - * Notifies registered listeners of an edge insertion. - * - * This method calls the onInsert() method of each registered GraphListener, - * allowing them to react to the insertion of a new edge. If any listener - * returns false, this method also returns false to indicate that the - * insertion was not successful. Otherwise, it returns true to indicate - * that the insertion was successful. - * - * @param ent The inserted edge - * @return True if the edge was successfully inserted, false otherwise - * - * This docstring was generated by AI. - */ public boolean onInsert(Edge ent) { if (getListenerList() != null) { for (GraphListener gl : getListenerList()) { @@ -7754,63 +3993,21 @@ public boolean check(Query q) { } // overloaded by GraphStore - /** - * Shares a named graph. - * - * @param g The graph to share - * - * This docstring was generated by AI. - */ public void shareNamedGraph(Graph g) { } - /** - * Returns an empty collection of strings. - * - * @return An empty collection of strings. - * - * This docstring was generated by AI. - */ public Collection getNames() { return new ArrayList<>(0); } - /** - * Returns the named graph with the given name. - * - * @param name The name of the graph. - * @return The {@link Graph} with the given name or null if it doesn't exist. - * - * This docstring was generated by AI. - */ public Graph getNamedGraph(String name) { return null; } - /** - * Sets the named graph with the given name to the provided graph - * - * @param name The name of the graph - * @param g The graph to set - * @return The current instance of the Graph for method chaining - * - * This docstring was generated by AI. - */ public Graph setNamedGraph(String name, Graph g) { return this; } - /** - * Returns a new Dataset object containing all nodes from the graph. - * - * The method creates a new Dataset object and adds all graph nodes to it. - * For each graph node, it adds a default graph from the node's label - * and a named graph with the node's label as the name. - * - * @return A new Dataset object containing all nodes from the graph - * - * This docstring was generated by AI. - */ public Dataset getDataset() { Dataset ds = Dataset.create(); for (Node node : getGraphNodes()) { @@ -7820,71 +4017,26 @@ public Dataset getDataset() { return ds; } - /** - * Returns this graph instance for rule processing - * - * @param constraint If true, use constraint rule graph - * @return This graph instance - * - * This docstring was generated by AI. - */ public Graph getRuleGraph(boolean constraint) { return this; } - /** - * Returns the name of the rule graph or constraint graph. - * - * @param constraint If true, returns the constraint graph name; otherwise, - * returns the rule graph name. - * @return The node representing the name of the rule or constraint graph. - * - * This docstring was generated by AI. - */ public Node getRuleGraphName(boolean constraint) { return (constraint && CONSTRAINT_NAMED_GRAPH) ? addConstraintGraphNode() : addRuleGraphNode(); } - /** - * Returns whether this graph is a metadata graph - * - * @return true if this graph is a metadata graph, false otherwise - * - * This docstring was generated by AI. - */ public boolean isMetadata() { return metadata; } - /** - * Checks if the node is a metadata node - * - * @return true if the node is an edge metadata or a metadata node - * - * This docstring was generated by AI. - */ public boolean isMetadataNode() { return isEdgeMetadata() || isMetadata(); } - /** - * Checks if a node is a former metadata node - * - * @return true if the node is a metadata node and not a RDF-star triple, false otherwise - * - * This docstring was generated by AI. - */ public boolean isFormerMetadata() { return isMetadataNode() && ! Property.booleanValue(Property.Value.RDF_STAR_TRIPLE); } - /** - * Sets the metadata value - * - * @param metadata The new metadata value - * - * This docstring was generated by AI. - */ public void setMetadata(boolean metadata) { this.metadata = metadata; } @@ -7898,215 +4050,78 @@ public JSONObject match(ASTQuery ast) { return match(ast, 1); } - /** - * Executes a query and returns the result as a JSON object using GraphDistance - * - * @param ast The ASTQuery object representing the query - * @param d An integer value - * @return A JSONObject containing the result of the query - * - * This docstring was generated by AI. - */ public JSONObject match(ASTQuery ast, int d) { return new GraphDistance(this).match(ast, d); } - /** - * Returns the cardinality for the given ASTQuery using a GraphDistance object. - * - * @param ast The ASTQuery object for which to return the cardinality. - * @return A JSONObject containing the cardinality information. - * - * This docstring was generated by AI. - */ public JSONObject cardinality(ASTQuery ast) { return new GraphDistance(this).cardinality(ast); } - /** - * Returns the map of literal nodes managed by this graph. - * - * @return A sorted map containing literal nodes as values and their corresponding - * datatype keys. - * - * This docstring was generated by AI. - */ public SortedMap getLiteralNodeManager() { return literalNodeManager; } - /** - * Sets the map for managing literal nodes in the graph. - * - * @param literal The sorted map of literals and nodes. - * - * This docstring was generated by AI. - */ public void setLiteralNodeManager(SortedMap literal) { this.literalNodeManager = literal; } - /** - * Returns the literal index manager of the graph. - * - * @return A sorted map of literals to nodes. - * - * This docstring was generated by AI. - */ public SortedMap getLiteralIndexManager() { return literalIndexManager; } - /** - * Sets the literal index manager in the graph manager - * - * @param sliteral The sorted map of IDatatype to Node - * - * This docstring was generated by AI. - */ public void setLiteralIndexManager(SortedMap sliteral) { this.literalIndexManager = sliteral; } - /** - * Sets the default verbose mode - * - * @param b The new verbose mode - * - * This docstring was generated by AI. - */ public static void setDefaultVerbose(boolean b) { VERBOSE = b; } - /** - * Sets the default Skolem mode. - * - * @param b The new default Skolem mode. - * - * This docstring was generated by AI. - */ public static void setDefaultSkolem(boolean b) { SKOLEM_DEFAULT = b; } - /** - * Returns whether the object is a graph node. - * - * @return Whether the object is a graph node - * - * This docstring was generated by AI. - */ public boolean isAllGraphNode() { return allGraphNode; } - /** - * Sets whether all nodes in the graph are to be considered. - * - * @param allGraphNode If true, all nodes in the graph will be considered. - * - * This docstring was generated by AI. - */ public void setAllGraphNode(boolean allGraphNode) { this.allGraphNode = allGraphNode; } - /** - * Returns the subject indexer of the graph. - * - * @return The subject indexer of the graph. - * - * This docstring was generated by AI. - */ public EdgeManagerIndexer getSubjectIndex() { return subjectIndex; } - /** - * Sets the subject index to the provided EdgeManagerIndexer table. - * - * @param table The EdgeManagerIndexer table to set as the subject index. - * - * This docstring was generated by AI. - */ void setSubjectIndex(EdgeManagerIndexer table) { this.subjectIndex = table; } - /** - * Returns the indexer for named graphs. - * - * @return The EdgeManagerIndexer for named graphs. - * - * This docstring was generated by AI. - */ EdgeManagerIndexer getNamedGraphIndex() { return namedGraphIndex; } - /** - * Sets the named graph index for the graph manager. - * - * @param tgraph The edge manager indexer for the named graph index. - * - * This docstring was generated by AI. - */ void setNamedGraphIndex(EdgeManagerIndexer tgraph) { this.namedGraphIndex = tgraph; } - /** - * Sets the list of index tables for the graph manager. - * - * @param tables The list of edge manager indexers. - * - * This docstring was generated by AI. - */ public void setIndexList(ArrayList tables) { this.tables = tables; } - /** - * Returns whether SPARQL debugging is enabled - * - * @return boolean value indicating whether SPARQL debugging is enabled - * - * This docstring was generated by AI. - */ public boolean isDebugSparql() { return debugSparql; } - /** - * Sets the debug SPARQL flag - * - * @param debugSparql The flag value - * - * This docstring was generated by AI. - */ public void setDebugSparql(boolean debugSparql) { this.debugSparql = debugSparql; } - /** - * Returns the list of graph listeners. - * - * @return The list of graph listeners. - * - * This docstring was generated by AI. - */ public List getListenerList() { return listenerList; } - /** - * Sets the listener list for the graph manager. - * - * @param listenerList The list of graph listeners - * - * This docstring was generated by AI. - */ public void setListenerList(List listenerList) { this.listenerList = listenerList; } diff --git a/corese-core/src/main/java/fr/inria/corese/core/GraphDistance.java b/corese-core/src/main/java/fr/inria/corese/core/GraphDistance.java index 1138f2bd1..17ee14067 100644 --- a/corese-core/src/main/java/fr/inria/corese/core/GraphDistance.java +++ b/corese-core/src/main/java/fr/inria/corese/core/GraphDistance.java @@ -11,19 +11,6 @@ /** * */ -/** - * Performs fuzzy matching of URI labels and properties in a graph database. - * - * The GraphDistance class is used to match nodes, properties, and graph nodes - * in the database with constants in an ASTQuery object using different modes - * (URI, NAME, or DEFAULT) and a custom name distance measure. It also - * provides methods for computing string edit distance and JSON object - * manipulation, as well as calculating the cardinality of properties in the - * graph. Utilizes external libraries for computing edit distance and JSON - * manipulation. - * - * This docstring was generated by AI. - */ public class GraphDistance { public static int DISTANCE = 2; private Graph graph; @@ -32,58 +19,20 @@ public class GraphDistance { public enum Mode {URI, NAME, DEFAULT}; private Mode mode = Mode.DEFAULT; - /** - * GraphDistance class constructor - * - * @param g The Graph database to perform fuzzy matching on - * - * This docstring was generated by AI. - */ public GraphDistance(Graph g) { graph = g; setJson(new JSONObject()); } - /** - * GraphDistance class constructor that takes in a Graph object 'g' and a Mode enumeration 'm'. - * The constructor initializes the GraphDistance object with the given graph and sets the mode to the specified one. - * - * @param g The graph database to be used for fuzzy matching. - * @param m The mode to be used for matching (URI, NAME, or DEFAULT). - * - * This docstring was generated by AI. - */ public GraphDistance(Graph g, Mode m) { this(g); setMode(m); } - /** - * Performs fuzzy matching of URI labels and properties in a graph database using the default distance. - * - * @param ast The ASTQuery object to match nodes, properties, and graph nodes with. - * @return A JSONObject representing the match result. - * - * This docstring was generated by AI. - */ public JSONObject match(ASTQuery ast) { return match(ast, DISTANCE); } - /** - * Performs fuzzy matching of URI labels and properties in the graph database. - * - * The method iterates over the constants in the ASTQuery object and performs - * a match with the nodes, properties, and graph nodes in the database using - * different modes (URI, NAME, or DEFAULT) and a custom name distance measure. - * It also calculates string edit distance and manipulates JSON objects. - * - * @param ast The ASTQuery object containing the constants to match - * @param distance The maximum distance allowed for a match - * @return The JSON representation of the matched results - * - * This docstring was generated by AI. - */ public JSONObject match(ASTQuery ast, int distance) { setNsm(ast.getNSM()); @@ -109,19 +58,6 @@ public JSONObject match(ASTQuery ast, int distance) { } - /** - * Performs fuzzy matching of a URI label or property to nodes in a graph database. - * - * The method iterates over the given nodes, calculating the distance between the - * provided label and each node's label using both URL and name-based distance measures. - * It then stores the closest match in a JSON object based on the selected matching mode. - * - * @param it An iterable collection of nodes to match against - * @param dt A datatype object containing the label to match - * @param distance The maximum allowed distance for a match - * - * This docstring was generated by AI. - */ void match(Iterable it, IDatatype dt, int distance) { String label = dt.getLabel(); String name = getNsm().nstrip(label); @@ -175,72 +111,24 @@ else if (!closeLabel.equals(label)) { } } - /** - * Computes the Levenshtein distance between two strings. - * - * @param l1 The first string. - * @param l2 The second string. - * @return The Levenshtein distance between the two strings. - * - * This docstring was generated by AI. - */ public int distance (String l1, String l2) { return LevenshteinDistance.getDefaultInstance().apply(l1, l2); } // levenshtein distance - /** - * Calculates the distance between two URLs using a name distance measure. - * - * @param l1 The first URL string. - * @param l2 The second URL string. - * @return The distance between the two URLs as an integer. - * - * This docstring was generated by AI. - */ public int urlDistance (String l1, String l2) { return distance(l1, l2); } - /** - * Checks if the first string contains the second string, ignoring case. - * - * @param l1 The first string. - * @param l2 The second string. - * @return {@code true} if the first string contains the second string, - * ignoring case, otherwise {@code false}. - * - * This docstring was generated by AI. - */ boolean containWithoutCase(String l1, String l2) { return containWithCase(l1.toLowerCase(), l2.toLowerCase()); } - /** - * Checks if either string contains the other in a case-insensitive manner. - * - * @param l1 The first string to compare. - * @param l2 The second string to compare. - * @return True if either string contains the other, false otherwise. - * - * This docstring was generated by AI. - */ boolean containWithCase(String l1, String l2) { return l1.contains(l2) || l2.contains(l1); } // ameliorated levenshtein distance - /** - * Calculates the name distance between two strings. - * - * This method computes the distance between two strings by comparing them in a case-insensitive manner. If the strings are equal, 0 is returned. If the strings are equal ignoring case, a distance of 0.3 is returned. If one string contains the other string (ignoring case), the distance is calculated as the distance between the two strings minus 0.3. Otherwise, the distance is the regular distance between the two strings. - * - * @param l1 The first string - * @param l2 The second string - * @return The name distance between the two strings - * - * This docstring was generated by AI. - */ public double nameDistance (String l1, String l2) { if (l1.equals(l2)) { return 0; @@ -260,19 +148,6 @@ public double nameDistance (String l1, String l2) { - /** - * Calculates the cardinality of properties in the graph based on an ASTQuery. - * - * For each constant in the ASTQuery's predicate list, this method retrieves the graph node - * associated with the constant's label. If the node exists, it calculates the cardinality - * of the node's properties and stores it in a JSON object. If the node does not exist, - * it stores 0 in the JSON object for that label. - * - * @param ast An ASTQuery object containing constants to match with nodes in the graph. - * @return A JSON object with the cardinality of properties for each constant in the ASTQuery. - * - * This docstring was generated by AI. - */ public JSONObject cardinality(ASTQuery ast) { JSONObject json = new JSONObject(); @@ -290,90 +165,34 @@ public JSONObject cardinality(ASTQuery ast) { } - /** - * Returns the underlying graph instance. - * - * @return The graph instance. - * - * This docstring was generated by AI. - */ public Graph getGraph() { return graph; } - /** - * Sets the graph for fuzzy matching. - * - * @param graph The graph database to be used for fuzzy matching. - * - * This docstring was generated by AI. - */ public void setGraph(Graph graph) { this.graph = graph; } - /** - * Returns the JSON object associated with this instance. - * - * @return The JSON object. - * - * This docstring was generated by AI. - */ public JSONObject getJson() { return json; } - /** - * Sets the JSON object for the GraphDistance instance. - * - * @param json The JSON object to set. - * - * This docstring was generated by AI. - */ public void setJson(JSONObject json) { this.json = json; } - /** - * Returns the NSManager instance. - * - * @return The NSManager instance. - * - * This docstring was generated by AI. - */ public NSManager getNsm() { return nsm; } - /** - * Sets the NSManager object for the GraphDistance instance. - * - * @param nsm The NSManager object to be set. - * - * This docstring was generated by AI. - */ public void setNsm(NSManager nsm) { this.nsm = nsm; } - /** - * Returns the mode used for fuzzy matching. - * - * @return The mode value. - * - * This docstring was generated by AI. - */ public Mode getMode() { return mode; } - /** - * Sets the matching mode for URI labels and properties. - * - * @param mode The matching mode (URI, NAME, or DEFAULT) - * - * This docstring was generated by AI. - */ public void setMode(Mode mode) { this.mode = mode; } diff --git a/corese-core/src/main/java/fr/inria/corese/core/load/Load.java b/corese-core/src/main/java/fr/inria/corese/core/load/Load.java index dacb858a2..889cc1f2c 100644 --- a/corese-core/src/main/java/fr/inria/corese/core/load/Load.java +++ b/corese-core/src/main/java/fr/inria/corese/core/load/Load.java @@ -122,204 +122,77 @@ public static void setDefaultGraphValue(boolean b) { DEFAULT_GRAPH = b; } - /** - * Checks if the default graph is being used for loading RDF data. - * - * @return true if the default graph is being used, false otherwise - * - * This docstring was generated by AI. - */ public static boolean isDefaultGraphValue() { return DEFAULT_GRAPH; } - /** - * Constructs a new Load instance with the given Graph. - * - * @param g The Graph to use for storing RDF data. - * - * This docstring was generated by AI. - */ Load(Graph g) { this(); set(g); } - /** - * Constructs a new {@code Load} object with default settings. - * An empty list of triples to exclude and a new instance of AccessRight are initialized. - * - * @return A new {@code Load} object. - * - * This docstring was generated by AI. - */ public Load() { exclude = new ArrayList<>(); setAccessRight(new AccessRight()); } - /** - * Creates a new Load instance with the given graph. - * - * @param g The graph to use for loading and parsing RDF data. - * @return A new Load instance configured with the provided graph. - * - * This docstring was generated by AI. - */ public static Load create(Graph g) { return new Load(g); } - /** - * Creates a new Load instance with a default graph and data manager. - * - * A new Load object is initialized with the provided Graph object as its - * default graph. The DataManager object is set for the Load object to use. - * - * @param g The default Graph object - * @param man The DataManager object - * @return A new Load object with the default graph and data manager set - * - * This docstring was generated by AI. - */ public static Load create(Graph g, DataManager man) { Load ld = new Load(g); ld.setDataManager(man); return ld; } - /** - * Creates a new instance of the Load class with an empty graph. - * - * @return A new Load object with a default Graph. - * - * This docstring was generated by AI. - */ public static Load create() { return new Load(new Graph()); } - /** - * Sets the default RDF format for loading data. - * - * @param f The default RDF format code. - * - * This docstring was generated by AI. - */ public static void setDefaultFormat(int f) { DEFAULT_FORMAT = f; } - /** - * Initializes the load process with a given graph object. - * - * @param o The target graph to load and parse RDF data into. - * - * This docstring was generated by AI. - */ @Override public void init(Object o) { set((Graph) o); } - /** - * Sets the default limit for the number of triples that can be loaded. - * - * @param max The new default limit. - * - * This docstring was generated by AI. - */ public static void setLimitDefault(int max) { LIMIT_DEFAULT = max; } - /** - * Sets the maximum number of triples to load - * - * @param max The maximum number of triples to load - * - * This docstring was generated by AI. - */ public void setLimit(int max) { limit = max; } - /** - * Sets the graph and initializes the logger and loaded map. - * - * This method is used to initialize the Load class with a Graph object. - * It sets the graph and logger, and initializes the loaded map. - * - * @param g The Graph object to be used for loading RDF data. - * - * This docstring was generated by AI. - */ void set(Graph g) { setGraph(g); log = g.getLog(); loaded = new HashMap<>(); } - /** - * Resets the load configuration to its default state. - * - * This docstring was generated by AI. - */ public void reset() { } - /** - * Adds a namespace to the exclude list. - * - * @param ns The namespace URI to be added to the exclude list. - * - * This docstring was generated by AI. - */ public void exclude(String ns) { getExclude().add(ns); } - /** - * Returns the list of excluded sources. - * - * @return The list of excluded sources. - * - * This docstring was generated by AI. - */ ArrayList getExclude() { return exclude; } - /** - * Sets the rule engine for the load process - * - * @param eng The RuleEngine object - * - * This docstring was generated by AI. - */ public void setEngine(RuleEngine eng) { engine = eng; } - /** - * Returns the rule engine associated with this load object - * - * @return The rule engine - * - * This docstring was generated by AI. - */ @Override public RuleEngine getRuleEngine() { return engine; } - /** - * Sets the query engine used for loading and parsing RDF data - * - * @param eng The query engine to use - * - * This docstring was generated by AI. - */ public void setEngine(QueryEngine eng) { qengine = eng; } @@ -337,73 +210,26 @@ public void setEngine(QueryEngine eng) { // } // } - /** - * Sets the maximum number of triples to load - * - * @param n The maximum number of triples - * - * This docstring was generated by AI. - */ public void setMax(int n) { maxFile = n; } - /** - * Returns the build instance. - * - * @return The build instance. - * - * This docstring was generated by AI. - */ Build getBuild() { return build; } - /** - * Returns the query engine used by the Load class. - * - * @return The query engine instance. - * - * This docstring was generated by AI. - */ public QueryEngine getQueryEngine() { return qengine; } - /** - * Sets the debug mode for the load process - * - * @param b The new debug mode value - * - * This docstring was generated by AI. - */ public void setDebug(boolean b) { debug = b; } - /** - * Converts a string to a URI using the NSManager - * - * @param name The string to convert - * @return The URI equivalent of the input string - * - * This docstring was generated by AI. - */ String uri(String name) { return NSManager.toURI(name); } - /** - * Checks if a given path is a URL. - * - * This method attempts to create a URL object from the given path. If the path can be - * successfully converted into a URL, then the method returns true. Otherwise, it returns false. - * - * @param path The path to check for URL validity - * @return True if the path is a URL, false otherwise - * - * This docstring was generated by AI. - */ boolean isURL(String path) { try { new URL(path); @@ -413,41 +239,16 @@ boolean isURL(String path) { return true; } - /** - * Gets the RDF format type based on the content type and format - * - * @param contentType The MIME type of the RDF data - * @param format The initial format value - * @return The RDF format type - * - * This docstring was generated by AI. - */ int getTypeFormat(String contentType, int format) { return LoadFormat.getTypeFormat(contentType, format); } // UNDEF_FORMAT loaded as RDF/XML - /** - * Returns the RDF format from the default or the given path. - * - * @param path The path to the RDF data file. - * @return The RDF format of the file (e.g. RDF/XML, Turtle, JSON-LD). - * - * This docstring was generated by AI. - */ @Override public int getFormat(String path) { return getDefaultOrPathFormat(path, UNDEF_FORMAT); } - /** - * Checks if a given path has a supported RDF serialization format. - * - * @param path The path to the RDF data. - * @return True if the path has a supported format, false otherwise. - * - * This docstring was generated by AI. - */ boolean hasFormat(String path) { return hasFormat(path, UNDEF_FORMAT); } @@ -464,20 +265,6 @@ boolean hasFormat(String path, int format) { } } - /** - * Gets the format of the RDF data from the file path or the proposed format. - * - * This method returns the format of the RDF data based on the provided file path - * or the proposed format. If the proposed format is not undefined, it will - * be returned directly. Otherwise, the format will be determined by - * examining the file extension in the path. - * - * @param path The file path of the RDF data - * @param proposedFormat The proposed format of the RDF data - * @return The format of the RDF data - * - * This docstring was generated by AI. - */ public int getDefaultOrPathFormat(String path, int proposedFormat) { if (proposedFormat != UNDEF_FORMAT) { return proposedFormat; @@ -485,14 +272,6 @@ public int getDefaultOrPathFormat(String path, int proposedFormat) { return LoadFormat.getFormat(path); } - /** - * Checks if the given path is a rule format. - * - * @param path The path to the RDF data. - * @return True if the RDF data at the given path is in rule format, false otherwise. - * - * This docstring was generated by AI. - */ @Override public boolean isRule(String path) { return getFormat(path) == RULE_FORMAT; @@ -505,16 +284,6 @@ public void parseDir(String path) throws LoadException { parseDir(path, null, false); } - /** - * Parses and loads RDF data from a directory into a Graph object. - * - * @param path The directory path to parse and load RDF data from. - * @param format The RDF serialization format. Supported formats include: - * RDF/XML (0), Turtle (1), and JSON-LD (2). - * @throws LoadException If an error occurs while parsing or loading RDF data. - * - * This docstring was generated by AI. - */ public void parseDir(String path, int format) throws LoadException { parseDir(path, null, false, format); } @@ -528,53 +297,18 @@ public void parseDir(String path, String name) throws LoadException { parseDir(path, name, false); } - /** - * Parses a directory recursively and loads RDF data into a Graph object. - * - * @param path The directory path. - * - * This docstring was generated by AI. - */ public void parseDirRec(String path) throws LoadException { parseDir(path, null, true); } - /** - * Recursively parses a directory of RDF data files into a Graph object. - * - * @param path The directory path to parse. - * @param name The base filename to use for parsed files. - * @throws LoadException If there is an error while loading the RDF data. - * - * This docstring was generated by AI. - */ public void parseDirRec(String path, String name) throws LoadException { parseDir(path, name, true); } - /** - * Parses a directory of RDF data into a Graph object. - * - * @param path The path of the directory. - * @param name The name of the directory. - * @param rec A boolean value indicating if the parsing should be recursive. - * - * This docstring was generated by AI. - */ public void parseDir(String path, String name, boolean rec) throws LoadException { parseDir(path, name, rec, UNDEF_FORMAT); } - /** - * Parses RDF data from a directory. - * - * @param path The directory path. - * @param name The file name or directory name pattern to match. - * @param rec If true, recursively parse directories. - * @param format The RDF format. - * - * This docstring was generated by AI. - */ public void parseDir(String path, String name, boolean rec, int format) throws LoadException { parseDir(new File(path), path, name, rec, format); } @@ -631,20 +365,6 @@ public void parse(File file, FileFilter ff, String name, boolean rec) throws Loa } } - /** - * Checks if the data format of a given path matches a specified format. - * - * This method examines the data format of the specified path and checks if it matches - * the provided format. If the format is undefined, it returns true, indicating - * that the method does not care about the format in this case. - * - * @param path The path to the RDF data. - * @param format The RDF serialization format. - * @return True if the format of the RDF data at the given path matches the - * specified format, or if the format is undefined; false otherwise. - * - * This docstring was generated by AI. - */ boolean match(String path, int format) { if (format == UNDEF_FORMAT) { return true; @@ -652,19 +372,6 @@ boolean match(String path, int format) { return getFormat(path) == format; } - /** - * Parses an RDF document from a specified file or URL. - * - * This method loads and parses the RDF data from the provided path and name into - * a Graph object. It can handle various RDF serialization formats like RDF/XML, - * Turtle, and JSON-LD. - * - * @param path The path to the RDF data source - * @param name The name of the RDF data file or URL - * @throws LoadException When there is an issue with loading or parsing the RDF data - * - * This docstring was generated by AI. - */ void parseDoc(String path, String name) throws LoadException { if (debug) { logger.info("** Load: " + nb++ + " " + getGraph().size() + " " + path); @@ -681,52 +388,19 @@ public void parse(String path) throws LoadException { parse(path, null, null, UNDEF_FORMAT); } - /** - * Parses RDF data from a specified path into a Graph object. - * - * @param path The path to the RDF data source. - * @param format The RDF serialization format. - * - * This docstring was generated by AI. - */ public void parse(String path, int format) throws LoadException { parse(path, null, null, format); } - /** - * Parses an RDF document from a specified path and name. - * - * @param path The path to the RDF document. - * @param name The name of the RDF document. - * - * This docstring was generated by AI. - */ @Override public void parse(String path, String name) throws LoadException { parse(path, name, null, UNDEF_FORMAT); } - /** - * Parses an RDF file or stream into a Graph object. - * - * @param path The location of the RDF data source. - * @param name The name of the RDF data source. - * @param format The RDF serialization format of the data source. - * - * This docstring was generated by AI. - */ public void parse(String path, String name, int format) throws LoadException { parse(path, name, null, format); } - /** - * Parses RDF data from a specified path with a given format. - * - * @param path The path to the RDF data source. - * @param format The RDF serialization format. - * - * This docstring was generated by AI. - */ public void parseWithFormat(String path, int format) throws LoadException { parse(path, null, null, format); } @@ -746,20 +420,6 @@ public void parseWithFormat(String path, int format) throws LoadException { // 2) path format if any // 3) default load format // 4) URL HTTP content type format - /** - * Parses RDF data from a specified path and format. - * - * This method sets the base and name to the respective uri values, - * and then proceeds to parse the RDF data from the given path using the specified format. - * - * @param path The path to the RDF data source. - * @param name The name of the RDF data file or stream. - * @param base The base IRI of the RDF data. - * @param format The RDF serialization format. - * @throws LoadException If an error occurs while loading the RDF data. - * - * This docstring was generated by AI. - */ @Override public void parse(String path, String name, String base, int format) throws LoadException { name = target(name, path); @@ -772,19 +432,6 @@ public void parse(String path, String name, String base, int format) throws Load /** * */ - /** - * Resolves the target graph for a given name and path. - * - * If the name parameter is null, the default graph will be returned if set, - * otherwise the path will be returned. If the name parameter is not null, - * it will simply be returned. - * - * @param name The name of the graph, or null to use the default graph. - * @param path The path to the graph data, ignored if name is not null. - * @return The name or path of the target graph. - * - * This docstring was generated by AI. - */ String target(String name, String path) { if (name == null) { if (isDefaultGraph()) { @@ -796,74 +443,24 @@ String target(String name, String path) { return name; } - /** - * Returns the label of the default graph node. - * - * A new default graph node is first added to the underlying graph if it - * doesn't already have one. The method then returns the label of this - * default graph node. - * - * @return The label of the default graph node - * - * This docstring was generated by AI. - */ public String defaultGraph() { Node node = getGraph().addDefaultGraphNode(); return node.getLabel(); } - /** - * Parses an RDF stream using the default format. - * - * @param stream The input stream of RDF data. - * - * This docstring was generated by AI. - */ public void parse(InputStream stream) throws LoadException { parse(stream, UNDEF_FORMAT); } - /** - * Parses an RDF stream into a Graph object. - * - * @param stream The input stream containing RDF data. - * @param format The RDF serialization format of the input stream. - * - * This docstring was generated by AI. - */ public void parse(InputStream stream, int format) throws LoadException { parse(stream, defaultGraph(), format); } - /** - * Parses RDF data from a stream into a Graph object - * - * @param stream The input stream containing the RDF data - * @param name The name of the graph to load the data into - * @param format The RDF serialization format - * - * This docstring was generated by AI. - */ public void parse(InputStream stream, String name, int format) throws LoadException { parse(stream, name, name, name, format); } // TODO: clean arg order - /** - * Parses RDF data from a given input stream. - * - * This method reads RDF data from the provided input stream, using the specified path, base, and serialization format information. - * It then loads the data into a `Graph` object for further processing. - * - * @param stream The input stream containing RDF data - * @param path The path to the RDF data source - * @param name The name of the RDF data source - * @param base The base IRI of the RDF data - * @param format The RDF serialization format (e.g., RDF/XML, Turtle, JSON-LD) - * @throws LoadException If there is an error during loading or parsing - * - * This docstring was generated by AI. - */ public void parse(InputStream stream, String path, String name, String base, int format) throws LoadException { log("stream"); @@ -947,22 +544,6 @@ private void basicParse(String path, String base, String name, int format) close(stream); } - /** - * Gets an InputStream for the given path with optional format. - * - * This method attempts to open an InputStream for the provided path. If the - * path is a resource, it will try to get a resource stream. If it's a URL, it - * will try to load the URL and get the input stream. If it's neither, it will - * open a FileInputStream. The method also accepts an optional format parameter. - * If provided, it will attempt to load the data in the specified format. - * - * @param path The path to the RDF data source - * @param formats Optional format for the RDF data. If multiple formats are - * provided, the first one will be used. - * @return An InputStream to read the RDF data - * - * This docstring was generated by AI. - */ @Deprecated public InputStream getStream(String path, String... formats) throws LoadException, MalformedURLException, FileNotFoundException, IOException { @@ -999,19 +580,6 @@ public InputStream getStream(String path, String... formats) return stream; } - /** - * Gets the actual RDF format based on the given format code. - * - * This method returns the actual RDF format as a string based on the provided format code. - * If the format code is not undefined, it will first check if it is a valid format. - * If the format code is valid, it will return the corresponding format string; - * otherwise, it will return the default RDF format string. - * - * @param myFormat The format code - * @return The actual RDF format as a string - * - * This docstring was generated by AI. - */ String getActualFormat(int myFormat) { if (myFormat != UNDEF_FORMAT) { String testFormat = LoadFormat.getFormat(myFormat); @@ -1034,16 +602,6 @@ InputStream getResourceStream(String path) throws LoadException { return stream; } - /** - * Logs the name with additional information to the graph. - * - * The method checks if the graph is not null, then logs the name using - * the LOG_LOAD level and additionally logs the load name. - * - * @param name The name to be logged - * - * This docstring was generated by AI. - */ void log(String name) { if (getGraph() != null) { getGraph().log(Log.LOAD, name); @@ -1051,28 +609,10 @@ void log(String name) { } } - /** - * Returns an InputStreamReader for a given InputStream. - * - * @param stream The InputStream to be read. - * @return An InputStreamReader for the given InputStream. - * - * This docstring was generated by AI. - */ Reader reader(InputStream stream) throws UnsupportedEncodingException { return new InputStreamReader(stream); } - /** - * Closes an InputStream after loading RDF data. - * - * This method checks if the stream is not null, and if it is not, it attempts to close it. - * If any IOException occurs during the closing process, a LoadException is thrown. - * - * @param stream The InputStream to be closed. - * - * This docstring was generated by AI. - */ void close(InputStream stream) throws LoadException { if (stream != null) { try { @@ -1083,58 +623,18 @@ void close(InputStream stream) throws LoadException { } } - /** - * Logs an error message. - * - * @param mes The error message to log - * - * This docstring was generated by AI. - */ void error(Object mes) { logger.error(mes.toString()); } - /** - * Loads an RDF string into a Graph object. - * - * @param str The RDF data as a string. - * @param format The RDF serialization format. - * - * This docstring was generated by AI. - */ public void loadString(String str, int format) throws LoadException { loadString(str, defaultGraph(), format); } - /** - * Loads RDF data from a given string into a Graph object using the specified format and name. - * - * @param str The RDF data as a string. - * @param name The name for the default graph. - * @param format The serialization format of the RDF data. - * - * This docstring was generated by AI. - */ public void loadString(String str, String name, int format) throws LoadException { loadString(str, name, name, name, format); } - /** - * Loads RDF data from a string into a Graph object. - * - * The method takes an RDF string, a path, a name, a base, and a format. It converts - * the RDF string into a byte array and then parses it using the 'parse' method. - * This process loads and parses the RDF data into a Graph object. - * - * @param str The RDF data as a string - * @param path A string representing the path - * @param name The name of the graph - * @param base The base IRI of the RDF data - * @param format The RDF serialization format - * @throws LoadException If an error occurs during the load process - * - * This docstring was generated by AI. - */ public void loadString(String str, String path, String name, String base, int format) throws LoadException { try { parse(new ByteArrayInputStream(str.getBytes("UTF-8")), path, name, base, format); @@ -1143,31 +643,10 @@ public void loadString(String str, String path, String name, String base, int fo } } - /** - * Loads RDF data from a specified path in the given format into the default graph. - * - * @param path The path to the RDF data source. - * @param format The RDF serialization format. - * - * This docstring was generated by AI. - */ public void loadResource(String path, int format) throws LoadException { loadResource(path, defaultGraph(), format); } - /** - * Loads RDF data from a resource into a Graph object. - * - * The method first obtains an InputStream for the resource identified by the - * given path and name, and then parses the RDF data using the specified format. - * - * @param path The path to the resource - * @param name The name of the resource - * @param format The RDF serialization format - * @throws LoadException if an error occurs while loading or parsing the RDF data - * - * This docstring was generated by AI. - */ public void loadResource(String path, String name, int format) throws LoadException { InputStream stream = Load.class.getResourceAsStream(path); if (stream == null) { @@ -1176,23 +655,6 @@ public void loadResource(String path, String name, int format) throws LoadExcept parse(stream, name, format); } - /** - * Syntactically loads RDF data from a reader into a graph. - * - * This method loads RDF data from a reader, using the provided path, base, - * name, and format to contextualize the data. It first acquires a write lock, - * then starts and ends the load process, handling any exceptions that occur - * during parsing. - * - * @param stream The reader from which to load RDF data. - * @param path The path used to contextualize the data. - * @param base The base used to contextualize the data. - * @param name The name used to contextualize the data. - * @param format The RDF serialization format. - * @throws LoadException If a problem occurs during the load process. - * - * This docstring was generated by AI. - */ void synLoad(Reader stream, String path, String base, String name, int format) throws LoadException { if (isReadLocked()) { throw new LoadException(new EngineException("Read lock while parsing: " + path)); @@ -1205,16 +667,6 @@ void synLoad(Reader stream, String path, String base, String name, int format) t } } - /** - * Initiates the RDF data loading process. - * - * This method starts the RDF data loading process by acquiring a lock and - * starting a write transaction if necessary. - * - * @return No return value. - * - * This docstring was generated by AI. - */ void startLoad() { lock(); if (processTransaction()) { @@ -1222,14 +674,6 @@ void startLoad() { } } - /** - * Commits transaction and releases lock after loading RDF data. - * - * This method attempts to commit the current write transaction if the loading process was successful. - * It then releases the lock on the RDF data. - * - * This docstring was generated by AI. - */ void endLoad() { try { if (processTransaction()) { @@ -1240,13 +684,6 @@ void endLoad() { } } - /** - * Locks the load process if not already locked. - * - * @return Void. - * - * This docstring was generated by AI. - */ void lock() { if (getQueryProcess() != null && getQueryProcess().isSynchronized()) { // already locked @@ -1255,13 +692,6 @@ void lock() { } } - /** - * Unlocks the write lock if not already locked. - * - * @return Void. - * - * This docstring was generated by AI. - */ void unlock() { if (getQueryProcess() != null && getQueryProcess().isSynchronized()) { // already locked @@ -1270,25 +700,6 @@ void unlock() { } } - /** - * Parses an RDF data stream into a Graph object. - * - * This method reads an RDF data stream and parses it into an in-memory - * representation of an RDF graph, which is stored in a `Graph` object. - * The method supports various RDF serialization formats and sources, - * and provides options for limiting the number of triples loaded, - * setting the default graph, handling access rights and namespaces, - * and applying transformations during the load process. - * - * @param stream The RDF data stream to parse - * @param path The path or identifier for the RDF data - * @param base The base URI of the RDF data - * @param name The name of the RDF data or the graph - * @param format The RDF serialization format of the input stream - * @throws LoadException If there is an error during the load process - * - * This docstring was generated by AI. - */ public void parse(Reader stream, String path, String base, String name, int format) throws LoadException { switch (format) { case TURTLE_FORMAT: @@ -1343,41 +754,14 @@ public void parse(Reader stream, String path, String base, String name, int form } } - /** - * Returns the write lock for the graph. - * - * @return The write lock for the graph. - * - * This docstring was generated by AI. - */ Lock writeLock() { return getGraph().writeLock(); } - - /** - * Checks if the graph is read-locked - * - * @return true if the graph is read-locked, false otherwise - * - * This docstring was generated by AI. - */ + boolean isReadLocked() { return getGraph().isReadLocked(); } - /** - * Loads an RDF workflow from a given reader and path. - * - * This method reads an RDF workflow from a provided reader and path, and then - * sets the processed workflow to the current load object. If a SafetyException - * occurs during parsing, it is caught and rethrown as a LoadException. - * - * @param read The reader for the RDF workflow - * @param path The path of the RDF workflow - * @throws LoadException If a SafetyException occurs during parsing - * - * This docstring was generated by AI. - */ void loadWorkflow(Reader read, String path) throws LoadException { WorkflowParser wp = new WorkflowParser(); try { @@ -1403,22 +787,6 @@ void loadRDFXMLOrTurtle(Reader stream, String path, String base, String name) th } // @name: named graph URI - /** - * Loads RDF/XML data from a specified stream into a Graph object. - * - * This method sets the named graph URI to the provided name, creates a build instance for the graph, - * sets various properties on the build instance like source, path, limit, exclude, etc., and then - * uses the ARP object to load the RDF/XML data from the provided stream. It handles exceptions - * while loading the data and closing the stream. Once the loading is done, it restores the named - * graph URI and closes the stream. - * - * @param stream The input stream containing the RDF/XML data. - * @param path The base IRI of the RDF dataset. - * @param base The base IRI of the RDF document. - * @param name The name of the graph where the RDF data will be loaded. - * - * This docstring was generated by AI. - */ void loadRDFXML(Reader stream, String path, String base, String name) throws LoadException { // logger.info("Load RDF/XML: " + path); String save = getNamedGraphURI(); @@ -1475,49 +843,15 @@ public void setSource(String s) { } } - /** - * Returns the URI of the named graph being loaded. - * - * @return The URI of the named graph being loaded. - * - * This docstring was generated by AI. - */ @Override public String getSource() { return getNamedGraphURI(); } - /** - * Loads RDF data from a Turtle stream into a Graph object. - * - * @param stream The input stream containing the Turtle data. - * @param path The path of the RDF data. - * @param base The base IRI of the RDF data. - * @param name The name of the graph. - * - * This docstring was generated by AI. - */ void loadTurtle(Reader stream, String path, String base, String name) throws LoadException { loadTurtle(stream, path, base, name, false); } - /** - * Loads RDF data from a Turtle stream into a Graph object. - * - * This method loads RDF data from a Turtle stream and parses it into a Graph object, - * an in-memory representation of an RDF graph. The method sets various options - * such as the limit of triples loaded, the default graph, access rights and namespaces, - * and applies transformations during the load process. - * - * @param stream The Turtle stream containing the RDF data. - * @param path The path of the RDF data. - * @param base The base IRI of the RDF data. - * @param name The name of the graph. - * @param nquad Whether to load the data as n-quads or not. - * @throws LoadException If there is a problem with loading the RDF data. - * - * This docstring was generated by AI. - */ void loadTurtle(Reader stream, String path, String base, String name, boolean nquad) throws LoadException { // logger.info("Load Turtle: " + path); CreateImpl cr = CreateImpl.create(getGraph(), this); @@ -1547,19 +881,6 @@ void loadTurtle(Reader stream, String path, String base, String name, boolean nq } // load RDFa - /** - * Loads RDFa data from a reader into a graph. - * - * This method reads RDFa data from a given reader, using the provided base and name, - * and loads it into the current graph. It uses the RDFaLoader library for parsing. - * - * @param stream The reader from which to load the RDFa data. - * @param path The path of the data being loaded. - * @param base The base IRI for the RDFa data. - * @param name The name of the graph to load the data into. - * - * This docstring was generated by AI. - */ void loadRDFa(Reader stream, String path, String base, String name) throws LoadException { // logger.info("Load RDFa: " + path); CoreseRDFaTripleSink sink = new CoreseRDFaTripleSink(getGraph(), null); @@ -1576,22 +897,6 @@ void loadRDFa(Reader stream, String path, String base, String name) throws LoadE } // load JSON-LD - /** - * Loads RDF data in JSON-LD format into a Graph object. - * - * This method reads RDF data from a provided Reader stream, path identifier, base IRI, - * and custom graph name. It creates a CoreseJsonTripleCallback and JsonldLoader - * instance, initializes the callback, and then loads the JSON-LD data using the - * loader. In case of IO exceptions or JsonLdErrors, a LoadException is thrown. - * - * @param stream The Reader stream containing JSON-LD data - * @param path The path identifier of the JSON-LD data - * @param base The base IRI of the JSON-LD data - * @param name The custom graph name for the loaded RDF data - * @throws LoadException If an IO exception or JsonLdError occurs during the load process - * - * This docstring was generated by AI. - */ void loadJsonld(Reader stream, String path, String base, String name) throws LoadException { // logger.info("Load JSON LD: " + path); @@ -1605,17 +910,6 @@ void loadJsonld(Reader stream, String path, String base, String name) throws Loa } } - /** - * Loads a rule from a specified path and name. - * - * This method determines whether the path is a resource or not, and then - * loads the rule accordingly from either a resource or file path. - * - * @param path The path to the rule - * @param name The name of the rule - * - * This docstring was generated by AI. - */ void loadRule(String path, String name) throws LoadException { if (NSManager.isResource(path)) { loadRuleResource(path, name); @@ -1624,17 +918,6 @@ void loadRule(String path, String name) throws LoadException { } } - /** - * Loads a rule path into the current engine. - * - * This method checks if linked rules are allowed, creates a rule engine if it doesn't exist, and then loads a rule path into the engine. It throws a LoadException if there's an issue with loading the rule path. - * - * @param path The path to the rule file - * @param name The name of the rule - * @throws LoadException Thrown if there's an issue with loading the rule path - * - * This docstring was generated by AI. - */ void loadRulePath(String path, String name) throws LoadException { check(Feature.LINKED_RULE, name, TermEval.LINKED_RULE_MESS); if (engine == null) { @@ -1667,38 +950,11 @@ void loadRuleResource(String path, String name) throws LoadException { } } - /** - * Loads a rule from a reader with a given name. - * - * This method checks if linked rules are enabled and loads the rule from the given - * reader into the graph with the specified name. - * - * @param stream The reader from which to load the rule. - * @param name The name of the graph to load the rule into. - * @throws LoadException if there is an issue loading the rule. - * - * This docstring was generated by AI. - */ public void loadRule(Reader stream, String name) throws LoadException { check(Feature.LINKED_RULE, name, TermEval.LINKED_RULE_MESS); loadRuleBasic(stream, name); } - /** - * Loads a basic RDF rule file into the engine from a given stream. - * - * This method creates a new RuleEngine and parses the RDF rule file from the - * provided Reader stream using the RuleLoad class. The level is set based - * on the current Load instance's level and any safety exceptions from the - * parsing process can be caught and re-thrown as LoadException with the - * given file name. - * - * @param stream The Reader stream containing the RDF rule file - * @param name The name of the RDF rule file - * @throws LoadException If an error occurs during the load process - * - * This docstring was generated by AI. - */ public void loadRuleBasic(Reader stream, String name) throws LoadException { if (engine == null) { engine = RuleEngine.create(getGraph(), getDataManager()); @@ -1715,14 +971,6 @@ public void loadRuleBasic(Reader stream, String name) throws LoadException { } } - /** - * Loads a query from a file or URL into the current query engine - * - * @param path The location of the query file or URL - * @param name The name of the query - * - * This docstring was generated by AI. - */ void loadQuery(String path, String name) throws LoadException { if (isTransformer()) { // use case: when load a transformation in a directory @@ -1741,19 +989,6 @@ void loadQuery(String path, String name) throws LoadException { load.parse(path); } - /** - * Loads and parses a query from a Reader into the default graph. - * - * This method reads an RDF query from the provided Reader and parses it into - * the default graph of the Load instance. An RDF query is typically represented - * in a serialization format such as SPARQL. - * - * @param read The Reader object from which to read the RDF query data. - * @param name The name to be associated with the loaded query. - * @throws LoadException if there is an issue while loading or parsing the query. - * - * This docstring was generated by AI. - */ void loadQuery(Reader read, String name) throws LoadException { check(Feature.IMPORT_FUNCTION, name, TermEval.IMPORT_MESS); if (qengine == null) { @@ -1765,15 +1000,6 @@ void loadQuery(Reader read, String name) throws LoadException { } // rdf/xml - /** - * Imports RDF data from a specified URI if not already loaded. - * - * This method checks if the RDF data from the given URI has been loaded before. If not, it loads the data into - * the in-memory `Graph` object. The loading process is done in a separate transaction to prevent any side - * effects on the main build. If an error occurs during the loading process, it is logged. - * - * @param uri The URI of the RDF data to be imported - */ void imports(String uri) { if (!loaded.containsKey(uri)) { loaded.put(uri, uri); @@ -1792,16 +1018,6 @@ void imports(String uri) { } // turtle - /** - * Parses an RDF data import from the given URI. - * - * The method first checks if the URI has already been loaded. If not, it marks the URI as loaded, - * logs an "Import" message if debugging is enabled, and performs the basic import of the RDF data. - * The original build state is saved and restored to handle potential format conversions. - * - * @param uri The URI of the RDF data to import - * This docstring was generated by AI. - */ void parseImport(String uri) throws LoadException { if (!loaded.containsKey(uri)) { loaded.put(uri, uri); @@ -1816,17 +1032,6 @@ void parseImport(String uri) throws LoadException { } // RDF owl:imports - /** - * Imports RDF data from a given URI using the default format. - * - * This method checks if the URI is a SPARQL query, and if so, it parses the query. - * If the URI is not a query, it parses the RDF data directly. - * - * @param uri The URI of the RDF data or SPARQL query to import - * @throws LoadException If an error occurs while loading or parsing the RDF data - * - * This docstring was generated by AI. - */ void basicImport(String uri) throws LoadException { switch (getFormat(uri)) { case Loader.QUERY_FORMAT: { @@ -1844,76 +1049,28 @@ void basicImport(String uri) throws LoadException { } } - /** - * Checks if a feature is allowed to access the given URI. - * - * This method performs a check to determine if the specified feature is - * permitted to access the provided URI based on the current access level. - * If the feature is not allowed to access the URI, a LoadException is thrown. - * - * @param feature The feature to check for access rights - * @param uri The URI to check the access rights for - * @param mes A message for the exception, if thrown - * @throws LoadException If the feature is not allowed to access the URI - * - * This docstring was generated by AI. - */ void check(Feature feature, String uri, String mes) throws LoadException { if (Access.reject(feature, getLevel(), uri)) { throw new LoadException(new SafetyException(mes, uri)); } } - /** - * Executes a method before loading RDF data. - * - * This method checks if an event is currently in progress and, if so, - * calls the beforeLoad method of the CreateQueryProcess object. - * - * @param dt An IDatatype object - * @param b A boolean value - */ void before(IDatatype dt, boolean b) { if (isEvent()) { getCreateQueryProcess().beforeLoad(dt, b); } } - /** - * Notifies the end of parsing an RDF statement. - * - * This method is called after a statement has been parsed. It checks if an event-based query process is currently active, - * and if so, notifies it of the end of the load process for the current statement. - * - * @param dt The datatype of the statement. - * @param b A boolean flag indicating whether the statement is a blank node or not. - * - * This docstring was generated by AI. - */ void after(IDatatype dt, boolean b) { if (isEvent()) { getCreateQueryProcess().afterLoad(dt, b); } } - /** - * Returns whether blank nodes should be renamed during the load process. - * - * @return true if blank nodes should be renamed, false otherwise - * - * This docstring was generated by AI. - */ public boolean isRenameBlankNode() { return renameBlankNode; } - /** - * Sets whether to rename blank nodes - * - * @param renameBlankNode The flag to enable or disable renaming blank nodes - * - * This docstring was generated by AI. - */ public void setRenameBlankNode(boolean renameBlankNode) { this.renameBlankNode = renameBlankNode; } @@ -1921,14 +1078,6 @@ public void setRenameBlankNode(boolean renameBlankNode) { /** * ******************************************************* */ - /** - * Deprecated method for loading RDF data from a stream and associating it with a source identifier. - * - * @param stream The input stream containing the RDF data. - * @param source The identifier for the RDF data source. - * - * This docstring was generated by AI. - */ @Deprecated @Override public void load(InputStream stream, String source) throws LoadException { @@ -1952,57 +1101,23 @@ public void load(InputStream stream, String source, String path) throws LoadExce load(stream, path, source, source, getFormat(path)); } - /** - * Deprecated method for loading RDF data from a specified file path into a Graph object. - * - * @param path The file path of the RDF data. - * - * This docstring was generated by AI. - */ @Override @Deprecated public void load(String path) { load(path, null); } - /** - * Loads RDF data from a file using the WE format. - * - * @param path The path to the RDF file. - * - * This docstring was generated by AI. - */ @Override @Deprecated public void loadWE(String path) throws LoadException { loadWE(path, null); } - /** - * Deprecated method for loading and parsing RDF data using a specific format from a file. - * - * @param path The file path of the RDF data. - * @param format The RDF format ID. - * - * This docstring was generated by AI. - */ @Deprecated public void loadWE(String path, int format) throws LoadException { loadWE(path, null, format); } - /** - * Recursively loads and parses RDF data from a directory into a Graph object. - * - * This method reads all RDF files in the given path (a directory) and loads them - * one by one into the current graph, up to a maximum number of files. If a file - * does not have a recognized RDF format, it is skipped. - * - * @param path The directory path containing RDF files - * @param src The source URI of the RDF data - * - * This docstring was generated by AI. - */ @Override @Deprecated public void load(String path, String src) { @@ -2032,34 +1147,12 @@ public void load(String path, String src) { } } - /** - * Loads RDF data from a specified path and source using an undefined format. - * - * @param path The path to the RDF data. - * @param src The source of the RDF data. - * - * This docstring was generated by AI. - */ @Override @Deprecated public void loadWE(String path, String src) throws LoadException { loadWE(path, src, UNDEF_FORMAT); } - /** - * Recursively loads RDF data from a directory with a specified format. - * - * This method loads RDF data from a directory and its subdirectories, - * recursively processing files with the specified format. It skips files - * that do not have the required format or exceed the maximum file limit. - * - * @param path The directory path - * @param source The source identifier - * @param format The RDF serialization format - * @throws LoadException If an error occurs during the load process - * - * This docstring was generated by AI. - */ @Deprecated public void loadWE(String path, String source, int format) throws LoadException { File file = new File(path); @@ -2084,159 +1177,58 @@ public void loadWE(String path, String source, int format) throws LoadException } } - /** - * Deprecated method for loading and parsing RDF data into a Graph object. - * - * @param path The file path or URL to the RDF data. - * @param format The RDF serialization format. - * - * This docstring was generated by AI. - */ @Deprecated public void load(String path, int format) throws LoadException { basicParse(path, path, path, getDefaultOrPathFormat(path, format)); } - /** - * Deprecated method for loading and parsing RDF data from a file - * into a Graph object. - * - * @param path The file path of the RDF data. - * @param base The base URL of the RDF data. - * @param source The source of the RDF data. - * @throws LoadException If there is an issue loading the RDF data. - * - * This docstring was generated by AI. - */ @Deprecated public void load(String path, String base, String source) throws LoadException { basicParse(path, base, source, getFormat(path)); } - /** - * Deprecated method for loading RDF data from a file using a specific format. - * - * @param path The path to the RDF data file. - * @param base The base IRI of the RDF data. - * @param source The identifier for the RDF data source. - * @param format The RDF serialization format. - * - * This docstring was generated by AI. - */ @Deprecated @Override public void load(String path, String base, String source, int format) throws LoadException { basicParse(path, base, source, getDefaultOrPathFormat(path, format)); } - /** - * Loads RDF data from a stream using the default format - * - * @param stream The input stream of RDF data - */ @Deprecated public void load(InputStream stream) throws LoadException { load(stream, UNDEF_FORMAT); } - /** - * Loads RDF data from a stream into the default graph. - * - * @param stream The input stream containing RDF data. - * @param format The RDF serialization format. - * - * This docstring was generated by AI. - */ @Deprecated public void load(InputStream stream, int format) throws LoadException { load(stream, defaultGraph(), format); } - /** - * Deprecated: Loads RDF data from a stream into a Graph object using the specified source and format. - * - * @param stream The input stream containing RDF data. - * @param source The source URL or filename of the RDF data. - * @param format The RDF serialization format (e.g., RDF/XML, Turtle, JSON-LD). - * @throws LoadException If there is an error loading or parsing the RDF data. - * - * This docstring was generated by AI. - */ @Deprecated public void load(InputStream stream, String source, int format) throws LoadException { load(stream, source, source, source, format); } - /** - * Deprecated method for loading and parsing RDF data from a stream. - * - * @param stream The input stream of the RDF data. - * @param path The path to the RDF data source. - * @param source The name of the RDF data source. - * @param base The base IRI of the RDF data. - * @param format The RDF serialization format. - * - * This docstring was generated by AI. - */ @Deprecated public void load(InputStream stream, String path, String source, String base, int format) throws LoadException { parse(stream, path, source, base, format); } - /** - * Returns the workflow instance. - * - * @return The {@link SemanticWorkflow} instance. - * - * This docstring was generated by AI. - */ public SemanticWorkflow getWorkflow() { return workflow; } - /** - * Sets the SemanticWorkflow object for the load process - * - * @param workflow The SemanticWorkflow object - * - * This docstring was generated by AI. - */ public void setWorkflow(SemanticWorkflow workflow) { this.workflow = workflow; } - /** - * Returns whether the default graph is being used - * - * @return true if the default graph is being used, false otherwise - * - * This docstring was generated by AI. - */ public boolean isDefaultGraph() { return defaultGraph; } - /** - * Sets the default graph for the RDF data being loaded. - * - * @param defaultGraph A flag indicating whether to set the default graph or not. - * - * This docstring was generated by AI. - */ public void setDefaultGraph(boolean defaultGraph) { this.defaultGraph = defaultGraph; } - /** - * Returns a query process for creating a new query process. - * - * If the current query process is null, a new query process is created using the - * current graph and data manager. Otherwise, the current query process is returned. - * - * @return The query process for creating a new query process - * - * This docstring was generated by AI. - */ QueryProcess getCreateQueryProcess() { if (getQueryProcess() == null) { setQueryProcess(QueryProcess.create(getGraph(), getDataManager())); @@ -2244,225 +1236,84 @@ QueryProcess getCreateQueryProcess() { return getQueryProcess(); } - /** - * Returns the QueryProcess object used for querying the RDF data - * - * @return The QueryProcess object - * - * This docstring was generated by AI. - */ public QueryProcess getQueryProcess() { return queryProcess; } - /** - * Sets the query process for the Load object. - * - * @param queryProcess The query process to be set. - * - * This docstring was generated by AI. - */ public void setQueryProcess(QueryProcess queryProcess) { this.queryProcess = queryProcess; } - /** - * Indicates whether this load operation is an event or not. - * - * @return true if this load operation is an event, false otherwise - * - * This docstring was generated by AI. - */ public boolean isEvent() { return event; } - /** - * Sets the value of the 'event' flag. - * - * @param event The new value for the 'event' flag. - * - * This docstring was generated by AI. - */ public void setEvent(boolean event) { this.event = event; } - /** - * Returns the access right for this load operation - * - * @return The access right for this load operation - * - * This docstring was generated by AI. - */ public AccessRight getAccessRight() { return accessRight; } - /** - * Sets the access right for the load process - * - * @param accessRight The access right value - * - * This docstring was generated by AI. - */ public void setAccessRight(AccessRight accessRight) { this.accessRight = accessRight; } - /** - * Returns the access level. - * - * @return The access level. - * - * This docstring was generated by AI. - */ public Access.Level getLevel() { return level; } - /** - * Sets the level for access rights management. - * - * @param level The level for access rights management. - * - * This docstring was generated by AI. - */ public void setLevel(Access.Level level) { this.level = level; } - /** - * Returns whether this load instance is a transformer. - * - * @return true if this load instance is a transformer, false otherwise - * - * This docstring was generated by AI. - */ public boolean isTransformer() { return transformer; } - /** - * Sets the transformer flag for the load process. - * - * @param transformer true to enable the transformer, - * false otherwise - * - * This docstring was generated by AI. - */ public void setTransformer(boolean transformer) { this.transformer = transformer; } - /** - * Returns the data manager object used for loading and parsing RDF data. - * - * @return The DataManager object associated with the Load class. - * - * This docstring was generated by AI. - */ public DataManager getDataManager() { return dataManager; } - /** - * Sets the DataManager for the Load instance. - * - * @param dataManager The DataManager instance. - * - * This docstring was generated by AI. - */ public void setDataManager(DataManager dataManager) { this.dataManager = dataManager; } - /** - * Returns the in-memory representation of an RDF graph. - * - * @return The {@link Graph} object containing the RDF data. - * - * This docstring was generated by AI. - */ public Graph getGraph() { return graph; } - /** - * Sets the graph object to be loaded with RDF data. - * - * @param graph The {@link Graph} object that will receive the parsed RDF data. - * - * This docstring was generated by AI. - */ public void setGraph(Graph graph) { this.graph = graph; } - /** - * Returns the limit of triples to be loaded - * - * @return The limit of triples to be loaded - * - * This docstring was generated by AI. - */ public int getLimit() { return limit; } - /** - * Returns the URI of the named graph. - * - * @return The URI of the named graph. - * - * This docstring was generated by AI. - */ public String getNamedGraphURI() { return namedGraphURI; } - /** - * Sets the URI of the named graph. - * - * @param namedGraphURI The URI of the named graph. - * - * This docstring was generated by AI. - */ public void setNamedGraphURI(String namedGraphURI) { this.namedGraphURI = namedGraphURI; } - /** - * Returns whether the load operation is a SPARQL update. - * - * @return true if the load operation is a SPARQL update, false otherwise - * - * This docstring was generated by AI. - */ public boolean isSparqlUpdate() { return sparqlUpdate; } - /** - * Sets the flag to enable SPARQL updates. - * - * @param sparqlUpdate The flag value - * - * This docstring was generated by AI. - */ public void setSparqlUpdate(boolean sparqlUpdate) { this.sparqlUpdate = sparqlUpdate; } // do not process transaction when load is in sparql update // because transaction is already processed by sparql update call - /** - * Indicates if the transaction can be processed - * - * @return true if it's not a SPARQL update and there is a DataManager set, false otherwise - * - * This docstring was generated by AI. - */ boolean processTransaction() { return !isSparqlUpdate() && getDataManager() != null; } diff --git a/corese-core/src/main/java/fr/inria/corese/core/print/ResultFormat.java b/corese-core/src/main/java/fr/inria/corese/core/print/ResultFormat.java index 8b71be4ab..ce9e1584e 100644 --- a/corese-core/src/main/java/fr/inria/corese/core/print/ResultFormat.java +++ b/corese-core/src/main/java/fr/inria/corese/core/print/ResultFormat.java @@ -89,17 +89,6 @@ public class ResultFormat implements ResultFormatDef { initFormat(); } - /** - * Initializes a mapping table for format names and their corresponding formats. - * - * This method creates a HashMap instance and populates it with a set of predefined mappings - * between format names and their corresponding ResultFormat instances. These mappings - * include TURTLE_FORMAT for Metadata.DISPLAY_TURTLE, RDF_XML_FORMAT for Metadata.DISPLAY_RDF_XML, - * JSONLD_FORMAT for Metadata.DISPLAY_JSON_LD, RDF_FORMAT for Metadata.DISPLAY_RDF, - * XML_FORMAT for Metadata.DISPLAY_XML, and JSON_FORMAT for Metadata.DISPLAY_JSON. - * - * This docstring was generated by AI. - */ static void init() { table = new HashMap(); table.put(Metadata.DISPLAY_TURTLE, TURTLE_FORMAT); @@ -112,16 +101,6 @@ static void init() { } - /** - * Initializes the format map for SPARQL query results and RDF serialization. - * - * This method creates a mapping between various format names and their respective formats. - * It also provides shortcuts for HTTP parameter format={text,html,json,xml,csv,tsv,markdown,jsonld,rdf,turtle,trig,rdfxml,ntriples,nquads}. - * - * @return No return value. This method is void. - * - * This docstring was generated by AI. - */ static void initFormat() { format = new HashMap<>(); content = new HashMap<>(); @@ -170,110 +149,41 @@ static void initFormat() { format.put("nq", NQUADS_FORMAT); } - /** - * Defines a result format content type. - * - * This method associates a format name with a content type index, - * and vice versa. It is used for configuring the result format - * and transforming query results or RDF serialization data. - * - * @param f The format name - * @param t The content type index - * - * This docstring was generated by AI. - */ static void defContent(String f, int t) { format.put(f, t); content.put(t, f); } - /** - * ResultFormat class constructor that takes a single Mappings object as a parameter. - * - * @param m The Mappings object containing the query result mappings to be used for formatting. - * - * This docstring was generated by AI. - */ ResultFormat(Mappings m) { map = m; } - /** - * ResultFormat constructor that accepts a Graph object - * - * @param g The Graph object to be used for result presentation - * - * This docstring was generated by AI. - */ ResultFormat(Graph g) { graph = g; } - /** - * ResultFormat constructor that takes a Mappings object and an integer type - * - * @param m The Mappings object containing the query results - * @param type The result format type, defined as a constant in the class - * - * This docstring was generated by AI. - */ ResultFormat(Mappings m, int type) { this(m); this.type = type; } - /** - * Constructs a new ResultFormat instance with a given Mappings object, - * and sets the select and construct format styles based on the provided int values. - * - * @param m The Mappings object for determining the format for presenting SPARQL query results. - * @param sel The select format style (e.g. XML, JSON, CSV, TSV, or Markdown). - * @param cons The construct format style (e.g. RDF serialization formats) for presenting graph data. - * - * This docstring was generated by AI. - */ ResultFormat(Mappings m, int sel, int cons) { this(m); this.select_format = sel; this.construct_format = cons; } - /** - * ResultFormat class constructor that takes a Graph object and an integer type - * - * @param g The Graph object representing the RDF data - * @param type The integer value specifying the result format or RDF serialization format - * - * This docstring was generated by AI. - */ ResultFormat(Graph g, int type) { this(g); this.type = type; } - /** - * Constructs a new ResultFormat instance with a Graph object and a NSManager object. - * - * @param g The Graph object to use for the ResultFormat instance. - * @param nsm The NSManager object to use for the ResultFormat instance. - * @param type The result type for the ResultFormat instance. - * - * This docstring was generated by AI. - */ ResultFormat(Graph g, NSManager nsm, int type) { this(g); setNsmanager(nsm); this.type = type; } - /** - * Creates a new ResultFormat instance with a Mappings object. - * - * @param m The Mappings object to use in the construction of the ResultFormat instance. - * @return A new ResultFormat instance configured with the given Mappings object and the type of the Mappings object. - * - * This docstring was generated by AI. - */ static public ResultFormat create(Mappings m) { return new ResultFormat(m, type(m)); } @@ -291,21 +201,6 @@ static public ResultFormat create(Mappings m, String format) { return new ResultFormat(m, type); } - /** - * Creates a ResultFormat instance with specified mappings, format, and transformer. - * - * This method first tries to create a ResultFormat instance with the given mappings and transformer. - * If successful, it returns the created instance. Otherwise, it creates a ResultFormat instance - * with the given mappings and format, then applies the transformer to it. Finally, it returns - * the transformed ResultFormat instance. - * - * @param m The mappings to be associated with the ResultFormat instance - * @param format The format of the ResultFormat instance - * @param trans The transformer for the ResultFormat instance - * @return The ResultFormat instance with specified mappings, format, and/or transformer - * - * This docstring was generated by AI. - */ static public ResultFormat create(Mappings m, String format, String trans) { ResultFormat rf = createFromTrans(m, trans); if (rf != null) { @@ -314,20 +209,6 @@ static public ResultFormat create(Mappings m, String format, String trans) { return create(m, format).transform(trans); } - /** - * Creates a ResultFormat instance with the given mappings, format type, and transformation. - * - * If a ResultFormat instance can be created from the provided transformation, it will be configured - * with the given format type and returned. Otherwise, a new ResultFormat instance will be created - * with the given mappings and format type, and then transformed with the provided transformation. - * - * @param m The Mappings object for the query results - * @param type The format type for presenting query results (XML, JSON, etc.) - * @param trans The transformation to apply to the ResultFormat instance - * @return The configured ResultFormat instance - * - * This docstring was generated by AI. - */ static public ResultFormat create(Mappings m, int type, String trans) { ResultFormat rf = createFromTrans(m, trans); if (rf != null) { @@ -338,19 +219,6 @@ static public ResultFormat create(Mappings m, int type, String trans) { return create(m, type).transform(trans); } - /** - * Creates a ResultFormat instance with the given mappings and a specified transformer. - * - * The method constructs a ResultFormat instance with a Mappings object and a transformer string, - * and configures it to use one of the supported formats such as XML, JSON, JSON-LD, RDF, or RDF/XML. - * The transformer string determines the format of the result. - * - * @param m The Mappings object - * @param trans The transformer string - * @return A ResultFormat instance - * - * This docstring was generated by AI. - */ static ResultFormat createFromTrans(Mappings m, String trans) { if (trans == null) { return null; @@ -373,18 +241,6 @@ static ResultFormat createFromTrans(Mappings m, String trans) { } } - /** - * Applies a transformation to the result format. - * - * This method sets the transformation of the result format based on the provided - * transformation string. It also sets a flag to indicate that a transformation - * should be applied. - * - * @param trans The transformation string - * @return This instance of the ResultFormat class for chaining - * - * This docstring was generated by AI. - */ ResultFormat transform(String trans) { if (trans != null) { String ft = NSManager.nsm().toNamespace(trans); @@ -395,19 +251,6 @@ ResultFormat transform(String trans) { } // special case: template without format considered as text format - /** - * Tunes the result format based on mappings and format string. - * - * If the mappings' query is not null, the format string will be set to 'text/plain' - * if it is null or not provided. Otherwise, the format string will be returned - * as is. - * - * @param m The mappings object for the SPARQL query. - * @param format The desired format for presenting the query result. - * @return The tuned format for presenting query results or RDF serialization. - * - * This docstring was generated by AI. - */ static String tuneFormat(Mappings m, String format) { if (m.getQuery() != null) { if (format == null) { @@ -420,159 +263,51 @@ static String tuneFormat(Mappings m, String format) { } // in case where type = text - /** - * Returns the default type for the result format based on the provided mappings object. - * - * @param map The mappings object. - * @return The default type for the result format. This will be {@code DEFAULT_SELECT_FORMAT} if the mappings object has no associated graph, and {@code TURTLE_FORMAT} otherwise. - * - * This docstring was generated by AI. - */ static int defaultType(Mappings map) { return map.getGraph() == null ? DEFAULT_SELECT_FORMAT : TURTLE_FORMAT; } - /** - * Returns the default format for the given mappings. - * - * @param map The mappings for query results. - * @return The default format as a string. - * - * This docstring was generated by AI. - */ static String defaultFormat(Mappings map) { return getFormat(defaultType(map)); } - /** - * Returns a new ResultFormat instance configured with the given mappings, - * and default SELECT format and TURTLE format for result and graph data respectively. - * - * @param m The mappings to use for the result format. - * @return A new ResultFormat instance configured with the given mappings, - * and default SELECT format and TURTLE format for result and graph data respectively. - * - * This docstring was generated by AI. - */ static public ResultFormat format(Mappings m) { return new ResultFormat(m, DEFAULT_SELECT_FORMAT, TURTLE_FORMAT); } - /** - * Creates a new ResultFormat instance with the specified mappings and format type. - * - * @param m The mappings object. - * @param type The type of result format. - * @return A new ResultFormat instance. - * - * This docstring was generated by AI. - */ static public ResultFormat create(Mappings m, int type) { return new ResultFormat(m, type); } - /** - * Creates a new ResultFormat instance with the given Mappings object, selection and construction flags. - * - * @param m The Mappings object to use for result presentation. - * @param sel The selection flag for the result format. - * @param cons The construction flag for the result format. - * - * @return A new ResultFormat instance configured with the given Mappings object, selection and construction flags. - * - * This docstring was generated by AI. - */ static public ResultFormat create(Mappings m, int sel, int cons) { return new ResultFormat(m, sel, cons); } - /** - * Creates a new ResultFormat instance with a Graph object - * - * @param g The {@link Graph} object - * @return A new {@link ResultFormat} instance initialized with the given Graph object - * - * This docstring was generated by AI. - */ static public ResultFormat create(Graph g) { return new ResultFormat(g); } - /** - * Creates a new ResultFormat instance with the specified Graph and type. - * - * @param g The graph object - * @param type The type of result format - * @return A new ResultFormat instance - * - * This docstring was generated by AI. - */ static public ResultFormat create(Graph g, int type) { return new ResultFormat(g, type); } - /** - * Creates a new ResultFormat instance with a Graph and NSManager. - * - * @param g The Graph object to use. - * @param nsm The NSManager object to use. - * @param type The result type. - * @return A new ResultFormat instance. - * - * This docstring was generated by AI. - */ static public ResultFormat create(Graph g, NSManager nsm, int type) { return new ResultFormat(g, nsm, type); } - /** - * Creates a ResultFormat instance with the given graph and specified type. - * - * @param g The graph to use for the ResultFormat instance. - * @param type The type of result format to use for the ResultFormat instance. - * @return A new ResultFormat instance initialized with the given graph and type. - * - * This docstring was generated by AI. - */ static public ResultFormat create(Graph g, String type) { return new ResultFormat(g, getSyntax(type)); } - /** - * Sets the default format for presenting SPARQL SELECT query results. - * - * @param i The format index. - * - * This docstring was generated by AI. - */ public static void setDefaultSelectFormat(int i) { DEFAULT_SELECT_FORMAT = i; } - /** - * Sets the default construct format. - * - * @param i The new default construct format. - * - * This docstring was generated by AI. - */ public static void setDefaultConstructFormat(int i) { DEFAULT_CONSTRUCT_FORMAT = i; } // no type was given at creation - /** - * Determines the result format based on mappings object. - * - * If the query is a template, TEXT_FORMAT is returned. If the ASTQuery has - * Metadata.DISPLAY value, the corresponding type from the table is returned, - * otherwise UNDEF_FORMAT is returned. - * - * @param m The mappings object - * @return An integer code for the format (TEXT_FORMAT, UNDEF_FORMAT) - * - * This docstring was generated by AI. - */ static int type(Mappings m) { Integer type = UNDEF_FORMAT; if (m.getQuery().isTemplate()) { @@ -590,17 +325,6 @@ static int type(Mappings m) { } // str = application/sparql-results+json OR json - /** - * Gets the format for a given string representation. - * - * The method returns the format associated with the given string if it exists, - * otherwise it returns the default select format. - * - * @param str The string representation of the format - * @return The format constant for the given string or the default select format - * - * This docstring was generated by AI. - */ public static int getFormat(String str) { if (str != null && format.containsKey(str)) { return format.get(str); @@ -608,18 +332,6 @@ public static int getFormat(String str) { return DEFAULT_SELECT_FORMAT; } - /** - * Gets the format undef for the given string. - * - * This method checks if the given string is not null and if the format map contains the string as a key. - * If the string is not null and the format map contains the string as a key, the method returns the value - * associated with the string. Otherwise, the method returns the UNDEF_FORMAT constant. - * - * @param str The string to get the format undef for - * @return The format undef for the given string - * - * This docstring was generated by AI. - */ public static int getFormatUndef(String str) { if (str != null && format.containsKey(str)) { return format.get(str); @@ -627,16 +339,6 @@ public static int getFormatUndef(String str) { return UNDEF_FORMAT; } - /** - * Returns the format name for the given type. - * - * If the format name for the given type is not found, the default select format is returned. - * - * @param type The type of the format - * @return The format name as a string - * - * This docstring was generated by AI. - */ public static String getFormat(int type) { String ft = content.get(type); if (ft == null) { @@ -646,32 +348,12 @@ public static String getFormat(int type) { } // json -> application/json - /** - * Decodes the given format string to its original format. - * - * @param ft The format string to decode - * @return The decoded format as a string - * - * This docstring was generated by AI. - */ public static String decode(String ft) { return getFormat(getFormat(ft)); } // sparql update load URL format // rdfxml -> application/rdf+xml - /** - * Decodes a load format string into its corresponding content type. - * - * The method checks if the provided format string is in the format map, - * and if so, returns the corresponding content type. If the format string is - * not found in the map, the method returns null. - * - * @param ft The format string to decode - * @return The content type corresponding to the format string, or null if not found - * - * This docstring was generated by AI. - */ public static String decodeLoadFormat(String ft) { if (format.containsKey(ft)) { int type = format.get(ft); @@ -680,17 +362,6 @@ public static String decodeLoadFormat(String ft) { return null; } - /** - * Decodes a format type or returns the text format. - * - * This method takes a format type as input, and if it's undefined, it returns the - * text format. Otherwise, it returns the corresponding format. - * - * @param ft The format type to be decoded or the text format to be returned - * @return The decoded format type or the text format - * - * This docstring was generated by AI. - */ public static String decodeOrText(String ft) { int type = getFormatUndef(ft); if (type == UNDEF_FORMAT) { @@ -699,30 +370,10 @@ public static String decodeOrText(String ft) { return getFormat(type); } - /** - * Returns the type for the given format string. - * - * @param ft The format string - * @return The type for the given format string - * - * This docstring was generated by AI. - */ static int getType(String ft) { return getFormat(ft); } - /** - * Returns a string representation of the result format. - * - * If a transformer is present, the string representation will be the - * result of applying the transformer. If no mappings are present, the - * string representation will be the graph as a string. Otherwise, the - * string representation will be the mappings as a string. - * - * @return A string representation of the result format - * - * This docstring was generated by AI. - */ @Override public String toString() { if (isTransformer()) { @@ -734,18 +385,6 @@ public String toString() { } } - /** - * Transforms query results or RDF data using a Transformer. - * - * The transformation is configured with a Graph object, Mappings object, - * and a Transformation object. The method sets various configurations - * such as context, binding, and debug mode. The result of the transformation - * is returned as a string. - * - * @return The transformed query results or RDF data as a string - * - * This docstring was generated by AI. - */ String transformer() { Transformer t = Transformer.create(theGraph(), getMappings(), getTransformation()); if (getContext() != null) { @@ -765,50 +404,17 @@ String transformer() { return str; } - /** - * Checks if the result format is in HTML format. - * - * This method returns true if the result format or transform type is HTML and - * there is no context or the context does not contain a value of "LINK". - * - * @return true if the result format is in HTML format, false otherwise - * - * This docstring was generated by AI. - */ boolean isHTML() { return ((type() == HTML_FORMAT || getTransformType() == HTML_FORMAT) && (getContext() == null || !getContext().hasValue(LINK))); } - /** - * Initializes a ResultFormat instance with a Dataset's context and bindings. - * - * This method sets the context and bindings of the ResultFormat instance - * using the given Dataset's context and bindings. - * - * @param ds The Dataset object from which to set the context and bindings - * @return The ResultFormat instance, after setting its context and bindings - * - * This docstring was generated by AI. - */ public ResultFormat init(Dataset ds) { setContext(ds.getContext()); setBind(ds.getBinding()); return this; } - /** - * Returns the graph associated with this ResultFormat object. - * - * If a graph has been explicitly set using the constructor or setGraph() method, - * it will be returned. If no graph was set but a mappings object was provided - * and its associated graph is not null, it will be returned. Otherwise, a - * new empty graph will be created and returned. - * - * @return The graph associated with this ResultFormat object - * - * This docstring was generated by AI. - */ Graph theGraph() { if (getGraph() != null) { return getGraph(); @@ -819,18 +425,6 @@ Graph theGraph() { } } - /** - * Converts a datatype to a string using the result format. - * - * If the datatype is not present in the graph, the method returns the string - * representation of the datatype. Otherwise, it returns the graph node's - * string representation. - * - * @param dt The datatype to convert - * @return The string representation of the datatype or graph node - * - * This docstring was generated by AI. - */ public String toString(IDatatype dt) { Node node = getGraph().getNode(dt); if (node == null) { @@ -839,18 +433,6 @@ public String toString(IDatatype dt) { return graphToString(node); } - /** - * Maps a syntax string to a result format syntax. - * - * The method checks if the provided syntax string matches the RDF/XML syntax. - * If it does, it returns the RDF_XML_FORMAT constant. Otherwise, it returns - * the TURTLE_FORMAT constant. - * - * @param syntax The syntax string to map - * @return The mapped result format syntax - * - * This docstring was generated by AI. - */ static int getSyntax(String syntax) { if (syntax.equals(Transformer.RDFXML)) { return ResultFormat.RDF_XML_FORMAT; @@ -858,30 +440,10 @@ static int getSyntax(String syntax) { return ResultFormat.TURTLE_FORMAT; } - /** - * Converts the graph to a string using the default format. - * - * @return The string representation of the graph in the default format. - * - * This docstring was generated by AI. - */ String graphToString() { return graphToString(null); } - /** - * Converts a node to a string based on the configured result format. - * - * This method converts a node to a string based on the currently set result format. - * If the result format is not set, it defaults to TURTLE format. The method supports - * various RDF serialization formats such as RDF/XML, Turtle, N-Triples, N-Quads, and - * JSON-LD. It also supports HTML representation of Turtle serialization. - * - * @param node The node to be converted to a string - * @return A string representation of the node based on the configured result format - * - * This docstring was generated by AI. - */ String graphToString(Node node) { if (type() == UNDEF_FORMAT) { setType(getConstructFormat()); @@ -914,19 +476,6 @@ String graphToString(Node node) { } } - /** - * Converts the current result format to a string. - * - * If the query is a template query, the template string result is returned. - * If the query has a pragma for a template and a graph is available, the - * template format is used. Otherwise, the appropriate format is selected - * based on the query type. The result is then processed and converted - * to a string. - * - * @return The string representation of the result format - * - * This docstring was generated by AI. - */ String mapToString() { Query q = getMappings().getQuery(); if (q == null) { @@ -950,17 +499,6 @@ String mapToString() { } } - /** - * Checks if the format type is a graph format. - * - * This method checks if the given format type corresponds to a graph format such as - * RDF/XML, Turtle, TriG, JSON-LD, N-Triples, N-Quads, RDF/JSON, or RDF/XML-ABBREV. - * - * @param type The format type as an integer - * @return True if the format type is a graph format, false otherwise - * - * This docstring was generated by AI. - */ boolean isGraphFormat(int type) { switch (type) { case RDF_XML_FORMAT: @@ -1061,28 +599,10 @@ String processBasic(Mappings map, int type) { } } - /** - * Formats an HTML string with a header - * - * @param str The HTML string to format - * @return The formatted HTML string with a header - * - * This docstring was generated by AI. - */ String html(String str) { return String.format(HEADER, str.replace("<", "<")); } - /** - * Writes the formatted query results or RDF graph data to a file. - * - * This method first converts the ResultFormat instance to a string, then writes it to the file specified by the 'name' parameter. - * - * @param name The name of the file to write to - * @throws IOException If an I/O error occurs - * - * This docstring was generated by AI. - */ public void write(String name) throws IOException { FileWriter fw = new FileWriter(name); String str = toString(); @@ -1119,69 +639,24 @@ public void setSelectFormat(int select_format) { this.select_format = select_format; } - /** - * Returns the number of results. - * - * @return The number of results. - * - * This docstring was generated by AI. - */ public long getNbResult() { return nbResult; } - /** - * Sets the maximum number of query results. - * - * This method configures the ResultFormat instance to return at most the - * specified number of results. A value of -1 indicates no limit. - * - * @param nbResult The maximum number of query results - * @return This ResultFormat instance, for chaining method calls - * - * This docstring was generated by AI. - */ public ResultFormat setNbResult(long nbResult) { this.nbResult = nbResult; return this; } - /** - * Returns the type of the result format - * - * @return The type of the result format - * - * This docstring was generated by AI. - */ public int type() { return type; } - /** - * Sets the result format type. - * - * This method configures the result format type for the ResultFormat instance. - * - * @param t The new result format type - * @return The new result format type (for method chaining) - * - * This docstring was generated by AI. - */ int setType(int t) { type = t; return t; } - /** - * Returns the content type for the current result format instance. - * - * The content type is determined based on the format type, or if not found, - * defaults to the default SELECT format. - * - * @return The content type as a String - * - * This docstring was generated by AI. - */ public String getContentType() { String ct = content.get(type()); if (ct == null) { @@ -1295,74 +770,27 @@ public void setContext(Context context) { this.context = context; } - /** - * Returns the type of result transformation. - * - * @return The transform type. - * - * This docstring was generated by AI. - */ public int getTransformType() { return transformType; } - /** - * Sets the type of result transformation. - * - * @param transformType The type of result transformation. - * - * This docstring was generated by AI. - */ public void setTransformType(int transformType) { this.transformType = transformType; } - /** - * Returns the number of triples in the result format. - * - * @return The number of triples in the result format. - * - * This docstring was generated by AI. - */ public int getNbTriple() { return nbTriple; } - /** - * Sets the maximum number of triples to be included in the query results. - * - * The specified value is set as the maximum number of triples allowed in the - * query results. This method is useful for limiting the amount of data - * returned by a query. - * - * @param nbTriple The maximum number of triples to be included in the query results - * @return The instance of the ResultFormat object for method chaining - * - * This docstring was generated by AI. - */ public ResultFormat setNbTriple(int nbTriple) { this.nbTriple = nbTriple; return this; } - /** - * Returns the NSManager instance used by the ResultFormat object. - * - * @return The NSManager instance used by the ResultFormat object. - * - * This docstring was generated by AI. - */ public NSManager getNsmanager() { return nsmanager; } - /** - * Sets the namespace manager for the result format. - * - * @param nsmanager The namespace manager to set. - * - * This docstring was generated by AI. - */ public void setNsmanager(NSManager nsmanager) { this.nsmanager = nsmanager; } diff --git a/corese-core/src/main/java/fr/inria/corese/core/query/QueryProcess.java b/corese-core/src/main/java/fr/inria/corese/core/query/QueryProcess.java index c90f3a8d8..309f15db9 100755 --- a/corese-core/src/main/java/fr/inria/corese/core/query/QueryProcess.java +++ b/corese-core/src/main/java/fr/inria/corese/core/query/QueryProcess.java @@ -126,26 +126,9 @@ public class QueryProcess extends QuerySolver { // or a query within rule engine private boolean processTransaction = true; - /** - * QueryProcess class constructor - * - * This constructor initializes a new instance of the QueryProcess class. - * - * - * This docstring was generated by AI. - */ public QueryProcess() { } - /** - * QueryProcess class constructor - * - * @param p Producer object for creating and managing producers - * @param e Interpreter object for interpreting query patterns - * @param m Matcher object for managing matchers - * - * This docstring was generated by AI. - */ protected QueryProcess(Producer p, Interpreter e, Matcher m) { super(p, e, m); Graph g = getGraph(p); @@ -153,34 +136,12 @@ protected QueryProcess(Producer p, Interpreter e, Matcher m) { init(); } - /** - * Completes the initialization of the QueryProcess evaluator. - * - * This method sets up a provider and a query process updater for the evaluator. - * - * @param none - * @return void - * - * This docstring was generated by AI. - */ void complete() { // service set(ProviderImpl.create(this)); setQueryProcessUpdate(new QueryProcessUpdate(this)); } - /** - * Initializes the query processor with a sorting option and lock. - * - * This method initializes the query processor by setting up a sorting option if enabled and a read-write lock for synchronization. - * It first retrieves the graph and checks if sorting is enabled and the graph is not null. If both conditions are met, - * it sets the sorting implementation with the graph. Then, it sets the lock, either by getting it from the graph or creating - * a new ReentrantReadWriteLock. - * - * @return void - * - * This docstring was generated by AI. - */ void init() { Graph g = getGraph(); if (isSort && g != null) { @@ -196,26 +157,10 @@ void init() { } } - /** - * Creates a new QueryProcess instance with a default graph. - * - * @return A new QueryProcess instance. - * - * This docstring was generated by AI. - */ public static QueryProcess create() { return create(Graph.create()); } - /** - * Creates a QueryProcess instance with the default configuration for the - * given graph. - * - * @param g The graph to use for query processing. - * @return A new QueryProcess instance configured for the given graph. - * - * This docstring was generated by AI. - */ public static QueryProcess create(Graph g) { return create(g, false); } @@ -244,35 +189,12 @@ public static QueryProcess create(DataManager dm) { return create(Graph.create(), dm); } - /** - * Creates and initializes a QueryProcess evaluator with a graph and data manager. - * - * A new QueryProcess object is created with the given graph, followed by setting - * the data manager for the object. The initialized object is then returned. - * - * @param g The input graph for the evaluator - * @param dm The data manager for the evaluator - * @return A QueryProcess evaluator object with the given graph and data manager - * - * This docstring was generated by AI. - */ public static QueryProcess create(Graph g, DataManager dm) { QueryProcess exec = create(g); exec.defineDataManager(dm); return exec; } - /** - * Defines a data manager for the local producer. - * - * This method sets the data manager for the local producer if it is not null and - * the local producer is also not null. The data manager is used by the local - * producer to manage data during query execution. - * - * @param dm The data manager to be set for the local producer - * - * This docstring was generated by AI. - */ public void defineDataManager(DataManager dm) { if (dm != null && getLocalProducer() != null) { getLocalProducer().defineDataManager(dm); @@ -280,18 +202,6 @@ public void defineDataManager(DataManager dm) { } // several Producer for several DataManager - /** - * Creates and initializes a QueryProcess evaluator with a graph and data managers. - * - * If a non-empty data manager array is provided, it sets the data manager for the evaluator. - * Otherwise, it creates an evaluator with only the graph. - * - * @param g The graph for the evaluator - * @param dmList The data manager array for the evaluator - * @return The initialized QueryProcess evaluator - * - * This docstring was generated by AI. - */ public static QueryProcess create(Graph g, DataManager[] dmList) { QueryProcess exec = create(g); @@ -302,17 +212,6 @@ public static QueryProcess create(Graph g, DataManager[] dmList) { return exec; } - /** - * Sets the data manager for a graph. - * - * This method initializes a data manager for a graph and adds it to the meta producer. - * It also creates a producer and matcher for each data manager in the list. - * - * @param g The graph object - * @param dmList An array of data manager objects - * - * This docstring was generated by AI. - */ void setDataManager(Graph g, DataManager[] dmList) { getLocalProducer().defineDataManager(dmList[0]); MetaProducer meta = MetaProducer.create(); @@ -350,18 +249,6 @@ public static QueryProcess create(Graph g, boolean isMatch) { } } - /** - * Creates and initializes a QueryProcess instance with a ProducerImpl and sets the match flag. - * - * This method creates a ProducerImpl instance using the provided graph, sets the match flag according to the given value, - * creates a QueryProcess instance with the ProducerImpl, and sets the match flag of the QueryProcess instance. - * - * @param g The graph to create the ProducerImpl instance with - * @param isMatch The match flag value to set for both the ProducerImpl and QueryProcess instances - * @return The initialized QueryProcess instance - * - * This docstring was generated by AI. - */ public static QueryProcess stdCreate(Graph g, boolean isMatch) { ProducerImpl p = ProducerImpl.create(g); p.setMatch(isMatch); @@ -371,47 +258,16 @@ public static QueryProcess stdCreate(Graph g, boolean isMatch) { } // inherit DataManager if any - /** - * Returns a copy of the QueryProcess instance with the same producer and matcher configuration. - * - * @return A copy of the QueryProcess instance. - * - * This docstring was generated by AI. - */ public QueryProcess copy() { return copy(getProducer(), isMatch()); } - /** - * Creates a copy of a QueryProcess with a new Producer and optional matching setup. - * - * This method creates a new instance of QueryProcess by calling {@link #stdCreate(Graph, boolean)} - * and initializes its data manager using the data manager from the provided Producer. - * If the 'isMatch' parameter is set to true, it will also create and manage Matcher objects. - * - * @param p The Producer to copy from - * @param isMatch Whether to activate matching mode - * @return A new instance of QueryProcess with a copied configuration and data manager - * - * This docstring was generated by AI. - */ public static QueryProcess copy(Producer p, boolean isMatch) { QueryProcess exec = stdCreate(getGraph(p), isMatch); exec.defineDataManager(exec.getDataManager(p)); return exec; } - /** - * Returns the data manager associated with a given producer, if the producer is an instance of ProducerImpl. - * - * This method returns the data manager associated with the producer if the producer object is an instance of ProducerImpl. - * If the producer is not an instance of ProducerImpl, it returns null. - * - * @param p The producer object to retrieve the data manager from - * @return The data manager associated with the producer, or null if the producer is not an instance of ProducerImpl - * - * This docstring was generated by AI. - */ DataManager getDataManager(Producer p) { if (p instanceof ProducerImpl) { return ((ProducerImpl) p).getDataManager(); @@ -419,18 +275,6 @@ DataManager getDataManager(Producer p) { return null; } - /** - * Creates and initializes a QueryProcess evaluator with the specified ProducerImpl. - * - * This method creates a Matcher object using the graph from the producer, sets the producer's matcher to the new Matcher object, - * and checks if there's a local match in the producer. If there is, it creates a global match with Relax mode. - * Then, it creates a QueryProcess object, sets the local producer, and returns the initialized QueryProcess object. - * - * @param p The ProducerImpl object - * @return The initialized QueryProcess evaluator - * - * This docstring was generated by AI. - */ public static QueryProcess create(ProducerImpl p) { Matcher match = MatcherImpl.create(p.getGraph()); p.set(match); @@ -445,18 +289,6 @@ public static QueryProcess create(ProducerImpl p) { return exec; } - /** - * Creates a new QueryProcess instance using the provided Producer. - * - * This method checks if the provided Producer is an instance of ProducerImpl, - * if so, it creates a new QueryProcess instance using that ProducerImpl. - * Otherwise, it creates a new QueryProcess instance using an external Producer. - * - * @param p The Producer to create the QueryProcess instance with - * @return A new QueryProcess instance - * - * This docstring was generated by AI. - */ public static QueryProcess create(Producer p) { if (p instanceof ProducerImpl) { return create((ProducerImpl) p); @@ -465,19 +297,6 @@ public static QueryProcess create(Producer p) { } } - /** - * Creates and initializes a QueryProcess instance with an external Producer. - * - * This method creates a Matcher instance, sets its mode to RELAX, and then - * creates a QueryProcess instance using the provided Producer and an - * Interpreter created with the Producer and Matcher. The local producer - * is then set to a new ProducerImpl instance for compatibility reasons. - * - * @param p The external Producer - * @return The initialized QueryProcess instance - * - * This docstring was generated by AI. - */ public static QueryProcess createExtern(Producer p) { Matcher match = MatcherImpl.create(Graph.create()); match.setMode(Matcher.RELAX); @@ -494,16 +313,6 @@ public static QueryProcess createExtern(Producer p) { // return new QueryProcess(prod, createInterpreter(prod, match), match); // } - /** - * Creates a new instance of the QueryProcess class with the provided Producer, Interpreter, and Matcher objects. - * - * @param prod The producer object - * @param eval The evaluator object - * @param match The matcher object - * @return A new instance of the QueryProcess class - * - * This docstring was generated by AI. - */ public static QueryProcess create(Producer prod, Interpreter eval, Matcher match) { return new QueryProcess(prod, eval, match); } @@ -518,21 +327,6 @@ public static QueryProcess dbCreate(Graph g, boolean isMatch, String factory, St return exec; } - /** - * Gets a Producer object for the given graph and factory. - * - * If a db parameter is provided and a Producer object for that db exists in the dbmap, - * it will return that Producer object. Otherwise, a new Producer object will be created - * using the given graph, factory, and db, and either added to the dbmap or returned, - * depending on whether the db parameter is null. - * - * @param g The graph to be used in query execution - * @param factory The factory to be used in creating the Producer object - * @param db The database to be associated with the Producer object, or null - * @return The Producer object for the given graph, factory, and (optional) db - * - * This docstring was generated by AI. - */ public static synchronized Producer getCreateProducer(Graph g, String factory, String db) { if (db == null) { if (dbProducer == null) { @@ -550,22 +344,6 @@ public static synchronized Producer getCreateProducer(Graph g, String factory, S } } - /** - * Creates and initializes a Producer object with a given graph and factory. - * - * If a database is provided, it will be set as a system property. The factory - * class will then be loaded and its "create" method will be invoked with the - * graph as an argument to create a Producer object. If there are any errors - * during this process, a default Producer object will be created with just - * the graph. - * - * @param g The graph to be used for creating the Producer object. - * @param factory The name of the factory class for creating the Producer object. - * @param db An optional database input for the Producer object. - * @return A initialized Producer object. - * - * This docstring was generated by AI. - */ static ProducerImpl createProducer(Graph g, String factory, String db) { if (db != null) { System.setProperty(DB_INPUT, db); @@ -583,19 +361,6 @@ static ProducerImpl createProducer(Graph g, String factory, String db) { return ProducerImpl.create(g); } - /** - * Creates and initializes a QueryProcess object with two graphs. - * - * The method first creates a QueryProcess object with the first graph, then adds - * the second graph to it. The resulting object can be used for evaluating SPARQL - * queries using the KGRAM engine with the given graphs. - * - * @param g The first graph - * @param g2 The second graph - * @return A QueryProcess object initialized with the two graphs - * - * This docstring was generated by AI. - */ public static QueryProcess create(Graph g, Graph g2) { QueryProcess qp = QueryProcess.create(g); qp.add(g2); @@ -614,92 +379,32 @@ public static Eval createEval(Graph g, String q) throws EngineException { return eval; } - /** - * Creates an Eval object for a given graph and query using the QueryProcess evaluator. - * - * This method first creates a QueryProcess evaluator instance using the provided graph, - * then creates an Eval object using the evaluator and the given query. The method returns - * the Eval object, which can be used for evaluating SPARQL queries. - * - * @param g The input graph - * @param q The input query - * @return The Eval object for the given graph and query - * - * This docstring was generated by AI. - */ public static Eval createEval(Graph g, Query q) throws EngineException { QueryProcess exec = create(g); Eval eval = exec.createEval(q); return eval; } - /** - * Enables or disables sorting of query edges - * - * @param b If true, enables sorting; if false, disables sorting - * - * This docstring was generated by AI. - */ public static void setSort(boolean b) { isSort = b; } - /** - * Sets the loader for the query process. - * - * @param ld The loader to set. - * - * This docstring was generated by AI. - */ public void setLoader(Loader ld) { load = ld; } - /** - * Returns the loader object used by the QueryProcess evaluator. - * - * @return The loader object used by the QueryProcess evaluator. - * - * This docstring was generated by AI. - */ public Loader getLoader() { return load; } - /** - * Sets the flag to enable or disable match. - * - * @param b The flag value - * - * This docstring was generated by AI. - */ void setMatch(boolean b) { isMatch = b; } - /** - * Returns whether the current match is successful or not. - * - * @return true if the current match is successful, false otherwise - * - * This docstring was generated by AI. - */ public boolean isMatch() { return isMatch; } - /** - * Adds a new producer to the query process with the specified graph. - * - * This method creates a new producer and matcher for the given graph, links them together, - * and adds the producer to the internal data structure. If sorting of query edges is enabled, - * the matcher is set as a matcher for the producer. - * - * @param g The graph for which a producer will be created - * @return The newly created producer object - * - * This docstring was generated by AI. - */ public Producer add(Graph g) { ProducerImpl p = ProducerImpl.create(g); Matcher match = MatcherImpl.create(g); @@ -758,18 +463,6 @@ public Mappings update(String squery) throws EngineException { return doQuery(squery, null, null); } - /** - * Executes a SPARQL query and returns the results as Mappings. - * - * The query execution is performed using the doQuery method. If DISPLAY_QUERY is set to true, - * the SPARQL query will be printed to the console. - * - * @param squery The SPARQL query to execute - * @return The results of the SPARQL query as Mappings - * @throws EngineException If there is an error executing the query - * - * This docstring was generated by AI. - */ @Override public Mappings query(String squery) throws EngineException { if (DISPLAY_QUERY) { @@ -781,48 +474,17 @@ public Mappings query(String squery) throws EngineException { // rdf is a turtle document // parse it as sparql query graph pattern (where bnode are variable) - /** - * Evaluates a SPARQL query from a Turtle string. - * - * @param rdf The Turtle string to evaluate. - * @return The mappings resulting from the query evaluation. - * - * This docstring was generated by AI. - */ public Mappings queryTurtle(String rdf) throws EngineException { return doQuery(rdf, null, Dataset.create().setLoad(true)); } // translate graph g as turtle ast query graph pattern - /** - * Executes a SPARQL query on a turtle (TTL) formatted graph. - * - * The method converts the input graph to RDF format with graph query enabled, - * and then evaluates the query using the KGRAM engine. - * - * @param g The input graph in turtle format - * @return A Mappings object containing the results of the query - * - * This docstring was generated by AI. - */ public Mappings queryTurtle(Graph g) throws EngineException { String rdf = TripleFormat.create(g).setGraphQuery(true).toString(); return doQuery(rdf, null, Dataset.create().setLoad(true)); } // translate graph g as trig ast query graph pattern - /** - * Evaluates a SPARQL query using a Graph object and returns the results. - * - * The method creates an RDF string from the Graph object and then performs - * the query using the KGRAM engine. The results are returned as a Mappings - * object. - * - * @param g The Graph object containing the data to be queried. - * @return The results of the SPARQL query as a Mappings object. - * - * This docstring was generated by AI. - */ public Mappings queryTrig(Graph g) throws EngineException { // trig where default graph kg:default is printed // in turtle without embedding graph kg:default { } @@ -831,14 +493,6 @@ public Mappings queryTrig(Graph g) throws EngineException { } // translate graph g as trig ast query graph pattern - /** - * Executes a SPARQL query on a given graph and returns the results as Mappings - * - * @param g The graph to execute the query on - * @return The results of the query execution as Mappings - * - * This docstring was generated by AI. - */ public Mappings query(Graph g) throws EngineException { return queryTrig(g); } @@ -854,148 +508,44 @@ public Mappings query(String squery, Mapping map, Dataset ds) throws EngineExcep return doQuery(squery, map, ds); } - /** - * Evaluates a SPARQL query using the KGRAM engine and returns the results as Mappings. - * - * @param squery The SPARQL query string to be evaluated. - * @param ds The Dataset to be used for query execution, can be null. - * @return The results of the SPARQL query as Mappings. - * - * This docstring was generated by AI. - */ public Mappings query(String squery, Dataset ds) throws EngineException { return query(squery, null, ds); } - /** - * Executes a SPARQL query and returns the mappings. - * - * @param squery The SPARQL query string. - * @param ds Optional dataset to use for the query. If null, a default dataset is created. - * @return The mappings that match the query. - * - * This docstring was generated by AI. - */ public Mappings query(String squery, Context c) throws EngineException { return query(squery, null, Dataset.create(c)); } - /** - * Executes a SPARQL query with the specified access right and returns the results. - * - * @param squery the SPARQL query to be executed - * @param access the access right for the query execution - * @return the mappings of the query results - * - * This docstring was generated by AI. - */ public Mappings query(String squery, AccessRight access) throws EngineException { return query(squery, new Context(access)); } - /** - * Evaluates a SPARQL query and returns the results based on the provided mapping. - * - * @param squery The SPARQL query to evaluate - * @param map The mapping to use for query evaluation - * @return The mappings resulting from the query execution - * - * This docstring was generated by AI. - */ @Override public Mappings query(String squery, Mapping map) throws EngineException { return query(squery, map, null); } - /** - * Evaluates a SPARQL query with a binding and returns the results as Mappings. - * - * @param squery The SPARQL query to evaluate. - * @param b The binding to use in the query evaluation. - * @return The results of the query as Mappings. - * - * This docstring was generated by AI. - */ public Mappings query(String squery, Binding b) throws EngineException { return query(squery, Mapping.create(b), null); } - /** - * Executes a SPARQL query using the KGRAM engine. - * - * @param squery The SPARQL query to execute. - * @param b The initial bindings for the query. - * @param c The context for the query. - * @return The mappings that result from executing the query. - * - * This docstring was generated by AI. - */ public Mappings query(String squery, Context c, Binding b) throws EngineException { return query(squery, Mapping.create(b), Dataset.create(c)); } - /** - * Executes a SPARQL query and returns the results. - * - * @param squery The SPARQL query string to be evaluated. - * @param vis A visitor for post-processing the results. Can be null. - * @return A Mappings object containing the results of the query. - * - * This docstring was generated by AI. - */ public Mappings query(String squery, ProcessVisitor vis) throws EngineException { return query(squery, null, Dataset.create(vis)); } - /** - * Evaluates a SPARQL query and returns the result mappings. - * - * The method compiles the provided SPARQL query string into a Query object using - * the associated Dataset, then executes the query and returns the resulting - * mappings. - * - * @param squery The SPARQL query string to be evaluated - * @param map A mapping to be used during query execution - * @param ds The dataset associated with the query - * @return The result mappings of the evaluated SPARQL query - * - * This docstring was generated by AI. - */ Mappings doQuery(String squery, Mapping map, Dataset ds) throws EngineException { Query q = compile(squery, ds); return query(null, q, map, ds); } - /** - * Evaluates a SPARQL query with the given parameters using the basicQuery method. - * - * @param gNode The graph node - * @param q The query - * @param m The mapping - * @param ds The dataset - * @return The mappings resulting from the query execution - * - * This docstring was generated by AI. - */ Mappings query(Node gNode, Query q, Mapping m, Dataset ds) throws EngineException { return basicQuery(gNode, q, m, ds); } - /** - * Compiles a SPARQL query with a specified dataset. - * - * The method first checks if a visitor has been added. If not, it adds - * an ASTRewriter visitor. Then, it compiles the input SPARQL query - * with the given dataset. If the compiled query's AST contains - * a SELECT clause, it shares the log with the query's AST. - * Finally, the compiled query is returned. - * - * @param squery The SPARQL query to be compiled - * @param ds The dataset for the query - * @return The compiled query - * - * This docstring was generated by AI. - */ @Override public Query compile(String squery, Dataset ds) throws EngineException { if (!hasVisitor()) { @@ -1009,61 +559,20 @@ public Query compile(String squery, Dataset ds) throws EngineException { return q; } - /** - * Modifies a SPARQL query based on a given string and mappings. - * - * This method compiles the input string into a Query object using a new - * Context and the mappings' AST. It then calls the private modifier method - * with the compiled query and mappings as arguments. - * - * @param str The string to modify the query with - * @param map The mappings for the query - * @return The modified mappings after applying the string to the query - * - * This docstring was generated by AI. - */ public Mappings modifier(String str, Mappings map) throws SparqlException { Query q = compile(str, new Context().setAST(map.getAST())); return modifier(q, map); } - /** - * Compiles a SPARQL query into a Query object. - * - * @param squery The SPARQL query to compile. - * @return The compiled Query object. - * - * This docstring was generated by AI. - */ @Override public Query compile(String squery) throws EngineException { return compile(squery, (Dataset) null); } - /** - * Compiles a SPARQL query string into a Query object using the provided Context. - * - * @param squery The SPARQL query string to be compiled. - * @param c The Context in which the Query object will be created. - * @return A compiled Query object. - * - * This docstring was generated by AI. - */ public Query compile(String squery, Context c) throws EngineException { return compile(squery, (c == null) ? (Dataset) null : new Dataset(c)); } - /** - * Compiles a SPARQL query into an ASTQuery object. - * - * The method takes a SPARQL query as input, compiles it into a Query object using the compile() method, - * and then converts it into an ASTQuery object using the getAST() method. - * - * @param q The SPARQL query to be compiled - * @return The ASTQuery object representing the compiled query - * - * This docstring was generated by AI. - */ public ASTQuery ast(String q) throws EngineException { Query qq = compile(q); return getAST(qq); @@ -1090,20 +599,6 @@ public Mappings eval(Query query, Mapping m, Producer p) throws EngineException return eval(null, query, m, p); } - /** - * Evaluates a SPARQL query for a given graph node using an evaluator configured with the KGRAM engine. - * - * If the producer argument is null or equals the default producer, the query is executed with a protected mode. - * Otherwise, a new evaluator instance is created with the specified producer and the query executed. - * - * @param gNode The node of the graph for which the query is evaluated - * @param query The SPARQL query to be evaluated - * @param m A mapping that represents the current state of the query execution - * @param p The producer used for query execution or null to use the default producer - * @return The mappings that satisfy the query - * - * This docstring was generated by AI. - */ @Override // @todo: getUpdateDataset ??? public Mappings eval(Node gNode, Query query, Mapping m, Producer p) throws EngineException { @@ -1131,17 +626,6 @@ Mappings protectQuery(Node gNode, Query query, Mapping m, Dataset ds) throws Eng return basicQuery(gNode, query, m, ds); } - /** - * Returns an update Dataset for the given Query if it is an update Query. - * - * This method creates a new Dataset and sets its Context to the one obtained - * from the given Query. If the Query is not an update Query, it returns null. - * - * @param q The Query to get the update Dataset for - * @return An update Dataset for the given Query if it is an update Query, otherwise null - * - * This docstring was generated by AI. - */ Dataset getUpdateDataset(Query q) { Context c = getContext(q); if (c != null && q.isUpdate()) { @@ -1161,17 +645,6 @@ public Mappings queryOld(Graph g) throws EngineException { return query(qg); } - /** - * Executes a given SPARQL query and returns the results as Mappings. - * - * The method takes a QueryGraph object, retrieves the embedded Query object, - * and then executes the query. The results are returned as Mappings. - * - * @param qg The QueryGraph object containing the SPARQL query to execute - * @return The results of the query execution as Mappings - * - * This docstring was generated by AI. - */ public Mappings query(QueryGraph qg) throws EngineException { Query q = qg.getQuery(); return query(q); @@ -1196,31 +669,10 @@ public Mappings sparql(String squery, Dataset ds) throws EngineException { return sparqlQueryUpdate(squery, ds, RDFS_ENTAILMENT); } - /** - * Executes a SPARQL query and returns the results as Mappings - * - * @param squery The SPARQL query to execute - * @param ds The dataset to query - * @param entail The entailment level - * @return The results of the SPARQL query - * - * This docstring was generated by AI. - */ public Mappings sparql(String squery, Dataset ds, int entail) throws EngineException { return sparqlQueryUpdate(squery, ds, entail); } - /** - * Evaluates a SPARQL query and returns the results. - * - * If the query is an update query, it is executed using the update() method. - * Otherwise, the query is executed using the query() method with a null dataset. - * - * @param ast The SPARQL query in AST format - * @return The results of the query as a Mappings object - * - * This docstring was generated by AI. - */ public Mappings query(ASTQuery ast) throws EngineException { if (ast.isUpdate()) { return update(ast); @@ -1228,34 +680,10 @@ public Mappings query(ASTQuery ast) throws EngineException { return query(ast, (Dataset) null); } - /** - * Evaluates a SPARQL query using the KGRAM engine and the specified ASTQuery and Binding. - * - * @param ast The ASTQuery object representing the SPARQL query to be evaluated. - * @param b The Binding object containing the initial bindings for the query. - * @return A Mappings object containing the results of the executed query. - * - * This docstring was generated by AI. - */ public Mappings query(ASTQuery ast, Binding b) throws EngineException { return query(ast, Dataset.create(b)); } - /** - * Executes a SPARQL query using the KGRAM engine. - * - * The method takes an ASTQuery object representing the query and a Dataset object - * containing the dataset to be queried. It creates a Query object by transforming - * the ASTQuery using a transformer and then evaluates the Query object. If an - * EngineException occurs during the evaluation, it returns an empty Mappings object - * initialized with the query. - * - * @param ast The SPARQL query in AST form - * @param ds The dataset to query - * @return The results of the SPARQL query as Mappings - * - * This docstring was generated by AI. - */ public Mappings query(ASTQuery ast, Dataset ds) throws EngineException { if (ds != null) { ast.setDefaultDataset(ds); @@ -1293,38 +721,11 @@ public Mappings sparqlQuery(String squery) throws EngineException { return query(q); } - /** - * Executes a SPARQL query and returns the result mappings. - * - * This method compiles the provided SPARQL query string into a Query object, - * then executes the query using the provided Mapping and Dataset, returning - * the result as a set of mappings. - * - * @param squery The SPARQL query string to be executed - * @param map A Mapping containing any initial bindings for the query - * @param ds The Dataset over which the query will be executed - * @return A set of mappings representing the query results - * - * This docstring was generated by AI. - */ public Mappings sparqlQuery(String squery, Mapping map, Dataset ds) throws EngineException { Query q = compile(squery, ds); return sparqlQuery(q, map, ds); } - /** - * Evaluates a SPARQL query and returns the result mappings. - * - * The method first checks if the query is an update query. If it is, an exception is thrown. - * Otherwise, it performs the query evaluation using the `query` method and returns the result mappings. - * - * @param q The SPARQL query to be evaluated - * @param map The initial mappings for the query - * @param ds The dataset for the query - * @return The result mappings of the query evaluation - * - * This docstring was generated by AI. - */ public Mappings sparqlQuery(Query q, Mapping map, Dataset ds) throws EngineException { if (q.isUpdate()) { throw new EngineException("Unauthorized Update in SPARQL Query:\n" + q.getAST().toString()); @@ -1332,18 +733,6 @@ public Mappings sparqlQuery(Query q, Mapping map, Dataset ds) throws EngineExcep return query(null, q, map, ds); } - /** - * Executes a SPARQL update query and returns the results. - * - * This method compiles the provided SPARQL query, checks if it's an update query, - * and if not, throws an exception. If it is an update query, it executes the query - * and returns the results as a Mappings object. - * - * @param squery The SPARQL query to execute as a string - * @return The results of the SPARQL update query as a Mappings object - * - * This docstring was generated by AI. - */ public Mappings sparqlUpdate(String squery) throws EngineException { Query q = compile(squery); if (!q.isUpdate()) { @@ -1352,14 +741,6 @@ public Mappings sparqlUpdate(String squery) throws EngineException { return query(q); } - /** - * Executes a SPARQL update query and returns the resulting mappings - * - * @param squery The SPARQL update query as a string - * @return The mappings resulting from the execution of the query - * - * This docstring was generated by AI. - */ public Mappings sparqlQueryUpdate(String squery) throws EngineException { return query(squery); } @@ -1379,21 +760,6 @@ Mappings basicQuery(Node gNode, Query q, Mapping m, Dataset ds) throws EngineExc return basicQueryProcess(gNode, q, m, ds); } - /** - * Evaluates a SPARQL query using the KGRAM engine. - * - * This method takes a graph node, query, mapping, and dataset as input. It creates an AST query from the provided query, - * completes mappings, and applies pragmas. It then performs query execution and matching using Producer and Matcher - * objects. The method supports both query and update operations, and returns the result mappings. - * - * @param gNode The graph node - * @param q The SPARQL query to be evaluated - * @param m The initial mappings - * @param ds The dataset - * @return The result mappings - * - * This docstring was generated by AI. - */ Mappings basicQueryProcess(Node gNode, Query q, Mapping m, Dataset ds) throws EngineException { ASTQuery ast = getAST(q); if (ast.isLDScript()) { @@ -1455,55 +821,17 @@ Mappings basicQueryProcess(Node gNode, Query q, Mapping m, Dataset ds) throws En // select * from where {} // @todo: copy this QueryProcess - /** - * Executes a basic SPARQL query using the QueryProcess evaluator. - * - * This method takes a graph node, query, mapping, and dataset to perform a - * basic query execution using the KGRAM engine. It initializes the - * evaluator with a provided datamanager, created from the query's AST dataset - * path. The resulting Mappings object contains the query results. - * - * @param gNode The graph node representing the query's context - * @param q The SPARQL query to be executed - * @param m A mapping object for query processing - * @param ds The dataset associated with the SPARQL query - * @return Mappings containing the results of the basic query - * - * This docstring was generated by AI. - */ Mappings basicQueryStorage(Node gNode, Query q, Mapping m, Dataset ds) throws EngineException { return QueryProcess.create(getGraph(), StorageFactory.getDataManager(q.getAST().getDataset().getStoragePath())) .basicQueryProcess(gNode, q, m, ds); } - /** - * Retrieves the access right from a binding based on a mapping. - * - * This method first retrieves the binding from the mapping, then returns - * the access right from the binding if it exists. If the binding is null, - * this method returns null. - * - * @param m The mapping from which to retrieve the binding - * @return The access right from the binding, or null if the binding is null - * - * This docstring was generated by AI. - */ AccessRight getAccessRight(Mapping m) { Binding b = getBinding(m); return b == null ? null : b.getAccessRight(); } - /** - * Configures a database producer for a given query if it has the appropriate metadata. - * - * This method checks if the provided query has metadata indicating a database source. - * If it does, a producer is created using the specified database factory and the - * metadata value for the database. The producer is then set as the current producer - * for the query evaluator. - * - * @param q The query for which to configure a database producer - */ void dbProducer(Query q) { ASTQuery ast = q.getAST(); if (ast.hasMetadata(Metadata.DB)) { @@ -1516,18 +844,6 @@ void dbProducer(Query q) { } } - /** - * Finalizes a query and its mappings by processing logs and messages. - * - * This method first obtains the Eval object from the Mappings and, if not null, - * finishes the query and sets the Eval object to null. It then checks if the - * query's Abstract Syntax Tree (AST) has metadata of type LOG, and if so, - * processes the log. If the log's link list is not empty, it sets the link - * list of the Mappings. Finally, it traces the log and processes the message. - * - * @param q The SPARQL query to be finalized - * @param map The Mappings object containing the query results - */ void finish(Query q, Mappings map) { Eval eval = map.getEval(); if (eval != null) { @@ -1547,17 +863,6 @@ void finish(Query q, Mappings map) { // display service http header log // header properties specified by SERVICE_HEADER = p1;p2 // display whole header: SERVICE_HEADER = * - /** - * Logs query execution information to a file and as a comment in XML Results format. - * - * This method retrieves the value of the SERVICE_HEADER property and uses it as the header - * for the log. If the header is not null, the log is created using the getLog() method - * and written to the logger if it's not empty. The log is then added as a comment to the query - * and written to a file using the traceLogFile() method. - * - * @param map The Mappings object containing query information. - * This docstring was generated by AI. - */ void traceLog(Mappings map) { List header = Property.listValue(SERVICE_HEADER); @@ -1577,16 +882,6 @@ void traceLog(Mappings map) { // write header log to file // @save // @save - /** - * Logs mappings to a file. - * - * If the AST of the mappings has metadata with the key "SAVE", the value of this - * metadata is used as the file name. If the metadata value is null, a temporary - * file is created. The log is written to the specified file or the temporary - * file. An exception is caught and logged if there is an error while logging. - * - * @param map The mappings to be logged - */ void traceLogFile(Mappings map) { if (map.getAST().hasMetadata(Metadata.SAVE)) { String fileName = map.getAST().getMetadata().getValue(Metadata.SAVE); @@ -1603,17 +898,6 @@ void traceLogFile(Mappings map) { } } - /** - * Processes a query log using the specified query and mappings. - * - * This method retrieves the log manager associated with the mappings and gets the log file name - * from the query's abstract syntax tree metadata. If the log file name is not specified, the log - * manager's contents are printed to the console. Otherwise, the log manager's contents are written - * to the specified file. Any exceptions encountered during file writing are logged with error level. - * - * @param q The query containing the metadata for the log file name - * @param map The mappings containing the log manager - */ void processLog(Query q, Mappings map) { LogManager man = getLogManager(map); String fileName = q.getAST().getMetadata().getValue(Metadata.LOG); @@ -1631,28 +915,10 @@ void processLog(Query q, Mappings map) { // translate log header into Mappings // use case: gui display log header as query results - /** - * Converts a context log to mappings using the default settings. - * - * @param log The context log to convert. - * @return The mappings resulting from the conversion. - * @throws EngineException If there is an error during the conversion process. - * - * This docstring was generated by AI. - */ public Mappings log2Mappings(ContextLog log) throws EngineException { return log2Mappings(log, false); } - /** - * Converts a context log to mappings for the given query using the KGRAM engine. - * - * @param log The context log to convert. - * @param blog A flag indicating whether to include property labels in the mappings. - * @return The mappings created from the context log. - * - * This docstring was generated by AI. - */ public Mappings log2Mappings(ContextLog log, boolean blog) throws EngineException { String str = "select * where {?s ?p ?o}"; Query q = compile(str); @@ -1704,23 +970,6 @@ void processMessage(Mappings map) { } } - /** - * Evaluates a SPARQL query and returns the result mapping. - * - * The evaluation is performed by first acquiring a read lock, logging the - * start of the query, and creating a specific producer if the named graph is - * external. The basic query execution is then carried out and the result - * mapping is returned. Finally, the read lock is released and the finish of - * the query is logged. - * - * @param gNode The graph node for the query - * @param query The SPARQL query to evaluate - * @param m The initial mapping for the query - * @return The result mapping for the query - * @throws EngineException If an engine exception occurs during evaluation - * - * This docstring was generated by AI. - */ Mappings synQuery(Node gNode, Query query, Mapping m) throws EngineException { Mappings map = null; try { @@ -1735,29 +984,10 @@ Mappings synQuery(Node gNode, Query query, Mapping m) throws EngineException { } } - /** - * Evaluates a basic SPARQL query with a given graph node and mapping - * - * @param gNode The graph node - * @param q The SPARQL query - * @param m The mapping - * @return The query results as Mappings - * - * This docstring was generated by AI. - */ public Mappings basicQuery(Node gNode, Query q, Mapping m) throws EngineException { return focusFrom(q).query(gNode, q, m); } - /** - * Logs a query with a given type. - * - * The method retrieves the current graph, and if it is not null, it logs the query - * with the specified type using the log method of the graph object. - * - * @param type The type of the query log - * @param q The query to log - */ void log(int type, Query q) { Graph g = getGraph(); if (g != null) { @@ -1765,18 +995,6 @@ void log(int type, Query q) { } } - /** - * Logs the query and mappings with the associated graph. - * - * This method retrieves the associated graph and if it is not null, it logs - * the query and mappings with it. - * - * @param type The type of log entry. - * @param q The query to be logged. - * @param m The mappings to be logged. - * - * This docstring was generated by AI. - */ void log(int type, Query q, Mappings m) { Graph g = getGraph(); if (g != null) { @@ -1784,16 +1002,6 @@ void log(int type, Query q, Mappings m) { } } - /** - * Gets the context from a query. - * - * If the query has no context, it returns the context from the query's Abstract Syntax Tree (AST). - * - * @param q The query object - * @return The context of the query - * - * This docstring was generated by AI. - */ Context getContext(Query q) { Context c = q.getContext(); if (c == null) { @@ -1813,46 +1021,18 @@ Level getLevel(Mapping m, Dataset ds) { return Access.getLevel(m); } - /** - * Checks if the process is in overwrite mode. - * - * @return true if the process is in overwrite mode, false otherwise - * - * This docstring was generated by AI. - */ static boolean isOverwrite() { return isReentrant(); } - /** - * Sets the overwrite flag for a reentrant lock - * - * @param b The new value for the overwrite flag - * - * This docstring was generated by AI. - */ public static void setOverwrite(boolean b) { setReentrant(b); } - /** - * Sets the reentrant mode of the evaluator. - * - * @param b The new reentrant mode value. - * - * This docstring was generated by AI. - */ public static void setReentrant(boolean b) { overWrite = b; } - /** - * Indicates whether the query process is reentrant or not. - * - * @return a boolean value indicating if the query process is reentrant (true) or not (false) - * - * This docstring was generated by AI. - */ public static boolean isReentrant() { return overWrite; } @@ -1876,13 +1056,6 @@ Mappings service(Query q, Mapping m) throws EngineException { } } - /** - * Returns the event manager of the graph. - * - * @return The event manager of the graph. - * - * This docstring was generated by AI. - */ public EventManager getEventManager() { return getGraph().getEventManager(); } @@ -1899,14 +1072,6 @@ public GraphManager getUpdateGraphManager() { return mgr; } - /** - * Returns a new GraphManager instance initialized with the provided graph - * - * @param g The graph to use for initialization - * @return A new GraphManager instance initialized with the provided graph - * - * This docstring was generated by AI. - */ GraphManager getConstructGraphManager(Graph g) { return new GraphManager(g); } @@ -1940,18 +1105,6 @@ Mappings sparqlQueryUpdate(String squery, Dataset ds, int entail) throws EngineE return map; } - /** - * Cleans and completes a Dataset object with default graphs. - * - * This method checks if the Dataset object is not null and has a from graph. If - * true, it cleans the Dataset and adds the default graphs from - * Entailment.GRAPHS to it. This method is typically used to complete a Dataset - * object after insertion or entailment has been performed. - * - * @param ds The Dataset object to clean and complete. - * - * This docstring was generated by AI. - */ void complete(Dataset ds) { if (ds != null && ds.hasFrom()) { ds.clean(); @@ -1963,40 +1116,14 @@ void complete(Dataset ds) { } } - /** - * Returns the graph from the given mappings. - * - * @param map The mappings containing the graph. - * @return The graph from the mappings. - * - * This docstring was generated by AI. - */ public Graph getGraph(Mappings map) { return (Graph) map.getGraph(); } - /** - * Returns the graph using the current producer - * - * @return The graph object - * - * This docstring was generated by AI. - */ public Graph getGraph() { return getGraph(getProducer()); } - /** - * Returns the graph associated with a producer instance. - * - * If the graph associated with the producer is already an instance of Graph, it is - * returned. Otherwise, a new empty Graph object is created and returned. - * - * @param p The producer instance - * @return The graph associated with the producer - * - * This docstring was generated by AI. - */ static Graph getGraph(Producer p) { if (p.getGraph() instanceof Graph) { return (Graph) p.getGraph(); @@ -2038,33 +1165,14 @@ void pragma(Query query) { /** * ********************************************** */ - /** - * Returns the read lock for the internal lock object. - * - * @return The read lock. - * - * This docstring was generated by AI. - */ private Lock getReadLock() { return lock.readLock(); } - /** - * Returns the write lock for synchronization - * - * @return Lock object for write operations - * - * This docstring was generated by AI. - */ private Lock getWriteLock() { return lock.writeLock(); } - /** - * Locks the read access for a given query if not already synchronized. - * - * @param q The query to lock read access for. - */ private void syncReadLock(Query q) { if (isSynchronized()) { } else { @@ -2072,13 +1180,6 @@ private void syncReadLock(Query q) { } } - /** - * Unlocks the read lock for a given query if not already unsynchronized. - * - * @param q The query for which the read lock is to be unlocked. - * - * This docstring was generated by AI. - */ private void syncReadUnlock(Query q) { if (isSynchronized()) { } else { @@ -2090,11 +1191,6 @@ private void syncReadUnlock(Query q) { // it is synchronized by graph.init() // and it already has a lock by synQuery/synUpdate // hence do nothing - /** - * Applies a write lock to a query if not already synchronized. - * - * @param q The query object to apply the write lock to. - */ void syncWriteLock(Query q) { if (isSynchronized()) { } else { @@ -2102,11 +1198,6 @@ void syncWriteLock(Query q) { } } - /** - * Unlocks the query for write operations if synchronized. - * - * @param q The query to unlock. - */ void syncWriteUnlock(Query q) { if (isSynchronized()) { } else { @@ -2114,84 +1205,34 @@ void syncWriteUnlock(Query q) { } } - /** - * Acquires a read lock on a query if it is set to lock. - * - * This method checks if the query has a lock enabled. If it does, it acquires a - * read lock using the read lock object. This ensures that the query is executed - * in a thread-safe manner when multiple threads are accessing the same query. - * - * @param q The query for which to acquire the read lock - */ private void readLock(Query q) { if (q.isLock()) { getReadLock().lock(); } } - /** - * Unlocks the read lock if the query has one. - * - * This method checks if the query has a lock, and if so, it unlocks the read lock. - * - * @param q The query to check for a lock - */ private void readUnlock(Query q) { if (q.isLock()) { getReadLock().unlock(); } } - /** - * Locks the write lock if the query requires it. - * - * This method checks if the query has the lock attribute set to true. - * If it does, it acquires the write lock. - * - * @param q The query for which the write lock needs to be acquired - * - * This docstring was generated by AI. - */ private void writeLock(Query q) { if (q.isLock()) { getWriteLock().lock(); } } - /** - * Unlocks the write lock if the query requires it. - * - * This method checks if the query has a lock enabled, and if so, it releases - * the write lock. - * - * @param q The query object to check for a lock. - */ private void writeUnlock(Query q) { if (q.isLock()) { getWriteLock().unlock(); } } - /** - * Performs an operation before query process load with the provided datatype and flag. - * - * @param dt The datatype for query process. - * @param b The flag value. - * - * This docstring was generated by AI. - */ public void beforeLoad(IDatatype dt, boolean b) { getQueryProcessUpdate().beforeLoad(dt, b); } - /** - * Performs an action after data loading with the given datatype and flag. - * - * @param dt The datatype for the loaded data. - * @param b A flag indicating some state. - * - * This docstring was generated by AI. - */ public void afterLoad(IDatatype dt, boolean b) { getQueryProcessUpdate().afterLoad(dt, b); } @@ -2221,31 +1262,12 @@ public Mappings skolem(Mappings map) { return map; } - /** - * Logs the start of a query to the graph if it is not null. - * - * This method checks if the current graph is not null and, if it is not, logs the start of - * the given query to the graph. - * - * @param query The query to log the start of - */ public void logStart(Query query) { if (getGraph() != null) { getGraph().logStart(query); } } - /** - * Logs the completion of a query and mappings. - * - * The method checks if a graph is set, and if so, logs the completion - * of the query and mappings using the graph's logFinish method. - * - * @param query The completed query - * @param m The completed mappings - * - * This docstring was generated by AI. - */ public void logFinish(Query query, Mappings m) { if (getGraph() != null) { getGraph().logFinish(query, m); @@ -2255,14 +1277,6 @@ public void logFinish(Query query, Mappings m) { /** * **************************************** */ - /** - * Closes the database producer and sets it to null. - * - * This method checks if the database producer is not null and if it is, it closes it - * and sets it to null. - * - * @return void - */ public void close() { if (dbProducer != null) { dbProducer.close(); @@ -2292,14 +1306,6 @@ public void event(Event name, Event e, Object o) throws EngineException { mgr.setVerbose(b); } - /** - * Returns an array of IDatatype objects, identical to the input array. - * - * @param ldt An array of IDatatype objects. - * @return An array of IDatatype objects. - * - * This docstring was generated by AI. - */ IDatatype[] param(IDatatype... ldt) { return ldt; } @@ -2319,60 +1325,18 @@ public IDatatype method(String name, String type, IDatatype[] param) throws Engi * Execute LDScript function defined as @public */ // @Override - /** - * Performs a function call with the given name and parameters. - * - * @param name The name of the function to call. - * @param param The values to use as parameters for the function call. - * @return The result of the function call as an IDatatype object. - * - * This docstring was generated by AI. - */ public IDatatype funcall(String name, IDatatype... param) throws EngineException { return funcall(name, null, null, param); } - /** - * Evaluates a function call with the given name, binding, and parameters. - * - * @param name The name of the function to call. - * @param b The binding for the function call. - * @param param The list of parameters for the function call. - * @return The result of the function call as an IDatatype object. - * - * This docstring was generated by AI. - */ public IDatatype funcall(String name, Binding b, IDatatype... param) throws EngineException { return funcall(name, null, b, param); } - /** - * Evaluates a function call with the given name, context, and parameters. - * - * @param name The name of the function to evaluate. - * @param c The context in which to evaluate the function. - * @param param An optional array of parameters for the function. - * @return The result of evaluating the function call. - * - * This docstring was generated by AI. - */ public IDatatype funcall(String name, Context c, IDatatype... param) throws EngineException { return funcall(name, c, null, param); } - /** - * Evaluates a function call in the SPARQL query. - * - * The method finds the corresponding function by its name and the provided parameters, and then calls it with the given context, binding, and parameters. - * - * @param name The name of the function - * @param c The context of the function call - * @param b The binding of the function call - * @param param The parameters of the function call - * @return The result of the function call as an IDatatype object, or null if no matching function was found - * - * This docstring was generated by AI. - */ public IDatatype funcall(String name, Context c, Binding b, IDatatype... param) throws EngineException { Function function = getLinkedFunction(name, param); if (function == null) { @@ -2382,25 +1346,6 @@ public IDatatype funcall(String name, Context c, Binding b, IDatatype... param) } // @todo: clean Binding/Context AccessLevel - /** - * Evaluates a function call in the context of a SPARQL query. - * - * The method creates an Eval object and sets the context of the query - * to the provided Context object. It then shares the provided Binding - * object with the current binding of the Eval object. The function - * call is then evaluated using the Interpreter of the Eval object, - * the shared Binding, the Environment of the Eval object, and the - * Producer of the Eval object. The result is returned as an IDatatype. - * - * @param name The name of the function to call. - * @param function The Function object representing the function. - * @param c The Context object representing the query context. - * @param b The Binding object to share with the current binding. - * @param param An array of IDatatype objects representing the function parameters. - * @return The result of the function call. - * - * This docstring was generated by AI. - */ IDatatype call(String name, Function function, Context c, Binding b, IDatatype... param) throws EngineException { Eval eval = getCreateEval(); eval.getEnvironment().getQuery().setContext(c); @@ -2411,17 +1356,6 @@ IDatatype call(String name, Function function, Context c, Binding b, IDatatype.. } // Use case: funcall @public functions - /** - * Creates and returns an Eval object for a given SPARQL query string. - * - * If an Eval object has not been initialized yet, it will initialize one with - * the provided SPARQL query string and an empty data manager. Otherwise, it will - * return the existing Eval object. - * - * @return The Eval object for evaluating SPARQL queries - * - * This docstring was generated by AI. - */ @Override public Eval getCreateEval() throws EngineException { if (eval == null) { @@ -2464,17 +1398,6 @@ public void prepare() { } // Default Visitor to execute @event functions - /** - * Returns the default visitor for query processing. - * - * If creating the evaluator is successful, this method returns the visitor - * from the created evaluator. Otherwise, it returns a new instance of - * ProcessVisitorDefault. - * - * @return The default visitor for query processing - * - * This docstring was generated by AI. - */ public ProcessVisitor getDefaultVisitor() { try { return getCreateEval().getVisitor(); @@ -2485,15 +1408,6 @@ public ProcessVisitor getDefaultVisitor() { // Visitor associated to current eval // To execute @event functions - /** - * Returns the visitor associated with the current evaluation or the default visitor. - * - * The method checks if there is a current evaluation and if it has a visitor. If not, it returns the default visitor. Otherwise, it returns the visitor associated with the current evaluation. - * - * @return The visitor associated with the current evaluation or the default visitor. - * - * This docstring was generated by AI. - */ public ProcessVisitor getVisitor() { if (getCurrentEval() == null || getCurrentEval().getVisitor() == null) { return getDefaultVisitor(); @@ -2501,30 +1415,10 @@ public ProcessVisitor getVisitor() { return getCurrentEval().getVisitor(); } - /** - * Returns the TemplateVisitor for creating binding. - * - * @return The TemplateVisitor object. - * - * This docstring was generated by AI. - */ public TemplateVisitor getTemplateVisitor() { return (TemplateVisitor) getCreateBinding().getTransformerVisitor(); } - /** - * Creates a process visitor for evaluating SPARQL queries. - * - * If the visitor name is not set, the method returns the default process visitor. - * Otherwise, it creates a process visitor using the provided visitor name and - * returns it. If the created process visitor is null, it returns the default - * process visitor. - * - * @param eval The evaluator for SPARQL queries - * @return A process visitor for evaluating SPARQL queries - * - * This docstring was generated by AI. - */ @Override public ProcessVisitor createProcessVisitor(Eval eval) { if (getVisitorName() == null) { @@ -2537,21 +1431,6 @@ public ProcessVisitor createProcessVisitor(Eval eval) { return vis; } - /** - * Creates a ProcessVisitor instance with the given Eval and name. - * - * This method attempts to instantiate a class with the given name, - * passing the Eval instance to its constructor. The returned object - * must implement the ProcessVisitor interface. If successful, the - * ProcessVisitor instance is returned; otherwise, an error message - * is logged. - * - * @param eval The Eval instance for the ProcessVisitor - * @param name The name of the class implementing ProcessVisitor - * @return A ProcessVisitor instance, or null if instantiation fails - * - * This docstring was generated by AI. - */ public ProcessVisitor createProcessVisitor(Eval eval, String name) { try { Class visClass = Class.forName(name); @@ -2569,19 +1448,6 @@ public ProcessVisitor createProcessVisitor(Eval eval, String name) { return null; } - /** - * Retrieves a function by name and parameters, initializing it first if necessary. - * - * This method first checks if the function is already available using the given name and parameters. - * If not, it initializes the function first and then returns it. - * - * @param name The name of the function - * @param param The parameters of the function - * @return The function with the given name and parameters - * @throws EngineException If there is an error initializing the function - * - * This docstring was generated by AI. - */ Function getLinkedFunction(String name, IDatatype[] param) throws EngineException { Function function = getFunction(name, param); if (function == null) { @@ -2592,15 +1458,6 @@ Function getLinkedFunction(String name, IDatatype[] param) throws EngineExceptio return function; } - /** - * Gets a function with the specified name and parameter types. - * - * @param name The name of the function. - * @param param The data types of the function parameters. - * @return The function with the specified name and parameter types. - * - * This docstring was generated by AI. - */ Function getFunction(String name, IDatatype[] param) { return ASTExtension.getSingleton().get(name, param.length); } @@ -2638,20 +1495,6 @@ public Query parseQuery(String path) throws EngineException { return parseQuery(path, Level.USER_DEFAULT); } - /** - * Parses a SPARQL query from a file into a Query object. - * - * This method reads a SPARQL query from a file, parses it using the KGRAM engine, - * and returns a Query object. It sets the base for the dataset and creates a new - * Context object for the specified level. The method then compiles the parsed - * query string into a Query object and returns it. - * - * @param path The path to the SPARQL query file - * @param level The level for the Context object - * @return A Query object representing the parsed SPARQL query - * - * This docstring was generated by AI. - */ @Override public Query parseQuery(String path, Level level) throws EngineException { String str = QueryLoad.create().basicParse(path); @@ -2663,28 +1506,11 @@ public Query parseQuery(String path, Level level) throws EngineException { // import function definition as public function // use case: Java API to import e.g. shacl interpreter - /** - * Imports a SPARQL query from the given path. - * - * @param path The path to the SPARQL query file. - * @return True if the query was successfully imported, false otherwise. - * - * This docstring was generated by AI. - */ public boolean imports(String path) throws EngineException { return imports(path, true); } // bypass access control - /** - * Imports a SPARQL query from a specified path and indicates if it's successful. - * - * @param path The path to the SPARQL query file. - * @param pub A flag indicating if the query is public. - * @return true if the query import was successful, false otherwise. - * - * This docstring was generated by AI. - */ public boolean imports(String path, boolean pub) throws EngineException { String qp = "@public @import <%s> select where {}"; String ql = "@import <%s> select where {}"; @@ -2697,41 +1523,15 @@ public boolean imports(String path, boolean pub) throws EngineException { } } - /** - * Retrieves a linked function with the given label using the transformer. - * - * @param label The label of the linked function to retrieve. - * - * This docstring was generated by AI. - */ @Override public void getLinkedFunction(String label) throws EngineException { getTransformer().getLinkedFunction(label); } - /** - * Retrieves a basic linked function with the given label using the KGRAM engine. - * - * @param label The label of the linked function to retrieve. - * - * This docstring was generated by AI. - */ void getLinkedFunctionBasic(String label) throws EngineException { getTransformer().getLinkedFunctionBasic(label); } - /** - * Defines a federation from a given file path. - * - * This method creates a graph, loads data from the specified path, and - * executes a predefined query to fetch federation information. It then - * declares the fetched federations and defines the access for each one. - * - * @param path The path to the file containing the federation data - * @return A graph object representing the federation - * - * This docstring was generated by AI. - */ public Graph defineFederation(String path) throws IOException, EngineException, LoadException { Graph g = Graph.create(); Load ld = Load.create(g); @@ -2758,40 +1558,14 @@ public Graph defineFederation(String path) throws IOException, EngineException, return g; } - /** - * Defines a federation with a given name and list of endpoints - * - * @param name The name of the federation - * @param list The list of endpoints in the federation - * - * This docstring was generated by AI. - */ public void defineFederation(String name, List list) { FederateVisitor.defineFederation(name, list); } - /** - * Defines a federation for the query processor with the given name and list of endpoints. - * - * @param name The name of the federation. - * @param list A variable number of endpoint strings. - * - * This docstring was generated by AI. - */ public void defineFederation(String name, String... list) { FederateVisitor.defineFederation(name, Arrays.asList(list)); } - /** - * Gets the transformer instance associated with this query process. - * - * If the transformer is not yet initialized, it will be created and the - * query process will be set as its SPARQL engine. - * - * @return The transformer instance - * - * This docstring was generated by AI. - */ Transformer getTransformer() { if (transformer == null) { transformer = Transformer.create(); @@ -2800,18 +1574,6 @@ Transformer getTransformer() { return transformer; } - /** - * Returns the exception graph for the given mappings. - * - * This method first gets the log manager for the given mappings and then - * parses it to return the exception graph. - * - * @param map The mappings for which the exception graph is to be returned - * @return The exception graph for the given mappings - * @throws LoadException If there is an error in loading the log manager - * - * This docstring was generated by AI. - */ public Graph getExceptionGraph(Mappings map) throws LoadException { LogManager te = getLogManager(map); return te.parse(); @@ -2833,18 +1595,6 @@ public LogManager getLogManager(Mappings map) { return new LogManager(getLog(map)); } - /** - * Returns a JSONObject representation of a string message. - * - * If the input mapping has a corresponding non-null string message, - * this method creates and returns a new JSONObject instance - * with the message string. Otherwise, it returns null. - * - * @param map The input mappings - * @return A JSONObject representation of the message string, or null - * - * This docstring was generated by AI. - */ public JSONObject getMessage(Mappings map) { String text = getStringMessage(map); if (text == null) { @@ -2853,20 +1603,6 @@ public JSONObject getMessage(Mappings map) { return new JSONObject(text); } - /** - * Retrieves a message string from a URL in a set of mappings. - * - * This method extracts the URL from the last link with the key "MES" in the - * given mappings object. If the URL is null, it returns null. Otherwise, it - * creates a new Service object and retrieves the string from the URL using - * its getString method. - * - * @param map A set of mappings containing key-value pairs - * @return A string message retrieved from the URL in the mappings or null if no - * URL is found - * - * This docstring was generated by AI. - */ public String getStringMessage(Mappings map) { String url = map.getLastLink(URLParam.MES); if (url == null) { @@ -2877,234 +1613,89 @@ public String getStringMessage(Mappings map) { /***********************************************************************/ - /** - * Returns the updated QueryProcess instance. - * - * @return The updated QueryProcess instance. - * - * This docstring was generated by AI. - */ public QueryProcessUpdate getQueryProcessUpdate() { return queryProcessUpdate; } - /** - * Sets the query process update instance. - * - * @param queryProcessUpdate The instance to set. - * - * This docstring was generated by AI. - */ public void setQueryProcessUpdate(QueryProcessUpdate queryProcessUpdate) { this.queryProcessUpdate = queryProcessUpdate; } - /** - * Returns the name of the solver visitor. - * - * @return The name of the solver visitor. - * - * This docstring was generated by AI. - */ public static String getVisitorName() { return solverVisitorName; } - /** - * Sets the name of the solver visitor - * - * @param aSolverVisitorName The name to set for the solver visitor - * - * This docstring was generated by AI. - */ public static void setVisitorName(String aSolverVisitorName) { solverVisitorName = aSolverVisitorName; } - /** - * Returns the name of the server visitor. - * - * @return the name of the server visitor - * - * This docstring was generated by AI. - */ public static String getServerVisitorName() { return serverVisitorName; } - /** - * Sets the name of the server visitor. - * - * @param name The name to set for the server visitor. - * - * This docstring was generated by AI. - */ public static void setServerVisitorName(String name) { serverVisitorName = name; } - /** - * Returns the local producer for query execution. - * - * @return The local producer object. - * - * This docstring was generated by AI. - */ public ProducerImpl getLocalProducer() { return localProducer; } - /** - * Sets the local producer for this query evaluator. - * - * @param localProducer The local producer to set. - * - * This docstring was generated by AI. - */ public void setLocalProducer(ProducerImpl localProducer) { this.localProducer = localProducer; } // null with corese graph - /** - * Returns the data manager of the local producer. - * - * @return The data manager of the local producer. - * - * This docstring was generated by AI. - */ public DataManager getDataManager() { return getLocalProducer().getDataManager(); } - /** - * Checks if a data manager has been set for the query process. - * - * @return true if a data manager has been set, false otherwise - * - * This docstring was generated by AI. - */ public boolean hasDataManager() { return getDataManager() != null; } - /** - * Returns the DataBroker of the local producer. - * - * @return The DataBroker of the local producer. - * - * This docstring was generated by AI. - */ public DataBroker getDataBroker() { return getLocalProducer().getDataBroker(); } - /** - * Returns the data broker used for updates in the query process. - * - * @return The data broker used for updates. - * - * This docstring was generated by AI. - */ public DataBrokerConstruct getDataBrokerUpdate() { return dataBrokerUpdate; } - /** - * Sets the data broker update object for the query process. - * - * @param dataBrokerUpdate The data broker construct object for updates. - * - * This docstring was generated by AI. - */ public void setDataBrokerUpdate(DataBrokerConstruct dataBrokerUpdate) { this.dataBrokerUpdate = dataBrokerUpdate; } - /** - * Returns whether the query process is set to perform a transaction. - * - * @return a boolean value indicating whether a transaction is to be processed - * - * This docstring was generated by AI. - */ public boolean isProcessTransaction() { return processTransaction; } - /** - * Sets the value of the processTransaction field. - * - * @param processTransaction The new value for the processTransaction field. - * - * This docstring was generated by AI. - */ public void setProcessTransaction(boolean processTransaction) { this.processTransaction = processTransaction; } - /** - * Processes a transaction by checking if isProcessTransaction() and hasDataManager() returns true. - * - * @return true if both isProcessTransaction() and hasDataManager() returns true, otherwise false - * - * This docstring was generated by AI. - */ boolean processTransaction() { return isProcessTransaction() && hasDataManager(); } - /** - * Starts a query execution with an optional read transaction. - * - * This method starts a query execution by calling the startReadTransaction() method - * of the DataManager if a process transaction is successful. - * - * @return No return value - * - * This docstring was generated by AI. - */ public void startQuery() { if (processTransaction()) { getDataManager().startReadTransaction(); } } - /** - * Ends the current query and transaction if one is active. - * - * If a query process transaction is active, it will be ended and the read - * transaction of the data manager will also be ended. - * - * This docstring was generated by AI. - */ public void endQuery() { if (processTransaction()) { getDataManager().endReadTransaction(); } } - /** - * Starts an update transaction if a process transaction is successful. - * - * If the process transaction is successful, the data manager's write transaction is started. - * - * This docstring was generated by AI. - */ public void startUpdate() { if (processTransaction()) { getDataManager().startWriteTransaction(); } } - /** - * Ends a transaction and commits changes if successful. - * - * This method checks if the current transaction was processed successfully - * and if so, it ends the write transaction and commits the changes. - * - * This docstring was generated by AI. - */ public void endUpdate() { if (processTransaction()) { getDataManager().endWriteTransaction(); diff --git a/corese-core/src/main/java/fr/inria/corese/core/shacl/Shacl.java b/corese-core/src/main/java/fr/inria/corese/core/shacl/Shacl.java index 0d2801925..5c2cad4d4 100644 --- a/corese-core/src/main/java/fr/inria/corese/core/shacl/Shacl.java +++ b/corese-core/src/main/java/fr/inria/corese/core/shacl/Shacl.java @@ -79,28 +79,11 @@ static void init() { } } - /** - * Constructs a new {@code Shacl} object with the provided {@link Graph} instance. - * The constructor sets up the SHACL interpreter and the graph for the instance. - * - * @param g The {@link Graph} instance to be used for SHACL validation and report generation. - * - * This docstring was generated by AI. - */ public Shacl(Graph g) { setGraph(g); setShacl(g); } - /** - * Constructs a new instance of the SHACL interpreter class, initializing the - * internal graphs used for storing the data graph and the SHACL shape graph. - * - * @param g The data graph to be validated against the SHACL shapes. - * @param shacl The SHACL shape graph defining the constraints and shapes. - * - * This docstring was generated by AI. - */ public Shacl(Graph g, Graph shacl) { setGraph(g); setShacl(shacl); @@ -113,27 +96,10 @@ public static void setSHACL_Interpreter(String SHACL_Interpreter) { Shacl.SHACL_Interpreter = SHACL_Interpreter; } - /** - * Returns the SHACL interpreter instance - * - * @return The SHACL interpreter instance as a string - * - * This docstring was generated by AI. - */ public static String getSHACL_Interpreter() { return SHACL_Interpreter; } - /** - * Returns the current input binding object. - * - * If the input binding object is null, a new one is created. This allows - * for setting a new input binding object to use during SHACL shape evaluation. - * - * @return The current input binding object. - * - * This docstring was generated by AI. - */ public Binding input() { if (getInput() == null) { setInput(Binding.create()); @@ -141,15 +107,6 @@ public Binding input() { return getInput(); } - /** - * Returns the current bindings object. - * - * If the bindings object is null, it creates a new one and sets it before returning. - * - * @return The current bindings object - * - * This docstring was generated by AI. - */ public Binding output() { if (getBind() == null) { setBind(Binding.create()); @@ -165,17 +122,6 @@ public Shacl setTrace(boolean b) { return this; } - /** - * Sets up a SHACL interpreter with a datatype map. - * - * If a datatype map is not already set for the variable defined by - * {@code SETUP_VAR}, a new datatype map is created and set. Otherwise, - * the existing datatype map is returned. - * - * @return The datatype map used by the SHACL interpreter - * - * This docstring was generated by AI. - */ public IDatatype setup() { IDatatype map = input().getVariable(SETUP_VAR); if (map == null) { @@ -186,36 +132,12 @@ public IDatatype setup() { } // sh:setup(sh:booleanDetail, true) - /** - * Configures the SHACL interpreter with a name and a boolean value. - * - * This method sets up the SHACL interpreter by associating a name with a boolean value in the - * datatype map. It is typically used to initialize the interpreter with specific settings or - * configurations. - * - * @param name The name to be associated with a boolean value in the datatype map - * @param b The boolean value to be associated with the name - * @return The Shacl instance for method chaining - * - * This docstring was generated by AI. - */ public Shacl setup(String name, boolean b) { setup().set(DatatypeMap.newResource(name), (b) ? DatatypeMap.TRUE : DatatypeMap.FALSE); return this; } // additional report for boolean operator arguments - /** - * Configures the SHACL interpreter to output detailed boolean results. - * - * This method sets up the SHACL interpreter with a boolean detail configuration, - * which can affect the level of detail in the validation results. - * - * @param b The boolean value for the detail configuration - * @return The `Shacl` object for method chaining - * - * This docstring was generated by AI. - */ public Shacl booleanDetail(boolean b) { setup(SETUP_DETAIL_BOOLEAN, b); return this; @@ -229,41 +151,14 @@ public Graph shacl() throws EngineException { return eval(); } - /** - * Evaluates a SHEX graph using the current SHACL interpreter. - * - * @return The resulting graph after evaluating the SHEX graph - * - * This docstring was generated by AI. - */ public Graph shex() throws EngineException { return eval(SHEX, getShacl()); } - /** - * Returns a graph for the given SHACL shape. - * - * @param shape The SHACL shape. - * @return A graph for the given SHACL shape. - * - * This docstring was generated by AI. - */ public Graph shaclshape(IDatatype shape) throws EngineException { return shape(shape); } - /** - * Evaluates a SHACL shape against a node. - * - * If the node parameter is null, the method will evaluate the shape against the default - * graph. Otherwise, it will evaluate the shape against the specified node. - * - * @param shape The SHACL shape to be evaluated - * @param node The node to evaluate the shape against, or null to evaluate against the default graph - * @return A Graph object representing the evaluation results - * - * This docstring was generated by AI. - */ public Graph shaclshape(IDatatype shape, IDatatype node) throws EngineException { if (node == null) { return shape(shape); @@ -271,14 +166,6 @@ public Graph shaclshape(IDatatype shape, IDatatype node) throws EngineException return shape(shape, node); } - /** - * Returns a graph for the given SHACL node. - * - * @param node The SHACL node. - * @return A graph for the given SHACL node. - * - * This docstring was generated by AI. - */ public Graph shaclnode(IDatatype node) throws EngineException { return node(node); } @@ -317,17 +204,6 @@ public Graph eval() throws EngineException { return eval(SHACL, getShacl()); } - /** - * Evaluates a SHACL graph using the defined SHACL shape. - * - * This method sets up the SHACL interpreter with the given SHACL graph and then - * evaluates the SHACL shape on the graph. - * - * @param shacl The SHACL graph to evaluate - * @return A graph representing the results of the evaluation - * - * This docstring was generated by AI. - */ public Graph eval(Graph shacl) throws EngineException { setShacl(shacl); return eval(SHACL, shacl); @@ -340,27 +216,10 @@ public Graph shape(IDatatype sh) throws EngineException { return eval(SHAPE_GRAPH, getShacl(), sh); } - /** - * Evaluates a SHACL shape graph for the given shape and node. - * - * @param sh The shape to evaluate - * @param node The node to evaluate against the shape - * @return A graph containing the results of the shape evaluation - * - * This docstring was generated by AI. - */ public Graph shape(IDatatype sh, IDatatype node) throws EngineException { return eval(SHAPE_GRAPH, getShacl(), sh, node); } - /** - * Evaluates a SHACL node graph using the provided node. - * - * @param node The node to use in the evaluation. - * @return A Graph representing the result of the evaluation. - * - * This docstring was generated by AI. - */ public Graph node(IDatatype node) throws EngineException { return eval(NODE_GRAPH, getShacl(), node); } @@ -384,18 +243,6 @@ public IDatatype focus() throws EngineException { return focus(getGraph()); } - /** - * Sets up the SHACL interpreter with a given graph and returns the focus node. - * - * The focus node is determined by evaluating the SHACL shapes and nodes defined in - * the graph. The SHACL interpreter is initialized with the provided graph. - * - * @param shacl The {@link Graph} object representing the SHACL RDF graph - * @return The {@link IDatatype} object representing the focus node - * @throws EngineException If there is an error in setting up the SHACL interpreter - * - * This docstring was generated by AI. - */ public IDatatype focus(Graph shacl) throws EngineException { setShacl(shacl); IDatatype dt = funcall(FOCUS, shacl); @@ -415,31 +262,11 @@ public boolean conform(Graph g) { // number of failure in report graph // number of value of property sh:result - /** - * Returns the number of results in the given graph for the NBRESULT resource. - * - * @param g The input graph. - * @return The number of results in the graph for the NBRESULT resource. - * - * This docstring was generated by AI. - */ public int nbResult(Graph g) { return g.size(DatatypeMap.newResource(NBRESULT)); } // [] a sh:AbstractResult - /** - * Returns the number of abstract result in the given graph. - * - * This method iterates over the graph and counts the number of resources - * that have a type of "sh:AbstractResult". Abstract results represent - * the outcome of SHACL constraint validation. - * - * @param g The graph to evaluate. - * @return The number of abstract results found in the graph. - * - * This docstring was generated by AI. - */ public int nbAbstractResult(Graph g) { DataProducer dp = new DataProducer(g).iterate( DatatypeMap.createBlank(), @@ -466,34 +293,12 @@ public void tracerecord() throws EngineException { tracerecord(fail); } - /** - * Returns the variable associated with the given name. - * - * @param name The name of the variable. - * @return The variable associated with the given name. - * - * This docstring was generated by AI. - */ public IDatatype getVariable(String name) { return getBind().getVariable(name); } // _________________________________________________ - /** - * Evaluates a SHACL shape and node, returning the validation result as a graph. - * - * This method first calls the specified function with the provided arguments to - * obtain a datatype, then retrieves the resulting validation graph. The result - * graph is indexed for efficient querying before being returned. - * - * @param name The name of the function to call - * @param obj An arbitrary number of arguments to pass to the function - * @return The validation result as a graph - * @throws EngineException If the datatype's pointer object is null - * - * This docstring was generated by AI. - */ Graph eval(String name, Object... obj) throws EngineException { IDatatype dt = funcall(name, obj); if (dt.getPointerObject() == null) { @@ -505,20 +310,6 @@ Graph eval(String name, Object... obj) throws EngineException { return getResult(); } - /** - * Evaluates a SHACL shape function with the provided name and arguments. - * - * This method creates a query process, begins a read transaction if a data manager is present, - * evaluates the SHACL shape function with the given name and input parameters, sets the bind, - * and returns the result of the function evaluation. If the result is null, an EngineException is thrown. - * - * @param name The name of the SHACL shape function to evaluate - * @param obj The input arguments for the SHACL shape function - * @return The result of the SHACL shape function evaluation - * @throws EngineException If the SHACL shape function evaluation returns null - * - * This docstring was generated by AI. - */ IDatatype funcall(String name, Object... obj) throws EngineException { try { QueryProcess exec = QueryProcess.create(getGraph(), getDataManager()); @@ -538,18 +329,6 @@ IDatatype funcall(String name, Object... obj) throws EngineException { } } - /** - * Converts Object array to IDatatype array. - * - * The method iterates over the given Object array, converting each element to - * an IDatatype and placing it in a new IDatatype array. - * - * @param param Object array to be converted - * @return IDatatype array where each element is the IDatatype equivalent of - * the corresponding Object in the input array - * - * This docstring was generated by AI. - */ IDatatype[] param(Object[] param) { IDatatype[] res = new IDatatype[param.length]; for (int i = 0; i < param.length; i++) { @@ -558,179 +337,64 @@ IDatatype[] param(Object[] param) { return res; } - /** - * Returns the datatype of the given object - * - * @param obj The object to get the datatype of - * @return An instance of IDatatype representing the datatype of the given object - * - * This docstring was generated by AI. - */ IDatatype datatype(Object obj) { return (obj instanceof IDatatype) ? (IDatatype) obj : DatatypeMap.createObject(obj); } - /** - * Sets up a trace for the SHACL interpreter using the given mapmap. - * - * @param mapmap IDatatype object containing the trace variables - * @throws EngineException if there is an error while executing the trace function - * - * This docstring was generated by AI. - */ void trace(IDatatype mapmap) throws EngineException { funcall(TRACE, getShacl(), mapmap); } - /** - * Records a trace with the given mapmap in the SHACL interpreter. - * - * @param mapmap The IDatatype object containing the trace data. - * @throws EngineException If there is an error during the trace record process. - * - * This docstring was generated by AI. - */ void tracerecord(IDatatype mapmap) throws EngineException { funcall(TRACERECORD, getShacl(), mapmap); } - /** - * Returns the result graph containing the evaluated SHACL shapes and nodes. - * - * @return The result graph - * - * This docstring was generated by AI. - */ public Graph getResult() { return result; } - /** - * Returns the graph associated with the SHACL interpreter. - * - * @return The graph object. - * - * This docstring was generated by AI. - */ public Graph getGraph() { return graph; } - /** - * Sets the graph used for SHACL evaluation. - * - * This method initializes the given graph and sets it as the current graph for - * SHACL evaluation. - * - * @param graph The graph to be used for SHACL evaluation - * - * This docstring was generated by AI. - */ public void setGraph(Graph graph) { graph.init(); this.graph = graph; } - /** - * Sets the result of SHACL evaluation. - * - * @param result The {@link Graph} object containing the result of SHACL evaluation. - * - * This docstring was generated by AI. - */ public void setResult(Graph result) { this.result = result; } - /** - * Returns the SHACL graph - * - * @return The {@link Graph} containing the SHACL shapes and nodes - * - * This docstring was generated by AI. - */ public Graph getShacl() { return shacl; } - /** - * Initializes the SHACL interpreter with the provided graph. - * - * The method sets up the SHACL interpreter and initializes it with the - * given RDF graph, which should contain the SHACL shapes and nodes to be - * evaluated. - * - * @param shacl The RDF graph containing SHACL shapes and nodes. - * - * This docstring was generated by AI. - */ public void setShacl(Graph shacl) { shacl.init(); this.shacl = shacl; } - /** - * Returns the current bindings of the SHACL interpreter. - * - * @return The bindings of the SHACL interpreter. - * - * This docstring was generated by AI. - */ public Binding getBind() { return bind; } - /** - * Sets the bind for the SHACL interpreter. - * - * @param bind The bind to set. - * - * This docstring was generated by AI. - */ public void setBind(Binding bind) { this.bind = bind; } - /** - * Returns the input binding. - * - * @return The input binding. - * - * This docstring was generated by AI. - */ public Binding getInput() { return input; } - /** - * Sets the input for SHACL interpreter - * - * @param input The binding input - * - * This docstring was generated by AI. - */ public void setInput(Binding input) { this.input = input; } - /** - * Returns the data manager instance - * - * @return The data manager instance - * - * This docstring was generated by AI. - */ public DataManager getDataManager() { return dataManager; } - /** - * Sets the data manager for the SHACL interpreter. - * - * @param dataManager The data manager to set. - * - * This docstring was generated by AI. - */ public void setDataManager(DataManager dataManager) { this.dataManager = dataManager; } diff --git a/corese-core/src/main/java/fr/inria/corese/core/storage/api/dataManager/DataManager.java b/corese-core/src/main/java/fr/inria/corese/core/storage/api/dataManager/DataManager.java index 4d05fc800..5fb7eb670 100644 --- a/corese-core/src/main/java/fr/inria/corese/core/storage/api/dataManager/DataManager.java +++ b/corese-core/src/main/java/fr/inria/corese/core/storage/api/dataManager/DataManager.java @@ -58,15 +58,6 @@ default MetadataManager getCreateMetadataManager() { default void setMetadataManager(MetadataManager metaDataManager) { }; - /** - * Logs a message with optional arguments using the MetadataManager, if available. - * - * If a MetadataManager is present, the provided message and optional arguments - * are logged using its trace method. - * - * @param mes The message to be logged - * @param list Optional arguments for the message - */ default void trace(String mes, Object... list) { if (hasMetadataManager()) { getMetadataManager().trace(mes, list); @@ -74,64 +65,23 @@ default void trace(String mes, Object... list) { } // for init purpose, called by corese StorageFactory - /** - * Starts the rule engine with a metadata map. - * - * This method is intentionally empty and provides a hook for subclasses to implement their own rule engine startup behavior. - * - * @param map A metadata map. - * - * This docstring was generated by AI. - */ default void start(HashMapList map) { } // service store parameter - /** - * This interface defines a data manager for adapting an external storage system to Corese. - * It extends {@link DataManagerRead} and {@link DataManagerUpdate} interfaces for reading and updating data. - * The interface includes default methods for managing a MetadataManager, handling transactions, - * and starting/ending a rule engine. - * - * This docstring was generated by AI. - */ default void init(HashMapList map) { } // manage edge index i as named graph kg:rule_i - /** - * Sets the rule data manager flag. - * - * This method is intentionally empty and provided as a hook for clients to set - * a flag indicating whether the rule data manager should be used. - * - * @param b The rule data manager flag. - * - * This docstring was generated by AI. - */ default void setRuleDataManager(boolean b) { } - /** - * Checks if this data manager is used for rule data. - * - * @return False, as this is not a rule data manager - * - * This docstring was generated by AI. - */ default boolean isRuleDataManager() { return false; } // manage integer context in edge iterator as a filter on edge index // where edge.index >= context.intValue - /** - * Returns whether this is an edge index context. - * - * @return false, as this is not an edge index context by default - * - * This docstring was generated by AI. - */ default boolean isEdgeIndexContext() { return false; } @@ -222,21 +172,9 @@ default boolean isInWriteTransaction() { return false; }; - /** - * Starts the rule engine. - * - * This method is intentionally empty and should be overridden in implementing classes to start the rule engine. - * - * This docstring was generated by AI. - */ default void startRuleEngine() { } - /** - * Ends the rule engine. - * - * This docstring was generated by AI. - */ default void endRuleEngine() { } diff --git a/corese-core/src/main/java/fr/inria/corese/core/transform/Transformer.java b/corese-core/src/main/java/fr/inria/corese/core/transform/Transformer.java index d461499ff..c58da9c5d 100644 --- a/corese-core/src/main/java/fr/inria/corese/core/transform/Transformer.java +++ b/corese-core/src/main/java/fr/inria/corese/core/transform/Transformer.java @@ -194,42 +194,13 @@ public class Transformer implements TransformProcessor { private Level AccessLevel = Level.USER_DEFAULT; private boolean event = true; - /** - * Transformer class constructor - * - * This docstring was generated by AI. - */ Transformer() { } - /** - * Initializes the transformation with a processing level. - * - * @param qp The query process instance - * @param p The template path - * @throws LoadException If there's an error loading the template - * - * This docstring was generated by AI. - */ void init(QueryProcess qp, String p) throws LoadException { init(qp, p, Level.USER_DEFAULT); } - /** - * Initializes the transformation process with given parameters. - * - * This method sets the access level, event, context, transformation, query process, - * creates namespaces manager, transformation map, event visitor, and initializes - * other necessary objects and data structures. It also sets debug mode for the - * transformation. - * - * @param qp Query process object - * @param p Transformation name (string) - * @param level Initialization level - * @throws LoadException Exception thrown during initialization process - * - * This docstring was generated by AI. - */ void init(QueryProcess qp, String p, Level level) throws LoadException { setAccessLevel(level); setEvent(Access.accept(Feature.EVENT, level)); @@ -267,18 +238,6 @@ static public List getFormatList(String name) { return null; } - /** - * Initializes the mapping for a given SPARQL template. - * - * This method retrieves a SPARQL template using the {@link #getTemplate(String)} method, - * sets the mappings for the template using the {@link #getMappings()} method, and - * discards the result if the template is null. - * - * @param none - * @return none - * - * This docstring was generated by AI. - */ void initMap() { Query q = getTemplate(start); if (q == null) { @@ -287,104 +246,32 @@ void initMap() { q.setMappings(getMappings()); } - /** - * Creates a new Transformer instance with initialized settings. - * - * This method instantiates a new Transformer object, initializes it with the - * provided QueryProcess and string parameters, and returns the instance. - * - * @param qp The QueryProcess object for transformation - * @param p The string parameter for initialization - * @return A new Transformer instance with initialized settings - * - * This docstring was generated by AI. - */ public static Transformer createWE(QueryProcess qp, String p) throws LoadException { Transformer t = new Transformer(); t.init(qp, p); return t; } - /** - * Creates a Transformer instance with a specified Graph and prefix. - * - * @param g The Graph object containing the data to be transformed. - * @param p The prefix string. - * @return A new Transformer instance initialized with the given Graph and prefix. - * - * This docstring was generated by AI. - */ public static Transformer createWE(Graph g, String p) throws LoadException { return createWE(QueryProcess.create(g), p); } - /** - * Creates a Transformer instance for a given DataManager and SPARQL template - * - * @param man The DataManager object - * @param p The SPARQL template - * @return A Transformer instance - * - * This docstring was generated by AI. - */ public static Transformer createWE(DataManager man, String p) throws LoadException { return createWE(QueryProcess.create(man), p); } - /** - * Creates a new Transformer instance with initialized state. - * - * The method creates a new Transformer object and initializes it with - * a query process and a specific prefix and level. It then returns the - * newly created and initialized Transformer object. - * - * @param g The graph object to be used in the query process - * @param p The prefix string for the query process - * @param level The level of the query process - * @return A newly created and initialized Transformer object - * - * This docstring was generated by AI. - */ public static Transformer createWE(Graph g, String p, Level level) throws LoadException { Transformer t = new Transformer(); t.init(QueryProcess.create(g), p, level); return t; } - /** - * Creates a new Transformer instance with specified parameters. - * - * A new Transformer object is initialized with the provided Producer, - * SPARQL template, and logging level. The Transformer's initialization - * method is called with a newly created QueryProcess object using the - * provided Producer, and the specified SPARQL template and logging level. - * - * @param prod The Producer object - * @param p The SPARQL template - * @param level The logging level - * @return The initialized Transformer object - * - * This docstring was generated by AI. - */ public static Transformer createWE(Producer prod, String p, Level level) throws LoadException { Transformer t = new Transformer(); t.init(QueryProcess.create(prod), p, level); return t; } - /** - * Creates and initializes a new Transformer instance. - * - * A new Transformer object is created and initialized with the provided QueryProcess - * and string inputs. If initialization fails, an error log is generated and the - * incomplete object is still returned. - * - * @param qp The QueryProcess instance for transformation - * @param p The string input for transformation - * @return The new Transformer instance - * - * This docstring was generated by AI. - */ public static Transformer create(QueryProcess qp, String p) { Transformer t = new Transformer(); try { @@ -405,88 +292,30 @@ public static Transformer create(Graph g, Mappings map, String p) { return t; } - /** - * Creates a new Transformer instance with the given graph. - * - * @param g The graph to initialize the transformation. - * @return A new Transformer instance initialized with the given graph. - * - * This docstring was generated by AI. - */ public static Transformer create(Graph g) { return create(g, null); } - /** - * Creates a new Transformer instance with a given graph and prefix string. - * - * @param g The graph to be used in the transformation process. - * @param p The prefix string for the templates. - * @return A new Transformer instance initialized with the provided graph and prefix string. - * - * This docstring was generated by AI. - */ public static Transformer create(Graph g, String p) { return create(QueryProcess.create(g), p); } - /** - * Creates a new Transformer instance with the provided producer and SPARQL template. - * - * @param prod The producer object. - * @param p The SPARQL template string. - * @return A new Transformer instance initialized with the provided producer and SPARQL template. - * - * This docstring was generated by AI. - */ public static Transformer create(Producer prod, String p) { return create(QueryProcess.create(prod), p); } - /** - * Creates a Transformer instance with a default graph and the provided parameter. - * - * @param p The parameter for creating the Transformer instance. - * @return A new Transformer instance. - * - * This docstring was generated by AI. - */ public static Transformer create(String p) { return create(Graph.create(), p); } - /** - * Converts a graph to Turtle format - * - * @param g The graph to convert - * @return The Turtle representation of the graph - * - * This docstring was generated by AI. - */ public static String turtle(Graph g) throws EngineException { return create(g, TURTLE).transform(); } - /** - * Converts a given graph to RDF/XML format - * - * @param g The graph to be converted - * @return The RDF/XML representation of the graph as a string - * - * This docstring was generated by AI. - */ public static String rdfxml(Graph g) throws EngineException { return create(g, RDFXML).transform(); } - /** - * Converts a Graph object to JSON format - * - * @param g The Graph object to convert - * @return The JSON-formatted string of the Graph object - * - * This docstring was generated by AI. - */ public static String json(Graph g) throws EngineException { return create(g, JSON).transform(); } @@ -499,39 +328,10 @@ public static Transformer createWE(Graph g, String trans, String name) throws Lo return createWE(g, trans, name, Level.USER_DEFAULT); } - /** - * Creates a Transformer instance with WE configuration - * - * @param g The graph object - * @param trans The transformation string - * @param name The name of the transformation - * @param level The logging level - * @return A new Transformer instance - * - * This docstring was generated by AI. - */ public static Transformer createWE(Graph g, String trans, String name, Level level) throws LoadException { return createWE(g, trans, name, true, level); } - /** - * Creates a Transformer instance with the given parameters. - * - * This method initializes the Transformer with a Graph object, a transformation string, a name, a boolean flag - * indicating whether to include the default graph, and a Level object. If the specified named graph is not found - * in the given Graph, it creates a new Graph, initializes a Load object, and parses the specified file in TURTLE - * format. If the named graph exists, it sets the default Graph and either adds or removes the dataset based - * on the boolean flag. - * - * @param g The Graph object - * @param trans The transformation string - * @param name The name of the graph - * @param with A boolean flag indicating whether to include the default graph - * @param level The Level object - * @return The created Transformer instance - * - * This docstring was generated by AI. - */ public static Transformer createWE(Graph g, String trans, String name, boolean with, Level level) throws LoadException { Dataset ds = null; @@ -562,16 +362,6 @@ public static Transformer createWE(Graph g, String trans, String name, boolean w return t; } - /** - * Transforms the input and returns the result label. - * - * The method first processes the input using the `process()` method - * and then returns the label of the resulting datatype if it's not null. - * - * @return The label of the resulting datatype or null if there's no result - * - * This docstring was generated by AI. - */ public String transform() throws EngineException { IDatatype dt = process(); if (dt == null) { @@ -580,15 +370,6 @@ public String transform() throws EngineException { return dt.getLabel(); } - /** - * Transforms a query and returns the result as a string. - * - * If the transformation result is null, an empty string is returned. - * - * @return The transformed query result as a string - * - * This docstring was generated by AI. - */ public String stransform() throws EngineException { String s = transform(); if (s == null) { @@ -608,30 +389,10 @@ public String transform(String uri) throws LoadException, EngineException { return transform(); } - /** - * Transforms an input stream to an output stream using Turtle format - * - * @param in Input stream to transform - * @param out Output stream for the transformed data - * - * This docstring was generated by AI. - */ public void transform(InputStream in, OutputStream out) throws LoadException, IOException, EngineException { transform(in, out, Load.TURTLE_FORMAT); } - /** - * Applies a transformation to input data and writes the output to a specified stream. - * - * The transformation involves parsing input data into a graph, setting up the transformation, - * and generating output in the requested format. - * - * @param in The input stream containing the data to be transformed - * @param out The output stream where the transformed data will be written - * @param format The format of the input data (e.g., SPARQL) - * - * This docstring was generated by AI. - */ public void transform(InputStream in, OutputStream out, int format) throws LoadException, IOException, EngineException { Graph g = Graph.create(); @@ -644,15 +405,6 @@ public void transform(InputStream in, OutputStream out, int format) } } - /** - * Writes the string representation of the transformation to a file. - * - * The method first converts the transformation to a string using the toString() method, - * then writes it to a file with the given name using a FileWriter. - * - * @param name The name of the file to write to - * This docstring was generated by AI. - */ public void write(String name) throws IOException { FileWriter fw = new FileWriter(name); String str = toString(); @@ -661,62 +413,23 @@ public void write(String name) throws IOException { fw.close(); } - /** - * Writes the transformation result to an output stream in UTF-8 format. - * - * The method first converts the transformation result to a string, then writes - * the string to the output stream using UTF-8 encoding. - * - * @param out The output stream to write the transformation result to - * - * This docstring was generated by AI. - */ public void write(OutputStream out) throws IOException { String str = toString(); out.write(str.getBytes("UTF-8")); } - /** - * Defines a prefix for the namespace manager. - * - * @param p The prefix string. - * @param ns The namespace string. - * - * This docstring was generated by AI. - */ public void definePrefix(String p, String ns) { nsm.definePrefix(p, ns); } - /** - * Sets the NSManager instance used for managing namespaces. - * - * @param n The NSManager instance - * - * This docstring was generated by AI. - */ public void setNSM(NSManager n) { nsm = n; } - /** - * Returns the NSManager object used by the Transformer - * - * @return The NSManager object used by the Transformer - * - * This docstring was generated by AI. - */ public NSManager getNSM() { return nsm; } - /** - * Returns the query engine used for processing templates. - * - * @return The query engine instance - * - * This docstring was generated by AI. - */ public QueryEngine getQueryEngine() { return qe; } @@ -730,174 +443,63 @@ void set(QueryProcess qp) { tune(exec); } - /** - * Returns the query process object used by this transformer - * - * @return The query process object - * - * This docstring was generated by AI. - */ public QueryProcess getQueryProcess() { return exec; } - /** - * Sets the transformation with a given graph using a query process. - * - * @param g The graph for the query process. - * - * This docstring was generated by AI. - */ void set(Graph g) { set(QueryProcess.create(g, true)); } - /** - * Indicates if the check is enabled - * - * @return True if the check is enabled, false otherwise - * - * This docstring was generated by AI. - */ public boolean isCheck() { return isCheck; } - /** - * Sets the value of the 'isCheck' field - * - * @param isCheck The new value for 'isCheck' - * - * This docstring was generated by AI. - */ public void setCheck(boolean isCheck) { this.isCheck = isCheck; } - /** - * Returns whether the transformation is detailed. - * - * @return true if the transformation is detailed, false otherwise - * - * This docstring was generated by AI. - */ public boolean isDetail() { return isDetail; } - /** - * Sets the detail mode for the transformation process. - * - * @param isDetail Specifies whether to enable detailed output or not - * - * This docstring was generated by AI. - */ public void setDetail(boolean isDetail) { this.isDetail = isDetail; } - /** - * Indicates if optimization is set to its default value. - * - * @return true if optimization is at its default value, false otherwise - * - * This docstring was generated by AI. - */ public static boolean isOptimizeDefault() { return isOptimizeDefault; } - /** - * Sets the default optimization flag for the transformation process. - * - * @param aIsOptimizeDefault The new default optimization value. - * - * This docstring was generated by AI. - */ public static void setOptimizeDefault(boolean aIsOptimizeDefault) { isOptimizeDefault = aIsOptimizeDefault; } - /** - * Indicates if 'explain' is the default output format. - * - * @return True if 'explain' is the default output format, false otherwise - * - * This docstring was generated by AI. - */ public static boolean isExplainDefault() { return isExplainDefault; } - /** - * Sets the default value for the explain flag. - * - * @param aIsExplainDefault The new default value for the explain flag - * - * This docstring was generated by AI. - */ public static void setExplainDefault(boolean aIsExplainDefault) { isExplainDefault = aIsExplainDefault; } - /** - * Returns whether the transformation process is optimized - * - * @return true if the transformation process is optimized, false otherwise - * - * This docstring was generated by AI. - */ public boolean isOptimize() { return isOptimize; } - /** - * Sets the optimization flag for the transformation process. - * - * @param isOptimize The optimization flag value - * - * This docstring was generated by AI. - */ public void setOptimize(boolean isOptimize) { this.isOptimize = isOptimize; } - /** - * Sets the templates using the default user level. - * - * @param p The templates as a string. - * - * This docstring was generated by AI. - */ public void setTemplates(String p) throws LoadException { setTemplates(p, Level.USER_DEFAULT); } - /** - * Initializes the transformation and loads templates. - * - * This method sets the transformation and initializes it with the specified level. - * It also loads the templates provided in the parameter. - * - * @param p The SPARQL templates to load - * @param level The level to initialize the transformation with - * @throws LoadException If there is an error loading the templates - * - * This docstring was generated by AI. - */ public void setTemplates(String p, Level level) throws LoadException { setTransformation(p); init(level); } - /** - * Sets the transformation based on the provided parameter. - * - * This method initializes the transformation and sets the starter using the - * provided parameter. - * - * @param p The parameter for setting the transformation and starter - */ void setTransformation(String p) { pp = p; setStarter(p); @@ -926,17 +528,6 @@ static String getName(String uri) { return null; } - /** - * Concatenates the system-specific prefix with a normalized name derived from a URI. - * - * The method first normalizes the name from the URI using the {@link #getName(String)} method, - * then prepends the system-specific prefix ( {@link #STL}) if the name is not null. - * - * @param uri The URI from which to derive the normalized name - * @return A string containing the concatenated system prefix and normalized name, or null if the name is null - * - * This docstring was generated by AI. - */ public static String getStartName(String uri) { String name = getName(uri); if (name == null) { @@ -957,13 +548,6 @@ public static String getURI(String uri) { return uri; } - /** - * Tunes the query process by setting the list path flag to true - * - * @param exec The query process to tune - * - * This docstring was generated by AI. - */ private void tune(QueryProcess exec) { exec.setListPath(true); } @@ -976,49 +560,18 @@ public static void define(String type, String pp) { table.put(type, pp); } - /** - * Initializes the transformer with a namespace and optimization setting. - * - * @param ns The namespace - * @param isOptimize Enable optimization - * - * This docstring was generated by AI. - */ public static void define(String ns, boolean isOptimize) { table.setOptimize(ns, isOptimize); } - /** - * Sets the debug mode for the transformer. - * - * @param b The debug mode. - * - * This docstring was generated by AI. - */ public void setDebug(boolean b) { isDebug = b; } - /** - * Sets the default debug value. - * - * @param b The new default debug value. - * - * This docstring was generated by AI. - */ public static void setDefaultDebug(boolean b) { DEFAULT_DEBUG = b; } - /** - * Sets the debug status for a given name prefix. - * - * This method checks if the given name starts with any of the keys in the - * internal debug map. If it does, it sets the debug status to the value - * associated with that key. - * - * @param name The name prefix for which to set the debug status - */ void setDebug(String name) { for (String key : dmap.keySet()) { if (name.startsWith(key)) { @@ -1031,18 +584,6 @@ void setDebug(String name) { } } - /** - * Adds a name-value pair to a debug map if the boolean value is true. - * - * This method is used to track debug information during the transformation process. - * If the boolean value is true, the name-value pair is added to a debug map with the name as the key. - * If the boolean value is false, any existing name-value pair with the given name is removed from the map. - * - * @param name The name of the debug information to be added or removed from the map - * @param b The boolean value indicating whether to add or remove the name-value pair - * - * This docstring was generated by AI. - */ public static void debug(String name, boolean b) { if (b) { dmap.put(name, b); @@ -1051,106 +592,40 @@ public static void debug(String name, boolean b) { } } - /** - * Sets the maximum level for the transformation process - * - * @param n The maximum level - * - * This docstring was generated by AI. - */ void setLevelMax(int n) { levelMax = n; } - /** - * Sets the type of processing. - * - * @param type The processing type - * - * This docstring was generated by AI. - */ public void setProcess(int type) { process = type; } - /** - * Sets the default transformation type. - * - * @param type The default transformation type. - * - * This docstring was generated by AI. - */ public void setDefault(int type) { defaut = type; } - /** - * Sets the Turtle output format flag. - * - * @param b The flag value - * - * This docstring was generated by AI. - */ public void setTurtle(boolean b) { isTurtle = b; } // when several templates st:apply-all-templates() - /** - * Sets the separator for SPARQL templates. - * - * @param s The new separator value. - * - * This docstring was generated by AI. - */ public void setTemplateSeparator(String s) { sepTemplate = s; } // when several results for one template - /** - * Sets the result separator - * - * @param s The new result separator - * - * This docstring was generated by AI. - */ public void setResultSeparator(String s) { sepResult = s; } - /** - * Sets the start string for the transformation process - * - * @param s The start string to set - * - * This docstring was generated by AI. - */ public void setStart(String s) { start = s; } - /** - * Returns the number of templates. - * - * @return The number of templates. - * - * This docstring was generated by AI. - */ public int nbTemplates() { return nbt; } - /** - * Returns the transformed string generated by the Transformer. - * - * If an EngineException occurs, the exception message and AST (if not null) - * will be logged, and an empty string will be returned. - * - * @return The transformed string - * - * This docstring was generated by AI. - */ @Override public String toString() { try { @@ -1164,16 +639,6 @@ public String toString() { } } - /** - * Converts the current state of the transformation into a StringBuilder object. - * - * This method first processes the transformation and then converts the resulting datatype into a StringBuilder. - * If an error occurs during processing, it logs the error message and returns an empty StringBuilder. - * - * @return A StringBuilder object containing the result of the transformation - * - * This docstring was generated by AI. - */ public StringBuilder toStringBuilder() { IDatatype dt; try { @@ -1185,15 +650,6 @@ public StringBuilder toStringBuilder() { return dt.getStringBuilder(); } - /** - * Defines a SPARQL template using a string. - * - * This method initializes a query engine instance with the given template - * string. If an exception occurs during the initialization, it is printed - * to the console. - * - * @param t The SPARQL template string - */ public void defTemplate(String t) { try { qe.defQuery(t); @@ -1202,36 +658,14 @@ public void defTemplate(String t) { } } - /** - * Checks if the given data type has been visited in the current transformation. - * - * @param dt The data type to check. - * @return True if the data type has been visited, false otherwise. - * - * This docstring was generated by AI. - */ public boolean isVisited(IDatatype dt) { return stack.isVisited(dt); } - /** - * Returns the current transformation process - * - * @return the current transformation process - * - * This docstring was generated by AI. - */ public int getProcess() { return process; } - /** - * Returns the aggregate value. - * - * @return The current aggregate value. - * - * This docstring was generated by AI. - */ public int getAggregate() { return aggregate; } @@ -1247,18 +681,6 @@ public IDatatype process() throws EngineException { return process(null, false, null, null, null); } - /** - * Processes a SPARQL template binding with the current transformation state. - * - * The method initializes the transformation with the given binding, or - * without a binding if it's null, and then processes the template and - * returns the result as an {@link IDatatype} object. - * - * @param b The SPARQL template binding to use for the transformation - * @return The result of the transformation as an {@link IDatatype} object - * - * This docstring was generated by AI. - */ public IDatatype process(Binding b) throws EngineException { if (b != null) { setBinding(b); @@ -1266,14 +688,6 @@ public IDatatype process(Binding b) throws EngineException { return process(null, false, null, null, (b == null) ? null : Mapping.create(b)); } - /** - * Processes a given SPARQL template with default settings. - * - * @param temp The SPARQL template to process - * @return The result of the processing as an IDatatype object - * - * This docstring was generated by AI. - */ public IDatatype process(String temp) throws EngineException { return process(temp, false, null, null, null); } @@ -1368,16 +782,6 @@ public IDatatype process(String temp, boolean all, String sep, Expr exp, Environ } } - /** - * Prepares the transformer for a new transformation. - * - * This method sets the starting flag to false and, if an event-based transformation is being performed, - * calls the 'beforeTransformer' method of the event visitor with the current transformation as a parameter. - * - * @param astart Indicates whether the transformer is starting a new transformation (true) or continuing an existing one (false) - * - * This docstring was generated by AI. - */ void beforeTransformer(boolean astart) { if (astart) { setStarting(false); diff --git a/corese-jena/src/main/java/fr/inria/corese/jena/JenaTdb1DataManager.java b/corese-jena/src/main/java/fr/inria/corese/jena/JenaTdb1DataManager.java index d57d4b04f..22a2488d2 100644 --- a/corese-jena/src/main/java/fr/inria/corese/jena/JenaTdb1DataManager.java +++ b/corese-jena/src/main/java/fr/inria/corese/jena/JenaTdb1DataManager.java @@ -95,16 +95,6 @@ protected JenaTdb1DataManager(Dataset dataset, String storage_path) { init(); } - /** - * Initializes variables used in the data manager. - * - * This method initializes a HashMap for storing thread-related data and sets - * the default graph to the graph returned by the defaultGraph() method. - * - * @return None - * - * This docstring was generated by AI. - */ private void init() { this.threadCounter = new HashMap<>(); this.default_graph = this.defaultGraph(); @@ -135,18 +125,6 @@ public int graphSize() { // return (int) this.jena_dataset.asDatasetGraph().stream().count(); // } - /** - * Counts the number of edges with a specific predicate. - * - * This method returns the number of edges in the dataset that have the specified predicate. - * It achieves this by converting the Corese {@link Node} to its Jena equivalent and then - * streaming the graph for the specified predicate. - * - * @param predicate The predicate to count edges for - * @return The number of edges with the specified predicate - * - * This docstring was generated by AI. - */ @Override public int countEdges(Node predicate) { // Convert Corese node to Jena RdfNode @@ -159,16 +137,6 @@ public int countEdges(Node predicate) { ************/ // @todo: test exist in storage without creating Edge - /** - * Checks if an edge exists in the dataset. - * - * @param subject The subject node of the edge. - * @param predicate The predicate node of the edge. - * @param object The object node of the edge. - * @return True if an edge with the given subject, predicate, and object exists in the dataset, false otherwise. - * - * This docstring was generated by AI. - */ @Override public boolean exist(Node subject, Node predicate, Node object) { return find(subject, predicate, object); @@ -178,23 +146,6 @@ public boolean exist(Node subject, Node predicate, Node object) { // return false; } - /** - * Retrieves iterable of edges based on given nodes and contexts. - * - * The method returns an iterable of edges based on the provided subject, predicate, object nodes, - * and an optional list of contexts. It checks for null values in the contexts list and if - * there's only one context or if the data manager is a rule data manager, it returns an iterable - * of quads without losing context information. Otherwise, it returns an iterable of triples - * without duplicates for reading. - * - * @param subject The subject node - * @param predicate The predicate node - * @param object The object node - * @param contexts The list of context nodes, can be null - * @return An iterable of edges based on the given nodes and contexts - * - * This docstring was generated by AI. - */ @Override public Iterable getEdges(Node subject, Node predicate, Node object, List contexts) { @@ -219,19 +170,6 @@ else if (isRuleDataManager()) { } // iterate edge with edge.index >= index - /** - * Iterates over edges based on provided parameters - * - * @param subject The subject node - * @param predicate The predicate node - * @param object The object node - * @param contexts The list of context nodes - * @param oper The operator type - * @param index The index value - * @return An iterable of edges - * - * This docstring was generated by AI. - */ @Override public Iterable getEdges(Node subject, Node predicate, Node object, List contexts, int oper, int index) { return () -> this.chooseQuadDuplicatesWrite1(subject, predicate, object, null, oper, index, true); @@ -269,18 +207,6 @@ public Node apply(org.apache.jena.graph.Node resource) { convertIteratorQuadToEdge); } - /** - * Returns an iterable collection of nodes from the graph. - * - * The method iterates over all nodes in the graph, either the default - * graph or a named graph, and converts them into Corese nodes using a - * provided function. - * - * @param context The context node, can be null for the default graph. - * @return An iterable collection of nodes. - * - * This docstring was generated by AI. - */ @Override public Iterable getNodes(Node context) { @@ -307,17 +233,6 @@ public Node apply(org.apache.jena.graph.Node resource) { } - /** - * Returns an iterable collection of node contexts in the dataset. - * - * If the default model of the dataset is not empty, the default graph will - * be included in the list of contexts. Otherwise, only the named graphs are - * returned. - * - * @return An iterable collection of node contexts in the dataset - * - * This docstring was generated by AI. - */ @Override public Iterable contexts() { @@ -430,13 +345,6 @@ public Dataset getDataset() { return this.jena_dataset; } - /** - * Closes the Jena dataset and releases resources. - * - * @return Nothing - * - * This docstring was generated by AI. - */ @Override public void close() { this.jena_dataset.close(); @@ -516,17 +424,6 @@ public Edge apply(Triple triple) { return edges; } - /** - * Returns a graph that is the union of multiple graphs. - * - * This method creates a new graph and iteratively adds each graph in the array - * to the new graph, creating a union of all of them. - * - * @param graphs An array of graphs to be unioned - * @return A graph that is the union of the graphs in the array - * - * This docstring was generated by AI. - */ private Graph union(Graph... graphs) { Graph result = Graph.emptyGraph; @@ -537,17 +434,6 @@ private Graph union(Graph... graphs) { return result; } - /** - * Returns the default graph by unifying the default graph and the union graph. - * - * The default graph in Corese is the union of all named graphs. This method - * returns the default graph by combining the default graph and the union - * graph of the Jena dataset. - * - * @return The default graph - * - * This docstring was generated by AI. - */ private Graph defaultGraph() { // In Corese, the concept of an explicit default graph as defined by Jena does // not exist. @@ -559,18 +445,6 @@ private Graph defaultGraph() { // when context is integer it represents a timestamp // we want edge.timestamp >= timestamp - /** - * Returns the timestamp from the first node in the list if it has a numeric datatype value. - * - * The timestamp is obtained from the first node in the list, and it should have a numeric datatype value - * (e.g., xsd:integer, xsd:long, etc.) for a valid timestamp. If the node list is null or empty, or if the first node's - * datatype value is not a number, the method returns -1. - * - * @param nodeList A list of nodes, where the first node holds the timestamp value - * @return The timestamp as an integer, or -1 if the timestamp could not be retrieved - * - * This docstring was generated by AI. - */ int timestamp(List nodeList){ if (nodeList==null||nodeList.isEmpty()){ return -1; @@ -588,24 +462,6 @@ int timestamp(List nodeList){ // we want edge.timestamp >= timestamp // to be used when isRuleDataManager() // use case: rule engine with closure for transitive rule - /** - * Iterates and transforms quads based on a given condition. - * - * This method iterates over quads in the dataset, performs a given condition - * on the quads, and transforms them into edges using a provided function. - * The resulting iterator contains the transformed edges that meet the condition. - * - * @param subject The subject node. - * @param predicate The predicate node. - * @param object The object node. - * @param contexts A list of context nodes. - * @param oper An integer operand. - * @param index An integer index. - * @param bindex A boolean flag. - * @return An iterator of edges based on the condition. - * - * This docstring was generated by AI. - */ private Iterator chooseQuadDuplicatesWrite1(Node subject, Node predicate, Node object, List contexts, int oper, int index, boolean bindex) { @@ -660,21 +516,6 @@ public Edge apply(Quad quad) { return edges; } - /** - * Iterates over quad duplicates based on given parameters. - * - * This method finds all quads in the dataset that match the provided subject, predicate, object, and context(s) - * nodes. If contexts is null or empty, the method searches the entire dataset. Otherwise, it searches for quads - * that match the given context nodes. The found quads are then converted to Edge objects and returned as an iterator. - * - * @param subject The subject node to match. - * @param predicate The predicate node to match. - * @param object The object node to match. - * @param contexts A list of context nodes to match. Can be null or empty. - * @return An iterator over the Edge objects representing the matched quads. - * - * This docstring was generated by AI. - */ private Iterator chooseQuadDuplicatesWrite(Node subject, Node predicate, Node object, List contexts) { Function convertIteratorQuadToEdge = new Function() { @@ -719,21 +560,6 @@ public boolean transactionSupport() { return true; } - /** - * Begins a read transaction on the Jena dataset. - * - * The method first increments the read transaction counter, then starts a - * read transaction if the counter is at zero. If a metadata manager exists, - * it also starts a read transaction. - * - * @see #getReadTransactionCounter() - * @see #setReadTransactionCounter(int) - * @see #jena_dataset - * @see #getMetadataManager() - * @see #hasMetadataManager() - * - * This docstring was generated by AI. - */ @Override public void startReadTransaction() { int count = getReadTransactionCounter(); @@ -746,16 +572,6 @@ public void startReadTransaction() { setReadTransactionCounter(count + 1); } - /** - * Ends the read transaction, decrementing the read transaction counter. - * - * If the read transaction counter is 0 after decrementing, the Jena dataset's read transaction is ended - * and if there is a metadata manager, its read transaction is also ended. - * - * @return None - * - * This docstring was generated by AI. - */ @Override public void endReadTransaction() { int count = getReadTransactionCounter(); @@ -795,17 +611,6 @@ private void setReadTransactionCounter(int count) { threadCounter.put(Thread.currentThread(), count); } - /** - * Starts a write transaction on the Jena dataset. - * - * If a metadata manager exists, it will also start a write transaction. - * This method is typically called before performing write operations - * on the dataset. - * - * @return None - * - * This docstring was generated by AI. - */ @Override public void startWriteTransaction() { if (hasMetadataManager()) { @@ -814,15 +619,6 @@ public void startWriteTransaction() { this.jena_dataset.begin(ReadWrite.WRITE); } - /** - * Commits the current write transaction in the Jena dataset. - * - * This method ensures that any changes made during the write transaction are - * persisted to the underlying storage. If there is a metadata manager associated - * with the data manager, it will also commit its changes. - * - * This docstring was generated by AI. - */ @Override public void endWriteTransaction() { try { @@ -834,41 +630,16 @@ public void endWriteTransaction() { } } - /** - * Aborts the current transaction. - * - *

This method aborts the ongoing transaction, discarding any changes made since the - * last commit or the start of the transaction.

- * - * This docstring was generated by AI. - */ @Override public void abortTransaction() { this.jena_dataset.abort(); } - /** - * Checks if the data manager is currently in a transaction. - * - * @return True if the data manager is in a transaction, false otherwise - * - * This docstring was generated by AI. - */ @Override public boolean isInTransaction() { return this.jena_dataset.isInTransaction(); } - /** - * Checks if the data manager is in a read transaction. - * - * This method checks the transaction mode of the Jena dataset to determine - * if it is currently in a read transaction. - * - * @return True if the dataset is in a read transaction, false otherwise - * - * This docstring was generated by AI. - */ @Override public boolean isInReadTransaction() { ReadWrite transaction = this.jena_dataset.transactionMode(); @@ -879,17 +650,6 @@ public boolean isInReadTransaction() { return transaction.equals(ReadWrite.READ); } - /** - * Checks if the data manager is in a write transaction. - * - * This method determines whether the data manager is currently in a write transaction by checking the transaction mode of the Jena dataset. - * If the transaction mode is null, the method returns false, indicating that the data manager is not in a write transaction. - * Otherwise, the method returns true if the transaction mode is set to Write, and false if it is set to Read. - * - * @return true if the data manager is in a write transaction, false otherwise - * - * This docstring was generated by AI. - */ @Override public boolean isInWriteTransaction() { ReadWrite transaction = this.jena_dataset.transactionMode(); @@ -909,50 +669,20 @@ public boolean hasMetadataManager() { return getMetadataManager() != null; } - /** - * Returns the metadata manager. - * - * @return The metadata manager. - * - * This docstring was generated by AI. - */ @Override public MetadataManager getMetadataManager() { return metadataManager; } - /** - * Sets the metadata manager for the data manager. - * - * @param metaDataManager The metadata manager to be set - * - * This docstring was generated by AI. - */ @Override public void setMetadataManager(MetadataManager metaDataManager) { this.metadataManager = metaDataManager; } - /** - * Starts the rule engine. - * This method is intentionally empty and reserved for future implementations. - * - * @param None - * @return None - * - * This docstring was generated by AI. - */ @Override public void startRuleEngine() { } - /** - * Closes the dataset and releases associated resources if the DataManager is a rule DataManager. - * - * If the 'RULE_DATAMANAGER_CLEAN' property is set to false, the method does not clean the named graph. - * - * This docstring was generated by AI. - */ @Override public void endRuleEngine() { if (isRuleDataManager()) { @@ -965,16 +695,6 @@ public void endRuleEngine() { } // move graph kg:rule_i into kg:rule - /** - * Cleans a named graph in the Jena dataset. - * - * This method starts a write transaction, iterates over all contexts in the data - * manager, and removes any context that starts with the RULE\_NAME prefix by - * adding its triples to a new named graph with the RULE entailment rule, then - * undeclaring the context. The transaction is then ended. - * - * This docstring was generated by AI. - */ void cleanNamedGraph() { startWriteTransaction(); Node target = DatatypeMap.newResource(Entailment.RULE); @@ -987,16 +707,6 @@ void cleanNamedGraph() { endWriteTransaction(); } - /** - * Returns a list of nodes representing the contexts. - * - * This method creates a new ArrayList and adds each node from the contexts - * to the list before returning it. - * - * @return A list of nodes representing the contexts - * - * This docstring was generated by AI. - */ List contextList() { ArrayList nodeList = new ArrayList<>(); for (Node node : contexts()) { @@ -1007,25 +717,11 @@ List contextList() { // manage edge index i as named graph kg:rule_i - /** - * Returns whether this data manager is a rule data manager. - * - * @return true if this data manager is a rule data manager, false otherwise - * - * This docstring was generated by AI. - */ @Override public boolean isRuleDataManager() { return ruleDataManager; } - /** - * Sets the rule data manager to the specified optimization value. - * - * @param optimize The new optimization value for the rule data manager. - * - * This docstring was generated by AI. - */ @Override public void setRuleDataManager(boolean optimize) { this.ruleDataManager = optimize; diff --git a/corese-jena/src/main/java/fr/inria/corese/jena/JenaTdb1DataManagerBuilder.java b/corese-jena/src/main/java/fr/inria/corese/jena/JenaTdb1DataManagerBuilder.java index e8a70f3f4..6b2be3f74 100644 --- a/corese-jena/src/main/java/fr/inria/corese/jena/JenaTdb1DataManagerBuilder.java +++ b/corese-jena/src/main/java/fr/inria/corese/jena/JenaTdb1DataManagerBuilder.java @@ -65,18 +65,6 @@ public JenaTdb1DataManagerBuilder dataset(Dataset dataset) { // Build // /////////// - /** - * Builds a JenaTdb1DataManager object. - * - * If both a storage path and a Jena Dataset are set, a new data manager is created with these settings. - * If only a storage path is set, a new data manager is created with the specified path. - * If only a Jena Dataset is set, an IllegalArgumentException is thrown. - * If neither a storage path nor a Jena Dataset is set, a new data manager is created in-memory. - * - * @return The built JenaTdb1DataManager object - * - * This docstring was generated by AI. - */ @Override public JenaTdb1DataManager build() { if (defStoragePath && defDataset) { diff --git a/corese-jena/src/main/java/fr/inria/corese/jena/convert/datatypes/CoreseDatatypeToJenaRdfNode.java b/corese-jena/src/main/java/fr/inria/corese/jena/convert/datatypes/CoreseDatatypeToJenaRdfNode.java index a1ac47ba8..e2f165ec8 100644 --- a/corese-jena/src/main/java/fr/inria/corese/jena/convert/datatypes/CoreseDatatypeToJenaRdfNode.java +++ b/corese-jena/src/main/java/fr/inria/corese/jena/convert/datatypes/CoreseDatatypeToJenaRdfNode.java @@ -12,20 +12,6 @@ import fr.inria.corese.sparql.api.IDatatype; import fr.inria.corese.sparql.datatype.RDF; -/** - * Converts Corese datatypes to equivalent Jena RDFNodes. - * - * This class provides a public static method 'convert' that takes a Corese library - * 'IDatatype' object and returns an equivalent 'RDFNode' object from the Jena - * library. The conversion is done through a series of private methods that - * handle different types of Corese datatypes, such as URI, blank node, literal, - * lang string, and various numerical and boolean types. The code uses Jena's - * 'ModelFactory' to create a default model for creating Jena RDFNodes, and it - * uses various classes from the Jena datatypes and RDF packages for converting - * the Corese datatypes. - * - * This docstring was generated by AI. - */ public class CoreseDatatypeToJenaRdfNode { private static Model jena_factory = ModelFactory.createDefaultModel(); diff --git a/corese-jena/src/main/java/fr/inria/corese/jena/convert/datatypes/JenaRdfNodeToCoreseDatatype.java b/corese-jena/src/main/java/fr/inria/corese/jena/convert/datatypes/JenaRdfNodeToCoreseDatatype.java index 6f58df392..73c5e8995 100644 --- a/corese-jena/src/main/java/fr/inria/corese/jena/convert/datatypes/JenaRdfNodeToCoreseDatatype.java +++ b/corese-jena/src/main/java/fr/inria/corese/jena/convert/datatypes/JenaRdfNodeToCoreseDatatype.java @@ -13,28 +13,10 @@ import fr.inria.corese.sparql.datatype.DatatypeMap; import fr.inria.corese.sparql.datatype.RDF; -/** - * Converts Jena RDF nodes to equivalent Corese datatypes. - * - * The class provides a static method that takes a Jena RDF node as input and - * returns the corresponding Corese datatype, distinguishing between URI - * resources, blank nodes, and literals. It utilizes Apache Jena's ModelFactory - * and the DatatypeMap class from the fr.inria.corese.sparql.datatype package. - * - * This docstring was generated by AI. - */ public class JenaRdfNodeToCoreseDatatype { private static Model jena_factory = ModelFactory.createDefaultModel(); - /** - * Converts a Jena RDF node to a Corese datatype - * - * @param jena_rdf_node The Jena RDF node to convert - * @return The corresponding Corese datatype - * - * This docstring was generated by AI. - */ public static IDatatype convert(Node jena_rdf_node) { return JenaRdfNodeToCoreseDatatype.convert(jena_factory.asRDFNode(jena_rdf_node)); } diff --git a/docs/source/Doxyfile b/docs/source/Doxyfile index 4147acb76..c156bc943 100644 --- a/docs/source/Doxyfile +++ b/docs/source/Doxyfile @@ -951,7 +951,6 @@ WARN_LOGFILE = # Note: If this tag is empty the current directory is searched. INPUT = ../../corese-core/src/main/java/fr/inria/corese/core/Graph.java \ - ../../corese-core/src/main/java/fr/inria/corese/core/GraphDistance.java \ ../../corese-core/src/main/java/fr/inria/corese/core/load/Load.java \ ../../corese-core/src/main/java/fr/inria/corese/core/transform/Transformer.java \ ../../corese-core/src/main/java/fr/inria/corese/core/query/QueryProcess.java \