File Source: RollerMessages.java
/*
P/P * Method: org.apache.roller.weblogger.util.RollerMessages__static_init
*/
1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. The ASF licenses this file to You
4 * under the Apache License, Version 2.0 (the "License"); you may not
5 * 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. For additional information regarding
15 * copyright in this work, please see the NOTICE file in the top level
16 * directory of this distribution.
17 */
18 package org.apache.roller.weblogger.util;
19
20 import java.util.ArrayList;
21 import java.util.Iterator;
22 import java.util.List;
23
24 /**
25 * Holds collection of error messages and collection of status messages.
26 * @author David M Johnson
27 */
28 public class RollerMessages
29 {
30 private List mErrors = new ArrayList();
31 private List mMessages = new ArrayList();
32
33 public RollerMessages()
/*
P/P * Method: void org.apache.roller.weblogger.util.RollerMessages()
*
* Postconditions:
* this.mErrors == &new ArrayList(RollerMessages#1)
* this.mMessages == &new ArrayList(RollerMessages#2)
* new ArrayList(RollerMessages#1) num objects == 1
* new ArrayList(RollerMessages#2) num objects == 1
*/
34 {
35 }
36 public void addError(String key)
37 {
/*
P/P * Method: void addError(String)
*
* Preconditions:
* this.mErrors != null
*/
38 mErrors.add(new RollerMessage(key, null));
39 }
40 public void addError(String key, String arg)
41 {
/*
P/P * Method: void addError(String, String)
*
* Preconditions:
* this.mErrors != null
*/
42 mErrors.add(new RollerMessage(key, new String[]{arg}));
43 }
44 public void addError(String key, String[] args)
45 {
/*
P/P * Method: void addError(String, String[])
*
* Preconditions:
* this.mErrors != null
*/
46 mErrors.add(new RollerMessage(key, args));
47 }
48 public void addMessage(String key)
49 {
/*
P/P * Method: void addMessage(String)
*
* Preconditions:
* this.mMessages != null
*/
50 mMessages.add(new RollerMessage(key, null));
51 }
52 public void addMessage(String key, String arg)
53 {
/*
P/P * Method: void addMessage(String, String)
*
* Preconditions:
* this.mMessages != null
*/
54 mMessages.add(new RollerMessage(key, new String[]{arg}));
55 }
56 public void addMessage(String key, String[] args)
57 {
/*
P/P * Method: void addMessage(String, String[])
*
* Preconditions:
* this.mMessages != null
*/
58 mMessages.add(new RollerMessage(key, args));
59 }
60 public Iterator getErrors()
61 {
/*
P/P * Method: Iterator getErrors()
*
* Preconditions:
* this.mErrors != null
*
* Postconditions:
* return_value != null
*/
62 return mErrors.iterator();
63 }
64 public Iterator getMessages()
65 {
/*
P/P * Method: Iterator getMessages()
*
* Preconditions:
* this.mMessages != null
*
* Postconditions:
* return_value != null
*/
66 return mMessages.iterator();
67 }
68 public int getErrorCount()
69 {
/*
P/P * Method: int getErrorCount()
*
* Preconditions:
* this.mErrors != null
*
* Postconditions:
* init'ed(return_value)
*/
70 return mErrors.size();
71 }
72 public int getMessageCount()
73 {
/*
P/P * Method: int getMessageCount()
*
* Preconditions:
* this.mMessages != null
*
* Postconditions:
* init'ed(return_value)
*/
74 return mMessages.size();
75 }
76 public String toString()
77 {
/*
P/P * Method: String toString()
*
* Preconditions:
* this.mErrors != null
* this.mMessages != null
*
* Presumptions:
* java.util.Iterator:next(...)@82 != null
* java.util.Iterator:next(...)@89 != null
*
* Postconditions:
* java.lang.StringBuffer:toString(...)._tainted == 0
* return_value == &java.lang.StringBuffer:toString(...)
*
* Test Vectors:
* java.util.Iterator:hasNext(...)@80: {0}, {1}
* java.util.Iterator:hasNext(...)@87: {0}, {1}
*/
78 StringBuffer sb = new StringBuffer();
79 Iterator msgs = mMessages.iterator();
80 while (msgs.hasNext())
81 {
82 RollerMessage msg = (RollerMessage) msgs.next();
83 sb.append(msg.getKey());
84 sb.append(" : ");
85 }
86 Iterator errs = mErrors.iterator();
87 while (errs.hasNext())
88 {
89 RollerMessage msg = (RollerMessage) errs.next();
90 sb.append(msg.getKey());
91 sb.append(" : ");
92 }
93 return sb.toString();
94 }
95 public static class RollerMessage
96 {
97 private String mKey;
98 private String[] mArgs;
99 public RollerMessage(String key, String[] args)
/*
P/P * Method: void org.apache.roller.weblogger.util.RollerMessages$RollerMessage(String, String[])
*
* Postconditions:
* this.mArgs == args
* init'ed(this.mArgs)
* this.mKey == key
* init'ed(this.mKey)
*/
100 {
101 mKey = key;
102 mArgs = args;
103 }
104 public String[] getArgs()
105 {
/*
P/P * Method: String[] getArgs()
*
* Preconditions:
* init'ed(this.mArgs)
*
* Postconditions:
* return_value == this.mArgs
* init'ed(return_value)
*/
106 return mArgs;
107 }
108 public void setArgs(String[] args)
109 {
/*
P/P * Method: void setArgs(String[])
*
* Postconditions:
* this.mArgs == args
* init'ed(this.mArgs)
*/
110 mArgs = args;
111 }
112 public String getKey()
113 {
/*
P/P * Method: String getKey()
*
* Preconditions:
* init'ed(this.mKey)
*
* Postconditions:
* return_value == this.mKey
* init'ed(return_value)
*/
114 return mKey;
115 }
116 public void setKey(String key)
117 {
/*
P/P * Method: void setKey(String)
*
* Postconditions:
* this.mKey == key
* init'ed(this.mKey)
*/
118 mKey = key;
119 }
120 }
121 }
SofCheck Inspector Build Version : 2.18479
| RollerMessages.java |
2009-Jan-02 14:25:34 |
| RollerMessages.class |
2009-Sep-04 03:12:30 |
| RollerMessages$RollerMessage.class |
2009-Sep-04 03:12:30 |