Skip to content

Commit

Permalink
Use more suitable naming for packages
Browse files Browse the repository at this point in the history
  • Loading branch information
smeyer198 committed Nov 27, 2024
1 parent 129f987 commit f57765c
Show file tree
Hide file tree
Showing 35 changed files with 104 additions and 98 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package de.darmstadt.tu.crossing;
package crysl;

import de.darmstadt.tu.crossing.parsing.CrySLException;
import de.darmstadt.tu.crossing.parsing.CrySLModelReader;
import de.darmstadt.tu.crossing.rule.CrySLRule;
import crysl.parsing.CrySLParserException;
import crysl.parsing.CrySLModelReader;
import crysl.rule.CrySLRule;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
Expand Down Expand Up @@ -67,17 +67,17 @@ public Collection<CrySLRule> parseRulesFromFiles(Collection<File> files) {
}

result.add(rule);
} catch (CrySLException e) {
} catch (CrySLParserException e) {
LOGGER.error(e.getMessage());
}
}
return result;
}

public CrySLRule parseRuleFromFile(File file) throws CrySLException {
public CrySLRule parseRuleFromFile(File file) throws CrySLParserException {
String fileName = file.getName();
if (!fileName.endsWith(CRYSL_FILE_ENDING)) {
throw new CrySLException(
throw new CrySLParserException(
"The extension of " + fileName + " does not match " + CRYSL_FILE_ENDING);
}

Expand Down Expand Up @@ -119,7 +119,7 @@ public Collection<CrySLRule> parseRulesFromZipArchive(String path) throws IOExce
try {
CrySLRule rule = parseRuleFromZipEntry(entry, zipFile, file);
result.add(rule);
} catch (CrySLException e) {
} catch (CrySLParserException e) {
LOGGER.error(e.getMessage());
}
}
Expand All @@ -128,10 +128,10 @@ public Collection<CrySLRule> parseRulesFromZipArchive(String path) throws IOExce
}

private CrySLRule parseRuleFromZipEntry(ZipEntry entry, ZipFile zipFile, File file)
throws CrySLException {
throws CrySLParserException {
String entryName = entry.getName();
if (entry.isDirectory() || !entryName.endsWith(CRYSL_FILE_ENDING)) {
throw new CrySLException("ZIP entry " + entryName + " is not a CrySL file");
throw new CrySLParserException("ZIP entry " + entryName + " is not a CrySL file");
}

try {
Expand All @@ -144,7 +144,7 @@ private CrySLRule parseRuleFromZipEntry(ZipEntry entry, ZipFile zipFile, File fi

return rule;
} catch (IOException ex) {
throw new CrySLException(
throw new CrySLParserException(
"Could not read file "
+ entry.getName()
+ " from Zip archive "
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.darmstadt.tu.crossing.parsing;
package crysl.parsing;

import com.google.inject.Injector;
import de.darmstadt.tu.crossing.CrySLStandaloneSetup;
Expand Down Expand Up @@ -32,22 +32,22 @@
import de.darmstadt.tu.crossing.crySL.ThisPredicateParameter;
import de.darmstadt.tu.crossing.crySL.TimedPredicate;
import de.darmstadt.tu.crossing.crySL.WildcardPredicateParameter;
import de.darmstadt.tu.crossing.rule.CrySLArithmeticConstraint;
import de.darmstadt.tu.crossing.rule.CrySLComparisonConstraint;
import de.darmstadt.tu.crossing.rule.CrySLCondPredicate;
import de.darmstadt.tu.crossing.rule.CrySLConstraint;
import de.darmstadt.tu.crossing.rule.CrySLForbiddenMethod;
import de.darmstadt.tu.crossing.rule.CrySLMethod;
import de.darmstadt.tu.crossing.rule.CrySLObject;
import de.darmstadt.tu.crossing.rule.CrySLPredicate;
import de.darmstadt.tu.crossing.rule.CrySLRule;
import de.darmstadt.tu.crossing.rule.CrySLSplitter;
import de.darmstadt.tu.crossing.rule.CrySLValueConstraint;
import de.darmstadt.tu.crossing.rule.ICrySLPredicateParameter;
import de.darmstadt.tu.crossing.rule.ISLConstraint;
import de.darmstadt.tu.crossing.rule.StateMachineGraph;
import de.darmstadt.tu.crossing.rule.StateNode;
import de.darmstadt.tu.crossing.rule.TransitionEdge;
import crysl.rule.CrySLArithmeticConstraint;
import crysl.rule.CrySLComparisonConstraint;
import crysl.rule.CrySLCondPredicate;
import crysl.rule.CrySLConstraint;
import crysl.rule.CrySLForbiddenMethod;
import crysl.rule.CrySLMethod;
import crysl.rule.CrySLObject;
import crysl.rule.CrySLPredicate;
import crysl.rule.CrySLRule;
import crysl.rule.CrySLSplitter;
import crysl.rule.CrySLValueConstraint;
import crysl.rule.ICrySLPredicateParameter;
import crysl.rule.ISLConstraint;
import crysl.rule.StateMachineGraph;
import crysl.rule.StateNode;
import crysl.rule.TransitionEdge;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -121,12 +121,12 @@ public CrySLModelReader(CrySLModelReaderClassPath classPath) {
* @return the {@link CrySLRule}
* @throws IllegalArgumentException If the file for the rule cannot be found
* @throws IOException If there is a problem with reading the file
* @throws CrySLException If the file is not a .crysl file
* @throws CrySLParserException If the file is not a .crysl file
*/
public CrySLRule readRule(InputStream stream, String virtualFileName)
throws IOException, CrySLException {
throws IOException, CrySLParserException {
if (!virtualFileName.endsWith(cryslFileEnding)) {
throw new CrySLException(
throw new CrySLParserException(
"The extension of " + virtualFileName + " does not match " + cryslFileEnding);
}

Expand All @@ -146,9 +146,9 @@ public CrySLRule readRule(InputStream stream, String virtualFileName)
*
* @param ruleFile the CrySL file
* @return the {@link CrySLRule} object
* @throws CrySLException If the file is not a .crysl file
* @throws CrySLParserException If the file is not a .crysl file
*/
public CrySLRule readRule(File ruleFile) throws CrySLException {
public CrySLRule readRule(File ruleFile) throws CrySLParserException {
Resource resource =
resourceSet.getResource(URI.createFileURI(ruleFile.getAbsolutePath()), true);

Expand Down Expand Up @@ -197,31 +197,31 @@ private boolean runValidator(Resource resource) {
return errorFound;
}

private CrySLRule createRuleFromResource(Resource resource) throws CrySLException {
private CrySLRule createRuleFromResource(Resource resource) throws CrySLParserException {
if (resource == null) {
throw new CrySLException(
throw new CrySLParserException(
"Internal error creating a CrySL rule: 'resource parameter was null'.");
}

if (runValidator(resource)) {
throw new CrySLException(
throw new CrySLParserException(
"Skipping rule since it contains errors: " + resource.getURI());
}

try {
return createRuleFromDomainModel((Domainmodel) resource.getContents().get(0));
} catch (Exception e) {
throw new CrySLException(
throw new CrySLParserException(
"An error occurred while reading the rule " + resource.getURI());
}
}

private CrySLRule createRuleFromDomainModel(Domainmodel model) throws CrySLException {
private CrySLRule createRuleFromDomainModel(Domainmodel model) throws CrySLParserException {
this.currentClass = model.getJavaType();
String currentClass = this.currentClass.getQualifiedName();

if (currentClass.equals("void")) {
throw new CrySLException("Class for the rule is not on the classpath.");
throw new CrySLParserException("Class for the rule is not on the classpath.");
}

final Collection<Map.Entry<String, String>> objects = getObjects(model.getObjects());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.darmstadt.tu.crossing.parsing;
package crysl.parsing;

import com.google.common.base.Splitter;
import java.io.File;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package crysl.parsing;

public class CrySLParserException extends Exception {

public CrySLParserException(String message) {
super(message);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.darmstadt.tu.crossing.parsing;
package crysl.parsing;

import de.darmstadt.tu.crossing.crySL.Aggregate;
import de.darmstadt.tu.crossing.crySL.AnyParameterType;
Expand All @@ -16,13 +16,13 @@
import de.darmstadt.tu.crossing.crySL.Object;
import de.darmstadt.tu.crossing.crySL.Operator;
import de.darmstadt.tu.crossing.crySL.StringLiteral;
import de.darmstadt.tu.crossing.rule.CrySLArithmeticConstraint;
import de.darmstadt.tu.crossing.rule.CrySLComparisonConstraint;
import de.darmstadt.tu.crossing.rule.CrySLConstraint;
import de.darmstadt.tu.crossing.rule.CrySLException;
import de.darmstadt.tu.crossing.rule.CrySLMethod;
import de.darmstadt.tu.crossing.rule.CrySLObject;
import de.darmstadt.tu.crossing.rule.ICrySLPredicateParameter;
import crysl.rule.CrySLArithmeticConstraint;
import crysl.rule.CrySLComparisonConstraint;
import crysl.rule.CrySLConstraint;
import crysl.rule.CrySLException;
import crysl.rule.CrySLMethod;
import crysl.rule.CrySLObject;
import crysl.rule.ICrySLPredicateParameter;
import java.util.AbstractMap.SimpleEntry;
import java.util.Collection;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package de.darmstadt.tu.crossing.parsing;
package crysl.parsing;

import de.darmstadt.tu.crossing.crySL.EventsBlock;
import de.darmstadt.tu.crossing.crySL.LabeledMethodCall;
import de.darmstadt.tu.crossing.rule.CrySLExceptionConstraint;
import de.darmstadt.tu.crossing.rule.CrySLMethod;
import crysl.rule.CrySLExceptionConstraint;
import crysl.rule.CrySLMethod;
import java.util.Collection;
import java.util.stream.Collectors;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package de.darmstadt.tu.crossing.parsing;
package crysl.parsing;

import de.darmstadt.tu.crossing.crySL.Event;
import de.darmstadt.tu.crossing.crySL.Order;
import de.darmstadt.tu.crossing.crySL.OrderOperator;
import de.darmstadt.tu.crossing.crySL.Primary;
import de.darmstadt.tu.crossing.rule.CrySLMethod;
import de.darmstadt.tu.crossing.rule.FiniteStateMachine;
import de.darmstadt.tu.crossing.rule.StateMachineGraph;
import de.darmstadt.tu.crossing.rule.StateNode;
import crysl.rule.CrySLMethod;
import crysl.rule.FiniteStateMachine;
import crysl.rule.StateMachineGraph;
import crysl.rule.StateNode;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.darmstadt.tu.crossing.rule;
package crysl.rule;

import java.util.ArrayList;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.darmstadt.tu.crossing.rule;
package crysl.rule;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.darmstadt.tu.crossing.rule;
package crysl.rule;

import java.util.Collection;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.darmstadt.tu.crossing.rule;
package crysl.rule;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.darmstadt.tu.crossing.rule;
package crysl.rule;

/** Helper Class to store an {@link Exception} as a String. */
public class CrySLException {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.darmstadt.tu.crossing.rule;
package crysl.rule;

import java.util.Collections;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.darmstadt.tu.crossing.rule;
package crysl.rule;

import java.util.Collection;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.darmstadt.tu.crossing.rule;
package crysl.rule;

public abstract class CrySLLiteral implements ISLConstraint {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.darmstadt.tu.crossing.rule;
package crysl.rule;

import java.util.List;
import java.util.Map.Entry;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.darmstadt.tu.crossing.rule;
package crysl.rule;

import java.util.Arrays;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.darmstadt.tu.crossing.rule;
package crysl.rule;

import java.util.ArrayList;
import java.util.Arrays;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.darmstadt.tu.crossing.rule;
package crysl.rule;

import java.util.Collection;
import java.util.LinkedList;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.darmstadt.tu.crossing.rule;
package crysl.rule;

public class CrySLSplitter {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.darmstadt.tu.crossing.rule;
package crysl.rule;

import java.util.ArrayList;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.darmstadt.tu.crossing.rule;
package crysl.rule;

import java.util.Collection;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.darmstadt.tu.crossing.rule;
package crysl.rule;

public interface ICrySLPredicateParameter {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.darmstadt.tu.crossing.rule;
package crysl.rule;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.darmstadt.tu.crossing.rule;
package crysl.rule;

import java.util.ArrayList;
import java.util.Collection;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.darmstadt.tu.crossing.rule;
package crysl.rule;

import java.io.File;
import java.io.FileInputStream;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.darmstadt.tu.crossing.rule;
package crysl.rule;

public class StateNode {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.darmstadt.tu.crossing.rule;
package crysl.rule;

import java.util.Collection;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.darmstadt.tu.crossing.rule;
package crysl.rule;

import java.util.Collection;

Expand Down

This file was deleted.

Loading

0 comments on commit f57765c

Please sign in to comment.