jsonld-java/jsonld-java — pull request #104 by stain (2014-03-19 12:16:37+00:00)
Title: Support JSON array in @context with toRDF

`JsonLdProcessor.toRDF` failed if `options.useNamespaces = true`
and the input has an @context which is an array rather than an object - the code tried to cast to Map.

Failing JSON-LD (as verified by included test `ArrayContextToRDFTest` and `src/test/resources/custom/array-context.jsonld`):

```
{
"@context": [
"http://nonexisting.example.com/context",
{ "ex2": "http://example.com/2/" }
],
"@id": "ex2:a",
"term2": "ex2:b"
}
```

This suggested fix is to reuse Context to recursively parse the contexts (including doing any imports) and remove the casting.

Additionally this fix ensures that only 'common' prefixes (e.g. where the URI end with / or #) are returned - thus not poluting the RDF namespaces with "term1", "term2" etc. -- if controversial this can be reversed in the call to `context.getPrefixes(true)` by changing to `false`.