1 31 32 package org.opencms.i18n; 33 34 import java.util.Locale ; 35 36 53 public class CmsMessageContainer { 54 55 56 protected Object [] m_args; 57 58 59 protected I_CmsMessageBundle m_bundle; 60 61 62 protected String m_key; 63 64 70 public CmsMessageContainer(I_CmsMessageBundle bundle, String key) { 71 72 m_bundle = bundle; 73 m_key = key; 74 } 75 76 83 public CmsMessageContainer(I_CmsMessageBundle bundle, String key, Object [] args) { 84 85 m_bundle = bundle; 86 m_key = key; 87 m_args = args; 88 } 89 90 95 public Object [] getArgs() { 96 97 return m_args; 98 } 99 100 105 public I_CmsMessageBundle getBundle() { 106 107 return m_bundle; 108 } 109 110 115 public String getKey() { 116 117 return m_key; 118 } 119 120 125 public String key() { 126 127 if (getBundle() == null) { 128 return getKey(); 129 } 130 return getBundle().getBundle().key(getKey(), getArgs()); 131 } 132 133 139 public String key(Locale locale) { 140 141 if (getBundle() == null) { 142 return getKey(); 143 } 144 return getBundle().getBundle(locale).key(getKey(), getArgs()); 145 } 146 147 150 public String toString() { 151 152 StringBuffer result = new StringBuffer (); 153 154 result.append('['); 155 result.append(this.getClass().getName()); 156 result.append(", bundle: "); 157 result.append(getBundle().getBundleName()); 158 result.append(", key: "); 159 result.append(getKey()); 160 Object [] args = getArgs(); 161 if (args != null) { 162 for (int i = 0; i < args.length; i++) { 163 result.append(", arg"); 164 result.append(i + 1); 165 result.append(": "); 166 result.append(args[i]); 167 } 168 } 169 result.append(']'); 170 171 return result.toString(); 172 } 173 } 174 | Popular Tags |