Diff for /java/classes/org/w3c/rdf/examples/SiRPACServlet.java between versions 1.20 and 1.21

version 1.20, 2001/02/22 23:04:14 version 1.21, 2001/06/08 19:10:06
Line 48 Line 48
  *       a link to the file   *       a link to the file
  *     NO_GRAPH - do not generate a graph   *     NO_GRAPH - do not generate a graph
  *   *
    * NTRIPLES if "on" the tabular output will be in the NTriples format;
    *  otherwise a table of Subject, Predicate, Objects will be generated
    *
  * @author Art Barstow <barstow@w3.org>   * @author Art Barstow <barstow@w3.org>
  *   *
  * The graphics package is AT&T's GraphVis tool.   * The graphics package is AT&T's GraphVis tool.
Line 93  public class SiRPACServlet extends HttpS Line 96  public class SiRPACServlet extends HttpS
     private static final String SAVE_DOT_FILE   = "SAVE_DOT_FILE";      private static final String SAVE_DOT_FILE   = "SAVE_DOT_FILE";
     private static final String SAVE_RDF        = "SAVE_RDF";      private static final String SAVE_RDF        = "SAVE_RDF";
     private static final String URI             = "URI";      private static final String URI             = "URI";
       private static final String NTRIPLES        = "NTRIPLES";
     
     private static final String NODE_COLOR         = "NODE_COLOR";      private static final String NODE_COLOR         = "NODE_COLOR";
     private static final String DEFAULT_NODE_COLOR = "black";      private static final String DEFAULT_NODE_COLOR = "black";
Line 554  public class SiRPACServlet extends HttpS Line 558  public class SiRPACServlet extends HttpS
      *       *
      *@param out the servlet's output stream       *@param out the servlet's output stream
      */       */
     private void printTripleTableHeader (ServletOutputStream out) {      private void printTripleTableHeader (ServletOutputStream out, boolean nTriples) 
       {
         try {          try {
             out.println("<hr title=\"triples\">");              if (nTriples) {
             out.println("<h3>Triples of the data model</h3>");                  out.println("<h3>Triples of the Data Model in N-Triples Format (Sub, Pred, Obj)</h3>");
             out.println("<table border><tr>" +                  out.println("<pre>");
                           "<td><b>Number</b></td>" +              } else {
                           "<td><b>Subject</b></td>" +                  out.println("<hr title=\"triples\">");
                           "<td><b>Predicate</b></td>" +                  out.println("<h3>Triples of the Data Model</h3>");
                           "<td><b>Object</b></td>" +                  out.println("<table border><tr>" +
                         "</tr>");                              "<td><b>Number</b></td>" +
                               "<td><b>Subject</b></td>" +
                               "<td><b>Predicate</b></td>" +
                               "<td><b>Object</b></td>" +
                               "</tr>");
               }
         } catch (Exception e) {          } catch (Exception e) {
             System.err.println("Exception: " + e.getMessage());              System.err.println("Exception: " + e.getMessage());
         }          }
Line 574  public class SiRPACServlet extends HttpS Line 584  public class SiRPACServlet extends HttpS
      *       *
      *@param out the servlet's output stream       *@param out the servlet's output stream
      */       */
     private void printTripleTableFooter (ServletOutputStream out, SiRPACServletDumpConsumer consumer) {      private void printTripleTableFooter (ServletOutputStream out, 
           SiRPACServletDumpConsumer consumer, boolean nTriples) 
       {
         try {          try {
             out.println("</table>");              if (nTriples)
                   out.println("</pre>");
               else
                   out.println("</table>");
             if (consumer != null)              if (consumer != null)
                 out.println("<p>The number of triples = " + consumer.getNumStatements() + "</p>");                  out.println("<p>The number of triples = " + consumer.getNumStatements() + "</p>");
         } catch (Exception e) {          } catch (Exception e) {
Line 672  public class SiRPACServlet extends HttpS Line 687  public class SiRPACServlet extends HttpS
      *       *
      *@param config the servlet's configuration object       *@param config the servlet's configuration object
      */       */
     public void init(ServletConfig config) throws ServletException {      public void init(ServletConfig config) throws ServletException 
       {
         super.init (config);          super.init (config);
   
         // Cache the parameters          // Cache the parameters
Line 684  public class SiRPACServlet extends HttpS Line 700  public class SiRPACServlet extends HttpS
         m_GraphVizPath = GraphVizRoot + "/" + config.getInitParameter(GRAPH_VIZ_PATH);          m_GraphVizPath = GraphVizRoot + "/" + config.getInitParameter(GRAPH_VIZ_PATH);
         m_GraphVizFontDir = GraphVizRoot + "/" + config.getInitParameter(GRAPH_VIZ_FONT_DIR);          m_GraphVizFontDir = GraphVizRoot + "/" + config.getInitParameter(GRAPH_VIZ_FONT_DIR);
         m_GraphVizLibDir = GraphVizRoot + "/" + config.getInitParameter(GRAPH_VIZ_LIB_DIR);          m_GraphVizLibDir = GraphVizRoot + "/" + config.getInitParameter(GRAPH_VIZ_LIB_DIR);
   
           if (m_SiRPACTmpDir == null || GraphVizRoot == null) {
               System.err.println (
                   "<html>" +
                   "<h1>Servlet Initialization Error</h1>" +
                   "<h2>One or more of the following parameters has not been initialized: " + 
                   SIRPAC_TMP_DIR + "," + GRAPH_VIZ_ROOT + "," +
                   GRAPH_VIZ_FONT_DIR + "," + GRAPH_VIZ_LIB_DIR + "," +
                   GRAPH_VIZ_PATH + "." + 
                   "</h2></h1>" +
                   "</html>");
           }
     }      }
   
     /*      /*
Line 727  public class SiRPACServlet extends HttpS Line 755  public class SiRPACServlet extends HttpS
         String    sSaveDOTFile = req.getParameter (SAVE_DOT_FILE);          String    sSaveDOTFile = req.getParameter (SAVE_DOT_FILE);
         String    sURI         = req.getParameter (URI);          String    sURI         = req.getParameter (URI);
         String    sFormat      = req.getParameter (FORMAT);          String    sFormat      = req.getParameter (FORMAT);
           String    sNTriples    = req.getParameter (NTRIPLES);
   
         SiRPAC        sirpac = new SiRPAC();          SiRPAC        sirpac = new SiRPAC();
         ErrorStore    errorHandler = new ErrorStore();          ErrorStore    errorHandler = new ErrorStore();
         InputSource   is = null;          InputSource   is = null;
         boolean       error = false;          boolean       error = false;
         String        sError = null;          String        sError = null;
           boolean       nTriples = false;
   
         SiRPACServletDumpConsumer    consumer = new SiRPACServletDumpConsumer();          SiRPACServletDumpConsumer consumer = new SiRPACServletDumpConsumer();
           if (sNTriples != null && sNTriples.equals("on")) {
               nTriples = true;
               consumer.setNTriplesOutput(true);
           }
   
         // Initialize the parser          // Initialize the parser
         sirpac.setErrorHandler(errorHandler);          sirpac.setErrorHandler(errorHandler);
Line 771  public class SiRPACServlet extends HttpS Line 805  public class SiRPACServlet extends HttpS
   
         printDocumentHeader (out);          printDocumentHeader (out);
         printListing (out, sRDF, sURI != null && sURI.length() >= 1);          printListing (out, sRDF, sURI != null && sURI.length() >= 1);
         printTripleTableHeader (out);          printTripleTableHeader (out, nTriples);
   
         try {          try {
             // Override the default triple output handler              // Override the default triple output handler
Line 787  public class SiRPACServlet extends HttpS Line 821  public class SiRPACServlet extends HttpS
   
             sirpac.parse(is, consumer);              sirpac.parse(is, consumer);
   
             printTripleTableFooter(out, consumer);              printTripleTableFooter(out, consumer, nTriples);
   
             if (sFormat != null && !sFormat.equals(FORMAT_NO_GRAPH)) {              if (sFormat != null && !sFormat.equals(FORMAT_NO_GRAPH)) {
                 generateGraph(out,                   generateGraph(out, 
Line 811  public class SiRPACServlet extends HttpS Line 845  public class SiRPACServlet extends HttpS
         res.setContentType ("text/html");          res.setContentType ("text/html");
   
         if (error) {          if (error) {
             printTripleTableFooter(out, null);              printTripleTableFooter(out, null, nTriples);
             out.println ("<h1>Errors during parsing</h1>\n");              out.println ("<h1>Errors during parsing</h1>\n");
             out.println ("<pre>\n");              out.println ("<pre>\n");
   

Removed from v.1.20  
changed lines
  Added in v.1.21


Webmaster