@Override public void writeValue(QuantityValue value, Resource resource) throws RDFHandlerException { this.rdfWriter.writeTripleValueObject( resource, RdfWriter.RDF_TYPE, RdfWriter.WB_QUANTITY_VALUE); this.rdfWriter.writeTripleLiteralObject( resource, RdfWriter.WB_NUMERIC_VALUE, value.getNumericValue().toString(), RdfWriter.XSD_DECIMAL); this.rdfWriter.writeTripleLiteralObject( resource, RdfWriter.WB_LOWER_BOUND, value.getLowerBound().toString(), RdfWriter.XSD_DECIMAL); this.rdfWriter.writeTripleLiteralObject( resource, RdfWriter.WB_UPPER_BOUND, value.getUpperBound().toString(), RdfWriter.XSD_DECIMAL); String unitIri; if ("".equals(value.getUnit())) { unitIri = Vocabulary.WB_NO_UNIT; } else { unitIri = value.getUnit(); } this.rdfWriter.writeTripleUriObject(resource, RdfWriter.WB_QUANTITY_UNIT, unitIri); }
/** * Returns a hash code for the given object. * * @see java.lang.Object#hashCode() * @param o the object to create a hash for * @return the hash code of the object */ public static int hashCode(QuantityValue o) { int result; result = o.getNumericValue().hashCode(); result = prime * result + o.getLowerBound().hashCode(); result = prime * result + o.getUpperBound().hashCode(); result = prime * result + o.getUnit().hashCode(); return result; }
@Override public Value getRdfValue(QuantityValue value, PropertyIdValue propertyIdValue, boolean simple) { String datatype = this.propertyRegister.setPropertyTypeFromQuantityValue(propertyIdValue, value); switch (datatype) { case DatatypeIdValue.DT_QUANTITY: if (simple) { this.rdfConversionBuffer.addDatatypeProperty(propertyIdValue); return this.rdfWriter.getLiteral( value.getNumericValue().toString(), RdfWriter.XSD_DECIMAL); } else { URI valueUri = this.rdfWriter.getUri( Vocabulary.getQuantityValueUri(value, this.propertyRegister.getUriPrefix())); this.rdfConversionBuffer.addObjectProperty(propertyIdValue); addValue(value, valueUri); return valueUri; } default: logIncompatibleValueError(propertyIdValue, datatype, "quantity"); return null; } }