FileDocCategorySizeDatePackage
LocaleUtilitiesImpl.javaAPI DocAzureus 3.0.3.43567Fri Aug 31 16:59:30 BST 2007org.gudy.azureus2.pluginsimpl.local.utils

LocaleUtilitiesImpl

public class LocaleUtilitiesImpl extends Object implements LocaleUtilities
author
parg

Fields Summary
private PluginInterface
pi
private List
listeners
Constructors Summary
public LocaleUtilitiesImpl(PluginInterface _pi)

		pi	 = _pi;
	
Methods Summary
public voidaddListener(LocaleListener l)

		if ( listeners == null ){
			
			listeners	= new ArrayList();
			
			COConfigurationManager.addParameterListener(
				"locale.set.complete.count", 
				new ParameterListener()
				{
					public void 
					parameterChanged(
						String parameterName )
					{
						for (int i=0;i<listeners.size();i++){
							
							try{
								((LocaleListener)listeners.get(i)).localeChanged( MessageText.getCurrentLocale());
								
							}catch( Throwable e ){
								
								Debug.printStackTrace(e);
							}
						}
					}
				});
		}
		
		listeners.add( l );
	
public java.util.LocalegetCurrentLocale()

		return MessageText.getCurrentLocale();
	
public LocaleDecoder[]getDecoders()

		LocaleUtilDecoder[]	decs = LocaleUtil.getSingleton().getDecoders();
		
		LocaleDecoder[]	res = new LocaleDecoder[decs.length];
		
		for (int i=0;i<res.length;i++){
			
			res[i] = new LocaleDecoderImpl( decs[i] );
		}
		
		return( res );
	
public java.lang.StringgetLocalisedMessageText(java.lang.String key)

		return( MessageText.getString( key ));
	
public java.lang.StringgetLocalisedMessageText(java.lang.String key, java.lang.String[] params)

		return( MessageText.getString( key, params ));
	
public voidintegrateLocalisedMessageBundle(java.lang.String resource_bundle_prefix)

		MessageText.integratePluginMessages(resource_bundle_prefix,pi.getPluginClassLoader());
	
public voidintegrateLocalisedMessageBundle(java.util.ResourceBundle rb)

		MessageText.integratePluginMessages(rb);
	
public voidintegrateLocalisedMessageBundle(java.util.Properties p)

		// Surely there's a more convenient way of doing this?
		ResourceBundle rb = null;
		try {
			PipedInputStream in_stream = new PipedInputStream();
			PipedOutputStream out_stream = new PipedOutputStream(in_stream);
			p.store(out_stream, "");
			out_stream.close();
			rb = new PropertyResourceBundle(in_stream);
			in_stream.close();
		}
		catch (IOException ioe) {return;}
		integrateLocalisedMessageBundle(rb);
	
public voidremoveListener(LocaleListener l)

		if ( listeners == null ){
			
			return;
		}
		
		listeners.remove(l);