congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
TurtlePrettyPrinter
Code IndexAdd Tabnine to your IDE (free)

How to use
TurtlePrettyPrinter
in
org.ldp4j.rdf.sesame

Best Java code snippets using org.ldp4j.rdf.sesame.TurtlePrettyPrinter (Showing top 16 results out of 315)

origin: ldp4j/ldp4j

@Override
public void handleComment(String comment) throws RDFHandlerException {
  trace("Discarded comment '%s'.",comment);
}
origin: ldp4j/ldp4j

@Test
public void testWithbase$simpleDoc$UnusedNamespacesAreDiscarded() throws Exception {
  withBase.startRDF();
  withBase.handleNamespace(NS1_PX1, NS1_NAMESPACE);
  withBase.handleNamespace(NS2_PX, NS2_NAMESPACE);
  withBase.handleNamespace(NO_PX,NO_NAMESPACE);
  withBase.handleStatement(statement(uriRef(NS1_NAMESPACE,URI1),uriRef(NS2_NAMESPACE,URI2),blankNode(BN_FOLDED)));
  withBase.endRDF();
  assertThat(outWithBase.toString(),containsString(BASE_DIRECTIVE));
  assertThat(outWithBase.toString(),containsString(prefixDirective(NS1_PX1, NS1_NAMESPACE)));
  assertThat(outWithBase.toString(),containsString(prefixDirective(NS2_PX, NS2_NAMESPACE)));
  assertThat(outWithBase.toString(),containsString(qname(NS1_PX1,URI1)));
  assertThat(outWithBase.toString(),containsString(qname(NS2_PX,URI2)));
  assertThat(outWithBase.toString(),containsString(blankNode(BN_FOLDED).toString()));
  assertThat(outWithBase.toString(),not(containsString(prefixDirective(NO_PX, NO_NAMESPACE))));
  assertThat(outWithBase.toString(),not(containsString(uriRef(NS1_NAMESPACE,URI1).toString())));
  assertThat(outWithBase.toString(),not(containsString(uriRef(NS2_NAMESPACE,URI2).toString())));
}
origin: ldp4j/ldp4j

public static String prettyPrint(RepositoryConnection connection, Resource... contexts) throws SesameUtilsException {
  try {
    StringWriter writer = new StringWriter();
    connection.export(new TurtlePrettyPrinter(writer), contexts);
    return writer.toString();
  } catch(RepositoryException e) {
    throw new SesameRepositoryFailure(COULD_NOT_SERIALIZE_CONTENTS,e);
  } catch (RDFHandlerException e) {
    throw new SesameUtilsAssertionError("Unexpected pretty printer failure",e);
  } catch(UnsupportedRDFormatException e) {
    throw new SesameUtilsAssertionError(TURTLE_FORMAT_SHOULD_BE_SUPPORTED, e);
  }
}
origin: ldp4j/ldp4j

@Test
public void testNobase$emptuDoc$NamespacesAreDiscarded() throws Exception {
  noBase.startRDF();
  noBase.handleNamespace(NS1_PX1, NS1_NAMESPACE);
  noBase.endRDF();
  assertThat(outNoBase.toString(),isEmptyString());
}
origin: ldp4j/ldp4j

@Test
public void testNoBase$emptyDoc$CommentsAreDiscarded() throws Exception {
  noBase.startRDF();
  noBase.handleComment(COMMENT);
  noBase.endRDF();
  assertThat(outNoBase.toString(),isEmptyString());
}
origin: ldp4j/ldp4j

@Test
public void testWithBase$emptyDoc() throws Exception {
  withBase.startRDF();
  withBase.endRDF();
  assertThat(outWithBase.toString(),containsString(BASE_DIRECTIVE));
}
origin: ldp4j/ldp4j

@Test
public void testWithbase$simpleDoc$NamespacePrefixesOverlap() throws Exception {
  withBase.startRDF();
  withBase.handleNamespace(NS1_PX1, NS1_NAMESPACE);
  withBase.handleNamespace(NS2_PX, NS2_NAMESPACE);
  withBase.handleNamespace(NS1_PX2,NS1_NAMESPACE);
  withBase.handleStatement(statement(uriRef(NS1_NAMESPACE,URI1),uriRef(NS2_NAMESPACE,URI2),blankNode(BN_FOLDED)));
  withBase.endRDF();
  assertThat(outWithBase.toString(),containsString(BASE_DIRECTIVE));
  assertThat(outWithBase.toString(),containsString(prefixDirective(NS1_PX2, NS1_NAMESPACE)));
  assertThat(outWithBase.toString(),containsString(prefixDirective(NS2_PX, NS2_NAMESPACE)));
  assertThat(outWithBase.toString(),containsString(qname(NS1_PX2,URI1)));
  assertThat(outWithBase.toString(),containsString(qname(NS2_PX,URI2)));
  assertThat(outWithBase.toString(),containsString(blankNode(BN_FOLDED).toString()));
  assertThat(outWithBase.toString(),not(containsString(prefixDirective(NS1_PX1, NS1_NAMESPACE))));
  assertThat(outWithBase.toString(),not(containsString(qname(NS1_PX1,URI1))));
  assertThat(outWithBase.toString(),not(containsString(uriRef(NS1_NAMESPACE,URI1).toString())));
  assertThat(outWithBase.toString(),not(containsString(uriRef(NS2_NAMESPACE,URI2).toString())));
}
origin: ldp4j/ldp4j

@Before
public void setUp() {
  vf = new MemValueFactory();
  outNoBase = new StringWriter();
  outWithBase = new StringWriter();
  noBase = new TurtlePrettyPrinter(outNoBase);
  withBase = new TurtlePrettyPrinter(vf.createURI(BASE),outWithBase);
}
origin: ldp4j/ldp4j

@Test
public void testWithbase$emptyDoc$NamespacesAreDiscarded() throws Exception {
  withBase.startRDF();
  withBase.handleNamespace(NS1_PX1, NS1_NAMESPACE);
  withBase.endRDF();
  assertThat(outWithBase.toString(),containsString(BASE_DIRECTIVE));
  assertThat(outWithBase.toString(),not(containsString(prefixDirective(NS1_PX1, NS1_NAMESPACE))));
}
origin: ldp4j/ldp4j

@Test
public void testWithBase$emptyDoc$CommentsAreDiscarded() throws Exception {
  withBase.startRDF();
  withBase.handleComment(COMMENT);
  withBase.endRDF();
  assertThat(outWithBase.toString(),containsString(BASE_DIRECTIVE));
  assertThat(outWithBase.toString(),not(containsString(comment(COMMENT))));
}
origin: ldp4j/ldp4j

@Test
public void testNoBase$emptyDoc() throws Exception {
  noBase.startRDF();
  noBase.endRDF();
  assertThat(outNoBase.toString(),isEmptyString());
}
origin: ldp4j/ldp4j

private RDFWriter createWriter(StringWriter writer) {
  RDFWriter result=null;
  if(format.equals(Format.TURTLE)) {
    result=new TurtlePrettyPrinter(new MemValueFactory().createURI(baseURI.toString()),writer);
  } else {
    RDFWriterRegistry registry=RDFWriterRegistry.getInstance();
    RDFFormat rawFormat=Rio.getWriterFormatForMIMEType(format.getMime(),RDFFormat.RDFXML);
    RDFWriterFactory factory=registry.get(rawFormat);
    result=factory.getWriter(writer);
    if(format.equals(Format.JSON_LD)) {
      result.getWriterConfig().set(JSONLDSettings.JSONLD_MODE,JSONLDMode.FLATTEN);
      result.getWriterConfig().set(BasicWriterSettings.PRETTY_PRINT,true);
    }
  }
  return result;
}
origin: ldp4j/ldp4j

@Override
public void handleNamespace(String prefix, String uri) throws RDFHandlerException {
  graph.addNamespace(prefix, uri);
  trace("Added prefix '%s' for namespace '%s'.",prefix,uri);
}
origin: ldp4j/ldp4j

@Override
public void startRDF() throws RDFHandlerException {
  trace("Started RDF processing...");
  graph=new GraphImpl(base);
}
origin: ldp4j/ldp4j

@Override
public void endRDF() throws RDFHandlerException {
  GraphRenderer renderer=new GraphRenderer(graph,writerConfig.get(ENABLE_FOLDING));
  out.append(renderer.render());
  out.flush();
  trace("Completed RDF processing.");
}
origin: ldp4j/ldp4j

@Override
public void handleStatement(Statement st) throws RDFHandlerException {
  Resource subject = st.getSubject();
  URI predicate = st.getPredicate();
  Value object = st.getObject();
  trace("Added triple (%s,%s,%s).",subject,predicate,object);
  graph.add(subject, predicate, object);
}
org.ldp4j.rdf.sesameTurtlePrettyPrinter

Most used methods

  • <init>
  • endRDF
  • handleComment
  • handleNamespace
  • handleStatement
  • startRDF
  • trace

Popular in Java

  • Reading from database using SQL prepared statement
  • addToBackStack (FragmentTransaction)
  • requestLocationUpdates (LocationManager)
  • findViewById (Activity)
  • ServerSocket (java.net)
    This class represents a server-side socket that waits for incoming client connections. A ServerSocke
  • Permission (java.security)
    Legacy security code; do not use.
  • Iterator (java.util)
    An iterator over a sequence of objects, such as a collection.If a collection has been changed since
  • ConcurrentHashMap (java.util.concurrent)
    A plug-in replacement for JDK1.5 java.util.concurrent.ConcurrentHashMap. This version is based on or
  • DataSource (javax.sql)
    An interface for the creation of Connection objects which represent a connection to a database. This
  • BoxLayout (javax.swing)
  • PhpStorm for WordPress
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now