private static boolean isBlank(Value value) { if (value instanceof IRI) { return value.stringValue().indexOf("/.well-known/genid/") > 0; } else { return value instanceof BNode; } }
private static boolean isBlank(Value value) { if (value instanceof IRI) { return value.stringValue().indexOf("/.well-known/genid/") > 0; } else { return value instanceof BNode; } }
/******************************************************************************************************************* * ******************************************************************************************************************/ @Nonnull protected static Optional<Long> toLong (final @Nullable Binding binding) { return Optional.ofNullable(binding).map(b -> b.getValue()).map(v -> Long.parseLong(v.stringValue())); }
/******************************************************************************************************************* * ******************************************************************************************************************/ @Nonnull protected static Optional<String> toString (final @Nullable Binding binding) { return Optional.ofNullable(binding).map(b -> b.getValue()).map(v -> v.stringValue()); }
/******************************************************************************************************************* * ******************************************************************************************************************/ @Nonnull protected static Optional<Integer> toInteger (final @Nullable Binding binding) { return Optional.ofNullable(binding).map(b -> b.getValue()).map(v -> Integer.parseInt(v.stringValue())); }
private boolean hasObject(Statement statement, String voc) { return statement .getObject() .stringValue() .equals(voc); }
public static Value getStorableValue(Value v, AGValueFactory vf, boolean allowExternalBlankNodeIds) { Value storable = v; if (v instanceof BNode && !vf.isAGBlankNodeId(v.stringValue())) { if (allowExternalBlankNodeIds) { storable = vf.createIRI(vf.PREFIX_FOR_EXTERNAL_BNODES + v.stringValue()); } else { throw new IllegalArgumentException("Cannot store external blank node " + v + " in AllegroGraph with the current settings. Please see javadoc for AGHttpRepoClient#setAllowExternalBlankNodeIds(boolean) for more details and options."); } } return storable; }
public void receiveTriple(Resource s, IRI p, Value o, IRI g, ExtractionContext context) throws TripleHandlerException { if(!this.resources.contains(s)) { this.resources.add(s); this.printStream.println(s.stringValue()); } if(o instanceof Resource && !this.resources.contains(o)) { this.resources.add((Resource) o); this.printStream.println(o.stringValue()); } }
/******************************************************************************************************************* * ******************************************************************************************************************/ @Nonnull protected static Optional<Duration> toDuration (final @Nullable Binding binding) { return Optional.ofNullable(binding).map(b -> b.getValue()).map(v -> Duration.ofMillis((int)Float.parseFloat(v.stringValue()))); }
/** * {@inheritDoc} */ @Override public UUID readValue(final Model theGraph, final Value theObj) { Preconditions.checkArgument(theObj instanceof Resource); final Optional<Value> aObject = Models2.getObject(theGraph, (Resource) theObj, PROPERTY); if (aObject.isPresent()) { return UUID.fromString(aObject.get().stringValue()); } return null; } }
/******************************************************************************************************************* * ******************************************************************************************************************/ @Nonnull protected static Optional<Id> toId (final @Nullable Binding binding) { return Optional.ofNullable(binding).map(b -> b.getValue()).map(v -> v.stringValue()).map(s -> new Id(s)); }
@Override @Nonnull public String apply (final @Nonnull Repository repository, final @Nonnull BindingSet bindingSet) { return bindingSet.iterator().next().getValue().stringValue(); } }
/** * Retrieves all object String values from the statements in the given model. * * @param m * the model from which to retrieve all object String values. * @return a {@link Set} containing object String values from the given model, which will be empty if no * such value exists. * @see Model#objects() */ public static Set<String> objectStrings(Model m) { return m.stream().map(st -> st.getObject().stringValue()).collect(Collectors.toSet()); }
/** * Retrieves all object String values from the statements in the given model. * * @param m * the model from which to retrieve all object String values. * @return a {@link Set} containing object String values from the given model, which will be empty if no * such value exists. * @see Model#objects() */ public static Set<String> objectStrings(Model m) { return m.stream().map(st -> st.getObject().stringValue()).collect(Collectors.toSet()); }
/** * Retrieves an object value as a String from the statements in the given model. If more than one possible * object value exists, any one value is picked and returned. * * @param m * the model from which to retrieve an object String value. * @return an {@link Optional} object String value from the given model, which will be * {@link Optional#empty() empty} if no such value exists. */ public static Optional<String> objectString(Model m) { return m.stream().map(st -> st.getObject().stringValue()).findAny(); }
@Override public void processAggregate(BindingSet s) throws QueryEvaluationException { Value v = evaluate(s); if (v != null && distinctValue(v)) { concatenated.append(v.stringValue()); concatenated.append(separator); } }
/** * Retrieves an object value as a String from the statements in the given model. If more than one possible * object value exists, any one value is picked and returned. * * @param m * the model from which to retrieve an object String value. * @return an {@link Optional} object String value from the given model, which will be * {@link Optional#empty() empty} if no such value exists. */ public static Optional<String> objectString(Model m) { return m.stream().map(st -> st.getObject().stringValue()).findAny(); }
public RepositoryMusicPerformer (final @Nonnull Repository repository, final @Nonnull BindingSet bindingSet) { this.musicArtist = new RepositoryMusicArtist(repository, bindingSet); final Optional<String> r = Optional.of(bindingSet.getBinding("role").getValue().stringValue() .replaceAll(BMMO.NS + "performer_", "")); this.role = r.map(RepositoryMusicPerformerRole::new); }
@Override public void processAggregate(BindingSet s) throws QueryEvaluationException { Value v = evaluate(s); if (v != null && distinctValue(v)) { concatenated.append(v.stringValue()); concatenated.append(separator); } }
@Override protected Value evaluate(ValueFactory valueFactory, Value arg) throws ValueExprEvaluationException { if (!(arg instanceof Literal)) { throw new ValueExprEvaluationException("Argument must be a literal"); } return valueFactory.createLiteral(arg.stringValue().trim()); } }