简体   繁体   中英

Some Jena vocabs use 'ResourceFactory.createProperty()' while others use 'ModelFactory.createDefaultModel().createProperty()'

I'm new to Jena, but when I look at the vocabularies defined with the Jena source (ie in directory: jena-2.10.0-Source\\jena-core\\src\\main\\java\\com\\hp\\hpl\\jena\\vocabulary ) I see some of the vocabularies create properties and resources using 'ResourceFactory.createProperty()' (eg OWL2.java, RDF.java, RDFS.java), whereas others in the same directory use 'ModelFactory.createDefaultModel().createProperty()' (eg DC_11.java, VCARD.java, DCTerms.java).

I understand that ResourceFactory is used to create resources and properties without reference to a 'model' , but I just want to understand why some of these vocabs choose to create and use a 'model' instance while others choose not to.

Is it just personal style, or is one approach generally recommended over the other (maybe one style is an 'old approach', as I understand Jena has been around a long time)?

I'd like to use both the RDFS and DC_11 vocabs with my code, and obviously define my own app-specific resources and properties, so I'm just trying to understand which approach I should adopt for my own stuff.

That both styles are used is just historical accident. I think these days, I'd probably suggest using the ResourceFactory approach, simply because it avoids the (small) overhead of allocating a model, and the model gives you no real advantages. At some point, we'll probably go back and do some refactoring to just use a single approach in the Jena codebase.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM