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; } }
/** * Checks a URI for validity. Jena models can store invalid URIs, but this causes RDF/XML output serialization to fail. * @param uri URI * @return null if URI is good, otherwise an error message String */ protected String checkURI( String uri ) { IRIFactory factory = IRIFactory.jenaImplementation(); IRI iri = factory.create( uri ); if (iri.hasViolation(false) ) { String errorStr = ("Bad URI: "+ uri + "\nOnly well-formed absolute URIrefs can be included in RDF/XML output: " + (iri.violations(false).next()).getShortMessage()); return errorStr; } else { return null; } }
static public String abbrevByBase(String uri, String base) { if ( hasScheme(uri) ) return uri ; IRI baseIRI = IRIFactory.jenaImplementation().construct(base) ; IRI rel = baseIRI.relativize(uri, relFlags) ; String r = rel.toString() ; return r ; }
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 public 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 public 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 ; }
public ValidationObject validate (Object obj) throws IllegalArgumentException { ValidationObject vo = new ValidationObject(); if (!(obj instanceof String)){ throw new IllegalArgumentException("Expected instance of String"); } IRIFactory factory = IRIFactory.jenaImplementation(); IRI iri = factory.create((String) obj); if (iri.hasViolation(false) ) { StringBuilder errorStr = new StringBuilder(); Iterator<Violation> violIt = iri.violations(false); while(violIt.hasNext()) { errorStr.append(violIt.next().getShortMessage()).append(" "); } vo.setValid(false); vo.setMessage("Please enter a valid URL. " + errorStr); } else { vo.setValid(true); } vo.setValidatedObject(obj); return vo; } }
private String checkURIForValidity(String uriStr) { uriStr = (uriStr == null) ? " " : uriStr; IRI iri = IRIFactory.jenaImplementation().create(uriStr); if (iri.hasViolation(false)) { return (iri.violations(false).next()).getShortMessage() + " "; } try { Resource res = ResourceFactory.createResource(uriStr); if (res.getLocalName().matches("\\d+")) { return "Localname must contain at least one non-numeric " + "character. Please enter another URI. "; } } catch (Exception e) { return "Not a valid URI. Please enter another URI. "; } return null; }
if ( v.equals("STRICT") ) { options.setIRIFactory(IRIFactory.semanticWebImplementation()) ; } else if ( v.equals("IRI") ) { options.setIRIFactory(IRIFactory.iriImplementation()) ; } else if ( v.equals("LAX") ) { options.setIRIFactory(IRIFactory.jenaImplementation()) ; } else eh.error(new IllegalArgumentException(
if ( v.equals("STRICT") ) { options.setIRIFactory(IRIFactory.semanticWebImplementation()) ; } else if ( v.equals("IRI") ) { options.setIRIFactory(IRIFactory.iriImplementation()) ; } else if ( v.equals("LAX") ) { options.setIRIFactory(IRIFactory.jenaImplementation()) ; } else eh.error(new IllegalArgumentException(
if ( v.equals("STRICT") ) { options.setIRIFactory(IRIFactory.semanticWebImplementation()) ; } else if ( v.equals("IRI") ) { options.setIRIFactory(IRIFactory.iriImplementation()) ; } else if ( v.equals("LAX") ) { options.setIRIFactory(IRIFactory.jenaImplementation()) ; } else eh.error(new IllegalArgumentException(
String uri = uris[i]; if (uri != null) { IRIFactory factory = IRIFactory.jenaImplementation(); IRI iri = factory.create(uri); if (iri.hasViolation(false)) {