001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package org.apache.jetspeed.prefs.om.impl;
018:
019: import java.sql.Timestamp;
020: import java.util.ArrayList;
021: import java.util.Collection;
022:
023: import org.apache.jetspeed.prefs.om.Node;
024:
025: /**
026: * <p>
027: * {@link Node}interface implementation.
028: * </p>
029: * <p>
030: * Represents a preferences node.
031: * </p>
032: *
033: * @author <a href="mailto:dlestrat@apache.org">David Le Strat </a>
034: */
035: public class NodeImpl implements Node {
036: /** The serial version uid. */
037: private static final long serialVersionUID = -5367800007757021163L;
038:
039: private long nodeId;
040:
041: private Long parentNodeId;
042:
043: private Collection nodeProperties;
044:
045: private Collection nodeKeys;
046:
047: private String nodeName;
048:
049: private int nodeType;
050:
051: private String fullPath;
052:
053: private Timestamp creationDate;
054:
055: /**
056: * <p>
057: * Preferences node implementation default constructor.
058: * </p>
059: */
060: public NodeImpl() {
061: }
062:
063: /**
064: * <p>
065: * Node constructor given:
066: * </p>
067: * <ul>
068: * <li>Parent node id,</li>
069: * <li>Property set definition id: Long so that we can pass null value if
070: * the node does not have any properties associated to it,</li>
071: * <li>Node name,</li>
072: * <li>Node type,</li>
073: * <li>Full path.</li>
074: * </ul>
075: *
076: * @param parentNodeId The parent node id.
077: * @param nodeName The node name.
078: * @param nodeType The node type.
079: * @param fullPath The full path.
080: */
081: public NodeImpl(Long parentNodeId, String nodeName, int nodeType,
082: String fullPath) {
083: this .parentNodeId = parentNodeId;
084: this .nodeName = nodeName;
085: this .nodeType = nodeType;
086: this .fullPath = fullPath;
087: this .nodeKeys = new ArrayList(0);
088: this .nodeProperties = new ArrayList(0);
089: this .creationDate = new Timestamp(System.currentTimeMillis());
090: this .modifiedDate = this .creationDate;
091: }
092:
093: /**
094: * @see org.apache.jetspeed.prefs.om.Node#getNodeId()
095: */
096: public long getNodeId() {
097: return this .nodeId;
098: }
099:
100: /**
101: * @see org.apache.jetspeed.prefs.om.Node#setNodeId(int)
102: */
103: public void setNodeId(long nodeId) {
104: this .nodeId = nodeId;
105: }
106:
107: /**
108: * @see org.apache.jetspeed.prefs.om.Node#getParentNodeId()
109: */
110: public Long getParentNodeId() {
111: return this .parentNodeId;
112: }
113:
114: /**
115: * @see org.apache.jetspeed.prefs.om.Node#setParentNodeId(java.lang.Long)
116: */
117: public void setParentNodeId(Long parentNodeId) {
118: this .parentNodeId = parentNodeId;
119: }
120:
121: /**
122: * @see org.apache.jetspeed.prefs.om.Node#getNodeProperties()
123: */
124: public Collection getNodeProperties() {
125: return this .nodeProperties;
126: }
127:
128: /**
129: * @see org.apache.jetspeed.prefs.om.Node#setNodeProperties(java.util.Collection)
130: */
131: public void setNodeProperties(Collection nodeProperties) {
132: this .nodeProperties = nodeProperties;
133: }
134:
135: /**
136: * @see org.apache.jetspeed.prefs.om.Node#getNodeKeys()
137: */
138: public Collection getNodeKeys() {
139: return this .nodeKeys;
140: }
141:
142: /**
143: * @see org.apache.jetspeed.prefs.om.Node#setNodeKeys(java.util.Collection)
144: */
145: public void setNodeKeys(Collection nodeKeys) {
146: this .nodeKeys = nodeKeys;
147: }
148:
149: /**
150: * @see org.apache.jetspeed.prefs.om.Node#getNodeName()
151: */
152: public String getNodeName() {
153: return this .nodeName;
154: }
155:
156: /**
157: * @see org.apache.jetspeed.prefs.om.Node#setNodeName(java.lang.String)
158: */
159: public void setNodeName(String nodeName) {
160: this .nodeName = nodeName;
161: }
162:
163: /**
164: * @see org.apache.jetspeed.prefs.om.Node#getNodeType()
165: */
166: public int getNodeType() {
167: return this .nodeType;
168: }
169:
170: /**
171: * @see org.apache.jetspeed.prefs.om.Node#setNodeType(int)
172: */
173: public void setNodeType(int nodeType) {
174: this .nodeType = nodeType;
175: }
176:
177: /**
178: * @see org.apache.jetspeed.prefs.om.Node#getFullPath()
179: */
180: public String getFullPath() {
181: return this .fullPath;
182: }
183:
184: /**
185: * @see org.apache.jetspeed.prefs.om.Node#setFullPath(java.lang.String)
186: */
187: public void setFullPath(String fullPath) {
188: this .fullPath = fullPath;
189: }
190:
191: /**
192: * @see org.apache.jetspeed.prefs.om.Node#getCreationDate()
193: */
194: public Timestamp getCreationDate() {
195: return this .creationDate;
196: }
197:
198: /**
199: * @see org.apache.jetspeed.prefs.om.Node#setCreationDate(java.sql.Timestamp)
200: */
201: public void setCreationDate(Timestamp creationDate) {
202: this .creationDate = creationDate;
203: }
204:
205: private Timestamp modifiedDate;
206:
207: /**
208: * @see org.apache.jetspeed.prefs.om.Node#getModifiedDate()
209: */
210: public Timestamp getModifiedDate() {
211: return this .modifiedDate;
212: }
213:
214: /**
215: * @see org.apache.jetspeed.prefs.om.Node#setModifiedDate(java.sql.Timestamp)
216: */
217: public void setModifiedDate(Timestamp modifiedDate) {
218: this .modifiedDate = modifiedDate;
219: }
220:
221: public boolean equals(Object o) {
222: return fullPath != null && o != null && o instanceof NodeImpl
223: && ((NodeImpl) o).fullPath != null
224: && fullPath.equals(((NodeImpl) o).fullPath);
225: }
226:
227: /**
228: * <p>
229: * Convert <code>Node</code> to string.
230: * </p>
231: *
232: * @return The Node string value.
233: */
234: public String toString() {
235: String toStringNode = "[[parentNodeId, " + this .parentNodeId
236: + "], " + "[nodeName, " + this .nodeName + "], "
237: + "[fullPath, " + this .fullPath + "], " + "[nodeType, "
238: + this .nodeType + "], " + "[nodeKeys, " + this .nodeKeys
239: + "], " + "[nodeProperties, " + this .nodeProperties
240: + "], " + "[creationDate, " + this .creationDate + "], "
241: + "[modifiedDate, " + this .modifiedDate + "]]";
242: return toStringNode;
243: }
244:
245: }
|