@Override public String getMessage() { return getViolation().getShortMessage(); }
@Override public String getMessage() { return getViolation().getShortMessage(); }
@Override public String getMessage() { return getViolation().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; } }
/** * Throw any exceptions resulting from IRI. * * @param iri * @return iri */ private static IRI exceptions(IRI iri) { if (!showExceptions) return iri; if (!iri.hasViolation(false)) return iri; String msg = iri.violations(false).next().getShortMessage(); throw new RiotException(msg); }
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()) ; } } }
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()) ; } } }
/** * Throw any exceptions resulting from IRI. * * @param iri * @return iri */ private static IRI exceptions(IRI iri) { if (!showExceptions) return iri ; if (!iri.hasViolation(false)) return iri ; String msg = iri.violations(false).next().getShortMessage() ; throw new RiotException(msg) ; }
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()) ; } } }
/** Answer the argument URI, but if we demandGoodURIs and it isn't good, throw a JenaException that encapsulates a MalformedURIException. There doesn't appear to be a convenient URI.checkGood() kind of method, alas. */ private String checkURI( String uri ) { if (demandGoodURIs) { IRI iri = factory.create( uri ); if (iri.hasViolation(false) ) throw new BadURIException( "Only well-formed absolute URIrefs can be included in RDF/XML output: " + (iri.violations(false).next()).getShortMessage()); } return uri; }
/** Answer the argument URI, but if we demandGoodURIs and it isn't good, throw a JenaException that encapsulates a MalformedURIException. There doesn't appear to be a convenient URI.checkGood() kind of method, alas. */ private String checkURI( String uri ) { if (demandGoodURIs) { IRI iri = factory.create( uri ); if (iri.hasViolation(false) ) throw new BadURIException( "Only well-formed absolute URIrefs can be included in RDF/XML output: " + (iri.violations(false).next()).getShortMessage()); } return uri; }
/** Answer the argument URI, but if we demandGoodURIs and it isn't good, throw a JenaException that encapsulates a MalformedURIException. There doesn't appear to be a convenient URI.checkGood() kind of method, alas. */ private String checkURI( String uri ) { if (demandGoodURIs) { IRI iri = factory.create( uri ); if (iri.hasViolation(false) ) throw new BadURIException( "Only well-formed absolute URIrefs can be included in RDF/XML output: " + (iri.violations(false).next()).getShortMessage()); } return uri; }
/** * 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; } }
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; }
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); } } }
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); } } }
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(); String uri = rslt.toString(); // if (msg.endsWith(uri)) { // msg = msg.substring(0, msg.length() - uri.length()) + "<" // + uri + ">"; // } else { // msg = "<" + uri + "> " + msg; // } 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); } } }
if ( iter.hasNext() ) { Violation viol = iter.next() ; msg = viol.getShortMessage() ;
if ( iter.hasNext() ) { Violation viol = iter.next() ; msg = viol.getShortMessage() ;