Maybe Resource.inModel() is what you need?
https://jena.apache.org/documentation/javadoc/jena/org/apache/jena/rdf/model/Resource.html#inModel-org.apache.jena.rdf.model.Model-

On Tue, Mar 3, 2020 at 12:55 PM Martin G. Skjæveland
<[email protected]> wrote:
>
> Hi,
>
> ModelCom has the following createResource methods:
>
> Resource createResource()
> Create a new anonymous resource whose model is this model.
>
> Resource        createResource(AnonId id)
> Create a blank node resource with a specified identifier.
>
> Resource        createResource(Resource type)
> Create a new anonymous resource with a given type.
>
> Resource        createResource(String uri)
> Create a new resource associated with this model.
>
> Resource        createResource(String uri, Resource type)
> Create a new resource with a given type.
>
>
> I incorrectly used createResource(Resource) to create a resource in my
> model. No big deal this, but may I suggest to rename
>
> Resource        createResource(Resource type)
> Resource        createResource(String uri, Resource type)
>
> to createTypedResource to avoid confusion?
>
>
> The reason I use createResource(Resource) to create the Resource "in my"
> model is that I need to as(Property.class) cast it, which this gives me
> a UnsupportedPolymorphismException if the resource exists without a
> model. Now I use createResource(Resource.toURI())
>
> Martin
>

Reply via email to