本文整理汇总了Java中org.databene.commons.IOUtil.readProperties方法的典型用法代码示例。如果您正苦于以下问题:Java IOUtil.readProperties方法的具体用法?Java IOUtil.readProperties怎么用?Java IOUtil.readProperties使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.databene.commons.IOUtil
的用法示例。
在下文中一共展示了IOUtil.readProperties方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkGeneration
import org.databene.commons.IOUtil; //导入方法依赖的package包/类
private void checkGeneration(String database, String stage, boolean shell) throws IOException, InterruptedException {
if (shell)
runFromCommandLine(BENERATOR_FILE, database, "test");
else
runAsClass(BENERATOR_FILE, database, "test");
// connect to database
Map<String, String> dbCfg = IOUtil.readProperties("demo/shop/" + database + "/shop." + database + ".properties");
DefaultBeneratorContext context = new DefaultBeneratorContext();
DBSystem db = new DefaultDBSystem("db", dbCfg.get("dbUri"), dbCfg.get("dbDriver"), dbCfg.get("dbUser"), dbCfg.get("dbPassword"), context.getDataModel());
// check generation results
Map<String, Object> genCfg = IOUtil.readProperties("demo/shop/shop." + stage + ".properties",
new DefaultEntryConverter(context));
int expectedProductCount = 6 + (Integer) genCfg.get("product_count");
int expectedCustomerCount = 1 + (Integer) genCfg.get("customer_count");
int expectedUserCount = 3 + expectedCustomerCount;
int ordersPerCustomer = (Integer) genCfg.get("orders_per_customer");
int expectedOrderCount = (expectedCustomerCount - 1) * ordersPerCustomer + 1;
int itemsPerOrder = (Integer) genCfg.get("items_per_order");
int expectedOrderItemCount = (expectedOrderCount - 1) * itemsPerOrder + 1;
checkEntities("db_category", new CategoryValidator("db_category"), 28, db);
checkEntities("db_product", new ProductValidator("db_product"), expectedProductCount, db);
checkEntities("db_user", new UserValidator("db_user"), expectedUserCount, db);
checkEntities("db_customer", new CustomerValidator("db_customer"), expectedCustomerCount, db);
checkEntities("db_order", new OrderValidator("db_order"), expectedOrderCount, db);
checkEntities("db_order_item", new OrderItemValidator("db_order_item"), expectedOrderItemCount, db);
}
示例2: parseDatasetTypeConfig
import org.databene.commons.IOUtil; //导入方法依赖的package包/类
private synchronized static Map<String, Dataset> parseDatasetTypeConfig(String nesting) {
try {
Map<String, Dataset> sets = new HashMap<String, Dataset>();
Map<String, String> properties = IOUtil.readProperties(nesting + ".set.properties");
for (Map.Entry<String, String> entry : properties.entrySet()) {
String name = entry.getKey();
Dataset dataset = getDataset(nesting, name, sets);
String[] subsetNames = StringUtil.tokenize(entry.getValue(), ',');
for (String subsetName : subsetNames) {
Dataset subset = getDataset(nesting, subsetName, sets);
dataset.addSubSet(subset);
}
}
types.put(nesting, sets);
return sets;
} catch (IOException e) {
throw new ConfigurationError("Setup for Dataset type failed: " + nesting, e);
}
}
示例3: getInstance
import org.databene.commons.IOUtil; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
public static AddressFormat getInstance(String country) {
if (instances.size() == 0) {
try {
IOUtil.readProperties(CONFIG_FILE, new UnsafeConverter<Map.Entry, Map.Entry>(Map.Entry.class, Map.Entry.class) {
@Override
public Entry convert(Entry entry) {
String pt = (String) entry.getValue();
instances.put((String) entry.getKey(), new AddressFormat(pt));
return entry;
}
});
} catch (IOException e) {
throw new ConfigurationError("Error while processing AddressFormat configuration", e);
}
}
return instances.get(country);
}
示例4: FemaleFamilyNameConverter
import org.databene.commons.IOUtil; //导入方法依赖的package包/类
public FemaleFamilyNameConverter(String datasetName) {
super(String.class, String.class);
ArrayBuilder<String[]> builder = new ArrayBuilder<String[]>(String[].class);
try {
if (datasetName != null) {
String dataFileName = DatasetUtil.filenameOfDataset(datasetName,
"/org/databene/domain/person/ffn_{0}.properties");
if (IOUtil.isURIAvailable(dataFileName)) {
Map<String, String> props = IOUtil.readProperties(dataFileName);
for (Map.Entry<String, String> entry : props.entrySet())
builder.add(new String[] { entry.getKey(), entry.getValue() });
}
}
} catch (Exception e) {
logger.debug("No female family name conversion defined for dataset '" + datasetName + "'");
}
this.mappings = builder.toArray();
}
示例5: parseSingleDbProperties
import org.databene.commons.IOUtil; //导入方法依赖的package包/类
public static JDBCConnectData parseSingleDbProperties(String filename) throws IOException {
Map<String, String> properties = IOUtil.readProperties(filename);
String readOnlyConfig = properties.get("db_readonly");
boolean readOnly = (!StringUtil.isEmpty(readOnlyConfig) ? ParseUtil.parseBoolean(readOnlyConfig, true) : false);
return new JDBCConnectData(
properties.get("db_driver"), properties.get("db_url"),
properties.get("db_user"), properties.get("db_password"),
properties.get("db_catalog"), properties.get("db_schema"),
readOnly);
}
示例6: restoreState
import org.databene.commons.IOUtil; //导入方法依赖的package包/类
private void restoreState() {
try {
Map<String, String> props = IOUtil.readProperties(GUI_PROPERTIES_FILE_NAME);
exclusionField.setText(props.get("exclusionPattern"));
} catch (Exception e) {
// no file defined yet, use default settings
}
}
示例7: init
import org.databene.commons.IOUtil; //导入方法依赖的package包/类
private static void init() {
if (IOUtil.isURIAvailable(FILENAME)) {
try {
Map<String, String> values = IOUtil.readProperties(FILENAME);
for (Map.Entry<String, String> entry : values.entrySet())
MAP.put(entry.getKey(), new IncrementalIdGenerator(Long.parseLong(entry.getValue())));
} catch (Exception e) {
throw new ConfigurationError(e);
}
}
}
示例8: setCountry
import org.databene.commons.IOUtil; //导入方法依赖的package包/类
private void setCountry(String countryCode) {
try {
Map<String, String> formats = IOUtil.readProperties("/org/databene/domain/address/postalCodeFormat.properties", Encodings.UTF_8);
pattern = Pattern.compile(formats.get(countryCode));
} catch (IOException e) {
throw new ConfigurationError("Error initializing " + getClass().getSimpleName() +
" with country code '" + countryCode + "'");
}
}
示例9: getEnvironmentData
import org.databene.commons.IOUtil; //导入方法依赖的package包/类
public static Map<String, String> getEnvironmentData(String environment) throws IOException {
return IOUtil.readProperties(environmentFileName(environment));
}
示例10: includeProperties
import org.databene.commons.IOUtil; //导入方法依赖的package包/类
public static void includeProperties(String uri, BeneratorContext context) throws IOException {
logger.debug("Including properties file: " + uri);
ScriptConverterForStrings preprocessor = new ScriptConverterForStrings(context);
DefaultEntryConverter converter = new DefaultEntryConverter(preprocessor, context, true);
IOUtil.readProperties(uri, converter);
}