001    /*
002     * Copyright 2001,2004 The Apache Software Foundation.
003     * 
004     * Licensed under the Apache License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     * 
008     *      http://www.apache.org/licenses/LICENSE-2.0
009     * 
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    
017    package org.apache.commons.scaffold.util;
018    
019    
020    import java.io.Serializable;
021    
022    // ------------------------------------------------------------------------ 78
023    
024    public class MessageImpl implements Serializable,Message {
025    
026    
027    // -------------------------------------------------------------- Constructors
028    
029    
030        /**
031         * Construct an action message with no replacement values.
032         *
033         * @param key Message key for this message
034         */
035        public MessageImpl(String key) {
036    
037            this.key = key;
038            this.values = null;
039    
040        }
041    
042    
043        /**
044         * Construct an action message with the specified replacement values.
045         *
046         * @param key Message key for this message
047         * @param value0 First replacement value
048         */
049        public MessageImpl(String key, Object value0) {
050    
051            this.key = key;
052            this.values = new Object[] { value0 };
053    
054        }
055    
056    
057        /**
058         * Construct an action message with the specified replacement values.
059         *
060         * @param key Message key for this message
061         * @param value0 First replacement value
062         * @param value1 Second replacement value
063         */
064        public MessageImpl(String key, Object value0, Object value1) {
065    
066            this.key = key;
067            this.values = new Object[] { value0, value1 };
068    
069        }
070    
071    
072        /**
073         * Construct an action message with the specified replacement values.
074         *
075         * @param key Message key for this message
076         * @param value0 First replacement value
077         * @param value1 Second replacement value
078         * @param value2 Third replacement value
079         */
080        public MessageImpl(String key, Object value0, Object value1,
081                           Object value2) {
082    
083            this.key = key;
084            this.values = new Object[] { value0, value1, value2 };
085    
086        }
087    
088    
089        /**
090         * Construct an action message with the specified replacement values.
091         *
092         * @param key Message key for this message
093         * @param value0 First replacement value
094         * @param value1 Second replacement value
095         * @param value2 Third replacement value
096         * @param value3 Fourth replacement value
097         */
098        public MessageImpl(String key, Object value0, Object value1,
099                           Object value2, Object value3) {
100    
101            this.key = key;
102            this.values = new Object[] { value0, value1, value2, value3 };
103        }
104    
105    
106        /**
107         * Construct an action message with the specified replacement values.
108         *
109         * @param key Message key for this message
110         * @param values Array of replacement values
111         */
112        public MessageImpl(String key, Object[] values) {
113    
114            this.key = key;
115            this.values = values;
116    
117        }
118    
119    
120    // -------------------------------------------------------- Instance Variables
121    
122    
123        /**
124         * The message key for this message.
125         */
126        protected String key = null;
127    
128    
129        /**
130         * The replacement values for this mesasge.
131         */
132        protected Object values[] = null;
133    
134    
135        // --------------------------------------------------------- Public Methods
136    
137    
138            // See interface for JavaDoc
139        public String getKey() {
140    
141            return (this.key);
142    
143        }
144    
145    
146            // See interface for JavaDoc
147        public Object[] getValues() {
148    
149            return (this.values);
150    
151        }
152    
153    
154    } // end MessageImpl