public void setBaseURI(IRI iri) { this.seenBaseURI = true ; this.resolver = IRIResolver.create(iri) ; }
private static String baseURI(String sourceURI, String absBaseURI) { if ( absBaseURI == null ) return IRIResolver.resolveString(sourceURI); else return IRIResolver.resolveString(sourceURI, absBaseURI); } }
/** Parse an IRI (does not resolve it) */ public static IRI parseIRI(String iriStr) { return iriFactory().create(iriStr); }
/** * Resolve a relative URI against the base of this IRIResolver * or normalize an absolute URI. * * @param uriStr * @return the resolved IRI * @throws RiotException * If resulting URI would not be legal, absolute IRI */ public IRI resolve(String uriStr) { return exceptions(resolveSilent(uriStr)); }
/** * Resolve an IRI against whatever is the base for this process (likely to * be based on the current working directory of this process at the time of * initialization of this class). */ public static IRI resolveIRI(String uriStr) { return exceptions(globalResolver.resolve(uriStr)); }
/** * Resolve a URI against a base. If baseStr is a relative file IRI * then it is first resolved against the current working directory. * * @param relStr * @param baseStr * Can be null if relStr is absolute * @return An absolute URI * @throws RiotException * If result would not be legal, absolute IRI */ static public IRI resolve(String relStr, String baseStr) throws RiotException { return exceptions(resolveIRI(relStr, baseStr)); }
public SparqlParserConfig setPrefixMapping(PrefixMapping pm) { if(prologue == null) { prologue = new Prologue(pm, IRIResolver.createNoResolve()); } else { prologue.setPrefixMapping(pm); } return this; }
/** Create a parser profile for the given setup * @param baseIRI Base IRI * @param resolveIRIs Whether to resolve IRIs * @param checking Whether to check * @param handler Error handler * @return ParserProfile * @see #profile for per-language setup * @deprecated To be removed. */ @Deprecated public static ParserProfile profile(String baseIRI, boolean resolveIRIs, boolean checking, ErrorHandler handler) { LabelToNode labelToNode = SyntaxLabels.createLabelToNode(); IRIResolver resolver; if ( resolveIRIs ) resolver = IRIResolver.create(baseIRI); else resolver = IRIResolver.createNoResolve(); ParserProfile profile = RiotLib.createParserProfile(factoryRDF(labelToNode), handler, resolver, checking); return profile; }
public void usePrologueFrom(Prologue other) { // Copy. prefixMap = PrefixMapFactory.createForInput(other.prefixMap) ; seenBaseURI = false ; if ( other.resolver != null ) resolver = IRIResolver.create(other.resolver.getBaseIRIasString()) ; }
@Override synchronized public IRI resolve(String uriStr) { return other.resolve(uriStr); }
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)); }
/** Check an IRI string (does not resolve it) */ public static boolean checkIRI(String iriStr) { IRI iri = parseIRI(iriStr); return iri.hasViolation(false); }
/** * 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 = globalResolver.resolve(filename); if (!r.getScheme().equalsIgnoreCase("file")) { // Pragmatic hack that copes with "c:" return resolveFileURL("./" + filename); } return r.toString(); }
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); }
@Override protected String resolveQuotedIRI(String iriStr, int line, int column) { iriStr = stripQuotes(iriStr); iriStr = unescapeIRI(iriStr); try { // Used to be errors (pre Jena 2.12.0) // .resolve(iriStr) IRIResolver resolver = getPrologue().getResolver(); IRI iri = resolver.resolve(iriStr) ; // IRI iri = resolver.resolveSilent(iriStr) ; // if ( true ) // CheckerIRI.iriViolations(iri, profile.getErrorHandler(), line, column) ; // iriStr = iri.toString() ; } catch (JenaURIException ex) { throw new RiotParseException(ex.getMessage(), line, column) ; } // IRI unwise characters are allowed sometimes but these are really, really // unwise (inserted by \ u escaping to by pass syntax). if ( iriStr.contains("<") || iriStr.contains(">") ) throw new RiotParseException("Illegal character '<' or '>' in IRI: '"+iriStr+"'", line, column); return getPrologue().getResolver().resolveToString(iriStr); } //
/** * Choose a base URI based on the current directory * * @return String Absolute URI */ static public IRI chooseBaseURI() { return globalResolver.getBaseIRI(); }
IRI iri = IRIResolver.resolveIRI(baseIRI) ; if ( iri.hasViolation(false) ) throw new CmdException("Bad base IRI: " + baseIRI) ;
public static String chooseBaseIRI() { return IRIResolver.chooseBaseURI().toString() ; }
/** * Creates a parser profile for the given job context * * @param context * Context * @param path * File path * @return Parser profile * @deprecated Legacy - use {@link #createRDFParserBuilder}. */ @Deprecated public static ParserProfile createParserProfile(JobContext context, Path path) { LabelToNode labelMapping = createLabelToNode(context, path); ParserProfile profile = RiotLib.createParserProfile(RiotLib.factoryRDF(labelMapping), ErrorHandlerFactory.errorHandlerStd, IRIResolver.createNoResolve(), false); return profile; }
public static ParserProfile profile(String baseIRI, boolean resolveIRIs, boolean checking, ErrorHandler handler) { LabelToNode labelToNode = true ? SyntaxLabels.createLabelToNode() : LabelToNode.createUseLabelEncoded() ; Prologue prologue ; if ( resolveIRIs ) prologue = new Prologue(PrefixMapFactory.createForInput(), IRIResolver.create(baseIRI)) ; else prologue = new Prologue(PrefixMapFactory.createForInput(), IRIResolver.createNoResolve()) ; if ( checking ) return new ParserProfileChecker(prologue, handler, labelToNode) ; else return new ParserProfileBase(prologue, handler, labelToNode) ; }