From 9d220d1066e73afdfaf3d2dd199ea335c0528bc7 Mon Sep 17 00:00:00 2001 From: LamGC Date: Sun, 11 Oct 2020 03:58:16 +0800 Subject: [PATCH] =?UTF-8?q?[Add]=20Framework-API=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E4=B8=80=E4=B8=AA=E5=88=9D=E5=AE=9A=E7=9A=84=20ResourceBundle?= =?UTF-8?q?=20=E5=B7=A5=E5=8E=82=E6=8E=A5=E5=8F=A3,=20=E4=BB=A5=E5=85=81?= =?UTF-8?q?=E8=AE=B8=E6=A1=86=E6=9E=B6=E6=8C=87=E5=AE=9A=20ResourceBundle;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [Add] ResourceBundleFactory 添加初定的 ResourceBundle 工厂接口; --- .../bot/framework/ResourceBundleFactory.java | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 ContentGrabbingJi-framework-api/src/main/java/net/lamgc/cgj/bot/framework/ResourceBundleFactory.java diff --git a/ContentGrabbingJi-framework-api/src/main/java/net/lamgc/cgj/bot/framework/ResourceBundleFactory.java b/ContentGrabbingJi-framework-api/src/main/java/net/lamgc/cgj/bot/framework/ResourceBundleFactory.java new file mode 100644 index 0000000..41e2717 --- /dev/null +++ b/ContentGrabbingJi-framework-api/src/main/java/net/lamgc/cgj/bot/framework/ResourceBundleFactory.java @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2020 LamGC + * + * ContentGrabbingJi is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * ContentGrabbingJi is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package net.lamgc.cgj.bot.framework; + +import java.util.Locale; +import java.util.MissingResourceException; +import java.util.ResourceBundle; + +/** + * ResourceBundle 构造工厂接口. + * 如实现该接口, 可允许让 Core 使用框架自带的 ResourceBundle, 而不使用全局范围的 ResourceBundle. + * @author LamGC + */ +public interface ResourceBundleFactory { + + /** + * 获取指定 Locale 的 ResourceBundle 对象. + * @param locale 地区对象. + * @return 返回 ResourceBundle 对象. + * @throws MissingResourceException 如果无法找到地区对应的 ResourceBundle 的同时, + * 也无法获取 Default ResourceBundle 的话可抛出该异常. + * 当 Core 捕获到该异常时, 将会使用全局范围的 ResourceBundle. + */ + ResourceBundle getBundle(Locale locale) throws MissingResourceException; + +}