Refine search
private void check(String string) { IRI iri = factory.create(string); if (iri.hasViolation(true)) { System.out.println("n: " + string); Iterator<Violation> it = iri.violations(true); while (it.hasNext()) { Violation v = it.next(); System.out.println(v.getLongMessage()); } } else { System.out.println("y: " + string); } }
static private String abbrevByBase(String uri, String base) { if ( base == null ) return null ; IRI baseIRI = IRIFactory.jenaImplementation().construct(base) ; IRI rel = baseIRI.relativize(uri, relFlags) ; String r = null ; try { r = rel.toASCIIString() ; } catch (MalformedURLException ex) { r = rel.toString() ; } return r ; }
static private IRI resolveIRI(String relStr, String baseStr) { IRI i = factory.create(relStr); if (i.isAbsolute()) // removes excess . segments return cwd.create(i); IRI base = factory.create(baseStr); if ("file".equalsIgnoreCase(base.getScheme())) return cwd.create(base).create(i); return base.create(i); }
/** Abbreviate the URI */ private String abbrevByBase(String uri) { IRI rel = iriResolver.relativize(uri, relFlags) ; String r = null ; try { r = rel.toASCIIString() ; } catch (MalformedURLException ex) { r = rel.toString() ; } return r ; }
/** Answer the relative form of the URI against the base, according to the relativeFlags. */ private String relativize( IRI base, String uri ) { // errors? return base.relativize( uri, relativeFlags).toString(); }
IRI base = iriFactory.create(baseIRI) ; iri = base.create(iriStr) ; } else iri = iriFactory.create(iriStr) ; if ( !iri.isAbsolute() ) throw new ExprEvalException("Relative IRI string: " + iriStr) ; if ( warningsForIRIs && iri.hasViolation(false) ) { String msg = "unknown violation from IRI library" ; Iterator<Violation> iter = iri.violations(false) ; if ( iter.hasNext() ) { Violation viol = iter.next() ; return NodeFactory.createURI(iri.toString()) ;
private Object open(IRI uri, boolean in) { IRI relative = uri.isAbsolute() ? base.relativize(uri, IRIRelativize.CHILD) : uri; if (relative.isAbsolute()) throw new IllegalArgumentException( "This TestInputStreamFactory only knows about '" + base + "'."); String relPath = relative.toString(); if ( relPath.length() - relPath.lastIndexOf('.') > 5 ) { relPath = relPath + ".rdf"; relative = iriFactory.create(relPath); URL url = mapBase.create(relative).toURL(); if (!in) { if (url.getProtocol().equalsIgnoreCase("file"))
public static void main(String... args) { //IRIFactory iriFactory = IRIFactory.iriImplementation() ; IRIFactory iriFactory = IRIResolver.iriFactory() ; boolean first = true ; for ( String iriStr : args ) { if ( iriStr.startsWith("<") && iriStr.endsWith(">") ) iriStr = iriStr.substring(1, iriStr.length()-1) ; 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.isRelative()) ; Iterator<Violation> vIter = iri.violations(true) ; for ( ; vIter.hasNext() ; ) { System.out.println(vIter.next().getShortMessage()) ; } } }
private boolean checkURI( String uri ) { IRIFactory factory = IRIFactory.jenaImplementation(); IRI iri = factory.create( uri ); if (iri.hasViolation(false) ) { log.error("Bad URI: "+uri); log.error( "Only well-formed absolute URIrefs can be included in RDF/XML output: " + iri.violations(false).next().getShortMessage()); return true; } else { return false; } }
if (uri.length() != 0) IRI u = iriFactory().create(uri); if (!u.isAbsolute()) { warning(null, WARN_RELATIVE_NAMESPACE_URI_DEPRECATED, if (!u.toASCIIString().equals(u.toString())) warning(null, WARN_BAD_NAMESPACE_URI, "Non-ascii characters in a namespace URI may not be completely portable: <" + u.toString() + ">. Resulting RDF URI references are legal."); } catch (MalformedURLException e) { WARN_BAD_NAMESPACE_URI, "Bad namespace URI: <" + u.toString() + ">. " + e.getMessage());
public AbsXMLContext withBase(XMLHandler forErrors, String b) throws SAXParseException { TaintImpl taintB = new TaintImpl(); IRI newB = resolveAsURI(forErrors, taintB, b, false); if (newB.isRelative()) return new XMLBaselessContext(forErrors,ERR_RESOLVING_AGAINST_RELATIVE_BASE, newB.create("")); if (newB.hasViolation(false)) return new XMLBaselessContext(forErrors, ERR_RESOLVING_AGAINST_MALFORMED_BASE, newB); return new XMLContext(keepDocument(forErrors), document, newB .create(""), taintB, lang, langTaint); }
Test(Resource r) { super( WGTestSuite .this .testDir .relativize(IRIFactory.iriImplementation().create(r.getURI()), IRI.CHILD) .toString()); testID = r; } String create(Property p) {
static private void show(IRI iri) { System.out.println("Scheme: " + iri.getScheme()); System.out.println("Authority: " + iri.getRawAuthority()); System.out.println("User: " + iri.getRawUserinfo()); System.out.println("Host: " + iri.getRawHost()); System.out.println("Port: " + iri.getPort()); System.out.println("Path: " + iri.getRawPath()); System.out.println("Query: " + iri.getRawQuery()); System.out.println("Fragment: " + iri.getRawFragment()); Iterator<Violation> it = ((AbsIRIImpl) iri).allViolations(); while (it.hasNext()) { System.out.println(it.next().getLongMessage()); } it = ((AbsIRIImpl) iri).violations(true); while (it.hasNext()) { System.out.println("+"+it.next().getLongMessage()); } it = ((AbsIRIImpl) iri).violations(false); while (it.hasNext()) { System.out.println("++"+it.next().getLongMessage()); } }
boolean includeIRIwarnings, long line, long col) { if ( !allowRelativeIRIs && iri.isRelative() ) errorHandler.error("Relative IRI: " + iri, line, col) ; if ( iri.hasViolation(includeIRIwarnings) ) { Iterator<Violation> iter = iri.violations(includeIRIwarnings) ; String iriStr = iri.toString() ;
protected IRI throwAnyErrors(IRI rslt) throws IRIException { if (rslt.hasViolation(false)) { throw new IRIImplException(rslt.violations(false).next()); // Iterator it = rslt.exceptions(); // while (it.hasNext()){ // Violation v = (Violation)it.next(); // if (v.isError()) // throw new IRIImplException(v); // } } return rslt; }
public static void main(String[] args) { IRIFactory iriFactory = IRIFactory.iriImplementation() ; iriFactory = IRIResolver.iriFactory ; 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.isRelative()) ; Iterator<Violation> vIter = iri.violations(true) ; for ( ; vIter.hasNext() ; ) { System.out.println(vIter.next().getShortMessage()) ; } } }
/** * Turn a filename into a well-formed file: URL relative to the working * directory. * * @param filename * @return String The filename as an absolute URL */ static public String resolveFileURL(String filename) throws IRIException { IRI r = cwd.resolve(filename); if (!r.getScheme().equalsIgnoreCase("file")) { return resolveFileURL("./" + filename); } return r.toString(); }
protected static void checkURI(XMLHandler forErrors, Taint taintMe, IRI rslt) throws SAXParseException { if (rslt.hasViolation(false)) { Iterator<Violation> it = rslt.violations(false); while (it.hasNext()) { Violation irie = it.next(); // if (irie.getViolationCode() == // ViolationCodes.REQUIRED_COMPONENT_MISSING) String msg = irie.getShortMessage(); if (irie.getViolationCode() == ViolationCodes.REQUIRED_COMPONENT_MISSING && irie.getComponent() == IRIComponents.SCHEME) { if (!forErrors.allowRelativeURIs()) forErrors.warning(taintMe, WARN_RELATIVE_URI, "Relative URIs are not permitted in RDF: specifically <"+rslt.toString()+">"); } else forErrors.warning(taintMe, WARN_MALFORMED_URI, "Bad URI: " + msg); } } }
static private IRI resolveIRI(String relStr, String baseStr) { IRI i = iriFactory().create(relStr); if (i.isAbsolute()) // removes excess . segments return globalResolver.getBaseIRI().create(i); IRI base = iriFactory().create(baseStr); return base.create(i); }
/** * Validates a URI is indeed valid * @param uri * @return */ public static boolean isValidUri(String uri) { return !iriFactory.create(uri).hasViolation(false); }