moved string tokenizer to svjatoslav-commons
authorSvjatoslav Agejenko <svjatoslav@svjatoslav.eu>
Sun, 28 Jul 2013 19:05:21 +0000 (22:05 +0300)
committerSvjatoslav Agejenko <svjatoslav@svjatoslav.eu>
Sun, 28 Jul 2013 19:05:21 +0000 (22:05 +0300)
pom.xml
src/main/java/eu/svjatoslav/inspector/java/methods/Annotation.java
src/main/java/eu/svjatoslav/inspector/java/methods/ClassReference.java
src/main/java/eu/svjatoslav/inspector/java/methods/Clazz.java
src/main/java/eu/svjatoslav/inspector/java/methods/JavaFile.java
src/main/java/eu/svjatoslav/inspector/java/methods/ProjectScanner.java
src/main/java/eu/svjatoslav/inspector/tokenizer/InvalidSyntaxException.java [deleted file]
src/main/java/eu/svjatoslav/inspector/tokenizer/Terminator.java [deleted file]
src/main/java/eu/svjatoslav/inspector/tokenizer/Tokenizer.java [deleted file]
src/main/java/eu/svjatoslav/inspector/tokenizer/TokenizerMatch.java [deleted file]

diff --git a/pom.xml b/pom.xml
index 09c54f8..c5825da 100755 (executable)
--- a/pom.xml
+++ b/pom.xml
@@ -16,7 +16,7 @@
                <dependency>
                        <groupId>eu.svjatoslav</groupId>
                        <artifactId>svjatoslavcommons</artifactId>
-                       <version>1.1-SNAPSHOT</version>
+                       <version>1.1</version>
                </dependency>
        </dependencies>
 
index d262061..96e0d20 100644 (file)
@@ -1,8 +1,8 @@
 package eu.svjatoslav.inspector.java.methods;
 
-import eu.svjatoslav.inspector.tokenizer.InvalidSyntaxException;
-import eu.svjatoslav.inspector.tokenizer.Tokenizer;
-import eu.svjatoslav.inspector.tokenizer.TokenizerMatch;
+import eu.svjatoslav.commons.string.tokenizer.InvalidSyntaxException;
+import eu.svjatoslav.commons.string.tokenizer.Tokenizer;
+import eu.svjatoslav.commons.string.tokenizer.TokenizerMatch;
 
 public class Annotation {
 
index 1a943f5..470a0d5 100644 (file)
@@ -3,8 +3,8 @@ package eu.svjatoslav.inspector.java.methods;
 import java.util.ArrayList;
 import java.util.List;
 
-import eu.svjatoslav.inspector.tokenizer.InvalidSyntaxException;
-import eu.svjatoslav.inspector.tokenizer.Tokenizer;
+import eu.svjatoslav.commons.string.tokenizer.InvalidSyntaxException;
+import eu.svjatoslav.commons.string.tokenizer.Tokenizer;
 
 public class ClassReference {
 
index 29c2899..430b5f1 100644 (file)
@@ -3,9 +3,9 @@ package eu.svjatoslav.inspector.java.methods;
 import java.util.ArrayList;
 import java.util.List;
 
-import eu.svjatoslav.inspector.tokenizer.InvalidSyntaxException;
-import eu.svjatoslav.inspector.tokenizer.Tokenizer;
-import eu.svjatoslav.inspector.tokenizer.TokenizerMatch;
+import eu.svjatoslav.commons.string.tokenizer.InvalidSyntaxException;
+import eu.svjatoslav.commons.string.tokenizer.Tokenizer;
+import eu.svjatoslav.commons.string.tokenizer.TokenizerMatch;
 
 public class Clazz {
 
index 3dd5557..15d5169 100644 (file)
@@ -8,9 +8,9 @@ import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 
-import eu.svjatoslav.inspector.tokenizer.InvalidSyntaxException;
-import eu.svjatoslav.inspector.tokenizer.Tokenizer;
-import eu.svjatoslav.inspector.tokenizer.TokenizerMatch;
+import eu.svjatoslav.commons.string.tokenizer.InvalidSyntaxException;
+import eu.svjatoslav.commons.string.tokenizer.Tokenizer;
+import eu.svjatoslav.commons.string.tokenizer.TokenizerMatch;
 
 public class JavaFile {
 
index b37fa4f..aaeacd4 100644 (file)
@@ -8,7 +8,7 @@ import java.util.List;
 import java.util.Map;
 
 import eu.svjatoslav.commons.file.FilePathParser;
-import eu.svjatoslav.inspector.tokenizer.InvalidSyntaxException;
+import eu.svjatoslav.commons.string.tokenizer.InvalidSyntaxException;
 
 public class ProjectScanner {
 
diff --git a/src/main/java/eu/svjatoslav/inspector/tokenizer/InvalidSyntaxException.java b/src/main/java/eu/svjatoslav/inspector/tokenizer/InvalidSyntaxException.java
deleted file mode 100644 (file)
index 1d47f4c..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-package eu.svjatoslav.inspector.tokenizer;
-
-public class InvalidSyntaxException extends Exception {
-
-       private static final long serialVersionUID = 88294980027680555L;
-
-       public InvalidSyntaxException(final String cause) {
-               super(cause);
-       }
-
-}
diff --git a/src/main/java/eu/svjatoslav/inspector/tokenizer/Terminator.java b/src/main/java/eu/svjatoslav/inspector/tokenizer/Terminator.java
deleted file mode 100644 (file)
index 8848775..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-package eu.svjatoslav.inspector.tokenizer;
-
-public class Terminator {
-
-       String startSequence;
-       String endSequence;
-       boolean ignoreTerminator;
-
-       public Terminator(final String startPattern, final boolean ignoreTerminator) {
-               this.startSequence = startPattern;
-               this.ignoreTerminator = ignoreTerminator;
-       }
-
-       public Terminator(final String startSequence, final String endSequence,
-                       final boolean ignoreTerminator) {
-
-               this.startSequence = startSequence;
-               this.endSequence = endSequence;
-               this.ignoreTerminator = ignoreTerminator;
-       }
-
-}
diff --git a/src/main/java/eu/svjatoslav/inspector/tokenizer/Tokenizer.java b/src/main/java/eu/svjatoslav/inspector/tokenizer/Tokenizer.java
deleted file mode 100644 (file)
index ec13b1a..0000000
+++ /dev/null
@@ -1,120 +0,0 @@
-package eu.svjatoslav.inspector.tokenizer;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Stack;
-
-public class Tokenizer {
-
-       private final List<Terminator> terminators = new ArrayList<Terminator>();
-       private final String source;
-
-       Stack<Integer> tokenIndexes = new Stack<Integer>();
-
-       private int currentIndex = 0;
-
-       public Tokenizer(final String source) {
-               this.source = source;
-       }
-
-       public void addTerminator(final String startSequence,
-                       final boolean ignoreTerminator) {
-               terminators.add(new Terminator(startSequence, ignoreTerminator));
-       }
-
-       public void addTerminator(final String startSequence,
-                       final String endSequence, final boolean ignoreTerminator) {
-               terminators.add(new Terminator(startSequence, endSequence,
-                               ignoreTerminator));
-       }
-
-       public void expectNextToken(final String value)
-                       throws InvalidSyntaxException {
-               final TokenizerMatch match = getNextToken();
-               if (!value.equals(match.token))
-                       throw new InvalidSyntaxException("Expected \"" + value
-                                       + "\" but got \"" + match.token + "\" instead.");
-       }
-
-       public TokenizerMatch getNextToken() {
-               tokenIndexes.push(currentIndex);
-               final StringBuffer result = new StringBuffer();
-
-               while (true) {
-                       if (currentIndex >= source.length())
-                               return null;
-
-                       boolean accumulateCurrentChar = true;
-
-                       findTerminator: for (final Terminator terminator : terminators)
-                               if (sequenceMatches(terminator.startSequence))
-
-                                       if (terminator.ignoreTerminator) {
-                                               currentIndex += terminator.startSequence.length();
-
-                                               if (terminator.endSequence != null)
-                                                       skipUntilSequence(terminator.endSequence);
-
-                                               if (result.length() > 0)
-                                                       return new TokenizerMatch(result.toString(),
-                                                                       terminator);
-                                               else {
-                                                       accumulateCurrentChar = false;
-                                                       break findTerminator;
-                                               }
-                                       } else if (result.length() > 0)
-                                               return new TokenizerMatch(result.toString(), terminator);
-                                       else {
-                                               currentIndex += terminator.startSequence.length();
-                                               return new TokenizerMatch(terminator.startSequence,
-                                                               terminator);
-                                       }
-
-                       if (accumulateCurrentChar) {
-                               result.append(source.charAt(currentIndex));
-                               currentIndex++;
-                       }
-               }
-
-       }
-
-       public boolean probeNextToken(final String token) {
-               if (token.equals(getNextToken().token))
-                       return true;
-
-               unreadToken();
-               return false;
-       }
-
-       public boolean sequenceMatches(final String sequence) {
-               if ((currentIndex + sequence.length()) > source.length())
-                       return false;
-
-               for (int i = 0; i < sequence.length(); i++)
-                       if (sequence.charAt(i) != source.charAt(i + currentIndex))
-                               return false;
-
-               return true;
-       }
-
-       public void skipUntilDataEnd() {
-               tokenIndexes.push(currentIndex);
-               currentIndex = source.length();
-       }
-
-       public void skipUntilSequence(final String sequence) {
-               while (currentIndex < source.length()) {
-                       if (sequenceMatches(sequence)) {
-                               currentIndex += sequence.length();
-                               return;
-                       }
-
-                       currentIndex++;
-               }
-       }
-
-       public void unreadToken() {
-               currentIndex = tokenIndexes.pop();
-       }
-
-}
diff --git a/src/main/java/eu/svjatoslav/inspector/tokenizer/TokenizerMatch.java b/src/main/java/eu/svjatoslav/inspector/tokenizer/TokenizerMatch.java
deleted file mode 100644 (file)
index 158a9d9..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-package eu.svjatoslav.inspector.tokenizer;
-
-public class TokenizerMatch {
-
-       public String token;
-       public Terminator terminator;
-
-       public TokenizerMatch(final String token, final Terminator terminator) {
-               this.token = token;
-               this.terminator = terminator;
-       }
-}