Java Properties Parse parseBooleanProperty(Properties props, String keyword, boolean defaultValue)

Here you can find the source of parseBooleanProperty(Properties props, String keyword, boolean defaultValue)

Description

parse Boolean Property

License

Open Source License

Declaration

public static boolean parseBooleanProperty(Properties props,
            String keyword, boolean defaultValue) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.*;

public class Main {
    public static boolean parseBooleanProperty(Properties props,
            String keyword, boolean defaultValue) {
        return parseBoolean(props != null ? props.getProperty(keyword)
                : null, defaultValue);/*from w  w  w .ja  v a 2s .co  m*/
    }

    public static boolean parseBoolean(String text, boolean defaultValue) {
        Boolean value = null;
        if (text != null) {
            value = Boolean.valueOf(text);
        }
        return value != null ? value.booleanValue() : defaultValue;
    }

    public static String getProperty(Properties props, String keyword) {
        String rv = null;
        if (props != null) {
            rv = props.getProperty(keyword);
        }
        if (rv != null) {
            if (rv.trim().isEmpty()) {
                rv = "";
            }
        } else {
            rv = "";
        }
        return rv;
    }
}

Related

  1. parseHtmlProperties(String s)
  2. parseProperties(final String string)
  3. parsePropertiesString(String s)
  4. parseProps(Properties p)