husted 2003/01/14 14:13:09
Added: resources/src/java/org/apache/commons/resources
MessageList.java Message.java
Log:
Add Message and MessageList interfaces based on Struts ActionMessage(s) class, per
discussion on Struts Dev list.
Revision Changes Path
1.1
jakarta-commons-sandbox/resources/src/java/org/apache/commons/resources/MessageList.java
Index: MessageList.java
===================================================================
/*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Scaffold", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
// ------------------------------------------------------------------------ 78
package org.apache.commons.resources;
import org.apache.commons.resources.Message;
import java.util.Iterator;
/**
* <p>
* A class that encapsulates messages. MessageList can be either global
* or they are specific to a particular bean property.
* </p>
* <p>
* Each individual message is described by an <code>Message</code>
* object, which contains a message key (to be looked up in an appropriate
* message resources database), and up to four placeholder arguments used for
* parametric substitution in the resulting message.
* </p>
* <p>
* <strong>IMPLEMENTATION NOTE</strong> - It is assumed that these objects
* are created and manipulated only within the context of a single thread.
* Therefore, no synchronization is required for access to internal
* collections.
* </p>
* Orginally based on org.apache.http.action.ActionMessages, Revision 1.7.
*
* @author David Geary
* @author Craig R. McClanahan
* @author David Winterfeldt
* @author David Graham
* @author Ted Husted
* @version $Revision: 1.1 $ $Date: 2003/01/14 22:13:09 $
*/
public interface MessageList {
/**
* A default key to represent "global" messages
* that do not pertain to a particular property.
*/
public static final String GLOBAL_MESSAGE_KEY =
"org.apache.commons.resources.GLOBAL_MESSAGE";
/**
* @return The default global message key
*/
public String getGlobalMessageKey();
/**
* @param globalMessageKey The new default global message key
*/
public void setGlobalMessageKey(String globalMessageKey);
/**
* Add a message to the set of messages for the specified property. An
* order of the property/key is maintained based on the initial addition
* of the property/key.
*
* @param property Property name (or MessageList.GLOBAL_MESSAGE_KEY)
* @param message The message to be added
*/
public void add(String property, Message message);
/**
* Add a message to the set of messages for the "global" property. An
* order of the property/key is maintained based on the initial addition
* of the property/key.
*
* @param message The message to be added
*/
public void add(Message message);
/**
* Adds the messages from the given <code>MessageList</code> object to
* this set of messages. The messages are added in the order they are returned
from
* the properties() method. If a message's property is already in the current
* <code>MessageList</code> object it is added to the end of the list for that
* property. If a message's property is not in the current list it is added to
the end
* of the properties.
*
* @param messages The <code>MessageList</code> object to be added.
*/
public void add(MessageList messages);
/**
* Clear all messages recorded by this object.
*/
public void clear();
/**
* Return <code>true</code> if there are no messages recorded
* in this collection, or <code>false</code> otherwise.
* @deprecated Use isEmpty instead.
*/
public boolean empty();
/**
* Return <code>true</code> if there are no messages recorded
* in this collection, or <code>false</code> otherwise.
*/
public boolean isEmpty();
/**
* Return the set of all recorded messages, without distinction
* by which property the messages are associated with. If there are
* no messages recorded, an empty enumeration is returned.
*/
public Iterator get();
/**
* Return the set of messages related to a specific property.
* If there are no such messages, an empty enumeration is returned.
*
* @param property Property name (or ActionMessages.GLOBAL_MESSAGE_KEY)
*/
public Iterator get(String property);
/**
* Return the set of property names for which at least one message has
* been recorded. If there are no messages, an empty Iterator is returned.
* If you have recorded global messages, the String value of
* <code>MessageList.GLOBAL_MESSAGE</code> will be one of the returned
* property names.
*/
public Iterator properties();
/**
* Return the number of messages recorded for all properties (including
* global messages). <strong>NOTE</strong> - it is more efficient to call
* <code>empty()</code> if all you care about is whether or not there are
* any messages at all.
*/
public int size();
/**
* Return the number of messages associated with the specified property.
*
* @param property Property name (or MessageList.GLOBAL_MESSAGE_KEY
*/
public int size(String property);
} // end MessageList
/*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Scaffold", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
1.1
jakarta-commons-sandbox/resources/src/java/org/apache/commons/resources/Message.java
Index: Message.java
===================================================================
/*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Scaffold", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
// ------------------------------------------------------------------------ 78
package org.apache.commons.resources;
/**
* An encapsulation of an individual message stored in a MessageList object,
consisting
* of a message key (to be used to look up message text in an appropriate
* message resources database) plus up to four placeholder objects that can
* be used for parametric replacement in the message text.
* <p>
* Orginally based on org.apache.http.action.ActionMessage, Revision 1.5.
*
* @author Craig R. McClanahan
* @author David Winterfeldt
* @author Ted Husted
* @version $Revision: 1.1 $ $Date: 2003/01/14 22:13:09 $
*/
public interface Message {
/**
* Get the message key for this message.
*/
public String getKey();
/**
* Get the replacement values for this message.
*/
public Object[] getValues();
} // end Message
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>