Skip to content

Commit

Permalink
fixed some javadoc errors
Browse files Browse the repository at this point in the history
  • Loading branch information
irina-dragoste committed Dec 6, 2019
1 parent 55ca9fe commit 6741fe8
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<PositiveLiteral> convertAtoms(final List<fr.lirmm.graphik.graal.api.core.Atom> atoms) {
Expand All @@ -109,8 +109,8 @@ public static List<PositiveLiteral> convertAtoms(final List<fr.lirmm.graphik.gra
* Converts a {@link List} of {@link fr.lirmm.graphik.graal.api.core.Atom Graal
* Atoms} into a {@link List} of {@link Fact VLog4j facts}.
*
* @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 Fact VLog4j facts}.
*/
public static List<Fact> convertAtomsToFacts(final List<fr.lirmm.graphik.graal.api.core.Atom> atoms) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -39,12 +40,12 @@ public class ParserConfiguration {
/**
* The registered data sources.
*/
private HashMap<String, DataSourceDeclarationHandler> dataSources = new HashMap<>();
private final HashMap<String, DataSourceDeclarationHandler> dataSources = new HashMap<>();

/**
* The registered datatypes.
*/
private HashMap<String, DatatypeConstantHandler> datatypes = new HashMap<>();
private final HashMap<String, DatatypeConstantHandler> datatypes = new HashMap<>();

/**
* Register a new (type of) Data Source.
Expand All @@ -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 <a href="https://github.com/knowsys/vlog4j/wiki/Rule-syntax-grammar">
* the grammar</a>.
*
* @param name Name of the data source, as it appears in the declaring
* directive.
Expand All @@ -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;
Expand All @@ -87,9 +88,9 @@ public ParserConfiguration registerDataSource(String name, DataSourceDeclaration
*
* @return the Data Source instance.
*/
public DataSource parseDataSourceSpecificPartOfDataSourceDeclaration(String name, List<String> args,
public DataSource parseDataSourceSpecificPartOfDataSourceDeclaration(final String name, final List<String> 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.");
Expand All @@ -104,30 +105,29 @@ 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.
* @throws IllegalArgumentException when both {@code languageTag} and
* {@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);
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.semanticweb.vlog4j.parser.javacc;

import java.io.ByteArrayInputStream;

/*-
* #%L
* vlog4j-parser
Expand All @@ -21,31 +23,30 @@
*/

import java.io.InputStream;
import java.io.ByteArrayInputStream;

import org.semanticweb.vlog4j.core.model.api.PrefixDeclarations;
import org.semanticweb.vlog4j.core.reasoner.KnowledgeBase;
import org.semanticweb.vlog4j.parser.ParserConfiguration;
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();
Expand All @@ -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);
Expand All @@ -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()));
}
}

0 comments on commit 6741fe8

Please sign in to comment.