protected long ifLongPresent(QuerySolution solution, String variableName, long defaultValue) { Literal literal = solution.getLiteral(variableName); if (literal == null) { return defaultValue; } else { return literal.getLong(); } }
@Override protected void processQuerySolution(QuerySolution qs) { if (count == -1) { Literal literal = qs.getLiteral("count"); count = literal.getLong(); } } }
protected long ifLongPresent(QuerySolution solution, String variableName, long defaultValue) { Literal literal = solution.getLiteral(variableName); if (literal == null) { return defaultValue; } else { return literal.getLong(); } }
public long getLong() { return getLiteral().getLong(); }
/** * convenience method */ protected long getPropertyLongValue(OntResource res, Property dataprop) { if (dataprop != null) { try { return ((Literal)res.getPropertyValue(dataprop)).getLong(); } catch (Exception e) { return -1L; } } else { return -1L; } }
public long getLong() { return getLiteral().getLong(); }
/** * Return the long value of a literal node. Depending on the backend implementing this method, * the value can be retrieved directly or must be parsed from the string representation. The method can throw * a NumberFormatException or ArithmeticException indicating that the value cannot be represented as long, and an * IllegalArgumentException, indicating that the passed node is not a literal * * @param rdfNode the literal node for which to return the long value * @return long value of the literal node * @throws NumberFormatException in case the literal cannot be represented as long value * @throws ArithmeticException in case the literal cannot be represented as long value * @throws IllegalArgumentException in case the node passed as argument is not a literal */ @Override public Long longValue(RDFNode rdfNode) { if(isLiteral(rdfNode)) { return ((Literal)rdfNode).getLong(); } else { throw new IllegalArgumentException("the node "+rdfNode+" is not a literal value"); } }
@Override public long getLong() throws ReadDeniedException, AuthenticationRequiredException { checkRead(); return holder.getBaseItem().getLong(); }
/** * convenience method for use with functional datatype properties */ protected void updatePropertyLongValue(Resource res, Property dataprop, Long value, Model model) { if (dataprop != null) { Long existingValue = null; Statement stmt = res.getProperty(dataprop); if (stmt != null) { RDFNode object = stmt.getObject(); if (object != null && object.isLiteral()) { existingValue = ((Literal) object).getLong(); } } if (existingValue == null) { model.add(res, dataprop, value.toString(), XSDDatatype.XSDlong); } else if (existingValue.longValue() != value) { model.removeAll(res, dataprop, null); model.add(res, dataprop, value.toString(), XSDDatatype.XSDlong); } } }
@Override public AggregatedTestCaseResult read(final Resource resource) { checkNotNull(resource); StatusTestCaseResult test = StatusTestCaseResultReader.create().read(resource); Long resultCount = null; for (Statement smt : resource.listProperties(RDFUNITv.resultCount).toList()) { resultCount = smt.getObject().asLiteral().getLong(); } checkNotNull(resultCount); Long resultPrevalence = null; for (Statement smt : resource.listProperties(RDFUNITv.resultPrevalence).toList()) { resultPrevalence = smt.getObject().asLiteral().getLong(); } checkNotNull(resultPrevalence); return new AggregatedTestCaseResultImpl(resource, test.getTestCaseUri(), test.getSeverity(), test.getMessage(), test.getTimestamp(), test.getStatus(), resultCount, resultPrevalence); } }
@Override public AggregatedTestCaseResult read(final Resource resource) { checkNotNull(resource); StatusTestCaseResult test = StatusTestCaseResultReader.create().read(resource); Long resultCount = null; for (Statement smt : resource.listProperties(RDFUNITv.resultCount).toList()) { resultCount = smt.getObject().asLiteral().getLong(); } checkNotNull(resultCount); Long resultPrevalence = null; for (Statement smt : resource.listProperties(RDFUNITv.resultPrevalence).toList()) { resultPrevalence = smt.getObject().asLiteral().getLong(); } checkNotNull(resultPrevalence); return new AggregatedTestCaseResultImpl(resource, test.getTestCaseUri(), test.getSeverity(), test.getMessage(), test.getTimestamp(), test.getStatus(), resultCount, resultPrevalence); } }
protected void testByte( final Model model, final byte tv ) { final Literal l = model.createTypedLiteral(tv); Assert.assertEquals(tv, l.getByte()); Assert.assertEquals(tv, l.getShort()); Assert.assertEquals(tv, l.getInt()); Assert.assertEquals(tv, l.getLong()); }
protected void testByte( final Model model, final byte tv ) { final Literal l = model.createTypedLiteral(tv); Assert.assertEquals(tv, l.getByte()); Assert.assertEquals(tv, l.getShort()); Assert.assertEquals(tv, l.getInt()); Assert.assertEquals(tv, l.getLong()); }
protected void testShort( final Model model, final short tv ) { final Literal l = model.createTypedLiteral(tv); try { Assert.assertEquals(tv, l.getByte()); assertInRange(Byte.MIN_VALUE, tv, Byte.MAX_VALUE); } catch (final IllegalArgumentException e) { assertOutsideRange(Byte.MIN_VALUE, tv, Byte.MAX_VALUE); } Assert.assertEquals(tv, l.getShort()); Assert.assertEquals(tv, l.getInt()); Assert.assertEquals(tv, l.getLong()); }
protected void testShort( final Model model, final short tv ) { final Literal l = model.createTypedLiteral(tv); try { Assert.assertEquals(tv, l.getByte()); assertInRange(Byte.MIN_VALUE, tv, Byte.MAX_VALUE); } catch (final IllegalArgumentException e) { assertOutsideRange(Byte.MIN_VALUE, tv, Byte.MAX_VALUE); } Assert.assertEquals(tv, l.getShort()); Assert.assertEquals(tv, l.getInt()); Assert.assertEquals(tv, l.getLong()); }
protected void testInt( final Model model, final int tv ) { final Literal l = model.createTypedLiteral(tv); try { Assert.assertEquals(tv, l.getByte()); assertInRange(Byte.MIN_VALUE, tv, Byte.MAX_VALUE); } catch (final IllegalArgumentException e) { assertOutsideRange(Byte.MIN_VALUE, tv, Byte.MAX_VALUE); } try { Assert.assertEquals(tv, l.getShort()); assertInRange(Short.MIN_VALUE, tv, Short.MAX_VALUE); } catch (final IllegalArgumentException e) { assertOutsideRange(Short.MIN_VALUE, tv, Short.MAX_VALUE); } Assert.assertEquals(tv, l.getInt()); Assert.assertEquals(tv, l.getLong()); }
protected void testInt( final Model model, final int tv ) { final Literal l = model.createTypedLiteral(tv); try { Assert.assertEquals(tv, l.getByte()); assertInRange(Byte.MIN_VALUE, tv, Byte.MAX_VALUE); } catch (final IllegalArgumentException e) { assertOutsideRange(Byte.MIN_VALUE, tv, Byte.MAX_VALUE); } try { Assert.assertEquals(tv, l.getShort()); assertInRange(Short.MIN_VALUE, tv, Short.MAX_VALUE); } catch (final IllegalArgumentException e) { assertOutsideRange(Short.MIN_VALUE, tv, Short.MAX_VALUE); } Assert.assertEquals(tv, l.getInt()); Assert.assertEquals(tv, l.getLong()); }
Assert.assertEquals(tv, l.getLong());