Example usage for java.util Properties keySet

List of usage examples for java.util Properties keySet

Introduction

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

Prototype

@Override
    public Set<Object> keySet() 

Source Link

Usage

From source file:Main.java

public static void xmlProps(final StringBuilder sb, final Properties props) {
    if (props != null) {
        int i = 0;
        for (Object key : props.keySet()) {
            if (i > 0)
                sb.append(';');
            sb.append(key.toString());//from ww w . jav a 2 s  .  c  o  m
            sb.append("="); //$NON-NLS-1$
            sb.append(props.getProperty(key.toString()));
            i++;
        }
    }
}

From source file:it.geosolutions.geobatch.jetty.Start.java

private static void setSystemProperties(final Properties prop) {
    Iterator<?> it = prop.keySet().iterator();
    while (it.hasNext()) {
        Object key = it.next();/* w ww.j av  a 2  s . c o  m*/
        System.setProperty(key.toString(), prop.get(key).toString());
    }
}

From source file:com.axiomine.largecollections.utilities.KryoUtils.java

public static void registerKryoClasses(Kryo kryo, String propFile) throws Exception {
    FileReader fReader = new FileReader(new File(propFile));
    Properties props = new Properties();
    props.load(fReader);//from ww  w.j a  va  2 s. co  m
    Set ks = props.keySet();
    for (Object k : ks) {
        Class c = Class.forName((String) k);
        Class s = Class.forName(props.getProperty((String) k));
        Serializer ss = (Serializer) s.newInstance();
        kryo.register(c, ss);
    }

}

From source file:gov.nih.nci.eagle.util.EAGLEListLoader.java

public static UserListBean loadDefaultLists(UserListBean userListBean, HttpSession session)
        throws OperationNotSupportedException {
    ListManager listManager = new ListManager();

    //      use RBT stuff for testing
    //   this is obviously testing stuff
    //        String oligos = "E09264,E09358,E09448,E09503,E09661,E09664,E09690,E09804,E09811,E09860,E09867,E09885,E09893,HF0087,HF0251,HF0285,HF0291,HF0327,HF0329,HF0332,HF0434,HF0453,HF0471,HF0488,HF0510,HF0599,HF0615,HF0639,HF0670,HF0726,HF0749,HF0813,HF0816,HF0822,HF0828,HF0831,HF0835,HF0897,HF0899,HF0914,HF0920,HF0931,HF0960,HF0962,HF0966,HF0975,HF1136,HF1150,HF1156,HF1167,HF1185,HF1219,HF1227,HF1235,HF1264,HF1325,HF1334,HF1345,HF1348,HF1380,HF1381,HF1433,HF1489,HF1493,HF1502,HF1551,HF1553,HF1606,HF1613,HF1677,MD508984";
    //        String astros = "E09137,E09176,E09214,E09262,E09334,E09362,E09394,E09408,E09471,E09542,E09673,E09743,E09759,E09800,E09801,E09818,E09826,E09848,E09900,E09922,E09923,E09945,HF0017,HF0026,HF0108,HF0152,HF0189,HF0223,HF0450,HF0491,HF0608,HF0757,HF0778,HF0953,HF1000,HF1032,HF1114,HF1139,HF1232,HF1246,HF1269,HF1295,HF1316,HF1344,HF1366,HF1398,HF1407,HF1442,HF1463,HF1469,HF1487,HF1511,HF1568,HF1581,HF1587,HF1708,MD547038,MD554082";
    //first 5+ astros are not in rbinary
    //        String oligos = "IGC-10-1107,IGC-08-1053,IGC-02-1067,IGC-02-1059";
    //        String astros = "IGC-10-1051,IGC-12-1077,IGC-09-1090,IGC-03-1007";
    //        String ftest = "IGC-08-1094,IGC-09-1085,IGC-13-1106,IGC-04-1113";
    ReadablePropertyPlaceholder propBean = (ReadablePropertyPlaceholder) SpringContext.getBean("patientLists");
    Properties props = propBean.getProps();
    for (Object listName : props.keySet()) {
        if (listName.toString().indexOf("data.") != -1)
            continue;
        List<String> sampleList = new ArrayList<String>();
        String samples = props.getProperty(listName.toString());
        sampleList = Arrays.asList(StringUtils.split(samples, ","));
        EAGLEListValidator listValidator = new EAGLEListValidator(ListType.PatientDID, sampleList);
        UserList mySampleList = listManager.createList(ListType.PatientDID, listName.toString(), sampleList,
                listValidator);//w  ww .j a  v a2 s .c o m
        mySampleList.setListOrigin(ListOrigin.Default);
        userListBean.addList(mySampleList);
    }
    //        List<String> oligoSamplesList = new ArrayList<String>();
    //        oligoSamplesList = Arrays.asList( StringUtils.split(oligos, ",") );
    //
    //      
    //        EAGLEListValidator listValidator = new EAGLEListValidator(ListType.PatientDID, ListSubType.Default, oligoSamplesList);
    //        UserList myOligoSampleList = listManager.createList(ListType.PatientDID,"testOligo",oligoSamplesList,listValidator); 
    //        myOligoSampleList.setListSubType(ListSubType.Default);
    //        userListBean.addList(myOligoSampleList);
    //        
    //        List<String> astroSamplesList = new ArrayList<String>();
    //        astroSamplesList = Arrays.asList( StringUtils.split(astros, ",") );
    //     
    //        listValidator = new EAGLEListValidator(ListType.PatientDID, ListSubType.Default, astroSamplesList);
    //        UserList myAstroSampleList = listManager.createList(ListType.PatientDID,"testAstro",astroSamplesList,listValidator); 
    //        myAstroSampleList.setListSubType(ListSubType.Default);
    //        userListBean.addList(myAstroSampleList);
    //        
    //        List<String> ftestList = new ArrayList<String>();
    //        ftestList = Arrays.asList( StringUtils.split(ftest, ",") );
    //     
    //        listValidator = new EAGLEListValidator(ListType.PatientDID, ListSubType.Default, ftestList);
    //        UserList ftestSampleList = listManager.createList(ListType.PatientDID,"ftest",ftestList,listValidator); 
    //        ftestSampleList.setListSubType(ListSubType.Default);
    //        userListBean.addList(ftestSampleList);

    return userListBean;
}

From source file:com.microsoft.windowsazure.services.core.Configuration.java

public static Configuration load() throws IOException {
    Configuration config = new Configuration();

    InputStream stream = Configuration.class.getClassLoader()
            .getResourceAsStream("META-INF/com.microsoft.windowsazure.properties");
    if (stream != null) {
        Properties properties = new Properties();
        properties.load(stream);//from   w w  w. ja va 2s  . com
        for (Object key : properties.keySet()) {
            config.setProperty(key.toString(), properties.get(key));
        }
    }

    return config;
}

From source file:com.subakva.formicid.Main.java

private static void defineTasks(Container container) throws IOException {
    Scriptable scope = container.getScope();
    InputStream stream = Task.class.getResourceAsStream("/org/apache/tools/ant/taskdefs/defaults.properties");
    Properties p = new Properties();
    p.load(stream);//from  www .  j  a va2  s. c  om

    for (Iterator iter = p.keySet().iterator(); iter.hasNext();) {
        String taskType = (String) iter.next();
        String functionName = taskType;
        if ("delete".equals(taskType)) {
            functionName = "rm";
        }
        scope.put(functionName, scope, new TaskFunction(container, taskType));
        //Path, Resource, Zip$WhenEmpty, Jar$FilesetManifestConfig, Zip$Duplicate,
        //ExecuteOn$FileDirBoth, Commandline, ExecuteStreamHandler, Tar$TarLongFileMode,
        //Tar$TarCompressionMethod, Javadoc$AccessType, Echo$EchoLevel, Definer$OnError,
        //Definer$Format, ClassLoader, Available$FileDir, Untar$UntarCompressionMethod,
        //WaitFor$Unit, Writer, FixCRLF$CrLf, EmailTask$Encoding, Checksum$FormatElement,
        //Reference, Recorder$VerbosityLevelChoices, Recorder$ActionChoices,
        //FixCRLF$AddAsisRemove, URL, Comparison, Date, Length$FileMode, SQLExec$OnError,
        //SQLExec$DelimiterType
    }
}

From source file:com.googlecode.flyway.maven.MigrateMojo.java

/**
 * Adds the additional placeholders contained in these properties to the existing list.
 *
 * @param placeholders The existing list of placeholders.
 * @param properties   The properties containing additional placeholders.
 *///from  ww  w  .  j  a  va  2 s.  co  m
private static void addPlaceholdersFromProperties(Map<String, String> placeholders, Properties properties) {
    for (Object property : properties.keySet()) {
        String propertyName = (String) property;
        if (propertyName.startsWith(PLACEHOLDERS_PROPERTY_PREFIX)
                && propertyName.length() > PLACEHOLDERS_PROPERTY_PREFIX.length()) {
            String placeholderName = propertyName.substring(PLACEHOLDERS_PROPERTY_PREFIX.length());
            String placeholderValue = properties.getProperty(propertyName);
            placeholders.put(placeholderName, placeholderValue);
        }
    }
}

From source file:com.microsoft.tfs.core.clients.build.internal.utils.XamlHelper.java

public static String updateProperties(final String originalXaml, final Properties properties) {
    final ArrayList keys = new ArrayList(properties.keySet());

    final Document document = DOMCreateUtils.parseString(originalXaml);
    final Element root = document.getDocumentElement();

    // first update any properties that we already have
    final NodeList nodes = root.getElementsByTagName("x:String"); //$NON-NLS-1$
    for (int i = 0; i < nodes.getLength(); i++) {
        final Element element = (Element) nodes.item(i);
        final String key = element.getAttribute("x:Key"); //$NON-NLS-1$
        element.getFirstChild().getNodeValue();

        if (properties.containsKey(key)) {
            keys.remove(key);/*from w  w w . j  a  v a  2s. c  o m*/
            element.getFirstChild().setNodeValue(properties.getProperty(key));
        }
    }

    // now add any new properties to the xaml
    for (final Iterator it = keys.iterator(); it.hasNext();) {
        final String key = (String) it.next();
        final Element element = DOMUtils.appendChild(root, "x:String"); //$NON-NLS-1$
        element.setAttributeNS(XAML_NAMESPACE, "x:Key", key); //$NON-NLS-1$
        element.setAttributeNS(XML_NAMESPACE, "xml:space", "preserve"); //$NON-NLS-1$ //$NON-NLS-2$
        DOMUtils.appendText(element, properties.getProperty(key));
    }

    return DOMSerializeUtils.toString(root, DOMSerializeUtils.INDENT).trim();
}

From source file:com.commonsware.android.gcm.cmd.GCM.java

private static void sendMessage(String apiKey, List<String> devices, Properties data) throws Exception {
    Sender sender = new Sender(apiKey);
    Message.Builder builder = new Message.Builder();

    for (Object o : data.keySet()) {
        String key = o.toString();

        builder.addData(key, data.getProperty(key));
    }// w w w  .  j  a  v  a2  s.  c  o  m

    MulticastResult mcResult = sender.send(builder.build(), devices, 5);

    for (int i = 0; i < mcResult.getTotal(); i++) {
        Result result = mcResult.getResults().get(i);

        if (result.getMessageId() != null) {
            String canonicalRegId = result.getCanonicalRegistrationId();

            if (canonicalRegId != null) {
                System.err.println(String.format("%s canonical ID = %s", devices.get(i), canonicalRegId));
            } else {
                System.out.println(String.format("%s success", devices.get(i)));
            }
        } else {
            String error = result.getErrorCodeName();

            if (Constants.ERROR_NOT_REGISTERED.equals(error)) {
                System.err.println(String.format("%s is unregistered", devices.get(i)));
            } else if (error != null) {
                System.err.println(String.format("%s error = %s", devices.get(i), error));
            }
        }
    }
}

From source file:com.cisco.dbds.utils.configfilehandler.ConfigFileHandler.java

/**
 * Sets the systemvariable.//  ww w.j  ava  2 s  .  c  o m
 *
 * @param input the new systemvariable
 */
public static void setSystemvariable(InputStream input) {
    Properties tmp1 = new Properties();
    try {
        tmp1.load(input);

        for (Object element : tmp1.keySet()) {
            System.setProperty(element.toString().trim(), tmp1.getProperty(element.toString().trim()).trim());
        }
    } catch (IOException e) {
        System.out.println("setSystemvariable method failure");
    }
}