当前位置: 首页>>代码示例>>Java>>正文


Java ResourceBundle类代码示例

本文整理汇总了Java中java.util.ResourceBundle的典型用法代码示例。如果您正苦于以下问题:Java ResourceBundle类的具体用法?Java ResourceBundle怎么用?Java ResourceBundle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ResourceBundle类属于java.util包,在下文中一共展示了ResourceBundle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initialize

import java.util.ResourceBundle; //导入依赖的package包/类
@Override
public void initialize(URL url, ResourceBundle rb) {
    recips.setAll(dao.getRecipients());
    topics.setAll(sns.getTopics());

    type.setItems(types);
    recipList.setItems(recips);
    topicCombo.setItems(topics);

    recipList.setCellFactory(p -> new ListCell<Recipient>() {
        @Override
        public void updateItem(Recipient recip, boolean empty) {
            super.updateItem(recip, empty);
            if (!empty) {
                setText(String.format("%s - %s", recip.getType(), recip.getAddress()));
            } else {
                setText(null);
            }
        }
    });
    recipList.getSelectionModel().selectedItemProperty().addListener((obs, oldRecipient, newRecipient) -> {
        type.valueProperty().setValue(newRecipient != null ? newRecipient.getType() : "");
        address.setText(newRecipient != null ? newRecipient.getAddress() : "");
    });
}
 
开发者ID:PacktPublishing,项目名称:Java-9-Programming-Blueprints,代码行数:26,代码来源:CloudNoticeManagerController.java

示例2: of

import java.util.ResourceBundle; //导入依赖的package包/类
public static LogEvent of(long sequenceNumber,
        boolean isLoggable, String name,
        Level level, ResourceBundle bundle,
        String key, Supplier<String> supplier,
        Throwable thrown, Object... params) {
    LogEvent evt = new LogEvent(sequenceNumber);
    evt.loggerName = name;
    evt.level = level;
    evt.args = params;
    evt.bundle = bundle;
    evt.thrown = thrown;
    evt.supplier = supplier;
    evt.msg = key;
    evt.isLoggable = isLoggable;
    return evt;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:BaseLoggerBridgeTest.java

示例3: get

import java.util.ResourceBundle; //导入依赖的package包/类
public String get(String key) {
	String ret;
	try {
		ret = locale.getString(key);
	} catch (MissingResourceException e) {
		ResourceBundle backup = dflt_locale;
		if (backup == null) {
			Locale backup_loc = Locale.US;
			backup = ResourceBundle.getBundle(dir_name + "/en/" + file_start, backup_loc);
			dflt_locale = backup;
		}
		try {
			ret = backup.getString(key);
		} catch (MissingResourceException e2) {
			ret = key;
		}
	}
	HashMap<Character, String> repl = LocaleManager.repl;
	if (repl != null)
		ret = replaceAccents(ret, repl);
	return ret;
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:23,代码来源:LocaleManager.java

示例4: setLocale

import java.util.ResourceBundle; //导入依赖的package包/类
/**
     * Changes the locale of the messages.
     * 
     * @param locale
     *            Locale the locale to change to.
     */
    static public ResourceBundle setLocale(final Locale locale,
            final String resource) {
//        try {
//            final ClassLoader loader = VM.bootCallerClassLoader();
//            return (ResourceBundle) AccessController
//                    .doPrivileged(new PrivilegedAction<Object>() {
//                        public Object run() {
//                            return ResourceBundle.getBundle(resource, locale,
//                                    loader != null ? loader : ClassLoader.getSystemClassLoader());
//                        }
//                    });
//        } catch (MissingResourceException e) {
//        }
        return null;
    }
 
开发者ID:yippeesoft,项目名称:NotifyTools,代码行数:22,代码来源:Messages.java

示例5: getValue

import java.util.ResourceBundle; //导入依赖的package包/类
@Override
public Object getValue(ELContext context, Object base, Object property)
		throws NullPointerException, PropertyNotFoundException, ELException {

	if (context == null) {
		throw new NullPointerException();
	}

	if (base instanceof ResourceBundle) {
		context.setPropertyResolved(true);

		if (property != null) {
			try {
				return ((ResourceBundle) base).getObject(property.toString());
			} catch (MissingResourceException mre) {
				return "???" + property.toString() + "???";
			}
		}
	}

	return null;
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:23,代码来源:ResourceBundleELResolver.java

示例6: getCalendarData

import java.util.ResourceBundle; //导入依赖的package包/类
int getCalendarData(String key) {
    Integer caldata;
    String cacheKey = CALENDAR_DATA  + key;

    removeEmptyReferences();

    ResourceReference data = cache.get(cacheKey);
    if (data == null || ((caldata = (Integer) data.get()) == null)) {
        ResourceBundle rb = localeData.getCalendarData(locale);
        if (rb.containsKey(key)) {
            caldata = Integer.parseInt(rb.getString(key));
        } else {
            caldata = 0;
        }

        cache.put(cacheKey,
                  new ResourceReference(cacheKey, (Object) caldata, referenceQueue));
    }

    return caldata;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:LocaleResources.java

示例7: getResourceBundle

import java.util.ResourceBundle; //导入依赖的package包/类
/**
 * Search current thread classloader for the resource bundle. If not found,
 * search validator (this) classloader.
 *
 * @param locale The locale of the bundle to load.
 * @return the resource bundle or <code>null</code> if none is found.
 */
@Override
public ResourceBundle getResourceBundle(Locale locale) {
    ResourceBundle rb = null;
    ClassLoader classLoader = GetClassLoader.fromContext();
    if (classLoader != null) {
        rb = loadBundle(
                classLoader, locale, bundleName
                        + " not found by thread local classloader"
        );
    }
    if (rb == null) {
        classLoader = GetClassLoader.fromClass(PlatformResourceBundleLocator.class);
        rb = loadBundle(
                classLoader, locale, bundleName
                        + " not found by validator classloader"
        );
    }
    if (rb != null) {
        log.debug(bundleName + " found.");
    } else {
        log.debug(bundleName + " not found.");
    }
    return rb;
}
 
开发者ID:devefx,项目名称:validator-web,代码行数:32,代码来源:PlatformResourceBundleLocator.java

示例8: getToolBox

import java.util.ResourceBundle; //导入依赖的package包/类
public static UIToolBox getToolBox() {
    if (toolBox == null) {
        Services services = getInjector().getInstance(Services.class);
        ResourceBundle bundle = ResourceBundle.getBundle("i18n",
                Locale.getDefault());

        // We're using less!! Load it using our custom loader
        LessCSSLoader lessLoader = new LessCSSLoader();
        String stylesheet = lessLoader.loadLess(Initializer.class.getResource("/less/annotation.less"))
                .toExternalForm();
        toolBox = new UIToolBox(new Data(),
                services,
                new EventBus(),
                bundle,
                getConfig(),
                Arrays.asList(stylesheet));
    }
    return toolBox;
}
 
开发者ID:mbari-media-management,项目名称:vars-annotation,代码行数:20,代码来源:Initializer.java

示例9: initialize

import java.util.ResourceBundle; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public void initialize(URL location, ResourceBundle resources) {
    // Initializes test base, tester and test map to access and modify the algorithm base
    testBase = TestBase.INSTANCE;   // Gets a reference to the test base
    tester = new Tester();          //
    testMap = tester.getTestMap();

    // Binds the list view with a list of algorithms (list items)
    listItems = FXCollections.observableList(new ArrayList<>(testMap.keySet()));
    list.itemsProperty().bindBidirectional(new SimpleListProperty<>(listItems));
    list.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
    list.getSelectionModel().selectedItemProperty().addListener((((observable, oldValue, newValue) -> {
        if(newValue != null) {
            textArea.setText(testMap.get(newValue).getContent());
        } else {
            textArea.clear();
        }
    })));
    list.getSelectionModel().select(0);

    // Initializes the trie that stores all algorithm names
    algorithmNameTrie = new Trie();
    for(String algorithmName : testMap.keySet()) {
        algorithmNameTrie.addWord(algorithmName);
    }

    // Binds search field with the list view (displays search result)
    searchField.textProperty().addListener((observable, oldValue, newValue) -> {
        listItems.setAll(algorithmNameTrie.getWords(newValue.toLowerCase()));
        if(!listItems.isEmpty()) {
            list.getSelectionModel().select(0);
        }
    });

    // For unknown reasons, this style does not work on css, so I put it in here
    textArea.setStyle("-fx-focus-color: transparent; -fx-text-box-border: transparent;");
    textArea.setFocusTraversable(false);
}
 
开发者ID:kinmanlui,项目名称:code-tracker,代码行数:40,代码来源:MainController.java

示例10: getMessage

import java.util.ResourceBundle; //导入依赖的package包/类
/**
 * Get a message localized to the specified locale, using the message ID
 * and package name if no message is available.  The locale is normally
 * that of the client of a service, chosen with knowledge that both the
 * client and this server support that locale.  There are two error
 * cases:  first, when the specified locale is unsupported or null, the
 * default locale is used if possible; second, when no bundle supports
 * that locale, the message ID and package name are used.
 *
 * @param locale    The locale of the message to use.  If this is null,
 *                  the default locale will be used.
 * @param messageId The ID of the message to use.
 * @return The message, localized as described above.
 */
public String getMessage(Locale locale,
                         String messageId) {
    ResourceBundle bundle;

    // cope with unsupported locale...
    if (locale == null)
        locale = Locale.getDefault();

    try {
        bundle = ResourceBundle.getBundle(bundleName, locale);
    } catch (MissingResourceException e) {
        bundle = ResourceBundle.getBundle(bundleName, Locale.ENGLISH);
    }
    return bundle.getString(messageId);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:30,代码来源:MessageCatalog.java

示例11: initialize

import java.util.ResourceBundle; //导入依赖的package包/类
@Override
public void initialize(URL location, ResourceBundle resources) {
	// TODO Auto-generated method stub
	/* Drag and Drop */
       borderPane.setOnMousePressed(event -> {
           xOffset = getLocalStage().getX() - event.getScreenX();
           yOffset = getLocalStage().getY() - event.getScreenY();
           borderPane.setCursor(Cursor.CLOSED_HAND);
       });
       borderPane.setOnMouseDragged(event -> {
       	getLocalStage().setX(event.getScreenX() + xOffset);
       	getLocalStage().setY(event.getScreenY() + yOffset);
       });
       borderPane.setOnMouseReleased(event -> {
           borderPane.setCursor(Cursor.DEFAULT);
       });
       //设置图标
       setIcon("images/icon_chatroom.png");
}
 
开发者ID:Laity000,项目名称:ChatRoom-JavaFX,代码行数:20,代码来源:ChatController.java

示例12: LogEvent

import java.util.ResourceBundle; //导入依赖的package包/类
private LogEvent(BootstrapLogger bootstrap,
        PlatformLogger.Level platformLevel,
        String sourceClass, String sourceMethod,
        ResourceBundle bundle, String msg,
        Throwable thrown, Object[] params) {
    this.acc = AccessController.getContext();
    this.timeMillis = System.currentTimeMillis();
    this.nanoAdjustment = VM.getNanoTimeAdjustment(timeMillis);
    this.level = null;
    this.platformLevel = platformLevel;
    this.bundle = bundle;
    this.msg = msg;
    this.msgSupplier = null;
    this.thrown = thrown;
    this.params = params;
    this.sourceClass = sourceClass;
    this.sourceMethod = sourceMethod;
    this.bootstrap = bootstrap;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:BootstrapLogger.java

示例13: loadDailyCost

import java.util.ResourceBundle; //导入依赖的package包/类
/**
 * loads the daily fuel cost for this unit from a resourcebundle
 * for use in constructor for setDailyCost()
 *
 * @return maximum mobility value for the unit
 */
private int loadDailyCost() {
    if (this instanceof HiddenUnit) {
        HiddenUnit me = (HiddenUnit) this;
        Unit cont = (me).getContainedUnit();
        return (cont.loadDailyCost());
    }
    ResourceBundle b = ResourceBundle.getBundle("unit_daily_fuel");
    try {
        double ans = Double.parseDouble(b.getString(getType()));
        return (int) (this.owner.CO.passive(ans, COFlag.DAILY_COST, getUnitType()));
    } catch (NumberFormatException e) {
        System.out.println(e.getStackTrace());
        System.out.println("Method: Unit.loadDailyCost()");
        throw new RuntimeException("Corrupt File");
    }
}
 
开发者ID:CBSkarmory,项目名称:AWGW,代码行数:23,代码来源:Unit.java

示例14: initialize

import java.util.ResourceBundle; //导入依赖的package包/类
@Override
public void initialize(URL url, ResourceBundle rb) {
    // TODO
    test.setVisible(false);
    date.setVisible(false);
    time.setVisible(false);
    code_output.setVisible(false);
    btnRun.setVisible(false);
    time.setText("test time");
    problem_tabs.setVisible(false);
    
    Date d = new Date();
    SimpleDateFormat sdf = new SimpleDateFormat("MMM d, ''yy");
    String sd=sdf.format(d);
    date.setText(sd);
    //startTimer();
    //problemView.getEngine().loadContent("<h1>HELLO WORLD<h1>");
}
 
开发者ID:JMurf,项目名称:NetCompile,代码行数:19,代码来源:TestSceneController.java

示例15: applyFilters

import java.util.ResourceBundle; //导入依赖的package包/类
protected void applyFilters(List<FilterField> filterFields,
        Pagination pagination) {
    Set<Filter> filters = new HashSet<>();
    FacesContext facesContext = FacesContext.getCurrentInstance();
    for (FilterField filterField : filterFields) {
        String propertyName = (String) filterField.getFilterExpression()
                .getValue(facesContext.getELContext());
        Object filterValue = filterField.getFilterValue();

        if (filterValue == null || filterValue.equals("")) {
            continue;
        }
        Filter filter = new Filter(columnNamesMapping.get(propertyName),
                filterValue.toString());
        filters.add(filter);
    }
    ResourceBundle bundle = facesContext.getApplication()
            .getResourceBundle(facesContext, Constants.BUNDLE_NAME);
    pagination.setDateFormat(bundle
            .getString(ApplicationBean.DatePatternEnum.DATE_INPUT_PATTERN
                    .getMessageKey()));
    pagination.setFilterSet(filters);
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:24,代码来源:RichLazyDataModel.java


注:本文中的java.util.ResourceBundle类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。