1 package org.apache.lucene.messages;
4 * Licensed to the Apache Software Foundation (ASF) under one or more
5 * contributor license agreements. See the NOTICE file distributed with
6 * this work for additional information regarding copyright ownership.
7 * The ASF licenses this file to You under the Apache License, Version 2.0
8 * (the "License"); you may not use this file except in compliance with
9 * the License. You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
20 import java.util.Locale;
23 * Default implementation of Message interface.
24 * For Native Language Support (NLS), system of software internationalization.
26 public class MessageImpl implements Message {
28 private static final long serialVersionUID = -3077643314630884523L;
32 private Object[] arguments = new Object[0];
34 public MessageImpl(String key) {
39 public MessageImpl(String key, Object... args) {
41 this.arguments = args;
44 public Object[] getArguments() {
45 return this.arguments;
48 public String getKey() {
52 public String getLocalizedMessage() {
53 return getLocalizedMessage(Locale.getDefault());
56 public String getLocalizedMessage(Locale locale) {
57 return NLS.getLocalizedMessage(getKey(), locale, getArguments());
61 public String toString() {
62 Object[] args = getArguments();
63 StringBuilder sb = new StringBuilder(getKey());
65 for (int i = 0; i < args.length; i++) {
66 sb.append(i == 0 ? " " : ", ").append(args[i]);