Example usage for java.util Properties clear

List of usage examples for java.util Properties clear

Introduction

In this page you can find the example usage for java.util Properties clear.

Prototype

@Override
    public synchronized void clear() 

Source Link

Usage

From source file:Main.java

public static void loadAttributesFromNode(Node node, Properties attrs) {
    attrs.clear();
    Element elem = (Element) node;
    NodeList list = elem.getElementsByTagName(TAG_ATTR);
    for (int i = 0; i < list.getLength(); i++) {
        String text = getTextTag(list.item(i));
        String[] s = text.split("=");
        if (s.length >= 2) {
            attrs.setProperty(s[0], s[1]);
        }//  www.  j ava2s  .c  om
    }
}

From source file:com.asakusafw.cleaner.testutil.UnitTestUtil.java

public static void tearDownEnv() throws Exception {
    Properties p = System.getProperties();
    p.clear();
    ConfigurationLoader.setSysProp(p);/*from w ww . ja va 2 s. c om*/
    System.setProperties(p);
}

From source file:io.fabric8.profiles.ProfilesHelpers.java

public static void merge(Properties target, Properties source) {
    if (source.contains(DELETED)) {
        target.clear();
    } else {//from w ww .ja v  a  2  s . c o m
        for (Map.Entry<Object, Object> entry : source.entrySet()) {
            if (DELETED.equals(entry.getValue())) {
                target.remove(entry.getKey());
            } else {
                target.put(entry.getKey(), entry.getValue());
            }
        }
    }
}

From source file:eu.scidipes.toolkits.pawebapp.util.FrameworkUtils.java

/**
 * Returns a map that holds an inner map per FormType (e.g. Document, Software etc) of user friendly type-names
 * (e.g. 'PDF') to actual RILs//w  ww.  ja  va2  s .c o  m
 * 
 * @return a map of type 'groups' to 'friendly' type names to RILs
 * @throws IOException
 */
public static Map<FormType, Map<String, CurationPersistentIdentifier>> getRILsByType() throws IOException {

    /* The return Map, e.g. "DOC" -> "PDF" - RIL1 */
    final Map<FormType, Map<String, CurationPersistentIdentifier>> rilMap = new HashMap<>();

    final Properties props = new Properties();
    props.load(FrameworkUtils.class.getResourceAsStream("/rin/doc_type_rilcpids.properties"));
    populateMapFromRILProps(props, rilMap, FormType.DOCUMENT);

    props.clear();
    props.load(FrameworkUtils.class.getResourceAsStream("/rin/software_langs_rilcpids.properties"));
    populateMapFromRILProps(props, rilMap, FormType.SOFTWARE);

    props.clear();
    props.load(FrameworkUtils.class.getResourceAsStream("/rin/data_type_rilcpids.properties"));
    populateMapFromRILProps(props, rilMap, FormType.DATA);

    if (LOG.isTraceEnabled()) {
        for (final Entry<FormType, Map<String, CurationPersistentIdentifier>> outerMap : rilMap.entrySet()) {
            for (final Entry<String, CurationPersistentIdentifier> innerMap : outerMap.getValue().entrySet()) {
                LOG.trace(innerMap.getKey() + ": " + innerMap.getValue());
            }
        }
    }
    return rilMap;
}

From source file:gov.nih.nci.logging.api.util.HibernateUtil.java

private static void validateProperties(Properties properties) throws Exception {

    if (properties.containsKey("CLMDS.jndiName")) {
        String jndiName = properties.getProperty("CLMDS.jndiName");
        String hibernateDialect = properties.getProperty("Hibernate.dialect");

        properties.clear();
        properties.setProperty("CLMDJndiDS.jndiName", jndiName);
        properties.setProperty("hibernate.dialect", hibernateDialect);
    }/*from   w ww .  ja  v  a2 s.  c o  m*/
    if (properties.containsKey("CLMDS.url") && properties.containsKey("CLMDS.driverClassName")
            && properties.containsKey("CLMDS.password") && properties.containsKey("CLMDS.username")) {

        String driverClassName = properties.getProperty("CLMDS.driverClassName");
        String url = properties.getProperty("CLMDS.url");
        String username = properties.getProperty("CLMDS.username");
        String password = properties.getProperty("CLMDS.password");
        String hibernateDialect = properties.getProperty("Hibernate.dialect");
        properties.clear();
        /*properties.setProperty("CLMConnectionPoolDS.driverClassName",driverClassName);
        properties.setProperty("CLMConnectionPoolDS.url", url);
        properties.setProperty("CLMConnectionPoolDS.username", username);
        properties.setProperty("CLMConnectionPoolDS.password", password);*/
        properties.setProperty("hibernate.connection.driver_class", driverClassName);
        properties.setProperty("hibernate.connection.url", url);
        properties.setProperty("hibernate.connection.username", username);
        properties.setProperty("hibernate.connection.password", password);
        properties.setProperty("hibernate.dialect", hibernateDialect);

    }

}

From source file:egovframework.oe1.cms.com.service.EgovOe1Properties.java

/**
 * ??  ?? Key  ? ? (Globals.java )//  w  w  w  .  ja  v a  2  s. com
 * 
 * @param ???
 *            ? ? Key
 * @return ??  ?? Key  ? 
 */
public static String getProperty(String keyName) {
    // System.out.println("====="+globalsPropertiesFile);
    String value = errCode;
    value = "99";
    debug(globalsPropertiesFile + " : " + keyName);
    FileInputStream fis = null;
    java.io.BufferedInputStream bis = null;
    try {
        Properties props = new Properties();

        String file1 = globalsPropertiesFile.replace('\\', FILE_SEPARATOR).replace('/', FILE_SEPARATOR);
        fis = new FileInputStream(file1);
        bis = new java.io.BufferedInputStream(fis);
        props.load(bis);
        value = props.getProperty(keyName).trim();
        props.clear();
    } catch (java.io.FileNotFoundException fne) {

        debug(fne);
    } catch (java.io.IOException ioe) {
        debug(ioe);
    } catch (java.lang.Exception e) {
        debug(e);
    } finally {
        if (fis != null)
            try {
                fis.close();
            } catch (Exception e) {
                debug(e);
            }
        if (bis != null)
            try {
                bis.close();
            } catch (Exception e) {
                debug(e);
            }
    }
    return value;
}

From source file:com.openteach.diamond.container.Container.java

private static void setExtenalClass() {
    // ???/*from  w  w w. j  ava2s  . c om*/
    // 1.???, 
    String excluded = System.getProperty(EXCLUDED_PREFIX_PROP);
    if (excluded == null) {
        //2.?????, ?, ?
        //  diamond.container
        String excludedPropertiesFile = System
                .getProperty("com.galaxy.diamond.container.excluded.prefixes.file");
        //3.?????, ?
        if (excludedPropertiesFile == null) {
            excludedPropertiesFile = EXCLUDED_FILE;
        }

        InputStream is = null;
        Properties properties = new Properties();
        try {
            is = Container.class.getClassLoader().getResourceAsStream(excludedPropertiesFile);
            if (is != null) {
                properties.load(is);
                is.close();
            }
        } catch (IOException e) {
            // ???, ?
            properties.clear();
        } finally {
            if (null != is) {
                try {
                    is.close();
                } catch (IOException e) {
                    // 
                    logger.error(e);
                }
            }
        }
        //5.????, excludenull
        excluded = properties.getProperty(EXCLUDED_PREFIX_PROP);
        if (excluded != null) {
            System.setProperty(EXCLUDED_PREFIX_PROP, excluded);
        }
    }
}

From source file:io.mycat.server.packet.util.CharsetUtil.java

/**
 * ? index_to_charset.properties ? collationIndex  charsetName
 * ??SELECT ID,CHARACTER_SET_NAME FROM INFORMATION_SCHEMA.COLLATIONS order by id;
 * //  w  ww.j ava 2  s  . c  o m
 * ?charset_to_default_index.properties?charsetNamecollationIndex
 * ??SELECT CHARACTER_SET_NAME,ID FROM INFORMATION_SCHEMA.COLLATIONS where Default='Yes';
 * 
 * ????
 * 
 * ?? ? mysql???
 */
public static void getCharsetInfoFromFile() {
    Properties pros = new Properties();
    try {
        pros.load(CharsetUtil.class.getClassLoader().getResourceAsStream("index_to_charset.properties"));
        Iterator<Entry<Object, Object>> it = pros.entrySet().iterator();
        while (it.hasNext()) {
            Entry<Object, Object> entry = it.next();
            Object key = entry.getKey();
            Object value = entry.getValue();
            INDEX_TO_CHARSET.put(Integer.parseInt(key.toString()), value.toString());
        }
        //            System.out.println(JSON.toJSONString(INDEX_TO_CHARSET));

        pros.clear();
        pros.load(
                CharsetUtil.class.getClassLoader().getResourceAsStream("charset_to_default_index.properties"));
        it = pros.entrySet().iterator();
        while (it.hasNext()) {
            Entry<Object, Object> entry = it.next();
            Object key = entry.getKey();
            Object value = entry.getValue();
            CHARSET_TO_INDEX.put(key.toString(), Integer.parseInt(value.toString()));
        }
        //            System.out.println(JSON.toJSONString(CHARSET_TO_INDEX));
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:com.thoughtworks.selenium.ScreenshotListenerVir.java

/**
 * Gets the properties.//  w  w w  .ja  v a 2  s  .c  o m
 * 
 * @return the properties
 * @throws IOException
 *             Signals that an I/O exception has occurred.
 */
private static String getProperties() throws IOException {
    Properties props = new Properties();
    File file = new File("");
    String absPath = file.getAbsolutePath();
    if ((absPath.indexOf("grid") > -1)) {
        absPath = absPath + File.separator + "grid" + File.separator + "selenium-grid-1.0.6";
    }
    String fileName = "";
    FileInputStream fis = null;
    try {
        fis = new FileInputStream(new File(absPath + File.separator + "project.properties"));
        props.load(fis);
    } finally {
        if (fis != null) {
            try {
                fis.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
    fileName = props.getProperty("currentScreenShot");

    props.clear();

    return fileName;
}

From source file:it.proximacentauri.ienergy.da.report.CustomJasperReportsMultiFormatView.java

@Override
protected void renderReport(JasperPrint populatedReport, Map<String, Object> model,
        HttpServletResponse response) throws Exception {

    Properties contentDispositions = this.getContentDispositionMappings();

    contentDispositions.clear();

    String fileNameString = "attachment; filename=" + model.get("filename");
    contentDispositions.setProperty("csv", fileNameString + ".csv");
    contentDispositions.setProperty("xls", fileNameString + ".xls");
    contentDispositions.setProperty("html", fileNameString + ".html");
    contentDispositions.setProperty("pdf", fileNameString + ".pdf");

    super.renderReport(populatedReport, model, response);
}