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.cloudfoundry.identity.uaa.config.YamlPropertiesFactoryBeanTests.java

@Test
public void testLoadNonExistentResource() throws Exception {
    YamlPropertiesFactoryBean factory = new YamlPropertiesFactoryBean();
    factory.setResolutionMethod(ResolutionMethod.OVERRIDE_AND_IGNORE);
    factory.setResources(new Resource[] { new ClassPathResource("no-such-file.yml") });
    Properties properties = factory.getObject();
    assertEquals(0, properties.size());
}

From source file:com.sanlq.common.BrandModel.java

public void initb() {
    try {/*from   ww  w. ja v  a 2  s.  c  o  m*/
        InputStream is = BrandModel.class.getClass().getResourceAsStream("/brandmodel.properties");
        Properties props = new Properties();
        props.load(is);
        System.out.println("props: " + props.size());
        Enumeration enu2 = props.propertyNames();
        Integer cnt = 0;
        while (enu2.hasMoreElements()) {
            String key = (String) enu2.nextElement();
            String d = props.getProperty(key);
            String[] arrd = d.split("::");
            ModelBean mbean = new ModelBean();
            if (arrd.length == 6) {
                mbean.setBrandId(Integer.valueOf(arrd[0]));
                mbean.setBrandTitleEn(arrd[1]);
                mbean.setBrandTitleCn(arrd[2]);
                mbean.setTitleOrg(arrd[3]);
                mbean.setTitleCn(arrd[4]);
                mbean.setTitleEn(arrd[5]);
                if (BRANDMODEL.contains(arrd[3])) {
                    System.out.println("Exist: " + d);
                } else {
                    BRANDMODEL.put(arrd[3], mbean);
                }
            } else {
                System.out.println("ERR: " + d);
            }
            cnt++;
        }
        System.out.println("cnt: " + cnt);
        System.out.println("BRANDMODEL: " + BRANDMODEL.size());
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:org.solmix.runtime.support.spring.ContainerEntityResolver.java

public ContainerEntityResolver(ClassLoader loader, EntityResolver dr, EntityResolver sr) {
    super(dr, sr);
    classLoader = loader;// w w  w.j  a  v a  2  s . co m
    dtdResolver = dr;
    schemaResolver = sr;

    try {
        Properties mappings = PropertiesLoaderUtils.loadAllProperties("META-INF/spring.schemas", classLoader);
        schemaMappings = new ConcurrentHashMap<String, String>(mappings.size());
        CollectionUtils.mergePropertiesIntoMap(mappings, schemaMappings);
    } catch (IOException e) {
        //ignore
    }
}

From source file:hsa.awp.common.naming.DirectoryTest.java

/**
 * Checks if the content of the Attributes and Properties is equal. In
 * properties it assumes the mapping from ldap names to our names.
 *
 * @param attributes Ldap Attribtues// ww w .  ja v a 2  s.com
 * @param properties Properties returned from Directory
 * @return True if they are equal, otherwise false
 * @throws Exception If someone went wron.
 */
private boolean isEqual(Attributes attributes, Properties properties) throws Exception {

    if (attributes.size() != properties.size()) {
        return false;
    }

    NamingEnumeration<String> attribIds = attributes.getIDs();
    while (attribIds.hasMoreElements()) {
        String curAttribId = attribIds.nextElement();
        String currentAttribValue = (String) attributes.get(curAttribId).get();
        String currentPropertyId = (String) directory.getClass().getField(mapping.getProperty(curAttribId))
                .get("");
        String currentPropertyValue = properties.getProperty(currentPropertyId);
        if (!currentAttribValue.equals(currentPropertyValue)) {
            return false;
        }
    }

    return true;
}

From source file:org.openinfobutton.responder.dao.impl.ResponderServiceDaoTest.java

@Test
public void testGetApplicationProperties() {

    Properties props = service.getApplicationProperties("atom.feed");
    assertTrue(props.size() == 0);

}

From source file:com.consol.citrus.admin.service.ProjectServiceTest.java

@Test(dataProvider = "projectProvider")
public void testGetProjectProperties(String projectHome, String description, Map<String, String> properties,
        boolean connectorActive) throws Exception {
    Project testProject = new Project(new ClassPathResource(projectHome).getFile().getCanonicalPath());

    projectService.setActiveProject(testProject);
    Properties projectProperties = projectService.getProjectProperties();

    Assert.assertEquals(projectProperties.size(), properties.size());
    for (Map.Entry<String, String> propEntry : properties.entrySet()) {
        Assert.assertEquals(projectProperties.get(propEntry.getKey()), propEntry.getValue());
    }/*from w w  w .  j  a v a2s  .  c om*/
}

From source file:org.paxml.bean.PropertiesTag.java

/**
 * {@inheritDoc}//from  www.  j a va2s  . c o m
 */
@Override
protected Object doInvoke(Context context) throws Exception {
    final String id = getId(context);
    if (StringUtils.isNotBlank(id) && getParent() instanceof ConstTag) {
        throw new PaxmlRuntimeException(
                "The 'id' attribute cannot be given to a <" + TAG_NAME + "> tag if it is under a data tag.");
    }

    Properties props = loadProperties(context);

    if (props.size() <= 0) {
        if (log.isWarnEnabled()) {
            log.warn("Properties has no content loaded: " + context.getStack().getFirst());
        }
    }
    if (StringUtils.isBlank(id)) {
        final boolean group = AbstractTagFactory.isUnderConst(this);
        if (group) {
            return new PropertiesObjectTree(props);
        } else {
            Context c = context.getCurrentEntityContext();
            // flatten the properties
            for (Map.Entry<Object, Object> entry : props.entrySet()) {
                String key = entry.getKey().toString();
                c.setConst(key, null, entry.getValue(), true);
                c.addPropertyConstId(key);
            }
            return null;
        }
    } else {
        context.getCurrentEntityContext().addPropertyConstId(id);
        // always group it here
        return new PropertiesObjectTree(props);

    }

}

From source file:org.opensingular.form.processor.TypeProcessorAttributeReadFromFile.java

/** L as associaes de atributos a partir de um arquivo de propriedades. */
@Nonnull/*from ww w .  j a va2s  .c  o m*/
private List<AttibuteEntry> readDefinitionsFor(@Nonnull Properties props) {
    List<AttibuteEntry> vals = new ArrayList<>(props.size());
    for (Map.Entry<Object, Object> entry : props.entrySet()) {
        String key = (String) entry.getKey();
        int pos = key.indexOf('@');
        if (pos == -1 || pos == key.length() - 1) {
            throw new SingularFormException("Invalid attribute definition key='" + key + "'");
        }
        AttibuteEntry definition = new AttibuteEntry();
        definition.subFieldPath = pos == 0 ? null : StringUtils.trimToNull(key.substring(0, pos));
        definition.attributeName = StringUtils.trimToNull(key.substring(pos + 1));
        definition.attributeValue = StringUtils.trimToNull((String) entry.getValue());
        if (definition.attributeName == null) {
            throw new SingularFormException("Invalid attribute definition key='" + key + "'");
        }
        vals.add(definition);
    }
    return vals;
}

From source file:sk.openhouse.web.recaptcha.LocaleReCaptchaImpl.java

/**
 * Produces javascript array with the RecaptchaOptions encoded.
 * If the value starts with "{" and ends with "}", single quotes are not
 * prepended and appended. This way javascript objects can be passed.
 *
 * @param properties//from   w w  w.  j av  a  2s . com
 * @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();

        String value = properties.getProperty(property).trim();
        if (value.startsWith("{") && value.endsWith("}")) {
            jsOptions += property + ":" + value;
        } else {
            jsOptions += property + ":'" + value + "'";
        }

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

    }

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

    return jsOptions;
}

From source file:org.rhq.enterprise.gui.legacy.portlet.didYouKnow.ViewAction.java

@Override
public ActionForward execute(ComponentContext context, ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response) throws Exception {

    String tip = "Tip #0: tips are only available to logged in users";
    try {//w  w  w .  j av  a 2 s .  c  om

        ClassLoader cl = this.getClass().getClassLoader();
        Properties tips = new Properties();

        tips.load(cl.getResourceAsStream("tips.properties"));

        // Load a random tip
        long index = System.currentTimeMillis() % tips.size();
        String strIndex = new Long(index + 1).toString();

        tip = "Tip #" + strIndex + ": " + (String) tips.get(strIndex);
    } catch (Exception e) {
        if (log.isDebugEnabled()) {
            log.debug("Dashboard Portlet [DidYouKnow] experienced an error: " + e.getMessage(), e);
        } else {
            log.error("Dashboard Portlet [DidYouKnow] experienced an error: " + e.getMessage());
        }
    } finally {
        context.putAttribute("tip", tip);
    }

    return null;
}