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.om.portlet.impl;
018:
019: import java.io.Serializable;
020: import java.util.Collection;
021: import java.util.HashSet;
022: import java.util.Iterator;
023:
024: import javax.portlet.PortletMode;
025:
026: import org.apache.jetspeed.om.common.portlet.ContentTypeComposite;
027: import org.apache.jetspeed.util.HashCodeBuilder;
028: import org.apache.pluto.om.portlet.ContentType;
029:
030: /**
031: *
032: * ContentTypeImpl
033: *
034: * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
035: * @version $Id: ContentTypeImpl.java 516448 2007-03-09 16:25:47Z ate $
036: *
037: */
038: public class ContentTypeImpl implements ContentTypeComposite,
039: Serializable {
040:
041: private String contentType;
042: protected Collection portletModes;
043: /**
044: * field that represents a FK relationship to the parent portlet.
045: * Required by some O/R tools like OJB.
046: */
047: protected long portletId;
048:
049: protected long contentTypeId;
050:
051: public ContentTypeImpl() {
052: portletModes = new HashSet();
053: }
054:
055: /**
056: * @see org.apache.pluto.om.portlet.ContentType#getContentType()
057: */
058: public String getContentType() {
059: return contentType;
060: }
061:
062: /**
063: * @see org.apache.pluto.om.portlet.ContentType#getPortletModes()
064: */
065: public Iterator getPortletModes() {
066: return portletModes.iterator();
067: }
068:
069: public Collection getPortletModesCollection() {
070: return portletModes;
071: }
072:
073: /**
074: * @see org.apache.pluto.om.portlet.ContentTypeCtrl#setContentType(java.lang.String)
075: */
076: public void setContentType(String contentType) {
077: this .contentType = contentType;
078: }
079:
080: /**
081: * @see java.lang.Object#equals(java.lang.Object)
082: */
083: public boolean equals(Object obj) {
084: if (obj != null && obj instanceof ContentType) {
085: ContentType cType = (ContentType) obj;
086: return this .getContentType().equals(cType.getContentType());
087: }
088:
089: return false;
090: }
091:
092: /**
093: * @see java.lang.Object#hashCode()
094: */
095: public int hashCode() {
096: HashCodeBuilder hasher = new HashCodeBuilder(27, 87);
097: hasher.append(contentType);
098: return hasher.toHashCode();
099: }
100:
101: /* (non-Javadoc)
102: * @see org.apache.jetspeed.om.common.portlet.ContentTypeComposite#addPortletMode(javax.portlet.PortletMode)
103: */
104: public void addPortletMode(PortletMode mode) {
105: portletModes.add(mode);
106:
107: }
108:
109: public void addPortletMode(String mode) {
110: portletModes.add(new PortletMode(mode));
111:
112: }
113:
114: /**
115: * @see org.apache.jetspeed.om.common.portlet.ContentTypeComposite#setModes(java.util.Collection)
116: */
117: public void setPortletModes(Collection modes) {
118: portletModes = modes;
119: }
120:
121: /* (non-Javadoc)
122: * @see org.apache.jetspeed.om.common.portlet.ContentTypeComposite#supportsPortletMode(javax.portlet.PortletMode)
123: */
124: public boolean supportsPortletMode(PortletMode mode) {
125: return portletModes.contains(mode);
126: }
127:
128: }
|