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-10-10 11:06:55 -0700 (Mon, 10 Oct 2005) $'
11
 * '$Revision: 2663 $'
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
  public long nodeid = -1;
37
  public long parentnodeid = -1;
38
  public long nodeindex = -1;
39
  public String nodename = null;
40
  public String nodeprefix = null;
41
  public String nodetype = null;
42
  public String nodedata = null;
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
  /** Get functions*/
61
  public long getNodeId()
62
  {
63
    return nodeid;
64
  }
65
  
66
  public long getParentNodeId()
67
  {
68
    return parentnodeid;
69
  }
70
  
71
  public long getNodeIndex()
72
  {
73
    return nodeindex;
74
  }
75
  
76
  public String getNodeName()
77
  {
78
    return nodename;
79
  }
80
  
81
  public String getNodeType()
82
  {
83
    return nodetype;
84
  }
85
  
86
  public String getNodePrefix()
87
  {
88
    return nodeprefix;
89
  }
90
  
91
  public String getNodeData()
92
  {
93
    return nodedata;
94
  }
95
  
96
  /** Method compare two records */
97
  public boolean contentEquals(NodeRecord record)
98
  {
99
    boolean flag = true;
100
    logMetacat.info("First nodetype: "+this.nodetype);
101
    logMetacat.info("Second nodetype: "+record.getNodeType());
102
    logMetacat.info("First nodename: "+this.nodename);
103
    logMetacat.info("Second nodename: "+record.getNodeName());
104
    logMetacat.info("First nodeprefix: "+this.nodeprefix);
105
    logMetacat.info("Second nodeprefix: "+record.getNodePrefix());
106
    logMetacat.info("First nodedata: "+this.nodedata);
107
    logMetacat.info("Second nodedata: "+record.getNodeData());
108
    if ((this.nodename == null && record.getNodeName() != null) ||
109
        (this.nodename != null && record.getNodeName() == null) ||
110
        (this.nodename != null && record.getNodeName() != null &&
111
        !(this.nodename).equals(record.getNodeName())))
112
    {
113
      //compare nodename
114
      flag = false;
115
    }
116
    else if ((this.nodetype == null && record.getNodeType() != null) ||
117
             (this.nodetype != null && record.getNodeType() == null) ||
118
             (this.nodetype != null && record.getNodeType() != null &&
119
             !(this.nodetype).equals(record.getNodeType())))
120
    {
121
      // compare node type
122
      flag = false;
123
    }
124
    else if ((this.nodeprefix == null && record.getNodePrefix() != null) ||
125
             (this.nodeprefix != null && record.getNodePrefix() == null) ||
126
             (this.nodeprefix != null && record.getNodePrefix() != null &&
127
             !(this.nodeprefix).equals(record.getNodePrefix())))
128
    {
129
      // compare node prefix
130
      flag = false;
131
    }
132
    else if ((this.nodedata == null && record.getNodeData() != null) ||
133
             (this.nodedata != null && record.getNodeData() == null) ||
134
             (this.nodedata != null && record.getNodeData() != null &&
135
             !(this.nodedata).equals(record.getNodeData())))
136
    {
137
      // compare node data
138
      flag = false;
139
    }
140
    return flag;
141
    
142
  }//contentEquals
143
}
(47-47/63)