http://git-wip-us.apache.org/repos/asf/incubator-juneau-website/blob/62afb533/content/site/apidocs/src-html/org/apache/juneau/uon/UonSerializerSession.html ---------------------------------------------------------------------- diff --git a/content/site/apidocs/src-html/org/apache/juneau/uon/UonSerializerSession.html b/content/site/apidocs/src-html/org/apache/juneau/uon/UonSerializerSession.html index 1e05dec..15937e8 100644 --- a/content/site/apidocs/src-html/org/apache/juneau/uon/UonSerializerSession.html +++ b/content/site/apidocs/src-html/org/apache/juneau/uon/UonSerializerSession.html @@ -137,149 +137,150 @@ <span class="sourceLineNo">129</span> aType = object();<a name="line.129"></a> <span class="sourceLineNo">130</span> }<a name="line.130"></a> <span class="sourceLineNo">131</span><a name="line.131"></a> -<span class="sourceLineNo">132</span> sType = aType.getSerializedClassMeta();<a name="line.132"></a> +<span class="sourceLineNo">132</span> sType = aType;<a name="line.132"></a> <span class="sourceLineNo">133</span> String typeName = getBeanTypeName(eType, aType, pMeta);<a name="line.133"></a> <span class="sourceLineNo">134</span><a name="line.134"></a> <span class="sourceLineNo">135</span> // Swap if necessary<a name="line.135"></a> -<span class="sourceLineNo">136</span> PojoSwap swap = aType.getPojoSwap();<a name="line.136"></a> +<span class="sourceLineNo">136</span> PojoSwap swap = aType.getPojoSwap(this);<a name="line.136"></a> <span class="sourceLineNo">137</span> if (swap != null) {<a name="line.137"></a> <span class="sourceLineNo">138</span> o = swap.swap(this, o);<a name="line.138"></a> -<span class="sourceLineNo">139</span><a name="line.139"></a> -<span class="sourceLineNo">140</span> // If the getSwapClass() method returns Object, we need to figure out<a name="line.140"></a> -<span class="sourceLineNo">141</span> // the actual type now.<a name="line.141"></a> -<span class="sourceLineNo">142</span> if (sType.isObject())<a name="line.142"></a> -<span class="sourceLineNo">143</span> sType = getClassMetaForObject(o);<a name="line.143"></a> -<span class="sourceLineNo">144</span> }<a name="line.144"></a> -<span class="sourceLineNo">145</span><a name="line.145"></a> -<span class="sourceLineNo">146</span> // '\0' characters are considered null.<a name="line.146"></a> -<span class="sourceLineNo">147</span> if (o == null || (sType.isChar() && ((Character)o).charValue() == 0))<a name="line.147"></a> -<span class="sourceLineNo">148</span> out.appendObject(null, false);<a name="line.148"></a> -<span class="sourceLineNo">149</span> else if (sType.isBoolean())<a name="line.149"></a> -<span class="sourceLineNo">150</span> out.appendBoolean(o);<a name="line.150"></a> -<span class="sourceLineNo">151</span> else if (sType.isNumber())<a name="line.151"></a> -<span class="sourceLineNo">152</span> out.appendNumber(o);<a name="line.152"></a> -<span class="sourceLineNo">153</span> else if (sType.isBean())<a name="line.153"></a> -<span class="sourceLineNo">154</span> serializeBeanMap(out, toBeanMap(o), typeName);<a name="line.154"></a> -<span class="sourceLineNo">155</span> else if (sType.isUri() || (pMeta != null && pMeta.isUri()))<a name="line.155"></a> -<span class="sourceLineNo">156</span> out.appendUri(o);<a name="line.156"></a> -<span class="sourceLineNo">157</span> else if (sType.isMap()) {<a name="line.157"></a> -<span class="sourceLineNo">158</span> if (o instanceof BeanMap)<a name="line.158"></a> -<span class="sourceLineNo">159</span> serializeBeanMap(out, (BeanMap)o, typeName);<a name="line.159"></a> -<span class="sourceLineNo">160</span> else<a name="line.160"></a> -<span class="sourceLineNo">161</span> serializeMap(out, (Map)o, eType);<a name="line.161"></a> -<span class="sourceLineNo">162</span> }<a name="line.162"></a> -<span class="sourceLineNo">163</span> else if (sType.isCollection()) {<a name="line.163"></a> -<span class="sourceLineNo">164</span> serializeCollection(out, (Collection) o, eType);<a name="line.164"></a> -<span class="sourceLineNo">165</span> }<a name="line.165"></a> -<span class="sourceLineNo">166</span> else if (sType.isArray()) {<a name="line.166"></a> -<span class="sourceLineNo">167</span> serializeCollection(out, toList(sType.getInnerClass(), o), eType);<a name="line.167"></a> -<span class="sourceLineNo">168</span> }<a name="line.168"></a> -<span class="sourceLineNo">169</span> else if (sType.isReader() || sType.isInputStream()) {<a name="line.169"></a> -<span class="sourceLineNo">170</span> IOUtils.pipe(o, out);<a name="line.170"></a> -<span class="sourceLineNo">171</span> }<a name="line.171"></a> -<span class="sourceLineNo">172</span> else {<a name="line.172"></a> -<span class="sourceLineNo">173</span> out.appendObject(o, false);<a name="line.173"></a> -<span class="sourceLineNo">174</span> }<a name="line.174"></a> -<span class="sourceLineNo">175</span><a name="line.175"></a> -<span class="sourceLineNo">176</span> if (! isRecursion)<a name="line.176"></a> -<span class="sourceLineNo">177</span> pop();<a name="line.177"></a> -<span class="sourceLineNo">178</span> return out;<a name="line.178"></a> -<span class="sourceLineNo">179</span> }<a name="line.179"></a> -<span class="sourceLineNo">180</span><a name="line.180"></a> -<span class="sourceLineNo">181</span> @SuppressWarnings({ "rawtypes", "unchecked" })<a name="line.181"></a> -<span class="sourceLineNo">182</span> private SerializerWriter serializeMap(UonWriter out, Map m, ClassMeta<?> type) throws Exception {<a name="line.182"></a> -<span class="sourceLineNo">183</span><a name="line.183"></a> -<span class="sourceLineNo">184</span> m = sort(m);<a name="line.184"></a> -<span class="sourceLineNo">185</span><a name="line.185"></a> -<span class="sourceLineNo">186</span> ClassMeta<?> keyType = type.getKeyType(), valueType = type.getValueType();<a name="line.186"></a> -<span class="sourceLineNo">187</span><a name="line.187"></a> -<span class="sourceLineNo">188</span> if (! plainTextParams)<a name="line.188"></a> -<span class="sourceLineNo">189</span> out.append('(');<a name="line.189"></a> -<span class="sourceLineNo">190</span><a name="line.190"></a> -<span class="sourceLineNo">191</span> Iterator mapEntries = m.entrySet().iterator();<a name="line.191"></a> -<span class="sourceLineNo">192</span><a name="line.192"></a> -<span class="sourceLineNo">193</span> while (mapEntries.hasNext()) {<a name="line.193"></a> -<span class="sourceLineNo">194</span> Map.Entry e = (Map.Entry) mapEntries.next();<a name="line.194"></a> -<span class="sourceLineNo">195</span> Object value = e.getValue();<a name="line.195"></a> -<span class="sourceLineNo">196</span> Object key = generalize(e.getKey(), keyType);<a name="line.196"></a> -<span class="sourceLineNo">197</span> out.cr(indent).appendObject(key, false).append('=');<a name="line.197"></a> -<span class="sourceLineNo">198</span> serializeAnything(out, value, valueType, (key == null ? null : toString(key)), null);<a name="line.198"></a> -<span class="sourceLineNo">199</span> if (mapEntries.hasNext())<a name="line.199"></a> -<span class="sourceLineNo">200</span> out.append(',');<a name="line.200"></a> -<span class="sourceLineNo">201</span> }<a name="line.201"></a> -<span class="sourceLineNo">202</span><a name="line.202"></a> -<span class="sourceLineNo">203</span> if (m.size() > 0)<a name="line.203"></a> -<span class="sourceLineNo">204</span> out.cre(indent-1);<a name="line.204"></a> -<span class="sourceLineNo">205</span><a name="line.205"></a> -<span class="sourceLineNo">206</span> if (! plainTextParams)<a name="line.206"></a> -<span class="sourceLineNo">207</span> out.append(')');<a name="line.207"></a> -<span class="sourceLineNo">208</span><a name="line.208"></a> -<span class="sourceLineNo">209</span> return out;<a name="line.209"></a> -<span class="sourceLineNo">210</span> }<a name="line.210"></a> -<span class="sourceLineNo">211</span><a name="line.211"></a> -<span class="sourceLineNo">212</span> private SerializerWriter serializeBeanMap(UonWriter out, BeanMap<?> m, String typeName) throws Exception {<a name="line.212"></a> -<span class="sourceLineNo">213</span><a name="line.213"></a> -<span class="sourceLineNo">214</span> if (! plainTextParams)<a name="line.214"></a> -<span class="sourceLineNo">215</span> out.append('(');<a name="line.215"></a> -<span class="sourceLineNo">216</span><a name="line.216"></a> -<span class="sourceLineNo">217</span> boolean addComma = false;<a name="line.217"></a> -<span class="sourceLineNo">218</span><a name="line.218"></a> -<span class="sourceLineNo">219</span> for (BeanPropertyValue p : m.getValues(isTrimNulls(), typeName != null ? createBeanTypeNameProperty(m, typeName) : null)) {<a name="line.219"></a> -<span class="sourceLineNo">220</span> BeanPropertyMeta pMeta = p.getMeta();<a name="line.220"></a> -<span class="sourceLineNo">221</span> ClassMeta<?> cMeta = p.getClassMeta();<a name="line.221"></a> -<span class="sourceLineNo">222</span><a name="line.222"></a> -<span class="sourceLineNo">223</span> String key = p.getName();<a name="line.223"></a> -<span class="sourceLineNo">224</span> Object value = p.getValue();<a name="line.224"></a> -<span class="sourceLineNo">225</span> Throwable t = p.getThrown();<a name="line.225"></a> -<span class="sourceLineNo">226</span> if (t != null)<a name="line.226"></a> -<span class="sourceLineNo">227</span> onBeanGetterException(pMeta, t);<a name="line.227"></a> -<span class="sourceLineNo">228</span><a name="line.228"></a> -<span class="sourceLineNo">229</span> if (canIgnoreValue(cMeta, key, value))<a name="line.229"></a> -<span class="sourceLineNo">230</span> continue;<a name="line.230"></a> -<span class="sourceLineNo">231</span><a name="line.231"></a> -<span class="sourceLineNo">232</span> if (addComma)<a name="line.232"></a> -<span class="sourceLineNo">233</span> out.append(',');<a name="line.233"></a> -<span class="sourceLineNo">234</span><a name="line.234"></a> -<span class="sourceLineNo">235</span> out.cr(indent).appendObject(key, false).append('=');<a name="line.235"></a> -<span class="sourceLineNo">236</span><a name="line.236"></a> -<span class="sourceLineNo">237</span> serializeAnything(out, value, cMeta, key, pMeta);<a name="line.237"></a> -<span class="sourceLineNo">238</span><a name="line.238"></a> -<span class="sourceLineNo">239</span> addComma = true;<a name="line.239"></a> -<span class="sourceLineNo">240</span> }<a name="line.240"></a> -<span class="sourceLineNo">241</span><a name="line.241"></a> -<span class="sourceLineNo">242</span> if (m.size() > 0)<a name="line.242"></a> -<span class="sourceLineNo">243</span> out.cre(indent-1);<a name="line.243"></a> -<span class="sourceLineNo">244</span> if (! plainTextParams)<a name="line.244"></a> -<span class="sourceLineNo">245</span> out.append(')');<a name="line.245"></a> -<span class="sourceLineNo">246</span><a name="line.246"></a> -<span class="sourceLineNo">247</span> return out;<a name="line.247"></a> -<span class="sourceLineNo">248</span> }<a name="line.248"></a> -<span class="sourceLineNo">249</span><a name="line.249"></a> -<span class="sourceLineNo">250</span> @SuppressWarnings({ "rawtypes", "unchecked" })<a name="line.250"></a> -<span class="sourceLineNo">251</span> private SerializerWriter serializeCollection(UonWriter out, Collection c, ClassMeta<?> type) throws Exception {<a name="line.251"></a> -<span class="sourceLineNo">252</span><a name="line.252"></a> -<span class="sourceLineNo">253</span> ClassMeta<?> elementType = type.getElementType();<a name="line.253"></a> -<span class="sourceLineNo">254</span><a name="line.254"></a> -<span class="sourceLineNo">255</span> c = sort(c);<a name="line.255"></a> -<span class="sourceLineNo">256</span><a name="line.256"></a> -<span class="sourceLineNo">257</span> if (! plainTextParams)<a name="line.257"></a> -<span class="sourceLineNo">258</span> out.append('@').append('(');<a name="line.258"></a> -<span class="sourceLineNo">259</span><a name="line.259"></a> -<span class="sourceLineNo">260</span> for (Iterator i = c.iterator(); i.hasNext();) {<a name="line.260"></a> -<span class="sourceLineNo">261</span> out.cr(indent);<a name="line.261"></a> -<span class="sourceLineNo">262</span> serializeAnything(out, i.next(), elementType, "<iterator>", null);<a name="line.262"></a> -<span class="sourceLineNo">263</span> if (i.hasNext())<a name="line.263"></a> -<span class="sourceLineNo">264</span> out.append(',');<a name="line.264"></a> -<span class="sourceLineNo">265</span> }<a name="line.265"></a> -<span class="sourceLineNo">266</span><a name="line.266"></a> -<span class="sourceLineNo">267</span> if (c.size() > 0)<a name="line.267"></a> -<span class="sourceLineNo">268</span> out.cre(indent-1);<a name="line.268"></a> -<span class="sourceLineNo">269</span> if (! plainTextParams)<a name="line.269"></a> -<span class="sourceLineNo">270</span> out.append(')');<a name="line.270"></a> -<span class="sourceLineNo">271</span><a name="line.271"></a> -<span class="sourceLineNo">272</span> return out;<a name="line.272"></a> -<span class="sourceLineNo">273</span> }<a name="line.273"></a> -<span class="sourceLineNo">274</span>}<a name="line.274"></a> +<span class="sourceLineNo">139</span> sType = swap.getSwapClassMeta(this);<a name="line.139"></a> +<span class="sourceLineNo">140</span><a name="line.140"></a> +<span class="sourceLineNo">141</span> // If the getSwapClass() method returns Object, we need to figure out<a name="line.141"></a> +<span class="sourceLineNo">142</span> // the actual type now.<a name="line.142"></a> +<span class="sourceLineNo">143</span> if (sType.isObject())<a name="line.143"></a> +<span class="sourceLineNo">144</span> sType = getClassMetaForObject(o);<a name="line.144"></a> +<span class="sourceLineNo">145</span> }<a name="line.145"></a> +<span class="sourceLineNo">146</span><a name="line.146"></a> +<span class="sourceLineNo">147</span> // '\0' characters are considered null.<a name="line.147"></a> +<span class="sourceLineNo">148</span> if (o == null || (sType.isChar() && ((Character)o).charValue() == 0))<a name="line.148"></a> +<span class="sourceLineNo">149</span> out.appendObject(null, false);<a name="line.149"></a> +<span class="sourceLineNo">150</span> else if (sType.isBoolean())<a name="line.150"></a> +<span class="sourceLineNo">151</span> out.appendBoolean(o);<a name="line.151"></a> +<span class="sourceLineNo">152</span> else if (sType.isNumber())<a name="line.152"></a> +<span class="sourceLineNo">153</span> out.appendNumber(o);<a name="line.153"></a> +<span class="sourceLineNo">154</span> else if (sType.isBean())<a name="line.154"></a> +<span class="sourceLineNo">155</span> serializeBeanMap(out, toBeanMap(o), typeName);<a name="line.155"></a> +<span class="sourceLineNo">156</span> else if (sType.isUri() || (pMeta != null && pMeta.isUri()))<a name="line.156"></a> +<span class="sourceLineNo">157</span> out.appendUri(o);<a name="line.157"></a> +<span class="sourceLineNo">158</span> else if (sType.isMap()) {<a name="line.158"></a> +<span class="sourceLineNo">159</span> if (o instanceof BeanMap)<a name="line.159"></a> +<span class="sourceLineNo">160</span> serializeBeanMap(out, (BeanMap)o, typeName);<a name="line.160"></a> +<span class="sourceLineNo">161</span> else<a name="line.161"></a> +<span class="sourceLineNo">162</span> serializeMap(out, (Map)o, eType);<a name="line.162"></a> +<span class="sourceLineNo">163</span> }<a name="line.163"></a> +<span class="sourceLineNo">164</span> else if (sType.isCollection()) {<a name="line.164"></a> +<span class="sourceLineNo">165</span> serializeCollection(out, (Collection) o, eType);<a name="line.165"></a> +<span class="sourceLineNo">166</span> }<a name="line.166"></a> +<span class="sourceLineNo">167</span> else if (sType.isArray()) {<a name="line.167"></a> +<span class="sourceLineNo">168</span> serializeCollection(out, toList(sType.getInnerClass(), o), eType);<a name="line.168"></a> +<span class="sourceLineNo">169</span> }<a name="line.169"></a> +<span class="sourceLineNo">170</span> else if (sType.isReader() || sType.isInputStream()) {<a name="line.170"></a> +<span class="sourceLineNo">171</span> IOUtils.pipe(o, out);<a name="line.171"></a> +<span class="sourceLineNo">172</span> }<a name="line.172"></a> +<span class="sourceLineNo">173</span> else {<a name="line.173"></a> +<span class="sourceLineNo">174</span> out.appendObject(o, false);<a name="line.174"></a> +<span class="sourceLineNo">175</span> }<a name="line.175"></a> +<span class="sourceLineNo">176</span><a name="line.176"></a> +<span class="sourceLineNo">177</span> if (! isRecursion)<a name="line.177"></a> +<span class="sourceLineNo">178</span> pop();<a name="line.178"></a> +<span class="sourceLineNo">179</span> return out;<a name="line.179"></a> +<span class="sourceLineNo">180</span> }<a name="line.180"></a> +<span class="sourceLineNo">181</span><a name="line.181"></a> +<span class="sourceLineNo">182</span> @SuppressWarnings({ "rawtypes", "unchecked" })<a name="line.182"></a> +<span class="sourceLineNo">183</span> private SerializerWriter serializeMap(UonWriter out, Map m, ClassMeta<?> type) throws Exception {<a name="line.183"></a> +<span class="sourceLineNo">184</span><a name="line.184"></a> +<span class="sourceLineNo">185</span> m = sort(m);<a name="line.185"></a> +<span class="sourceLineNo">186</span><a name="line.186"></a> +<span class="sourceLineNo">187</span> ClassMeta<?> keyType = type.getKeyType(), valueType = type.getValueType();<a name="line.187"></a> +<span class="sourceLineNo">188</span><a name="line.188"></a> +<span class="sourceLineNo">189</span> if (! plainTextParams)<a name="line.189"></a> +<span class="sourceLineNo">190</span> out.append('(');<a name="line.190"></a> +<span class="sourceLineNo">191</span><a name="line.191"></a> +<span class="sourceLineNo">192</span> Iterator mapEntries = m.entrySet().iterator();<a name="line.192"></a> +<span class="sourceLineNo">193</span><a name="line.193"></a> +<span class="sourceLineNo">194</span> while (mapEntries.hasNext()) {<a name="line.194"></a> +<span class="sourceLineNo">195</span> Map.Entry e = (Map.Entry) mapEntries.next();<a name="line.195"></a> +<span class="sourceLineNo">196</span> Object value = e.getValue();<a name="line.196"></a> +<span class="sourceLineNo">197</span> Object key = generalize(e.getKey(), keyType);<a name="line.197"></a> +<span class="sourceLineNo">198</span> out.cr(indent).appendObject(key, false).append('=');<a name="line.198"></a> +<span class="sourceLineNo">199</span> serializeAnything(out, value, valueType, (key == null ? null : toString(key)), null);<a name="line.199"></a> +<span class="sourceLineNo">200</span> if (mapEntries.hasNext())<a name="line.200"></a> +<span class="sourceLineNo">201</span> out.append(',');<a name="line.201"></a> +<span class="sourceLineNo">202</span> }<a name="line.202"></a> +<span class="sourceLineNo">203</span><a name="line.203"></a> +<span class="sourceLineNo">204</span> if (m.size() > 0)<a name="line.204"></a> +<span class="sourceLineNo">205</span> out.cre(indent-1);<a name="line.205"></a> +<span class="sourceLineNo">206</span><a name="line.206"></a> +<span class="sourceLineNo">207</span> if (! plainTextParams)<a name="line.207"></a> +<span class="sourceLineNo">208</span> out.append(')');<a name="line.208"></a> +<span class="sourceLineNo">209</span><a name="line.209"></a> +<span class="sourceLineNo">210</span> return out;<a name="line.210"></a> +<span class="sourceLineNo">211</span> }<a name="line.211"></a> +<span class="sourceLineNo">212</span><a name="line.212"></a> +<span class="sourceLineNo">213</span> private SerializerWriter serializeBeanMap(UonWriter out, BeanMap<?> m, String typeName) throws Exception {<a name="line.213"></a> +<span class="sourceLineNo">214</span><a name="line.214"></a> +<span class="sourceLineNo">215</span> if (! plainTextParams)<a name="line.215"></a> +<span class="sourceLineNo">216</span> out.append('(');<a name="line.216"></a> +<span class="sourceLineNo">217</span><a name="line.217"></a> +<span class="sourceLineNo">218</span> boolean addComma = false;<a name="line.218"></a> +<span class="sourceLineNo">219</span><a name="line.219"></a> +<span class="sourceLineNo">220</span> for (BeanPropertyValue p : m.getValues(isTrimNulls(), typeName != null ? createBeanTypeNameProperty(m, typeName) : null)) {<a name="line.220"></a> +<span class="sourceLineNo">221</span> BeanPropertyMeta pMeta = p.getMeta();<a name="line.221"></a> +<span class="sourceLineNo">222</span> ClassMeta<?> cMeta = p.getClassMeta();<a name="line.222"></a> +<span class="sourceLineNo">223</span><a name="line.223"></a> +<span class="sourceLineNo">224</span> String key = p.getName();<a name="line.224"></a> +<span class="sourceLineNo">225</span> Object value = p.getValue();<a name="line.225"></a> +<span class="sourceLineNo">226</span> Throwable t = p.getThrown();<a name="line.226"></a> +<span class="sourceLineNo">227</span> if (t != null)<a name="line.227"></a> +<span class="sourceLineNo">228</span> onBeanGetterException(pMeta, t);<a name="line.228"></a> +<span class="sourceLineNo">229</span><a name="line.229"></a> +<span class="sourceLineNo">230</span> if (canIgnoreValue(cMeta, key, value))<a name="line.230"></a> +<span class="sourceLineNo">231</span> continue;<a name="line.231"></a> +<span class="sourceLineNo">232</span><a name="line.232"></a> +<span class="sourceLineNo">233</span> if (addComma)<a name="line.233"></a> +<span class="sourceLineNo">234</span> out.append(',');<a name="line.234"></a> +<span class="sourceLineNo">235</span><a name="line.235"></a> +<span class="sourceLineNo">236</span> out.cr(indent).appendObject(key, false).append('=');<a name="line.236"></a> +<span class="sourceLineNo">237</span><a name="line.237"></a> +<span class="sourceLineNo">238</span> serializeAnything(out, value, cMeta, key, pMeta);<a name="line.238"></a> +<span class="sourceLineNo">239</span><a name="line.239"></a> +<span class="sourceLineNo">240</span> addComma = true;<a name="line.240"></a> +<span class="sourceLineNo">241</span> }<a name="line.241"></a> +<span class="sourceLineNo">242</span><a name="line.242"></a> +<span class="sourceLineNo">243</span> if (m.size() > 0)<a name="line.243"></a> +<span class="sourceLineNo">244</span> out.cre(indent-1);<a name="line.244"></a> +<span class="sourceLineNo">245</span> if (! plainTextParams)<a name="line.245"></a> +<span class="sourceLineNo">246</span> out.append(')');<a name="line.246"></a> +<span class="sourceLineNo">247</span><a name="line.247"></a> +<span class="sourceLineNo">248</span> return out;<a name="line.248"></a> +<span class="sourceLineNo">249</span> }<a name="line.249"></a> +<span class="sourceLineNo">250</span><a name="line.250"></a> +<span class="sourceLineNo">251</span> @SuppressWarnings({ "rawtypes", "unchecked" })<a name="line.251"></a> +<span class="sourceLineNo">252</span> private SerializerWriter serializeCollection(UonWriter out, Collection c, ClassMeta<?> type) throws Exception {<a name="line.252"></a> +<span class="sourceLineNo">253</span><a name="line.253"></a> +<span class="sourceLineNo">254</span> ClassMeta<?> elementType = type.getElementType();<a name="line.254"></a> +<span class="sourceLineNo">255</span><a name="line.255"></a> +<span class="sourceLineNo">256</span> c = sort(c);<a name="line.256"></a> +<span class="sourceLineNo">257</span><a name="line.257"></a> +<span class="sourceLineNo">258</span> if (! plainTextParams)<a name="line.258"></a> +<span class="sourceLineNo">259</span> out.append('@').append('(');<a name="line.259"></a> +<span class="sourceLineNo">260</span><a name="line.260"></a> +<span class="sourceLineNo">261</span> for (Iterator i = c.iterator(); i.hasNext();) {<a name="line.261"></a> +<span class="sourceLineNo">262</span> out.cr(indent);<a name="line.262"></a> +<span class="sourceLineNo">263</span> serializeAnything(out, i.next(), elementType, "<iterator>", null);<a name="line.263"></a> +<span class="sourceLineNo">264</span> if (i.hasNext())<a name="line.264"></a> +<span class="sourceLineNo">265</span> out.append(',');<a name="line.265"></a> +<span class="sourceLineNo">266</span> }<a name="line.266"></a> +<span class="sourceLineNo">267</span><a name="line.267"></a> +<span class="sourceLineNo">268</span> if (c.size() > 0)<a name="line.268"></a> +<span class="sourceLineNo">269</span> out.cre(indent-1);<a name="line.269"></a> +<span class="sourceLineNo">270</span> if (! plainTextParams)<a name="line.270"></a> +<span class="sourceLineNo">271</span> out.append(')');<a name="line.271"></a> +<span class="sourceLineNo">272</span><a name="line.272"></a> +<span class="sourceLineNo">273</span> return out;<a name="line.273"></a> +<span class="sourceLineNo">274</span> }<a name="line.274"></a> +<span class="sourceLineNo">275</span>}<a name="line.275"></a>
http://git-wip-us.apache.org/repos/asf/incubator-juneau-website/blob/62afb533/content/site/apidocs/src-html/org/apache/juneau/urlencoding/UrlEncodingParserSession.html ---------------------------------------------------------------------- diff --git a/content/site/apidocs/src-html/org/apache/juneau/urlencoding/UrlEncodingParserSession.html b/content/site/apidocs/src-html/org/apache/juneau/urlencoding/UrlEncodingParserSession.html index 46edf66..b1be538 100644 --- a/content/site/apidocs/src-html/org/apache/juneau/urlencoding/UrlEncodingParserSession.html +++ b/content/site/apidocs/src-html/org/apache/juneau/urlencoding/UrlEncodingParserSession.html @@ -67,7 +67,7 @@ <span class="sourceLineNo">059</span> * @return <jk>true</jk> if the specified bean property should be expanded as multiple key-value pairs.<a name="line.59"></a> <span class="sourceLineNo">060</span> */<a name="line.60"></a> <span class="sourceLineNo">061</span> public final boolean shouldUseExpandedParams(BeanPropertyMeta pMeta) {<a name="line.61"></a> -<span class="sourceLineNo">062</span> ClassMeta<?> cm = pMeta.getClassMeta();<a name="line.62"></a> +<span class="sourceLineNo">062</span> ClassMeta<?> cm = pMeta.getClassMeta().getSerializedClassMeta(this);<a name="line.62"></a> <span class="sourceLineNo">063</span> if (cm.isCollectionOrArray()) {<a name="line.63"></a> <span class="sourceLineNo">064</span> if (expandedParams)<a name="line.64"></a> <span class="sourceLineNo">065</span> return true;<a name="line.65"></a> @@ -97,8 +97,8 @@ <span class="sourceLineNo">089</span><a name="line.89"></a> <span class="sourceLineNo">090</span> if (eType == null)<a name="line.90"></a> <span class="sourceLineNo">091</span> eType = (ClassMeta<T>)object();<a name="line.91"></a> -<span class="sourceLineNo">092</span> PojoSwap<T,Object> transform = (PojoSwap<T,Object>)eType.getPojoSwap();<a name="line.92"></a> -<span class="sourceLineNo">093</span> ClassMeta<?> sType = eType.getSerializedClassMeta();<a name="line.93"></a> +<span class="sourceLineNo">092</span> PojoSwap<T,Object> swap = (PojoSwap<T,Object>)eType.getPojoSwap(this);<a name="line.92"></a> +<span class="sourceLineNo">093</span> ClassMeta<?> sType = swap == null ? eType : swap.getSwapClassMeta(this);<a name="line.93"></a> <span class="sourceLineNo">094</span><a name="line.94"></a> <span class="sourceLineNo">095</span> int c = r.peekSkipWs();<a name="line.95"></a> <span class="sourceLineNo">096</span> if (c == '?')<a name="line.96"></a> @@ -147,8 +147,8 @@ <span class="sourceLineNo">139</span> }<a name="line.139"></a> <span class="sourceLineNo">140</span> }<a name="line.140"></a> <span class="sourceLineNo">141</span><a name="line.141"></a> -<span class="sourceLineNo">142</span> if (transform != null && o != null)<a name="line.142"></a> -<span class="sourceLineNo">143</span> o = transform.unswap(this, o, eType);<a name="line.143"></a> +<span class="sourceLineNo">142</span> if (swap != null && o != null)<a name="line.142"></a> +<span class="sourceLineNo">143</span> o = swap.unswap(this, o, eType);<a name="line.143"></a> <span class="sourceLineNo">144</span><a name="line.144"></a> <span class="sourceLineNo">145</span> if (outer != null)<a name="line.145"></a> <span class="sourceLineNo">146</span> setParent(eType, o, outer);<a name="line.146"></a> http://git-wip-us.apache.org/repos/asf/incubator-juneau-website/blob/62afb533/content/site/apidocs/src-html/org/apache/juneau/urlencoding/UrlEncodingSerializerSession.html ---------------------------------------------------------------------- diff --git a/content/site/apidocs/src-html/org/apache/juneau/urlencoding/UrlEncodingSerializerSession.html b/content/site/apidocs/src-html/org/apache/juneau/urlencoding/UrlEncodingSerializerSession.html index 41894f0..72d3f26 100644 --- a/content/site/apidocs/src-html/org/apache/juneau/urlencoding/UrlEncodingSerializerSession.html +++ b/content/site/apidocs/src-html/org/apache/juneau/urlencoding/UrlEncodingSerializerSession.html @@ -70,7 +70,7 @@ <span class="sourceLineNo">062</span> * Returns <jk>true</jk> if the specified bean property should be expanded as multiple key-value pairs.<a name="line.62"></a> <span class="sourceLineNo">063</span> */<a name="line.63"></a> <span class="sourceLineNo">064</span> private boolean shouldUseExpandedParams(BeanPropertyMeta pMeta) {<a name="line.64"></a> -<span class="sourceLineNo">065</span> ClassMeta<?> cm = pMeta.getClassMeta();<a name="line.65"></a> +<span class="sourceLineNo">065</span> ClassMeta<?> cm = pMeta.getClassMeta().getSerializedClassMeta(this);<a name="line.65"></a> <span class="sourceLineNo">066</span> if (cm.isCollectionOrArray()) {<a name="line.66"></a> <span class="sourceLineNo">067</span> if (expandedParams)<a name="line.67"></a> <span class="sourceLineNo">068</span> return true;<a name="line.68"></a> @@ -86,7 +86,7 @@ <span class="sourceLineNo">078</span> private boolean shouldUseExpandedParams(Object value) {<a name="line.78"></a> <span class="sourceLineNo">079</span> if (value == null || ! expandedParams)<a name="line.79"></a> <span class="sourceLineNo">080</span> return false;<a name="line.80"></a> -<span class="sourceLineNo">081</span> ClassMeta<?> cm = getClassMetaForObject(value).getSerializedClassMeta();<a name="line.81"></a> +<span class="sourceLineNo">081</span> ClassMeta<?> cm = getClassMetaForObject(value).getSerializedClassMeta(this);<a name="line.81"></a> <span class="sourceLineNo">082</span> if (cm.isCollectionOrArray()) {<a name="line.82"></a> <span class="sourceLineNo">083</span> if (expandedParams)<a name="line.83"></a> <span class="sourceLineNo">084</span> return true;<a name="line.84"></a> @@ -112,159 +112,161 @@ <span class="sourceLineNo">104</span> if (aType == null)<a name="line.104"></a> <span class="sourceLineNo">105</span> aType = object();<a name="line.105"></a> <span class="sourceLineNo">106</span><a name="line.106"></a> -<span class="sourceLineNo">107</span> sType = aType.getSerializedClassMeta();<a name="line.107"></a> +<span class="sourceLineNo">107</span> sType = aType;<a name="line.107"></a> <span class="sourceLineNo">108</span> String typeName = getBeanTypeName(object(), aType, null);<a name="line.108"></a> <span class="sourceLineNo">109</span><a name="line.109"></a> <span class="sourceLineNo">110</span> // Swap if necessary<a name="line.110"></a> -<span class="sourceLineNo">111</span> PojoSwap swap = aType.getPojoSwap();<a name="line.111"></a> +<span class="sourceLineNo">111</span> PojoSwap swap = aType.getPojoSwap(this);<a name="line.111"></a> <span class="sourceLineNo">112</span> if (swap != null) {<a name="line.112"></a> <span class="sourceLineNo">113</span> o = swap.swap(this, o);<a name="line.113"></a> -<span class="sourceLineNo">114</span><a name="line.114"></a> -<span class="sourceLineNo">115</span> // If the getSwapClass() method returns Object, we need to figure out<a name="line.115"></a> -<span class="sourceLineNo">116</span> // the actual type now.<a name="line.116"></a> -<span class="sourceLineNo">117</span> if (sType.isObject())<a name="line.117"></a> -<span class="sourceLineNo">118</span> sType = getClassMetaForObject(o);<a name="line.118"></a> -<span class="sourceLineNo">119</span> }<a name="line.119"></a> -<span class="sourceLineNo">120</span><a name="line.120"></a> -<span class="sourceLineNo">121</span> if (sType.isMap()) {<a name="line.121"></a> -<span class="sourceLineNo">122</span> if (o instanceof BeanMap)<a name="line.122"></a> -<span class="sourceLineNo">123</span> serializeBeanMap(out, (BeanMap)o, typeName);<a name="line.123"></a> -<span class="sourceLineNo">124</span> else<a name="line.124"></a> -<span class="sourceLineNo">125</span> serializeMap(out, (Map)o, sType);<a name="line.125"></a> -<span class="sourceLineNo">126</span> } else if (sType.isBean()) {<a name="line.126"></a> -<span class="sourceLineNo">127</span> serializeBeanMap(out, toBeanMap(o), typeName);<a name="line.127"></a> -<span class="sourceLineNo">128</span> } else if (sType.isCollection() || sType.isArray()) {<a name="line.128"></a> -<span class="sourceLineNo">129</span> Map m = sType.isCollection() ? getCollectionMap((Collection)o) : getCollectionMap(o);<a name="line.129"></a> -<span class="sourceLineNo">130</span> serializeCollectionMap(out, m, getClassMeta(Map.class, Integer.class, Object.class));<a name="line.130"></a> -<span class="sourceLineNo">131</span> } else if (sType.isReader() || sType.isInputStream()) {<a name="line.131"></a> -<span class="sourceLineNo">132</span> IOUtils.pipe(o, out);<a name="line.132"></a> -<span class="sourceLineNo">133</span> } else {<a name="line.133"></a> -<span class="sourceLineNo">134</span> // All other types can't be serialized as key/value pairs, so we create a<a name="line.134"></a> -<span class="sourceLineNo">135</span> // mock key/value pair with a "_value" key.<a name="line.135"></a> -<span class="sourceLineNo">136</span> out.append("_value=");<a name="line.136"></a> -<span class="sourceLineNo">137</span> super.serializeAnything(out, o, null, null, null);<a name="line.137"></a> -<span class="sourceLineNo">138</span> }<a name="line.138"></a> -<span class="sourceLineNo">139</span><a name="line.139"></a> -<span class="sourceLineNo">140</span> pop();<a name="line.140"></a> -<span class="sourceLineNo">141</span> return out;<a name="line.141"></a> -<span class="sourceLineNo">142</span> }<a name="line.142"></a> -<span class="sourceLineNo">143</span><a name="line.143"></a> -<span class="sourceLineNo">144</span> /*<a name="line.144"></a> -<span class="sourceLineNo">145</span> * Converts a Collection into an integer-indexed map.<a name="line.145"></a> -<span class="sourceLineNo">146</span> */<a name="line.146"></a> -<span class="sourceLineNo">147</span> private static Map<Integer,Object> getCollectionMap(Collection<?> c) {<a name="line.147"></a> -<span class="sourceLineNo">148</span> Map<Integer,Object> m = new TreeMap<Integer,Object>();<a name="line.148"></a> -<span class="sourceLineNo">149</span> int i = 0;<a name="line.149"></a> -<span class="sourceLineNo">150</span> for (Object o : c)<a name="line.150"></a> -<span class="sourceLineNo">151</span> m.put(i++, o);<a name="line.151"></a> -<span class="sourceLineNo">152</span> return m;<a name="line.152"></a> -<span class="sourceLineNo">153</span> }<a name="line.153"></a> -<span class="sourceLineNo">154</span><a name="line.154"></a> -<span class="sourceLineNo">155</span> /*<a name="line.155"></a> -<span class="sourceLineNo">156</span> * Converts an array into an integer-indexed map.<a name="line.156"></a> -<span class="sourceLineNo">157</span> */<a name="line.157"></a> -<span class="sourceLineNo">158</span> private static Map<Integer,Object> getCollectionMap(Object array) {<a name="line.158"></a> -<span class="sourceLineNo">159</span> Map<Integer,Object> m = new TreeMap<Integer,Object>();<a name="line.159"></a> -<span class="sourceLineNo">160</span> for (int i = 0; i < Array.getLength(array); i++)<a name="line.160"></a> -<span class="sourceLineNo">161</span> m.put(i, Array.get(array, i));<a name="line.161"></a> -<span class="sourceLineNo">162</span> return m;<a name="line.162"></a> -<span class="sourceLineNo">163</span> }<a name="line.163"></a> -<span class="sourceLineNo">164</span><a name="line.164"></a> -<span class="sourceLineNo">165</span> private SerializerWriter serializeMap(UonWriter out, Map m, ClassMeta<?> type) throws Exception {<a name="line.165"></a> -<span class="sourceLineNo">166</span><a name="line.166"></a> -<span class="sourceLineNo">167</span> m = sort(m);<a name="line.167"></a> -<span class="sourceLineNo">168</span><a name="line.168"></a> -<span class="sourceLineNo">169</span> ClassMeta<?> keyType = type.getKeyType(), valueType = type.getValueType();<a name="line.169"></a> -<span class="sourceLineNo">170</span><a name="line.170"></a> -<span class="sourceLineNo">171</span> boolean addAmp = false;<a name="line.171"></a> -<span class="sourceLineNo">172</span><a name="line.172"></a> -<span class="sourceLineNo">173</span> for (Map.Entry e : (Set<Map.Entry>)m.entrySet()) {<a name="line.173"></a> -<span class="sourceLineNo">174</span> Object key = generalize(e.getKey(), keyType);<a name="line.174"></a> -<span class="sourceLineNo">175</span> Object value = e.getValue();<a name="line.175"></a> -<span class="sourceLineNo">176</span><a name="line.176"></a> -<span class="sourceLineNo">177</span> if (shouldUseExpandedParams(value)) {<a name="line.177"></a> -<span class="sourceLineNo">178</span> Iterator i = value instanceof Collection ? ((Collection)value).iterator() : iterator(value);<a name="line.178"></a> -<span class="sourceLineNo">179</span> while (i.hasNext()) {<a name="line.179"></a> -<span class="sourceLineNo">180</span> if (addAmp)<a name="line.180"></a> -<span class="sourceLineNo">181</span> out.cr(indent).append('&');<a name="line.181"></a> -<span class="sourceLineNo">182</span> out.appendObject(key, true).append('=');<a name="line.182"></a> -<span class="sourceLineNo">183</span> super.serializeAnything(out, i.next(), null, (key == null ? null : key.toString()), null);<a name="line.183"></a> -<span class="sourceLineNo">184</span> addAmp = true;<a name="line.184"></a> -<span class="sourceLineNo">185</span> }<a name="line.185"></a> -<span class="sourceLineNo">186</span> } else {<a name="line.186"></a> -<span class="sourceLineNo">187</span> if (addAmp)<a name="line.187"></a> -<span class="sourceLineNo">188</span> out.cr(indent).append('&');<a name="line.188"></a> -<span class="sourceLineNo">189</span> out.appendObject(key, true).append('=');<a name="line.189"></a> -<span class="sourceLineNo">190</span> super.serializeAnything(out, value, valueType, (key == null ? null : key.toString()), null);<a name="line.190"></a> -<span class="sourceLineNo">191</span> addAmp = true;<a name="line.191"></a> -<span class="sourceLineNo">192</span> }<a name="line.192"></a> -<span class="sourceLineNo">193</span> }<a name="line.193"></a> -<span class="sourceLineNo">194</span><a name="line.194"></a> -<span class="sourceLineNo">195</span> return out;<a name="line.195"></a> -<span class="sourceLineNo">196</span> }<a name="line.196"></a> -<span class="sourceLineNo">197</span><a name="line.197"></a> -<span class="sourceLineNo">198</span> private SerializerWriter serializeCollectionMap(UonWriter out, Map m, ClassMeta<?> type) throws Exception {<a name="line.198"></a> -<span class="sourceLineNo">199</span><a name="line.199"></a> -<span class="sourceLineNo">200</span> ClassMeta<?> valueType = type.getValueType();<a name="line.200"></a> -<span class="sourceLineNo">201</span><a name="line.201"></a> -<span class="sourceLineNo">202</span> boolean addAmp = false;<a name="line.202"></a> -<span class="sourceLineNo">203</span><a name="line.203"></a> -<span class="sourceLineNo">204</span> for (Map.Entry e : (Set<Map.Entry>)m.entrySet()) {<a name="line.204"></a> -<span class="sourceLineNo">205</span> if (addAmp)<a name="line.205"></a> -<span class="sourceLineNo">206</span> out.cr(indent).append('&');<a name="line.206"></a> -<span class="sourceLineNo">207</span> out.append(e.getKey()).append('=');<a name="line.207"></a> -<span class="sourceLineNo">208</span> super.serializeAnything(out, e.getValue(), valueType, null, null);<a name="line.208"></a> -<span class="sourceLineNo">209</span> addAmp = true;<a name="line.209"></a> -<span class="sourceLineNo">210</span> }<a name="line.210"></a> -<span class="sourceLineNo">211</span><a name="line.211"></a> -<span class="sourceLineNo">212</span> return out;<a name="line.212"></a> -<span class="sourceLineNo">213</span> }<a name="line.213"></a> -<span class="sourceLineNo">214</span><a name="line.214"></a> -<span class="sourceLineNo">215</span> private SerializerWriter serializeBeanMap(UonWriter out, BeanMap<?> m, String typeName) throws Exception {<a name="line.215"></a> -<span class="sourceLineNo">216</span> boolean addAmp = false;<a name="line.216"></a> -<span class="sourceLineNo">217</span><a name="line.217"></a> -<span class="sourceLineNo">218</span> for (BeanPropertyValue p : m.getValues(isTrimNulls(), typeName != null ? createBeanTypeNameProperty(m, typeName) : null)) {<a name="line.218"></a> -<span class="sourceLineNo">219</span> BeanPropertyMeta pMeta = p.getMeta();<a name="line.219"></a> -<span class="sourceLineNo">220</span> ClassMeta<?> cMeta = p.getClassMeta();<a name="line.220"></a> -<span class="sourceLineNo">221</span><a name="line.221"></a> -<span class="sourceLineNo">222</span> String key = p.getName();<a name="line.222"></a> -<span class="sourceLineNo">223</span> Object value = p.getValue();<a name="line.223"></a> -<span class="sourceLineNo">224</span> Throwable t = p.getThrown();<a name="line.224"></a> -<span class="sourceLineNo">225</span> if (t != null)<a name="line.225"></a> -<span class="sourceLineNo">226</span> onBeanGetterException(pMeta, t);<a name="line.226"></a> -<span class="sourceLineNo">227</span><a name="line.227"></a> -<span class="sourceLineNo">228</span> if (canIgnoreValue(cMeta, key, value))<a name="line.228"></a> -<span class="sourceLineNo">229</span> continue;<a name="line.229"></a> -<span class="sourceLineNo">230</span><a name="line.230"></a> -<span class="sourceLineNo">231</span> if (value != null && shouldUseExpandedParams(pMeta)) {<a name="line.231"></a> -<span class="sourceLineNo">232</span> // Transformed object array bean properties may be transformed resulting in ArrayLists,<a name="line.232"></a> -<span class="sourceLineNo">233</span> // so we need to check type if we think it's an array.<a name="line.233"></a> -<span class="sourceLineNo">234</span> Iterator i = (cMeta.isCollection() || value instanceof Collection) ? ((Collection)value).iterator() : iterator(value);<a name="line.234"></a> -<span class="sourceLineNo">235</span> while (i.hasNext()) {<a name="line.235"></a> -<span class="sourceLineNo">236</span> if (addAmp)<a name="line.236"></a> -<span class="sourceLineNo">237</span> out.cr(indent).append('&');<a name="line.237"></a> -<span class="sourceLineNo">238</span><a name="line.238"></a> -<span class="sourceLineNo">239</span> out.appendObject(key, true).append('=');<a name="line.239"></a> +<span class="sourceLineNo">114</span> sType = swap.getSwapClassMeta(this);<a name="line.114"></a> +<span class="sourceLineNo">115</span><a name="line.115"></a> +<span class="sourceLineNo">116</span> // If the getSwapClass() method returns Object, we need to figure out<a name="line.116"></a> +<span class="sourceLineNo">117</span> // the actual type now.<a name="line.117"></a> +<span class="sourceLineNo">118</span> if (sType.isObject())<a name="line.118"></a> +<span class="sourceLineNo">119</span> sType = getClassMetaForObject(o);<a name="line.119"></a> +<span class="sourceLineNo">120</span> }<a name="line.120"></a> +<span class="sourceLineNo">121</span><a name="line.121"></a> +<span class="sourceLineNo">122</span> if (sType.isMap()) {<a name="line.122"></a> +<span class="sourceLineNo">123</span> if (o instanceof BeanMap)<a name="line.123"></a> +<span class="sourceLineNo">124</span> serializeBeanMap(out, (BeanMap)o, typeName);<a name="line.124"></a> +<span class="sourceLineNo">125</span> else<a name="line.125"></a> +<span class="sourceLineNo">126</span> serializeMap(out, (Map)o, sType);<a name="line.126"></a> +<span class="sourceLineNo">127</span> } else if (sType.isBean()) {<a name="line.127"></a> +<span class="sourceLineNo">128</span> serializeBeanMap(out, toBeanMap(o), typeName);<a name="line.128"></a> +<span class="sourceLineNo">129</span> } else if (sType.isCollection() || sType.isArray()) {<a name="line.129"></a> +<span class="sourceLineNo">130</span> Map m = sType.isCollection() ? getCollectionMap((Collection)o) : getCollectionMap(o);<a name="line.130"></a> +<span class="sourceLineNo">131</span> serializeCollectionMap(out, m, getClassMeta(Map.class, Integer.class, Object.class));<a name="line.131"></a> +<span class="sourceLineNo">132</span> } else if (sType.isReader() || sType.isInputStream()) {<a name="line.132"></a> +<span class="sourceLineNo">133</span> IOUtils.pipe(o, out);<a name="line.133"></a> +<span class="sourceLineNo">134</span> } else {<a name="line.134"></a> +<span class="sourceLineNo">135</span> // All other types can't be serialized as key/value pairs, so we create a<a name="line.135"></a> +<span class="sourceLineNo">136</span> // mock key/value pair with a "_value" key.<a name="line.136"></a> +<span class="sourceLineNo">137</span> out.append("_value=");<a name="line.137"></a> +<span class="sourceLineNo">138</span> super.serializeAnything(out, o, null, null, null);<a name="line.138"></a> +<span class="sourceLineNo">139</span> }<a name="line.139"></a> +<span class="sourceLineNo">140</span><a name="line.140"></a> +<span class="sourceLineNo">141</span> pop();<a name="line.141"></a> +<span class="sourceLineNo">142</span> return out;<a name="line.142"></a> +<span class="sourceLineNo">143</span> }<a name="line.143"></a> +<span class="sourceLineNo">144</span><a name="line.144"></a> +<span class="sourceLineNo">145</span> /*<a name="line.145"></a> +<span class="sourceLineNo">146</span> * Converts a Collection into an integer-indexed map.<a name="line.146"></a> +<span class="sourceLineNo">147</span> */<a name="line.147"></a> +<span class="sourceLineNo">148</span> private static Map<Integer,Object> getCollectionMap(Collection<?> c) {<a name="line.148"></a> +<span class="sourceLineNo">149</span> Map<Integer,Object> m = new TreeMap<Integer,Object>();<a name="line.149"></a> +<span class="sourceLineNo">150</span> int i = 0;<a name="line.150"></a> +<span class="sourceLineNo">151</span> for (Object o : c)<a name="line.151"></a> +<span class="sourceLineNo">152</span> m.put(i++, o);<a name="line.152"></a> +<span class="sourceLineNo">153</span> return m;<a name="line.153"></a> +<span class="sourceLineNo">154</span> }<a name="line.154"></a> +<span class="sourceLineNo">155</span><a name="line.155"></a> +<span class="sourceLineNo">156</span> /*<a name="line.156"></a> +<span class="sourceLineNo">157</span> * Converts an array into an integer-indexed map.<a name="line.157"></a> +<span class="sourceLineNo">158</span> */<a name="line.158"></a> +<span class="sourceLineNo">159</span> private static Map<Integer,Object> getCollectionMap(Object array) {<a name="line.159"></a> +<span class="sourceLineNo">160</span> Map<Integer,Object> m = new TreeMap<Integer,Object>();<a name="line.160"></a> +<span class="sourceLineNo">161</span> for (int i = 0; i < Array.getLength(array); i++)<a name="line.161"></a> +<span class="sourceLineNo">162</span> m.put(i, Array.get(array, i));<a name="line.162"></a> +<span class="sourceLineNo">163</span> return m;<a name="line.163"></a> +<span class="sourceLineNo">164</span> }<a name="line.164"></a> +<span class="sourceLineNo">165</span><a name="line.165"></a> +<span class="sourceLineNo">166</span> private SerializerWriter serializeMap(UonWriter out, Map m, ClassMeta<?> type) throws Exception {<a name="line.166"></a> +<span class="sourceLineNo">167</span><a name="line.167"></a> +<span class="sourceLineNo">168</span> m = sort(m);<a name="line.168"></a> +<span class="sourceLineNo">169</span><a name="line.169"></a> +<span class="sourceLineNo">170</span> ClassMeta<?> keyType = type.getKeyType(), valueType = type.getValueType();<a name="line.170"></a> +<span class="sourceLineNo">171</span><a name="line.171"></a> +<span class="sourceLineNo">172</span> boolean addAmp = false;<a name="line.172"></a> +<span class="sourceLineNo">173</span><a name="line.173"></a> +<span class="sourceLineNo">174</span> for (Map.Entry e : (Set<Map.Entry>)m.entrySet()) {<a name="line.174"></a> +<span class="sourceLineNo">175</span> Object key = generalize(e.getKey(), keyType);<a name="line.175"></a> +<span class="sourceLineNo">176</span> Object value = e.getValue();<a name="line.176"></a> +<span class="sourceLineNo">177</span><a name="line.177"></a> +<span class="sourceLineNo">178</span> if (shouldUseExpandedParams(value)) {<a name="line.178"></a> +<span class="sourceLineNo">179</span> Iterator i = value instanceof Collection ? ((Collection)value).iterator() : iterator(value);<a name="line.179"></a> +<span class="sourceLineNo">180</span> while (i.hasNext()) {<a name="line.180"></a> +<span class="sourceLineNo">181</span> if (addAmp)<a name="line.181"></a> +<span class="sourceLineNo">182</span> out.cr(indent).append('&');<a name="line.182"></a> +<span class="sourceLineNo">183</span> out.appendObject(key, true).append('=');<a name="line.183"></a> +<span class="sourceLineNo">184</span> super.serializeAnything(out, i.next(), null, (key == null ? null : key.toString()), null);<a name="line.184"></a> +<span class="sourceLineNo">185</span> addAmp = true;<a name="line.185"></a> +<span class="sourceLineNo">186</span> }<a name="line.186"></a> +<span class="sourceLineNo">187</span> } else {<a name="line.187"></a> +<span class="sourceLineNo">188</span> if (addAmp)<a name="line.188"></a> +<span class="sourceLineNo">189</span> out.cr(indent).append('&');<a name="line.189"></a> +<span class="sourceLineNo">190</span> out.appendObject(key, true).append('=');<a name="line.190"></a> +<span class="sourceLineNo">191</span> super.serializeAnything(out, value, valueType, (key == null ? null : key.toString()), null);<a name="line.191"></a> +<span class="sourceLineNo">192</span> addAmp = true;<a name="line.192"></a> +<span class="sourceLineNo">193</span> }<a name="line.193"></a> +<span class="sourceLineNo">194</span> }<a name="line.194"></a> +<span class="sourceLineNo">195</span><a name="line.195"></a> +<span class="sourceLineNo">196</span> return out;<a name="line.196"></a> +<span class="sourceLineNo">197</span> }<a name="line.197"></a> +<span class="sourceLineNo">198</span><a name="line.198"></a> +<span class="sourceLineNo">199</span> private SerializerWriter serializeCollectionMap(UonWriter out, Map m, ClassMeta<?> type) throws Exception {<a name="line.199"></a> +<span class="sourceLineNo">200</span><a name="line.200"></a> +<span class="sourceLineNo">201</span> ClassMeta<?> valueType = type.getValueType();<a name="line.201"></a> +<span class="sourceLineNo">202</span><a name="line.202"></a> +<span class="sourceLineNo">203</span> boolean addAmp = false;<a name="line.203"></a> +<span class="sourceLineNo">204</span><a name="line.204"></a> +<span class="sourceLineNo">205</span> for (Map.Entry e : (Set<Map.Entry>)m.entrySet()) {<a name="line.205"></a> +<span class="sourceLineNo">206</span> if (addAmp)<a name="line.206"></a> +<span class="sourceLineNo">207</span> out.cr(indent).append('&');<a name="line.207"></a> +<span class="sourceLineNo">208</span> out.append(e.getKey()).append('=');<a name="line.208"></a> +<span class="sourceLineNo">209</span> super.serializeAnything(out, e.getValue(), valueType, null, null);<a name="line.209"></a> +<span class="sourceLineNo">210</span> addAmp = true;<a name="line.210"></a> +<span class="sourceLineNo">211</span> }<a name="line.211"></a> +<span class="sourceLineNo">212</span><a name="line.212"></a> +<span class="sourceLineNo">213</span> return out;<a name="line.213"></a> +<span class="sourceLineNo">214</span> }<a name="line.214"></a> +<span class="sourceLineNo">215</span><a name="line.215"></a> +<span class="sourceLineNo">216</span> private SerializerWriter serializeBeanMap(UonWriter out, BeanMap<?> m, String typeName) throws Exception {<a name="line.216"></a> +<span class="sourceLineNo">217</span> boolean addAmp = false;<a name="line.217"></a> +<span class="sourceLineNo">218</span><a name="line.218"></a> +<span class="sourceLineNo">219</span> for (BeanPropertyValue p : m.getValues(isTrimNulls(), typeName != null ? createBeanTypeNameProperty(m, typeName) : null)) {<a name="line.219"></a> +<span class="sourceLineNo">220</span> BeanPropertyMeta pMeta = p.getMeta();<a name="line.220"></a> +<span class="sourceLineNo">221</span> ClassMeta<?> cMeta = p.getClassMeta();<a name="line.221"></a> +<span class="sourceLineNo">222</span> ClassMeta<?> sMeta = cMeta.getSerializedClassMeta(this);<a name="line.222"></a> +<span class="sourceLineNo">223</span><a name="line.223"></a> +<span class="sourceLineNo">224</span> String key = p.getName();<a name="line.224"></a> +<span class="sourceLineNo">225</span> Object value = p.getValue();<a name="line.225"></a> +<span class="sourceLineNo">226</span> Throwable t = p.getThrown();<a name="line.226"></a> +<span class="sourceLineNo">227</span> if (t != null)<a name="line.227"></a> +<span class="sourceLineNo">228</span> onBeanGetterException(pMeta, t);<a name="line.228"></a> +<span class="sourceLineNo">229</span><a name="line.229"></a> +<span class="sourceLineNo">230</span> if (canIgnoreValue(sMeta, key, value))<a name="line.230"></a> +<span class="sourceLineNo">231</span> continue;<a name="line.231"></a> +<span class="sourceLineNo">232</span><a name="line.232"></a> +<span class="sourceLineNo">233</span> if (value != null && shouldUseExpandedParams(pMeta)) {<a name="line.233"></a> +<span class="sourceLineNo">234</span> // Transformed object array bean properties may be transformed resulting in ArrayLists,<a name="line.234"></a> +<span class="sourceLineNo">235</span> // so we need to check type if we think it's an array.<a name="line.235"></a> +<span class="sourceLineNo">236</span> Iterator i = (sMeta.isCollection() || value instanceof Collection) ? ((Collection)value).iterator() : iterator(value);<a name="line.236"></a> +<span class="sourceLineNo">237</span> while (i.hasNext()) {<a name="line.237"></a> +<span class="sourceLineNo">238</span> if (addAmp)<a name="line.238"></a> +<span class="sourceLineNo">239</span> out.cr(indent).append('&');<a name="line.239"></a> <span class="sourceLineNo">240</span><a name="line.240"></a> -<span class="sourceLineNo">241</span> super.serializeAnything(out, i.next(), cMeta.getElementType(), key, pMeta);<a name="line.241"></a> +<span class="sourceLineNo">241</span> out.appendObject(key, true).append('=');<a name="line.241"></a> <span class="sourceLineNo">242</span><a name="line.242"></a> -<span class="sourceLineNo">243</span> addAmp = true;<a name="line.243"></a> -<span class="sourceLineNo">244</span> }<a name="line.244"></a> -<span class="sourceLineNo">245</span> } else {<a name="line.245"></a> -<span class="sourceLineNo">246</span> if (addAmp)<a name="line.246"></a> -<span class="sourceLineNo">247</span> out.cr(indent).append('&');<a name="line.247"></a> -<span class="sourceLineNo">248</span><a name="line.248"></a> -<span class="sourceLineNo">249</span> out.appendObject(key, true).append('=');<a name="line.249"></a> +<span class="sourceLineNo">243</span> super.serializeAnything(out, i.next(), cMeta.getElementType(), key, pMeta);<a name="line.243"></a> +<span class="sourceLineNo">244</span><a name="line.244"></a> +<span class="sourceLineNo">245</span> addAmp = true;<a name="line.245"></a> +<span class="sourceLineNo">246</span> }<a name="line.246"></a> +<span class="sourceLineNo">247</span> } else {<a name="line.247"></a> +<span class="sourceLineNo">248</span> if (addAmp)<a name="line.248"></a> +<span class="sourceLineNo">249</span> out.cr(indent).append('&');<a name="line.249"></a> <span class="sourceLineNo">250</span><a name="line.250"></a> -<span class="sourceLineNo">251</span> super.serializeAnything(out, value, cMeta, key, pMeta);<a name="line.251"></a> +<span class="sourceLineNo">251</span> out.appendObject(key, true).append('=');<a name="line.251"></a> <span class="sourceLineNo">252</span><a name="line.252"></a> -<span class="sourceLineNo">253</span> addAmp = true;<a name="line.253"></a> -<span class="sourceLineNo">254</span> }<a name="line.254"></a> -<span class="sourceLineNo">255</span><a name="line.255"></a> -<span class="sourceLineNo">256</span> }<a name="line.256"></a> -<span class="sourceLineNo">257</span> return out;<a name="line.257"></a> -<span class="sourceLineNo">258</span> }<a name="line.258"></a> -<span class="sourceLineNo">259</span>}<a name="line.259"></a> +<span class="sourceLineNo">253</span> super.serializeAnything(out, value, cMeta, key, pMeta);<a name="line.253"></a> +<span class="sourceLineNo">254</span><a name="line.254"></a> +<span class="sourceLineNo">255</span> addAmp = true;<a name="line.255"></a> +<span class="sourceLineNo">256</span> }<a name="line.256"></a> +<span class="sourceLineNo">257</span><a name="line.257"></a> +<span class="sourceLineNo">258</span> }<a name="line.258"></a> +<span class="sourceLineNo">259</span> return out;<a name="line.259"></a> +<span class="sourceLineNo">260</span> }<a name="line.260"></a> +<span class="sourceLineNo">261</span>}<a name="line.261"></a> http://git-wip-us.apache.org/repos/asf/incubator-juneau-website/blob/62afb533/content/site/apidocs/src-html/org/apache/juneau/xml/XmlParserSession.html ---------------------------------------------------------------------- diff --git a/content/site/apidocs/src-html/org/apache/juneau/xml/XmlParserSession.html b/content/site/apidocs/src-html/org/apache/juneau/xml/XmlParserSession.html index 7508dfb..5b11117 100644 --- a/content/site/apidocs/src-html/org/apache/juneau/xml/XmlParserSession.html +++ b/content/site/apidocs/src-html/org/apache/juneau/xml/XmlParserSession.html @@ -291,8 +291,8 @@ <span class="sourceLineNo">283</span><a name="line.283"></a> <span class="sourceLineNo">284</span> if (eType == null)<a name="line.284"></a> <span class="sourceLineNo">285</span> eType = (ClassMeta<T>)object();<a name="line.285"></a> -<span class="sourceLineNo">286</span> PojoSwap<T,Object> transform = (PojoSwap<T,Object>)eType.getPojoSwap();<a name="line.286"></a> -<span class="sourceLineNo">287</span> ClassMeta<?> sType = eType.getSerializedClassMeta();<a name="line.287"></a> +<span class="sourceLineNo">286</span> PojoSwap<T,Object> swap = (PojoSwap<T,Object>)eType.getPojoSwap(this);<a name="line.286"></a> +<span class="sourceLineNo">287</span> ClassMeta<?> sType = swap == null ? eType : swap.getSwapClassMeta(this);<a name="line.287"></a> <span class="sourceLineNo">288</span> setCurrentClass(sType);<a name="line.288"></a> <span class="sourceLineNo">289</span><a name="line.289"></a> <span class="sourceLineNo">290</span> String wrapperAttr = (isRoot && preserveRootElement) ? r.getName().getLocalPart() : null;<a name="line.290"></a> @@ -385,8 +385,8 @@ <span class="sourceLineNo">377</span> sType.getInnerClass().getName(), sType.getNotABeanReason(), pMeta == null ? null : pMeta.getName());<a name="line.377"></a> <span class="sourceLineNo">378</span> }<a name="line.378"></a> <span class="sourceLineNo">379</span><a name="line.379"></a> -<span class="sourceLineNo">380</span> if (transform != null && o != null)<a name="line.380"></a> -<span class="sourceLineNo">381</span> o = transform.unswap(this, o, eType);<a name="line.381"></a> +<span class="sourceLineNo">380</span> if (swap != null && o != null)<a name="line.380"></a> +<span class="sourceLineNo">381</span> o = swap.unswap(this, o, eType);<a name="line.381"></a> <span class="sourceLineNo">382</span><a name="line.382"></a> <span class="sourceLineNo">383</span> if (outer != null)<a name="line.383"></a> <span class="sourceLineNo">384</span> setParent(eType, o, outer);<a name="line.384"></a>