/** * Writes all of the edge comments to the writer to create the comment file and whether a datamap * entry is generated or not. Each line represents an entry of the datamap. Each line contains a 1 * or a 0 that signifies if generates or not and is followed by a comment if there is one. */ public void writeComments(Writer commentWriter) throws IOException { // Write out all the edge comments Enumeration e = rep.edges(); while (e.hasMoreElements()) { NamedEdge edge = (NamedEdge) e.nextElement(); if (edge.isGenerated()) { commentWriter.write("1 " + edge.getComment() + '\n'); } else commentWriter.write("0 " + edge.getComment() + '\n'); } }
/** * Adds a triple to working memory Also sets a comment to the edge that the triple creates. This * comment is read in by the SoarWorkingMemoryReader when the .dm file is loaded */ public void addTriple( SoarVertex v0, String attribute, SoarVertex v1, int generated, String comment) { if (!v0.allowsEmanatingEdges()) throw new IllegalArgumentException("The First SoarVertex does not allow emanating edges"); NamedEdge ne = new NamedEdge(v0, v1, attribute); if (comment.length() > 1) ne.setComment(comment); if (generated == 1) ne.setAsGenerated(); rep.addEdge(ne); notifyListenersOfAdd(ne); }
/** * returns a string to represent this object, it is a combination of the file, line number and the * message * * @return a string that represents this object */ public String toString() { if (!isDataMapObject()) { if (msgEnough) return message; else return node.getUniqueName() + "(" + lineNumber + "): " + message; } else { return dataMapName + ": " + edge.toString(); } }
/** * Adds a triple to working memory Also denotes that this triple was created by the automatic * DataMap generator. This will cause the dataMap entry of this triple to show up as colored text * until the entry is validated by the user as acceptable. */ public void addTriple( SoarVertex v0, String attribute, SoarVertex v1, boolean generated, OperatorNode current, int lineNumber) { if (!v0.allowsEmanatingEdges()) throw new IllegalArgumentException("The First SoarVertex does not allow emanating edges"); NamedEdge ne = new NamedEdge(v0, v1, attribute); if (generated) { ne.setAsGenerated(); ne.setNode(current); ne.setLineNumber(lineNumber); } rep.addEdge(ne); notifyListenersOfAdd(ne); }
/** * Writes out information for the datamap file (.dm file) .dm datamap file is in the format of: * number of vertices <br> * write out all vertices: |vertex type| |vertex id int| * |number of enumerations| |enumeration strings .....| <br> * number of edges <br> * write out all edges: | left vertex | |name of edge| * |right vertex| * * @param graphWriter the file to be written too - .dm file */ public void write(Writer graphWriter) throws IOException { // Write out the number of Vertices graphWriter.write("" + rep.numberOfVertices() + '\n'); // Write out all the vertices Enumeration v = rep.vertices(); while (v.hasMoreElements()) { SoarVertex vertex = (SoarVertex) v.nextElement(); if (vertex != null) vertex.write(graphWriter); } // Write out the number of edges graphWriter.write("" + rep.numberOfEdges() + '\n'); // Write out all the edges Enumeration e = rep.edges(); while (e.hasMoreElements()) { NamedEdge edge = (NamedEdge) e.nextElement(); edge.write(graphWriter); } }