String resolveMapping(String value, boolean useVocab) throws MalformedIriException { if (iriMappings.containsKey(value)) { return iriMappings.get(value); } if (!nullified && parent != null) { try { return parent.resolveMapping(value, false); } catch (MalformedIriException e) { } } if (useVocab && vocab != null && value.indexOf(':') == -1) { return vocab + value; } throw new MalformedIriException("Can't resolve term " + value); }
/** * Resolves @predicate or @datatype according to RDFa Core 1.1 section 5 * * @param value value of attribute * @return resource IRI * @throws org.semarglproject.ri.MalformedIriException if IRI can not be resolved */ String resolvePredOrDatatype(String value) throws MalformedIriException { if (value == null || value.isEmpty()) { throw new MalformedIriException("Empty predicate or datatype found"); } if (value == RdfaParser.AUTODETECT_DATE_DATATYPE) { return RdfaParser.AUTODETECT_DATE_DATATYPE; } return resolveTermOrCurieOrAbsIri(value); }
/** * Resolves @predicate or @datatype according to RDFa Core 1.1 section 5 * * @param value value of attribute * @return resource IRI * @throws org.semarglproject.ri.MalformedIriException if IRI can not be resolved */ String resolvePredOrDatatype(String value) throws MalformedIriException { if (value == null || value.isEmpty()) { throw new MalformedIriException("Empty predicate or datatype found"); } if (value == RdfaParser.AUTODETECT_DATE_DATATYPE) { return RdfaParser.AUTODETECT_DATE_DATATYPE; } return resolveTermOrCurieOrAbsIri(value); }
/** * Resolves @predicate or @datatype according to RDFa Core 1.1 section 5 * * @param value value of attribute * @return resource IRI * @throws org.semarglproject.ri.MalformedIriException if IRI can not be resolved */ String resolvePredOrDatatype(String value) throws MalformedIriException { if (value == null || value.isEmpty()) { throw new MalformedIriException("Empty predicate or datatype found"); } if (value == RdfaParser.AUTODETECT_DATE_DATATYPE) { return RdfaParser.AUTODETECT_DATE_DATATYPE; } return resolveTermOrCurieOrAbsIri(value); }
private String resolve(String value, boolean ignoreRelIri, boolean useVocab) throws MalformedIriException { if (value == null || value.startsWith(RDF.BNODE_PREFIX)) { return value; } if (value.isEmpty()) { throw new MalformedIriException("Empty IRI"); } try { String mapping = resolveMapping(value, useVocab); if (mapping != null && mapping.charAt(0) != '@') { if (mapping.startsWith(RDF.BNODE_PREFIX)) { return mapping; } return resolveCurieOrIri(mapping, false); } } catch (MalformedIriException e) { } return resolveCurieOrIri(value, ignoreRelIri); }
return result; throw new MalformedIriException("Malformed IRI: " + iri);
return result; throw new MalformedIriException("Malformed IRI: " + iri);
return result; throw new MalformedIriException("Malformed IRI: " + iri);
private String resolveCurieOrIri(String curie, boolean ignoreRelIri) throws MalformedIriException { if (!ignoreRelIri && (curie == null || curie.isEmpty())) { return documentContext.resolveIri(curie); } boolean safeSyntax = curie.startsWith("[") && curie.endsWith("]"); if (safeSyntax) { curie = curie.substring(1, curie.length() - 1); } int delimPos = curie.indexOf(':'); if (delimPos == -1) { if (safeSyntax || ignoreRelIri) { throw new MalformedCurieException("CURIE with no prefix (" + curie + ") found"); } return documentContext.resolveIri(curie); } String result = resolveMapping(curie, delimPos, safeSyntax); if (RIUtils.isIri(result)) { return result; } throw new MalformedIriException("Malformed IRI: " + curie); }
private String resolveCurieOrIri(String curie, boolean ignoreRelIri) throws MalformedIriException { if (!ignoreRelIri && (curie == null || curie.isEmpty())) { return documentContext.resolveIri(curie); } boolean safeSyntax = curie.startsWith("[") && curie.endsWith("]"); if (safeSyntax) { curie = curie.substring(1, curie.length() - 1); } int delimPos = curie.indexOf(':'); if (delimPos == -1) { if (safeSyntax || ignoreRelIri) { throw new MalformedCurieException("CURIE with no prefix (" + curie + ") found"); } return documentContext.resolveIri(curie); } String result = resolveMapping(curie, delimPos, safeSyntax); if (RIUtils.isIri(result)) { return result; } throw new MalformedIriException("Malformed IRI: " + curie); }
private String resolveCurieOrIri(String curie, boolean ignoreRelIri) throws MalformedIriException { if (!ignoreRelIri && (curie == null || curie.isEmpty())) { return documentContext.resolveIri(curie); } boolean safeSyntax = curie.startsWith("[") && curie.endsWith("]"); if (safeSyntax) { curie = curie.substring(1, curie.length() - 1); } int delimPos = curie.indexOf(':'); if (delimPos == -1) { if (safeSyntax || ignoreRelIri) { throw new MalformedCurieException("CURIE with no prefix (" + curie + ") found"); } return documentContext.resolveIri(curie); } String result = resolveMapping(curie, delimPos, safeSyntax); if (RIUtils.isIri(result)) { return result; } throw new MalformedIriException("Malformed IRI: " + curie); }
/** * Resolves TERMorCURIEorAbsIRI according to RDFa Core 1.1 section A * @param value value to be resolved * @return resource IRI * @throws org.semarglproject.ri.MalformedIriException if IRI can not be resolved */ private String resolveTermOrCurieOrAbsIri(String value) throws MalformedIriException { if (TERM_PATTERN.matcher(value).matches()) { if (vocab == null && documentContext.rdfaVersion > RDFa.VERSION_10 && "describedby".equals(value)) { return POWDER_DESCRIBED_BY; } String term; if (vocab != null) { term = vocab.resolveTerm(value); } else { term = resolveXhtmlTerm(value); } if (term == null) { documentContext.parser.warning(RDFa.UNRESOLVED_TERM, CAN_NOT_RESOLVE_TERM + value); throw new MalformedIriException(CAN_NOT_RESOLVE_TERM + value); } return term; } try { return resolveCurieOrIri(value, true); } catch (MalformedCurieException e) { throw new MalformedIriException(e.getMessage()); } }
/** * Resolves TERMorCURIEorAbsIRI according to RDFa Core 1.1 section A * @param value value to be resolved * @return resource IRI * @throws org.semarglproject.ri.MalformedIriException if IRI can not be resolved */ private String resolveTermOrCurieOrAbsIri(String value) throws MalformedIriException { if (TERM_PATTERN.matcher(value).matches()) { if (vocab == null && documentContext.rdfaVersion > RDFa.VERSION_10 && "describedby".equals(value)) { return POWDER_DESCRIBED_BY; } String term; if (vocab != null) { term = vocab.resolveTerm(value); } else { term = resolveXhtmlTerm(value); } if (term == null) { documentContext.parser.warning(RDFa.UNRESOLVED_TERM, CAN_NOT_RESOLVE_TERM + value); throw new MalformedIriException(CAN_NOT_RESOLVE_TERM + value); } return term; } return resolveCurieOrIri(value, true); }
/** * Resolves TERMorCURIEorAbsIRI according to RDFa Core 1.1 section A * @param value value to be resolved * @return resource IRI * @throws org.semarglproject.ri.MalformedIriException if IRI can not be resolved */ private String resolveTermOrCurieOrAbsIri(String value) throws MalformedIriException { if (TERM_PATTERN.matcher(value).matches()) { if (vocab == null && documentContext.rdfaVersion > RDFa.VERSION_10 && "describedby".equals(value)) { return POWDER_DESCRIBED_BY; } String term; if (vocab != null) { term = vocab.resolveTerm(value); } else { term = resolveXhtmlTerm(value); } if (term == null) { documentContext.parser.warning(RDFa.UNRESOLVED_TERM, CAN_NOT_RESOLVE_TERM + value); throw new MalformedIriException(CAN_NOT_RESOLVE_TERM + value); } return term; } return resolveCurieOrIri(value, true); }
throw new MalformedIriException("Malformed IRI: " + curie);