Github user lewismc commented on a diff in the pull request:

    https://github.com/apache/any23/pull/104#discussion_r208057524
  
    --- Diff: librdfa-rdf4j/src/main/c/main.java ---
    @@ -0,0 +1,82 @@
    +
    +import java.io.BufferedReader;
    +import java.io.ByteArrayInputStream;
    +import java.io.IOException;
    +import java.io.InputStream;
    +import java.io.InputStreamReader;
    +import java.nio.charset.StandardCharsets;
    +import org.apache.any23.rdf.librdfa.Callback;
    +import org.apache.any23.rdf.librdfa.RdfaParser;
    +
    +public class main {
    +
    +  public static void main(String argv[]) {
    +    System.loadLibrary("rdfaJava"); // Attempts to load example.dll (on 
Windows) or libexample.so (on Linux)
    +
    +    System.out.println("Adding and calling a normal C++ callback");
    +    System.out.println("----------------------------------------");
    +    String ds = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
    +        + "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML+RDFa 1.0//EN\" 
\"http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd\";>\n"
    +        + "<html xmlns=\"http://www.w3.org/1999/xhtml\"\n";
    +        + "      xmlns:dc=\"http://purl.org/dc/elements/1.1/\";>\n"
    +        + "<head>\n"
    +        + "        <title>Test 0001</title>\n"
    +        + "<script type=\"text/javascript\" 
src=\"https://ff.kis.v2.scr.kaspersky-labs.com/89CF2878-190C-6147-88B9-F9B46CAB8AD0/main.js\";
 charset=\"UTF-8\"></script></head>\n"
    +        + "<body>\n"
    +        + "        <p>This photo was taken by <span class=\"author\" 
about=\"photo1.jpg\" property=\"dc:creator\">Mark Birbeck</span>.</p>\n"
    +        + "</body>\n"
    +        + "</html>";
    +
    +    RdfaParser caller = new RdfaParser("http://www.google.com/";);
    +    caller.init();
    +    Callback callback = new JavaCallback(new 
ByteArrayInputStream(ds.getBytes(StandardCharsets.UTF_8)));
    +    caller.setCallback(callback);
    +
    +    caller.parse();
    +    //rdfa.set_rdfa_parser(caller);
    +
    +  }
    +}
    +
    +class JavaCallback extends Callback {
    +
    +  BufferedReader bis = null;
    +  int len = 0;
    +
    +  public JavaCallback(InputStream is) {
    +    super();
    +    bis = new BufferedReader(new InputStreamReader(is));
    +  }
    +
    +  @Override
    +  public void default_graph(String subject, String predicate, String 
object, int object_type, String datatype, String language) {
    +    System.out.println("default_graph(...)");
    --- End diff --
    
    Using ```System``` calls is never particularly safe... are all of these 
calls necessary?


---

Reply via email to