Package com.google.devtools.depan.model

Examples of com.google.devtools.depan.model.GraphModel


   * No need to start a node, since the caller ensures we are wrapped correctly.
   */
  @Override
  public void marshal(Object source, HierarchicalStreamWriter writer,
      MarshallingContext context) {
    GraphModel graph = (GraphModel) source;

    // Save all nodes.
    for (GraphNode node : graph.getNodes()) {
      marshalObject(node, writer, context);
    }

    // Save all edges.
    for (GraphEdge edge : graph.getEdges()) {
      marshalObject(edge, writer, context);
    }
  }
View Full Code Here


    // There should not be two graphs in the same serialization,
    // but just in case ....
    Object prior = context.get(GraphModel.class);

    try {
      GraphModel result = new GraphModel();
      context.put(GraphModel.class, result);

      while (reader.hasMoreChildren()) {
        reader.moveDown();
        String childName = reader.getNodeName();
        Class<?> childClass = mapper.realClass(childName);

        if (GraphNode.class.isAssignableFrom(childClass)) {
          GraphNode node = (GraphNode) context.convertAnother(null, childClass);
          result.addNode(node);
        }
        else if (GraphEdge.class.isAssignableFrom(childClass)) {
          GraphEdge edge =
              (GraphEdge) context.convertAnother(null, childClass);
          result.addEdge(edge);
        } else {
          logger.info("Skipped object with tag " + childName);
        }

        reader.moveUp();
View Full Code Here

   */
  @Override
  public Object unmarshal(HierarchicalStreamReader reader,
      UnmarshallingContext context) {
    try {
      GraphModel graph = viewConverter.getGraphModel(context);

      reader.moveDown();
      Relation relation = unmarshallRelation(reader, context);
      reader.moveUp();

      reader.moveDown();
      GraphNode head = unmarshallGraphNode(reader, context, graph);
      reader.moveUp();

      reader.moveDown();
      GraphNode tail = unmarshallGraphNode(reader, context, graph);
      reader.moveUp();

      GraphEdge result = (GraphEdge) graph.findEdge(relation, head, tail);
      return result;
    } catch (RuntimeException err) {
      // TODO(leeca): Add some error diagnostics, or eliminate as dead code.
      throw err;
    }
View Full Code Here

    public GraphNode[] nodeArray;
    public Set<GraphNode>nodeSet;
    public RelationshipSetAdapter countSet;

    private TestData(int size, boolean forward, boolean reverse) {
      testModel = new GraphModel();
      nodeArray = TestUtils.buildComplete(
          testModel, size, SampleRelation.sampleRelation);
      nodeSet = TestUtils.toSet(nodeArray);

      countSet = new RelationshipSetAdapter("count");
View Full Code Here

  /**
   * Tests non-recursive version of RelationshipSetMatcher.nextMatch()
   */
  public void testPathMatcherTermNextMatchNonRecursive() {
    GraphModel graph = new GraphModel();
    GraphNode[] nodes = fillGraphModel(graph);

    MultipleDirectedRelationFinder finder =
        new MultipleDirectedRelationFinder();

View Full Code Here

  /**
   * Tests non-recursive version of
   * PathExpression.nextMatch(GraphModel, Collection<GraphNode>)
   */
  public void testPathExpressionNextMatchNonRecursive() {
    GraphModel graph = new GraphModel();
    GraphNode[] nodes = fillGraphModel(graph);

    PathExpression pathExpression = createPathExpression(false, false, false);

    Collection<GraphNode> output = pathExpression.nextMatch(graph,
View Full Code Here

  /**
   * Tests recursive version of PathExpression.nextMatch()
   */
  public void testPathExpressionNextMatchRecursiveShort() {
    GraphModel graph = new GraphModel();
    GraphNode[] nodes = fillGraphModel(graph);

    MultipleDirectedRelationFinder finder =
        new MultipleDirectedRelationFinder();

View Full Code Here

  /**
   * Tests recursive version of
   * PathExpression.nextMatch(GraphModel, Collection<GraphNode>)
   */
  public void testPathExpressionNextMatchRecursive() {
    GraphModel graph = new GraphModel();
    GraphNode[] nodes = fillGraphModel(graph);

    PathExpression pathExpression = createPathExpression(true, false, true);

    Collection<GraphNode> output = pathExpression.nextMatch(graph,
View Full Code Here

   * Tests non-recursive and cumulative version of
   * PathExpression.nextMatch(GraphModel, Collection<GraphNode>)
   */
  public void testPathExpressionNextMatchCumulativeNonRecursive() {

    GraphModel graph = new GraphModel();
    GraphNode[] nodes = fillGraphModel(graph);

    PathExpression pathExpression = createPathExpression(false, true, false);

    Collection<GraphNode> output = pathExpression.nextMatch(graph,
View Full Code Here

   */
  public void testPathExpressionNextMatchCumulativeRecursive() {

    PathExpression pathExpression = createPathExpression(true, true, true);

    GraphModel graph = new GraphModel();
    GraphNode[] nodes = fillGraphModel(graph);

    Collection<GraphNode> output = pathExpression.nextMatch(graph,
        buildSingleSet(nodes[0]));

View Full Code Here

TOP

Related Classes of com.google.devtools.depan.model.GraphModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.