Examples of FlexibleProperties


Examples of org.ofbiz.base.util.collections.FlexibleProperties

     * @return The properties file
     */
    public static Properties getProperties(String resource) {
        if (resource == null || resource.length() <= 0)
            return null;
        FlexibleProperties properties = resourceCache.get(resource);

        if (properties == null) {
            try {
                URL url = UtilURL.fromResource(resource);

View Full Code Here

Examples of org.ofbiz.base.util.collections.FlexibleProperties

     * @return The properties file
     */
    public static Properties getProperties(URL url) {
        if (url == null)
            return null;
        FlexibleProperties properties = urlCache.get(url.toString());

        if (properties == null) {
            try {
                properties = FlexibleProperties.makeFlexibleProperties(url);
                urlCache.put(url.toString(), properties);
View Full Code Here

Examples of org.ofbiz.base.util.collections.FlexibleProperties

            } catch (MalformedURLException e) {
                Debug.logError(e, module);
            }

            if (propsURL != null) {
                props = new FlexibleProperties(propsURL);
                Debug.logWarning("[VelocityViewHandler.init] : Loaded /WEB-INF/velocity.properties", module);
            } else {
                props = new Properties();
                Debug.logWarning("[VelocityViewHandler.init] : Cannot load /WEB-INF/velocity.properties. " +
                    "Using default properties.", module);
View Full Code Here

Examples of org.ofbiz.base.util.collections.FlexibleProperties

     * @return The value of the property in the properties file
     */
    public static String getPropertyValue(String resource, String name) {
        if (resource == null || resource.length() <= 0) return "";
        if (name == null || name.length() <= 0) return "";
        FlexibleProperties properties = (FlexibleProperties) resourceCache.get(resource);

        if (properties == null) {
            try {
                URL url = UtilURL.fromResource(resource);

                if (url == null) return "";
                properties = FlexibleProperties.makeFlexibleProperties(url);
                resourceCache.put(resource, properties);
            } catch (MissingResourceException e) {
                Debug.log(e.getMessage(), module);
            }
        }
        if (properties == null) {
            Debug.log("[UtilProperties.getPropertyValue] could not find resource: " + resource, module);
            return "";
        }

        String value = null;

        try {
            value = properties.getProperty(name);
        } catch (Exception e) {
            Debug.log(e.getMessage(), module);
        }
        return value == null ? "" : value.trim();
    }  
View Full Code Here

Examples of org.ofbiz.base.util.collections.FlexibleProperties

     * @return The value of the property in the properties file
     */
    public static String getPropertyValue(URL url, String name) {
        if (url == null) return "";
        if (name == null || name.length() <= 0) return "";
        FlexibleProperties properties = (FlexibleProperties) urlCache.get(url);

        if (properties == null) {
            try {
                properties = FlexibleProperties.makeFlexibleProperties(url);
                urlCache.put(url, properties);
            } catch (MissingResourceException e) {
                Debug.log(e.getMessage(), module);
            }
        }
        if (properties == null) {
            Debug.log("[UtilProperties.getPropertyValue] could not find resource: " + url, module);
            return null;
        }

        String value = null;

        try {
            value = properties.getProperty(name);
        } catch (Exception e) {
            Debug.log(e.getMessage(), module);
        }
        return value == null ? "" : value.trim();
    }
View Full Code Here

Examples of org.ofbiz.base.util.collections.FlexibleProperties

     */
    public static String getSplitPropertyValue(URL url, String name) {
        if (url == null) return "";
        if (name == null || name.length() <= 0) return "";

        FlexibleProperties properties = (FlexibleProperties) urlCache.get(url);

        if (properties == null) {
            try {
                properties = FlexibleProperties.makeFlexibleProperties(url);
                urlCache.put(url, properties);
            } catch (MissingResourceException e) {
                Debug.log(e.getMessage(), module);
            }
        }
        if (properties == null) {
            Debug.log("[UtilProperties.getPropertyValue] could not find resource: " + url, module);
            return null;
        }

        String value = null;

        try {
            int curIdx = 1;
            String curName = null;

            while ((curName = properties.getProperty("name." + curIdx)) != null) {
                if (name.equals(curName)) {
                    value = properties.getProperty("value." + curIdx);
                    break;
                }
                curIdx++;
            }
        } catch (Exception e) {
View Full Code Here

Examples of org.ofbiz.base.util.collections.FlexibleProperties

    * @param name The name of the property in the properties file
    * @param value The value of the property in the properties file */
    public static void setPropertyValue(String resource, String name, String value) {
        if (resource == null || resource.length() <= 0) return;
        if (name == null || name.length() <= 0) return;
        FlexibleProperties properties = (FlexibleProperties) resourceCache.get(resource);

        if (properties == null) {
            try {
                URL url = UtilURL.fromResource(resource);

                if (url == null) return;
                properties = FlexibleProperties.makeFlexibleProperties(url);
                resourceCache.put(resource, properties);
            } catch (MissingResourceException e) {
                Debug.log(e.getMessage(), module);
            }
        }

        if (properties == null) {
            Debug.log("[UtilProperties.setPropertyValue] could not find resource: " + resource, module);
            return;
        }

        try {
            properties.setProperty(name, value);
            FileOutputStream propFile = new FileOutputStream(resource);
            properties.store(propFile,            
            "##############################################################################\n"
            +"# Licensed to the Apache Software Foundation (ASF) under one                   \n"
            +"# or more contributor license agreements.  See the NOTICE file                 \n"
            +"# distributed with this work for additional information                        \n"
            +"# regarding copyright ownership.  The ASF licenses this file                   \n"
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.