/** * Gets the long value of the supplied literal. The fallback value is returned in case * {@link Literal#longValue()} throws a {@link NumberFormatException}. * * @param l * The literal to get the long value for. * @param fallback * The value to fall back to in case no long value could gotten from the literal. * @return Either the literal's long value, or the fallback value. */ public static long getLongValue(Literal l, long fallback) { try { return l.longValue(); } catch (NumberFormatException e) { return fallback; } }
/** * Gets the long value of the supplied literal. The fallback value is returned in case * {@link Literal#longValue()} throws a {@link NumberFormatException}. * * @param l * The literal to get the long value for. * @param fallback * The value to fall back to in case no long value could gotten from the literal. * @return Either the literal's long value, or the fallback value. */ public static long getLongValue(Literal l, long fallback) { try { return l.longValue(); } catch (NumberFormatException e) { return fallback; } }
@Override boolean checkTuple(Tuple t) { Literal literal = (Literal) t.line.get(1); return literal.longValue() <= maxCount; }
@Override boolean checkTuple(Tuple t) { Literal literal = (Literal) t.line.get(1); return literal.longValue() <= maxCount; }
@Override boolean checkTuple(Tuple t) { Literal literal = (Literal) t.line.get(1); return literal.longValue() >= minCount; }
@Override boolean checkTuple(Tuple t) { Literal literal = (Literal) t.line.get(1); return literal.longValue() >= minCount; }
private long literalToLong(Value v) { if (!(v instanceof Literal)) { throw new IllegalArgumentException( "value [" + v + "] was not a literal, which is expected " + "for a parameter of type long or Long." ); } Literal literal = (Literal) v; return literal.longValue(); }
private static long longValueOfTimeStamp(Literal ts) { if (XMLDatatypeUtil.isCalendarDatatype(ts.getDatatype())) { return ts.calendarValue().toGregorianCalendar().getTimeInMillis(); } return ts.longValue(); }
private long getTriplesCount(IRI subjectNode, long defaultValue) { try (CloseableIteration<? extends Statement, SailException> ci = statsConnection.getStatements(subjectNode, VOID.TRIPLES, null, true, HALYARD.STATS_GRAPH_CONTEXT)) { if (ci.hasNext()) { Value v = ci.next().getObject(); if (v instanceof Literal) { try { long l = ((Literal) v).longValue(); LOG.log(Level.FINER, "triple stats for {0} = {1}", new Object[]{subjectNode, l}); return l; } catch (NumberFormatException ignore) { } } LOG.log(Level.WARNING, "Invalid statistics for:{0}", subjectNode); } } LOG.log(Level.FINER, "triple stats for {0} are not available", subjectNode); return defaultValue; }
/** * Exports BindingSets to Kafka. The BindingSet and topic are extracted from * the indicated BindingSetRecord and the BindingSet is then exported to the topic. */ @Override public void exportNotification(final BindingSetRecord record) throws BindingSetRecordExportException { try { log.info("Exporting {} records to Kafka to topic: {}", record.getBindingSet().size(), record.getTopic()); final String bindingName = IncrementalUpdateConstants.PERIODIC_BIN_ID; final BindingSet bindingSet = record.getBindingSet(); final String topic = record.getTopic(); final long binId = ((Literal) bindingSet.getValue(bindingName)).longValue(); final Future<RecordMetadata> future = producer .send(new ProducerRecord<String, BindingSet>(topic, Long.toString(binId), bindingSet)); //wait for confirmation that results have been received future.get(5, TimeUnit.SECONDS); } catch (final Exception e) { // catch all possible exceptional behavior and throw as our checked exception. throw new BindingSetRecordExportException(e.getMessage(), e); } }
public void parse(Model m, Resource implNode) throws SailConfigException { try { Models.objectLiteral(m.filter(implNode, SAILTYPE, null)).ifPresent( lit -> setType(lit.getLabel())); Models.objectLiteral( m.filter(implNode, SailConfigSchema.ITERATION_CACHE_SYNC_THRESHOLD, null)).ifPresent( lit -> setIterationCacheSyncThreshold(lit.longValue())); Models.objectLiteral( m.filter(implNode, SailConfigSchema.CONNECTION_TIME_OUT, null)).ifPresent( lit -> setConnectionTimeOut(lit.longValue())); } catch (ModelException e) { throw new SailConfigException(e.getMessage(), e); } }
public void parse(Model m, Resource implNode) throws SailConfigException { try { Models.objectLiteral(m.filter(implNode, SAILTYPE, null)).ifPresent( lit -> setType(lit.getLabel())); Models.objectLiteral( m.filter(implNode, SailConfigSchema.ITERATION_CACHE_SYNC_THRESHOLD, null)).ifPresent( lit -> setIterationCacheSyncThreshold(lit.longValue())); Models.objectLiteral( m.filter(implNode, SailConfigSchema.CONNECTION_TIME_OUT, null)).ifPresent( lit -> setConnectionTimeOut(lit.longValue())); } catch (ModelException e) { throw new SailConfigException(e.getMessage(), e); } }
private Object getObjectValue(Literal object) { IRI datatype = object.getDatatype(); if (datatype.equals(XMLSchema.INT) || datatype.equals(XMLSchema.INTEGER) || datatype.equals(XMLSchema.LONG)){ return object.longValue(); } else if (datatype.equals(XMLSchema.DECIMAL) || datatype.equals(XMLSchema.DOUBLE) || datatype.equals(XMLSchema.FLOAT)) { return object.doubleValue(); } else if (datatype.equals(XMLSchema.BOOLEAN)) { return object.booleanValue(); } else { // it's a string, and it can be tagged with language info. // if a language filter has been defined we apply it here final Optional<String> language = object.getLanguage(); if(langFilter == null || !language.isPresent() || (language.isPresent() && langFilter.equals(language.get()))){ return object.stringValue(); } return null; //string is filtered } }
private Object getObjectValue(Literal object) { IRI datatype = object.getDatatype(); if (datatype.equals(XMLSchema.INT) || datatype.equals(XMLSchema.INTEGER) || datatype.equals(XMLSchema.LONG)){ return object.longValue(); } else if (datatype.equals(XMLSchema.DECIMAL) || datatype.equals(XMLSchema.DOUBLE) || datatype.equals(XMLSchema.FLOAT)) { return object.doubleValue(); } else if (datatype.equals(XMLSchema.BOOLEAN)) { return object.booleanValue(); } else { // it's a string, and it can be tagged with language info. // if a language filter has been defined we apply it here final Optional<String> language = object.getLanguage(); if(langFilter == null || !language.isPresent() || (language.isPresent() && langFilter.equals(language.get()))){ return object.stringValue(); } return null; //string is filtered } }
booleanValue = literal.longValue() != 0L;
@Override protected Value evaluate(ValueFactory valueFactory, Value arg1, Value arg2) throws ValueExprEvaluationException { if (!(arg1 instanceof Literal) || !(arg2 instanceof Literal)) { throw new ValueExprEvaluationException("Both arguments must be literals"); } Literal number = (Literal)arg1; Literal format = (Literal)arg2; java.text.DecimalFormat formatter = new java.text.DecimalFormat(format.getLabel()); String value; if (XMLSchema.INT.equals(number.getDatatype()) || XMLSchema.LONG.equals(number.getDatatype()) || XMLSchema.SHORT.equals(number.getDatatype()) || XMLSchema.BYTE.equals(number.getDatatype())) { value = formatter.format(number.longValue()); } else if (XMLSchema.DECIMAL.equals(number.getDatatype())) { value = formatter.format(number.decimalValue()); } else if (XMLSchema.INTEGER.equals(number.getDatatype())) { value = formatter.format(number.integerValue()); } else { value = formatter.format(number.doubleValue()); } return valueFactory.createLiteral(value); } }
setSyncDelay((syncDelayValue).longValue());
setSyncDelay((syncDelayValue).longValue());
size += ((Literal)scanner.next().getObject()).longValue(); try (CloseableIteration<? extends Statement, SailException> scanner = getStatements(HALYARD.STATS_ROOT_NODE, VOID.TRIPLES, null, true, HALYARD.STATS_GRAPH_CONTEXT)) { if (scanner.hasNext()) { size += ((Literal)scanner.next().getObject()).longValue();