📄 resourcebundledatapropertyhandlerutil.java
字号:
/*
* ResourceBundleDataPropertyHandlerUtil.java
*
* Created on 2002/08/13, 10:07
*/
package jp.co.intra_mart.framework.base.data;
import java.util.Enumeration;
import java.util.ResourceBundle;
import java.util.Vector;
import java.util.MissingResourceException;
/**
* 巜掕偝傟偨儕僜乕僗僶儞僪儖偐傜僨乕僞僾儘僷僥傿傪庢摼偡傞儐乕僥傿儕僥傿偱偡丅
*
* @author INTRAMART
* @since 3.2
*/
class ResourceBundleDataPropertyHandlerUtil {
/**
* DAO偺僋儔僗柤傪庢摼偟傑偡丅
* <CODE>application</CODE>丄<CODE>key</CODE>偲<CODE>connect</CODE>偱巜掕偝傟偨DAO偺僋儔僗柤傪庢摼偟傑偡丅
*
* @param applicationBundle 傾僾儕働乕僔儑儞偺儕僜乕僗僶儞僪儖
* @param application 傾僾儕働乕僔儑儞ID
* @param key DAO偺僉乕
* @param connect 愙懕忣曬
* @return DAO偺僋儔僗柤
* @throws DataPropertyException DAO偺僋儔僗柤偺庢摼偵幐攕
*/
public static String getDAOName(ResourceBundle applicationBundle, String application, String key, String connect) throws DataPropertyException {
String name;
try {
name = applicationBundle.getString("dao.class." + key + "." + connect);
} catch (MissingResourceException e) {
try {
name = applicationBundle.getString("dao.class." + key);
} catch (MissingResourceException ex) {
String message = null;
try {
ResourceBundle messageBundle = ResourceBundle.getBundle("jp.co.intra_mart.framework.base.data.i18n");
message = messageBundle.getString("ResourceBundleDataPropertyHandlerUtil.param.DAOClassNotDeclared");
} catch (MissingResourceException exc) {
}
throw new DataPropertyException(message + " : application = " + application + ", key = " + key + ", connect = " + connect, ex);
}
}
return name;
}
/**
* DAO偵懳偡傞僨乕僞僐僱僋僞柤傪庢摼偟傑偡丅
* <CODE>application</CODE>丄<CODE>key</CODE>偲<CODE>connect</CODE>偱巜掕偝傟偨DAO偺僨乕僞僐僱僋僞柤傪庢摼偟傑偡丅
* 懳墳偡傞僨乕僞僐僱僋僞柤偑巜掕偝傟偰偄側偄応崌丄null偑曉傝傑偡丅
*
* @param applicationBundle 傾僾儕働乕僔儑儞偺儕僜乕僗僶儞僪儖
* @param application 傾僾儕働乕僔儑儞ID
* @param key DAO偺僉乕
* @param connect 愙懕忣曬
* @return 僨乕僞僐僱僋僞偺柤慜
* @throws DataPropertyException 僨乕僞僐僱僋僞柤偺庢摼帪偵椺奜偑敪惗
*/
public static String getConnectorName(ResourceBundle applicationBundle, String application, String key, String connect) throws DataPropertyException {
String name;
try {
name = applicationBundle.getString("dao.connector." + key + "." + connect);
} catch (MissingResourceException e) {
try {
name = applicationBundle.getString("dao.connector." + key);
} catch (MissingResourceException ex) {
try {
name = applicationBundle.getString("dao.connector");
} catch (MissingResourceException exc) {
name = null;
}
}
}
return name;
}
/**
* 僨乕僞僐僱僋僞偺僋儔僗柤傪庢摼偟傑偡丅
* <CODE>application</CODE>丄<CODE>key</CODE>偲<CODE>connect</CODE>偱巜掕偝傟偨僨乕僞僐僱僋僞偺僋儔僗柤傪庢摼偟傑偡丅
*
* @param commonBundle 嫟捠偺儕僜乕僗僶儞僪儖
* @param connectorName 僨乕僞僐僱僋僞柤
* @return 僨乕僞僐僱僋僞偺僋儔僗柤
* @throws DataPropertyException 僨乕僞僐僱僋僞偺僋儔僗柤偺庢摼偵幐攕
*/
public static String getConnectorClassName(ResourceBundle commonBundle, String connectorName) throws DataPropertyException {
String name;
try {
name = commonBundle.getString("connector.class." + connectorName);
} catch (MissingResourceException e) {
String message = null;
try {
message = ResourceBundle.getBundle("jp.co.intra_mart.framework.base.data.i18n").getString("ResourceBundleDataPropertyHandlerUtil.param.ConnectorClassNotDeclared");
} catch (MissingResourceException ex) {
}
throw new DataPropertyException(message + " : Connector name = " + connectorName, e);
}
return name;
}
/**
* 僨乕僞僐僱僋僞偺儕僜乕僗柤傪庢摼偟傑偡丅
* <CODE>application</CODE>丄<CODE>key</CODE>偲<CODE>connect</CODE>偱巜掕偝傟偨僨乕僞僐僱僋僞偺儕僜乕僗柤傪庢摼偟傑偡丅
* 懳墳偡傞儕僜乕僗柤偑側偄応崌丄null傪曉偟傑偡丅
*
* @param commonBundle 嫟捠偺儕僜乕僗僶儞僪儖
* @param connectorName 僨乕僞僐僱僋僞柤
* @return 僨乕僞僐僱僋僞偺儕僜乕僗柤
* @throws DataPropertyException 僨乕僞僐僱僋僞偺儕僜乕僗柤偺庢摼帪偵椺奜偑敪惗
*/
public static String getConnectorResource(ResourceBundle commonBundle, String connectorName) throws DataPropertyException {
String name;
try {
name = commonBundle.getString("connector.resource." + connectorName);
} catch (MissingResourceException ex) {
name = null;
}
return name;
}
/**
* 儕僜乕僗偺僷儔儊乕僞傪庢摼偟傑偡丅
* <CODE>name</CODE>偱巜掕偝傟偨儕僜乕僗偺僷儔儊乕僞傪庢摼偟傑偡丅
*
* @param commonBundle 嫟捠偺儕僜乕僗僶儞僪儖
* @param name 儕僜乕僗柤
* @return 儕僜乕僗偺僷儔儊乕僞
* @throws DataPropertyException 儕僜乕僗偺僷儔儊乕僞偺庢摼帪偵椺奜偑敪惗
*/
public static ResourceParam[] getResourceParams(ResourceBundle commonBundle, String name) throws DataPropertyException {
ResourceParam[] result;
String prefix = "resource.param." + name + ".";
Enumeration keys = commonBundle.getKeys();
String key;
String paramName;
String value;
ResourceParam param;
Vector params = new Vector();
while (keys.hasMoreElements()) {
key = (String)keys.nextElement();
if (key.startsWith(prefix)) {
paramName = key.substring(prefix.length());
try {
value = commonBundle.getString(key);
} catch (MissingResourceException e) {
String message = null;
try {
message = ResourceBundle.getBundle("jp.co.intra_mart.framework.base.data.i18n").getString("ResourceBundleDataPropertyHandlerUtil.param.ResourceDetailNotDeclared");
} catch (MissingResourceException ex) {
}
throw new DataPropertyException(message + " : resource name = " + name, e);
}
param = new ResourceParam();
param.setName(paramName);
param.setValue(value);
params.add(param);
}
}
result = new ResourceParam[params.size()];
for (int i = 0; i < params.size(); i++) {
result[i] = (ResourceParam)params.get(i);
}
return result;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -