當前位置: 首頁>>代碼示例>>Java>>正文


Java ListResourceBundle類代碼示例

本文整理匯總了Java中java.util.ListResourceBundle的典型用法代碼示例。如果您正苦於以下問題:Java ListResourceBundle類的具體用法?Java ListResourceBundle怎麽用?Java ListResourceBundle使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ListResourceBundle類屬於java.util包,在下文中一共展示了ListResourceBundle類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getResourceBundle

import java.util.ListResourceBundle; //導入依賴的package包/類
/**
 * Gets a resource bundle using the specified base name and locale, and the caller's class loader.
 * @param bundle the base name of the resource bundle, a fully qualified class name
 * @param locale the locale for which a resource bundle is desired
 * @return a resource bundle for the given base name and locale
 */
public static ListResourceBundle getResourceBundle(final String bundle, final Locale locale) {
    return AccessController.doPrivileged(new PrivilegedAction<ListResourceBundle>() {
        public ListResourceBundle run() {
            try {
                return (ListResourceBundle)ResourceBundle.getBundle(bundle, locale);
            } catch (MissingResourceException e) {
                try {
                    return (ListResourceBundle)ResourceBundle.getBundle(bundle, new Locale("en", "US"));
                } catch (MissingResourceException e2) {
                    throw new MissingResourceException(
                            "Could not load any resource bundle by " + bundle, bundle, "");
                }
            }
        }
    });
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:23,代碼來源:SecuritySupport.java

示例2: getResourceBundle

import java.util.ListResourceBundle; //導入依賴的package包/類
/**
 * Gets a resource bundle using the specified base name and locale, and the
 * caller's class loader.
 *
 * @param bundle the base name of the resource bundle, a fully qualified
 * class name
 * @param locale the locale for which a resource bundle is desired
 * @return a resource bundle for the given base name and locale
 */
public static ListResourceBundle getResourceBundle(final String bundle, final Locale locale) {
    return AccessController.doPrivileged(new PrivilegedAction<ListResourceBundle>() {
        public ListResourceBundle run() {
            try {
                return (ListResourceBundle) ResourceBundle.getBundle(bundle, locale);
            } catch (MissingResourceException e) {
                try {
                    return (ListResourceBundle) ResourceBundle.getBundle(bundle, new Locale("en", "US"));
                } catch (MissingResourceException e2) {
                    throw new MissingResourceException(
                            "Could not load any resource bundle by " + bundle, bundle, "");
                }
            }
        }
    });
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:26,代碼來源:SecuritySupport.java

示例3: loadClass

import java.util.ListResourceBundle; //導入依賴的package包/類
/**
 * Loads a resources using JRE and returns the names
 */
private static Set<String> loadClass(String clazz) throws Exception {
    ListResourceBundle lrb =
            (ListResourceBundle)Class.forName(clazz).newInstance();
    Set<String> keys = lrb.keySet();
    Map<String,String> newold = new HashMap<String,String>();
    boolean dup = false;
    // Check if normalize() creates dup entries. This is crucial.
    for (String k: keys) {
        String key = normalize(k);
        if (newold.containsKey(key)) {
            err("Dup found for " + key + ":");
            err("["+newold.get(key)+"]");
            err("["+k+"]");
            dup = true;
        }
        newold.put(key, k);
    }
    if (dup) throw new Exception();
    return keys;
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:24,代碼來源:NewResourcesNames.java

示例4: AbstractConverter

import java.util.ListResourceBundle; //導入依賴的package包/類
/**
 * @deprecated Construtor para AbstractConverter contendo os formatadores de
 *             convers�o padr�o<br>
 *             � altamente recomend�vel que se construa este objeto
 *             informando o resourceBundle de internacionalizacao
 */
public AbstractConverter() {
	logger
			.warn("ATENCAO!! CONSTRUINDO UM RESOURCE BUNDLE COM A INTERNACIONALIZA��O DE "
					+ "FORMATOS PADR�O!!!. ISTO PODE COMPROMETER A PORTABILIDADE DA APLICACAO");

	ResourceBundle resourceBundle = new ListResourceBundle() {
		protected Object[][] getContents() {
			String valores[][] = {
					{ PROPERTY_FORMATO_DATA_VIEW, DEFAULT_FORMATO_DATA },
					{ PROPERTY_DECIMAL_SEPARATOR, DEFAULT_DECIMAL_SEPARATOR },
					{ PROPERTY_GROUPING_SEPARATOR,
							DEFAULT_GROUPING_SEPARATOR },
					{ PROPERTY_FORMATO_SHORT, DEFAULT_FORMATO_SHORT },
					{ PROPERTY_FORMATO_INTEGER, DEFAULT_FORMATO_INTEGER },
					{ PROPERTY_FORMATO_LONG, DEFAULT_FORMATO_LONG },
					{ PROPERTY_FORMATO_FLOAT, DEFAULT_FORMATO_FLOAT },
					{ PROPERTY_FORMATO_DOUBLE, DEFAULT_FORMATO_DOUBLE } };
			return valores;
		}
	};

	setResourceBundle(resourceBundle);
}
 
開發者ID:darciopacifico,項目名稱:omr,代碼行數:30,代碼來源:AbstractConverter.java

示例5: getResourceBundle

import java.util.ListResourceBundle; //導入依賴的package包/類
@POST
@Path( "/wildcard" )
public ResourceBundle getResourceBundle( ResourceBundleRequest resourceBundleRequest ) {
  final List<ResourceBundle> resourceBundles = new ArrayList<ResourceBundle>(  );
  for ( ResourceBundleWildcard resourceBundleWildcard : resourceBundleRequest.getWildcards() ) {
    Pattern keyPattern = Pattern.compile( resourceBundleWildcard.getKeyRegex() );
    resourceBundles.addAll( getResourceBundles( keyPattern, getLocale( resourceBundleRequest.getLocale() ) ) );
  }
  return new ListResourceBundle() {
    @Override protected Object[][] getContents() {
      List<Object[]> entries = new ArrayList<Object[]>();
      for ( ResourceBundle resourceBundle : resourceBundles ) {
        for ( String key : Collections.list( resourceBundle.getKeys() ) ) {
          entries.add( new Object[] { key, resourceBundle.getString( key ) } );
        }
      }
      return entries.toArray( new Object[ entries.size() ][] );
    }
  };
}
 
開發者ID:pentaho,項目名稱:pentaho-osgi-bundles,代碼行數:21,代碼來源:LocalizationWebservice.java

示例6: onCreateActions

import java.util.ListResourceBundle; //導入依賴的package包/類
@Override
public void onCreateActions(ListResourceBundle resources, final BaseEditor baseEditor, IProgressMonitor monitor) {
    PyEdit edit = (PyEdit) baseEditor;
    edit.addOfflineActionListener("--internal-test-modules", new Action() {
        @Override
        public void run() {
            List<IPythonNature> allPythonNatures = PythonNature.getAllPythonNatures();
            StringBuffer buf = new StringBuffer();
            try {
                for (IPythonNature nature : allPythonNatures) {
                    buf.append(checkIntegrity(nature, new NullProgressMonitor(), true));
                }
            } catch (MisconfigurationException e) {
                buf.append(e.getMessage());
            }
            UIUtils.showString(buf.toString());
        }
    }, "Used just for testing (do not use).", true);
}
 
開發者ID:fabioz,項目名稱:Pydev,代碼行數:20,代碼來源:AdditionalInfoIntegrityChecker.java

示例7: notifyOnCreateActions

import java.util.ListResourceBundle; //導入依賴的package包/類
/**
 * Notifies listeners that the actions have just been created in the editor.
 */
public void notifyOnCreateActions(final ListResourceBundle resources) {
    final BaseEditor edit = pyEdit.get();
    if (edit == null) {
        return;
    }
    INotifierRunnable runnable = new INotifierRunnable() {
        @Override
        public void run(final IProgressMonitor monitor) {
            for (IPyEditListener listener : edit.getAllListeners()) {
                try {
                    if (!monitor.isCanceled()) {
                        listener.onCreateActions(resources, edit, monitor);
                    }
                } catch (Exception e) {
                    //must not fail
                    Log.log(e);
                }
            }
        }
    };
    runIt(runnable);
}
 
開發者ID:fabioz,項目名稱:Pydev,代碼行數:26,代碼來源:PyEditNotifier.java

示例8: onCreateActions

import java.util.ListResourceBundle; //導入依賴的package包/類
/**
 * This method associates Ctrl+new line with the evaluation of commands in the console.
 */
@Override
public void onCreateActions(ListResourceBundle resources, final BaseEditor baseEditor, IProgressMonitor monitor) {
    final PyEdit edit = (PyEdit) baseEditor;
    final EvaluateAction evaluateAction = new EvaluateAction(edit);
    evaluateAction.setActionDefinitionId(IInteractiveConsoleConstants.EVALUATE_ACTION_ID);
    evaluateAction.setId(IInteractiveConsoleConstants.EVALUATE_ACTION_ID);
    Runnable runnable = new Runnable() {
        @Override
        public void run() {
            if (!edit.isDisposed()) {
                edit.setAction(IInteractiveConsoleConstants.EVALUATE_ACTION_ID, evaluateAction);
            }
        }
    };
    Display.getDefault().syncExec(runnable);
}
 
開發者ID:fabioz,項目名稱:Pydev,代碼行數:20,代碼來源:EvaluateActionSetter.java

示例9: onCreateActions

import java.util.ListResourceBundle; //導入依賴的package包/類
@Override
public void onCreateActions(ListResourceBundle resources, BaseEditor baseEditor, IProgressMonitor monitor) {
    //Note: can be called multiple times (will only create handlers for the new actions).
    Map<String, InteractiveCommandCustomHandler> commandIdToHandler = InteractiveConsoleCommand
            .getCommandIdToHandler();
    Set<Entry<String, InteractiveCommandCustomHandler>> entrySet = commandIdToHandler.entrySet();
    for (Entry<String, InteractiveCommandCustomHandler> entry : entrySet) {
        if (idToAction.containsKey(entry.getKey())) {
            continue;
        }
        InteractiveConsoleUserCommandAction action = new InteractiveConsoleUserCommandAction(resources,
                "Pyedit.InteractiveConsoleUserCommand", baseEditor, entry.getKey());
        action.setActionDefinitionId(entry.getKey());
        action.setId(entry.getKey());
        baseEditor.setAction(FullRepIterable.getLastPart(entry.getKey()), action);
        idToAction.put(entry.getKey(), action);
    }
    this.resources = resources;
    this.weakEditor = new WeakReference<>(baseEditor);
    InteractiveConsoleCommand.onCommandIdToHandlerChanged.registerListener(onCommandIdToHandlerChangedCallback);
}
 
開發者ID:fabioz,項目名稱:Pydev,代碼行數:22,代碼來源:InteractiveConsoleCommandsSyncListener.java

示例10: setUp

import java.util.ListResourceBundle; //導入依賴的package包/類
@Before
public void setUp() {
	request = mock(HttpServletRequest.class);
	servletContext = mock(ServletContext.class);
	session = mock(HttpSession.class);

	localization = new JstlLocalization(request);

	ResourceBundle bundle = new ListResourceBundle() {
		@Override
		protected Object[][] getContents() {
			return new Object[][] { { "my.key", "abc" } };
		}
	};

	LocalizationContext context = new LocalizationContext(bundle);
	when(request.getAttribute(FMT_LOCALIZATION_CONTEXT + ".request")).thenReturn(context);

	when(request.getSession(false)).thenReturn(session);
	when(request.getServletContext()).thenReturn(servletContext);
}
 
開發者ID:caelum,項目名稱:vraptor4,代碼行數:22,代碼來源:JstlLocalizationTest.java

示例11: call

import java.util.ListResourceBundle; //導入依賴的package包/類
public Object call() throws Exception {
    LogRecord lg = new LogRecord(Level.ALL, getMessage());
    lg.setResourceBundle(new ListResourceBundle() {
        protected Object[][] getContents() {
            return new Object[][] { {getMessage(), getMessage()} };
        }
    });
    return new LogRecord[] { lg };
}
 
開發者ID:wordin0,項目名稱:javacv,代碼行數:10,代碼來源:BaseChildSettings.java

示例12: AbstractConverter

import java.util.ListResourceBundle; //導入依賴的package包/類
/**
 * @deprecated Construtor para AbstractConverter contendo os formatadores de conversao padrAo<br>
 *             e altamente recomendAvel que se construa este objeto informando o resourceBundle de internacionalizacao
 */
public AbstractConverter() {
	logger.warn("ATENCAO!! CONSTRUINDO UM RESOURCE BUNDLE COM A INTERNACIONALIZAcao DE " + "FORMATOS PADRAO!!!. ISTO PODE COMPROMETER A PORTABILIDADE DA APLICACAO");

	ResourceBundle resourceBundle = new ListResourceBundle() {
		protected Object[][] getContents() {
			String valores[][] = { { PROPERTY_FORMATO_DATA_VIEW, DEFAULT_FORMATO_DATA }, { PROPERTY_DECIMAL_SEPARATOR, DEFAULT_DECIMAL_SEPARATOR }, { PROPERTY_GROUPING_SEPARATOR, DEFAULT_GROUPING_SEPARATOR }, { PROPERTY_FORMATO_SHORT, DEFAULT_FORMATO_SHORT }, { PROPERTY_FORMATO_INTEGER, DEFAULT_FORMATO_INTEGER }, { PROPERTY_FORMATO_LONG, DEFAULT_FORMATO_LONG },
					{ PROPERTY_FORMATO_FLOAT, DEFAULT_FORMATO_FLOAT }, { PROPERTY_FORMATO_DOUBLE, DEFAULT_FORMATO_DOUBLE } };
			return valores;
		}
	};

	setResourceBundle(resourceBundle);
}
 
開發者ID:darciopacifico,項目名稱:omr,代碼行數:18,代碼來源:AbstractConverter.java

示例13: getDefaultBuildInfo

import java.util.ListResourceBundle; //導入依賴的package包/類
private static BuildInfo getDefaultBuildInfo() {
  return new BuildInfo(
    new ListResourceBundle() {
      @Override
      public Object[][] getContents() {
        return new Object[][] {
            { "svnVersion", "345M", },
            { "timestamp", "January 1, 2007", },
        };
      }
    });
}
 
開發者ID:google,項目名稱:caja,代碼行數:13,代碼來源:BuildInfoTest.java

示例14: testConvertResourceBundle_add2558

import java.util.ListResourceBundle; //導入依賴的package包/類
@org.junit.Test(timeout = 1000)
public void testConvertResourceBundle_add2558() {
    fr.inria.diversify.testamplification.logger.Logger.writeTestStart(Thread.currentThread(),this, "testConvertResourceBundle_add2558");
    final Map<java.lang.String, java.lang.String> in = new HashMap<java.lang.String, java.lang.String>(5 , 1);
    in.put("1", "A");
    in.put("1", "A");
    in.put("2", "B");
    in.put("3", "C");
    in.put("4", "D");
    in.put("5", "E");
    final ResourceBundle b = new ListResourceBundle() {
        @Override
        public Object[][] getContents() {
            final Object[][] contents = new Object[in.size()][2];
            final Iterator<java.lang.String> i = in.keySet().iterator();
            int n = 0;
            while (i.hasNext()) {
                final Object key = i.next();
                final Object val = in.get(key);
                contents[n][0] = key;
                contents[n][1] = val;
                ++n;
            }
            return contents;
        }
    };
    final Map<java.lang.String, java.lang.Object> out = org.apache.commons.collections4.MapUtils.toMap(b);
    fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),7777,in,7776,in.equals(out));
    fr.inria.diversify.testamplification.logger.Logger.writeTestFinish(Thread.currentThread());
}
 
開發者ID:DIVERSIFY-project,項目名稱:sosiefier,代碼行數:31,代碼來源:MapUtilsTest.java

示例15: testConvertResourceBundle_add2559

import java.util.ListResourceBundle; //導入依賴的package包/類
@org.junit.Test(timeout = 1000)
public void testConvertResourceBundle_add2559() {
    fr.inria.diversify.testamplification.logger.Logger.writeTestStart(Thread.currentThread(),this, "testConvertResourceBundle_add2559");
    final Map<java.lang.String, java.lang.String> in = new HashMap<java.lang.String, java.lang.String>(5 , 1);
    in.put("1", "A");
    in.put("2", "B");
    in.put("2", "B");
    in.put("3", "C");
    in.put("4", "D");
    in.put("5", "E");
    final ResourceBundle b = new ListResourceBundle() {
        @Override
        public Object[][] getContents() {
            final Object[][] contents = new Object[in.size()][2];
            final Iterator<java.lang.String> i = in.keySet().iterator();
            int n = 0;
            while (i.hasNext()) {
                final Object key = i.next();
                final Object val = in.get(key);
                contents[n][0] = key;
                contents[n][1] = val;
                ++n;
            }
            return contents;
        }
    };
    final Map<java.lang.String, java.lang.Object> out = org.apache.commons.collections4.MapUtils.toMap(b);
    fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),7777,in,7776,in.equals(out));
    fr.inria.diversify.testamplification.logger.Logger.writeTestFinish(Thread.currentThread());
}
 
開發者ID:DIVERSIFY-project,項目名稱:sosiefier,代碼行數:31,代碼來源:MapUtilsTest.java


注:本文中的java.util.ListResourceBundle類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。