Skip to content

Commit

Permalink
Added methods to add typed literals, and string in a specific language
Browse files Browse the repository at this point in the history
  • Loading branch information
egonw committed Oct 24, 2012
1 parent ee4c4d4 commit bf0c24e
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
Expand Up @@ -170,6 +170,30 @@ public void addDataProperty(IRDFStore store,
String subject, String predicate, String value)
throws BioclipseException;

@Recorded
@PublishedMethod(
params = "IRDFStore store, String subject, String predicate, " +
"String value, String dataType",
methodSummary = "Adds a triple to the given store"
)
@TestMethods("testAddTypedDataProperty")
public void addTypedDataProperty(IRDFStore store,
String subject, String predicate, String value,
String dataType)
throws BioclipseException;

@Recorded
@PublishedMethod(
params = "IRDFStore store, String subject, String predicate, " +
"String value, Locale language",
methodSummary = "Adds a triple to the given store"
)
@TestMethods("testAddPropertyInLanguage")
public void addPropertyInLanguage(IRDFStore store,
String subject, String predicate, String value,
String language)
throws BioclipseException;

@Recorded
@PublishedMethod(
params = "IRDFStore store",
Expand Down
Expand Up @@ -236,6 +236,34 @@ public void addDataProperty(IRDFStore store, String subject,
model.add(subjectRes, propertyRes, value);
}

public void addTypedDataProperty(IRDFStore store,
String subject, String property, String value,
String dataType)
throws BioclipseException {
if (!(store instanceof IJenaStore))
throw new RuntimeException(
"Can only handle IJenaStore's for now."
);
Model model = ((IJenaStore)store).getModel();
Resource subjectRes = model.createResource(subject);
Property propertyRes = model.createProperty(property);
model.add(subjectRes, propertyRes, model.createTypedLiteral(value, dataType));
}

public void addPropertyInLanguage(IRDFStore store,
String subject, String property, String value,
String language)
throws BioclipseException {
if (!(store instanceof IJenaStore))
throw new RuntimeException(
"Can only handle IJenaStore's for now."
);
Model model = ((IJenaStore)store).getModel();
Resource subjectRes = model.createResource(subject);
Property propertyRes = model.createProperty(property);
model.add(subjectRes, propertyRes, value, language);
}

public long size(IRDFStore store) throws BioclipseException {
if (!(store instanceof IJenaStore))
throw new RuntimeException(
Expand Down

0 comments on commit bf0c24e

Please sign in to comment.