| NodeImpl.java |
1 /*
2 * NodeImpl.java
3 *
4 * Copyright (c) 1998-2004, The University of Sheffield.
5 *
6 * This file is part of GATE (see http://gate.ac.uk/), and is free
7 * software, licenced under the GNU Library General Public License,
8 * Version 2, June 1991 (in the distribution as file licence.html,
9 * and also available at http://gate.ac.uk/gate/licence.html).
10 *
11 * Valentin Tablan, 24.01.2000
12 *
13 * $Id: NodeImpl.java,v 1.11 2004/07/21 17:10:02 akshay Exp $
14 */
15
16 package gate.annotation;
17
18 import gate.Node;
19
20 /** Provides an implementation for the interface gate.Node.
21 *
22 */
23 public class NodeImpl implements Node, Comparable
24 {
25 /** Debug flag
26 */
27 private static final boolean DEBUG = false;
28
29 /** Freeze the serialization UID. */
30 static final long serialVersionUID = -8240414984367916298L;
31
32 /** Construction from id. Creates an unrooted node.
33 */
34 public NodeImpl (Integer id) {
35 this.id = id;
36 offset = null;
37 } // Node()
38
39 /** Construction from id and offset.
40 *
41 * @param id the Id of the new node
42 * @param offset the (temporal) offset of the Node; Should be <b>null</b>
43 * for non-anchored nodes.
44 */
45 public NodeImpl (Integer id, Long offset) {
46 this.id = id;
47 this.offset = offset;
48 } // Node(id, offset)
49
50 /** Returns the Id of the Node.
51 */
52 public Integer getId () { return id; }
53
54 /** Offset (will be null when the node is not anchored)
55 */
56 public Long getOffset () { return offset; }
57
58 /** String representation
59 */
60 public String toString() {
61 return "NodeImpl: id=" + id + "; offset=" + offset;
62 } // toString()
63
64 /** Ordering
65 */
66 public int compareTo(Object o) throws ClassCastException {
67 Node other = (Node) o;
68 return id.compareTo(other.getId());
69 } // compareTo
70
71 /** To allow AnnotationSet to revise offsets during editing
72 */
73 void setOffset(Long offset) { this.offset = offset; }
74
75 /**
76 * The id of this node (used for persistency)
77 *
78 */
79 Integer id;
80 /**
81 * The offset of this node
82 *
83 */
84 Long offset;
85 }
86