View Javadoc

1   /*
2    * Copyright 2000-2001,2004 The Apache Software Foundation.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.apache.jetspeed.om.registry.base;
18  
19  import org.apache.jetspeed.om.registry.*;
20  
21  /***
22   * Default bean like implementation of MediaTypeEntry interface
23   * suitable for serializing with Castor
24   *
25   * @author <a href="mailto:raphael@apache.org">RaphaŽl Luta</a>
26   * @version $Id: BaseMediaTypeEntry.java,v 1.6 2004/02/23 03:08:26 jford Exp $
27   */
28  public class BaseMediaTypeEntry extends BaseRegistryEntry
29      implements MediaTypeEntry
30  {
31  
32      protected String mimeType;
33      protected String characterSet;
34      private CapabilityMap capabilities = new BaseCapabilityMap();
35  
36      public BaseMediaTypeEntry()
37      {}
38  
39      public BaseMediaTypeEntry(long id,
40                                String name,
41                                int _hidden,
42                                String mimeType,
43                                String title,
44                                String description,
45                                String image,
46                                 String role)
47      {
48          super(id, name, _hidden, title, description, image, role);
49  
50          this.mimeType = mimeType;
51      }
52  
53      /***
54       * Implements the equals operation so that 2 elements are equal if
55       * all their member values are equal.
56       */
57      public boolean equals(Object object)
58      {
59          if (object==null)
60          {
61              return false;
62          }
63  
64          BaseMediaTypeEntry obj = (BaseMediaTypeEntry)object;
65  
66          if (mimeType!=null)
67          {
68              if (!mimeType.equals(obj.mimeType))
69              {
70                  return false;
71              }
72          }
73          else
74          {
75              if (obj.mimeType!=null)
76              {
77                  return false;
78              }
79          }
80  
81          if (characterSet!=null)
82          {
83              if (!characterSet.equals(obj.characterSet))
84              {
85                  return false;
86              }
87          }
88          else
89          {
90              if (obj.characterSet!=null)
91              {
92                  return false;
93              }
94          }
95  
96          if (!capabilities.equals(obj.capabilities))
97          {
98              return false;
99          }
100 
101         return super.equals(object);
102     }
103 
104     /*** @return the mime type associated with this MediaType */
105     public String getMimeType()
106     {
107         return this.mimeType;
108     }
109 
110     /*** Sets the MimeType associated with this MediaType
111      *  @param mimeType the MIME type to associate
112      */
113     public void setMimeType( String mimeType )
114     {
115         this.mimeType = mimeType;
116     }
117 
118     /*** @return the character set associated with this MediaType */
119     public String getCharacterSet()
120     {
121         return this.characterSet;
122     }
123 
124     /*** Sets the character set associated with this MediaType */
125     public void setCharacterSet( String charSet)
126     {
127         this.characterSet = charSet;
128     }
129 
130     public CapabilityMap getCapabilityMap()
131     {
132         return capabilities;
133     }
134 
135     // castor related method definitions
136 
137     public BaseCapabilityMap getCapabilities()
138     {
139         return (BaseCapabilityMap)capabilities;
140     }
141 
142     public void setCapabilities(BaseCapabilityMap capabilities)
143     {
144         this.capabilities = capabilities;
145     }
146 }