001: /*
002: * $Header: /cvsroot/jvalidate/jvalidate-framework/jvalidate/src/main/java/nl/knowlogy/validation/Messages.java,v 1.5 2007/04/20 12:53:18 roberthofstra Exp $
003: * $Revision: 1.5 $
004: * $Date: 2007/04/20 12:53:18 $
005: *
006: *
007: * Copyright 2004 - 2005 Knowlogy, the Netherlands, www.knowlogy.nl
008: *
009: * Licensed under the Apache License, Version 2.0 (the "License");
010: * you may not use this file except in compliance with the License.
011: * You may obtain a copy of the License at
012: *
013: * http://www.apache.org/licenses/LICENSE-2.0
014: *
015: * Unless required by applicable law or agreed to in writing, software
016: * distributed under the License is distributed on an "AS IS" BASIS,
017: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
018: * See the License for the specific language governing permissions and
019: * limitations under the License.
020: */
021: package nl.knowlogy.validation;
022:
023: import java.io.Serializable;
024: import java.util.List;
025: import java.util.ResourceBundle;
026:
027: /**
028: * <p>
029: * A <code>Messages</code> is a message container,in which messages are
030: * stored during validating and is used to provide feedback about the
031: * validation.
032: * </p>
033: *
034: *
035: * @see Message
036: *
037: * @author Robert
038: */
039: public interface Messages extends Serializable {
040:
041: /**
042: * Stores an message in the messages.
043: *
044: * @param message message to add
045: */
046: void addMessage(Message message);
047:
048: /**
049: * <p>
050: * Stores and creates an <code>Message</code> in the messages, based
051: * on the give params.
052: * </p>
053: * <p>
054: * These messages are not bound to a specific property of the object.
055: * </p>
056: *
057: * @param messageType type of the message
058: * @param object the rejected object
059: * @param messageCode message code, interpretable as message key
060: */
061: void addMessage(MessageType messageType, Object object,
062: String messageCode);
063:
064: /**
065: * Add a message.
066: * @param messageType type of the message
067: * @param messageCode message code, interpretable as message key
068: * @param defaultMessage fallback default message
069: */
070: void addMessage(MessageType messageType, Object object,
071: String messageCode, String defaultMessage);
072:
073: /**
074: * Add a message.
075: * @param messageType type of the message
076: * @param messageCode message code, interpretable as message key
077: * @param messageArgs message arguments, for argument binding via MessageFormat
078: * (can be null)
079: * @param defaultMessage fallback default message
080: */
081: void addMessage(MessageType messageType, Object object,
082: String messageCode, Object[] messageArgs,
083: String defaultMessage);
084:
085: /**
086: * Add a message for a specific property of the object.
087: * @param messageType type of the message
088: * @param propertyName the property name
089: * @param messageCode message code, interpretable as message key
090: */
091: void addPropertyMessage(MessageType messageType, Object object,
092: String propertyName, String messageCode);
093:
094: /**
095: * Add a message for a specific property of the object.
096: * @param messageType type of the message
097: * @param propertyName the field name
098: * @param messageCode message code, interpretable as message key
099: * @param defaultMessage fallback default message
100: */
101: void addPropertyMessage(MessageType messageType, Object object,
102: String propertyName, String messageCode,
103: String defaultMessage);
104:
105: /**
106: * Add a message for a specific property of the object.
107: * @param messageType type of the message
108: * @param propertyName the property name
109: * @param messageCode message code, interpretable as message key
110: * @param messageArgs message arguments, for argument binding via MessageFormat
111: * (can be null)
112: * @param defaultMessage fallback default message
113: */
114: void addPropertyMessage(MessageType messageType, Object object,
115: String propertyName, String messageCode,
116: Object[] messageArgs, String defaultMessage);
117:
118: /**
119: * Returns the number of message's.
120: *
121: * @return
122: */
123: int getNumberOfMessages();
124:
125: int getNumberOfErrorMessages();
126:
127: /**
128: * Returns the number of messages with a specific messagetype.
129: *
130: * @param messageType
131: * @return
132: */
133: int getNumberOfMessages(MessageType messageType);
134:
135: /**
136: * Returns the first message associated with the given object and propertyName, if such
137: * a message is present else null.
138: *
139: * @param object object that is associated with the message.
140: * @param propertyName that is associated with the message.
141: *
142: * @return Returns the first message associated with the given object and propertyName, if such
143: * a message is present else null.
144: */
145: Message getMessage(Object object, String propertyName);
146:
147: /**
148: * Returns a list of <code>Message</code> instances associated with the given object and propertyName, if such
149: * a message is present.
150: *
151: * @param object object that is associated with the message.
152: * @param propertyName that is associated with the message.
153: *
154: * @return a list of <code>Message</code>instances associated with the given object and propertyName, if such
155: * a message is present.
156: */
157: List getMessages(Object object, String propertyName);
158:
159: Message getMessage(Object object, boolean objectLevelOnly);
160:
161: List getMessages(Object object, boolean objectLevelOnly);
162:
163: List getMessages();
164:
165: /**
166: * Adds messages.
167: *
168: * @param messages
169: */
170: void addMessages(Messages messages);
171:
172: /**
173: * Returns an overal messageMessage.
174: *
175: * @return
176: */
177: String getMessage();
178:
179: void convertMessageCodes(ResourceBundle resourceBundle);
180:
181: /**
182: * Clears all messages in the container.
183: */
184: void clear();
185: }
|