diff --git a/vlog4j-graal/src/main/java/org/semanticweb/vlog4j/graal/GraalToVLog4JModelConverter.java b/vlog4j-graal/src/main/java/org/semanticweb/vlog4j/graal/GraalToVLog4JModelConverter.java index bec53d7fb..fe44ed0b9 100644 --- a/vlog4j-graal/src/main/java/org/semanticweb/vlog4j/graal/GraalToVLog4JModelConverter.java +++ b/vlog4j-graal/src/main/java/org/semanticweb/vlog4j/graal/GraalToVLog4JModelConverter.java @@ -93,8 +93,8 @@ public static Fact convertAtomToFact(final fr.lirmm.graphik.graal.api.core.Atom * Atoms} into a {@link List} of {@link PositiveLiteral VLog4J * PositiveLiterals}. * - * @param literals A {@link List} of {@link fr.lirmm.graphik.graal.api.core.Atom - * Graal Atoms}. + * @param literals list of {@link fr.lirmm.graphik.graal.api.core.Atom Graal + * Atoms}. * @return A {@link List} of {@link PositiveLiteral VLog4J PositiveLiterals}. */ public static List convertAtoms(final List atoms) { @@ -109,8 +109,8 @@ public static List convertAtoms(final List convertAtomsToFacts(final List atoms) { diff --git a/vlog4j-parser/src/main/java/org/semanticweb/vlog4j/parser/ParserConfiguration.java b/vlog4j-parser/src/main/java/org/semanticweb/vlog4j/parser/ParserConfiguration.java index a3b16dcba..770c7fd16 100644 --- a/vlog4j-parser/src/main/java/org/semanticweb/vlog4j/parser/ParserConfiguration.java +++ b/vlog4j-parser/src/main/java/org/semanticweb/vlog4j/parser/ParserConfiguration.java @@ -26,6 +26,7 @@ import org.apache.commons.lang3.Validate; import org.semanticweb.vlog4j.core.model.api.Constant; import org.semanticweb.vlog4j.core.model.api.DataSource; +import org.semanticweb.vlog4j.core.model.api.DataSourceDeclaration; import org.semanticweb.vlog4j.core.model.api.PrefixDeclarations; import org.semanticweb.vlog4j.core.model.implementation.Expressions; import org.semanticweb.vlog4j.parser.javacc.SubParserFactory; @@ -39,12 +40,12 @@ public class ParserConfiguration { /** * The registered data sources. */ - private HashMap dataSources = new HashMap<>(); + private final HashMap dataSources = new HashMap<>(); /** * The registered datatypes. */ - private HashMap datatypes = new HashMap<>(); + private final HashMap datatypes = new HashMap<>(); /** * Register a new (type of) Data Source. @@ -53,8 +54,8 @@ public class ParserConfiguration { * production of the rules grammar, corresponding to some {@link DataSource} * type. * - * @see <"https://github.com/knowsys/vlog4j/wiki/Rule-syntax-grammar"> for the - * grammar. + * @see + * the grammar. * * @param name Name of the data source, as it appears in the declaring * directive. @@ -63,9 +64,9 @@ public class ParserConfiguration { * @throws IllegalArgumentException if the provided name is already registered. * @return this */ - public ParserConfiguration registerDataSource(String name, DataSourceDeclarationHandler handler) + public ParserConfiguration registerDataSource(final String name, final DataSourceDeclarationHandler handler) throws IllegalArgumentException { - Validate.isTrue(!dataSources.containsKey(name), "The Data Source \"%s\" is already registered.", name); + Validate.isTrue(!this.dataSources.containsKey(name), "The Data Source \"%s\" is already registered.", name); this.dataSources.put(name, handler); return this; @@ -87,9 +88,9 @@ public ParserConfiguration registerDataSource(String name, DataSourceDeclaration * * @return the Data Source instance. */ - public DataSource parseDataSourceSpecificPartOfDataSourceDeclaration(String name, List args, + public DataSource parseDataSourceSpecificPartOfDataSourceDeclaration(final String name, final List args, final SubParserFactory subParserFactory) throws ParsingException { - DataSourceDeclarationHandler handler = dataSources.get(name); + final DataSourceDeclarationHandler handler = this.dataSources.get(name); if (handler == null) { throw new ParsingException("Data source \"" + name + "\" is not known."); @@ -104,8 +105,7 @@ public DataSource parseDataSourceSpecificPartOfDataSourceDeclaration(String name * @param lexicalForm the (unescaped) lexical form of the constant. * @param languageTag the language tag, or null if not present. * @param the datatype, or null if not present. - * @note At most one of {@code languageTag} and {@code datatype} may be - * non-null. + * @pre At most one of {@code languageTag} and {@code datatype} may be non-null. * * @throws ParsingException when the lexical form is invalid for the * given data type. @@ -113,21 +113,21 @@ public DataSource parseDataSourceSpecificPartOfDataSourceDeclaration(String name * {@code datatype} are non-null. * @return the {@link Constant} corresponding to the given arguments. */ - public Constant parseConstant(String lexicalForm, String languageTag, String datatype) + public Constant parseConstant(final String lexicalForm, final String languageTag, final String datatype) throws ParsingException, IllegalArgumentException { - Validate.isTrue(languageTag == null || datatype == null, + Validate.isTrue((languageTag == null) || (datatype == null), "A constant with a language tag may not explicitly specify a data type."); if (languageTag != null) { return Expressions.makeLanguageStringConstant(lexicalForm, languageTag); } else { - return parseDatatypeConstant(lexicalForm, datatype); + return this.parseDatatypeConstant(lexicalForm, datatype); } } - private Constant parseDatatypeConstant(String lexicalForm, String datatype) throws ParsingException { - String type = ((datatype != null) ? datatype : PrefixDeclarations.XSD_STRING); - DatatypeConstantHandler handler = datatypes.get(type); + private Constant parseDatatypeConstant(final String lexicalForm, final String datatype) throws ParsingException { + final String type = ((datatype != null) ? datatype : PrefixDeclarations.XSD_STRING); + final DatatypeConstantHandler handler = this.datatypes.get(type); if (handler != null) { return handler.createConstant(lexicalForm); @@ -148,9 +148,9 @@ private Constant parseDatatypeConstant(String lexicalForm, String datatype) thro * * @return this */ - public ParserConfiguration registerDatatype(String name, DatatypeConstantHandler handler) + public ParserConfiguration registerDatatype(final String name, final DatatypeConstantHandler handler) throws IllegalArgumentException { - Validate.isTrue(!datatypes.containsKey(name), "The Data type \"%s\" is already registered.", name); + Validate.isTrue(!this.datatypes.containsKey(name), "The Data type \"%s\" is already registered.", name); this.datatypes.put(name, handler); return this; diff --git a/vlog4j-parser/src/main/java/org/semanticweb/vlog4j/parser/javacc/SubParserFactory.java b/vlog4j-parser/src/main/java/org/semanticweb/vlog4j/parser/javacc/SubParserFactory.java index 1b9deccaa..c4a012baf 100644 --- a/vlog4j-parser/src/main/java/org/semanticweb/vlog4j/parser/javacc/SubParserFactory.java +++ b/vlog4j-parser/src/main/java/org/semanticweb/vlog4j/parser/javacc/SubParserFactory.java @@ -1,5 +1,7 @@ package org.semanticweb.vlog4j.parser.javacc; +import java.io.ByteArrayInputStream; + /*- * #%L * vlog4j-parser @@ -21,7 +23,6 @@ */ import java.io.InputStream; -import java.io.ByteArrayInputStream; import org.semanticweb.vlog4j.core.model.api.PrefixDeclarations; import org.semanticweb.vlog4j.core.reasoner.KnowledgeBase; @@ -29,23 +30,23 @@ import org.semanticweb.vlog4j.parser.RuleParser; /** - * Factory for creating a SubParser sharing configuration, state, and - * prefixes, but with an independent input stream, to be used, e.g., - * for parsing arguments in data source declarations. + * Factory for creating a SubParser sharing configuration, state, and prefixes, + * but with an independent input stream, to be used, e.g., for parsing arguments + * in data source declarations. * * @author Maximilian Marx */ public class SubParserFactory { - private KnowledgeBase knowledgeBase; - private ParserConfiguration parserConfiguration; - private PrefixDeclarations prefixDeclarations; + private final KnowledgeBase knowledgeBase; + private final ParserConfiguration parserConfiguration; + private final PrefixDeclarations prefixDeclarations; /** * Construct a SubParserFactory. * - * @argument parser the parser instance to get the state from. + * @param parser the parser instance to get the state from. */ - SubParserFactory(JavaCCParser parser) { + SubParserFactory(final JavaCCParser parser) { this.knowledgeBase = parser.getKnowledgeBase(); this.prefixDeclarations = parser.getPrefixDeclarations(); this.parserConfiguration = parser.getParserConfiguration(); @@ -54,14 +55,14 @@ public class SubParserFactory { /** * Create a new parser with the specified state and given input. * - * @argument inputStream the input stream to parse. - * @argument encoding encoding of the input stream. + * @param inputStream the input stream to parse. + * @param encoding encoding of the input stream. * - * @return A new {@link JavaCCParser} bound to inputStream and - * with the specified parser state. + * @return A new {@link JavaCCParser} bound to inputStream and with the + * specified parser state. */ public JavaCCParser makeSubParser(final InputStream inputStream, final String encoding) { - JavaCCParser subParser = new JavaCCParser(inputStream, encoding); + final JavaCCParser subParser = new JavaCCParser(inputStream, encoding); subParser.setKnowledgeBase(this.knowledgeBase); subParser.setPrefixDeclarations(this.prefixDeclarations); subParser.setParserConfiguration(this.parserConfiguration); @@ -70,10 +71,10 @@ public JavaCCParser makeSubParser(final InputStream inputStream, final String en } public JavaCCParser makeSubParser(final InputStream inputStream) { - return makeSubParser(inputStream, RuleParser.DEFAULT_STRING_ENCODING); + return this.makeSubParser(inputStream, RuleParser.DEFAULT_STRING_ENCODING); } public JavaCCParser makeSubParser(final String string) { - return makeSubParser(new ByteArrayInputStream(string.getBytes())); + return this.makeSubParser(new ByteArrayInputStream(string.getBytes())); } }