/** * Get the StringManager for a particular package. If a manager for * a package already exists, it will be reused, else a new * StringManager will be created and returned. * * @param packageName The package name */ public synchronized static StringManager getManager(String packageName) { StringManager mgr = (StringManager)managers.get(packageName); if (mgr == null) { mgr = new StringManager(packageName); managers.put(packageName, mgr); } return mgr; } }
/** * Get a string from the underlying resource bundle and format it * with the given object argument. This argument can of course be * a String object. * * @param key The resource name * @param arg Formatting directive */ public String getString(String key, Object arg) { Object[] args = new Object[] {arg}; return getString(key, args); }
/** * Retrieve the StringManager for a list of Locales. The first StringManager * found will be returned. * * @param packageName The package for which the StringManager is required * @param requestedLocales the list of Locales * * @return the found StringManager or the default StringManager */ public static StringManager getManager(String packageName, Enumeration<Locale> requestedLocales) { while (requestedLocales.hasMoreElements()) { Locale locale = requestedLocales.nextElement(); StringManager result = getManager(packageName, locale); if (result.getLocale().equals(locale)) { return result; } } // Return the default return getManager(packageName); } }
/** * If a manager for a package already exists, it will be reused, else a new * StringManager will be created and returned. * * @param packageName The package name * * @return The StringManager for the given package. */ public static final StringManager getManager(String packageName) { return getManager(packageName, Locale.getDefault()); }
/** * Get a string from the underlying resource bundle. * * @param key The resource name */ public String getString(String key) { return MessageFormat.format(getStringInternal(key), (Object [])null); }
/** * The StringManager will be returned for the package in which the class is * located. If a manager for that package already exists, it will be reused, * else a new StringManager will be created and returned. * * @param clazz The class for which to retrieve the StringManager * * @return The StringManager for the given class. */ public static final StringManager getManager(Class<?> clazz) { return getManager(clazz.getPackage().getName()); }
String value = getStringInternal(key);
/** * Get a string from the underlying resource bundle and format it * with the given object arguments. These arguments can of course * be String objects. * * @param key The resource name * @param arg1 Formatting directive * @param arg2 Formatting directive */ public String getString(String key, Object arg1, Object arg2) { Object[] args = new Object[] {arg1, arg2}; return getString(key, args); }
/** * Get the StringManager for a particular package. If a manager for * a package already exists, it will be reused, else a new * StringManager will be created and returned. * * @param packageName The package name */ public static final synchronized StringManager getManager(String packageName) { StringManager mgr = managers.get(packageName); if (mgr == null) { mgr = new StringManager(packageName); managers.put(packageName, mgr); } return mgr; }
/** * Get a string from the underlying resource bundle and format it * with the given object arguments. These arguments can of course * be String objects. * * @param key The resource name * @param arg1 Formatting directive * @param arg2 Formatting directive * @param arg3 Formatting directive */ public String getString(String key, Object arg1, Object arg2, Object arg3) { Object[] args = new Object[] {arg1, arg2, arg3}; return getString(key, args); }
/** * Get the StringManager for a particular package. If a manager for * a package already exists, it will be reused, else a new * StringManager will be created and returned. * * @param packageName The package name */ public static final synchronized StringManager getManager(String packageName) { StringManager mgr = managers.get(packageName); if (mgr == null) { mgr = new StringManager(packageName); managers.put(packageName, mgr); } return mgr; }
/** * Get a string from the underlying resource bundle and format it * with the given object arguments. These arguments can of course * be String objects. * * @param key The resource name * @param arg1 Formatting directive * @param arg2 Formatting directive * @param arg3 Formatting directive * @param arg4 Formatting directive */ public String getString(String key, Object arg1, Object arg2, Object arg3, Object arg4) { Object[] args = new Object[] {arg1, arg2, arg3, arg4}; return getString(key, args); } // --------------------------------------------------------------
mgr = new StringManager(packageName, locale); map.put(locale, mgr);
public void setLength(int size) { if ( size > buf.length ) throw new ArrayIndexOutOfBoundsException(sm.getString("xByteBuffer.size.larger.buffer")); bufSize = size; }
public static boolean contains(byte[] source, int srcoffset, byte[] key, int keyoffset, int length) { if ( srcoffset < 0 || srcoffset >= source.length) throw new ArrayIndexOutOfBoundsException(sm.getString("arrays.srcoffset.outOfBounds")); if ( keyoffset < 0 || keyoffset >= key.length) throw new ArrayIndexOutOfBoundsException(sm.getString("arrays.keyoffset.outOfBounds")); if ( length > (key.length-keyoffset) ) throw new ArrayIndexOutOfBoundsException(sm.getString("arrays.length.outOfBounds")); //we don't have enough data to validate it if ( length > (source.length-srcoffset) ) return false; boolean match = true; int pos = keyoffset; for ( int i=srcoffset; match && i<length; i++ ) { match = (source[i] == key[pos++]); } return match; }
/** * Check if a required property is available. * @param properties The set of properties * @param name The property to check for */ protected void hasProperty(Properties properties, String name){ if ( properties.getProperty(name)==null) throw new IllegalArgumentException(sm.getString("mcastService.missing.property", name)); }
public boolean force(Runnable o) { if (parent != null && parent.isShutdown()) { throw new RejectedExecutionException(sm.getString("executorFactory.not.running")); } // Forces the item onto the queue, to be used if the task is rejected return super.offer(o); }
public void trim(int length) { if ( (bufSize - length) < 0 ) throw new ArrayIndexOutOfBoundsException(sm.getString("xByteBuffer.unableTrim", Integer.toString(bufSize), Integer.toString(length))); bufSize -= length; }
public static byte[] fromString(String value) { if ( value == null ) return null; if ( !value.startsWith("{") ) throw new RuntimeException(sm.getString("arrays.malformed.arrays")); StringTokenizer t = new StringTokenizer(value,"{,}",false); byte[] result = new byte[t.countTokens()]; for (int i=0; i<result.length; i++ ) result[i] = Byte.parseByte(t.nextToken()); return result; }
/** * Adds a channel listener to the channel.<br> * Channel listeners are uniquely identified using the equals(Object) method * @param channelListener ChannelListener */ @Override public void addChannelListener(ChannelListener channelListener) { if (!this.channelListeners.contains(channelListener) ) { this.channelListeners.add(channelListener); } else { throw new IllegalArgumentException(sm.getString("groupChannel.listener.alreadyExist", channelListener,channelListener.getClass().getName())); } }