1 /*--------------------------------------------------------------------------
\r
2 * Copyright 2009 Taro L. Saito
\r
4 * Licensed under the Apache License, Version 2.0 (the "License");
\r
5 * you may not use this file except in compliance with the License.
\r
6 * You may obtain a copy of the License at
\r
8 * http://www.apache.org/licenses/LICENSE-2.0
\r
10 * Unless required by applicable law or agreed to in writing, software
\r
11 * distributed under the License is distributed on an "AS IS" BASIS,
\r
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
13 * See the License for the specific language governing permissions and
\r
14 * limitations under the License.
\r
15 *--------------------------------------------------------------------------*/
\r
16 //--------------------------------------
\r
20 // Since: May 14, 2009 11:36:59 AM
\r
22 // $URL: http://www.xerial.org/svn/project/XerialJ/trunk/xerial-core/src/main/java/org/xerial/lens/relation/LNode.java $
\r
24 //--------------------------------------
\r
25 package org.xerial.lens.relation;
\r
28 * Light-weight node that holds only a node ID and node value.
\r
33 public class LNode extends NodeBase<LNode>
\r
35 private final static long INVALID_ID = -1;
\r
36 private final static String NULL_TEXT = null;
\r
38 public final long nodeID;
\r
39 public final String nodeValue;
\r
41 public LNode(long nodeID, String nodeValue)
\r
43 this.nodeID = nodeID;
\r
44 this.nodeValue = nodeValue;
\r
48 * Builder class for {@link Node}
\r
53 public static class NodeBuilder
\r
55 private long nodeID = INVALID_ID;
\r
56 private String nodeValue = NULL_TEXT;
\r
58 public NodeBuilder()
\r
61 public NodeBuilder(Node node)
\r
63 this.nodeID = node.nodeID;
\r
64 this.nodeValue = node.nodeValue;
\r
67 public NodeBuilder nodeID(long nodeID)
\r
69 this.nodeID = nodeID;
\r
73 public NodeBuilder nodeValue(String nodeValue)
\r
75 this.nodeValue = nodeValue;
\r
79 public LNode build()
\r
81 return new LNode(nodeID, nodeValue);
\r
87 public String toString()
\r
89 StringBuilder buf = new StringBuilder();
\r
91 if (nodeValue != null)
\r
94 buf.append(nodeValue);
\r
96 return buf.toString();
\r