public static boolean isString(Literal literal) { RDFDatatype dtype = literal.getDatatype() ; if ( dtype == null ) return true ; if ( dtype.equals(XSDDatatype.XSDstring) ) return true ; return false ; }
String lang = l.getLanguage(); String spelling = l.getLexicalForm(); RDFDatatype dt = l.getDatatype();
/** * Compares two instances of values of the given datatype. */ public Boolean isEqual(Literal value1, Literal value2) { return value1.getDatatype() == value2.getDatatype() && value1.getValue().equals(value2.getValue()); }
/** * @return True if this node is a literal, and has an XML literal as its value */ public boolean isXmlLiteral() { if (isLiteral()) { RDFDatatype typ = asLiteral().getDatatype(); return (typ != null) && XMLLiteralType.theXMLLiteralType.equals( typ ); } else { return false; } }
/** Answer the String value of the literal <code>L</code>, which is the object of the Statement <code>s</code>. If the literal is not an XSD String or a plain string without a language code, throw a BadObjectException. */ public static String getString( Statement s, Literal L ) { if (!L.getLanguage().equals( "" )) throw new BadObjectException( s ); if (L.getDatatype() == null) return L.getLexicalForm(); if (L.getDatatype() == XSDDatatype.XSDstring) return L.getLexicalForm(); throw new BadObjectException( s ); }
/** Answer the plain string object of the statement <code>s</code>. If the object is not a string literal, throw a BadObjectException with that statement. */ public static String getString( Statement s ) { RDFNode ob = s.getObject(); if (ob.isResource()) throw new BadObjectException( s ); Literal L = (Literal) ob; if (!L.getLanguage().equals( "" )) throw new BadObjectException( s ); if (L.getDatatype() == null) return L.getLexicalForm(); if (L.getDatatype() == XSDDatatype.XSDstring) return L.getLexicalForm(); throw new BadObjectException( s ); }
/** * Convert an xsd:datetype or xsd:date to a javascript compatible string. * Returns null if not a supported type */ public static String formatDateTime(Literal l, boolean jsonUsesISOdate ) { Object val = getTemporalValue(l); if (val instanceof XSDDateTime) { boolean isDate = l.getDatatype().equals(XSDDatatype.XSDdate); Date date = ((XSDDateTime)val).asCalendar().getTime(); if(jsonUsesISOdate) { return dateFormatISO(hasTimeZone(l.getLexicalForm()), isDate).format(date); } else { return dateFormat(hasTimeZone(l.getLexicalForm()), isDate).format(date); } } else { return null; } }
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); }
RDFDatatype dt = lit.getDatatype();
try { Class<?> literalJavaClass = node.asLiteral() .getDatatype() .getJavaClass(); String literalJavaClassName = node.asLiteral() .getDatatype() .getJavaClass().getName();
private String convertRSToString (QuerySolution soln, String colName) { if (soln.getLiteral(colName).getDatatype() == null) { return soln.getLiteral(colName).getString(); } else { String colType = soln.getLiteral(colName).getDatatype().getURI(); if (colType.equals(XSDDatatype.XSDdecimal.getURI())) { return ConverterUtil.convertToString(ConverterUtil.convertToDecimal(soln
private String convertRSToString (QuerySolution soln, String colName) { if (soln.getLiteral(colName).getDatatype() == null) { return soln.getLiteral(colName).getString(); } else { String colType = soln.getLiteral(colName).getDatatype().getURI(); if (colType.equals(XSDDatatype.XSDdecimal.getURI())) { return ConverterUtil.convertToString(ConverterUtil.convertToDecimal(soln
if (object.isLiteral()) { Literal obj = object.asLiteral(); objNode = NodeFactory.createLiteral(obj.getString(), obj.getDatatype()); } else { objNode = NodeFactory.createLiteral(object.toString());