Project

General

Profile

1
/**
2
 *  '$RCSfile$'
3
 *    Purpose: A Class that represents all node info from the database
4
 *  Copyright: 2000 Regents of the University of California and the
5
 *             National Center for Ecological Analysis and Synthesis
6
 *    Authors: Matt Jones
7
 *    Release: @release@
8
 *
9
 *   '$Author: sgarg $'
10
 *     '$Date: 2005-11-18 13:10:20 -0800 (Fri, 18 Nov 2005) $'
11
 * '$Revision: 2762 $'
12
 *
13
 * This program is free software; you can redistribute it and/or modify
14
 * it under the terms of the GNU General Public License as published by
15
 * the Free Software Foundation; either version 2 of the License, or
16
 * (at your option) any later version.
17
 *
18
 * This program is distributed in the hope that it will be useful,
19
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21
 * GNU General Public License for more details.
22
 *
23
 * You should have received a copy of the GNU General Public License
24
 * along with this program; if not, write to the Free Software
25
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
26
 */
27

    
28
package edu.ucsb.nceas.metacat;
29

    
30
import org.apache.log4j.Logger;
31

    
32
/**
33
 * A utility class that encapsulates a node and its data
34
 */
35
public class NodeRecord {
36
  private long nodeid = -1;
37
  private long parentnodeid = -1;
38
  private long nodeindex = -1;
39
  private String nodename = null;
40
  private String nodeprefix = null;
41
  private String nodetype = null;
42
  private String nodedata = null;
43
  private float nodedatanumerical = -1;
44
  private Logger logMetacat = Logger.getLogger(NodeRecord.class);
45

    
46
  /**
47
   * Constructor
48
   */
49
  public NodeRecord(long nodeid, long parentnodeid, long nodeindex,
50
                    String nodetype, String nodename, String nodeprefix, 
51
                    String nodedata) {
52
    this.nodeid = nodeid;
53
    this.parentnodeid = parentnodeid;
54
    this.nodeindex = nodeindex;
55
    this.nodename = nodename;
56
    this.nodeprefix = nodeprefix;
57
    this.nodetype = nodetype;
58
    this.nodedata = nodedata;
59
  }
60
  
61
  
62
  public NodeRecord(long nodeid, long parentnodeid, long nodeindex,
63
                    String nodetype, String nodename, String nodeprefix, 
64
                    String nodedata, float nodedatanumerical) {
65
    this.nodeid = nodeid;
66
    this.parentnodeid = parentnodeid;
67
    this.nodeindex = nodeindex;
68
    this.nodename = nodename;
69
    this.nodeprefix = nodeprefix;
70
    this.nodetype = nodetype;
71
    this.nodedata = nodedata;
72
    this.nodedatanumerical = nodedatanumerical;
73
  }
74
  
75
  /** Get functions*/
76
  public long getNodeId()
77
  {
78
    return nodeid;
79
  }
80
  
81
  public long getParentNodeId()
82
  {
83
    return parentnodeid;
84
  }
85
  
86
  public long getNodeIndex()
87
  {
88
    return nodeindex;
89
  }
90
  
91
  public String getNodeName()
92
  {
93
    return nodename;
94
  }
95
  
96
  public String getNodeType()
97
  {
98
    return nodetype;
99
  }
100
  
101
  public String getNodePrefix()
102
  {
103
    return nodeprefix;
104
  }
105
  
106
  public String getNodeData()
107
  {
108
    return nodedata;
109
  }
110

    
111
  public float getNodeDataNumerical()
112
  {
113
    return nodedatanumerical;
114
  }
115
  /** Method compare two records */
116
  public boolean contentEquals(NodeRecord record)
117
  {
118
    boolean flag = true;
119
    logMetacat.info("First nodetype: "+this.nodetype);
120
    logMetacat.info("Second nodetype: "+record.getNodeType());
121
    logMetacat.info("First nodename: "+this.nodename);
122
    logMetacat.info("Second nodename: "+record.getNodeName());
123
    logMetacat.info("First nodeprefix: "+this.nodeprefix);
124
    logMetacat.info("Second nodeprefix: "+record.getNodePrefix());
125
    logMetacat.info("First nodedata: "+this.nodedata);
126
    logMetacat.info("Second nodedata: "+record.getNodeData());
127
    if ((this.nodename == null && record.getNodeName() != null) ||
128
        (this.nodename != null && record.getNodeName() == null) ||
129
        (this.nodename != null && record.getNodeName() != null &&
130
        !(this.nodename).equals(record.getNodeName())))
131
    {
132
      //compare nodename
133
      flag = false;
134
    }
135
    else if ((this.nodetype == null && record.getNodeType() != null) ||
136
             (this.nodetype != null && record.getNodeType() == null) ||
137
             (this.nodetype != null && record.getNodeType() != null &&
138
             !(this.nodetype).equals(record.getNodeType())))
139
    {
140
      // compare node type
141
      flag = false;
142
    }
143
    else if ((this.nodeprefix == null && record.getNodePrefix() != null) ||
144
             (this.nodeprefix != null && record.getNodePrefix() == null) ||
145
             (this.nodeprefix != null && record.getNodePrefix() != null &&
146
             !(this.nodeprefix).equals(record.getNodePrefix())))
147
    {
148
      // compare node prefix
149
      flag = false;
150
    }
151
    else if ((this.nodedata == null && record.getNodeData() != null) ||
152
             (this.nodedata != null && record.getNodeData() == null) ||
153
             (this.nodedata != null && record.getNodeData() != null &&
154
             !(this.nodedata).equals(record.getNodeData())))
155
    {
156
      // compare node data
157
      flag = false;
158
    }
159
    return flag;
160
    
161
  }//contentEquals
162
}
(49-49/65)