@Override /* Serializer */ public WriterSerializerSession createSession(SerializerSessionArgs args) { return new UrlEncodingSerializerSession(this, null, args); }
private boolean shouldUseExpandedParams(Object value) { if (value == null || ! isExpandedParams()) return false; ClassMeta<?> cm = getClassMetaForObject(value).getSerializedClassMeta(this); if (cm.isCollectionOrArray()) { if (isExpandedParams()) return true; } return false; }
@Override /* SerializerSession */ protected void doSerialize(SerializerPipe out, Object o) throws Exception { serializeAnything(getUonWriter(out), o); }
ClassMeta<?> eType = getExpectedRootType(o); aType = push("root", o, eType); indent--; if (aType == null) aType = object(); String typeName = getBeanTypeName(eType, aType, null); sType = getClassMetaForObject(o); serializeBeanMap(out, (BeanMap)o, typeName); else serializeMap(out, (Map)o, sType); } else if (sType.isBean()) { serializeBeanMap(out, toBeanMap(o), typeName); } else if (sType.isCollection() || sType.isArray()) { Map m = sType.isCollection() ? getCollectionMap((Collection)o) : getCollectionMap(o); serializeCollectionMap(out, m, getClassMeta(Map.class, Integer.class, Object.class)); } else if (sType.isReader() || sType.isInputStream()) { IOUtils.pipe(o, out); pop(); return out;
private SerializerWriter serializeBeanMap(UonWriter out, BeanMap<?> m, String typeName) throws Exception { boolean addAmp = false; for (BeanPropertyValue p : m.getValues(isTrimNullProperties(), typeName != null ? createBeanTypeNameProperty(m, typeName) : null)) { BeanPropertyMeta pMeta = p.getMeta(); if (pMeta.canRead()) { Throwable t = p.getThrown(); if (t != null) onBeanGetterException(pMeta, t); if (canIgnoreValue(sMeta, key, value)) continue; if (value != null && shouldUseExpandedParams(pMeta)) {
private SerializerWriter serializeMap(UonWriter out, Map m, ClassMeta<?> type) throws Exception { m = sort(m); ClassMeta<?> keyType = type.getKeyType(), valueType = type.getValueType(); boolean addAmp = false; for (Map.Entry e : (Set<Map.Entry>)m.entrySet()) { Object key = generalize(e.getKey(), keyType); Object value = e.getValue(); if (shouldUseExpandedParams(value)) { Iterator i = value instanceof Collection ? ((Collection)value).iterator() : iterator(value); while (i.hasNext()) { if (addAmp) out.cr(indent).append('&'); out.appendObject(key, true).append('='); super.serializeAnything(out, i.next(), null, (key == null ? null : key.toString()), null); addAmp = true; } } else { if (addAmp) out.cr(indent).append('&'); out.appendObject(key, true).append('='); super.serializeAnything(out, value, valueType, (key == null ? null : key.toString()), null); addAmp = true; } } return out; }
ClassMeta<?> eType = getExpectedRootType(o); aType = push("root", o, eType); indent--; if (aType == null) aType = object(); String typeName = getBeanTypeName(eType, aType, null); sType = getClassMetaForObject(o); serializeBeanMap(out, (BeanMap)o, typeName); else serializeMap(out, (Map)o, sType); } else if (sType.isBean()) { serializeBeanMap(out, toBeanMap(o), typeName); } else if (sType.isCollection() || sType.isArray()) { Map m = sType.isCollection() ? getCollectionMap((Collection)o) : getCollectionMap(o); serializeCollectionMap(out, m, getClassMeta(Map.class, Integer.class, Object.class)); } else if (sType.isReader() || sType.isInputStream()) { IOUtils.pipe(o, out); pop(); return out;
private SerializerWriter serializeBeanMap(UonWriter out, BeanMap<?> m, String typeName) throws Exception { boolean addAmp = false; for (BeanPropertyValue p : m.getValues(isTrimNullProperties(), typeName != null ? createBeanTypeNameProperty(m, typeName) : null)) { BeanPropertyMeta pMeta = p.getMeta(); if (pMeta.canRead()) { Throwable t = p.getThrown(); if (t != null) onBeanGetterException(pMeta, t); if (canIgnoreValue(sMeta, key, value)) continue; if (value != null && shouldUseExpandedParams(pMeta)) {
private SerializerWriter serializeMap(UonWriter out, Map m, ClassMeta<?> type) throws Exception { m = sort(m); ClassMeta<?> keyType = type.getKeyType(), valueType = type.getValueType(); boolean addAmp = false; for (Map.Entry e : (Set<Map.Entry>)m.entrySet()) { Object key = generalize(e.getKey(), keyType); Object value = e.getValue(); if (shouldUseExpandedParams(value)) { Iterator i = value instanceof Collection ? ((Collection)value).iterator() : iterator(value); while (i.hasNext()) { if (addAmp) out.cr(indent).append('&'); out.appendObject(key, true).append('='); super.serializeAnything(out, i.next(), null, (key == null ? null : key.toString()), null); addAmp = true; } } else { if (addAmp) out.cr(indent).append('&'); out.appendObject(key, true).append('='); super.serializeAnything(out, value, valueType, (key == null ? null : key.toString()), null); addAmp = true; } } return out; }
ClassMeta<?> eType = getExpectedRootType(o); aType = push("root", o, eType); indent--; if (aType == null) aType = object(); String typeName = getBeanTypeName(eType, aType, null); sType = getClassMetaForObject(o); serializeBeanMap(out, (BeanMap)o, typeName); else serializeMap(out, (Map)o, sType); } else if (sType.isBean()) { serializeBeanMap(out, toBeanMap(o), typeName); } else if (sType.isCollection() || sType.isArray()) { Map m = sType.isCollection() ? getCollectionMap((Collection)o) : getCollectionMap(o); serializeCollectionMap(out, m, getClassMeta(Map.class, Integer.class, Object.class)); } else if (sType.isReader() || sType.isInputStream()) { IOUtils.pipe(o, out); pop(); return out;
private SerializerWriter serializeBeanMap(UonWriter out, BeanMap<?> m, String typeName) throws Exception { boolean addAmp = false; for (BeanPropertyValue p : m.getValues(isTrimNullProperties(), typeName != null ? createBeanTypeNameProperty(m, typeName) : null)) { BeanPropertyMeta pMeta = p.getMeta(); if (pMeta.canRead()) { Throwable t = p.getThrown(); if (t != null) onBeanGetterException(pMeta, t); if (canIgnoreValue(sMeta, key, value)) continue; if (value != null && shouldUseExpandedParams(pMeta)) {
private SerializerWriter serializeMap(UonWriter out, Map m, ClassMeta<?> type) throws Exception { m = sort(m); ClassMeta<?> keyType = type.getKeyType(), valueType = type.getValueType(); boolean addAmp = false; for (Map.Entry e : (Set<Map.Entry>)m.entrySet()) { Object key = generalize(e.getKey(), keyType); Object value = e.getValue(); if (shouldUseExpandedParams(value)) { Iterator i = value instanceof Collection ? ((Collection)value).iterator() : iterator(value); while (i.hasNext()) { if (addAmp) out.cr(indent).append('&'); out.appendObject(key, true).append('='); super.serializeAnything(out, i.next(), null, (key == null ? null : key.toString()), null); addAmp = true; } } else { if (addAmp) out.cr(indent).append('&'); out.appendObject(key, true).append('='); super.serializeAnything(out, value, valueType, (key == null ? null : key.toString()), null); addAmp = true; } } return out; }
private boolean shouldUseExpandedParams(Object value) { if (value == null || ! isExpandedParams()) return false; ClassMeta<?> cm = getClassMetaForObject(value).getSerializedClassMeta(this); if (cm.isCollectionOrArray()) { if (isExpandedParams()) return true; } return false; }
@Override /* SerializerSession */ protected void doSerialize(SerializerPipe out, Object o) throws Exception { serializeAnything(getUonWriter(out), o); }
@Override /* Serializer */ public WriterSerializerSession createSession(SerializerSessionArgs args) { return new UrlEncodingSerializerSession(this, null, args); }
private boolean shouldUseExpandedParams(Object value) { if (value == null || ! isExpandedParams()) return false; ClassMeta<?> cm = getClassMetaForObject(value).getSerializedClassMeta(this); if (cm.isCollectionOrArray()) { if (isExpandedParams()) return true; } return false; }
@Override /* SerializerSession */ protected void doSerialize(SerializerPipe out, Object o) throws Exception { serializeAnything(getUonWriter(out), o); }
@Override /* Serializer */ public WriterSerializerSession createSession(SerializerSessionArgs args) { return new UrlEncodingSerializerSession(this, null, args); }