コード例 #1
0
  /** Checks if an arrowpoint is allowed by background knowledge. */
  public static boolean isArrowpointAllowed1(Node from, Node to, Knowledge knowledge) {
    if (knowledge == null) {
      return true;
    }

    return !knowledge.edgeRequired(to.toString(), from.toString())
        && !knowledge.edgeForbidden(from.toString(), to.toString());
  }
コード例 #2
0
ファイル: Graph.java プロジェクト: BenEskildsen/Charting_App
 public void removeNode(Node n) {
   for (Node v : nodes) {
     if (v.toString().equals(n.toString())) {
       nodes.remove(v);
       return;
     }
   }
   // System.out.println("Node not found!!");
 }
コード例 #3
0
ファイル: RegNode.java プロジェクト: fgravil/Java
 /*@ ensures \result != "";*/
 public String toString() {
   return leftNode.toString(Node.Placement.RIGHT)
       + "("
       + key.toString()
       + ","
       + obj.toString()
       + ")"
       + rightNode.toString(Node.Placement.LEFT);
 }
コード例 #4
0
ファイル: Tuple.java プロジェクト: cccrystalyy/RingStar_new
 public String toString() {
   return n1.toString()
       + "\n"
       + n2.toString()
       + "\n"
       + insert.toString()
       + "\n"
       + " cost: "
       + this.cost;
 }
コード例 #5
0
ファイル: BSTree.java プロジェクト: Karol-Regula/MKS22X
 public String toString() {
   if (left == null && right == null) {
     return data + " " + "_" + " " + "_";
   } else if (left == null) {
     return data + " " + "_" + " " + right.toString();
   } else if (right == null) {
     return data + " " + left.toString() + " " + "_";
   } else {
     return data + " " + left.toString() + " " + right.toString();
   }
 }
コード例 #6
0
 /** Recursively prints a node and its children as a string. */
 @Override
 public String toString() {
   return "[v:"
       + value
       + ",b:"
       + balance
       + ",l:"
       + (left == null ? "#" : left.toString())
       + ",r:"
       + (right == null ? "#" : right.toString())
       + "]";
 }
コード例 #7
0
  public static boolean isArrowpointAllowed2(Node from, Node to, Knowledge knowledge, Graph graph) {
    if (knowledge == null) {
      return true;
    }

    if (!graph.getNodesInTo(to, Endpoint.ARROW).isEmpty()) {
      return false;
    }

    return !knowledge.edgeRequired(to.toString(), from.toString())
        && !knowledge.edgeForbidden(from.toString(), to.toString());
  }
コード例 #8
0
ファイル: test.java プロジェクト: randyqin/PersonalityProfile
 public static void main(String[] args) throws Exception {
   Node node = new Node();
   node.getInfo("smallville");
   System.out.println(node.toString());
   node.getAdjacentNodes();
   System.out.println("=========================");
   System.out.println(node.toString());
   System.out.println("=========== nodeX ==============");
   Node nodeX = node.AdjacentNodes.get(0);
   nodeX.getAdjacentNodes();
   System.out.println(nodeX.toString());
 }
コード例 #9
0
ファイル: BSTree.java プロジェクト: nicolecheng/MKS22X
 public String toString() {
   String s = " " + data;
   if (left == null) {
     s += " _";
   } else {
     s += left.toString();
   }
   if (right == null) {
     s += " _";
   } else {
     s += right.toString();
   }
   return s;
 }
コード例 #10
0
ファイル: Node.java プロジェクト: AdnanLapendic/homeworks
 /** toString method */
 public String toString() {
   if (next == null) {
     return value + "";
   } else {
     return value + ", " + next.toString();
   }
 }
コード例 #11
0
ファイル: Tree.java プロジェクト: Nelspike/UniversityStuff
  public String toString() {
    String tree = "";

    tree += startingNode.toString();

    return tree;
  }
コード例 #12
0
ファイル: LinkedList.java プロジェクト: zhenhuafeng/JavaLand
 /** Returns a String representation of the list. */
 public void display() {
   Node currentNode = head;
   while (currentNode != null) {
     System.out.println(currentNode.toString());
     currentNode = currentNode.next;
   }
 }
コード例 #13
0
 private String toString(Node n, int depth, String pre) {
   if (n == null) return "";
   String retString = "";
   for (int d = 0; d < depth; d++) retString += "  ";
   retString += pre + n.toString() + "\n";
   return retString + toString(n.left, depth + 1, "L: ") + toString(n.right, depth + 1, "R: ");
 }
コード例 #14
0
  /**
   * Returns a URI that represents the Node.
   *
   * @param node the node representing the URI.
   * @throws GraphException
   * @return URI
   */
  protected String getURI(Node node) throws GraphException {

    // value to be returned
    String uri = null;

    // determine type of subject node and create uri from it
    if (node != null) {

      try {

        if (node instanceof URIReference) {
          uri = ((URIReference) node).getURI().toString();
        } else if (node instanceof BlankNode) {
          uri = new URI("#" + ((BlankNode) node).toString()).toString();
        } else {
          uri = node.toString();
        }
      } catch (URISyntaxException uriException) {
        throw new GraphException("Could not get URI for Node: " + node + ".", uriException);
      }
    } else {
      throw new GraphException("Could not get URI for Node: " + node + ". Node is null.");
    }

    // return the URI with any namespaces replaced with prefixes
    return this.replaceNamespace(uri);
  }
コード例 #15
0
  /**
   * Returns a String representation of an ObjectNode. Object values do not have to be escaped.
   *
   * @param node Node
   * @throws GraphException
   * @return String
   */
  protected String getNodeString(Node node) throws GraphException {

    // value to be returned
    String object = null;

    // determine type of subject node and create uri from it
    if (node != null) {

      try {

        if (node instanceof URIReference) {
          object = ((URIReference) node).getURI().toString();
        } else if (node instanceof BlankNode) {
          object = new URI("#" + ((BlankNode) node).toString()).toString();
        } else if (node instanceof Literal) {
          object = ((Literal) node).getLexicalForm();
        } else {
          object = node.toString();
        }
      } catch (URISyntaxException uriException) {
        throw new GraphException(
            "Could not get String for ObjectNode: " + node + ".", uriException);
      }
    } else {
      throw new GraphException(
          "Could not get String for ObjectNode: " + node + ". ObjectNode is null.");
    }

    return object;
  }
コード例 #16
0
ファイル: IndividualImpl.java プロジェクト: hmottestad/jena
 @Override
 public EnhNode wrap(Node n, EnhGraph eg) {
   if (canWrap(n, eg)) {
     return new IndividualImpl(n, eg);
   } else {
     throw new ConversionException("Cannot convert node " + n.toString() + " to Individual");
   }
 }
コード例 #17
0
ファイル: BSTree.java プロジェクト: nicolecheng/MKS22X
 public String toString() {
   String s = "";
   if (root == null) {
     return "";
   } else {
     return root.toString();
   }
 }
コード例 #18
0
ファイル: IntStack.java プロジェクト: pdvrieze/ProcessManager
    /**
     * A string representation of the node.
     *
     * @return A string representation
     */
    @Override
    public String toString() {
      if (mNext != null) {
        return mNext.toString() + ", " + Integer.toString(mValue);
      }

      return Integer.toString(mValue);
    }
コード例 #19
0
 @Override
 public String toString() {
   String result = "";
   for (Node child : children) {
     result += "(" + child.toString() + ")+";
   }
   return result.substring(0, result.length() - 1); // remove trailing +
 }
コード例 #20
0
 public String getName() {
   // TODO does this make sense?
   Node child = jjtGetChild(0);
   if (child instanceof ASTVar) {
     return ((ASTVar) child).getName();
   } else {
     return child.toString();
   }
 }
コード例 #21
0
 @Override
 public String toString() {
   StringBuilder res = new StringBuilder();
   for (Node n : versions) {
     if (n == null) res.append(String.format("[]"));
     else res.append(String.format("[%s]\n", n.toString()));
   }
   return res.toString();
 }
コード例 #22
0
 public void visit(Node node) {
   System.out.println(indentString() + node.toString());
   indent += 1;
   int count = node.jjtGetNumChildren();
   for (int i = 0; i < count; i++) {
     Node child = node.jjtGetChild(i);
     visit(child);
   }
   indent -= 1;
 }
コード例 #23
0
 @Override
 public String toString() {
   StringBuilder builder = new StringBuilder();
   builder.append("Model [dimensions=");
   builder.append(dimensions);
   builder.append(", root\n");
   builder.append(StringUtil.indent(root.toString(), " "));
   builder.append("\n]");
   return builder.toString();
 }
コード例 #24
0
 @Override
 public Node getChild(String name) {
   Node child = null;
   for (Node n : this.children) {
     if (n.toString().equals(name)) {
       child = n;
       break;
     }
   }
   return child;
 }
コード例 #25
0
ファイル: Graph.java プロジェクト: sormaz/implanner-fx
  /**
   * Executes the "Printout" command
   *
   * @param commandList the command along with the necessary parameters specified by the user
   */
  public void executePrintout(ArrayList<String> commandList) throws Exception {
    if (commandList.size() != 2 && commandList.size() != 3) {
      throw new Exception(
          "\nInvalid arguments, code not executed"
              + "\nCorrect Syntax: \nprintout node_name"
              + "\nprintout node1_name node2_name\n");
    }

    if (commandList.size() == 2) {
      Node node = getNode(commandList.get(1));

      System.out.println(node.toString());

      // Also printout all the arcs the node is connected to
      // I kept it because it helped in debugging
      for (UndirectedArc undirArc : node.getArcs()) {
        System.out.println(undirArc.toString());
      }
      for (DirectedArc dirArc : node.getInArcs()) {
        System.out.println(dirArc.toString());
      }
      for (DirectedArc dirArc : node.getOutArcs()) {
        System.out.println(dirArc.toString());
      }

    } else {
      Node node1 = getNode(commandList.get(1));
      Node node2 = getNode(commandList.get(2));
      Boolean arcExists = false;

      try {
        System.out.println(getDirArc(node1, node2).toString());
        arcExists = true;
      } catch (Exception e) {

      }
      try {
        System.out.println(getDirArc(node2, node1).toString());
        arcExists = true;
      } catch (Exception e) {

      }
      try {
        System.out.println(getUndirArc(node1, node2).toString());
        arcExists = true;
      } catch (Exception e) {

      }

      if (!arcExists) {
        System.out.println("No arcs exist between node");
      }
    }
  }
コード例 #26
0
 @Override
 public String toString() {
   StringBuilder builder = new StringBuilder();
   builder.append("Node [splitter=");
   builder.append(splitter);
   builder.append(", count=");
   builder.append(count);
   builder.append(", bounds=");
   builder.append(bounds);
   if (null != left) {
     builder.append(", \nleft=\n");
     builder.append(StringUtil.indent(left.toString(), " "));
   }
   if (null != left) {
     builder.append(", \nright=\n");
     builder.append(StringUtil.indent(right.toString(), " "));
   }
   builder.append("\n]");
   return builder.toString();
 }
コード例 #27
0
ファイル: Graph.java プロジェクト: sormaz/implanner-fx
  /**
   * Executes the "Nodes" command
   *
   * @param commandList the command along with the necessary parameters specified by the user
   */
  public void executeNodes(ArrayList<String> commandList) throws Exception {
    if (commandList.size() != 1) {
      throw new Exception("\nInvalid arguments, code not executed" + "\nCorrect Syntax: \nnodes\n");
    }

    HashSet<Node> nodeList = getNodes();

    for (Node aNode : nodeList) {
      System.out.println(aNode.toString());
    }
  }
コード例 #28
0
 @FixFor("MODE-1254")
 @Test
 public void shouldNotIncludeBinaryContentsInToString() throws Exception {
   altima = cache.findJcrNode(null, path("/Cars/Hybrid/Nissan Altima"));
   Node node = rootNode.addNode("nodeWithBinaryProperty", "nt:unstructured");
   String value = "This is the string value";
   Binary binaryValue =
       cache.session().getValueFactory().createBinary(new ByteArrayInputStream(value.getBytes()));
   node.setProperty("binProp", binaryValue);
   String toString = node.toString();
   assertThat(toString.indexOf("**binary-value") > 0, is(true));
 }
コード例 #29
0
  public String toString() {
    StringBuffer buffer = new StringBuffer();

    if (head != null) {
      Node temp = head;

      while (temp != null) {
        buffer.append(temp.toString() + " ");
        temp = temp.next();
      }
    }

    return buffer.toString();
  }
コード例 #30
0
 @Override
 public String toString() {
   if (problemNode == null && getMessage() == null) return "ResolutionException (unknown cause)";
   if (problemNode == null) return "AstException: " + getMessage();
   String nodeDescription =
       problemNode == null ? "(null)" : (problemNode.getClass().getName() + "(toString failed)");
   try {
     nodeDescription = problemNode.toString();
   } catch (Throwable ignore) {
     // throwing exceptions in toString() is bad.
   }
   if (getMessage() == null) return "ResolutionException at " + nodeDescription;
   return String.format("ResolutionException: %s (at %s)", getMessage(), nodeDescription);
 }