Example usage for org.apache.commons.collections.keyvalue DefaultKeyValue DefaultKeyValue

List of usage examples for org.apache.commons.collections.keyvalue DefaultKeyValue DefaultKeyValue

Introduction

In this page you can find the example usage for org.apache.commons.collections.keyvalue DefaultKeyValue DefaultKeyValue.

Prototype

public DefaultKeyValue(final Object key, final Object value) 

Source Link

Document

Constructs a new pair with the specified key and given value.

Usage

From source file:org.jahia.taglibs.facet.FunctionsTest.java

/**
 * Method: getDeleteFacetUrl(Object facetFilterObj, KeyValue facetValue, String queryString)
 *///w w  w .j av  a2 s  .c  o  m
@Test
public void testGetDeleteFacetUrl() throws Exception {
    String query = "j:tagList###tag1###3056820\\:FACET\\:tags:4c1b0348\\-89d0\\-461e\\-b31d\\-d725b8e6ea18|||j:tagList###tag2###3056820\\:FACET\\:tags:cdc62535\\-bcac\\-44d7\\-b4da\\-be8c865d7a58";
    KeyValue facetValue1 = new DefaultKeyValue("tag1",
            "3056820\\:FACET\\:tags:4c1b0348\\-89d0\\-461e\\-b31d\\-d725b8e6ea18");
    KeyValue facetValue2 = new DefaultKeyValue("tag2",
            "3056820\\:FACET\\:tags:cdc62535\\-bcac\\-44d7\\-b4da\\-be8c865d7a58");

    assertEquals("j:tagList###tag2###3056820\\:FACET\\:tags:cdc62535\\-bcac\\-44d7\\-b4da\\-be8c865d7a58",
            Functions.getDeleteFacetUrl(facetValue1, query));
    assertEquals("j:tagList###tag1###3056820\\:FACET\\:tags:4c1b0348\\-89d0\\-461e\\-b31d\\-d725b8e6ea18",
            Functions.getDeleteFacetUrl(facetValue2, query));
}

From source file:org.okj.commons.web.taglib.CheckboxListTag.java

/**
 *
 * @see org.storevm.ftps.web.taglibs.SelectTag#doStartTag()
 *///from w w  w  .j a v a2  s.com
@Override
public int doStartTag() throws JspException {
    String content = "";
    try {
        ControlAttribute attribute = new ControlAttribute();

        //
        BeanCopier copier = BeanCopier.create(this.getClass(), ControlAttribute.class, false);
        copier.copy(this, attribute, null);

        content = new CheckboxTemplate(attribute) {

            /** 
             * @see com.lakala.bmcp.tags.template.FormTemplate#getOptions()
             */
            @Override
            public List<KeyValue> getOptions() {
                List<KeyValue> options = new ArrayList<KeyValue>();

                try {
                    //JSON
                    JSONObject json = JSONObject.fromObject(list);
                    Set set = json.entrySet();
                    Iterator it = set.iterator();
                    while (it.hasNext()) {
                        Map.Entry entry = (Map.Entry) it.next();
                        options.add(new DefaultKeyValue(entry.getValue(), entry.getKey()));
                    }
                    return options;
                } catch (JSONException ex) {
                    LOGGER.warn("listJsonlist=" + list
                            + ", error=" + ex.getMessage());
                }

                //Jsonrequest
                Object obj = pageContext.getRequest().getAttribute(list);
                if (obj instanceof List) {
                    for (Object o : (List<?>) obj) {
                        Object key, value;

                        try {
                            key = BeanUtils.getNestedProperty(o, listKey);
                            value = BeanUtils.getNestedProperty(o, listValue);

                            options.add(new DefaultKeyValue(key, value));
                        } catch (Exception ex) {
                            LOGGER.warn("", ex);
                        }
                    }
                }
                return options;
            }

        }.render();

        pageContext.getOut().write(content);
        return SKIP_BODY;
    } catch (Exception e) {
        throw new JspException(e.toString());
    }
}

From source file:org.okj.commons.web.taglib.RadioTag.java

/** 
 * @see com.lakala.bmcp.tags.SelectTag#doStartTag()
 *///from w  w w . ja  va2 s  .  c om
@Override
public int doStartTag() throws JspException {
    String content = "";
    try {
        ControlAttribute attribute = new ControlAttribute();

        //
        BeanCopier copier = BeanCopier.create(this.getClass(), ControlAttribute.class, false);
        copier.copy(this, attribute, null);

        content = new RadioTemplate(attribute) {

            /** 
             * @see com.lakala.bmcp.tags.template.FormTemplate#getOptions()
             */
            @Override
            public List<KeyValue> getOptions() {
                List<KeyValue> options = new ArrayList<KeyValue>();

                try {
                    //JSON
                    JSONObject json = JSONObject.fromObject(list);
                    Set set = json.entrySet();
                    Iterator it = set.iterator();
                    while (it.hasNext()) {
                        Map.Entry entry = (Map.Entry) it.next();
                        options.add(new DefaultKeyValue(entry.getKey(), entry.getValue()));
                    }
                    return options;
                } catch (JSONException ex) {
                    LOGGER.warn("listJsonlist=" + list
                            + ", error=" + ex.getMessage());
                }

                //Jsonrequest
                Object obj = pageContext.getRequest().getAttribute(list);
                if (obj instanceof List) {
                    for (Object o : (List) obj) {
                        Object key, value;

                        try {
                            key = BeanUtils.getNestedProperty(o, listKey);
                            value = BeanUtils.getNestedProperty(o, listValue);

                            options.add(new DefaultKeyValue(key, value));
                        } catch (Exception ex) {
                            LOGGER.warn("", ex);
                        }
                    }
                }
                return options;
            }

        }.render();

        pageContext.getOut().write(content);
        return SKIP_BODY;
    } catch (Exception e) {
        throw new JspException(e.toString());
    }
}

From source file:org.okj.commons.web.taglib.SelectTag.java

/**
 *
 * @see javax.servlet.jsp.tagext.TagSupport#doStartTag()
 *//*from   ww w  . ja  v  a2 s.  c o  m*/
@Override
public int doStartTag() throws JspException {
    String content = "";
    try {
        ControlAttribute attribute = new ControlAttribute();

        //
        BeanCopier copier = BeanCopier.create(this.getClass(), ControlAttribute.class, false);
        copier.copy(this, attribute, null);

        content = new SelectOptionsTemplate(attribute) {

            /** 
             * @see com.lakala.bmcp.tags.template.FormTemplate#getOptions()
             */
            @Override
            public List<KeyValue> getOptions() {
                List<KeyValue> options = new ArrayList<KeyValue>();

                try {
                    //JSON
                    JSONObject json = JSONObject.fromObject(list);
                    Set set = json.entrySet();
                    Iterator it = set.iterator();
                    while (it.hasNext()) {
                        Map.Entry entry = (Map.Entry) it.next();
                        options.add(new DefaultKeyValue(entry.getValue(), entry.getKey()));
                    }
                    return options;
                } catch (JSONException ex) {
                    LOGGER.warn("listJsonlist=" + list
                            + ", error=" + ex.getMessage());
                }

                //Jsonrequest
                Object obj = pageContext.getRequest().getAttribute(list);
                if (obj instanceof List) {
                    for (Object o : (List) obj) {
                        Object key, value;

                        try {
                            key = BeanUtils.getNestedProperty(o, listKey);
                            value = BeanUtils.getNestedProperty(o, listValue);

                            options.add(new DefaultKeyValue(key, value));
                        } catch (Exception ex) {
                            LOGGER.warn("", ex);
                        }
                    }
                }
                return options;
            }

        }.render();

        pageContext.getOut().write(content);
        return SKIP_BODY;
    } catch (Exception e) {
        throw new JspException(e.toString());
    }
}

From source file:org.polymap.core.data.ui.featuretable.SimpleFeatureTableElement.java

public Object getValue(String name) {
    if (sortedValue == null || !sortedValue.getKey().equals(name)) {
        SimpleFeature feature = feature();
        if (feature != null) {
            sortedValue = new DefaultKeyValue(name, feature.getAttribute(name));
        }/*from   ww  w  .  j av a 2  s  . c om*/
    }
    return sortedValue != null ? sortedValue.getValue() : null;
}