if (emailResource.isResource()) { Statement valueStatement = getValueStatement(emailResource); String mailTo = valueStatement.getObject().toString(); Matcher matcher = MAIL_TO_PATTERN.matcher(mailTo); checkState(matcher.matches(), "%s mail to address doesn't match", mailTo); if (telephoneResource.isResource()) { Statement valueStatement = getValueStatement(telephoneResource); String telephoneNumber = valueStatement.getObject().toString(); Telephone telephoneObject = new Telephone(telephoneNumber); if (telephoneResource.hasProperty(RDF.type)) {
for (ExtendedIterator<? extends OntResource> it= iClass.listInstances(true);it.hasNext();) { Individual ins = (Individual) it.next(); RDFNode iValue = ins.getPropertyValue(iProperty); System.out.println(iValue.toString()); }
/** * Get either testCaseLogLevel or generate it from resultAnnotations **/ private static RLOGLevel findAnnotationLevel(RLOGLevel testCaseLogLevel, Collection<ResultAnnotation> givenAnnotations) { for (ResultAnnotation annotation : givenAnnotations) { if (annotation.getAnnotationProperty().equals(RLOG.level)) { return RLOGLevel.resolve(annotation.getAnnotationValue().get().toString()); } } // return default return testCaseLogLevel; }
public String getValueAsString() { if (value.isResource()) { // some vocabularies use spaces in uris return "<" + value.toString().trim().replace(" ", "") + ">"; } else { return value.asLiteral().getLexicalForm(); } }
private void printResult(StringBuilder results, String template, ShaclLiteTestCaseResult result) { String testcaseElement = String.format(template, result.getTestCaseUri().replace(PrefixNSService.getNSFromPrefix("rutt"), "rutt:"), result.getFailingNode().toString()); results.append(testcaseElement); if(result.getSeverity().equals(RLOGLevel.ERROR)|| result.getSeverity().equals(RLOGLevel.FATAL)) { results.append("\t\t<failure message=\"").append(result.getMessage()).append("\" type=\"").append(result.getSeverity().name()).append("\"/>\n"); } results.append("\t</testcase>\n"); }
/** * Answer the string value of the parameter if set, or null otherwise. Note command line * has precedence. * * @return String */ protected String getStringValue( List<String> cmdLineArgs, Resource confRoot ) { RDFNode n = getValue( cmdLineArgs, confRoot ); return (n == null) ? null : (n.isLiteral() ? n.asLiteral().getLexicalForm() : n.toString() ); }
/** * Answer the string value of the parameter if set, or null otherwise. Note command line * has precedence. * * @return String */ protected String getStringValue( List<String> cmdLineArgs, Resource confRoot ) { RDFNode n = getValue( cmdLineArgs, confRoot ); return (n == null) ? null : (n.isLiteral() ? n.asLiteral().getLexicalForm() : n.toString() ); }
private static String stringValue(RDFNode n) { if (n.isResource()) { return n.asResource().getURI(); } else if (n.isLiteral()) { return n.asLiteral().getValue().toString(); } return n.toString(); }
public static List<String> getResult(QueryExecutionFactory qef, Query query, Var targetVar) throws Exception{ try(QueryExecution qe = qef.createQueryExecution(query)) { ResultSet rs = qe.execSelect(); return StreamSupport.stream(((Iterable<QuerySolution>)() -> rs).spliterator(), false) .map(qs -> qs.get(targetVar.getName()).toString()) .collect(Collectors.toList()); } catch (Exception e) { throw new Exception("Failed to get result for query\n" + query, e); } }
@Override public boolean test( final Statement st ) { return (st.getSubject().toString().length() + st.getPredicate().toString().length() + st .getObject().toString().length()) == 15; /* * eh:/S + eh:/P * + eh:/O */ } };
@Override public boolean test( final Statement st ) { return (st.getSubject().toString().length() + st.getPredicate().toString().length() + st .getObject().toString().length()) == 15; /* * eh:/S + eh:/P * + eh:/O */ } };
@Test public final void thereIsOneFrench() { final StmtIterator it = TestListStatements.m.listStatements( TestListStatements.s, TestListStatements.p, null, "fr"); final List<Statement> lis = it.toList(); Assert.assertTrue(lis.size() == 1); Assert.assertTrue(lis.get(0).getObject().toString().equals("texte@fr")); }
@Test public final void theresOneTextEN() { final StmtIterator it = TestListStatements.m.listStatements( TestListStatements.s, TestListStatements.p, "text", "en"); final List<Statement> lis = it.toList(); Assert.assertTrue(lis.size() == 1); Assert.assertTrue(lis.get(0).getObject().toString().equals("text@en")); }
@Test public final void thereIsOneFrench() { final StmtIterator it = TestListStatements.m.listStatements( TestListStatements.s, TestListStatements.p, null, "fr"); final List<Statement> lis = it.toList(); Assert.assertTrue(lis.size() == 1); Assert.assertTrue(lis.get(0).getObject().toString().equals("texte@fr")); }
@Test public final void theresOneTextEN() { final StmtIterator it = TestListStatements.m.listStatements( TestListStatements.s, TestListStatements.p, "text", "en"); final List<Statement> lis = it.toList(); Assert.assertTrue(lis.size() == 1); Assert.assertTrue(lis.get(0).getObject().toString().equals("text@en")); }
private Statement lgg(Model model, Statement s1, Statement s2) { Resource s = s1.getSubject().equals(s2.getObject()) ? s1.getSubject() : model.createResource(AnonId.create(s1.getSubject().toString() + s2.getSubject().toString())); RDFNode o = s1.getObject().equals(s2.getObject()) ? s1.getObject() : model.createResource(AnonId.create(s1.getObject().toString() + s2.getObject().toString())); return model.createStatement(s, s1.getPredicate(), o); }
/** * Load the premises or conclusions for the test. */ public Model getDoc(Resource test, Property docType) throws IOException { Model result = ModelFactory.createDefaultModel(); StmtIterator si = test.listProperties(docType); while ( si.hasNext() ) { String fname = si.nextStatement().getObject().toString() + ".rdf"; loadFile(fname, result); } return result; }
/** * Load the premises or conclusions for the test. */ public Model getDoc(Resource test, Property docType) throws IOException { Model result = ModelFactory.createDefaultModel(); StmtIterator si = test.listProperties(docType); while ( si.hasNext() ) { String fname = si.nextStatement().getObject().toString() + ".rdf"; loadFile(fname, result); } return result; }