1 package org.apache.slide.projector.value; 2 3 import java.util.Locale ; 4 5 import org.apache.slide.projector.i18n.MessageManager; 6 import org.apache.slide.projector.i18n.MessageNotFoundException; 7 8 public class MessageValue implements Value { 9 public final static String CONTENT_TYPE = "application/slide-message"; 10 public final static String ID = "id"; 11 public final static String ARGUMENTS = "arguments"; 12 13 protected String id; 14 protected Value[] arguments; 15 16 public MessageValue(String messageId) { 17 this.id = messageId; 18 this.arguments = new Value[0]; 19 } 20 21 public MessageValue(String messageId, Object [] arguments) { 22 this.id = messageId; 23 this.arguments = new Value[arguments.length]; 24 for ( int i = 0; i < arguments.length; i++ ) { 25 this.arguments[i] = new ObjectValue(arguments[i]); 26 } 27 } 28 29 public String getId() { 30 return id; 31 } 32 33 public Value[] getArguments() { 34 return arguments; 35 } 36 37 public String getText(String key, Locale locale) throws MessageNotFoundException { 38 return MessageManager.getText(id, key, arguments, locale); 39 } 40 41 public String getText(String key, String defaultText, Locale locale) { 42 return MessageManager.getText(id, key, arguments, locale, defaultText); 43 } 44 45 public String getContentType() { 46 return CONTENT_TYPE; 47 } 48 } | Popular Tags |