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
 *
8
 *   '$Author: jones $'
9
 *     '$Date: 2006-11-10 10:25:38 -0800 (Fri, 10 Nov 2006) $'
10
 * '$Revision: 3077 $'
11
 *
12
 * This program is free software; you can redistribute it and/or modify
13
 * it under the terms of the GNU General Public License as published by
14
 * the Free Software Foundation; either version 2 of the License, or
15
 * (at your option) any later version.
16
 *
17
 * This program is distributed in the hope that it will be useful,
18
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
 * GNU General Public License for more details.
21
 *
22
 * You should have received a copy of the GNU General Public License
23
 * along with this program; if not, write to the Free Software
24
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
25
 */
26

    
27
package edu.ucsb.nceas.metacat;
28

    
29
import org.apache.log4j.Logger;
30

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

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

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