@Override public boolean visitReferenceProperty(String propertyName, AutoBean<?> value, PropertyContext ctx) { // containsKey to distinguish null from unknown if (flatValueMap.containsKey(propertyName)) { Object resolved = null; // The null check on getKeyType() is necessary as some of the given PropertyContext's // implement both MapPropertyContext and CollectionPropertyContext. if (ctx.getType() == Map.class) { MapPropertyContext mapCtx = (MapPropertyContext) ctx; Class<?> keyType = mapCtx.getKeyType(); Class<?> valueType = mapCtx.getValueType(); Object newValue = EntityCodex.decode(state, mapCtx.getType(), keyType, valueType, flatValueMap.get(propertyName)); resolved = state.getResolver().resolveDomainValue(newValue, false); } else { Class<?> elementType = ctx instanceof CollectionPropertyContext ? ((CollectionPropertyContext) ctx) .getElementType() : null; Object newValue = EntityCodex.decode(state, ctx.getType(), elementType, flatValueMap .get(propertyName)); resolved = state.getResolver().resolveDomainValue(newValue, false); } service.setProperty(domain, propertyName, service.resolveDomainClass(ctx.getType()), resolved); } return false; }
private void encodeProperty(String propertyName, Object value, PropertyContext ctx) { CoderCreator pd = new CoderCreator(); ctx.accept(pd); Coder decoder = pd.getCoder(); if (first) { first = false; } else { state.sb.append(","); } state.sb.append(StringQuoter.quote(propertyName)); state.sb.append(":"); decoder.encode(state, value); } }
@Override public boolean visitReferenceProperty(String propertyName, AutoBean<?> value, PropertyContext ctx) { if (ctx.canSet()) { if (properties.containsKey(propertyName)) { Splittable raw = properties.get(propertyName); Object decoded = null; if (ctx.getType() == Map.class) { MapPropertyContext mapCtx = (MapPropertyContext) ctx; Class<?> keyType = mapCtx.getKeyType(); Class<?> valueType = mapCtx.getValueType(); decoded = EntityCodex.decode(AbstractRequestContext.this, mapCtx.getType(), keyType, valueType, raw); } else { Class<?> elementType = ctx instanceof CollectionPropertyContext ? ((CollectionPropertyContext) ctx) .getElementType() : null; decoded = EntityCodex.decode(AbstractRequestContext.this, ctx.getType(), elementType, raw); } ctx.set(decoded); } } return false; }
@Override public boolean visitReferenceProperty(String propertyName, AutoBean<?> value, PropertyContext ctx) { // containsKey to distinguish null from unknown if (flatValueMap.containsKey(propertyName)) { Object resolved = null; // The null check on getKeyType() is necessary as some of the given PropertyContext's // implement both MapPropertyContext and CollectionPropertyContext. if (ctx.getType() == Map.class) { MapPropertyContext mapCtx = (MapPropertyContext) ctx; Class<?> keyType = mapCtx.getKeyType(); Class<?> valueType = mapCtx.getValueType(); Object newValue = EntityCodex.decode(state, mapCtx.getType(), keyType, valueType, flatValueMap.get(propertyName)); resolved = state.getResolver().resolveDomainValue(newValue, false); } else { Class<?> elementType = ctx instanceof CollectionPropertyContext ? ((CollectionPropertyContext) ctx) .getElementType() : null; Object newValue = EntityCodex.decode(state, ctx.getType(), elementType, flatValueMap .get(propertyName)); resolved = state.getResolver().resolveDomainValue(newValue, false); } service.setProperty(domain, propertyName, service.resolveDomainClass(ctx.getType()), resolved); } return false; }
@Override public boolean visitReferenceProperty(String propertyName, AutoBean<?> value, PropertyContext ctx) { // containsKey to distinguish null from unknown if (flatValueMap.containsKey(propertyName)) { Object resolved = null; // The null check on getKeyType() is necessary as some of the given PropertyContext's // implement both MapPropertyContext and CollectionPropertyContext. if (ctx.getType() == Map.class) { MapPropertyContext mapCtx = (MapPropertyContext) ctx; Class<?> keyType = mapCtx.getKeyType(); Class<?> valueType = mapCtx.getValueType(); Object newValue = EntityCodex.decode(state, mapCtx.getType(), keyType, valueType, flatValueMap.get(propertyName)); resolved = state.getResolver().resolveDomainValue(newValue, false); } else { Class<?> elementType = ctx instanceof CollectionPropertyContext ? ((CollectionPropertyContext) ctx) .getElementType() : null; Object newValue = EntityCodex.decode(state, ctx.getType(), elementType, flatValueMap .get(propertyName)); resolved = state.getResolver().resolveDomainValue(newValue, false); } service.setProperty(domain, propertyName, service.resolveDomainClass(ctx.getType()), resolved); } return false; }
@Override public boolean visitReferenceProperty(String propertyName, AutoBean<?> value, PropertyContext ctx) { // containsKey to distinguish null from unknown if (flatValueMap.containsKey(propertyName)) { Object resolved = null; // The null check on getKeyType() is necessary as some of the given PropertyContext's // implement both MapPropertyContext and CollectionPropertyContext. if (ctx.getType() == Map.class) { MapPropertyContext mapCtx = (MapPropertyContext) ctx; Class<?> keyType = mapCtx.getKeyType(); Class<?> valueType = mapCtx.getValueType(); Object newValue = EntityCodex.decode(state, mapCtx.getType(), keyType, valueType, flatValueMap.get(propertyName)); resolved = state.getResolver().resolveDomainValue(newValue, false); } else { Class<?> elementType = ctx instanceof CollectionPropertyContext ? ((CollectionPropertyContext) ctx) .getElementType() : null; Object newValue = EntityCodex.decode(state, ctx.getType(), elementType, flatValueMap .get(propertyName)); resolved = state.getResolver().resolveDomainValue(newValue, false); } service.setProperty(domain, propertyName, service.resolveDomainClass(ctx.getType()), resolved); } return false; }
@Override public boolean visitReferenceProperty(String propertyName, AutoBean<?> value, PropertyContext ctx) { if (ctx.canSet()) { if (properties.containsKey(propertyName)) { Splittable raw = properties.get(propertyName); Object decoded = null; if (ctx.getType() == Map.class) { MapPropertyContext mapCtx = (MapPropertyContext) ctx; Class<?> keyType = mapCtx.getKeyType(); Class<?> valueType = mapCtx.getValueType(); decoded = EntityCodex.decode(AbstractRequestContext.this, mapCtx.getType(), keyType, valueType, raw); } else { Class<?> elementType = ctx instanceof CollectionPropertyContext ? ((CollectionPropertyContext) ctx) .getElementType() : null; decoded = EntityCodex.decode(AbstractRequestContext.this, ctx.getType(), elementType, raw); } ctx.set(decoded); } } return false; }
@Override public boolean visitReferenceProperty(String propertyName, AutoBean<?> value, PropertyContext ctx) { if (ctx.canSet()) { if (properties.containsKey(propertyName)) { Splittable raw = properties.get(propertyName); Object decoded = null; if (ctx.getType() == Map.class) { MapPropertyContext mapCtx = (MapPropertyContext) ctx; Class<?> keyType = mapCtx.getKeyType(); Class<?> valueType = mapCtx.getValueType(); decoded = EntityCodex.decode(AbstractRequestContext.this, mapCtx.getType(), keyType, valueType, raw); } else { Class<?> elementType = ctx instanceof CollectionPropertyContext ? ((CollectionPropertyContext) ctx) .getElementType() : null; decoded = EntityCodex.decode(AbstractRequestContext.this, ctx.getType(), elementType, raw); } ctx.set(decoded); } } return false; }
@Override public boolean visitReferenceProperty(String propertyName, AutoBean<?> value, PropertyContext ctx) { if (ctx.canSet()) { if (properties.containsKey(propertyName)) { Splittable raw = properties.get(propertyName); Object decoded = null; if (ctx.getType() == Map.class) { MapPropertyContext mapCtx = (MapPropertyContext) ctx; Class<?> keyType = mapCtx.getKeyType(); Class<?> valueType = mapCtx.getValueType(); decoded = EntityCodex.decode(AbstractRequestContext.this, mapCtx.getType(), keyType, valueType, raw); } else { Class<?> elementType = ctx instanceof CollectionPropertyContext ? ((CollectionPropertyContext) ctx) .getElementType() : null; decoded = EntityCodex.decode(AbstractRequestContext.this, ctx.getType(), elementType, raw); } ctx.set(decoded); } } return false; }
@SuppressWarnings("unchecked") public boolean visitReferenceProperty(String propertyName, AutoBean<?> value, PropertyContext ctx) { if (Map.class.getName().equals(ctx.getType().getName())) { // Only Map<String, String> is supported! final AutoBean<Map<String, String>> mapValue = (AutoBean<Map<String, String>>) value; visitItem(propertyName, new FormItemVisitor() { public void visit(FormItem item) { item.resetMetaData(); if (mapValue != null) { item.setUndefined(false); item.setValue(mapValue.as()); } else { item.setUndefined(true); item.setModified(true); // don't escape validation } } }); } else { isComplex = true; //System.out.println("begin reference "+propertyName+ ": "+ctx.getType()); } return true; }
@Override public boolean visitReferenceProperty(String propertyName, AutoBean<?> value, PropertyContext ctx) { value = AutoBeanUtils.getAutoBean(values.get(propertyName)); if (value != null) { if (isValueType(ctx.getType()) || isEntityType(ctx.getType())) { /* * Value proxies must be cloned upfront, since the value is replaced outright. */ @SuppressWarnings("unchecked") AutoBean<BaseProxy> valueBean = (AutoBean<BaseProxy>) value; ctx.set(editProxy(valueBean.as())); } else { ctx.set(value.as()); } } return false; }
@Override public boolean visitReferenceProperty(String propertyName, AutoBean<?> value, PropertyContext ctx) { value = AutoBeanUtils.getAutoBean(values.get(propertyName)); if (value != null) { if (isValueType(ctx.getType()) || isEntityType(ctx.getType())) { /* * Value proxies must be cloned upfront, since the value is replaced outright. */ @SuppressWarnings("unchecked") AutoBean<BaseProxy> valueBean = (AutoBean<BaseProxy>) value; ctx.set(editProxy(valueBean.as())); } else { ctx.set(value.as()); } } return false; }
@Override public boolean visitReferenceProperty(String propertyName, AutoBean<?> value, PropertyContext ctx) { value = AutoBeanUtils.getAutoBean(values.get(propertyName)); if (value != null) { if (isValueType(ctx.getType()) || isEntityType(ctx.getType())) { /* * Value proxies must be cloned upfront, since the value is replaced outright. */ @SuppressWarnings("unchecked") AutoBean<BaseProxy> valueBean = (AutoBean<BaseProxy>) value; ctx.set(editProxy(valueBean.as())); } else { ctx.set(value.as()); } } return false; }
@Override public boolean visitValueProperty(String propertyName, Object value, PropertyContext ctx) { if (ctx.canSet()) { if (properties.containsKey(propertyName)) { Splittable raw = properties.get(propertyName); Object decoded = ValueCodex.decode(ctx.getType(), raw); /* * Hack for Date subtypes, consider generalizing for "custom serializers" */ if (decoded != null && Date.class.equals(ctx.getType())) { decoded = new DatePoser((Date) decoded); } ctx.set(decoded); } } return false; } });
@Override public boolean visitValueProperty(String propertyName, Object value, PropertyContext ctx) { if (ctx.canSet()) { if (properties.containsKey(propertyName)) { Splittable raw = properties.get(propertyName); Object decoded = ValueCodex.decode(ctx.getType(), raw); /* * Hack for Date subtypes, consider generalizing for "custom serializers" */ if (decoded != null && Date.class.equals(ctx.getType())) { decoded = new DatePoser((Date) decoded); } ctx.set(decoded); } } return false; } });
@Override public boolean visitValueProperty(String propertyName, Object value, PropertyContext ctx) { if (ctx.canSet()) { if (properties.containsKey(propertyName)) { Splittable raw = properties.get(propertyName); Object decoded = ValueCodex.decode(ctx.getType(), raw); /* * Hack for Date subtypes, consider generalizing for "custom serializers" */ if (decoded != null && Date.class.equals(ctx.getType())) { decoded = new DatePoser((Date) decoded); } ctx.set(decoded); } } return false; } });
@Override public boolean visitValueProperty(String propertyName, Object value, PropertyContext ctx) { /* * Only call the getter for simple values once since they're not * explicitly enumerated. */ if (needsSimpleValues) { // Limit unrequested value properties? value = service.getProperty(domainEntity, propertyName); ctx.set(value); } return false; } }