You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@jena.apache.org by GitBox <gi...@apache.org> on 2022/07/05 22:47:46 UTC
[GitHub] [jena] AtesComp opened a new pull request, #1430: Code Review: Checker.java
AtesComp opened a new pull request, #1430:
URL: https://github.com/apache/jena/pull/1430
GitHub issue resolved # NONE
Pull request Description:
Code review of Checker.java revealed several significant improvements for documentation and code.
----
- [ ] Tests are included.
- [ ] Documentation change and updates are provided for the [Apache Jena website](https://github.com/apache/jena-site/)
- [ ] Commits have been squashed to remove intermediate development commit messages.
- [ ] Key commit messages start with the issue number (GH-xxxx or JENA-xxxx)
By submitting this pull request, I acknowledge that I am making a contribution to the Apache Software Foundation under the terms and conditions of the [Contributor's Agreement](https://www.apache.org/licenses/contributor-agreements.html).
----
See the [Apache Jena "Contributing" guide](https://github.com/apache/jena/blob/main/CONTRIBUTING.md).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
[GitHub] [jena] afs merged pull request #1430: Code Review: Checker.java
Posted by GitBox <gi...@apache.org>.
afs merged PR #1430:
URL: https://github.com/apache/jena/pull/1430
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
[GitHub] [jena] AtesComp commented on a diff in pull request #1430: Code Review: Checker.java
Posted by GitBox <gi...@apache.org>.
AtesComp commented on code in PR #1430:
URL: https://github.com/apache/jena/pull/1430#discussion_r916226729
##########
jena-arq/src/main/java/org/apache/jena/riot/system/Checker.java:
##########
@@ -40,19 +40,30 @@
/**
* Functions for checking nodes, triples and quads.
* <p>
- * If the errorHandler is null, use the system wide handler.
+ * The check functions have two basic signatures:<br>
+ * 1. "<tt>check...(<i>object</i>)</tt>"
+ * 2. "<tt>check...(<i>object, errorHandler, line, col</i>)</tt>"
+ * The first type are for boolean testing and do not generate output. They call the
+ * second type with default values for the last 3 parameters: nullErrorHandler, -1L, -1
+ * The second type are for boolean testing and optionally generate error handling
+ * output.
* <p>
- * If the errorHandler line/columns numbers are -1, -1, messages do not include them.
+ * Parameters:<br>
+ * {@link ErrorHandler} errorHandler - the errorHandler for output. If the errorHandler
+ * is null, use the system wide handler.<br>
+ * {@link long} line - code line number generating the check.<br>
Review Comment:
Yep, copy error. Working too fast. I'll also convert to the following format:
`* @param param1 Description of param1`
with `@link` embeds when appropriate.
As per [this doc](https://www.oracle.com/technical-resources/articles/java/javadoc-tool.html)...unless you want to follow another standard.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
[GitHub] [jena] afs commented on a diff in pull request #1430: Code Review: Checker.java
Posted by GitBox <gi...@apache.org>.
afs commented on code in PR #1430:
URL: https://github.com/apache/jena/pull/1430#discussion_r915852467
##########
jena-arq/src/main/java/org/apache/jena/riot/system/Checker.java:
##########
@@ -40,19 +40,30 @@
/**
* Functions for checking nodes, triples and quads.
* <p>
- * If the errorHandler is null, use the system wide handler.
+ * The check functions have two basic signatures:<br>
+ * 1. "<tt>check...(<i>object</i>)</tt>"
+ * 2. "<tt>check...(<i>object, errorHandler, line, col</i>)</tt>"
+ * The first type are for boolean testing and do not generate output. They call the
+ * second type with default values for the last 3 parameters: nullErrorHandler, -1L, -1
+ * The second type are for boolean testing and optionally generate error handling
+ * output.
* <p>
- * If the errorHandler line/columns numbers are -1, -1, messages do not include them.
+ * Parameters:<br>
+ * {@link ErrorHandler} errorHandler - the errorHandler for output. If the errorHandler
+ * is null, use the system wide handler.<br>
+ * {@link long} line - code line number generating the check.<br>
+ * {@link long} col - code column number generating the check.<br>
+ * If the errorHandler is null, the line and column numbers not used.
* <p>
- * Operations "<tt>checkXXX(<i>item</i>)</tt>" are for boolean testing
- * and do not generate output.
+ * The functions "<tt>check...(<i>object</i>)</tt>" are for boolean testing and do not
+ * generate output.
*/
public class Checker {
/** A node -- must be concrete node or a variable. */
public static boolean check(Node node) {
- return check(node, nullErrorHandler, -1, -1);
+ return check(node, nullErrorHandler, -1L, -1L);
Review Comment:
Side note: `-1` is converted by the compiler to `-1L` to match the signature so this is zero runtime cost.
Leaving them changed to `-1L` is OK.
##########
jena-arq/src/main/java/org/apache/jena/riot/system/Checker.java:
##########
@@ -206,36 +217,45 @@ public static boolean checkLiteral(String lexicalForm, String lang, ErrorHandler
public static boolean checkLiteral(String lexicalForm, String lang, RDFDatatype datatype, ErrorHandler errorHandler, long line,
long col) {
- boolean hasLang = lang != null && !lang.equals("");
- if ( !hasLang ) {
- // Datatype check (and RDF 1.0 simple literals are always well formed)
- if ( datatype != null )
- return validateByDatatype(lexicalForm, datatype, errorHandler, line, col);
- return true;
- }
-
- // Has a language.
- if ( JenaRuntime.isRDF11 ) {
- if ( datatype != null && !Objects.equals(datatype.getURI(), NodeConst.rdfLangString.getURI()) ) {
- errorHandler(errorHandler).error("Literal has language but wrong datatype", line, col);
- return false;
+ boolean hasLang = ( lang != null && !lang.isEmpty() );
+ boolean hasDatatype = datatype != null;
+
+ // Has language...
+ if ( hasLang ) {
+ // Has datatype (generally, a problem)...
+ if ( hasDatatype) {
+ // Jena is using RDF 1.1...
+ if ( JenaRuntime.isRDF11 ) {
+ // The datatype is NOT "rdf:langString"...
+ if ( datatype.getURI() != NodeConst.rdfLangString.getURI() ) {
Review Comment:
Use `Objects.equals` here. Strings should not be compared with `=` or `!=` which is "same object" not "same string".
##########
jena-arq/src/main/java/org/apache/jena/riot/system/Checker.java:
##########
@@ -206,36 +217,45 @@ public static boolean checkLiteral(String lexicalForm, String lang, ErrorHandler
public static boolean checkLiteral(String lexicalForm, String lang, RDFDatatype datatype, ErrorHandler errorHandler, long line,
long col) {
- boolean hasLang = lang != null && !lang.equals("");
- if ( !hasLang ) {
- // Datatype check (and RDF 1.0 simple literals are always well formed)
- if ( datatype != null )
- return validateByDatatype(lexicalForm, datatype, errorHandler, line, col);
- return true;
- }
-
- // Has a language.
- if ( JenaRuntime.isRDF11 ) {
- if ( datatype != null && !Objects.equals(datatype.getURI(), NodeConst.rdfLangString.getURI()) ) {
- errorHandler(errorHandler).error("Literal has language but wrong datatype", line, col);
- return false;
+ boolean hasLang = ( lang != null && !lang.isEmpty() );
+ boolean hasDatatype = datatype != null;
+
+ // Has language...
+ if ( hasLang ) {
+ // Has datatype (generally, a problem)...
Review Comment:
The comment implies it is common but as node are normally created by the parsers, it isn't.
"If there is a language, the data type must be rdf:langString."
##########
jena-arq/src/main/java/org/apache/jena/riot/system/Checker.java:
##########
@@ -40,19 +40,30 @@
/**
* Functions for checking nodes, triples and quads.
* <p>
- * If the errorHandler is null, use the system wide handler.
+ * The check functions have two basic signatures:<br>
+ * 1. "<tt>check...(<i>object</i>)</tt>"
+ * 2. "<tt>check...(<i>object, errorHandler, line, col</i>)</tt>"
+ * The first type are for boolean testing and do not generate output. They call the
+ * second type with default values for the last 3 parameters: nullErrorHandler, -1L, -1
+ * The second type are for boolean testing and optionally generate error handling
+ * output.
* <p>
- * If the errorHandler line/columns numbers are -1, -1, messages do not include them.
+ * Parameters:<br>
+ * {@link ErrorHandler} errorHandler - the errorHandler for output. If the errorHandler
+ * is null, use the system wide handler.<br>
+ * {@link long} line - code line number generating the check.<br>
Review Comment:
`long` isn't a class so the link does not work (I get a warning in Eclipse). `Long` would be incorrect.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
[GitHub] [jena] AtesComp commented on a diff in pull request #1430: Code Review: Checker.java
Posted by GitBox <gi...@apache.org>.
AtesComp commented on code in PR #1430:
URL: https://github.com/apache/jena/pull/1430#discussion_r916194458
##########
jena-arq/src/main/java/org/apache/jena/riot/system/Checker.java:
##########
@@ -40,19 +40,30 @@
/**
* Functions for checking nodes, triples and quads.
* <p>
- * If the errorHandler is null, use the system wide handler.
+ * The check functions have two basic signatures:<br>
+ * 1. "<tt>check...(<i>object</i>)</tt>"
+ * 2. "<tt>check...(<i>object, errorHandler, line, col</i>)</tt>"
+ * The first type are for boolean testing and do not generate output. They call the
+ * second type with default values for the last 3 parameters: nullErrorHandler, -1L, -1
+ * The second type are for boolean testing and optionally generate error handling
+ * output.
* <p>
- * If the errorHandler line/columns numbers are -1, -1, messages do not include them.
+ * Parameters:<br>
+ * {@link ErrorHandler} errorHandler - the errorHandler for output. If the errorHandler
+ * is null, use the system wide handler.<br>
+ * {@link long} line - code line number generating the check.<br>
+ * {@link long} col - code column number generating the check.<br>
+ * If the errorHandler is null, the line and column numbers not used.
* <p>
- * Operations "<tt>checkXXX(<i>item</i>)</tt>" are for boolean testing
- * and do not generate output.
+ * The functions "<tt>check...(<i>object</i>)</tt>" are for boolean testing and do not
+ * generate output.
*/
public class Checker {
/** A node -- must be concrete node or a variable. */
public static boolean check(Node node) {
- return check(node, nullErrorHandler, -1, -1);
+ return check(node, nullErrorHandler, -1L, -1L);
Review Comment:
Yeah, I thought that, since it was explicit in some places, just make them consistent.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
[GitHub] [jena] AtesComp commented on a diff in pull request #1430: Code Review: Checker.java
Posted by GitBox <gi...@apache.org>.
AtesComp commented on code in PR #1430:
URL: https://github.com/apache/jena/pull/1430#discussion_r916200257
##########
jena-arq/src/main/java/org/apache/jena/riot/system/Checker.java:
##########
@@ -206,36 +217,45 @@ public static boolean checkLiteral(String lexicalForm, String lang, ErrorHandler
public static boolean checkLiteral(String lexicalForm, String lang, RDFDatatype datatype, ErrorHandler errorHandler, long line,
long col) {
- boolean hasLang = lang != null && !lang.equals("");
- if ( !hasLang ) {
- // Datatype check (and RDF 1.0 simple literals are always well formed)
- if ( datatype != null )
- return validateByDatatype(lexicalForm, datatype, errorHandler, line, col);
- return true;
- }
-
- // Has a language.
- if ( JenaRuntime.isRDF11 ) {
- if ( datatype != null && !Objects.equals(datatype.getURI(), NodeConst.rdfLangString.getURI()) ) {
- errorHandler(errorHandler).error("Literal has language but wrong datatype", line, col);
- return false;
+ boolean hasLang = ( lang != null && !lang.isEmpty() );
+ boolean hasDatatype = datatype != null;
+
+ // Has language...
+ if ( hasLang ) {
+ // Has datatype (generally, a problem)...
+ if ( hasDatatype) {
+ // Jena is using RDF 1.1...
+ if ( JenaRuntime.isRDF11 ) {
+ // The datatype is NOT "rdf:langString"...
+ if ( datatype.getURI() != NodeConst.rdfLangString.getURI() ) {
Review Comment:
Indeed! I'll update to: ( ! datatype.getURI().equals( NodeConst.rdfLangString.getURI() )
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
[GitHub] [jena] AtesComp commented on a diff in pull request #1430: Code Review: Checker.java
Posted by GitBox <gi...@apache.org>.
AtesComp commented on code in PR #1430:
URL: https://github.com/apache/jena/pull/1430#discussion_r916260961
##########
jena-arq/src/main/java/org/apache/jena/riot/system/Checker.java:
##########
@@ -206,36 +217,45 @@ public static boolean checkLiteral(String lexicalForm, String lang, ErrorHandler
public static boolean checkLiteral(String lexicalForm, String lang, RDFDatatype datatype, ErrorHandler errorHandler, long line,
long col) {
- boolean hasLang = lang != null && !lang.equals("");
- if ( !hasLang ) {
- // Datatype check (and RDF 1.0 simple literals are always well formed)
- if ( datatype != null )
- return validateByDatatype(lexicalForm, datatype, errorHandler, line, col);
- return true;
- }
-
- // Has a language.
- if ( JenaRuntime.isRDF11 ) {
- if ( datatype != null && !Objects.equals(datatype.getURI(), NodeConst.rdfLangString.getURI()) ) {
- errorHandler(errorHandler).error("Literal has language but wrong datatype", line, col);
- return false;
+ boolean hasLang = ( lang != null && !lang.isEmpty() );
+ boolean hasDatatype = datatype != null;
+
+ // Has language...
+ if ( hasLang ) {
+ // Has datatype (generally, a problem)...
Review Comment:
Yeah, bad wording on my part. I'll update the commenting throughout checkLiteral().
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org