juneau-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jamesbog...@apache.org
Subject [19/51] [partial] incubator-juneau-website git commit: Javadoc updates.
Date Sat, 01 Apr 2017 23:58:07 GMT
http://git-wip-us.apache.org/repos/asf/incubator-juneau-website/blob/5aed2f48/content/site/apidocs/src-html/org/apache/juneau/jena/RdfParser.NTriple.html
----------------------------------------------------------------------
diff --git a/content/site/apidocs/src-html/org/apache/juneau/jena/RdfParser.NTriple.html b/content/site/apidocs/src-html/org/apache/juneau/jena/RdfParser.NTriple.html
index 675f202..9d7976b 100644
--- a/content/site/apidocs/src-html/org/apache/juneau/jena/RdfParser.NTriple.html
+++ b/content/site/apidocs/src-html/org/apache/juneau/jena/RdfParser.NTriple.html
@@ -177,314 +177,315 @@
 <span class="sourceLineNo">169</span>      // Special case where we're parsing a loose collection of resources.<a name="line.169"></a>
 <span class="sourceLineNo">170</span>      if (s.isLooseCollections() &amp;&amp; type.isCollectionOrArray()) {<a name="line.170"></a>
 <span class="sourceLineNo">171</span>         Collection c = null;<a name="line.171"></a>
-<span class="sourceLineNo">172</span>         if (type.isArray())<a name="line.172"></a>
+<span class="sourceLineNo">172</span>         if (type.isArray() || type.isArgs())<a name="line.172"></a>
 <span class="sourceLineNo">173</span>            c = new ArrayList();<a name="line.173"></a>
 <span class="sourceLineNo">174</span>         else<a name="line.174"></a>
 <span class="sourceLineNo">175</span>            c = (type.canCreateNewInstance(session.getOuter()) ? (Collection&lt;?&gt;)type.newInstance(session.getOuter()) : new ObjectList(session));<a name="line.175"></a>
-<span class="sourceLineNo">176</span>         for (Resource resource : roots)<a name="line.176"></a>
-<span class="sourceLineNo">177</span>            c.add(parseAnything(s, type.getElementType(), resource, session.getOuter(), null));<a name="line.177"></a>
-<span class="sourceLineNo">178</span><a name="line.178"></a>
-<span class="sourceLineNo">179</span>         if (type.isArray())<a name="line.179"></a>
-<span class="sourceLineNo">180</span>            return (T)session.toArray(type, c);<a name="line.180"></a>
-<span class="sourceLineNo">181</span>         return (T)c;<a name="line.181"></a>
-<span class="sourceLineNo">182</span>      }<a name="line.182"></a>
-<span class="sourceLineNo">183</span><a name="line.183"></a>
-<span class="sourceLineNo">184</span>      if (roots.isEmpty())<a name="line.184"></a>
-<span class="sourceLineNo">185</span>         return null;<a name="line.185"></a>
-<span class="sourceLineNo">186</span>      if (roots.size() &gt; 1)<a name="line.186"></a>
-<span class="sourceLineNo">187</span>         throw new ParseException(session, "Too many root nodes found in model:  {0}", roots.size());<a name="line.187"></a>
-<span class="sourceLineNo">188</span>      Resource resource = roots.get(0);<a name="line.188"></a>
-<span class="sourceLineNo">189</span><a name="line.189"></a>
-<span class="sourceLineNo">190</span>      return parseAnything(s, type, resource, session.getOuter(), null);<a name="line.190"></a>
-<span class="sourceLineNo">191</span>   }<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>    * Finds the roots in the model using either the "root" property to identify it,<a name="line.194"></a>
-<span class="sourceLineNo">195</span>    *    or by resorting to scanning the model for all nodes with no incoming predicates.<a name="line.195"></a>
-<span class="sourceLineNo">196</span>    */<a name="line.196"></a>
-<span class="sourceLineNo">197</span>   private static List&lt;Resource&gt; getRoots(RdfParserSession session, Model m) {<a name="line.197"></a>
-<span class="sourceLineNo">198</span>      List&lt;Resource&gt; l = new LinkedList&lt;Resource&gt;();<a name="line.198"></a>
-<span class="sourceLineNo">199</span><a name="line.199"></a>
-<span class="sourceLineNo">200</span>      // First try to find the root using the "http://www.apache.org/juneau/root" property.<a name="line.200"></a>
-<span class="sourceLineNo">201</span>      Property root = m.createProperty(session.getJuneauNsUri(), RDF_juneauNs_ROOT);<a name="line.201"></a>
-<span class="sourceLineNo">202</span>      for (ResIterator i  = m.listResourcesWithProperty(root); i.hasNext();)<a name="line.202"></a>
-<span class="sourceLineNo">203</span>         l.add(i.next());<a name="line.203"></a>
-<span class="sourceLineNo">204</span><a name="line.204"></a>
-<span class="sourceLineNo">205</span>      if (! l.isEmpty())<a name="line.205"></a>
-<span class="sourceLineNo">206</span>         return l;<a name="line.206"></a>
-<span class="sourceLineNo">207</span><a name="line.207"></a>
-<span class="sourceLineNo">208</span>      // Otherwise, we need to find all resources that aren't objects.<a name="line.208"></a>
-<span class="sourceLineNo">209</span>      // We want to explicitly ignore statements where the subject<a name="line.209"></a>
-<span class="sourceLineNo">210</span>      // and object are the same node.<a name="line.210"></a>
-<span class="sourceLineNo">211</span>      Set&lt;RDFNode&gt; objects = new HashSet&lt;RDFNode&gt;();<a name="line.211"></a>
-<span class="sourceLineNo">212</span>      for (StmtIterator i = m.listStatements(); i.hasNext();) {<a name="line.212"></a>
-<span class="sourceLineNo">213</span>         Statement st = i.next();<a name="line.213"></a>
-<span class="sourceLineNo">214</span>         RDFNode subject = st.getSubject();<a name="line.214"></a>
-<span class="sourceLineNo">215</span>         RDFNode object = st.getObject();<a name="line.215"></a>
-<span class="sourceLineNo">216</span>         if (object.isResource() &amp;&amp; ! object.equals(subject))<a name="line.216"></a>
-<span class="sourceLineNo">217</span>            objects.add(object);<a name="line.217"></a>
-<span class="sourceLineNo">218</span>      }<a name="line.218"></a>
-<span class="sourceLineNo">219</span>      for (ResIterator i = m.listSubjects(); i.hasNext();) {<a name="line.219"></a>
-<span class="sourceLineNo">220</span>         Resource r = i.next();<a name="line.220"></a>
-<span class="sourceLineNo">221</span>         if (! objects.contains(r))<a name="line.221"></a>
-<span class="sourceLineNo">222</span>            l.add(r);<a name="line.222"></a>
-<span class="sourceLineNo">223</span>      }<a name="line.223"></a>
-<span class="sourceLineNo">224</span>      return l;<a name="line.224"></a>
-<span class="sourceLineNo">225</span>   }<a name="line.225"></a>
-<span class="sourceLineNo">226</span><a name="line.226"></a>
-<span class="sourceLineNo">227</span>   private &lt;T&gt; BeanMap&lt;T&gt; parseIntoBeanMap(RdfParserSession session, Resource r2, BeanMap&lt;T&gt; m) throws Exception {<a name="line.227"></a>
-<span class="sourceLineNo">228</span>      BeanMeta&lt;T&gt; bm = m.getMeta();<a name="line.228"></a>
-<span class="sourceLineNo">229</span>      RdfBeanMeta rbm = bm.getExtendedMeta(RdfBeanMeta.class);<a name="line.229"></a>
-<span class="sourceLineNo">230</span>      if (rbm.hasBeanUri() &amp;&amp; r2.getURI() != null)<a name="line.230"></a>
-<span class="sourceLineNo">231</span>         rbm.getBeanUriProperty().set(m, r2.getURI());<a name="line.231"></a>
-<span class="sourceLineNo">232</span>      for (StmtIterator i = r2.listProperties(); i.hasNext();) {<a name="line.232"></a>
-<span class="sourceLineNo">233</span>         Statement st = i.next();<a name="line.233"></a>
-<span class="sourceLineNo">234</span>         Property p = st.getPredicate();<a name="line.234"></a>
-<span class="sourceLineNo">235</span>         String key = session.decodeString(p.getLocalName());<a name="line.235"></a>
-<span class="sourceLineNo">236</span>         BeanPropertyMeta pMeta = m.getPropertyMeta(key);<a name="line.236"></a>
-<span class="sourceLineNo">237</span>         session.setCurrentProperty(pMeta);<a name="line.237"></a>
-<span class="sourceLineNo">238</span>         if (pMeta != null) {<a name="line.238"></a>
-<span class="sourceLineNo">239</span>            RDFNode o = st.getObject();<a name="line.239"></a>
-<span class="sourceLineNo">240</span>            ClassMeta&lt;?&gt; cm = pMeta.getClassMeta();<a name="line.240"></a>
-<span class="sourceLineNo">241</span>            if (cm.isCollectionOrArray() &amp;&amp; isMultiValuedCollections(session, pMeta)) {<a name="line.241"></a>
-<span class="sourceLineNo">242</span>               ClassMeta&lt;?&gt; et = cm.getElementType();<a name="line.242"></a>
-<span class="sourceLineNo">243</span>               Object value = parseAnything(session, et, o, m.getBean(false), pMeta);<a name="line.243"></a>
-<span class="sourceLineNo">244</span>               setName(et, value, key);<a name="line.244"></a>
-<span class="sourceLineNo">245</span>               pMeta.add(m, value);<a name="line.245"></a>
-<span class="sourceLineNo">246</span>            } else {<a name="line.246"></a>
-<span class="sourceLineNo">247</span>               Object value = parseAnything(session, cm, o, m.getBean(false), pMeta);<a name="line.247"></a>
-<span class="sourceLineNo">248</span>               setName(cm, value, key);<a name="line.248"></a>
-<span class="sourceLineNo">249</span>               pMeta.set(m, value);<a name="line.249"></a>
-<span class="sourceLineNo">250</span>            }<a name="line.250"></a>
-<span class="sourceLineNo">251</span>         } else if (! (p.equals(session.getRootProperty()) || p.equals(session.getTypeProperty()))) {<a name="line.251"></a>
-<span class="sourceLineNo">252</span>            onUnknownProperty(session, key, m, -1, -1);<a name="line.252"></a>
-<span class="sourceLineNo">253</span>         }<a name="line.253"></a>
-<span class="sourceLineNo">254</span>         session.setCurrentProperty(null);<a name="line.254"></a>
-<span class="sourceLineNo">255</span>      }<a name="line.255"></a>
-<span class="sourceLineNo">256</span>      return m;<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>   private static boolean isMultiValuedCollections(RdfParserSession session, BeanPropertyMeta pMeta) {<a name="line.259"></a>
-<span class="sourceLineNo">260</span>      if (pMeta != null &amp;&amp; pMeta.getExtendedMeta(RdfBeanPropertyMeta.class).getCollectionFormat() != RdfCollectionFormat.DEFAULT)<a name="line.260"></a>
-<span class="sourceLineNo">261</span>         return pMeta.getExtendedMeta(RdfBeanPropertyMeta.class).getCollectionFormat() == RdfCollectionFormat.MULTI_VALUED;<a name="line.261"></a>
-<span class="sourceLineNo">262</span>      return session.getCollectionFormat() == RdfCollectionFormat.MULTI_VALUED;<a name="line.262"></a>
-<span class="sourceLineNo">263</span>   }<a name="line.263"></a>
-<span class="sourceLineNo">264</span><a name="line.264"></a>
-<span class="sourceLineNo">265</span>   @SuppressWarnings({ "unchecked", "rawtypes" })<a name="line.265"></a>
-<span class="sourceLineNo">266</span>   private &lt;T&gt; T parseAnything(RdfParserSession session, ClassMeta&lt;T&gt; eType, RDFNode n, Object outer, BeanPropertyMeta pMeta) throws Exception {<a name="line.266"></a>
-<span class="sourceLineNo">267</span><a name="line.267"></a>
-<span class="sourceLineNo">268</span>      if (eType == null)<a name="line.268"></a>
-<span class="sourceLineNo">269</span>         eType = (ClassMeta&lt;T&gt;)object();<a name="line.269"></a>
-<span class="sourceLineNo">270</span>      PojoSwap&lt;T,Object&gt; transform = (PojoSwap&lt;T,Object&gt;)eType.getPojoSwap();<a name="line.270"></a>
-<span class="sourceLineNo">271</span>      ClassMeta&lt;?&gt; sType = eType.getSerializedClassMeta();<a name="line.271"></a>
-<span class="sourceLineNo">272</span>      session.setCurrentClass(sType);<a name="line.272"></a>
-<span class="sourceLineNo">273</span><a name="line.273"></a>
-<span class="sourceLineNo">274</span>      if (! sType.canCreateNewInstance(outer)) {<a name="line.274"></a>
-<span class="sourceLineNo">275</span>         if (n.isResource()) {<a name="line.275"></a>
-<span class="sourceLineNo">276</span>            Statement st = n.asResource().getProperty(session.getTypeProperty());<a name="line.276"></a>
-<span class="sourceLineNo">277</span>            if (st != null) {<a name="line.277"></a>
-<span class="sourceLineNo">278</span>               String c = st.getLiteral().getString();<a name="line.278"></a>
-<span class="sourceLineNo">279</span>               ClassMeta tcm = session.getClassMeta(c, pMeta, eType);<a name="line.279"></a>
-<span class="sourceLineNo">280</span>               if (tcm != null)<a name="line.280"></a>
-<span class="sourceLineNo">281</span>                  sType = eType = tcm;<a name="line.281"></a>
-<span class="sourceLineNo">282</span>            }<a name="line.282"></a>
-<span class="sourceLineNo">283</span>         }<a name="line.283"></a>
-<span class="sourceLineNo">284</span>      }<a name="line.284"></a>
-<span class="sourceLineNo">285</span><a name="line.285"></a>
-<span class="sourceLineNo">286</span>      Object o = null;<a name="line.286"></a>
-<span class="sourceLineNo">287</span>      if (n.isResource() &amp;&amp; n.asResource().getURI() != null &amp;&amp; n.asResource().getURI().equals(RDF_NIL)) {<a name="line.287"></a>
-<span class="sourceLineNo">288</span>         // Do nothing.  Leave o == null.<a name="line.288"></a>
-<span class="sourceLineNo">289</span>      } else if (sType.isObject()) {<a name="line.289"></a>
-<span class="sourceLineNo">290</span>         if (n.isLiteral()) {<a name="line.290"></a>
-<span class="sourceLineNo">291</span>            o = n.asLiteral().getValue();<a name="line.291"></a>
-<span class="sourceLineNo">292</span>            if (o instanceof String) {<a name="line.292"></a>
-<span class="sourceLineNo">293</span>               o = session.decodeString(o);<a name="line.293"></a>
-<span class="sourceLineNo">294</span>            }<a name="line.294"></a>
-<span class="sourceLineNo">295</span>         }<a name="line.295"></a>
-<span class="sourceLineNo">296</span>         else if (n.isResource()) {<a name="line.296"></a>
-<span class="sourceLineNo">297</span>            Resource r = n.asResource();<a name="line.297"></a>
-<span class="sourceLineNo">298</span>            if (session.wasAlreadyProcessed(r))<a name="line.298"></a>
-<span class="sourceLineNo">299</span>               o = r.getURI();<a name="line.299"></a>
-<span class="sourceLineNo">300</span>            else if (r.getProperty(session.getValueProperty()) != null) {<a name="line.300"></a>
-<span class="sourceLineNo">301</span>               o = parseAnything(session, object(), n.asResource().getProperty(session.getValueProperty()).getObject(), outer, null);<a name="line.301"></a>
-<span class="sourceLineNo">302</span>            } else if (isSeq(session, r)) {<a name="line.302"></a>
-<span class="sourceLineNo">303</span>               o = new ObjectList(session);<a name="line.303"></a>
-<span class="sourceLineNo">304</span>               parseIntoCollection(session, r.as(Seq.class), (Collection)o, sType.getElementType(), pMeta);<a name="line.304"></a>
-<span class="sourceLineNo">305</span>            } else if (isBag(session, r)) {<a name="line.305"></a>
-<span class="sourceLineNo">306</span>               o = new ObjectList(session);<a name="line.306"></a>
-<span class="sourceLineNo">307</span>               parseIntoCollection(session, r.as(Bag.class), (Collection)o, sType.getElementType(), pMeta);<a name="line.307"></a>
-<span class="sourceLineNo">308</span>            } else if (r.canAs(RDFList.class)) {<a name="line.308"></a>
-<span class="sourceLineNo">309</span>               o = new ObjectList(session);<a name="line.309"></a>
-<span class="sourceLineNo">310</span>               parseIntoCollection(session, r.as(RDFList.class), (Collection)o, sType.getElementType(), pMeta);<a name="line.310"></a>
-<span class="sourceLineNo">311</span>            } else {<a name="line.311"></a>
-<span class="sourceLineNo">312</span>               // If it has a URI and no child properties, we interpret this as an<a name="line.312"></a>
-<span class="sourceLineNo">313</span>               // external resource, and convert it to just a URL.<a name="line.313"></a>
-<span class="sourceLineNo">314</span>               String uri = r.getURI();<a name="line.314"></a>
-<span class="sourceLineNo">315</span>               if (uri != null &amp;&amp; ! r.listProperties().hasNext()) {<a name="line.315"></a>
-<span class="sourceLineNo">316</span>                  o = r.getURI();<a name="line.316"></a>
-<span class="sourceLineNo">317</span>               } else {<a name="line.317"></a>
-<span class="sourceLineNo">318</span>                  ObjectMap m2 = new ObjectMap(session);<a name="line.318"></a>
-<span class="sourceLineNo">319</span>                  parseIntoMap(session, r, m2, null, null, pMeta);<a name="line.319"></a>
-<span class="sourceLineNo">320</span>                  o = session.cast(m2, pMeta, eType);<a name="line.320"></a>
-<span class="sourceLineNo">321</span>               }<a name="line.321"></a>
-<span class="sourceLineNo">322</span>            }<a name="line.322"></a>
-<span class="sourceLineNo">323</span>         } else {<a name="line.323"></a>
-<span class="sourceLineNo">324</span>            throw new ParseException(session, "Unrecognized node type ''{0}'' for object", n);<a name="line.324"></a>
-<span class="sourceLineNo">325</span>         }<a name="line.325"></a>
-<span class="sourceLineNo">326</span>      } else if (sType.isBoolean()) {<a name="line.326"></a>
-<span class="sourceLineNo">327</span>         o = session.convertToType(getValue(session, n, outer), boolean.class);<a name="line.327"></a>
-<span class="sourceLineNo">328</span>      } else if (sType.isCharSequence()) {<a name="line.328"></a>
-<span class="sourceLineNo">329</span>         o = session.decodeString(getValue(session, n, outer));<a name="line.329"></a>
-<span class="sourceLineNo">330</span>      } else if (sType.isChar()) {<a name="line.330"></a>
-<span class="sourceLineNo">331</span>         o = session.decodeString(getValue(session, n, outer)).charAt(0);<a name="line.331"></a>
-<span class="sourceLineNo">332</span>      } else if (sType.isNumber()) {<a name="line.332"></a>
-<span class="sourceLineNo">333</span>         o = parseNumber(getValue(session, n, outer).toString(), (Class&lt;? extends Number&gt;)sType.getInnerClass());<a name="line.333"></a>
-<span class="sourceLineNo">334</span>      } else if (sType.isMap()) {<a name="line.334"></a>
-<span class="sourceLineNo">335</span>         Resource r = n.asResource();<a name="line.335"></a>
-<span class="sourceLineNo">336</span>         if (session.wasAlreadyProcessed(r))<a name="line.336"></a>
-<span class="sourceLineNo">337</span>            return null;<a name="line.337"></a>
-<span class="sourceLineNo">338</span>         Map m = (sType.canCreateNewInstance(outer) ? (Map)sType.newInstance(outer) : new ObjectMap(session));<a name="line.338"></a>
-<span class="sourceLineNo">339</span>         o = parseIntoMap(session, r, m, eType.getKeyType(), eType.getValueType(), pMeta);<a name="line.339"></a>
-<span class="sourceLineNo">340</span>      } else if (sType.isCollectionOrArray()) {<a name="line.340"></a>
-<span class="sourceLineNo">341</span>         if (sType.isArray())<a name="line.341"></a>
-<span class="sourceLineNo">342</span>            o = new ArrayList();<a name="line.342"></a>
-<span class="sourceLineNo">343</span>         else<a name="line.343"></a>
-<span class="sourceLineNo">344</span>            o = (sType.canCreateNewInstance(outer) ? (Collection&lt;?&gt;)sType.newInstance(outer) : new ObjectList(session));<a name="line.344"></a>
-<span class="sourceLineNo">345</span>         Resource r = n.asResource();<a name="line.345"></a>
-<span class="sourceLineNo">346</span>         if (session.wasAlreadyProcessed(r))<a name="line.346"></a>
-<span class="sourceLineNo">347</span>            return null;<a name="line.347"></a>
-<span class="sourceLineNo">348</span>         if (isSeq(session, r)) {<a name="line.348"></a>
-<span class="sourceLineNo">349</span>            parseIntoCollection(session, r.as(Seq.class), (Collection)o, sType.getElementType(), pMeta);<a name="line.349"></a>
-<span class="sourceLineNo">350</span>         } else if (isBag(session, r)) {<a name="line.350"></a>
-<span class="sourceLineNo">351</span>            parseIntoCollection(session, r.as(Bag.class), (Collection)o, sType.getElementType(), pMeta);<a name="line.351"></a>
-<span class="sourceLineNo">352</span>         } else if (r.canAs(RDFList.class)) {<a name="line.352"></a>
-<span class="sourceLineNo">353</span>            parseIntoCollection(session, r.as(RDFList.class), (Collection)o, sType.getElementType(), pMeta);<a name="line.353"></a>
-<span class="sourceLineNo">354</span>         } else {<a name="line.354"></a>
-<span class="sourceLineNo">355</span>            throw new ParseException("Unrecognized node type ''{0}'' for collection", n);<a name="line.355"></a>
-<span class="sourceLineNo">356</span>         }<a name="line.356"></a>
-<span class="sourceLineNo">357</span>         if (sType.isArray())<a name="line.357"></a>
-<span class="sourceLineNo">358</span>            o = session.toArray(sType, (Collection)o);<a name="line.358"></a>
-<span class="sourceLineNo">359</span>      } else if (sType.canCreateNewBean(outer)) {<a name="line.359"></a>
-<span class="sourceLineNo">360</span>         Resource r = n.asResource();<a name="line.360"></a>
-<span class="sourceLineNo">361</span>         if (session.wasAlreadyProcessed(r))<a name="line.361"></a>
-<span class="sourceLineNo">362</span>            return null;<a name="line.362"></a>
-<span class="sourceLineNo">363</span>         BeanMap&lt;?&gt; bm = session.newBeanMap(outer, sType.getInnerClass());<a name="line.363"></a>
-<span class="sourceLineNo">364</span>         o = parseIntoBeanMap(session, r, bm).getBean();<a name="line.364"></a>
-<span class="sourceLineNo">365</span>      } else if (sType.isUri() &amp;&amp; n.isResource()) {<a name="line.365"></a>
-<span class="sourceLineNo">366</span>         o = sType.newInstanceFromString(outer, session.decodeString(n.asResource().getURI()));<a name="line.366"></a>
-<span class="sourceLineNo">367</span>      } else if (sType.canCreateNewInstanceFromString(outer)) {<a name="line.367"></a>
-<span class="sourceLineNo">368</span>         o = sType.newInstanceFromString(outer, session.decodeString(getValue(session, n, outer)));<a name="line.368"></a>
-<span class="sourceLineNo">369</span>      } else if (sType.canCreateNewInstanceFromNumber(outer)) {<a name="line.369"></a>
-<span class="sourceLineNo">370</span>         o = sType.newInstanceFromNumber(session, outer, parseNumber(getValue(session, n, outer).toString(), sType.getNewInstanceFromNumberClass()));<a name="line.370"></a>
-<span class="sourceLineNo">371</span>      } else if (n.isResource()) {<a name="line.371"></a>
-<span class="sourceLineNo">372</span>         Resource r = n.asResource();<a name="line.372"></a>
-<span class="sourceLineNo">373</span>         Map m = new ObjectMap(session);<a name="line.373"></a>
-<span class="sourceLineNo">374</span>         parseIntoMap(session, r, m, sType.getKeyType(), sType.getValueType(), pMeta);<a name="line.374"></a>
-<span class="sourceLineNo">375</span>         if (m.containsKey(session.getBeanTypePropertyName()))<a name="line.375"></a>
-<span class="sourceLineNo">376</span>            o = session.cast((ObjectMap)m, pMeta, eType);<a name="line.376"></a>
-<span class="sourceLineNo">377</span>         else<a name="line.377"></a>
-<span class="sourceLineNo">378</span>            throw new ParseException(session, "Class ''{0}'' could not be instantiated.  Reason: ''{1}''", sType.getInnerClass().getName(), sType.getNotABeanReason());<a name="line.378"></a>
-<span class="sourceLineNo">379</span>      } else {<a name="line.379"></a>
-<span class="sourceLineNo">380</span>         throw new ParseException("Class ''{0}'' could not be instantiated.  Reason: ''{1}''", sType.getInnerClass().getName(), sType.getNotABeanReason());<a name="line.380"></a>
-<span class="sourceLineNo">381</span>      }<a name="line.381"></a>
-<span class="sourceLineNo">382</span><a name="line.382"></a>
-<span class="sourceLineNo">383</span>      if (transform != null &amp;&amp; o != null)<a name="line.383"></a>
-<span class="sourceLineNo">384</span>         o = transform.unswap(session, o, eType);<a name="line.384"></a>
-<span class="sourceLineNo">385</span><a name="line.385"></a>
-<span class="sourceLineNo">386</span>      if (outer != null)<a name="line.386"></a>
-<span class="sourceLineNo">387</span>         setParent(eType, o, outer);<a name="line.387"></a>
-<span class="sourceLineNo">388</span><a name="line.388"></a>
-<span class="sourceLineNo">389</span>      return (T)o;<a name="line.389"></a>
-<span class="sourceLineNo">390</span>   }<a name="line.390"></a>
-<span class="sourceLineNo">391</span><a name="line.391"></a>
-<span class="sourceLineNo">392</span>   private static boolean isSeq(RdfParserSession session, RDFNode n) {<a name="line.392"></a>
-<span class="sourceLineNo">393</span>      if (n.isResource()) {<a name="line.393"></a>
-<span class="sourceLineNo">394</span>         Statement st = n.asResource().getProperty(session.getRdfTypeProperty());<a name="line.394"></a>
-<span class="sourceLineNo">395</span>         if (st != null)<a name="line.395"></a>
-<span class="sourceLineNo">396</span>            return RDF_SEQ.equals(st.getResource().getURI());<a name="line.396"></a>
-<span class="sourceLineNo">397</span>      }<a name="line.397"></a>
-<span class="sourceLineNo">398</span>      return false;<a name="line.398"></a>
-<span class="sourceLineNo">399</span>   }<a name="line.399"></a>
-<span class="sourceLineNo">400</span><a name="line.400"></a>
-<span class="sourceLineNo">401</span>   private static boolean isBag(RdfParserSession session, RDFNode n) {<a name="line.401"></a>
-<span class="sourceLineNo">402</span>      if (n.isResource()) {<a name="line.402"></a>
-<span class="sourceLineNo">403</span>         Statement st = n.asResource().getProperty(session.getRdfTypeProperty());<a name="line.403"></a>
-<span class="sourceLineNo">404</span>         if (st != null)<a name="line.404"></a>
-<span class="sourceLineNo">405</span>            return RDF_BAG.equals(st.getResource().getURI());<a name="line.405"></a>
-<span class="sourceLineNo">406</span>      }<a name="line.406"></a>
-<span class="sourceLineNo">407</span>      return false;<a name="line.407"></a>
-<span class="sourceLineNo">408</span>   }<a name="line.408"></a>
-<span class="sourceLineNo">409</span><a name="line.409"></a>
-<span class="sourceLineNo">410</span>   private Object getValue(RdfParserSession session, RDFNode n, Object outer) throws Exception {<a name="line.410"></a>
-<span class="sourceLineNo">411</span>      if (n.isLiteral())<a name="line.411"></a>
-<span class="sourceLineNo">412</span>         return n.asLiteral().getValue();<a name="line.412"></a>
-<span class="sourceLineNo">413</span>      if (n.isResource()) {<a name="line.413"></a>
-<span class="sourceLineNo">414</span>         Statement st = n.asResource().getProperty(session.getValueProperty());<a name="line.414"></a>
-<span class="sourceLineNo">415</span>         if (st != null) {<a name="line.415"></a>
-<span class="sourceLineNo">416</span>            n = st.getObject();<a name="line.416"></a>
-<span class="sourceLineNo">417</span>            if (n.isLiteral())<a name="line.417"></a>
-<span class="sourceLineNo">418</span>               return n.asLiteral().getValue();<a name="line.418"></a>
-<span class="sourceLineNo">419</span>            return parseAnything(session, object(), st.getObject(), outer, null);<a name="line.419"></a>
-<span class="sourceLineNo">420</span>         }<a name="line.420"></a>
-<span class="sourceLineNo">421</span>      }<a name="line.421"></a>
-<span class="sourceLineNo">422</span>      throw new ParseException(session, "Unknown value type for node ''{0}''", n);<a name="line.422"></a>
-<span class="sourceLineNo">423</span>   }<a name="line.423"></a>
-<span class="sourceLineNo">424</span><a name="line.424"></a>
-<span class="sourceLineNo">425</span>   private &lt;K,V&gt; Map&lt;K,V&gt; parseIntoMap(RdfParserSession session, Resource r, Map&lt;K,V&gt; m, ClassMeta&lt;K&gt; keyType, ClassMeta&lt;V&gt; valueType, BeanPropertyMeta pMeta) throws Exception {<a name="line.425"></a>
-<span class="sourceLineNo">426</span>      // Add URI as "uri" to generic maps.<a name="line.426"></a>
-<span class="sourceLineNo">427</span>      if (r.getURI() != null) {<a name="line.427"></a>
-<span class="sourceLineNo">428</span>         K uri = convertAttrToType(session, m, "uri", keyType);<a name="line.428"></a>
-<span class="sourceLineNo">429</span>         V value = convertAttrToType(session, m, r.getURI(), valueType);<a name="line.429"></a>
-<span class="sourceLineNo">430</span>         m.put(uri, value);<a name="line.430"></a>
-<span class="sourceLineNo">431</span>      }<a name="line.431"></a>
-<span class="sourceLineNo">432</span>      for (StmtIterator i = r.listProperties(); i.hasNext();) {<a name="line.432"></a>
-<span class="sourceLineNo">433</span>         Statement st = i.next();<a name="line.433"></a>
-<span class="sourceLineNo">434</span>         Property p = st.getPredicate();<a name="line.434"></a>
-<span class="sourceLineNo">435</span>         String key = p.getLocalName();<a name="line.435"></a>
-<span class="sourceLineNo">436</span>         if (! (key.equals("root") &amp;&amp; p.getURI().equals(session.getJuneauNsUri()))) {<a name="line.436"></a>
-<span class="sourceLineNo">437</span>            key = session.decodeString(key);<a name="line.437"></a>
-<span class="sourceLineNo">438</span>            RDFNode o = st.getObject();<a name="line.438"></a>
-<span class="sourceLineNo">439</span>            K key2 = convertAttrToType(session, m, key, keyType);<a name="line.439"></a>
-<span class="sourceLineNo">440</span>            V value = parseAnything(session, valueType, o, m, pMeta);<a name="line.440"></a>
-<span class="sourceLineNo">441</span>            setName(valueType, value, key);<a name="line.441"></a>
-<span class="sourceLineNo">442</span>            m.put(key2, value);<a name="line.442"></a>
-<span class="sourceLineNo">443</span>         }<a name="line.443"></a>
-<span class="sourceLineNo">444</span><a name="line.444"></a>
-<span class="sourceLineNo">445</span>      }<a name="line.445"></a>
-<span class="sourceLineNo">446</span>      return m;<a name="line.446"></a>
-<span class="sourceLineNo">447</span>   }<a name="line.447"></a>
-<span class="sourceLineNo">448</span><a name="line.448"></a>
-<span class="sourceLineNo">449</span>   private &lt;E&gt; Collection&lt;E&gt; parseIntoCollection(RdfParserSession session, Container c, Collection&lt;E&gt; l, ClassMeta&lt;E&gt; et, BeanPropertyMeta pMeta) throws Exception {<a name="line.449"></a>
-<span class="sourceLineNo">450</span>      for (NodeIterator ni = c.iterator(); ni.hasNext();) {<a name="line.450"></a>
-<span class="sourceLineNo">451</span>         E e = parseAnything(session, et, ni.next(), l, pMeta);<a name="line.451"></a>
-<span class="sourceLineNo">452</span>         l.add(e);<a name="line.452"></a>
-<span class="sourceLineNo">453</span>      }<a name="line.453"></a>
-<span class="sourceLineNo">454</span>      return l;<a name="line.454"></a>
-<span class="sourceLineNo">455</span>   }<a name="line.455"></a>
-<span class="sourceLineNo">456</span><a name="line.456"></a>
-<span class="sourceLineNo">457</span>   private &lt;E&gt; Collection&lt;E&gt; parseIntoCollection(RdfParserSession session, RDFList list, Collection&lt;E&gt; l, ClassMeta&lt;E&gt; et, BeanPropertyMeta pMeta) throws Exception {<a name="line.457"></a>
-<span class="sourceLineNo">458</span>      for (ExtendedIterator&lt;RDFNode&gt; ni = list.iterator(); ni.hasNext();) {<a name="line.458"></a>
-<span class="sourceLineNo">459</span>         E e = parseAnything(session, et, ni.next(), l, pMeta);<a name="line.459"></a>
-<span class="sourceLineNo">460</span>         l.add(e);<a name="line.460"></a>
-<span class="sourceLineNo">461</span>      }<a name="line.461"></a>
-<span class="sourceLineNo">462</span>      return l;<a name="line.462"></a>
-<span class="sourceLineNo">463</span>   }<a name="line.463"></a>
-<span class="sourceLineNo">464</span><a name="line.464"></a>
-<span class="sourceLineNo">465</span>   @Override /* Parser */<a name="line.465"></a>
-<span class="sourceLineNo">466</span>   protected Object[] doParseArgs(ParserSession session, ClassMeta&lt;?&gt;[] argTypes) throws Exception {<a name="line.466"></a>
-<span class="sourceLineNo">467</span>      throw new UnsupportedOperationException("Parser '"+getClass().getName()+"' does not support this method.");<a name="line.467"></a>
-<span class="sourceLineNo">468</span>   }<a name="line.468"></a>
-<span class="sourceLineNo">469</span><a name="line.469"></a>
-<span class="sourceLineNo">470</span>   <a name="line.470"></a>
-<span class="sourceLineNo">471</span>   //--------------------------------------------------------------------------------<a name="line.471"></a>
-<span class="sourceLineNo">472</span>   // Entry point methods<a name="line.472"></a>
-<span class="sourceLineNo">473</span>   //--------------------------------------------------------------------------------<a name="line.473"></a>
-<span class="sourceLineNo">474</span><a name="line.474"></a>
-<span class="sourceLineNo">475</span>   @Override /* Parser */<a name="line.475"></a>
-<span class="sourceLineNo">476</span>   public RdfParserSession createSession(Object input, ObjectMap op, Method javaMethod, Object outer, Locale locale, TimeZone timeZone, MediaType mediaType) {<a name="line.476"></a>
-<span class="sourceLineNo">477</span>      return new RdfParserSession(ctx, op, input, javaMethod, outer, locale, timeZone, mediaType);<a name="line.477"></a>
-<span class="sourceLineNo">478</span>   }<a name="line.478"></a>
-<span class="sourceLineNo">479</span>}<a name="line.479"></a>
+<span class="sourceLineNo">176</span>         <a name="line.176"></a>
+<span class="sourceLineNo">177</span>         int argIndex = 0;<a name="line.177"></a>
+<span class="sourceLineNo">178</span>         for (Resource resource : roots)<a name="line.178"></a>
+<span class="sourceLineNo">179</span>            c.add(parseAnything(s, type.isArgs() ? type.getArg(argIndex++) : type.getElementType(), resource, session.getOuter(), null));<a name="line.179"></a>
+<span class="sourceLineNo">180</span><a name="line.180"></a>
+<span class="sourceLineNo">181</span>         if (type.isArray() || type.isArgs())<a name="line.181"></a>
+<span class="sourceLineNo">182</span>            return (T)session.toArray(type, c);<a name="line.182"></a>
+<span class="sourceLineNo">183</span>         return (T)c;<a name="line.183"></a>
+<span class="sourceLineNo">184</span>      }<a name="line.184"></a>
+<span class="sourceLineNo">185</span><a name="line.185"></a>
+<span class="sourceLineNo">186</span>      if (roots.isEmpty())<a name="line.186"></a>
+<span class="sourceLineNo">187</span>         return null;<a name="line.187"></a>
+<span class="sourceLineNo">188</span>      if (roots.size() &gt; 1)<a name="line.188"></a>
+<span class="sourceLineNo">189</span>         throw new ParseException(session, "Too many root nodes found in model:  {0}", roots.size());<a name="line.189"></a>
+<span class="sourceLineNo">190</span>      Resource resource = roots.get(0);<a name="line.190"></a>
+<span class="sourceLineNo">191</span><a name="line.191"></a>
+<span class="sourceLineNo">192</span>      return parseAnything(s, type, resource, session.getOuter(), null);<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>    * Finds the roots in the model using either the "root" property to identify it,<a name="line.196"></a>
+<span class="sourceLineNo">197</span>    *    or by resorting to scanning the model for all nodes with no incoming predicates.<a name="line.197"></a>
+<span class="sourceLineNo">198</span>    */<a name="line.198"></a>
+<span class="sourceLineNo">199</span>   private static List&lt;Resource&gt; getRoots(RdfParserSession session, Model m) {<a name="line.199"></a>
+<span class="sourceLineNo">200</span>      List&lt;Resource&gt; l = new LinkedList&lt;Resource&gt;();<a name="line.200"></a>
+<span class="sourceLineNo">201</span><a name="line.201"></a>
+<span class="sourceLineNo">202</span>      // First try to find the root using the "http://www.apache.org/juneau/root" property.<a name="line.202"></a>
+<span class="sourceLineNo">203</span>      Property root = m.createProperty(session.getJuneauNsUri(), RDF_juneauNs_ROOT);<a name="line.203"></a>
+<span class="sourceLineNo">204</span>      for (ResIterator i  = m.listResourcesWithProperty(root); i.hasNext();)<a name="line.204"></a>
+<span class="sourceLineNo">205</span>         l.add(i.next());<a name="line.205"></a>
+<span class="sourceLineNo">206</span><a name="line.206"></a>
+<span class="sourceLineNo">207</span>      if (! l.isEmpty())<a name="line.207"></a>
+<span class="sourceLineNo">208</span>         return l;<a name="line.208"></a>
+<span class="sourceLineNo">209</span><a name="line.209"></a>
+<span class="sourceLineNo">210</span>      // Otherwise, we need to find all resources that aren't objects.<a name="line.210"></a>
+<span class="sourceLineNo">211</span>      // We want to explicitly ignore statements where the subject<a name="line.211"></a>
+<span class="sourceLineNo">212</span>      // and object are the same node.<a name="line.212"></a>
+<span class="sourceLineNo">213</span>      Set&lt;RDFNode&gt; objects = new HashSet&lt;RDFNode&gt;();<a name="line.213"></a>
+<span class="sourceLineNo">214</span>      for (StmtIterator i = m.listStatements(); i.hasNext();) {<a name="line.214"></a>
+<span class="sourceLineNo">215</span>         Statement st = i.next();<a name="line.215"></a>
+<span class="sourceLineNo">216</span>         RDFNode subject = st.getSubject();<a name="line.216"></a>
+<span class="sourceLineNo">217</span>         RDFNode object = st.getObject();<a name="line.217"></a>
+<span class="sourceLineNo">218</span>         if (object.isResource() &amp;&amp; ! object.equals(subject))<a name="line.218"></a>
+<span class="sourceLineNo">219</span>            objects.add(object);<a name="line.219"></a>
+<span class="sourceLineNo">220</span>      }<a name="line.220"></a>
+<span class="sourceLineNo">221</span>      for (ResIterator i = m.listSubjects(); i.hasNext();) {<a name="line.221"></a>
+<span class="sourceLineNo">222</span>         Resource r = i.next();<a name="line.222"></a>
+<span class="sourceLineNo">223</span>         if (! objects.contains(r))<a name="line.223"></a>
+<span class="sourceLineNo">224</span>            l.add(r);<a name="line.224"></a>
+<span class="sourceLineNo">225</span>      }<a name="line.225"></a>
+<span class="sourceLineNo">226</span>      return l;<a name="line.226"></a>
+<span class="sourceLineNo">227</span>   }<a name="line.227"></a>
+<span class="sourceLineNo">228</span><a name="line.228"></a>
+<span class="sourceLineNo">229</span>   private &lt;T&gt; BeanMap&lt;T&gt; parseIntoBeanMap(RdfParserSession session, Resource r2, BeanMap&lt;T&gt; m) throws Exception {<a name="line.229"></a>
+<span class="sourceLineNo">230</span>      BeanMeta&lt;T&gt; bm = m.getMeta();<a name="line.230"></a>
+<span class="sourceLineNo">231</span>      RdfBeanMeta rbm = bm.getExtendedMeta(RdfBeanMeta.class);<a name="line.231"></a>
+<span class="sourceLineNo">232</span>      if (rbm.hasBeanUri() &amp;&amp; r2.getURI() != null)<a name="line.232"></a>
+<span class="sourceLineNo">233</span>         rbm.getBeanUriProperty().set(m, r2.getURI());<a name="line.233"></a>
+<span class="sourceLineNo">234</span>      for (StmtIterator i = r2.listProperties(); i.hasNext();) {<a name="line.234"></a>
+<span class="sourceLineNo">235</span>         Statement st = i.next();<a name="line.235"></a>
+<span class="sourceLineNo">236</span>         Property p = st.getPredicate();<a name="line.236"></a>
+<span class="sourceLineNo">237</span>         String key = session.decodeString(p.getLocalName());<a name="line.237"></a>
+<span class="sourceLineNo">238</span>         BeanPropertyMeta pMeta = m.getPropertyMeta(key);<a name="line.238"></a>
+<span class="sourceLineNo">239</span>         session.setCurrentProperty(pMeta);<a name="line.239"></a>
+<span class="sourceLineNo">240</span>         if (pMeta != null) {<a name="line.240"></a>
+<span class="sourceLineNo">241</span>            RDFNode o = st.getObject();<a name="line.241"></a>
+<span class="sourceLineNo">242</span>            ClassMeta&lt;?&gt; cm = pMeta.getClassMeta();<a name="line.242"></a>
+<span class="sourceLineNo">243</span>            if (cm.isCollectionOrArray() &amp;&amp; isMultiValuedCollections(session, pMeta)) {<a name="line.243"></a>
+<span class="sourceLineNo">244</span>               ClassMeta&lt;?&gt; et = cm.getElementType();<a name="line.244"></a>
+<span class="sourceLineNo">245</span>               Object value = parseAnything(session, et, o, m.getBean(false), pMeta);<a name="line.245"></a>
+<span class="sourceLineNo">246</span>               setName(et, value, key);<a name="line.246"></a>
+<span class="sourceLineNo">247</span>               pMeta.add(m, value);<a name="line.247"></a>
+<span class="sourceLineNo">248</span>            } else {<a name="line.248"></a>
+<span class="sourceLineNo">249</span>               Object value = parseAnything(session, cm, o, m.getBean(false), pMeta);<a name="line.249"></a>
+<span class="sourceLineNo">250</span>               setName(cm, value, key);<a name="line.250"></a>
+<span class="sourceLineNo">251</span>               pMeta.set(m, value);<a name="line.251"></a>
+<span class="sourceLineNo">252</span>            }<a name="line.252"></a>
+<span class="sourceLineNo">253</span>         } else if (! (p.equals(session.getRootProperty()) || p.equals(session.getTypeProperty()))) {<a name="line.253"></a>
+<span class="sourceLineNo">254</span>            onUnknownProperty(session, key, m, -1, -1);<a name="line.254"></a>
+<span class="sourceLineNo">255</span>         }<a name="line.255"></a>
+<span class="sourceLineNo">256</span>         session.setCurrentProperty(null);<a name="line.256"></a>
+<span class="sourceLineNo">257</span>      }<a name="line.257"></a>
+<span class="sourceLineNo">258</span>      return m;<a name="line.258"></a>
+<span class="sourceLineNo">259</span>   }<a name="line.259"></a>
+<span class="sourceLineNo">260</span><a name="line.260"></a>
+<span class="sourceLineNo">261</span>   private static boolean isMultiValuedCollections(RdfParserSession session, BeanPropertyMeta pMeta) {<a name="line.261"></a>
+<span class="sourceLineNo">262</span>      if (pMeta != null &amp;&amp; pMeta.getExtendedMeta(RdfBeanPropertyMeta.class).getCollectionFormat() != RdfCollectionFormat.DEFAULT)<a name="line.262"></a>
+<span class="sourceLineNo">263</span>         return pMeta.getExtendedMeta(RdfBeanPropertyMeta.class).getCollectionFormat() == RdfCollectionFormat.MULTI_VALUED;<a name="line.263"></a>
+<span class="sourceLineNo">264</span>      return session.getCollectionFormat() == RdfCollectionFormat.MULTI_VALUED;<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>   @SuppressWarnings({ "unchecked", "rawtypes" })<a name="line.267"></a>
+<span class="sourceLineNo">268</span>   private &lt;T&gt; T parseAnything(RdfParserSession session, ClassMeta&lt;T&gt; eType, RDFNode n, Object outer, BeanPropertyMeta pMeta) throws Exception {<a name="line.268"></a>
+<span class="sourceLineNo">269</span><a name="line.269"></a>
+<span class="sourceLineNo">270</span>      if (eType == null)<a name="line.270"></a>
+<span class="sourceLineNo">271</span>         eType = (ClassMeta&lt;T&gt;)object();<a name="line.271"></a>
+<span class="sourceLineNo">272</span>      PojoSwap&lt;T,Object&gt; transform = (PojoSwap&lt;T,Object&gt;)eType.getPojoSwap();<a name="line.272"></a>
+<span class="sourceLineNo">273</span>      ClassMeta&lt;?&gt; sType = eType.getSerializedClassMeta();<a name="line.273"></a>
+<span class="sourceLineNo">274</span>      session.setCurrentClass(sType);<a name="line.274"></a>
+<span class="sourceLineNo">275</span><a name="line.275"></a>
+<span class="sourceLineNo">276</span>      if (! sType.canCreateNewInstance(outer)) {<a name="line.276"></a>
+<span class="sourceLineNo">277</span>         if (n.isResource()) {<a name="line.277"></a>
+<span class="sourceLineNo">278</span>            Statement st = n.asResource().getProperty(session.getTypeProperty());<a name="line.278"></a>
+<span class="sourceLineNo">279</span>            if (st != null) {<a name="line.279"></a>
+<span class="sourceLineNo">280</span>               String c = st.getLiteral().getString();<a name="line.280"></a>
+<span class="sourceLineNo">281</span>               ClassMeta tcm = session.getClassMeta(c, pMeta, eType);<a name="line.281"></a>
+<span class="sourceLineNo">282</span>               if (tcm != null)<a name="line.282"></a>
+<span class="sourceLineNo">283</span>                  sType = eType = tcm;<a name="line.283"></a>
+<span class="sourceLineNo">284</span>            }<a name="line.284"></a>
+<span class="sourceLineNo">285</span>         }<a name="line.285"></a>
+<span class="sourceLineNo">286</span>      }<a name="line.286"></a>
+<span class="sourceLineNo">287</span><a name="line.287"></a>
+<span class="sourceLineNo">288</span>      Object o = null;<a name="line.288"></a>
+<span class="sourceLineNo">289</span>      if (n.isResource() &amp;&amp; n.asResource().getURI() != null &amp;&amp; n.asResource().getURI().equals(RDF_NIL)) {<a name="line.289"></a>
+<span class="sourceLineNo">290</span>         // Do nothing.  Leave o == null.<a name="line.290"></a>
+<span class="sourceLineNo">291</span>      } else if (sType.isObject()) {<a name="line.291"></a>
+<span class="sourceLineNo">292</span>         if (n.isLiteral()) {<a name="line.292"></a>
+<span class="sourceLineNo">293</span>            o = n.asLiteral().getValue();<a name="line.293"></a>
+<span class="sourceLineNo">294</span>            if (o instanceof String) {<a name="line.294"></a>
+<span class="sourceLineNo">295</span>               o = session.decodeString(o);<a name="line.295"></a>
+<span class="sourceLineNo">296</span>            }<a name="line.296"></a>
+<span class="sourceLineNo">297</span>         }<a name="line.297"></a>
+<span class="sourceLineNo">298</span>         else if (n.isResource()) {<a name="line.298"></a>
+<span class="sourceLineNo">299</span>            Resource r = n.asResource();<a name="line.299"></a>
+<span class="sourceLineNo">300</span>            if (session.wasAlreadyProcessed(r))<a name="line.300"></a>
+<span class="sourceLineNo">301</span>               o = r.getURI();<a name="line.301"></a>
+<span class="sourceLineNo">302</span>            else if (r.getProperty(session.getValueProperty()) != null) {<a name="line.302"></a>
+<span class="sourceLineNo">303</span>               o = parseAnything(session, object(), n.asResource().getProperty(session.getValueProperty()).getObject(), outer, null);<a name="line.303"></a>
+<span class="sourceLineNo">304</span>            } else if (isSeq(session, r)) {<a name="line.304"></a>
+<span class="sourceLineNo">305</span>               o = new ObjectList(session);<a name="line.305"></a>
+<span class="sourceLineNo">306</span>               parseIntoCollection(session, r.as(Seq.class), (Collection)o, sType, pMeta);<a name="line.306"></a>
+<span class="sourceLineNo">307</span>            } else if (isBag(session, r)) {<a name="line.307"></a>
+<span class="sourceLineNo">308</span>               o = new ObjectList(session);<a name="line.308"></a>
+<span class="sourceLineNo">309</span>               parseIntoCollection(session, r.as(Bag.class), (Collection)o, sType, pMeta);<a name="line.309"></a>
+<span class="sourceLineNo">310</span>            } else if (r.canAs(RDFList.class)) {<a name="line.310"></a>
+<span class="sourceLineNo">311</span>               o = new ObjectList(session);<a name="line.311"></a>
+<span class="sourceLineNo">312</span>               parseIntoCollection(session, r.as(RDFList.class), (Collection)o, sType, pMeta);<a name="line.312"></a>
+<span class="sourceLineNo">313</span>            } else {<a name="line.313"></a>
+<span class="sourceLineNo">314</span>               // If it has a URI and no child properties, we interpret this as an<a name="line.314"></a>
+<span class="sourceLineNo">315</span>               // external resource, and convert it to just a URL.<a name="line.315"></a>
+<span class="sourceLineNo">316</span>               String uri = r.getURI();<a name="line.316"></a>
+<span class="sourceLineNo">317</span>               if (uri != null &amp;&amp; ! r.listProperties().hasNext()) {<a name="line.317"></a>
+<span class="sourceLineNo">318</span>                  o = r.getURI();<a name="line.318"></a>
+<span class="sourceLineNo">319</span>               } else {<a name="line.319"></a>
+<span class="sourceLineNo">320</span>                  ObjectMap m2 = new ObjectMap(session);<a name="line.320"></a>
+<span class="sourceLineNo">321</span>                  parseIntoMap(session, r, m2, null, null, pMeta);<a name="line.321"></a>
+<span class="sourceLineNo">322</span>                  o = session.cast(m2, pMeta, eType);<a name="line.322"></a>
+<span class="sourceLineNo">323</span>               }<a name="line.323"></a>
+<span class="sourceLineNo">324</span>            }<a name="line.324"></a>
+<span class="sourceLineNo">325</span>         } else {<a name="line.325"></a>
+<span class="sourceLineNo">326</span>            throw new ParseException(session, "Unrecognized node type ''{0}'' for object", n);<a name="line.326"></a>
+<span class="sourceLineNo">327</span>         }<a name="line.327"></a>
+<span class="sourceLineNo">328</span>      } else if (sType.isBoolean()) {<a name="line.328"></a>
+<span class="sourceLineNo">329</span>         o = session.convertToType(getValue(session, n, outer), boolean.class);<a name="line.329"></a>
+<span class="sourceLineNo">330</span>      } else if (sType.isCharSequence()) {<a name="line.330"></a>
+<span class="sourceLineNo">331</span>         o = session.decodeString(getValue(session, n, outer));<a name="line.331"></a>
+<span class="sourceLineNo">332</span>      } else if (sType.isChar()) {<a name="line.332"></a>
+<span class="sourceLineNo">333</span>         o = session.decodeString(getValue(session, n, outer)).charAt(0);<a name="line.333"></a>
+<span class="sourceLineNo">334</span>      } else if (sType.isNumber()) {<a name="line.334"></a>
+<span class="sourceLineNo">335</span>         o = parseNumber(getValue(session, n, outer).toString(), (Class&lt;? extends Number&gt;)sType.getInnerClass());<a name="line.335"></a>
+<span class="sourceLineNo">336</span>      } else if (sType.isMap()) {<a name="line.336"></a>
+<span class="sourceLineNo">337</span>         Resource r = n.asResource();<a name="line.337"></a>
+<span class="sourceLineNo">338</span>         if (session.wasAlreadyProcessed(r))<a name="line.338"></a>
+<span class="sourceLineNo">339</span>            return null;<a name="line.339"></a>
+<span class="sourceLineNo">340</span>         Map m = (sType.canCreateNewInstance(outer) ? (Map)sType.newInstance(outer) : new ObjectMap(session));<a name="line.340"></a>
+<span class="sourceLineNo">341</span>         o = parseIntoMap(session, r, m, eType.getKeyType(), eType.getValueType(), pMeta);<a name="line.341"></a>
+<span class="sourceLineNo">342</span>      } else if (sType.isCollectionOrArray() || sType.isArgs()) {<a name="line.342"></a>
+<span class="sourceLineNo">343</span>         if (sType.isArray() || sType.isArgs())<a name="line.343"></a>
+<span class="sourceLineNo">344</span>            o = new ArrayList();<a name="line.344"></a>
+<span class="sourceLineNo">345</span>         else<a name="line.345"></a>
+<span class="sourceLineNo">346</span>            o = (sType.canCreateNewInstance(outer) ? (Collection&lt;?&gt;)sType.newInstance(outer) : new ObjectList(session));<a name="line.346"></a>
+<span class="sourceLineNo">347</span>         Resource r = n.asResource();<a name="line.347"></a>
+<span class="sourceLineNo">348</span>         if (session.wasAlreadyProcessed(r))<a name="line.348"></a>
+<span class="sourceLineNo">349</span>            return null;<a name="line.349"></a>
+<span class="sourceLineNo">350</span>         if (isSeq(session, r)) {<a name="line.350"></a>
+<span class="sourceLineNo">351</span>            parseIntoCollection(session, r.as(Seq.class), (Collection)o, sType, pMeta);<a name="line.351"></a>
+<span class="sourceLineNo">352</span>         } else if (isBag(session, r)) {<a name="line.352"></a>
+<span class="sourceLineNo">353</span>            parseIntoCollection(session, r.as(Bag.class), (Collection)o, sType, pMeta);<a name="line.353"></a>
+<span class="sourceLineNo">354</span>         } else if (r.canAs(RDFList.class)) {<a name="line.354"></a>
+<span class="sourceLineNo">355</span>            parseIntoCollection(session, r.as(RDFList.class), (Collection)o, sType, pMeta);<a name="line.355"></a>
+<span class="sourceLineNo">356</span>         } else {<a name="line.356"></a>
+<span class="sourceLineNo">357</span>            throw new ParseException("Unrecognized node type ''{0}'' for collection", n);<a name="line.357"></a>
+<span class="sourceLineNo">358</span>         }<a name="line.358"></a>
+<span class="sourceLineNo">359</span>         if (sType.isArray() || sType.isArgs())<a name="line.359"></a>
+<span class="sourceLineNo">360</span>            o = session.toArray(sType, (Collection)o);<a name="line.360"></a>
+<span class="sourceLineNo">361</span>      } else if (sType.canCreateNewBean(outer)) {<a name="line.361"></a>
+<span class="sourceLineNo">362</span>         Resource r = n.asResource();<a name="line.362"></a>
+<span class="sourceLineNo">363</span>         if (session.wasAlreadyProcessed(r))<a name="line.363"></a>
+<span class="sourceLineNo">364</span>            return null;<a name="line.364"></a>
+<span class="sourceLineNo">365</span>         BeanMap&lt;?&gt; bm = session.newBeanMap(outer, sType.getInnerClass());<a name="line.365"></a>
+<span class="sourceLineNo">366</span>         o = parseIntoBeanMap(session, r, bm).getBean();<a name="line.366"></a>
+<span class="sourceLineNo">367</span>      } else if (sType.isUri() &amp;&amp; n.isResource()) {<a name="line.367"></a>
+<span class="sourceLineNo">368</span>         o = sType.newInstanceFromString(outer, session.decodeString(n.asResource().getURI()));<a name="line.368"></a>
+<span class="sourceLineNo">369</span>      } else if (sType.canCreateNewInstanceFromString(outer)) {<a name="line.369"></a>
+<span class="sourceLineNo">370</span>         o = sType.newInstanceFromString(outer, session.decodeString(getValue(session, n, outer)));<a name="line.370"></a>
+<span class="sourceLineNo">371</span>      } else if (sType.canCreateNewInstanceFromNumber(outer)) {<a name="line.371"></a>
+<span class="sourceLineNo">372</span>         o = sType.newInstanceFromNumber(session, outer, parseNumber(getValue(session, n, outer).toString(), sType.getNewInstanceFromNumberClass()));<a name="line.372"></a>
+<span class="sourceLineNo">373</span>      } else if (n.isResource()) {<a name="line.373"></a>
+<span class="sourceLineNo">374</span>         Resource r = n.asResource();<a name="line.374"></a>
+<span class="sourceLineNo">375</span>         Map m = new ObjectMap(session);<a name="line.375"></a>
+<span class="sourceLineNo">376</span>         parseIntoMap(session, r, m, sType.getKeyType(), sType.getValueType(), pMeta);<a name="line.376"></a>
+<span class="sourceLineNo">377</span>         if (m.containsKey(session.getBeanTypePropertyName()))<a name="line.377"></a>
+<span class="sourceLineNo">378</span>            o = session.cast((ObjectMap)m, pMeta, eType);<a name="line.378"></a>
+<span class="sourceLineNo">379</span>         else<a name="line.379"></a>
+<span class="sourceLineNo">380</span>            throw new ParseException(session, "Class ''{0}'' could not be instantiated.  Reason: ''{1}''", sType.getInnerClass().getName(), sType.getNotABeanReason());<a name="line.380"></a>
+<span class="sourceLineNo">381</span>      } else {<a name="line.381"></a>
+<span class="sourceLineNo">382</span>         throw new ParseException("Class ''{0}'' could not be instantiated.  Reason: ''{1}''", sType.getInnerClass().getName(), sType.getNotABeanReason());<a name="line.382"></a>
+<span class="sourceLineNo">383</span>      }<a name="line.383"></a>
+<span class="sourceLineNo">384</span><a name="line.384"></a>
+<span class="sourceLineNo">385</span>      if (transform != null &amp;&amp; o != null)<a name="line.385"></a>
+<span class="sourceLineNo">386</span>         o = transform.unswap(session, o, eType);<a name="line.386"></a>
+<span class="sourceLineNo">387</span><a name="line.387"></a>
+<span class="sourceLineNo">388</span>      if (outer != null)<a name="line.388"></a>
+<span class="sourceLineNo">389</span>         setParent(eType, o, outer);<a name="line.389"></a>
+<span class="sourceLineNo">390</span><a name="line.390"></a>
+<span class="sourceLineNo">391</span>      return (T)o;<a name="line.391"></a>
+<span class="sourceLineNo">392</span>   }<a name="line.392"></a>
+<span class="sourceLineNo">393</span><a name="line.393"></a>
+<span class="sourceLineNo">394</span>   private static boolean isSeq(RdfParserSession session, RDFNode n) {<a name="line.394"></a>
+<span class="sourceLineNo">395</span>      if (n.isResource()) {<a name="line.395"></a>
+<span class="sourceLineNo">396</span>         Statement st = n.asResource().getProperty(session.getRdfTypeProperty());<a name="line.396"></a>
+<span class="sourceLineNo">397</span>         if (st != null)<a name="line.397"></a>
+<span class="sourceLineNo">398</span>            return RDF_SEQ.equals(st.getResource().getURI());<a name="line.398"></a>
+<span class="sourceLineNo">399</span>      }<a name="line.399"></a>
+<span class="sourceLineNo">400</span>      return false;<a name="line.400"></a>
+<span class="sourceLineNo">401</span>   }<a name="line.401"></a>
+<span class="sourceLineNo">402</span><a name="line.402"></a>
+<span class="sourceLineNo">403</span>   private static boolean isBag(RdfParserSession session, RDFNode n) {<a name="line.403"></a>
+<span class="sourceLineNo">404</span>      if (n.isResource()) {<a name="line.404"></a>
+<span class="sourceLineNo">405</span>         Statement st = n.asResource().getProperty(session.getRdfTypeProperty());<a name="line.405"></a>
+<span class="sourceLineNo">406</span>         if (st != null)<a name="line.406"></a>
+<span class="sourceLineNo">407</span>            return RDF_BAG.equals(st.getResource().getURI());<a name="line.407"></a>
+<span class="sourceLineNo">408</span>      }<a name="line.408"></a>
+<span class="sourceLineNo">409</span>      return false;<a name="line.409"></a>
+<span class="sourceLineNo">410</span>   }<a name="line.410"></a>
+<span class="sourceLineNo">411</span><a name="line.411"></a>
+<span class="sourceLineNo">412</span>   private Object getValue(RdfParserSession session, RDFNode n, Object outer) throws Exception {<a name="line.412"></a>
+<span class="sourceLineNo">413</span>      if (n.isLiteral())<a name="line.413"></a>
+<span class="sourceLineNo">414</span>         return n.asLiteral().getValue();<a name="line.414"></a>
+<span class="sourceLineNo">415</span>      if (n.isResource()) {<a name="line.415"></a>
+<span class="sourceLineNo">416</span>         Statement st = n.asResource().getProperty(session.getValueProperty());<a name="line.416"></a>
+<span class="sourceLineNo">417</span>         if (st != null) {<a name="line.417"></a>
+<span class="sourceLineNo">418</span>            n = st.getObject();<a name="line.418"></a>
+<span class="sourceLineNo">419</span>            if (n.isLiteral())<a name="line.419"></a>
+<span class="sourceLineNo">420</span>               return n.asLiteral().getValue();<a name="line.420"></a>
+<span class="sourceLineNo">421</span>            return parseAnything(session, object(), st.getObject(), outer, null);<a name="line.421"></a>
+<span class="sourceLineNo">422</span>         }<a name="line.422"></a>
+<span class="sourceLineNo">423</span>      }<a name="line.423"></a>
+<span class="sourceLineNo">424</span>      throw new ParseException(session, "Unknown value type for node ''{0}''", n);<a name="line.424"></a>
+<span class="sourceLineNo">425</span>   }<a name="line.425"></a>
+<span class="sourceLineNo">426</span><a name="line.426"></a>
+<span class="sourceLineNo">427</span>   private &lt;K,V&gt; Map&lt;K,V&gt; parseIntoMap(RdfParserSession session, Resource r, Map&lt;K,V&gt; m, ClassMeta&lt;K&gt; keyType, ClassMeta&lt;V&gt; valueType, BeanPropertyMeta pMeta) throws Exception {<a name="line.427"></a>
+<span class="sourceLineNo">428</span>      // Add URI as "uri" to generic maps.<a name="line.428"></a>
+<span class="sourceLineNo">429</span>      if (r.getURI() != null) {<a name="line.429"></a>
+<span class="sourceLineNo">430</span>         K uri = convertAttrToType(session, m, "uri", keyType);<a name="line.430"></a>
+<span class="sourceLineNo">431</span>         V value = convertAttrToType(session, m, r.getURI(), valueType);<a name="line.431"></a>
+<span class="sourceLineNo">432</span>         m.put(uri, value);<a name="line.432"></a>
+<span class="sourceLineNo">433</span>      }<a name="line.433"></a>
+<span class="sourceLineNo">434</span>      for (StmtIterator i = r.listProperties(); i.hasNext();) {<a name="line.434"></a>
+<span class="sourceLineNo">435</span>         Statement st = i.next();<a name="line.435"></a>
+<span class="sourceLineNo">436</span>         Property p = st.getPredicate();<a name="line.436"></a>
+<span class="sourceLineNo">437</span>         String key = p.getLocalName();<a name="line.437"></a>
+<span class="sourceLineNo">438</span>         if (! (key.equals("root") &amp;&amp; p.getURI().equals(session.getJuneauNsUri()))) {<a name="line.438"></a>
+<span class="sourceLineNo">439</span>            key = session.decodeString(key);<a name="line.439"></a>
+<span class="sourceLineNo">440</span>            RDFNode o = st.getObject();<a name="line.440"></a>
+<span class="sourceLineNo">441</span>            K key2 = convertAttrToType(session, m, key, keyType);<a name="line.441"></a>
+<span class="sourceLineNo">442</span>            V value = parseAnything(session, valueType, o, m, pMeta);<a name="line.442"></a>
+<span class="sourceLineNo">443</span>            setName(valueType, value, key);<a name="line.443"></a>
+<span class="sourceLineNo">444</span>            m.put(key2, value);<a name="line.444"></a>
+<span class="sourceLineNo">445</span>         }<a name="line.445"></a>
+<span class="sourceLineNo">446</span><a name="line.446"></a>
+<span class="sourceLineNo">447</span>      }<a name="line.447"></a>
+<span class="sourceLineNo">448</span>      return m;<a name="line.448"></a>
+<span class="sourceLineNo">449</span>   }<a name="line.449"></a>
+<span class="sourceLineNo">450</span><a name="line.450"></a>
+<span class="sourceLineNo">451</span>   @SuppressWarnings("unchecked")<a name="line.451"></a>
+<span class="sourceLineNo">452</span>   private &lt;E&gt; Collection&lt;E&gt; parseIntoCollection(RdfParserSession session, Container c, Collection&lt;E&gt; l, ClassMeta&lt;?&gt; type, BeanPropertyMeta pMeta) throws Exception {<a name="line.452"></a>
+<span class="sourceLineNo">453</span>      int argIndex = 0;<a name="line.453"></a>
+<span class="sourceLineNo">454</span>      for (NodeIterator ni = c.iterator(); ni.hasNext();) {<a name="line.454"></a>
+<span class="sourceLineNo">455</span>         E e = (E)parseAnything(session, type.isArgs() ? type.getArg(argIndex++) : type.getElementType(), ni.next(), l, pMeta);<a name="line.455"></a>
+<span class="sourceLineNo">456</span>         l.add(e);<a name="line.456"></a>
+<span class="sourceLineNo">457</span>      }<a name="line.457"></a>
+<span class="sourceLineNo">458</span>      return l;<a name="line.458"></a>
+<span class="sourceLineNo">459</span>   }<a name="line.459"></a>
+<span class="sourceLineNo">460</span><a name="line.460"></a>
+<span class="sourceLineNo">461</span>   @SuppressWarnings("unchecked")<a name="line.461"></a>
+<span class="sourceLineNo">462</span>   private &lt;E&gt; Collection&lt;E&gt; parseIntoCollection(RdfParserSession session, RDFList list, Collection&lt;E&gt; l, ClassMeta&lt;?&gt; type, BeanPropertyMeta pMeta) throws Exception {<a name="line.462"></a>
+<span class="sourceLineNo">463</span>      int argIndex = 0;<a name="line.463"></a>
+<span class="sourceLineNo">464</span>      for (ExtendedIterator&lt;RDFNode&gt; ni = list.iterator(); ni.hasNext();) {<a name="line.464"></a>
+<span class="sourceLineNo">465</span>         E e = (E)parseAnything(session, type.isArgs() ? type.getArg(argIndex++) : type.getElementType(), ni.next(), l, pMeta);<a name="line.465"></a>
+<span class="sourceLineNo">466</span>         l.add(e);<a name="line.466"></a>
+<span class="sourceLineNo">467</span>      }<a name="line.467"></a>
+<span class="sourceLineNo">468</span>      return l;<a name="line.468"></a>
+<span class="sourceLineNo">469</span>   }<a name="line.469"></a>
+<span class="sourceLineNo">470</span><a name="line.470"></a>
+<span class="sourceLineNo">471</span>   <a name="line.471"></a>
+<span class="sourceLineNo">472</span>   //--------------------------------------------------------------------------------<a name="line.472"></a>
+<span class="sourceLineNo">473</span>   // Entry point methods<a name="line.473"></a>
+<span class="sourceLineNo">474</span>   //--------------------------------------------------------------------------------<a name="line.474"></a>
+<span class="sourceLineNo">475</span><a name="line.475"></a>
+<span class="sourceLineNo">476</span>   @Override /* Parser */<a name="line.476"></a>
+<span class="sourceLineNo">477</span>   public RdfParserSession createSession(Object input, ObjectMap op, Method javaMethod, Object outer, Locale locale, TimeZone timeZone, MediaType mediaType) {<a name="line.477"></a>
+<span class="sourceLineNo">478</span>      return new RdfParserSession(ctx, op, input, javaMethod, outer, locale, timeZone, mediaType);<a name="line.478"></a>
+<span class="sourceLineNo">479</span>   }<a name="line.479"></a>
+<span class="sourceLineNo">480</span>}<a name="line.480"></a>
 
 
 


Mime
View raw message