Skip to content

Commit 83c59ef

Browse files
committed
Introduced standard maven project source folder structure
1 parent 50617a4 commit 83c59ef

File tree

12 files changed

+95
-31
lines changed

12 files changed

+95
-31
lines changed

pom.xml

Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,38 @@
1-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2-
<modelVersion>4.0.0</modelVersion>
3-
<groupId>de.fraunhofer.iem</groupId>
4-
<artifactId>PathExpression</artifactId>
5-
<version>1.0.0</version>
6-
<build>
7-
<sourceDirectory>src</sourceDirectory>
8-
<testSourceDirectory>test</testSourceDirectory>
9-
<plugins>
10-
<plugin>
11-
<artifactId>maven-compiler-plugin</artifactId>
12-
<version>3.3</version>
13-
<configuration>
14-
<source>1.7</source>
15-
<target>1.7</target>
16-
</configuration>
17-
</plugin>
18-
</plugins>
19-
</build>
20-
21-
<dependencies>
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>de.fraunhofer.iem</groupId>
5+
<artifactId>PathExpression</artifactId>
6+
<version>1.0.0</version>
7+
<build>
8+
<plugins>
9+
<plugin>
10+
<artifactId>maven-compiler-plugin</artifactId>
11+
<version>3.3</version>
12+
<configuration>
13+
<source>1.7</source>
14+
<target>1.7</target>
15+
</configuration>
16+
</plugin>
17+
</plugins>
18+
</build>
19+
20+
<dependencies>
2221
<dependency>
23-
<groupId>com.google.guava</groupId>
24-
<artifactId>guava</artifactId>
25-
<version>23.5-jre</version>
22+
<groupId>com.google.guava</groupId>
23+
<artifactId>guava</artifactId>
24+
<version>23.5-jre</version>
2625
</dependency>
27-
<dependency>
28-
<groupId>junit</groupId>
29-
<artifactId>junit</artifactId>
30-
<version>4.12</version>
31-
<scope>test</scope>
32-
</dependency>
33-
</dependencies>
26+
<dependency>
27+
<groupId>junit</groupId>
28+
<artifactId>junit</artifactId>
29+
<version>4.12</version>
30+
<scope>test</scope>
31+
</dependency>
32+
<dependency>
33+
<groupId>org.apache.logging.log4j</groupId>
34+
<artifactId>log4j-core</artifactId>
35+
<version>2.11.0</version>
36+
</dependency>
37+
</dependencies>
3438
</project>
File renamed without changes.

src/pathexpression/PathExpressionComputer.java renamed to src/main/java/pathexpression/PathExpressionComputer.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,24 @@
1818
import com.google.common.collect.Table;
1919
import pathexpression.RegEx.EmptySet;
2020

21+
import java.util.HashMap;
2122
import java.util.LinkedList;
2223
import java.util.List;
24+
import java.util.Map;
25+
26+
import org.apache.logging.log4j.LogManager;
27+
import org.apache.logging.log4j.Logger;
2328

2429
public class PathExpressionComputer<N, V> {
2530

31+
final static Logger logger = LogManager.getLogger(PathExpressionComputer.class);
32+
2633
private LabeledGraph<N, V> graph;
2734
private BiMap<N, Integer> nodeToIntMap = HashBiMap.create();
2835
private Table<Integer, Integer, IRegEx<V>> table = HashBasedTable.create();
2936
private IRegEx<V> emptyRegEx = new RegEx.EmptySet<V>();
37+
private Map<N,List<IRegEx<V>>> allPathFromNode = new HashMap<>();
38+
private boolean eliminated;
3039

3140
public PathExpressionComputer(LabeledGraph<N, V> graph) {
3241
this.graph = graph;
@@ -56,7 +65,12 @@ public IRegEx<V> getExpressionBetween(N a, N b) {
5665

5766
private List<IRegEx<V>> computeAllPathFrom(N a) {
5867
assert graph.getNodes().contains(a);
68+
if(allPathFromNode.get(a) != null) {
69+
return allPathFromNode.get(a);
70+
}
71+
5972
eliminate();
73+
logger.debug("Compute all path from {}", a);
6074
List<PathExpression<V>> extractPathSequence = extractPathSequence();
6175
List<IRegEx<V>> regEx = new LinkedList<>();
6276
for (int i = 0; i < graph.getNodes().size(); i++) {
@@ -84,10 +98,14 @@ private List<IRegEx<V>> computeAllPathFrom(N a) {
8498
regEx.set(wi - 1, RegEx.<V>union(regExWi, inter));
8599
}
86100
}
101+
allPathFromNode.put(a, regEx);
102+
logger.debug("End extraction all path");
87103
return regEx;
88104
}
89105

90106
private List<PathExpression<V>> extractPathSequence() {
107+
108+
91109
int n = graph.getNodes().size();
92110
List<PathExpression<V>> list = new LinkedList<PathExpression<V>>();
93111
for (int u = 1; u <= n; u++) {
@@ -110,6 +128,10 @@ private List<PathExpression<V>> extractPathSequence() {
110128
}
111129

112130
private void eliminate() {
131+
if(eliminated) {
132+
return;
133+
}
134+
logger.debug("Start eliminating");
113135
int numberOfNodes = graph.getNodes().size();
114136
for (int v = 1; v <= numberOfNodes; v++) {
115137
for (int w = 1; w <= numberOfNodes; w++) {
@@ -151,6 +173,8 @@ private void eliminate() {
151173
}
152174
}
153175
}
176+
eliminated = true;
177+
logger.debug("End eliminating");
154178
}
155179

156180

src/pathexpression/RegEx.java renamed to src/main/java/pathexpression/RegEx.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,25 @@ public static <V> IRegEx<V> concatenate(IRegEx<V> a, IRegEx<V> b) {
194194
return simplify(new Concatenate<V>(a, b));
195195
}
196196

197+
public static <V> IRegEx<V> reverse(IRegEx<V> a) {
198+
assert a != null;
199+
if(a instanceof EmptySet || a instanceof Epsilon || a instanceof Plain)
200+
return a;
201+
if(a instanceof Concatenate) {
202+
Concatenate concatenate = (Concatenate) a;
203+
return concatenate(reverse(concatenate.getSecond()), reverse(concatenate.getFirst()));
204+
}
205+
if(a instanceof Union) {
206+
Union union = (Union) a;
207+
return union(reverse(union.getFirst()), reverse(union.getSecond()));
208+
}
209+
if(a instanceof Star) {
210+
Star star = (Star) a;
211+
return star(reverse(star.getPlain()));
212+
}
213+
throw new IllegalStateException("Cannot reverse this regular expression: " + a);
214+
}
215+
197216
public static <V> boolean containsEpsilon(IRegEx<V> regex) {
198217
if (regex instanceof Union) {
199218
Union con = (Union) regex;
@@ -301,4 +320,5 @@ public boolean equals(Object obj) {
301320

302321

303322

323+
304324
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Root logger option
2+
log4j.rootLogger=DEBUG, stdout, file
3+
4+
# Redirect log messages to console
5+
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
6+
log4j.appender.stdout.Target=System.out
7+
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
8+
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
9+
10+
# Redirect log messages to a log file, support file rolling.
11+
log4j.appender.file=org.apache.log4j.RollingFileAppender
12+
log4j.appender.file.File=C:\\log4j-application.log
13+
log4j.appender.file.MaxFileSize=5MB
14+
log4j.appender.file.MaxBackupIndex=10
15+
log4j.appender.file.layout=org.apache.log4j.PatternLayout
16+
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
File renamed without changes.

0 commit comments

Comments
 (0)