Hi Joshua Thanks for the comments. I did not mean to mangle the code; I was trying to express the gist of my problem.
I will rework code, as you suggest in your first sentence. Thx for prompt response Mona Sent from my iPhone On Jan 27, 2014, at 3:36 PM, Joshua TAYLOR <[email protected]> wrote: > You can pass models as parameters to methods (just like any other Java > object). The code in this message looks like it may have been mangled > on its way to the list. It's certainly not in a compilable state at > the moment. E.g., lines like > > Product.addProperty(category_n, classDetails.get( ); > > don't even have balanced parentheses. It will be much easier to see > what the problem is if you can provide a minimal example that other > people can use to reproduce the error, and if you show what error > you're actually getting. E.g., when you say that "[you] tried > passing the model in a parameter list from Parser.java. It did not > work: `Annotator.printAnnotations(model).`", what do you mean that it > didn't work? Did you get a compilation error? Were you able to run > it, but it produced different results than what you'd been expected? > Or something else entirely? > > > > On Mon, Jan 27, 2014 at 6:10 PM, Mona Salem <[email protected]> wrote: >> Hi >> >> I am a newbie to Jena. >> >> I want to be able to add rdf statements to my model in two different .java >> classes; ie Parser.java and Annotator.java >> >> I did the following: >> >> public class Parser { >> >> >> >> public static Model model = ModelFactory.createDefaultModel(); >> >> >> >> >> >> Resource Product = model.createResource(ItemAddress); >> >> >> >> //create the properties >> >> Property category1 = model.createProperty("http: .); >> >> Property category2 = model.createProperty("http: .); >> >> Property category3 = model.createProperty("http: .); >> >> . >> >> . >> >> . >> >> Property category_n = model.createProperty("http: .); >> >> >> >> //add object >> >> Product.addProperty(category1, ); >> >> Product.addProperty(category2, ); >> >> . >> >> . >> >> . >> >> >> >> } >> >> >> >> I want to load values for category_n in a method of the second class: >> >> >> >> public class Annotator{ >> >> >> >> private static void printAnnotations(JsonNode annotations){ >> >> for (JsonNode annotation : annotations){ >> >> >> >> System.out.println(" something here"); >> >> >> >> Product.addProperty(category_n, classDetails.get( ); >> >> >> >> } >> >> } >> >> >> >> Note that the loop in the printAnnotations method will create multiple rdf >> statements with same pair resource/predicate and multiple objects. >> >> >> >> I tried passing the model in a parameter list from Parser.java. It did not >> work >> >> Annotator.printAnnotations(model). >> >> >> >> I thought making the model public would make this work. >> >> >> >> Should I use an array in Annotator to collect the values in the loop? >> >> >> >> Thanks for the help. >> >> Mona > > > > -- > Joshua Taylor, http://www.cs.rpi.edu/~tayloj/
