Coverage Report - org.seasar.teeda.core.portlet.FacesPortletState
 
Classes in this File Line Coverage Branch Coverage Complexity
FacesPortletState
0%
0/34
0%
0/8
1.5
 
 1  
 /*
 2  
  * Copyright 2004-2011 the Seasar Foundation and the Others.
 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,
 13  
  * either express or implied. See the License for the specific language
 14  
  * governing permissions and limitations under the License.
 15  
  */
 16  
 package org.seasar.teeda.core.portlet;
 17  
 
 18  
 import java.io.Serializable;
 19  
 import java.util.ArrayList;
 20  
 import java.util.Collections;
 21  
 import java.util.HashMap;
 22  
 import java.util.Iterator;
 23  
 import java.util.List;
 24  
 import java.util.Map;
 25  
 
 26  
 import javax.faces.application.FacesMessage;
 27  
 
 28  
 /**
 29  
  * @author shinsuke
 30  
  * 
 31  
  */
 32  0
 public class FacesPortletState implements Serializable {
 33  
 
 34  
     private static final long serialVersionUID = -2877915312956741979L;
 35  
 
 36  0
     private Map messages = new HashMap();
 37  
 
 38  0
     private Map requestMap = null;
 39  
 
 40  0
     private String viewId = null;
 41  
 
 42  0
     private Object state = null;
 43  
 
 44  
     public void addMessage(String clientId, FacesMessage message) {
 45  0
         List list = (List) messages.get(clientId);
 46  0
         if (list == null) {
 47  0
             list = new ArrayList();
 48  0
             messages.put(clientId, list);
 49  
         }
 50  0
         list.add(message);
 51  0
     }
 52  
 
 53  
     public Iterator getMessages(String clientId) {
 54  0
         List list = (List) messages.get(clientId);
 55  0
         if (list != null) {
 56  0
             return (list.iterator());
 57  
         } else {
 58  0
             return (Collections.EMPTY_LIST.iterator());
 59  
         }
 60  
     }
 61  
 
 62  
     public StringBuffer getMessagesBuffer(String clientId) {
 63  0
         List list = (List) messages.get(clientId);
 64  0
         StringBuffer buffer = new StringBuffer();
 65  0
         if (list != null) {
 66  0
             Iterator messages = list.iterator();
 67  
             FacesMessage message;
 68  0
             while (messages.hasNext()) {
 69  0
                 message = (FacesMessage) messages.next();
 70  0
                 buffer.append(" ");
 71  0
                 buffer.append(message.getDetail());
 72  
             }
 73  
         }
 74  0
         return buffer;
 75  
     }
 76  
 
 77  
     // iterate over the client ids in this view
 78  
     public Iterator getClientIds() {
 79  0
         return (messages.keySet().iterator());
 80  
     }
 81  
 
 82  
     /**
 83  
      * @return Returns the requestMap.
 84  
      */
 85  
     public Map getRequestMap() {
 86  0
         return requestMap;
 87  
     }
 88  
 
 89  
     /**
 90  
      * @param requestMap The requestMap to set.
 91  
      */
 92  
     public void setRequestMap(Map requestMap) {
 93  0
         this.requestMap = requestMap;
 94  0
     }
 95  
 
 96  
     /**
 97  
      * @return Returns the viewId.
 98  
      */
 99  
     public String getViewId() {
 100  0
         return viewId;
 101  
     }
 102  
 
 103  
     /**
 104  
      * @param viewId The viewId to set.
 105  
      */
 106  
     public void setViewId(String viewId) {
 107  0
         this.viewId = viewId;
 108  0
     }
 109  
 
 110  
     /**
 111  
      * @return Returns the state.
 112  
      */
 113  
     public Object getState() {
 114  0
         return state;
 115  
     }
 116  
 
 117  
     /**
 118  
      * @param state The state to set.
 119  
      */
 120  
     public void setState(Object state) {
 121  0
         this.state = state;
 122  0
     }
 123  
 
 124  
 }