/** Returns the date/time object derived from the literal l. As a sop to literals of type xsd_Date which have an associated Time, if getting the value throws a datatype format exception, try again on a literal with the same lexical form but type xsd_dateTime. */ private static Object getTemporalValue(Literal l) { try { return l.getValue(); } catch (DatatypeFormatException e) { Literal lit = ResourceFactory.createTypedLiteral(l.getLexicalForm(), XSDDatatype.XSDdateTime ); return lit.getValue(); } }
@Override public RDFNode getNewTargetNode(Statement originalStatement, JComponent component) { JSpinner spinner = (JSpinner) component; Date d = (Date) spinner.getValue(); if ((originalStatement == null) || !originalStatement.getObject().asLiteral().getValue() .equals(d)) { Calendar cal = GregorianCalendar.getInstance(); cal.setTime(d); return createTypedLiteral(cal); } return null; }
@Override public RDFNode getNewTargetNode(Statement originalStatement, JComponent component) { JSpinner spinner = (JSpinner) component; Date d = (Date) spinner.getValue(); if ((originalStatement == null) || !originalStatement.getObject().asLiteral().getValue() .equals(d)) { Calendar cal = GregorianCalendar.getInstance(); cal.setTime(d); return createTypedLiteral(cal); } return null; }
private Date getDate(Individual individual, Property property) { Statement stmt = individual.getProperty(property); if (stmt != null) { Object obj = stmt.getObject(); if (obj instanceof Literal) { Literal lit = (Literal) obj; XSDDateTime d = (XSDDateTime) lit.getValue(); return d.asCalendar().getTime(); } } return null; } }
private Object getAxiom(Individual axiomIndiv) { RDFNode value = axiomIndiv.getPropertyValue(RDF.value); if (value != null && value.isLiteral()) { return value.asLiteral().getValue(); } return null; }
/** * converts a {@link Node} into an {l@ink Expr} * @param n * @return */ protected Expr toExpr(Node n) { if (n.isVariable()) { return new VariableExpr(n.getName()); } else if (n.isURI()) { try { return new ConstantExpr(new URI(n.getURI())); } catch (URISyntaxException e) { throw new RuntimeException(e); } } else if (n.isLiteral()) { Literal l = (Literal) n; return new ConstantExpr(l.getValue()); } else { throw new RuntimeException("Unsuported node type in query : "+n); } } /**
/** Set a parameter from a statement, given the property and its RDFNode value. Most parameters are, historically, set from the string value of the RDFNode, but newer parameters may have Resource values with embedded models, for which their toString() is not just suspect, but definitively wrong. Hence the introduction of this relay station. @param parameter the propoerty naming the value to set @param value the RDFNode with the value of that property @return true if the property was understood, false otherwise */ protected boolean doSetRDFNodeParameter( Property parameter, RDFNode value ) { return (value instanceof Resource && doSetResourceParameter( parameter, (Resource) value )) || (value instanceof Literal && doSetParameter( parameter, ((Literal)value).getValue() )) || doSetParameter(parameter, value.toString()) ; }
private void importLiteral(VertexBuilder v, Statement statement, File baseDir, GraphPropertyWorkData data, VisibilityJson visibilityJson, Visibility visibility, User user) { String propertyName = statement.getPredicate().toString(); RDFDatatype datatype = statement.getLiteral().getDatatype(); Object literalValue = statement.getLiteral().getValue(); Object value = literalValue; if (datatype == null || XSDDatatype.XSDstring.equals(datatype)) { String valueString = statement.getLiteral().toString(); if (valueString.startsWith("streamingValue:")) { value = convertStreamingValueJsonToValueObject(baseDir, valueString); } } else if (literalValue instanceof XSDDateTime) { XSDDateTime xsdDateTime = (XSDDateTime) literalValue; value = xsdDateTime.asCalendar().getTime(); } else { value = literalValue; } Metadata metadata = new Metadata(); if (data != null) { metadata = data.createPropertyMetadata(user); } else { VisalloProperties.VISIBILITY_JSON_METADATA.setMetadata(metadata, visibilityJson, visibility); VisalloProperties.MODIFIED_BY_METADATA.setMetadata(metadata, user.getUserId(), visibility); VisalloProperties.MODIFIED_DATE_METADATA.setMetadata(metadata, new Date(), visibility); } v.addPropertyValue(MULTI_VALUE_KEY, propertyName, value, metadata, visibility); }
private Object getValue(RDFNode n, Object outer) throws Exception { if (n.isLiteral()) return n.asLiteral().getValue(); if (n.isResource()) { Statement st = n.asResource().getProperty(pValue); if (st != null) { n = st.getObject(); if (n.isLiteral()) return n.asLiteral().getValue(); return parseAnything(object(), st.getObject(), outer, null); } } throw new ParseException(this, "Unknown value type for node ''{0}''", n); }
s.setEditor(de); if (statement != null) { Object o = statement.getObject().asLiteral().getValue(); if (o instanceof XSDDateTime) dateModel.setValue(((XSDDateTime) o).asCalendar().getTime());
s.setEditor(de); if (statement != null) { Object o = statement.getObject().asLiteral().getValue(); if (o instanceof XSDDateTime) dateModel.setValue(((XSDDateTime) o).asCalendar().getTime());
encodeString( jw, spelling, lang ); } else if (dt.equals( XSDDatatype.XSDboolean)) { jw.value( (boolean) ((Boolean) lit.getValue()) ); } else if (isFloatLike(dt)) { jw.value( Double.parseDouble( spelling ) );
date = toDateFormat(qualityMD.listObjectsOfProperty(res, qualityMD.createProperty("http://purl.org/linked-data/sdmx/2009/dimension#timePeriod")).next().asLiteral().getValue().toString()); } catch (ParseException e) {
date = toDateFormat(qualityMD.listObjectsOfProperty(res, qualityMD.createProperty("http://purl.org/linked-data/sdmx/2009/dimension#timePeriod")).next().asLiteral().getValue().toString()); } catch (ParseException e) {
private static Term createTerm(RDFNode node) { Term term = null; if (node.isLiteral()) { Literal l = node.asLiteral(); term = DefaultTermFactory.instance().createLiteral(URIUtils.createURI(l.getDatatypeURI()), l.getValue()); } else { term = DefaultTermFactory.instance().createConstant(URIzer.instance().output(node.toString())); } return term; }
date = toDateFormat(qualityMD.listObjectsOfProperty(res, DC.date).next().asLiteral().getValue().toString()); } catch (ParseException e) {
QuerySolution soln = results.nextSolution(); Literal syntacticType = soln.getLiteral("syntacticType"); String syntacticTypeValue = syntacticType.getValue().toString(); System.out.println(syntacticTypeValue); assertTrue(syntacticTypeValue
assertEquals( "Output port 'output' not populated by service instance", cause.getValue().toString()); } finally { qexec.close();
Literal cause = soln.getLiteral("cause"); assertEquals("Test matches, aborting downstream processors", cause .getValue().toString()); } finally { qexec.close();