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