/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 *  contributor license agreements.  See the NOTICE file distributed with
 *  this work for additional information regarding copyright ownership.
 *  The ASF licenses this file to You under the Apache License, Version 2.0
 *  (the "License"); you may not use this file except in compliance with
 *  the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 */
package org.apache.lenya.cms.usecase;

import org.apache.lenya.util.Assert;


/**
 * A message in a usecase. This an encapsulation for an internationalizable
 * message, containing a message content and potentially some parameters.
 * The parameters correspond to the placeholders in dictionary entries.
 * 
 * @version $Id$
 */
public class UsecaseMessage {

    private String message;
    private String[] params;

    /**
     * Ctor.
     * @param _message The message.
     */
    public UsecaseMessage(String _message) {
        Assert.notNull("message", _message);
        this.message = _message;
    }

    /**
     * Ctor.
     * @param _message The message.
     * @param _params The parameters.
     */
    public UsecaseMessage(String _message, String[] _params) {
        this(_message);
        
        Assert.notNull("params", _params);
        for (int i = 0; i < _params.length; i++) {
            Assert.notNull("params[" + i + "]", _params[i]);
        }
        this.params = _params;
    }

    /**
     * Determine if this message has parameters
     * @return true if the message has parameters
     */
    public boolean hasParameters() {
        return params != null && params.length > 0;
    }

    /**
     * Retrieve the message content
     * @return the message
     */
    public String getMessage() {
        return message;
    }

    /**
     * Retrieve the parameters for this message
     * @return the parameters
     */
    public String[] getParameters() {
        return params;
    }

    /** 
     * Accomodates scripts which do no care about parameters
     * @return a string representation disregarding any parameters
     */
    public String toString() {
        return message;
    }
}

@@ -886,17 +886,16 @@
 ssert;%0A%0A
-%0A
 /**%0A * A
@@ -1043,15 +1043,15 @@
 ers.
-%0A *
  The
+%0A *
  par
@@ -1611,24 +1611,16 @@
 ssage);%0A
-        
 %0A       
@@ -2182,29 +2182,28 @@
 *%0A     * Ret
-rieve
+urns
  the paramet
@@ -2206,19 +2206,18 @@
 ameters 
+o
 f
-or
  this me
@@ -2217,24 +2217,93 @@
 this message
+. If no parameters are set,%0A     * an empty String array is returned.
 %0A     * @ret
@@ -2378,24 +2378,67 @@
      return 
+this.params == null ? new String%5B0%5D : this.
 params;%0A    
@@ -2447,17 +2447,16 @@
 %0A    /**
- 
 %0A     * 

Return empty array instead of null in UsecaseMessage.getParameters()