"+
997 | "
");
1006 |
1007 |
1008 | } catch (Exception e) {
1009 | System.err.println("Exception (printDocumentHeader): " + e.getMessage());
1010 | }
1011 | }
1012 |
1013 | /*
1014 | * Print the rdf listing
1015 | *
1016 | *@param out the servlet's output Writer
1017 | *@param rdf the RDF code
1018 | *@param needCR if true, add a CarriageReturn to the output; if false,
1019 | * do not add it
1020 | */
1021 | private void printListing (PrintWriter out, String rdf,
1022 | boolean needCR)
1023 | {
1024 | try {
1025 | out.println("
" +
1026 | "
" +
1028 | "
");
1029 |
1030 | String s = replaceString(rdf, "&", "&");
1031 | s = replaceString(s, "<", "<");
1032 |
1033 | // Now output the RDF one line at a time with line numbers
1034 | int lineNum = 1;
1035 | int nl = 0;
1036 | String terminator = needCR?"\n":"";
1037 | do {
1038 | String tok;
1039 | nl = s.indexOf('\n');
1040 | if ( nl == -1 ) {
1041 | tok = s;
1042 | } else {
1043 | tok = s.substring(0,nl);
1044 | s = s.substring(nl+1);
1045 | }
1046 | out.print("" + lineNum +
1047 | ": " + tok + terminator);
1048 | lineNum++;
1049 | } while ( nl != -1 );
1050 |
1051 | out.println("
");
1052 | } catch (Exception e) {
1053 | System.err.println("Exception (printListing): " + e.getMessage());
1054 | }
1055 | }
1056 |
1057 | /*
1058 | * Print the header for the triple listing
1059 | *
1060 | *@param out the servlet's output Writer
1061 | *@param nTriples if true, output is N-Triples syntax
1062 | */
1063 | private void printTripleTableHeader (PrintWriter out, boolean nTriples)
1064 | {
1065 | try {
1066 | if (nTriples) {
1067 | out.println("
" +
1071 | "
");
1072 | } else {
1073 | out.println("
");
1074 | out.println("");
1076 | out.println("
" +
1077 | "Number | " +
1078 | "Subject | " +
1079 | "Predicate | " +
1080 | "Object | " +
1081 | "
");
1082 | }
1083 | } catch (Exception e) {
1084 | System.err.println("Exception (printTripleTableHeader): " + e.getMessage());
1085 | }
1086 | }
1087 |
1088 | /*
1089 | * Print the footer info for the triple listing
1090 | *
1091 | *@param out the servlet's output Writer
1092 | *@param nTriples if true, output is N-Triples syntax
1093 | */
1094 | private void printTripleTableFooter (PrintWriter out,
1095 | boolean nTriples)
1096 | {
1097 | try {
1098 | if (nTriples)
1099 | out.println("");
1100 | else
1101 | out.println("
");
1102 | } catch (Exception e) {
1103 | System.err.println("Exception (printTripleTableFooter): " + e.getMessage());
1104 | }
1105 | }
1106 |
1107 | /*
1108 | * Print the document's footer info
1109 | *
1110 | *@param out the servlet's output Writer
1111 | *@param rdf the RDF code
1112 | */
1113 | private void printDocumentFooter (PrintWriter out, String rdf)
1114 | {
1115 | try {
1116 |
1117 | String s;
1118 |
1119 | s = "
" +
1120 | "
" +
1121 | "
If you suspect the parser is in error, please enter an explanation below and then press the Submit problem report button, to mail the report (and listing) to " + MAIL_TO + "
" +
1122 | "
");
1143 |
1144 | out.println("
");
1145 |
1146 | } catch (Exception e) {
1147 | System.err.println("Exception (printDocumentFooter): " + e.getMessage());
1148 | }
1149 | }
1150 |
1151 | /*
1152 | * Create a formatted string from the exception's message
1153 | *
1154 | *@param e any exception other than a SAXParseException
1155 | *@return a formatted string
1156 | */
1157 | private static String formatOtherThanSAXParseEx(Exception e)
1158 | {
1159 | String msg = e.getMessage();
1160 | if (msg == null)
1161 | msg = e.toString();
1162 | msg = replaceString(msg,"&","&");
1163 | msg = replaceString(msg,"<","<");
1164 | msg = replaceString(msg,">",">");
1165 | msg = replaceString(msg,"\"",""");
1166 | msg = replaceString(msg,"'","'");
1167 | return msg;
1168 | }
1169 |
1170 | /*
1171 | * Servlet's get info method
1172 | */
1173 | public String getServletInfo () {
1174 | return "Servlet wrapper for the ARP RDF parser. This is revision " + REVISION;
1175 | }
1176 |
1177 | /*
1178 | * Servlet's init method
1179 | *
1180 | *@param config the servlet's configuration object
1181 | *@throws ServletException
1182 | */
1183 | public void init(ServletConfig config) throws ServletException
1184 | {
1185 | super.init (config);
1186 |
1187 | try {
1188 | String t = config.getInitParameter("LOG_A_LOT");
1189 | Matcher m = LogALotPattern.matcher(t);
1190 | if (m.find() && m.group(1) != null) {
1191 | System.err.println("considering LOG_A_LOT value \"" + t + "\" to be true base on substring \"" + m.group(1) + "\"");
1192 | LogALot = true;
1193 | } else {
1194 | System.err.println("considering LOG_A_LOT value \"" + t + "\" to be false.");
1195 | }
1196 | } catch (Throwable t) {
1197 | }
1198 |
1199 | // Cache the required parameters ...
1200 | m_ServletTmpDir = config.getInitParameter(SERVLET_TMP_DIR);
1201 | m_RenderDot = config.getInitParameter("RENDER_DOT");
1202 |
1203 | // ... and the optional parameters.
1204 | try { m_BitmappedFont = config.getInitParameter("BITMAPPED_FONT"); } catch (Throwable t) {}
1205 | try { m_VectorFont = config.getInitParameter("VECTOR_FONT"); } catch (Throwable t) {}
1206 |
1207 | if (m_ServletTmpDir == null) {
1208 | System.err.println (
1209 | "" +
1210 | "