Coverage Report - javax.faces.application.FacesMessage
 
Classes in this File Line Coverage Branch Coverage Complexity
FacesMessage
0%
0/42
0%
0/6
0
FacesMessage$1
N/A
N/A
0
FacesMessage$Severity
0%
0/10
0%
0/2
0
 
 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one
 3  
  * or more contributor license agreements.  See the NOTICE file
 4  
  * distributed with this work for additional information
 5  
  * regarding copyright ownership.  The ASF licenses this file
 6  
  * to you under the Apache License, Version 2.0 (the
 7  
  * "License"); you may not use this file except in compliance
 8  
  * with the License.  You may obtain a copy of the License at
 9  
  *
 10  
  *   http://www.apache.org/licenses/LICENSE-2.0
 11  
  *
 12  
  * Unless required by applicable law or agreed to in writing,
 13  
  * software distributed under the License is distributed on an
 14  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 15  
  * KIND, either express or implied.  See the License for the
 16  
  * specific language governing permissions and limitations
 17  
  * under the License.
 18  
  */
 19  
 package javax.faces.application;
 20  
 
 21  
 import java.io.Serializable;
 22  
 import java.util.*;
 23  
 
 24  
 /**
 25  
  * see Javadoc of <a href="http://java.sun.com/javaee/javaserverfaces/1.2/docs/api/index.html">JSF Specification</a>
 26  
  *
 27  
  * @author Manfred Geiler (latest modification by $Author: skitching $)
 28  
  * @version $Revision: 676298 $ $Date: 2008-07-13 05:31:48 -0500 (Sun, 13 Jul 2008) $
 29  
  */
 30  
 public class FacesMessage
 31  
         implements Serializable
 32  
 {
 33  
     private static final long serialVersionUID = 4851488727794169661L;
 34  
 
 35  
     public static final String FACES_MESSAGES = "javax.faces.Messages";
 36  
 
 37  0
     public static final FacesMessage.Severity SEVERITY_INFO = new Severity("Info", 1);
 38  0
     public static final FacesMessage.Severity SEVERITY_WARN = new Severity("Warn", 2);
 39  0
     public static final FacesMessage.Severity SEVERITY_ERROR = new Severity("Error", 3);
 40  0
     public static final FacesMessage.Severity SEVERITY_FATAL = new Severity("Fatal", 4);
 41  
     public static final List VALUES;
 42  
     public static final Map VALUES_MAP;
 43  
     static
 44  
     {
 45  0
         Map<String, FacesMessage.Severity> map = new HashMap<String, FacesMessage.Severity>(7);
 46  0
         map.put(SEVERITY_INFO.toString(), SEVERITY_INFO);
 47  0
         map.put(SEVERITY_WARN.toString(), SEVERITY_WARN);
 48  0
         map.put(SEVERITY_ERROR.toString(), SEVERITY_ERROR);
 49  0
         map.put(SEVERITY_FATAL.toString(), SEVERITY_FATAL);
 50  0
         VALUES = Collections.unmodifiableList(new ArrayList<FacesMessage.Severity>(map.values()));
 51  0
         VALUES_MAP = Collections.unmodifiableMap(map);
 52  0
     }
 53  
 
 54  
     private FacesMessage.Severity _severity;
 55  
     private String _summary;
 56  
     private String _detail;
 57  
 
 58  
     public FacesMessage()
 59  0
     {
 60  0
         _severity = SEVERITY_INFO;
 61  0
     }
 62  
 
 63  
     public FacesMessage(String summary)
 64  0
     {
 65  0
         _summary = summary;
 66  0
         _severity = SEVERITY_INFO;
 67  0
     }
 68  
 
 69  
     public FacesMessage(String summary, String detail)
 70  0
     {
 71  0
         _summary = summary;
 72  0
         _detail = detail;
 73  0
         _severity = SEVERITY_INFO;
 74  0
     }
 75  
 
 76  
     public FacesMessage(FacesMessage.Severity severity,
 77  
                         String summary,
 78  
                         String detail)
 79  0
     {
 80  0
         if(severity == null) throw new NullPointerException("severity");
 81  0
         _severity = severity;
 82  0
         _summary = summary;
 83  0
         _detail = detail;
 84  0
     }
 85  
 
 86  
     public FacesMessage.Severity getSeverity()
 87  
     {
 88  0
         return _severity;
 89  
     }
 90  
 
 91  
     public void setSeverity(FacesMessage.Severity severity)
 92  
     {
 93  0
         if(severity == null) throw new NullPointerException("severity");
 94  0
         _severity = severity;
 95  0
     }
 96  
 
 97  
     public String getSummary()
 98  
     {
 99  0
         return _summary;
 100  
     }
 101  
 
 102  
     public void setSummary(String summary)
 103  
     {
 104  0
         _summary = summary;
 105  0
     }
 106  
 
 107  
     public String getDetail()
 108  
     {
 109  0
         if (_detail == null)
 110  
         {
 111  
             // Javadoc:
 112  
             // If no localized detail text has been defined for this message, return the localized summary text instead
 113  0
             return _summary;
 114  
         }
 115  0
         return _detail;
 116  
     }
 117  
 
 118  
     public void setDetail(String detail)
 119  
     {
 120  0
         _detail = detail;
 121  0
     }
 122  
 
 123  
 
 124  0
     public static class Severity
 125  
             implements Comparable
 126  
     {
 127  
         private String _name;
 128  
         private int _ordinal;
 129  
 
 130  
         private Severity(String name, int ordinal)
 131  0
         {
 132  0
             _name = name;
 133  0
             _ordinal = ordinal;
 134  0
         }
 135  
 
 136  
         public int getOrdinal()
 137  
         {
 138  0
             return _ordinal;
 139  
         }
 140  
 
 141  
         public String toString()
 142  
         {
 143  0
             return _name;
 144  
         }
 145  
 
 146  
         public int compareTo(Object o)
 147  
         {
 148  0
             if (!(o instanceof Severity))
 149  
             {
 150  0
                 throw new IllegalArgumentException(o.getClass().getName());
 151  
             }
 152  0
             return getOrdinal() - ((Severity)o).getOrdinal();
 153  
         }
 154  
     }
 155  
 
 156  
 }