01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.jetspeed.om.portlet.impl;
18:
19: import javax.portlet.WindowState;
20:
21: import org.apache.jetspeed.om.common.portlet.CustomWindowState;
22:
23: public class CustomWindowStateImpl implements CustomWindowState {
24: /** The application id. */
25: protected long appId;
26:
27: protected long id;
28:
29: protected String customName;
30:
31: protected String mappedName;
32:
33: protected String description;
34:
35: protected transient WindowState customState;
36:
37: protected transient WindowState mappedState;
38:
39: public CustomWindowStateImpl() {
40: }
41:
42: public void setCustomName(String customName) {
43: if (customName == null) {
44: throw new IllegalArgumentException("CustomName is required");
45: } else if (this .customName != null) {
46: throw new IllegalStateException("CustomName already set");
47: }
48: this .customName = customName.toLowerCase();
49: }
50:
51: public void setDescription(String description) {
52: this .description = description;
53: }
54:
55: public void setMappedName(String mappedName) {
56: if (this .mappedName != null || this .mappedState != null) {
57: throw new IllegalArgumentException("MappedName already set");
58: } else if (mappedName != null) {
59: this .mappedName = mappedName.toLowerCase();
60: }
61: }
62:
63: public WindowState getCustomState() {
64: if (customState == null) {
65: customState = new WindowState(customName);
66: }
67: return customState;
68: }
69:
70: public WindowState getMappedState() {
71: if (mappedState == null) {
72: if (mappedName != null) {
73: mappedState = new WindowState(mappedName);
74: } else {
75: mappedState = getCustomState();
76: }
77: }
78: return mappedState;
79: }
80:
81: public String getDescription() {
82: return description;
83: }
84:
85: public int hashCode() {
86: return customName != null ? customName.hashCode() : super
87: .hashCode();
88: }
89:
90: public boolean equals(Object object) {
91: if (object instanceof CustomWindowStateImpl)
92: return customName
93: .equals(((CustomWindowStateImpl) object).customName);
94: else
95: return false;
96: }
97: }
|