use of org.apache.jena.iri.IRI in project jena by apache.
the class IRIValidatorHTML method executeHTML.
public static void executeHTML(HttpServletRequest httpRequest, HttpServletResponse httpResponse) {
try {
String[] args = httpRequest.getParameterValues(paramIRI);
ServletOutputStream outStream = httpResponse.getOutputStream();
PrintStream stdout = System.out;
PrintStream stderr = System.err;
System.setOut(new PrintStream(outStream));
System.setErr(new PrintStream(outStream));
setHeaders(httpResponse);
outStream.println("<html>");
printHead(outStream, "Jena IRI Validator Report");
outStream.println("<body>");
outStream.println("<h1>IRI Report</h1>");
startFixed(outStream);
try {
boolean first = true;
for (String iriStr : args) {
if (!first)
System.out.println();
first = false;
IRI iri = iriFactory.create(iriStr);
System.out.println(iriStr + " ==> " + iri);
if (iri.isRelative())
System.out.println("Relative IRI: " + iriStr);
Iterator<Violation> vIter = iri.violations(true);
for (; vIter.hasNext(); ) {
String str = vIter.next().getShortMessage();
str = htmlQuote(str);
System.out.println(str);
}
}
} finally {
finishFixed(outStream);
System.out.flush();
System.err.flush();
System.setOut(stdout);
System.setErr(stdout);
}
outStream.println("</body>");
outStream.println("</html>");
} catch (IOException ex) {
}
}
use of org.apache.jena.iri.IRI in project jena by apache.
the class CheckerIRI method checkURI.
// abstract
public final boolean checkURI(Node node, long line, long col) {
if (cache != null && cache.containsKey(node))
return true;
// always works - no exceptions.
IRI iri = iriFactory.create(node.getURI());
boolean b = checkIRI(iri, line, col);
// If OK, put in cache.
if (cache != null && b)
cache.put(node, iri);
return b;
}
use of org.apache.jena.iri.IRI in project jena by apache.
the class LangTurtleBase method directiveBase.
protected final void directiveBase() {
Token token = peekToken();
if (!lookingAt(IRI))
exception(token, "@base requires an IRI (found '" + token + "')");
String baseStr = token.getImage();
IRI baseIRI = profile.makeIRI(baseStr, currLine, currCol);
emitBase(baseIRI.toString());
nextToken();
IRIResolver newResolver = IRIResolver.create(baseIRI);
profile.setIRIResolver(newResolver);
}
use of org.apache.jena.iri.IRI in project jena by apache.
the class ParserSupport method checkIdSymbol.
/**
* @param str The fully expanded URI
*/
protected void checkIdSymbol(Taint taintMe, AbsXMLContext ctxt, String str) throws SAXParseException {
if (arp.idsUsed != null) {
IRI uri = ctxt.uri;
Map<String, ARPLocation> idsUsedForBase = idsUsed().get(uri);
if (idsUsedForBase == null) {
idsUsedForBase = new HashMap<>();
idsUsed().put(uri, idsUsedForBase);
}
ARPLocation prev = idsUsedForBase.get(str);
if (prev != null) {
arp.warning(taintMe, WARN_REDEFINITION_OF_ID, "Redefinition of ID: " + str);
arp.warning(taintMe, WARN_REDEFINITION_OF_ID, prev, "Previous definition of '" + str + "'.");
} else {
idsUsedForBase.put(str, arp.location());
arp.idsUsedCount++;
if (arp.idsUsedCount > 10000) {
arp.idsUsed = null;
arp.warning(taintMe, WARN_BIG_FILE, "Input is large. Switching off checking for illegal reuse of rdf:ID's.");
}
}
}
checkID_XMLName(taintMe, str);
checkEncoding(taintMe, str);
}
use of org.apache.jena.iri.IRI in project jena by apache.
the class URIReference method resolve.
/**
*
* @param f
* A frame for error reporting. AbsXMLContext of frame is ignored.
* @param ctxt
* The XML context for the base URI
* @param uri
* Input string, may be relative etc.
* @return The resolved URI
* @throws SAXParseException
*/
public static URIReference resolve(Frame f, AbsXMLContext ctxt, String uri) throws SAXParseException {
Taint taintMe = new TaintImpl();
IRI iri = ctxt.resolveAsURI(f.arp, taintMe, uri);
f.checkEncoding(taintMe, uri);
URIReference rslt = new URIReference(iri.toString());
if (taintMe.isTainted())
rslt.taint();
return rslt;
}
Aggregations