Example usage for org.springframework.core.style StylerUtils style

List of usage examples for org.springframework.core.style StylerUtils style

Introduction

In this page you can find the example usage for org.springframework.core.style StylerUtils style.

Prototype

public static String style(Object value) 

Source Link

Document

Style the specified value according to default conventions.

Usage

From source file:org.agatom.springatom.cmp.wizards.core.AbstractWizardProcessor.java

private void doBind(final DataBinder binder, Map<String, Object> params) throws Exception {
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug(String.format(
                "Binding allowed request parameters in %s to form object with name '%s', pre-bind formObject toString = %s",
                params, binder.getObjectName(), binder.getTarget()));
        if (binder.getAllowedFields() != null && binder.getAllowedFields().length > 0) {
            LOGGER.debug(//  w ww. j a  va2s  .c om
                    String.format("(Allowed fields are %s)", StylerUtils.style(binder.getAllowedFields())));
        } else {
            LOGGER.debug("(Any field is allowed)");
        }
    }
    binder.bind(new MutablePropertyValues(params));
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug(String.format(
                "Binding completed for form object with name '%s', post-bind formObject toString = %s",
                binder.getObjectName(), binder.getTarget()));
        LOGGER.debug(String.format("There are [%d] errors, details: %s",
                binder.getBindingResult().getErrorCount(), binder.getBindingResult().getAllErrors()));
    }
}

From source file:no.abmu.questionnaire.webflow.MuseumStatisticFormAction.java

/**
 * Bind allowed parameters in the external context request parameter map to the form object using given binder.
 * @param context the action execution context, for accessing and setting data in "flow scope" or "request scope"
 * @param binder the data binder to use/*from  w  w w  . j a  va 2s .c o  m*/
 * @throws Exception when an unrecoverable exception occurs
 */
protected void doBind(RequestContext context, DataBinder binder) throws Exception {
    logger.debug("Execute local doBind");
    if (logger.isDebugEnabled()) {
        logger.debug("Binding allowed request parameters in "
                + StylerUtils.style(context.getExternalContext().getRequestParameterMap())
                + " to form object with name '" + binder.getObjectName() + "', pre-bind formObject toString = "
                + binder.getTarget());
        if (binder.getAllowedFields() != null && binder.getAllowedFields().length > 0) {
            logger.debug("(Allowed fields are " + StylerUtils.style(binder.getAllowedFields()) + ")");
        } else {
            logger.debug("(Any field is allowed)");
        }
    }
    logger.debug("BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBb");
    logger.debug("BBBBBBBBB Value of binder befor binding BBBBBBBBBBBBBBBBBBb");
    logger.debug("BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBb");
    logger.debug(binder);
    binder.bind(new MutablePropertyValues(context.getRequestParameters().asMap()));
    logger.debug("BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBb");
    logger.debug("BBBBBBBBB Value of binder after binding BBBBBBBBBBBBBBBBBBb");
    logger.debug("BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBb");
    logger.debug(binder);

    if (logger.isDebugEnabled()) {
        logger.debug("Binding completed for form object with name '" + binder.getObjectName()
                + "', post-bind formObject toString = " + binder.getTarget());
        logger.debug("There are [" + binder.getErrors().getErrorCount() + "] errors, details: "
                + binder.getErrors().getAllErrors());
    }
}

From source file:org.springframework.binding.method.MethodInvoker.java

/**
 * Invoke the method on the bean provided. Argument values are pulled from the provided argument source.
 * @param signature the definition of the method to invoke, including the method name and the method argument types
 * @param bean the bean to invoke//from w w w.  j  av  a  2  s  .  c o  m
 * @param argumentSource the source for method arguments
 * @return the invoked method's return value
 * @throws MethodInvocationException the method could not be invoked
 */
public Object invoke(MethodSignature signature, Object bean, Object argumentSource)
        throws MethodInvocationException {
    Parameters parameters = signature.getParameters();
    Object[] arguments = new Object[parameters.size()];
    for (int i = 0; i < parameters.size(); i++) {
        Parameter parameter = parameters.getParameter(i);
        Object argument = parameter.evaluateArgument(argumentSource);
        arguments[i] = applyTypeConversion(argument, parameter.getType());
    }
    Class<?>[] parameterTypes = parameters.getTypesArray();
    for (int i = 0; i < parameterTypes.length; i++) {
        if (parameterTypes[i] == null) {
            Object argument = arguments[i];
            if (argument != null) {
                parameterTypes[i] = argument.getClass();
            }
        }
    }
    MethodKey key = new MethodKey(bean.getClass(), signature.getMethodName(), parameterTypes);
    try {
        Method method = methodCache.get(key);
        if (logger.isDebugEnabled()) {
            logger.debug("Invoking method with signature [" + key + "] with arguments "
                    + StylerUtils.style(arguments) + " on bean [" + bean + "]");

        }
        Object returnValue = method.invoke(bean, arguments);
        if (logger.isDebugEnabled()) {
            logger.debug("Invoked method with signature [" + key + "] returned value [" + returnValue + "]");
        }
        return returnValue;
    } catch (InvocationTargetException e) {
        throw new MethodInvocationException(signature, arguments, e.getTargetException());
    } catch (Exception e) {
        throw new MethodInvocationException(signature, arguments, e);
    }
}

From source file:org.springframework.core.convert.support.GenericConversionService.java

public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
    assertNotNull(sourceType, targetType);
    if (logger.isDebugEnabled()) {
        logger.debug(/*w w w  . ja v a2s .  c om*/
                "Converting value " + StylerUtils.style(source) + " of " + sourceType + " to " + targetType);
    }
    if (sourceType == TypeDescriptor.NULL) {
        Assert.isTrue(source == null, "The value must be null if sourceType == TypeDescriptor.NULL");
        Object result = convertNullSource(sourceType, targetType);
        if (logger.isDebugEnabled()) {
            logger.debug("Converted to " + StylerUtils.style(result));
        }
        return result;
    }
    if (targetType == TypeDescriptor.NULL) {
        logger.debug("Converted to null");
        return null;
    }
    Assert.isTrue(source == null || sourceType.getObjectType().isInstance(source));
    GenericConverter converter = getConverter(sourceType, targetType);
    if (converter == null) {
        if (source == null || sourceType.isAssignableTo(targetType)) {
            logger.debug("No converter found - returning assignable source object as-is");
            return source;
        } else {
            throw new ConverterNotFoundException(sourceType, targetType);
        }
    }
    Object result = ConversionUtils.invokeConverter(converter, source, sourceType, targetType);
    if (logger.isDebugEnabled()) {
        logger.debug("Converted to " + StylerUtils.style(result));
    }
    return result;
}

From source file:org.springframework.richclient.image.DefaultImageSource.java

private void debugPrintResources() {
    if (logger.isDebugEnabled()) {
        logger.debug("Initialing image source with resources: " + StylerUtils.style(this.imageResources));
    }/*from   w  w  w . j a  v  a 2 s .  c o m*/
}

From source file:org.springframework.richclient.util.ClassUtils.java

public static Method getStaticMethod(String name, Class locatorClass, Class[] args) {
    try {/*  w w  w.j  a  v a 2  s  . c o  m*/
        logger.debug("Attempting to get method '" + name + "' on class " + locatorClass + " with arguments '"
                + StylerUtils.style(args) + "'");
        Method method = locatorClass.getDeclaredMethod(name, args);
        if ((method.getModifiers() & Modifier.STATIC) != 0)
            return method;

        return null;
    } catch (NoSuchMethodException e) {
        return null;
    }
}

From source file:org.springframework.rules.reporting.DefaultMessageTranslator.java

private String buildMessage(String objectName, Object rejectedValue, Constraint constraint) {
    StringBuffer buf = new StringBuffer(255);
    MessageSourceResolvable[] args = resolveArguments(constraint);
    if (logger.isDebugEnabled()) {
        logger.debug(StylerUtils.style(args));
    }/*from w  ww . j a v  a 2 s . c om*/
    if (objectName != null) {
        buf.append(resolveObjectName(objectName));
        buf.append(' ');
    }
    for (int i = 0; i < args.length - 1; i++) {
        MessageSourceResolvable arg = args[i];
        buf.append(messages.getMessage(arg, locale));
        buf.append(' ');
    }
    buf.append(messages.getMessage(args[args.length - 1], locale));
    buf.append(".");
    return buf.toString();
}

From source file:org.springframework.web.portlet.DispatcherPortlet.java

/**
 * No handler found -> throw appropriate exception.
 * @param request current portlet request
 * @param response current portlet response
 * @throws Exception if preparing the response failed
 *//*from   w w  w . j ava2s . c  om*/
protected void noHandlerFound(PortletRequest request, PortletResponse response) throws Exception {
    if (pageNotFoundLogger.isWarnEnabled()) {
        pageNotFoundLogger.warn("No handler found for current request " + "in DispatcherPortlet with name '"
                + getPortletName() + "', mode '" + request.getPortletMode() + "', phase '"
                + request.getAttribute(PortletRequest.LIFECYCLE_PHASE) + "', parameters "
                + StylerUtils.style(request.getParameterMap()));
    }
    throw new NoHandlerFoundException("No handler found for portlet request", request);
}

From source file:org.springframework.webflow.engine.Flow.java

/**
 * Add given state definition to this flow definition. Marked protected, as this method is to be called by the
 * (privileged) state definition classes themselves during state construction as part of a FlowBuilder invocation.
 * @param state the state to add//  w  w w .  jav  a 2s  . c  o  m
 * @throws IllegalArgumentException when the state cannot be added to the flow; for instance if another state shares
 * the same id as the one provided or if given state already belongs to another flow
 */
protected void add(State state) throws IllegalArgumentException {
    if (this != state.getFlow() && state.getFlow() != null) {
        throw new IllegalArgumentException("State " + state + " cannot be added to this flow '" + getId()
                + "' -- it already belongs to a different flow: '" + state.getFlow().getId() + "'");
    }
    if (this.states.contains(state) || this.containsState(state.getId())) {
        throw new IllegalArgumentException("This flow '" + getId() + "' already contains a state with id '"
                + state.getId() + "' -- state ids must be locally unique to the flow definition; "
                + "existing state-ids of this flow include: " + StylerUtils.style(getStateIds()));
    }
    boolean firstAdd = states.isEmpty();
    states.add(state);
    if (firstAdd) {
        setStartState(state);
    }
}

From source file:org.springframework.webflow.engine.Flow.java

/**
 * Lookup the identified state instance of this flow.
 * @param stateId the state id/*w  ww .  j  a v a2s.  c  o m*/
 * @return the state
 * @throws IllegalArgumentException if the identified state cannot be found
 */
public State getStateInstance(String stateId) throws IllegalArgumentException {
    if (!StringUtils.hasText(stateId)) {
        throw new IllegalArgumentException(
                "The specified stateId is invalid: state identifiers must be non-blank");
    }
    for (State state : states) {
        if (state.getId().equals(stateId)) {
            return state;
        }
    }
    throw new IllegalArgumentException("Cannot find state with id '" + stateId + "' in flow '" + getId()
            + "' -- " + "Known state ids are '" + StylerUtils.style(getStateIds()) + "'");
}