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:
021: import org.apache.jetspeed.prefs.om.Property;
022:
023: /**
024: * <p>
025: * {@link Property} interface implementation.
026: * </p>
027: * <p>
028: * Represents a property key/value pair.
029: * </p>
030: *
031: * @author <a href="mailto:dlestrat@apache.org">David Le Strat</a>
032: */
033: public class PropertyImpl implements Property {
034: /** The serial version uid. */
035: private static final long serialVersionUID = 7037975617489867366L;
036:
037: private long nodeId;
038:
039: private String propertyName;
040:
041: private String propertyValue;
042:
043: private long propertyValueId;
044:
045: /**
046: * <p>
047: * Property implementation default constructor.
048: * </p>
049: */
050: public PropertyImpl() {
051: }
052:
053: /**
054: * Property constructor given a property key id, node id and the appropriate
055: * value.
056: *
057: * @param nodeId The node id.
058: * @param propertyName The property name.
059: * @param valueObject The value object.
060: */
061: public PropertyImpl(long nodeId, String propertyName,
062: Object valueObject) {
063: this .nodeId = nodeId;
064: this .propertyName = propertyName;
065: this .creationDate = new Timestamp(System.currentTimeMillis());
066: this .modifiedDate = this .creationDate;
067:
068: setPropertyValue((String) valueObject);
069: }
070:
071: /**
072: * @see org.apache.jetspeed.prefs.om.Property#getPropertyValue()
073: */
074: public final String getPropertyValue() {
075: return propertyValue;
076: }
077:
078: /**
079: * @see org.apache.jetspeed.prefs.om.Property#setPropertyValue(java.lang.String)
080: */
081: public final void setPropertyValue(String valueObject) {
082: this .propertyValue = valueObject;
083: }
084:
085: /**
086: * @see org.apache.jetspeed.prefs.om.Property#getPropertyValueId()
087: */
088: public long getPropertyValueId() {
089: return this .propertyValueId;
090: }
091:
092: /**
093: * @see org.apache.jetspeed.prefs.om.Property#setPropertyValueId(int)
094: */
095: public void setPropertyValueId(long propertyValueId) {
096: this .propertyValueId = propertyValueId;
097: }
098:
099: /**
100: * @see org.apache.jetspeed.prefs.om.Property#getNodeId()
101: */
102: public long getNodeId() {
103: return this .nodeId;
104: }
105:
106: /**
107: * @see org.apache.jetspeed.prefs.om.Property#setNodeId(long)
108: */
109: public void setNodeId(long nodeId) {
110: this .nodeId = nodeId;
111: }
112:
113: /**
114: * @return Returns the propertyName.
115: */
116: public String getPropertyName() {
117: return propertyName;
118: }
119:
120: /**
121: * @param propertyName The propertyName to set.
122: */
123: public void setPropertyName(String propertyName) {
124: this .propertyName = propertyName;
125: }
126:
127: private Timestamp creationDate;
128:
129: /**
130: * @see org.apache.jetspeed.prefs.om.Property#getCreationDate()
131: */
132: public Timestamp getCreationDate() {
133: return this .creationDate;
134: }
135:
136: /**
137: * @see org.apache.jetspeed.ospi.om.prefs.Property#setCreationDate(java.sql.Timestamp)
138: */
139: public void setCreationDate(Timestamp creationDate) {
140: this .creationDate = creationDate;
141: }
142:
143: private Timestamp modifiedDate;
144:
145: /**
146: * @see org.apache.jetspeed.prefs.om.Property#getModifiedDate()
147: */
148: public Timestamp getModifiedDate() {
149: return this .modifiedDate;
150: }
151:
152: /**
153: * @see org.apache.jetspeed.prefs.om.Property#setModifiedDate(java.sql.Timestamp)
154: */
155: public void setModifiedDate(Timestamp modifiedDate) {
156: this .modifiedDate = modifiedDate;
157: }
158:
159: /**
160: * <p>
161: * Convert <code>Property</code> to string.
162: * </p>
163: *
164: * @return The Property string value.
165: */
166: public String toString() {
167: String toStringProperty = "[[nodeId, " + this .nodeId + "], "
168: + "[propertyValue, " + getPropertyValue() + "], "
169: + "[creationDate, " + this .creationDate + "], "
170: + "[modifiedDate, " + this .modifiedDate + "]]";
171: return toStringProperty;
172: }
173:
174: }
|