View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    * 
9    *      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.container.state.impl;
18  
19  import java.io.Serializable;
20  import java.util.HashMap;
21  import java.util.Map;
22  
23  import javax.portlet.PortletMode;
24  import javax.portlet.WindowState;
25  
26  /***
27   * PortletWindowExtendedNavigationalState
28   *
29   * @author <a href="mailto:ate@apache.org">Ate Douma</a>
30   * @version $Id: PortletWindowExtendedNavigationalState.java 551865 2007-06-29 12:13:10Z ate $
31   */
32  public class PortletWindowExtendedNavigationalState extends PortletWindowBaseNavigationalState
33  {
34      private static final class ModeStateKey implements Serializable
35      {
36          private final String mode;
37          private final String state;
38          private final int hashCode;
39          
40          public ModeStateKey(PortletMode mode, WindowState state)
41          {
42              this.mode = (mode != null ? mode.toString() : PortletMode.VIEW.toString()).intern() ;
43              this.state = (state != null ? state.toString() : WindowState.NORMAL.toString()).intern();
44              hashCode = this.mode.hashCode()+this.state.hashCode();
45          }
46          
47          public boolean equals(Object obj)
48          {
49              if (obj != null && obj instanceof ModeStateKey)
50              {
51                  ModeStateKey key = (ModeStateKey)obj;
52                  return mode.equals(key.mode) && state.equals(key.state);
53              }
54              return false;
55          }
56  
57          public int hashCode()
58          {
59              return hashCode;
60          }
61      }
62      
63      private Map parametersMap;
64      
65      private Map decoratorActionEncodings;
66          
67      public Map getParametersMap()
68      {
69          return parametersMap;
70      }
71  
72      public void setParameters(String name, String[] values)
73      {
74          if ( parametersMap == null )
75          {
76              parametersMap = new HashMap();
77          }
78          parametersMap.put(name, values);
79      }    
80      
81      public void setParametersMap(Map parametersMap)
82      {
83          this.parametersMap = parametersMap;
84      }
85      
86      public void resetDecoratorActionEncodings()
87      {
88          if (decoratorActionEncodings != null)
89          {
90              decoratorActionEncodings.clear();
91          }
92      }
93      
94      public void setDecoratorActionEncoding(PortletMode mode, WindowState state, String encoding)
95      {
96          if (decoratorActionEncodings == null)
97          {
98              decoratorActionEncodings = new HashMap(4);
99          }
100         decoratorActionEncodings.put(new ModeStateKey(mode,state), encoding);
101     }
102     
103     public String getDecoratorActionEncoding(PortletMode mode, WindowState state)
104     {
105         if (decoratorActionEncodings != null)
106         {
107             return (String)decoratorActionEncodings.get(new ModeStateKey(mode,state));
108         }
109         return null;
110     }
111 }