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); } }
@Override public void add(String prefix, String iriString) { this.add(prefix, IRIFactory.iriImplementation().create(iriString)); }
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 ; }
/** Set the error/warning state of a violation code. * @param factory IRIFactory * @param code ViolationCodes constant * @param isError Whether it is to be treated an error. * @param isWarning Whether it is to be treated a warning. */ private static void setErrorWarning(IRIFactory factory, int code, boolean isError, boolean isWarning) { factory.setIsWarning(code, isWarning); factory.setIsError(code, isError); }
/** * Set condition #<code>code</code> * to be treated as a warning; * or clear it as a warning condition. * Setting a code to be a warning, clears it from * being an error. Care must be taken * if the <code>code</code> is one that is documented * in {@link ViolationCodes} has having SHOULD or MUST * force, since ignoring any resulting warning may * result in a nonconformant application. * @param code A condition code from {@link ViolationCodes}. * @param set True to set this as a warning, false to clear. * @throws IllegalStateException If this factory has already been used to create an IRI. */ public void setIsWarning(int code, boolean set) { initializing(); if (set) { warnings |= (1l<<code); setIsError(code,false); } else warnings &= ~(1l<<code); }
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; } }
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); }
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) ;
/** * Creates new XMLContext * * @throws SAXParseException */ XMLContext(XMLHandler h, String base) throws SAXParseException { this(h, h.iriFactory().create(base)); }
static public void main(String args[]) throws IOException { LineNumberReader in = new LineNumberReader(new InputStreamReader( System.in)); IRIImpl last = null; DEBUG = true; IRIFactory factory = IRIFactory.iriImplementation(); while (true) { String s = in.readLine().trim(); if (s.equals("quit")) return; IRIImpl iri = (IRIImpl) factory.create(s); show(iri); if (last != null) { IRI r = last.create(iri); System.out.println("Resolved: " + r.toString()); show(r); } last = iri; } }
Test(Resource r) { super( WGTestSuite .this .testDir .relativize(IRIFactory.iriImplementation().create(r.getURI()), IRI.CHILD) .toString()); testID = r; } String create(Property p) {
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()) ; } } }
/** * Note: must work with uri being null. */ private void setLocalName(String uri) { if (uri == null || uri.equals("")) localName = ""; else // try { IRI u = BaseXMLWriter.factory.create(uri); u = u.create(""); localName = u.toString(); } // catch (MalformedURIException e) { // throw new BadURIException(uri, e); // } }
public static final IRIFactory iriFactory = new IRIFactory() ; private static boolean showExceptions = true ; static { iriFactory.useSpecificationIRI(true) ; iriFactory.useSchemeSpecificRules("*", true) ; iriFactory.setSameSchemeRelativeReferences("file") ; iriFactory.setIsError(ViolationCodes.UNREGISTERED_IANA_SCHEME, false) ; iriFactory.setIsWarning(ViolationCodes.UNREGISTERED_IANA_SCHEME, false) ; IRI cwd ; try { cwd = iriFactory.construct(globalBase) ; } catch (IRIException e) { System.err.println("Unexpected IRIException in initializer: " + e.getMessage()) ; cwd = iriFactory.create("file:///") ; e.printStackTrace(System.err) ;
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()) ; } } }
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); }
String uri = uris[i]; if (uri != null) { IRIFactory factory = IRIFactory.jenaImplementation(); IRI iri = factory.create(uri); if (iri.hasViolation(false)) { badURITriples.add(stmt); log.error("Discarding added triple " + stmt + " because " +
public TurtleParserBase() { /* **** temporary **** */ setPrologue(new Prologue()); IRIFactory iriFactory = new IRIFactory(IRIFactory.iriImplementation()); // // These two are from IRIFactory.iriImplementation() ... // iriFactory.useSpecificationIRI(true); // iriFactory.useSchemeSpecificRules("*", true); // // // Allow relative references for file: URLs. // iriFactory.setSameSchemeRelativeReferences("file"); // // DOUBLE_WHITESPACE is misnamed - it applies to last character being a space as well (IRI bug?) //setErrorWarning(iriFactory, ViolationCodes.DOUBLE_WHITESPACE, true, true); setErrorWarning(iriFactory, ViolationCodes.UNWISE_CHARACTER, true, true); setErrorWarning(iriFactory, ViolationCodes.WHITESPACE, true, true); setErrorWarning(iriFactory, ViolationCodes.UNREGISTERED_IANA_SCHEME, false, false); setErrorWarning(iriFactory, ViolationCodes.UNDEFINED_UNICODE_CHARACTER, false, false); IRI iri = iriFactory.create(IRIResolver.chooseBaseURI()); IRIResolver resolver = IRIResolver.create(iri); getPrologue().setResolver(IRIResolver.create(iri)); }