You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@any23.apache.org by an...@apache.org on 2017/01/13 22:25:52 UTC
[13/25] any23 git commit: Fix Javadoc for ANY23-276
Fix Javadoc for ANY23-276
Project: http://git-wip-us.apache.org/repos/asf/any23/repo
Commit: http://git-wip-us.apache.org/repos/asf/any23/commit/e4632e4d
Tree: http://git-wip-us.apache.org/repos/asf/any23/tree/e4632e4d
Diff: http://git-wip-us.apache.org/repos/asf/any23/diff/e4632e4d
Branch: refs/heads/master
Commit: e4632e4dc2de2bb18ae4e5b8860b20a2128dad96
Parents: 445d13a
Author: Lewis John McGibbney <le...@gmail.com>
Authored: Mon Dec 26 11:11:16 2016 -0800
Committer: Lewis John McGibbney <le...@gmail.com>
Committed: Mon Dec 26 11:11:16 2016 -0800
----------------------------------------------------------------------
.../any23/extractor/rdfa/RDFa11Parser.java | 143 +++++++++++--------
.../any23/extractor/rdfa/XSLTStylesheet.java | 2 +
.../any23/rdf/Any23ValueFactoryWrapper.java | 10 +-
.../java/org/apache/any23/rdf/RDFUtils.java | 84 ++++++-----
.../MissingItemscopeAttributeValueRule.java | 2 +-
.../any23/writer/RDFWriterTripleHandler.java | 2 +-
6 files changed, 139 insertions(+), 104 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/any23/blob/e4632e4d/core/src/main/java/org/apache/any23/extractor/rdfa/RDFa11Parser.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/any23/extractor/rdfa/RDFa11Parser.java b/core/src/main/java/org/apache/any23/extractor/rdfa/RDFa11Parser.java
index 2b9c028..8f0cca5 100644
--- a/core/src/main/java/org/apache/any23/extractor/rdfa/RDFa11Parser.java
+++ b/core/src/main/java/org/apache/any23/extractor/rdfa/RDFa11Parser.java
@@ -100,20 +100,26 @@ public class RDFa11Parser {
private URL documentBase;
- private final Stack<IRIMapping> IRIMappingStack = new Stack<IRIMapping>();
+ private final Stack<IRIMapping> IRIMappingStack = new Stack<>();
- private final Stack<Vocabulary> vocabularyStack = new Stack<Vocabulary>();
+ private final Stack<Vocabulary> vocabularyStack = new Stack<>();
- private final List<IncompleteTriple> listOfIncompleteTriples = new ArrayList<IncompleteTriple>();
+ private final List<IncompleteTriple> listOfIncompleteTriples = new ArrayList<>();
- private final Stack<EvaluationContext> evaluationContextStack = new Stack<EvaluationContext>();
+ private final Stack<EvaluationContext> evaluationContextStack = new Stack<>();
+
+ public RDFa11Parser() {
+ //default constructor
+ }
protected static URL getDocumentBase(URL documentURL, Document document) throws MalformedURLException {
String base;
base = DomUtils.find(document, "/HTML/HEAD/BASE/@href"); // Non XHTML documents.
- if( ! "".equals(base) ) return new URL(base);
+ if( ! "".equals(base) )
+ return new URL(base);
base = DomUtils.find(document, "//*/h:head/h:base[position()=1]/@href"); // XHTML documents.
- if( ! "".equals(base) ) return new URL(base);
+ if( ! "".equals(base) )
+ return new URL(base);
return documentURL;
}
@@ -126,7 +132,7 @@ public class RDFa11Parser {
*/
protected static String[] extractPrefixSections(String prefixesDeclaration) {
final String[] parts = prefixesDeclaration.split("\\s");
- final List<String> out = new ArrayList<String>();
+ final List<String> out = new ArrayList<>();
int i = 0;
while(i < parts.length) {
final String part = parts[i];
@@ -136,7 +142,8 @@ public class RDFa11Parser {
}
if(part.charAt( part.length() -1 ) == IRI_PREFIX_SEPARATOR) {
i++;
- while(i < parts.length && parts[i].length() == 0) i++;
+ while(i < parts.length && parts[i].length() == 0)
+ i++;
out.add( part + (i < parts.length ? parts[i] : "") );
i++;
} else {
@@ -147,18 +154,20 @@ public class RDFa11Parser {
return out.toArray( new String[out.size()] );
}
- protected static boolean isAbsoluteIRI(String IRI) {
- return IRI.contains(IRI_SCHEMA_SEPARATOR);
+ protected static boolean isAbsoluteIRI(String iri) {
+ return iri.contains(IRI_SCHEMA_SEPARATOR);
}
protected static boolean isCURIE(String curie) {
if(curie == null) {
throw new NullPointerException("curie string cannot be null.");
}
- if(curie.trim().length() == 0) return false;
+ if(curie.trim().length() == 0)
+ return false;
// '[' PREFIX ':' VALUE ']'
- if( curie.charAt(0) != '[' || curie.charAt(curie.length() -1) != ']') return false;
+ if( curie.charAt(0) != '[' || curie.charAt(curie.length() -1) != ']')
+ return false;
int separatorIndex = curie.indexOf(CURIE_SEPARATOR);
return separatorIndex > 0 && curie.indexOf(CURIE_SEPARATOR, separatorIndex + 1) == -1;
}
@@ -168,16 +177,19 @@ public class RDFa11Parser {
}
protected static boolean isRelativeNode(Node node) {
- if( ATTRIBUTE_CSS.equals( DomUtils.readAttribute(node, TYPE_ATTRIBUTE) ) ) return false;
+ if( ATTRIBUTE_CSS.equals( DomUtils.readAttribute(node, TYPE_ATTRIBUTE) ) )
+ return false;
return DomUtils.hasAttribute(node, REL_ATTRIBUTE) || DomUtils.hasAttribute(node, REV_ATTRIBUTE);
}
// RDFa1.0[5.5.9.2]
protected static Literal getAsPlainLiteral(Node node, String currentLanguage) {
final String content = DomUtils.readAttribute(node, CONTENT_ATTRIBUTE, null);
- if(content != null) return RDFUtils.literal(content, currentLanguage);
+ if(content != null)
+ return RDFUtils.literal(content, currentLanguage);
- if(! node.hasChildNodes() ) return RDFUtils.literal("", currentLanguage);
+ if(! node.hasChildNodes() )
+ return RDFUtils.literal("", currentLanguage);
final String nodeTextContent = node.getTextContent();
return nodeTextContent == null ? null : RDFUtils.literal(nodeTextContent.trim(), currentLanguage);
@@ -185,7 +197,8 @@ public class RDFa11Parser {
protected static Literal getAsXMLLiteral(Node node) throws IOException, TransformerException {
final String datatype = DomUtils.readAttribute(node, DATATYPE_ATTRIBUTE, null);
- if(! XML_LITERAL_DATATYPE.equals(datatype)) return null;
+ if(! XML_LITERAL_DATATYPE.equals(datatype))
+ return null;
final String xmlSerializedNode = DomUtils.serializeToXML(node, false);
return RDFUtils.literal(xmlSerializedNode, RDF.XMLLITERAL);
@@ -193,12 +206,11 @@ public class RDFa11Parser {
protected static boolean isXMLNSDeclared(Document document) {
final String attributeValue = document.getDocumentElement().getAttribute(XMLNS_ATTRIBUTE);
- if(attributeValue.length() == 0) return false;
+ if(attributeValue.length() == 0)
+ return false;
return XMLNS_DEFAULT.equals(attributeValue);
}
- public RDFa11Parser() {}
-
/**
* <a href="http://www.w3.org/TR/rdfa-syntax/#s_model">RDFa Syntax - Processing Model</a>.
*
@@ -260,7 +272,8 @@ public class RDFa11Parser {
*/
protected void updateVocabulary(Node currentNode) {
final String vocabularyStr = DomUtils.readAttribute(currentNode, VOCAB_ATTRIBUTE, null);
- if(vocabularyStr == null) return;
+ if(vocabularyStr == null)
+ return;
try {
pushVocabulary(currentNode, RDFUtils.iri(vocabularyStr));
} catch (Exception e) {
@@ -275,7 +288,8 @@ public class RDFa11Parser {
*/
protected void updateIRIMapping(Node node) {
final NamedNodeMap attributes = node.getAttributes();
- if (null == attributes) return;
+ if (null == attributes)
+ return;
Node attribute;
final List<PrefixMap> prefixMapList = new ArrayList<PrefixMap>();
@@ -294,7 +308,8 @@ public class RDFa11Parser {
extractPrefixes(node, prefixMapList);
- if(prefixMapList.size() == 0) return;
+ if(prefixMapList.size() == 0)
+ return;
pushMappings(
node,
prefixMapList
@@ -321,16 +336,18 @@ public class RDFa11Parser {
* Resolves a <em>whitelist</em> separated list of <i>CURIE</i> or <i>URI</i>.
*
* @param n current node.
- * @param curieOrURIList list of CURIE/URI.
+ * @param curieOrIRIList list of CURIE/URI.
+ * @param termAllowed determine whether the term should be whitelisted.
* @return list of resolved URIs.
* @throws URISyntaxException if there is an error processing CURIE or URL
*/
protected IRI[] resolveCIRIeOrIRIList(Node n, String curieOrIRIList, boolean termAllowed)
throws URISyntaxException {
- if(curieOrIRIList == null || curieOrIRIList.trim().length() == 0) return new IRI[0];
+ if(curieOrIRIList == null || curieOrIRIList.trim().length() == 0)
+ return new IRI[0];
final String[] curieOrIRIListParts = curieOrIRIList.split("\\s");
- final List<IRI> result = new ArrayList<IRI>();
+ final List<IRI> result = new ArrayList<>();
Resource curieOrIRI;
for(String curieORIRIListPart : curieOrIRIListParts) {
curieOrIRI = resolveCURIEOrIRI(curieORIRIListPart, termAllowed);
@@ -346,22 +363,22 @@ public class RDFa11Parser {
/**
* Resolves a IRI string as IRI.
*
- * @param IRIStr (partial) IRI string to be resolved.
+ * @param iriStr (partial) IRI string to be resolved.
* @return the resolved IRI.
*/
- protected IRI resolveIRI(String IRIStr) {
+ protected IRI resolveIRI(String iriStr) {
return
- isAbsoluteIRI(IRIStr)
+ isAbsoluteIRI(iriStr)
?
- RDFUtils.iri(IRIStr)
+ RDFUtils.iri(iriStr)
:
- RDFUtils.iri( this.documentBase.toExternalForm(), IRIStr );
+ RDFUtils.iri( this.documentBase.toExternalForm(), iriStr );
}
/**
* Resolves a <i>CURIE</i> or <i>IRI</i> string.
*
- * @param curieOrIRI
+ * @param curieOrIRI individual of CURIE/URI to resolve
* @param termAllowed if <code>true</code> the resolution can be a term.
* @return the resolved resource.
*/
@@ -369,7 +386,8 @@ public class RDFa11Parser {
if( isCURIE(curieOrIRI) ) {
return resolveNamespacedIRI(curieOrIRI.substring(1, curieOrIRI.length() - 1), ResolutionPolicy.NSRequired);
}
- if(isAbsoluteIRI(curieOrIRI)) return resolveIRI(curieOrIRI);
+ if(isAbsoluteIRI(curieOrIRI))
+ return resolveIRI(curieOrIRI);
return resolveNamespacedIRI(
curieOrIRI,
termAllowed ? ResolutionPolicy.TermAllowed : ResolutionPolicy.NSNotRequired
@@ -420,7 +438,8 @@ public class RDFa11Parser {
* @return the current peek vocabulary.
*/
private IRI getVocabulary() {
- if(vocabularyStack.isEmpty()) return null;
+ if(vocabularyStack.isEmpty())
+ return null;
return vocabularyStack.peek().prefix;
}
@@ -430,7 +449,8 @@ public class RDFa11Parser {
* @param current
*/
private void popVocabulary(Node current) {
- if(vocabularyStack.isEmpty()) return;
+ if(vocabularyStack.isEmpty())
+ return;
if(DomUtils.isAncestorOf(current, vocabularyStack.peek().originatingNode)) {
vocabularyStack.pop();
}
@@ -442,7 +462,7 @@ public class RDFa11Parser {
* @param current
*/
private void purgeIncompleteTriples(Node current) {
- final List<IncompleteTriple> toBePurged = new ArrayList<IncompleteTriple>();
+ final List<IncompleteTriple> toBePurged = new ArrayList<>();
for(IncompleteTriple incompleteTriple : listOfIncompleteTriples) {
if( DomUtils.isAncestorOf(current, incompleteTriple.originatingNode, true) ) {
toBePurged.add(incompleteTriple);
@@ -482,9 +502,9 @@ public class RDFa11Parser {
try {
processNode(node, extractionResult);
} catch (Exception e) {
- if(logger.isDebugEnabled()) logger.debug("Error while processing node.", e);
+ if(logger.isDebugEnabled())
+ logger.debug("Error while processing node.", e);
reportError(node, e.getMessage());
- // e.printStackTrace();
}
depthFirstChildren(node.getChildNodes(), extractionResult);
purgeIncompleteTriples(node);
@@ -515,7 +535,6 @@ public class RDFa11Parser {
* @param extractionResult
*/
private void writeTriple(Resource s, IRI p, Value o, ExtractionResult extractionResult) {
- // if(logger.isTraceEnabled()) logger.trace(String.format("writeTriple(%s %s %s)" , s, p, o));
assert s != null : "subject is null.";
assert p != null : "predicate is null.";
assert o != null : "object is null.";
@@ -534,7 +553,6 @@ public class RDFa11Parser {
*/
// TODO: add references to the RDFa 1.1 algorithm.
private void processNode(Node currentElement, ExtractionResult extractionResult) throws Exception {
- // if(logger.isTraceEnabled()) logger.trace("processNode(" + DomUtils.getXPathForNode(currentElement) + ")");
final EvaluationContext currentEvaluationContext = getContext();
try {
if(
@@ -570,8 +588,10 @@ public class RDFa11Parser {
}
assert currentEvaluationContext.newSubject != null : "newSubject must be not null.";
*/
- if(currentEvaluationContext.newSubject == null) return;
- if(logger.isDebugEnabled()) logger.debug("newSubject: " + currentEvaluationContext.newSubject);
+ if(currentEvaluationContext.newSubject == null)
+ return;
+ if(logger.isDebugEnabled())
+ logger.debug("newSubject: " + currentEvaluationContext.newSubject);
// RDFa1.0[5.5.6] / RDFa1.1[7.5.8]
final IRI[] types = getTypes(currentElement);
@@ -680,7 +700,8 @@ public class RDFa11Parser {
*/
private void extractPrefixes(Node node, List<PrefixMap> prefixMapList) {
final String prefixAttribute = DomUtils.readAttribute(node, PREFIX_ATTRIBUTE, null);
- if(prefixAttribute == null) return;
+ if(prefixAttribute == null)
+ return;
final String[] prefixParts = extractPrefixSections(prefixAttribute);
for(String prefixPart : prefixParts) {
int splitPoint = prefixPart.indexOf(IRI_PREFIX_SEPARATOR);
@@ -689,21 +710,21 @@ public class RDFa11Parser {
reportError(node, String.format("Invalid prefix length in prefix attribute '%s'", prefixAttribute));
continue;
}
- final IRI IRI;
- final String IRIStr = prefixPart.substring(splitPoint + 1);
+ final IRI iri;
+ final String iriStr = prefixPart.substring(splitPoint + 1);
try {
- IRI = resolveIRI(IRIStr);
+ iri = resolveIRI(iriStr);
} catch (Exception e) {
reportError(
node,
String.format(
"Resolution of prefix '%s' defines an invalid IRI: '%s'",
- prefixAttribute, IRIStr
+ prefixAttribute, iriStr
)
);
continue;
}
- prefixMapList.add( new PrefixMap(prefix, IRI) );
+ prefixMapList.add( new PrefixMap(prefix, iri) );
}
}
@@ -715,7 +736,8 @@ public class RDFa11Parser {
*/
private void updateLanguage(Node node, EvaluationContext currentEvaluationContext) {
final String candidateLanguage = DomUtils.readAttribute(node, XML_LANG_ATTRIBUTE, null);
- if(candidateLanguage != null) currentEvaluationContext.language = candidateLanguage;
+ if(candidateLanguage != null)
+ currentEvaluationContext.language = candidateLanguage;
}
/**
@@ -825,7 +847,8 @@ public class RDFa11Parser {
private IRI[] getPredicate(Node node) throws URISyntaxException {
final String candidateIRI = DomUtils.readAttribute(node, PROPERTY_ATTRIBUTE, null);
- if(candidateIRI == null) return null;
+ if(candidateIRI == null)
+ return null;
return resolveCIRIeOrIRIList(node, candidateIRI, true);
}
@@ -855,7 +878,8 @@ public class RDFa11Parser {
Literal literal;
literal = getAsTypedLiteral(node);
- if(literal != null) return literal;
+ if(literal != null)
+ return literal;
literal = getAsXMLLiteral(node);
if(literal != null) {
@@ -864,14 +888,16 @@ public class RDFa11Parser {
}
literal = getAsPlainLiteral(node, currentEvaluationContext.language);
- if(literal != null) return literal;
+ if(literal != null)
+ return literal;
return null;
}
private static String getNodeContent(Node node) {
final String candidateContent = DomUtils.readAttribute(node, CONTENT_ATTRIBUTE, null);
- if(candidateContent != null) return candidateContent;
+ if(candidateContent != null)
+ return candidateContent;
return node.getTextContent();
}
@@ -893,9 +919,8 @@ public class RDFa11Parser {
}
private void pushMappings(Node sourceNode, List<PrefixMap> prefixMapList) {
- // logger.trace("pushMappings()");
- final Map<String, IRI> mapping = new HashMap<String, IRI>();
+ final Map<String, IRI> mapping = new HashMap<>();
for (PrefixMap prefixMap : prefixMapList) {
mapping.put(prefixMap.prefix, prefixMap.IRI);
}
@@ -903,10 +928,10 @@ public class RDFa11Parser {
}
private void popMappings(Node node) {
- if(IRIMappingStack.isEmpty()) return;
+ if(IRIMappingStack.isEmpty())
+ return;
final IRIMapping peek = IRIMappingStack.peek();
if( ! DomUtils.isAncestorOf(peek.sourceNode, node) ) {
- // logger.trace("popMappings()");
IRIMappingStack.pop();
}
}
@@ -1060,9 +1085,11 @@ public class RDFa11Parser {
}
public boolean produceTriple(Node resourceNode, Resource r, ExtractionResult extractionResult) {
- if( ! DomUtils.isAncestorOf(originatingNode, resourceNode, true) ) return false;
+ if( ! DomUtils.isAncestorOf(originatingNode, resourceNode, true) )
+ return false;
- if(r == null) throw new IllegalArgumentException();
+ if(r == null)
+ throw new IllegalArgumentException();
switch (direction) {
case Forward:
extractionResult.writeTriple(subject, predicate, r);
http://git-wip-us.apache.org/repos/asf/any23/blob/e4632e4d/core/src/main/java/org/apache/any23/extractor/rdfa/XSLTStylesheet.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/any23/extractor/rdfa/XSLTStylesheet.java b/core/src/main/java/org/apache/any23/extractor/rdfa/XSLTStylesheet.java
index 4a41089..e45d069 100644
--- a/core/src/main/java/org/apache/any23/extractor/rdfa/XSLTStylesheet.java
+++ b/core/src/main/java/org/apache/any23/extractor/rdfa/XSLTStylesheet.java
@@ -58,6 +58,7 @@ public class XSLTStylesheet {
* Applies the XSLT transformation
* @param document where apply the transformation
* @param output the {@link java.io.Writer} where write on
+ * @throws XSLTStylesheetException if there is an error applying the transformation
*/
public synchronized void applyTo(Document document, Writer output)
throws XSLTStylesheetException {
@@ -70,6 +71,7 @@ public class XSLTStylesheet {
* @param output the {@link java.io.Writer} where write on
* @param parameters the parameters to be passed to {@link Transformer}.
* Pass an empty {@link Map} if no parameters are foreseen.
+ * @throws XSLTStylesheetException if there is an error applying the transformation
*/
public synchronized void applyTo(Document document, Writer output,
Map<String, String> parameters) throws XSLTStylesheetException {
http://git-wip-us.apache.org/repos/asf/any23/blob/e4632e4d/core/src/main/java/org/apache/any23/rdf/Any23ValueFactoryWrapper.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/any23/rdf/Any23ValueFactoryWrapper.java b/core/src/main/java/org/apache/any23/rdf/Any23ValueFactoryWrapper.java
index 48dd4fc..c6efba8 100644
--- a/core/src/main/java/org/apache/any23/rdf/Any23ValueFactoryWrapper.java
+++ b/core/src/main/java/org/apache/any23/rdf/Any23ValueFactoryWrapper.java
@@ -36,7 +36,7 @@ import org.slf4j.LoggerFactory;
import javax.xml.datatype.XMLGregorianCalendar;
/**
- * Any23 specialization of the {@link org.openrdf.model.ValueFactory}.
+ * Any23 specialization of the {@link org.eclipse.rdf4j.model.ValueFactory}.
* It provides a wrapper to instantiate RDF objects.
*/
// TODO: Merge with RDFUtils.java
@@ -216,12 +216,12 @@ public class Any23ValueFactoryWrapper implements ValueFactory {
}
/**
- * @param uri
+ * @param iri IRI to fix
* @return a valid sesame IRI or null if any exception occurred
*/
- public IRI fixIRI(String uri) {
+ public IRI fixIRI(String iri) {
try {
- return wrappedFactory.createIRI(RDFUtils.fixIRIWithException(uri));
+ return wrappedFactory.createIRI(RDFUtils.fixIRIWithException(iri));
} catch (Exception e) {
reportError(e);
return null;
@@ -232,7 +232,7 @@ public class Any23ValueFactoryWrapper implements ValueFactory {
* Helper method to conditionally add a schema to a URI unless it's there, or null if link is empty.
* @param link string representation of the URI
* @param defaultSchema schema to add the URI
- * @return a valid {@link org.openrdf.model.URI}
+ * @return a valid sesame IRI or null if any exception occurred
*/
public IRI fixLink(String link, String defaultSchema) {
if (link == null) return null;
http://git-wip-us.apache.org/repos/asf/any23/blob/e4632e4d/core/src/main/java/org/apache/any23/rdf/RDFUtils.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/any23/rdf/RDFUtils.java b/core/src/main/java/org/apache/any23/rdf/RDFUtils.java
index c3ad8ec..bbfe5ec 100644
--- a/core/src/main/java/org/apache/any23/rdf/RDFUtils.java
+++ b/core/src/main/java/org/apache/any23/rdf/RDFUtils.java
@@ -23,10 +23,8 @@ import org.eclipse.rdf4j.model.Literal;
import org.eclipse.rdf4j.model.Resource;
import org.eclipse.rdf4j.model.Statement;
import org.eclipse.rdf4j.model.URI;
-import org.eclipse.rdf4j.model.IRI;
import org.eclipse.rdf4j.model.Value;
import org.eclipse.rdf4j.model.ValueFactory;
-import org.eclipse.rdf4j.model.impl.SimpleIRI;
import org.eclipse.rdf4j.model.impl.SimpleValueFactory;
import org.eclipse.rdf4j.model.vocabulary.RDF;
import org.eclipse.rdf4j.rio.RDFFormat;
@@ -65,16 +63,16 @@ public class RDFUtils {
private static final ValueFactory valueFactory = SimpleValueFactory.getInstance();
/**
- * Fixes typical errors in an absolute IRI, such as unescaped spaces.
+ * Fixes typical errors in an absolute org.eclipse.rdf4j.model.IRI, such as unescaped spaces.
*
- * @param uri An absolute IRI, can have typical syntax errors
- * @return An absolute IRI that is valid against the IRI syntax
- * @throws IllegalArgumentException if IRI is not fixable
+ * @param uri An absolute org.eclipse.rdf4j.model.IRI, can have typical syntax errors
+ * @return An absolute org.eclipse.rdf4j.model.IRI that is valid against the org.eclipse.rdf4j.model.IRI syntax
+ * @throws IllegalArgumentException if org.eclipse.rdf4j.model.IRI is not fixable
*/
public static String fixAbsoluteIRI(String uri) {
String fixed = fixIRIWithException(uri);
- if (!fixed.matches("[a-zA-Z0-9]+:/.*")) throw new IllegalArgumentException("not a absolute IRI: " + uri);
- // Add trailing slash if IRI has only authority but no path.
+ if (!fixed.matches("[a-zA-Z0-9]+:/.*")) throw new IllegalArgumentException("not a absolute org.eclipse.rdf4j.model.IRI: " + uri);
+ // Add trailing slash if org.eclipse.rdf4j.model.IRI has only authority but no path.
if (fixed.matches("https?://[a-zA-Z0-9.-]+(:[0-9+])?")) {
fixed = fixed + "/";
}
@@ -131,7 +129,7 @@ public class RDFUtils {
* @return the unescaped string.
*/
public static String fixIRIWithException(String unescapedIRI) {
- if (unescapedIRI == null) throw new IllegalArgumentException("IRI was null");
+ if (unescapedIRI == null) throw new IllegalArgumentException("org.eclipse.rdf4j.model.IRI was null");
// Remove starting and ending whitespace
String escapedIRI = unescapedIRI.trim();
@@ -150,11 +148,11 @@ public class RDFUtils {
//Drop the triple if it matches this regex (only protocol): ^[a-zA-Z0-9]+:/?/?$
if (escapedIRI.matches("^[a-zA-Z0-9]+:/?/?$"))
- throw new IllegalArgumentException("no authority in IRI: " + unescapedIRI);
+ throw new IllegalArgumentException("no authority in org.eclipse.rdf4j.model.IRI: " + unescapedIRI);
//Drop the triple if it matches this regex: ^javascript:
if (escapedIRI.matches("^javascript:"))
- throw new IllegalArgumentException("IRI starts with javascript: " + unescapedIRI);
+ throw new IllegalArgumentException("org.eclipse.rdf4j.model.IRI starts with javascript: " + unescapedIRI);
// stripHTML
// escapedIRI = escapedIRI.replaceAll("\\<.*?\\>", "");
@@ -164,45 +162,50 @@ public class RDFUtils {
//Drop the triple if any of these appear in the URL: <>[]|*{}"<>\
if (escapedIRI.matches("[<>\\[\\]|\\*\\{\\}\"\\\\]"))
- throw new IllegalArgumentException("Invalid character in IRI: " + unescapedIRI);
+ throw new IllegalArgumentException("Invalid character in org.eclipse.rdf4j.model.IRI: " + unescapedIRI);
return escapedIRI;
}
/**
- * Creates a {@link IRI}.
- * @param uri string representation of the {@link IRI}
- * @return a valid {@link IRI}
+ * Creates a {@link org.eclipse.rdf4j.model.IRI}.
+ * @param uri string representation of the {@link org.eclipse.rdf4j.model.IRI}
+ * @return a valid {@link org.eclipse.rdf4j.model.IRI}
* @deprecated Use {@link #iri(String)} instead.
*/
@Deprecated
- public static IRI uri(String uri) {
+ public static org.eclipse.rdf4j.model.IRI uri(String uri) {
return iri(uri);
}
/**
- * Creates a {@link IRI}.
- * @param namespace a base namespace for the {@link IRI}
- * @param localName a local name to associate with the namespace
- * @return a valid {@link IRI}
+ * Creates a {@link org.eclipse.rdf4j.model.IRI}.
+ * @param iri a base string for the {@link org.eclipse.rdf4j.model.IRI}
+ * @return a valid {@link org.eclipse.rdf4j.model.IRI}
*/
- public static IRI iri(String uri) {
- return valueFactory.createIRI(uri);
+ public static org.eclipse.rdf4j.model.IRI iri(String iri) {
+ return valueFactory.createIRI(iri);
}
/**
- * Creates a {@link IRI}.
+ * Creates a {@link org.eclipse.rdf4j.model.IRI}.
* @deprecated Use {@link #iri(String, String)} instead.
+ * @param namespace a base namespace for the {@link org.eclipse.rdf4j.model.IRI}
+ * @param localName a local name to associate with the namespace
+ * @return a valid {@link org.eclipse.rdf4j.model.IRI}
*/
@Deprecated
- public static IRI uri(String namespace, String localName) {
+ public static org.eclipse.rdf4j.model.IRI uri(String namespace, String localName) {
return valueFactory.createIRI(namespace, localName);
}
/**
- * Creates a {@link IRI}.
+ * Creates a {@link org.eclipse.rdf4j.model.IRI}.
+ * @param namespace a base namespace for the {@link org.eclipse.rdf4j.model.IRI}
+ * @param localName a local name to associate with the namespace
+ * @return a valid {@link org.eclipse.rdf4j.model.IRI}
*/
- public static IRI iri(String namespace, String localName) {
+ public static org.eclipse.rdf4j.model.IRI iri(String namespace, String localName) {
return valueFactory.createIRI(namespace, localName);
}
@@ -300,7 +303,7 @@ public class RDFUtils {
* {@link org.eclipse.rdf4j.model.Literal}
* @param datatype the datatype to associate with the namespace.
* @return valid {@link org.eclipse.rdf4j.model.Literal}
- * @deprecated Use {@link #literal(String, IRI)} instead.
+ * @deprecated Use {@link #literal(String, org.eclipse.rdf4j.model.IRI)} instead.
*/
@Deprecated
public static Literal literal(String s, URI datatype) {
@@ -309,8 +312,12 @@ public class RDFUtils {
/**
* Creates a {@link Literal}.
+ * @param s string representation of the base namespace for the
+ * {@link org.eclipse.rdf4j.model.Literal}
+ * @param datatype the datatype to associate with the namespace.
+ * @return valid {@link org.eclipse.rdf4j.model.Literal}
*/
- public static Literal literal(String s, IRI datatype) {
+ public static Literal literal(String s, org.eclipse.rdf4j.model.IRI datatype) {
return valueFactory.createLiteral(s, datatype);
}
@@ -350,7 +357,7 @@ public class RDFUtils {
* @param o object {@link org.eclipse.rdf4j.model.Value}
* @return valid {@link org.eclipse.rdf4j.model.Statement}
*/
- public static Statement triple(Resource s, IRI p, Value o) {
+ public static Statement triple(Resource s, org.eclipse.rdf4j.model.IRI p, Value o) {
return valueFactory.createStatement(s, p, o);
}
@@ -363,7 +370,7 @@ public class RDFUtils {
* @return a statement instance.
*/
public static Statement triple(String s, String p, String o) {
- return valueFactory.createStatement((Resource) toValue(s), (IRI) toValue(p), toValue(o));
+ return valueFactory.createStatement((Resource) toValue(s), (org.eclipse.rdf4j.model.IRI) toValue(p), toValue(o));
}
/**
@@ -374,7 +381,7 @@ public class RDFUtils {
* @param g quad resource
* @return a statement instance.
*/
- public static Statement quad(Resource s, IRI p, Value o, Resource g) {
+ public static Statement quad(Resource s, org.eclipse.rdf4j.model.IRI p, Value o, Resource g) {
return valueFactory.createStatement(s, p, o, g);
}
@@ -387,7 +394,7 @@ public class RDFUtils {
* @return a statement instance.
*/
public static Statement quad(String s, String p, String o, String g) {
- return valueFactory.createStatement((Resource) toValue(s), (IRI) toValue(p), toValue(o), (Resource) toValue(g));
+ return valueFactory.createStatement((Resource) toValue(s), (org.eclipse.rdf4j.model.IRI) toValue(p), toValue(o), (Resource) toValue(g));
}
/**
@@ -411,7 +418,6 @@ public class RDFUtils {
* Returns all the available {@link RDFFormat}s.
*
* @return an unmodifiable collection of formats.
- * @see org.openrdf.rio.RDFFormat#values()
*/
public static Collection<RDFFormat> getFormats() {
return RDFParserRegistry.getInstance().getKeys();
@@ -469,7 +475,7 @@ public class RDFUtils {
* specified parser <code>p</code> using <code>baseIRI</code>.
*
* @param format input format type.
- * @param is input stream containing <code>RDF</data>.
+ * @param is input stream containing <code>RDF</code>.
* @param baseIRI base uri.
* @return list of statements detected within the input stream.
* @throws RDFHandlerException if there is an error handling the RDF
@@ -490,7 +496,7 @@ public class RDFUtils {
/**
* Parses the content of <code>is</code> input stream with the
- * specified parser <code>p</code> using <code>''</code> as base IRI.
+ * specified parser <code>p</code> using <code>''</code> as base org.eclipse.rdf4j.model.IRI.
*
* @param format input format type.
* @param is input stream containing <code>RDF</code>.
@@ -506,7 +512,7 @@ public class RDFUtils {
/**
* Parses the content of <code>in</code> string with the
- * specified parser <code>p</code> using <code>''</code> as base IRI.
+ * specified parser <code>p</code> using <code>''</code> as base org.eclipse.rdf4j.model.IRI.
*
* @param format input format type.
* @param in input string containing <code>RDF</code>.
@@ -527,8 +533,8 @@ public class RDFUtils {
* @param resource resource name.
* @return the statements declared within the resource file.
* @throws java.io.IOException if an error occurs while reading file.
- * @throws org.openrdf.rio.RDFHandlerException if an error occurs while parsing file.
- * @throws org.openrdf.rio.RDFParseException if an error occurs while parsing file.
+ * @throws org.eclipse.rdf4j.rio.RDFHandlerException if an error occurs while parsing file.
+ * @throws org.eclipse.rdf4j.rio.RDFParseException if an error occurs while parsing file.
*/
public static Statement[] parseRDF(String resource) throws RDFHandlerException, IOException, RDFParseException {
final int extIndex = resource.lastIndexOf(".");
@@ -542,7 +548,7 @@ public class RDFUtils {
/**
* Checks if <code>href</code> is absolute or not.
*
- * @param href candidate IRI.
+ * @param href candidate org.eclipse.rdf4j.model.IRI.
* @return <code>true</code> if <code>href</code> is absolute,
* <code>false</code> otherwise.
*/
http://git-wip-us.apache.org/repos/asf/any23/blob/e4632e4d/core/src/main/java/org/apache/any23/validator/rule/MissingItemscopeAttributeValueRule.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/any23/validator/rule/MissingItemscopeAttributeValueRule.java b/core/src/main/java/org/apache/any23/validator/rule/MissingItemscopeAttributeValueRule.java
index b0ecd9b..67d44b2 100644
--- a/core/src/main/java/org/apache/any23/validator/rule/MissingItemscopeAttributeValueRule.java
+++ b/core/src/main/java/org/apache/any23/validator/rule/MissingItemscopeAttributeValueRule.java
@@ -29,7 +29,7 @@ import org.w3c.dom.Node;
* This fixes missing attribute values for the 'itemscope' attribute
* Typically when such a snippet of XHTML is fed through the
* {@link org.apache.any23.extractor.rdfa.RDFa11Extractor}, and
- * subsequently to Sesame's {@link org.semarglproject.sesame.rdf.rdfa.SesameRDFaParser},
+ * subsequently to Sesame's SesameRDFaParser,
* it will result in the following behavior.
* <pre>
* {@code
http://git-wip-us.apache.org/repos/asf/any23/blob/e4632e4d/core/src/main/java/org/apache/any23/writer/RDFWriterTripleHandler.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/any23/writer/RDFWriterTripleHandler.java b/core/src/main/java/org/apache/any23/writer/RDFWriterTripleHandler.java
index 1c14ffb..2df55e0 100644
--- a/core/src/main/java/org/apache/any23/writer/RDFWriterTripleHandler.java
+++ b/core/src/main/java/org/apache/any23/writer/RDFWriterTripleHandler.java
@@ -27,7 +27,7 @@ import org.eclipse.rdf4j.rio.RDFWriter;
/**
* A {@link TripleHandler} that writes
- * triples to a Sesame {@link org.openrdf.rio.RDFWriter},
+ * triples to a Sesame {@link org.eclipse.rdf4j.rio.RDFWriter},
* eg for serialization using one of Sesame's writers.
*
* @author Richard Cyganiak (richard@cyganiak.de)