/** * Load a new {@link ExProperties} object from the given file. */ public static ExProperties load(File file) { return Props.load(file); }
/** * Returns the value as {@link Boolean} of the given key. * * <p> * Returns <code>null</code> if the key not exists of the value is null or empty. */ public static boolean getBoolean(Properties properties,String key){ return get(properties,key,Boolean.class); }
public Boolean getBoolean(String key) { return Props.getBoolean(this, key); }
String text = chars.toString().trim(); if (text.length() > 0) { ExProperties props = Props.loadKeyValues(text);
public Integer getInteger(String key) { return Props.getInteger(this, key); }
/** * Create a new JNDI initial context. Invoked by {@link #getContext}. * <p>The default implementation use this template's environment settings. * Can be subclassed for custom contexts, e.g. for testing. * @return the initial Context instance * @throws NamingException in case of initialization errors */ @SuppressWarnings("rawtypes") protected Context createInitialContext() throws NamingException { Hashtable icEnv = null; Properties env = getEnvironment(); if (env != null) { icEnv = new Hashtable(env.size()); Props.mergePropertiesIntoMap(env, icEnv); } return new InitialContext(icEnv); }
String text = chars.toString().trim(); if(text.length() > 0) { ExProperties props = Props.loadKeyValues(text);
public int getInteger(String key,int defaultValue) { return Props.getInteger(this, key,defaultValue); }
/** * Reads the given properties file. * * @throws NestedIOException if an I/O error occurs. */ public static ExProperties load(File file) throws NestedIOException { return load(file,null); }
/** * Returns the value as {@link Integer} of the given key. * * <p> * Returns <code>null</null> if the key not exists of the value is null or empty. */ public static Integer getInteger(Properties properties,String key){ return get(properties,key,Integer.class); }
public boolean getBoolean(String key,boolean defaultValue) { return Props.getBoolean(this, key,defaultValue); }
/** * Load a new {@link ExProperties} object from the given file. */ public static ExProperties load(File file,Properties defaults) { return Props.load(file); }
/** * Returns the value as {@link Integer} of the given key. * * <p> * Returns the given default value if the key not exists of the value is null or empty. */ public static int getInteger(Properties properties,String key,int defaultValue){ return get(properties,key,Integer.class,defaultValue); }
public I18nHelper(String dir, String defaultBaseName, String locale) { super(defaultBaseName); File file = new File(dir + "_i18n/messages.properties"); if(file.exists()) { this.props.putAll(Props.load(file).toMap()); } file = new File(dir + "_i18n/messages_" + locale + ".properties"); if(file.exists()) { this.props.putAll(Props.load(file).toMap()); } }
/** * Returns the value as {@link Boolean} of the given key. * * <p> * Returns the given default value if the key not exists of the value is null or empty. */ public static boolean getBoolean(Properties properties,String key,boolean defaultValue){ return get(properties,key,Boolean.class,defaultValue); }
private void loadPatterns(Resource r) { if(r.exists()){ ExProperties p = Props.load(r); for(Entry<Object, Object> entry : p.entrySet()){ String name = (String)entry.getKey(); String value = (String)entry.getValue(); if(name.endsWith(FLAGS_SUFFIX)){ continue; } if(name.endsWith(REGEX_SUFFIX)){ name = name.substring(0,name.length() - REGEX_SUFFIX.length()); } addPattern(r, name, value, p.get(name + FLAGS_SUFFIX)); } } }
public <T> T get(String key, Class<T> type) { return Props.get((PropertyGetter)this, key, type); }
protected void initDefaultProperties(ConfigurableEnvironment env) { Map<String, Object> props = new HashMap<>(); for(Resource resource : Resources.scan("classpath*:META-INF/jmms/application.properties")){ props.putAll(Props.load(resource).toMap()); } env.getPropertySources().addLast(new MapPropertySource("jmms-meta-inf-config", props)); }
private void init(Map<String, BeanInfo> beans, String type, String types) { for(Resource resource : Resources.scan("classpath*:META-INF/jmms." + types)) { String url = resource.getURLString(); Map<String, String> nameAndValues = Props.load(resource).toMap(); nameAndValues.forEach((beanName, className) -> { BeanInfo exists = beans.get(beanName); if(null != exists) { throw new IllegalStateException("Found duplicated " + type + " '" + beanName + "' at [ " + exists.url + " , " + url + " ]"); } if(Strings.isEmpty(className)) { throw new IllegalStateException("The class of '" + beanName + "' must not be empty, " + url); } try { Class<?> cls = Classes.forName(className); BeanInfo info = new BeanInfo(); info.cls = cls; info.url = url; beans.put(beanName, info); }catch (Exception e) { throw new IllegalStateException("Invalid class '" + className + "' , " + e.getMessage() + ", " + url); } }); } }
@Override public boolean readProperties(AppPropertyContext context, Resource resource) { String filename = resource.getFilename(); if(Strings.endsWithIgnoreCase(filename, ".properties") || Strings.endsWithIgnoreCase(filename,".properties.xml")) { Props.load(resource).forEach( (key, value) -> putProperty(context, resource, (String)key, (String)value) ); return true; } return false; }