Example usage for java.util Properties size

List of usage examples for java.util Properties size

Introduction

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

Prototype

@Override
    public int size() 

Source Link

Usage

From source file:org.agatom.springatom.core.locale.SAMessageSource.java

@Override
public Map<String, String> getAllMessages(final Locale locale) {
    final Properties properties = this.getMergedProperties(locale).getProperties();
    final Map<String, String> map = Maps.newHashMapWithExpectedSize(properties.size());
    for (final Object propKey : properties.keySet()) {
        map.put(propKey.toString(), properties.get(propKey).toString());
    }/*from   w  ww  .j  a va 2  s .co  m*/
    return map;
}

From source file:org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp.XMPPNotificationStrategy.java

@Override
public void execute(NotificationContext ctx) throws PushNotificationExecutionFailedException {
    Map<String, String> dynamicProperties = new HashMap<>();
    Properties properties = ctx.getOperation().getProperties();
    if (properties != null & properties.size() > 0) {
        dynamicProperties.put(DYNAMIC_PROPERTY_JID, properties.getProperty(XMPP_CLIENT_JID));
        dynamicProperties.put(DYNAMIC_PROPERTY_SUBJECT, properties.getProperty(XMPP_CLIENT_SUBJECT));
        dynamicProperties.put(DYNAMIC_PROPERTY_MSGTYPE, properties.getProperty(XMPP_CLIENT_MESSAGE_TYPE));
    } else {/*from   w  w w  . j a va2  s.co m*/
        dynamicProperties.put(DYNAMIC_PROPERTY_JID, ctx.getDeviceId().getId() + subDomain);
        dynamicProperties.put(DYNAMIC_PROPERTY_SUBJECT, ctx.getOperation().getType().toString());
        dynamicProperties.put(DYNAMIC_PROPERTY_MSGTYPE, XMPPAdapterConstants.CHAT_PROPERTY_KEY);
    }
    XMPPDataHolder.getInstance().getOutputEventAdapterService().publish(xmppAdapterName, dynamicProperties,
            ctx.getOperation().getPayLoad());
}

From source file:org.duracloud.tools.BridgeReportCaptureToolTest.java

/**
 * Tests the reading and writing of properties to and from a file
 *
 * @throws Exception//  w  w  w  .  j  av  a 2s  .  co m
 */
@Test
public void testPropsWriteRead() throws Exception {
    File propsFile = new File(System.getProperty("java.io.tmpdir"), "test-bridge-props-file.properties");

    try {
        String bridgeUrlValue = "bridge-url";
        String bridgeUserValue = "bridge-username";
        String bridgePassValue = "bridge-password";
        String s3AccessValue = "s3-access-key";
        String s3SecretValue = "s3-secret-key";
        String s3BucketValue = "s3-bucket-name";

        Properties writeProps = new Properties();
        writeProps.put(BRIDGE_URL_PROP, bridgeUrlValue);
        writeProps.put(BRIDGE_USERNAME_PROP, bridgeUserValue);
        writeProps.put(BRIDGE_PASSWORD_PROP, bridgePassValue);
        writeProps.put(S3_ACCESS_KEY_PROP, s3AccessValue);
        writeProps.put(S3_SECRET_KEY_PROP, s3SecretValue);
        writeProps.put(S3_BUCKET_NAME_PROP, s3BucketValue);

        BridgeReportCaptureTool.writeProps(propsFile.getAbsolutePath(), writeProps);

        Properties readProps = BridgeReportCaptureTool.readProps(propsFile.getAbsolutePath());

        assertEquals(6, readProps.size());
        assertEquals(bridgeUrlValue, readProps.get((BRIDGE_URL_PROP)));
        assertEquals(bridgeUserValue, readProps.get((BRIDGE_USERNAME_PROP)));
        assertEquals(bridgePassValue, readProps.get((BRIDGE_PASSWORD_PROP)));
        assertEquals(s3AccessValue, readProps.get((S3_ACCESS_KEY_PROP)));
        assertEquals(s3SecretValue, readProps.get((S3_SECRET_KEY_PROP)));
        assertEquals(s3BucketValue, readProps.get((S3_BUCKET_NAME_PROP)));
    } finally {
        if (propsFile.exists()) {
            FileUtils.forceDelete(propsFile);
        }
    }

}

From source file:com.enonic.cms.core.boot.ConfigBuilderTest.java

@Test
public void testDefault() throws Exception {
    Properties props = this.builder.loadProperties();
    assertNotNull(props);//from w  ww. j  a v  a  2s. com
    assertEquals(2, props.size());
    assertEquals(this.homeDir.toString(), props.getProperty("cms.home"));
    assertEquals(this.homeDir.toURI().toString(), props.getProperty("cms.home.uri"));
}

From source file:com.peoplemerge.recaptcha.ReCaptchaImpl.java

/**
 * Produces javascript array with the RecaptchaOptions encoded.
 * /*  w  w  w. jav a 2 s  .  c o m*/
 * @param properties
 * @return
 */
private String fetchJSOptions(Properties properties) {

    if (properties == null || properties.size() == 0) {
        return "";
    }

    String jsOptions = "<script type=\"text/javascript\">\r\n" + "var RecaptchaOptions = {";

    for (Enumeration e = properties.keys(); e.hasMoreElements();) {
        String property = (String) e.nextElement();

        jsOptions += property + ":'" + properties.getProperty(property) + "'";

        if (e.hasMoreElements()) {
            jsOptions += ",";
        }

    }

    jsOptions += "};\r\n</script>\r\n";

    return jsOptions;
}

From source file:com.enonic.cms.core.boot.ConfigBuilderTest.java

@Test
public void testSystemProperties() throws Exception {
    setupSystemProperties();//from   www  .j a va  2s . c  o  m

    Properties props = this.builder.loadProperties();
    assertNotNull(props);
    assertEquals(4, props.size());
    assertEquals("value", props.getProperty("system.param"));
    assertEquals("system", props.getProperty("override"));
}

From source file:com.enonic.cms.core.boot.ConfigBuilderTest.java

@Test
public void testClassLoader() throws Exception {
    setupClassPathProperties();/*from w w w.ja v a 2  s .c o  m*/

    Properties props = this.builder.loadProperties();
    assertNotNull(props);
    assertEquals(4, props.size());
    assertEquals("value", props.getProperty("classpath.param"));
    assertEquals("classpath", props.getProperty("override"));
}

From source file:com.enonic.cms.core.boot.ConfigBuilderTest.java

@Test
public void testHomeConfig() throws Exception {
    setupHomeProperties();//from w  w  w.j a v a2  s. com

    Properties props = this.builder.loadProperties();
    assertNotNull(props);
    assertEquals(4, props.size());
    assertEquals("value", props.getProperty("home.param"));
    assertEquals("home", props.getProperty("override"));
}

From source file:com.enonic.cms.core.boot.ConfigBuilderTest.java

@Test
public void testCombining() throws Exception {
    setupClassPathProperties();//from   w  ww .  j a v  a  2 s  . co m
    setupHomeProperties();

    Properties props = this.builder.loadProperties();
    assertNotNull(props);
    assertEquals(5, props.size());
    assertEquals("value", props.getProperty("classpath.param"));
    assertEquals("value", props.getProperty("home.param"));
    assertEquals("home", props.getProperty("override"));
}

From source file:org.cloudfoundry.identity.uaa.integration.TestProfileEnvironment.java

private TestProfileEnvironment() {

    List<Resource> resources = new ArrayList<Resource>();

    for (String location : DEFAULT_PROFILE_CONFIG_FILE_LOCATIONS) {
        location = environment.resolvePlaceholders(location);
        Resource resource = recourceLoader.getResource(location);
        if (resource != null && resource.exists()) {
            resources.add(resource);/*from  w  w  w  .j a va 2  s.co  m*/
        }
    }

    YamlPropertiesFactoryBean factory = new YamlPropertiesFactoryBean();
    factory.setResources(resources.toArray(new Resource[resources.size()]));
    factory.setDocumentMatchers(Collections.singletonMap("platform",
            environment.acceptsProfiles("postgresql") ? "postgresql" : "hsqldb"));
    factory.setResolutionMethod(ResolutionMethod.OVERRIDE_AND_IGNORE);
    Properties properties = factory.getObject();

    logger.debug("Decoding environment properties: " + properties.size());
    if (!properties.isEmpty()) {
        for (Enumeration<?> names = properties.propertyNames(); names.hasMoreElements();) {
            String name = (String) names.nextElement();
            String value = properties.getProperty(name);
            if (value != null) {
                properties.setProperty(name, environment.resolvePlaceholders(value));
            }
        }
        if (properties.containsKey("spring_profiles")) {
            properties.setProperty(StandardEnvironment.ACTIVE_PROFILES_PROPERTY_NAME,
                    properties.getProperty("spring_profiles"));
        }
        // System properties should override the ones in the config file, so add it last
        environment.getPropertySources().addLast(new PropertiesPropertySource("uaa.yml", properties));
    }

    EnvironmentPropertiesFactoryBean environmentProperties = new EnvironmentPropertiesFactoryBean();
    environmentProperties.setEnvironment(environment);
    environmentProperties.setDefaultProperties(properties);
    Map<String, ?> debugProperties = environmentProperties.getObject();
    logger.debug("Environment properties: " + debugProperties);
}