Package org.nasutekds.server.admin.client.ldap

Examples of org.nasutekds.server.admin.client.ldap.LDAPManagedObject$ValueEncoder


        expect(pke.toValue(primaryKey)).andReturn(value);

        replay();

        ValueEncoder ve = coercion.coerce(pke);

        assertEquals(ve.toClient(value), "99");
        assertEquals(ve.toValue("99"), value);

        verify();
    }
View Full Code Here


                    if (isArray)
                    {
                        parameterType = parameterType.getComponentType();
                    }
                   
                    ValueEncoder valueEncoder = valueEncoderSource.getValueEncoder(parameterType);

                    String parameterValue = request.getParameter(parameterName);

                    if (!allowBlank && parameterValue == null)
                        throw new RuntimeException(String.format(
                                "The value for query parameter '%s' was blank, but a non-blank value is needed.",
                                parameterName));
                   
                    Object value;

                    if (!isArray) {
                        value = coerce(parameterName, parameterType, parameterValue, valueEncoder);
                    }
                    else {
                        String[] parameterValues = request.getParameters(parameterName);
                        Object[] array = (Object[]) Array.newInstance(parameterType, parameterValues.length);
                        for (int i = 0; i < parameterValues.length; i++)
                        {
                            array[i] = coerce(parameterName, parameterType, parameterValues[i], valueEncoder);
                        }
                        value = array;
                    }

                    return value;
                } catch (Exception ex)
                {
                    throw new RuntimeException(
                            String.format(
                                    "Unable process query parameter '%s' as parameter #%d of event handler method %s: %s",
                                    parameterName, parameterIndex + 1, methodIdentifier,
                                    ExceptionUtils.toMessage(ex)), ex);
                }
            }

            private Object coerce(final String parameterName, Class parameterType,
                    String parameterValue, ValueEncoder valueEncoder)
            {
                Object value = valueEncoder.toValue(parameterValue);

                if (parameterType.isPrimitive() && value == null)
                    throw new RuntimeException(
                            String.format(
                                    "Query parameter '%s' evaluates to null, but the event method parameter is type %s, a primitive.",
View Full Code Here

        final ClassPropertyAdapter classPropertyAdapter = this.propertyAccess.getAdapter(object);

        final PropertyAdapter propertyAdapter = classPropertyAdapter
                .getPropertyAdapter(labelProperty);

        final ValueEncoder encoder = this.valueEncoderSource.getValueEncoder(propertyAdapter
                .getType());

        final Object label = propertyAdapter.get(object);

        return encoder.toClient(label);
    }
View Full Code Here

        // Assumption: the field type is not one that's loaded by the component class loader, so it's safe
        // to convert to a hard type during class transformation.

        Class fieldType = classCache.forName(field.getTypeName());

        ValueEncoder encoder = valueEncoderSource.getValueEncoder(fieldType);

        FieldHandle handle = field.getHandle();

        String fieldName = String.format("%s.%s", field.getPlasticClass().getClassName(), field.getName());
View Full Code Here

    public String toClient(Object value)
    {
        Defense.notNull(value, "value");

        ValueEncoder encoder = valueEncoderSource.getValueEncoder(value.getClass());

        return encoder.toClient(value);
    }
View Full Code Here

public class ContextValueEncoderImplTest extends InternalBaseTestCase
{
    @Test
    public void to_client()
    {
        ValueEncoder valueEncoder = mockValueEncoder();
        ValueEncoderSource source = mockValueEncoderSource();

        Long value = 23L;
        String encoded = "twentythree";
View Full Code Here


    @Test
    public void to_value()
    {
        ValueEncoder valueEncoder = mockValueEncoder();
        ValueEncoderSource source = mockValueEncoderSource();

        Long value = 23L;
        String clientValue = "twentythree";
View Full Code Here

TOP

Related Classes of org.nasutekds.server.admin.client.ldap.LDAPManagedObject$ValueEncoder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.