Example usage for org.springframework.expression TypedValue TypedValue

List of usage examples for org.springframework.expression TypedValue TypedValue

Introduction

In this page you can find the example usage for org.springframework.expression TypedValue TypedValue.

Prototype

public TypedValue(@Nullable Object value) 

Source Link

Document

Create a TypedValue for a simple object.

Usage

From source file:org.echocat.redprecursor.annotations.utils.MapPropertyAccessor.java

@Override
public TypedValue read(EvaluationContext context, Object target, String name) throws AccessException {
    final Object plainValue = target instanceof Map ? ((Map) target).get(name) : null;
    return plainValue != null ? new TypedValue(plainValue) : TypedValue.NULL;
}

From source file:com.fitbur.core.el.spring.internal.MapPropertyAccessor.java

@Override
public TypedValue read(EvaluationContext context, Object target, String name) throws AccessException {
    Map<?, ?> map = (Map<?, ?>) target;
    Object value = map.get(name);

    if (value == null && !map.containsKey(name)) {
        throw new MapAccessException(name);
    }//from   w w  w. j a va2  s.  c o  m
    return new TypedValue(value);
}

From source file:it.geosolutions.opensdi2.workflow.transform.spel.accessors.MapPropertyAccessor.java

@Override
public TypedValue read(EvaluationContext ctx, Object target, String name) throws AccessException {
    if (target instanceof Map) {

        return new TypedValue(((Map<String, Object>) target).get(name));
    }/*from ww  w  .  j  ava2  s  .com*/
    return null;
}

From source file:org.springjutsu.validation.spel.NamedAttributeAccessorPropertyAccessor.java

@Override
public TypedValue read(EvaluationContext context, Object target, String name) throws AccessException {
    return new TypedValue(((AbstractNamedAttributeAccessor) target).get(name));
}

From source file:guru.qas.martini.tag.CategoryExecutor.java

public TypedValue execute(Martini martini, String category) {
    Collection<MartiniTag> tags = martini.getTags();

    boolean evaluation = false;
    for (Iterator<MartiniTag> i = tags.iterator(); !evaluation && i.hasNext();) {
        MartiniTag tag = i.next();// w  w  w. java2 s  .  co  m
        evaluation = categories.isMatch(category, tag);
    }
    return new TypedValue(evaluation);
}

From source file:guru.qas.martini.tag.AbstractIdentifierExecutor.java

public TypedValue execute(Martini martini, String identifier) {
    String martiniIdentifier = getIdentifier(martini);
    String normalizedMartiniIdentifier = getNormalized(martiniIdentifier);
    String normalizedIdentifier = getNormalized(identifier);
    boolean evaluation = normalizedMartiniIdentifier.equals(normalizedIdentifier);
    return new TypedValue(evaluation);
}

From source file:guru.qas.martini.tag.TagExecutor.java

protected TypedValue execute(Martini martini, String argument) {
    Collection<MartiniTag> tags = martini.getTags();
    boolean evaluation = false;
    for (Iterator<MartiniTag> i = tags.iterator(); !evaluation && i.hasNext();) {
        MartiniTag tag = i.next();/*from   w  w  w.  j  a  va2  s .  c  om*/
        String candidate = tag.getName();
        evaluation = null == argument ? tagName.equals(candidate)
                : tagName.equals(candidate) && argument.equals(tag.getArgument());
    }
    return new TypedValue(evaluation);
}

From source file:org.echocat.redprecursor.annotations.utils.MethodCallPropertyAccessor.java

@Override
public TypedValue read(EvaluationContext context, Object target, String name) throws AccessException {
    final Object value;
    if (target instanceof MethodCall) {
        final MethodCall<?> methodCall = (MethodCall<?>) target;
        if (THIS_KEYWORD.equals(name)) {
            final Object thisInstance = methodCall.getThis();
            value = thisInstance != null ? thisInstance : methodCall.getType();
        } else {/* w  w w  .  ja  v a  2 s.  co  m*/
            value = methodCall.getParameters().getParameter(name).getValue();
        }
    } else {
        throw new AccessException(target + " is no instance of " + MethodCall.class.getName() + ".");
    }
    return new TypedValue(value);
}

From source file:it.geosolutions.geostore.core.security.MapExpressionUserMapper.java

public MapExpressionUserMapper(Map<String, String> attributeMappings) {
    super(attributeMappings);
    // property accessor for JSONObject attributes (read only)
    evaluationContext.addPropertyAccessor(new PropertyAccessor() {

        @Override/*from ww w. j a  v a 2 s. c o m*/
        public void write(EvaluationContext ctx, Object target, String name, Object value)
                throws AccessException {

        }

        @Override
        public TypedValue read(EvaluationContext ctx, Object target, String name) throws AccessException {
            if (target instanceof Map) {
                Map map = (Map) target;
                return new TypedValue(map.get(name));
            }
            return null;
        }

        @Override
        public Class[] getSpecificTargetClasses() {
            return new Class[] { Map.class };
        }

        @Override
        public boolean canWrite(EvaluationContext ctx, Object target, String name) throws AccessException {
            return false;
        }

        @Override
        public boolean canRead(EvaluationContext ctx, Object target, String name) throws AccessException {
            return target instanceof Map;
        }
    });
}

From source file:it.geosolutions.geostore.core.security.JSONExpressionUserMapper.java

public JSONExpressionUserMapper(Map<String, String> attributeMappings) {
    super(attributeMappings);
    // property accessor for JSONObject attributes (read only)
    evaluationContext.addPropertyAccessor(new PropertyAccessor() {

        @Override//from ww w.j a v a2s . c  om
        public void write(EvaluationContext ctx, Object target, String name, Object value)
                throws AccessException {

        }

        @Override
        public TypedValue read(EvaluationContext ctx, Object target, String name) throws AccessException {
            if (target instanceof JSONObject) {
                JSONObject details = (JSONObject) target;
                return new TypedValue(details.get(name));
            }
            return null;
        }

        @Override
        public Class[] getSpecificTargetClasses() {
            return new Class[] { JSONObject.class };
        }

        @Override
        public boolean canWrite(EvaluationContext ctx, Object target, String name) throws AccessException {
            return false;
        }

        @Override
        public boolean canRead(EvaluationContext ctx, Object target, String name) throws AccessException {
            return target instanceof JSONObject;
        }
    });
}