Example usage for org.springframework.util ObjectUtils getDisplayString

List of usage examples for org.springframework.util ObjectUtils getDisplayString

Introduction

In this page you can find the example usage for org.springframework.util ObjectUtils getDisplayString.

Prototype

public static String getDisplayString(@Nullable Object obj) 

Source Link

Document

Return a content-based String representation if obj is not null ; otherwise returns an empty String.

Usage

From source file:com.github.totyumengr.minicubes.cluster.Application.java

public static void main(String[] args) {

    LOGGER.info("Start application with args {}", ObjectUtils.getDisplayString(args));

    SpringApplication.run(Application.class, args);
}

From source file:cn.guoyukun.spring.web.form.ValueFormatter.java

public static String getDisplayString(Object value, boolean htmlEscape) {
    String displayValue = ObjectUtils.getDisplayString(value);
    return (htmlEscape ? HtmlUtils.htmlEscape(displayValue) : displayValue);
}

From source file:org.hdiv.web.servlet.tags.form.ValueFormatterHDIV.java

/**
 * Build the display value of the supplied <code>Object</code>, HTML escaped
 * as required. This version is <strong>not</strong> {@link PropertyEditor}-aware.
 * @see #getDisplayString(Object, java.beans.PropertyEditor, boolean)
 *//*from   w  ww .  j  a  v a  2 s . c  o m*/
public static String getDisplayString(Object value, boolean htmlEscape) {
    String displayValue = ObjectUtils.getDisplayString(value);
    return (htmlEscape ? HtmlUtils.htmlEscape(displayValue) : displayValue);
}

From source file:com.xyxy.platform.modules.core.web.taglib.BSAbstractMultiCheckedElementTag.java

/**
 * Copy & Paste, .//from   w w  w.  j a  v  a 2 s .  co  m
 */
@Override
protected int writeTagContent(TagWriter tagWriter) throws JspException {
    Object items = getItems();
    Object itemsObject = (items instanceof String ? evaluate("items", items) : items);

    String itemValue = getItemValue();
    String itemLabel = getItemLabel();
    String valueProperty = (itemValue != null ? ObjectUtils.getDisplayString(evaluate("itemValue", itemValue))
            : null);
    String labelProperty = (itemLabel != null ? ObjectUtils.getDisplayString(evaluate("itemLabel", itemLabel))
            : null);

    Class<?> boundType = getBindStatus().getValueType();
    if ((itemsObject == null) && (boundType != null) && boundType.isEnum()) {
        itemsObject = boundType.getEnumConstants();
    }

    if (itemsObject == null) {
        throw new IllegalArgumentException(
                "Attribute 'items' is required and must be a Collection, an Array or a Map");
    }

    if (itemsObject.getClass().isArray()) {
        Object[] itemsArray = (Object[]) itemsObject;
        for (int i = 0; i < itemsArray.length; i++) {
            Object item = itemsArray[i];
            writeObjectEntry(tagWriter, valueProperty, labelProperty, item, i);
        }
    } else if (itemsObject instanceof Collection) {
        final Collection optionCollection = (Collection) itemsObject;
        int itemIndex = 0;
        for (Iterator it = optionCollection.iterator(); it.hasNext(); itemIndex++) {
            Object item = it.next();
            writeObjectEntry(tagWriter, valueProperty, labelProperty, item, itemIndex);
        }
    } else if (itemsObject instanceof Map) {
        final Map optionMap = (Map) itemsObject;
        int itemIndex = 0;
        for (Iterator it = optionMap.entrySet().iterator(); it.hasNext(); itemIndex++) {
            Map.Entry entry = (Map.Entry) it.next();
            writeMapEntry(tagWriter, valueProperty, labelProperty, entry, itemIndex);
        }
    } else {
        throw new IllegalArgumentException("Attribute 'items' must be an array, a Collection or a Map");
    }

    return SKIP_BODY;
}

From source file:org.hdiv.web.servlet.tags.form.OptionsTagHDIV.java

@Override
protected int writeTagContent(TagWriter tagWriter) throws JspException {

    // make sure we are under a '<code>select</code>' tag before proceeding.
    assertUnderSelectTag();/*w w w.j  av  a 2s  .c om*/

    IDataComposer dataComposer = (IDataComposer) this.pageContext.getRequest()
            .getAttribute(org.hdiv.web.util.TagUtils.DATA_COMPOSER);
    SelectTagHDIV selectTag = (SelectTagHDIV) org.hdiv.web.util.TagUtils.getAncestorOfType(this,
            SelectTagHDIV.class);

    Object items = getItems();
    Object itemsObject = null;
    if (items != null) {
        itemsObject = (items instanceof String ? evaluate("items", (String) items) : items);
    } else {
        Class<?> selectTagBoundType = ((SelectTagHDIV) findAncestorWithClass(this, SelectTagHDIV.class))
                .getBindStatus().getValueType();
        if (selectTagBoundType != null && selectTagBoundType.isEnum()) {
            itemsObject = selectTagBoundType.getEnumConstants();
        }
    }

    if (itemsObject != null) {
        String itemValue = getItemValue();
        String itemLabel = getItemLabel();

        String valueProperty = (itemValue != null
                ? ObjectUtils.getDisplayString(evaluate("itemValue", itemValue))
                : null);
        String labelProperty = (itemLabel != null
                ? ObjectUtils.getDisplayString(evaluate("itemLabel", itemLabel))
                : null);

        OptionsWriter optionWriter = new OptionsWriter(dataComposer, selectTag.getName(), itemsObject,
                valueProperty, labelProperty);
        optionWriter.writeOptions(tagWriter);
    }

    return SKIP_BODY;
}

From source file:org.hdiv.web.servlet.tags.form.SubmitTagHDIV.java

/**
 * Gets the appropriate CSS class to use.
 *//*from ww w  .j  a  va 2 s  .  c o  m*/
protected String resolveCssClass() throws JspException {
    return ObjectUtils.getDisplayString(evaluate("cssClass", getCssClass()));
}

From source file:org.agatom.springatom.cmp.wizards.data.context.WizardDataScopeHolder.java

@SuppressWarnings("unchecked")
private WizardDataScopeHolder addData(final DataScope scope, final String key, final Object data) {
    LOGGER.trace(/*from w  w  w . ja  v  a 2 s .  co m*/
            String.format("addData(scope=%s,key=%s,data=%s)", scope, key, ObjectUtils.getDisplayString(data)));
    if (data == null) {
        LOGGER.trace(String.format("Cannot add data, because it is null"));
        return this;
    } else if (ClassUtils.isAssignableValue(Collection.class, data) && ((Collection<?>) data).isEmpty()) {
        LOGGER.trace(String.format("Data is an empty collection, wont be added"));
        return this;
    } else if (ClassUtils.isAssignableValue(Map.class, data) && ((Map<?, ?>) data).isEmpty()) {
        LOGGER.trace(String.format("Data is an empty collection, wont be added"));
        return this;
    }
    ModelMap localHolder = this.data.get(scope);
    if (localHolder == null) {
        localHolder = new ModelMap();
        this.data.put(scope, localHolder);
    }

    final boolean isMap = ClassUtils.isAssignableValue(Map.class, data);
    final boolean isCollection = ClassUtils.isAssignableValue(Collection.class, data);
    final boolean keyHasText = StringUtils.hasText(key);

    if (isMap && !keyHasText) {
        localHolder.addAllAttributes((Map<String, ?>) data);
    } else if (isCollection && !keyHasText) {
        localHolder.addAllAttributes((Collection<?>) data);
    } else if (!keyHasText) {
        localHolder.addAttribute(data);
    } else {
        localHolder.addAttribute(key, data);
    }

    return this;
}

From source file:org.hdiv.web.servlet.tags.form.SelectTagHDIV.java

/**
 * Renders the HTML '<code>select</code>' tag to the supplied
 * {@link TagWriter}./*from w  w w.  j ava  2 s  . co  m*/
 * <p>Renders nested '<code>option</code>' tags if the
 * {@link #setItems items} property is set, otherwise exposes the
 * bound value for the nested {@link OptionTag OptionTags}.
 */
@Override
protected int writeTagContent(TagWriter tagWriter) throws JspException {

    dataComposer = (IDataComposer) this.pageContext.getRequest().getAttribute(TagUtils.DATA_COMPOSER);
    dataComposer.compose(this.getName(), "", false);

    tagWriter.startTag("select");
    writeDefaultAttributes(tagWriter);
    if (isMultiple()) {
        tagWriter.writeAttribute("multiple", "multiple");
    }
    tagWriter.writeOptionalAttributeValue("size", getDisplayString(evaluate("size", getSize())));

    Object items = getItems();
    if (items != null) {
        // Items specified, but might still be empty...
        if (items != EMPTY) {
            Object itemsObject = evaluate("items", items);
            if (itemsObject != null) {

                String valueProperty = (getItemValue() != null
                        ? ObjectUtils.getDisplayString(evaluate("itemValue", getItemValue()))
                        : null);
                String labelProperty = (getItemLabel() != null
                        ? ObjectUtils.getDisplayString(evaluate("itemLabel", getItemLabel()))
                        : null);

                OptionWriterHDIV optionWriter = new OptionWriterHDIV(dataComposer, this.getName(), itemsObject,
                        getBindStatus(), valueProperty, labelProperty, isHtmlEscape());
                optionWriter.writeOptions(tagWriter);
            }
        }
        tagWriter.endTag(true);
        writeHiddenTagIfNecessary(tagWriter);
        return SKIP_BODY;
    } else {
        // Using nested <form:option/> tags, so just expose the value in the PageContext...
        tagWriter.forceBlock();
        this.tagWriter = tagWriter;
        this.pageContext.setAttribute(LIST_VALUE_PAGE_ATTRIBUTE, getBindStatus());
        return EVAL_BODY_INCLUDE;
    }
}

From source file:com.github.totyumengr.minicubes.cluster.BootTimeSeriesMiniCubeController.java

@RequestMapping(value = "/sum", method = { RequestMethod.POST, RequestMethod.GET })
public @ResponseBody BigDecimal sum(@NotBlank @RequestParam String indName,
        @RequestParam(required = false) String filterDims, @NotBlank @RequestParam String... timeSeries)
        throws Throwable {

    LOGGER.info("Try to sum {} on {} with filter {}.", indName, ObjectUtils.getDisplayString(timeSeries),
            filterDims);//from   w  w w  . j ava 2s  .  c o m
    long timing = System.currentTimeMillis();
    Map<String, List<Integer>> filter = (filterDims == null || "".equals(filterDims)) ? null
            : objectMapper.readValue(filterDims, new TypeReference<Map<String, List<Integer>>>() {
            });
    BigDecimal sum = manager.aggs(timeSeries).sum(indName, filter);
    LOGGER.info("Sucess to sum {} on {} result is {} using {}ms.", indName, timeSeries, sum,
            System.currentTimeMillis() - timing);

    return sum;
}

From source file:com.github.totyumengr.minicubes.cluster.BootTimeSeriesMiniCubeController.java

@RequestMapping(value = "/groupsum", method = { RequestMethod.POST, RequestMethod.GET })
public @ResponseBody Map<Integer, BigDecimal> groupsum(@NotBlank @RequestParam String indName,
        @RequestParam(required = false) String filterDims, @RequestParam String groupbyDim,
        @NotBlank @RequestParam String... timeSeries) throws Throwable {

    LOGGER.info("Try to sum {} on {} with filter {}.", indName, ObjectUtils.getDisplayString(timeSeries),
            filterDims);/*w  ww  .  j a  v  a2s . c om*/
    long timing = System.currentTimeMillis();
    Map<String, List<Integer>> filter = (filterDims == null || "".equals(filterDims)) ? null
            : objectMapper.readValue(filterDims, new TypeReference<Map<String, List<Integer>>>() {
            });
    Map<Integer, BigDecimal> sum = manager.aggs(timeSeries).sum(indName, groupbyDim, filter);
    LOGGER.info("Sucess to sum {} on {} result size is {} using {}ms.", indName, timeSeries, sum.size(),
            System.currentTimeMillis() - timing);
    LOGGER.debug("Sucess to sum {} on {} result is {}.", indName, timeSeries, sum);

    return sum;
}