Package org.apache.sling.api.wrappers

Examples of org.apache.sling.api.wrappers.ValueMapDecorator


    }

    @SuppressWarnings("unchecked")
    public <AdapterType> AdapterType adaptTo(Class<AdapterType> type) {
        if (type == ValueMap.class) {
            ValueMap map = new ValueMapDecorator(new HashMap<String, Object>());
            if (resourceType != null) {
                map.put("resourceType", resourceType);
            }
            if (resourceSuperType != null) {
                map.put("resourceSuperType", resourceSuperType);
            }
            for (String key : this.properties.keySet()) {
                map.put(key,this.properties.get(key));
            }
            return (AdapterType) map;
        }
        throw new UnsupportedOperationException("AdaptTo " + type.getSimpleName() + " not implemented");
    }
View Full Code Here


  @Test
  public void testAdaptObject() {
    log.info("testAdaptObject");

    log.info("Setting up tests");
    ValueMap properties = new ValueMapDecorator(
        new HashMap<String, Object>());
    properties.put(TEST_KEY, TEST_VALUE);
    getPropertyTag.setProperties(properties);
    getPropertyTag.setVar(VAR_KEY);

    log.info("Testing retrieving value with default value");
    getPropertyTag.setDefaultValue(TEST_VALUE);
View Full Code Here

        Map<String, Object> localMap = new HashMap<String, Object>();
        // copy all items to local map
        localMap.putAll(jcrVM);

        // decoarate it as value map
        ValueMapDecorator localVM = new ValueMapDecorator(localMap);

        this.vm = localVM;

    }
View Full Code Here

    @Override
    public <AdapterType> AdapterType adaptTo(Class<AdapterType> type) {

        if (type == ValueMap.class || type == Map.class) {
            return (AdapterType) new ValueMapDecorator(getProperties());
        } else {
            if (adapters != null) {
                for (Object adapter : adapters) {
                    if (adapter == null) continue;
View Full Code Here

          } else {
            throw new RuntimeException(
                "Unsupported property type: " + p.getType());
          }
        }
        ValueMap valueMap = new ValueMapDecorator(map);
        return (AdapterType) valueMap;
      } catch (Exception e) {
        e.printStackTrace();
        return null;
      }
View Full Code Here

        private final ModifiableValueMap targetMap;

        private final ValueMap properties;

        public ModifiableProperties(final Resource rsrc, final ModifiableValueMap targetMap) {
            this.properties = new DeepReadValueMapDecorator(rsrc, new ValueMapDecorator(new HashMap<String, Object>(rsrc.getValueMap())));
            this.targetMap = targetMap;
        }
View Full Code Here

        @SuppressWarnings("unchecked")
        @Override
        public <AdapterType> AdapterType adaptTo(Class<AdapterType> type) {
            if (type == ValueMap.class) {
                return (AdapterType) new ValueMapDecorator(props);
            }

            return super.adaptTo(type);
        }
View Full Code Here

                    } else {
                        throw new RuntimeException(
                                "Unsupported property type: " + p.getType());
                    }
                }
                ValueMap valueMap = new ValueMapDecorator(map);
                return (AdapterType) valueMap;
            } catch (Exception e) {
                e.printStackTrace();
                return null;
            }
View Full Code Here

    public <AdapterType> AdapterType getAdapter(Object adaptable, Class<AdapterType> type) {
        AdapterType adapter = null;
        if (adaptable instanceof SlingHttpServletRequest) {
            final SlingHttpServletRequest request = (SlingHttpServletRequest) adaptable;
            if (type == VALUE_MAP_CLASS) {
                adapter = (AdapterType) new ValueMapDecorator(request.getParameterMap());
            } else {
                LOG.warn("Cannot handle adapter {}", type.getName());
            }
        } else {
            LOG.warn("Cannot handle adaptable {}", adaptable.getClass().getName());
View Full Code Here

            }
            ValidationModel vm = validationService.getValidationModel("sling/validation/test", "/apps/validation/1/resource");
            HashMap<String, Object> hashMap = new HashMap<String, Object>() {{
                put("field1", "1");
            }};
            ValueMap map = new ValueMapDecorator(hashMap);
            ValidationResult vr = validationService.validate(map, vm);
        } finally {
            if (model1 != null) {
                rr.delete(model1);
            }
View Full Code Here

TOP

Related Classes of org.apache.sling.api.wrappers.ValueMapDecorator

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.