private static Statement getValueStatement(Resource r) { Statement valueStatement = r.getProperty(VCARD4.hasValue); if (valueStatement == null) { valueStatement = r.getProperty(VCARD4.value); } if (valueStatement == null) { throw new IllegalStateException("Couldn't find value property in: " + r); } return valueStatement; } }
private List<VCard> parseAddressBook(Resource selfResource, SolidUtilities utilities) throws IOException { String peopleUri = selfResource.getProperty(NAME_EMAIL_INDEX_PROPERTY).getResource().getURI(); Model peopleModel = utilities.getModel(peopleUri); List<VCard> vcards = new ArrayList<>(); ResIterator subjects = peopleModel.listSubjects(); while (subjects.hasNext()) { Resource subject = subjects.nextResource(); Model personModel = utilities.getModel(subject.getURI()); Resource personResource = SolidUtilities.getResource(subject.getURI(), personModel); if (personResource == null) { throw new IllegalStateException(subject.getURI() + " not found in " + subject.toString()); } vcards.add(parsePerson(personResource)); } return vcards; }
vcard.setFormattedName(r.getProperty(VCARD4.fn).getString()); StructuredName structuredName = new StructuredName(); if (structuredNameResource.hasProperty(VCARD4.family_name)) { structuredName.setFamily(structuredNameResource.getProperty(VCARD4.family_name).getString()); structuredName.setGiven(structuredNameResource.getProperty(VCARD4.given_name).getString()); vcard.setOrganization(r.getProperty(VCARD4.organization_name).getString()); vcard.addNote(r.getProperty(VCARD4.note).getString());
private boolean _getTextIndex() { Statement s = testResource.getProperty(TestManifestX.textIndex) ; if ( s == null ) return false ; return s.getString().equalsIgnoreCase("true") ; }
public static String getStringValue(Resource r, Property p) { if ( !atmostOneProperty(r, p) ) throw new NotUniqueException(r, p) ; Statement s = r.getProperty(p) ; if ( s == null ) return null ; return s.getString() ; }
private Analyzer analyzerWithStopWords(Resource root) { RDFNode node = root.getProperty(TextVocab.pStopWords).getObject(); if (! node.isResource()) { throw new TextIndexException("text:stopWords property takes a list as a value : " + node); } CharArraySet stopWords = toCharArraySet((Resource) node); return new StandardAnalyzer(stopWords); }
private Resource _getAction() { if ( actionResource == null ) actionResource = testResource.getProperty(TestManifest.action).getResource() ; return actionResource ; }
@Override public Object open(Assembler a, Resource root, Mode mode) { if (root.hasProperty(TextVocab.pUseAnalyzer)) { Statement useStmt = root.getProperty(TextVocab.pUseAnalyzer); Resource key = useStmt.getResource(); return Util.getDefinedAnalyzer(key); } return null; }
public static String getAsStringValue(Resource r, Property p) { if ( !atmostOneProperty(r, p) ) throw new NotUniqueException(r, p) ; Statement s = r.getProperty(p) ; if ( s == null ) return null ; if ( s.getObject().isResource() ) return s.getResource().getURI() ; return s.getString() ; }
public static Resource getResource(Resource r, Property p) { if ( r == null ) return null ; if ( ! r.hasProperty(p) ) return null ; RDFNode n = r.getProperty(p).getObject() ; if ( n instanceof Resource ) return (Resource)n ; throw new TestException("Manifest problem (not a Resource): "+n+" => "+p) ; }
public void testAddTypedPropertyObject() { final Object z = new Object(); final Resource r = model.createResource(); r.addLiteral(RDF.value, z); Assert.assertEquals(model.createTypedLiteral(z), r.getProperty(RDF.value).getLiteral()); }
public void testAddTypedPropertyObject() { final Object z = new Object(); final Resource r = model.createResource(); r.addLiteral(RDF.value, z); Assert.assertEquals(model.createTypedLiteral(z), r.getProperty(RDF.value).getLiteral()); }
public static String getLiteral(Resource r, Property p) { if ( r == null ) return null ; if ( ! r.hasProperty(p) ) return null ; RDFNode n = r.getProperty(p).getObject() ; if ( n instanceof Literal ) return ((Literal)n).getLexicalForm() ; throw new TestException("Manifest problem (not a Literal): "+n+" => "+p) ; }
public static String getLiteral(Resource r, Property p) { if (r == null) return null; if (!r.hasProperty(p)) return null; RDFNode n = r.getProperty(p).getObject(); if (n instanceof Literal) return ((Literal) n).getLexicalForm(); throw new ManifestException("Manifest problem (not a Literal): " + n + " => " + p); }
public static String getLiteral(Resource r, Property p) { if (r == null) return null; if (!r.hasProperty(p)) return null; RDFNode n = r.getProperty(p).getObject(); if (n instanceof Literal) return ((Literal) n).getLexicalForm(); throw new ManifestException("Manifest problem (not a Literal): " + n + " => " + p); }
public void testAddTypedPropertyFloat() { final Resource r = model.createResource(); r.addLiteral(RDF.value, 1.0f); Assert.assertEquals(model.createTypedLiteral(1.0f), r.getProperty(RDF.value).getLiteral()); }
public void testAddTypedPropertyBoolean() { final Resource r = model.createResource(); r.addLiteral(RDF.value, true); Assert.assertEquals(model.createTypedLiteral(true), r.getProperty(RDF.value).getLiteral()); }
public void testAddTypedPropertyChar() { final Resource r = model.createResource(); r.addLiteral(RDF.value, 'x'); Assert.assertEquals(model.createTypedLiteral('x'), r.getProperty(RDF.value).getLiteral()); }
public void testAddTypedPropertyDouble() { final Resource r = model.createResource(); r.addLiteral(RDF.value, 1.0d); Assert.assertEquals(model.createTypedLiteral(1.0d), r.getProperty(RDF.value).getLiteral()); }
public void testAddTypedPropertyDouble() { final Resource r = model.createResource(); r.addLiteral(RDF.value, 1.0d); Assert.assertEquals(model.createTypedLiteral(1.0d), r.getProperty(RDF.value).getLiteral()); }