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.pluto.internal.impl;
018:
019: import org.apache.pluto.internal.InternalPortletPreference;
020:
021: /**
022: * TODO: javadoc
023: * @version 1.0
024: * @since Sep 20, 2004
025: */
026: public class PortletPreferenceImpl implements InternalPortletPreference {
027:
028: // Private Member Variables ------------------------------------------------
029:
030: /** The preference name. */
031: private String name;
032:
033: /** The preference values. */
034: private String[] values;
035:
036: /** Flag indicating if this preference is read-only. */
037: private boolean readOnly = false;
038:
039: // Constructors ------------------------------------------------------------
040:
041: public PortletPreferenceImpl(String name, String[] values) {
042: this .name = name;
043: this .values = values;
044: this .readOnly = false;
045: }
046:
047: public PortletPreferenceImpl(String name, String[] values,
048: boolean readOnly) {
049: this .name = name;
050: this .values = values;
051: this .readOnly = readOnly;
052: }
053:
054: /**
055: * Private constructor that is used only within the <code>clone()</code>
056: * method.
057: * @see #clone()
058: */
059: private PortletPreferenceImpl() {
060: // Do nothing.
061: }
062:
063: // PortletPreference Impl --------------------------------------------------
064:
065: public String getName() {
066: return name;
067: }
068:
069: public void setName(String name) {
070: this .name = name;
071: }
072:
073: public String[] getValues() {
074: return values;
075: }
076:
077: public void setValues(String[] values) {
078: this .values = values;
079: }
080:
081: public boolean isReadOnly() {
082: return readOnly;
083: }
084:
085: public void setReadOnly(boolean readOnly) {
086: this .readOnly = readOnly;
087: }
088:
089: public Object clone() {
090: PortletPreferenceImpl copy = new PortletPreferenceImpl();
091: copy.name = this .name;
092: if (this .values != null) {
093: copy.values = (String[]) this .values.clone();
094: }
095: copy.readOnly = this .readOnly;
096: return copy;
097: }
098:
099: // Object Methods ----------------------------------------------------------
100:
101: /**
102: * Override of toString() that prints out name and values of fields.
103: * @see java.lang.Object#toString()
104: */
105: public String toString() {
106: StringBuffer buffer = new StringBuffer();
107: buffer.append(getClass().getName());
108: buffer.append("[name=").append(name).append(";");
109: if (values != null) {
110: for (int i = 0; i < values.length; i++) {
111: buffer.append("value[").append(i).append("]=").append(
112: values[i]).append(";");
113: }
114: } else {
115: buffer.append("values=NULL;");
116: }
117: buffer.append("readOnly=").append(readOnly).append("]");
118: return buffer.toString();
119: }
120:
121: }
|