@Test void testParseQuad() { final Optional<Quad> quad = FileUtils.parseQuad( "<trellis:data/resource> <http: + "\"Some title\" <http: assertTrue(quad.isPresent(), "Quad isn't present in parsed string!"); quad.ifPresent(q -> { assertEquals("trellis:data/resource", ((IRI) q.getSubject()).getIRIString(), "Incorrect subject!"); assertEquals(DC.title, q.getPredicate(), "Incorrect predicate!"); assertEquals("Some title", ((Literal) q.getObject()).getLexicalForm(), "Incorrect literal object!"); assertTrue(q.getGraphName().isPresent(), "Graph name isn't present!"); q.getGraphName().ifPresent(g -> assertEquals(Trellis.PreferUserManaged, g, "Incorrect graph name!")); }); }
public static Stream<Quad> parseQuad(final String line) { final List<Token> tokens = new ArrayList<>(); fromString(line).forEachRemaining(tokens::add); final List<Node> nodes = tokens.stream().filter(Token::isNode).map(Token::asNode).filter(Objects::nonNull) .collect(toList()); if (nodes.size() == 3) { return of(fromJena(create(defaultGraphIRI, nodes.get(0), nodes.get(1), nodes.get(2)))); } else if (nodes.size() == 4) { return of(fromJena(create(nodes.get(3), nodes.get(0), nodes.get(1), nodes.get(2)))); } else { LOGGER.debug("Skipping invalid data value: {}", line); return empty(); } }
FileUtils { public static Stream<Quad> parseQuad(final String line) { final List<Token> tokens = new ArrayList<>(); fromString(line).forEachRemaining(tokens::add); final List<Node> nodes = tokens.stream().filter(Token::isNode).map(Token::asNode).filter(Objects::nonNull) .collect(toList()); if (nodes.size() == 3) { return of(fromJena(create(defaultGraphIRI, nodes.get(0), nodes.get(1), nodes.get(2)))); } else if (nodes.size() == 4) { return of(fromJena(create(nodes.get(3), nodes.get(0), nodes.get(1), nodes.get(2)))); } else { LOGGER.debug("Skipping invalid data value: {}", line); return empty(); } } }
FileUtils { public static Stream<Quad> parseQuad(final String line) { final List<Token> tokens = new ArrayList<>(); fromString(line).forEachRemaining(tokens::add); final List<Node> nodes = tokens.stream().filter(Token::isNode).map(Token::asNode).filter(Objects::nonNull) .collect(toList()); if (nodes.size() == 3) { return of(fromJena(create(defaultGraphIRI, nodes.get(0), nodes.get(1), nodes.get(2)))); } else if (nodes.size() == 4) { return of(fromJena(create(nodes.get(3), nodes.get(0), nodes.get(1), nodes.get(2)))); } else { LOGGER.debug("Skipping invalid data value: {}", line); return empty(); } } private  FileUtils(); }
FileUtils { public static Stream<Quad> parseQuad(final String line) { final List<Token> tokens = new ArrayList<>(); fromString(line).forEachRemaining(tokens::add); final List<Node> nodes = tokens.stream().filter(Token::isNode).map(Token::asNode).filter(Objects::nonNull) .collect(toList()); if (nodes.size() == 3) { return of(fromJena(create(defaultGraphIRI, nodes.get(0), nodes.get(1), nodes.get(2)))); } else if (nodes.size() == 4) { return of(fromJena(create(nodes.get(3), nodes.get(0), nodes.get(1), nodes.get(2)))); } else { LOGGER.debug("Skipping invalid data value: {}", line); return empty(); } } private  FileUtils(); static File getResourceDirectory(final File baseDirectory, final IRI identifier); static Stream<Quad> parseQuad(final String line); static boolean filterServerManagedQuads(final Quad quad); static boolean uncheckedDeleteIfExists(final Path path); static Stream<Path> uncheckedList(final Path path); static void writeMemento(final File resourceDir, final Resource resource,
            final Instant time); static InputStream getBoundedStream(final InputStream stream, final int from, final int to); static String serializeQuad(final Quad quad); static File getNquadsFile(final File dir, final Instant time); }
FileUtils { public static Stream<Quad> parseQuad(final String line) { final List<Token> tokens = new ArrayList<>(); fromString(line).forEachRemaining(tokens::add); final List<Node> nodes = tokens.stream().filter(Token::isNode).map(Token::asNode).filter(Objects::nonNull) .collect(toList()); if (nodes.size() == 3) { return of(fromJena(create(defaultGraphIRI, nodes.get(0), nodes.get(1), nodes.get(2)))); } else if (nodes.size() == 4) { return of(fromJena(create(nodes.get(3), nodes.get(0), nodes.get(1), nodes.get(2)))); } else { LOGGER.debug("Skipping invalid data value: {}", line); return empty(); } } private  FileUtils(); static File getResourceDirectory(final File baseDirectory, final IRI identifier); static Stream<Quad> parseQuad(final String line); static boolean filterServerManagedQuads(final Quad quad); static boolean uncheckedDeleteIfExists(final Path path); static Stream<Path> uncheckedList(final Path path); static void writeMemento(final File resourceDir, final Resource resource,
            final Instant time); static InputStream getBoundedStream(final InputStream stream, final int from, final int to); static String serializeQuad(final Quad quad); static File getNquadsFile(final File dir, final Instant time); static final String CONFIG_FILE_LDP_TYPE; static final String CONFIG_FILE_DIGEST_ALGORITHM; static final int LENGTH; static final int MAX; }