Removed non-UTF characters from source files.

This commit is contained in:
Harald Kuhr 2011-02-19 15:45:58 +01:00
parent 26128bf7ea
commit dba1fa20da
2 changed files with 61 additions and 62 deletions

View File

@ -66,7 +66,7 @@ import java.io.PrintStream;
* For each character in the mask a state representing that character is created. * For each character in the mask a state representing that character is created.
* The number of states therefore coincides with the length of the mask. * The number of states therefore coincides with the length of the mask.
* <li>An <b>alphabet</b> consisting of all legal filename characters - included the two wildcard characters '*' and '?'. * <li>An <b>alphabet</b> consisting of all legal filename characters - included the two wildcard characters '*' and '?'.
* This alphabet is hard-coded in this class. It contains {a .. å}, {A .. Å}, {0 .. 9}, {.}, {_}, {-}, {*} and {?}. * This alphabet is hard-coded in this class. It contains {a .. <EFBFBD>}, {A .. <EFBFBD>}, {0 .. 9}, {.}, {_}, {-}, {*} and {?}.
* <li>A finite set of <b>initial states</b>, here only consisting of the state corresponding to the first character in the mask. * <li>A finite set of <b>initial states</b>, here only consisting of the state corresponding to the first character in the mask.
* <li>A finite set of <b>final states</b>, here only consisting of the state corresponding to the last character in the mask. * <li>A finite set of <b>final states</b>, here only consisting of the state corresponding to the last character in the mask.
* <li>A <b>transition relation</b> that is a finite set of transitions satisfying some formal rules.<br> * <li>A <b>transition relation</b> that is a finite set of transitions satisfying some formal rules.<br>
@ -120,9 +120,9 @@ public class WildcardStringParser {
/** Field ALPHABET */ /** Field ALPHABET */
public static final char[] ALPHABET = { public static final char[] ALPHABET = {
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'æ', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'æ',
'ø', 'å', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'N', 'M', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'ø', 'å', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'N', 'M', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y',
'Z', 'Æ', 'Ø', 'Å', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.', '_', '-' 'Z', 'Æ', 'Ø', 'Å', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.', '_', '-'
}; };
/** Field FREE_RANGE_CHARACTER */ /** Field FREE_RANGE_CHARACTER */
@ -132,11 +132,11 @@ public class WildcardStringParser {
public static final char FREE_PASS_CHARACTER = '?'; public static final char FREE_PASS_CHARACTER = '?';
// Members // Members
boolean mInitialized; boolean initialized;
String mStringMask; String stringMask;
WildcardStringParserState mInitialState; WildcardStringParserState initialState;
int mTotalNumberOfStringsParsed; int totalNumberOfStringsParsed;
boolean mDebugging; boolean debugging;
PrintStream out; PrintStream out;
// Properties // Properties
@ -172,11 +172,10 @@ public class WildcardStringParser {
* @param pDebuggingPrintStream the {@code java.io.PrintStream} to which the debug messages will be emitted. * @param pDebuggingPrintStream the {@code java.io.PrintStream} to which the debug messages will be emitted.
*/ */
public WildcardStringParser(final String pStringMask, final boolean pDebugging, final PrintStream pDebuggingPrintStream) { public WildcardStringParser(final String pStringMask, final boolean pDebugging, final PrintStream pDebuggingPrintStream) {
this.stringMask = pStringMask;
this.mStringMask = pStringMask; this.debugging = pDebugging;
this.mDebugging = pDebugging;
this.out = pDebuggingPrintStream; this.out = pDebuggingPrintStream;
mInitialized = buildAutomaton(); initialized = buildAutomaton();
} }
// Methods // Methods
@ -212,8 +211,8 @@ public class WildcardStringParser {
/** @return {@code true} if and only if the string mask only consists of free-range wildcard character(s). */ /** @return {@code true} if and only if the string mask only consists of free-range wildcard character(s). */
private boolean isTrivialAutomaton() { private boolean isTrivialAutomaton() {
for (int i = 0; i < mStringMask.length(); i++) { for (int i = 0; i < stringMask.length(); i++) {
if (!isFreeRangeCharacter(mStringMask.charAt(i))) { if (!isFreeRangeCharacter(stringMask.charAt(i))) {
return false; return false;
} }
} }
@ -228,16 +227,16 @@ public class WildcardStringParser {
WildcardStringParserState lastFreeRangeState = null; WildcardStringParserState lastFreeRangeState = null;
// Create the initial state of the automaton // Create the initial state of the automaton
if ((mStringMask != null) && (mStringMask.length() > 0)) { if ((stringMask != null) && (stringMask.length() > 0)) {
newState = new WildcardStringParserState(mStringMask.charAt(0)); newState = new WildcardStringParserState(stringMask.charAt(0));
newState.mAutomatonStateNumber = 0; newState.mAutomatonStateNumber = 0;
newState.mPreviousState = null; newState.mPreviousState = null;
if (checkIfLastFreeRangeState(newState)) { if (checkIfLastFreeRangeState(newState)) {
lastFreeRangeState = newState; lastFreeRangeState = newState;
} }
runnerState = newState; runnerState = newState;
mInitialState = runnerState; initialState = runnerState;
mInitialState.mAutomatonStateNumber = 0; initialState.mAutomatonStateNumber = 0;
} }
else { else {
System.err.println("string mask provided are null or empty - aborting!"); System.err.println("string mask provided are null or empty - aborting!");
@ -245,8 +244,8 @@ public class WildcardStringParser {
} }
// Create the rest of the automaton // Create the rest of the automaton
for (int i = 1; i < mStringMask.length(); i++) { for (int i = 1; i < stringMask.length(); i++) {
activeChar = mStringMask.charAt(i); activeChar = stringMask.charAt(i);
// Check if the char is an element in the alphabet or is a wildcard character // Check if the char is an element in the alphabet or is a wildcard character
if (!((isInAlphabet(activeChar)) || (isWildcardCharacter(activeChar)))) { if (!((isInAlphabet(activeChar)) || (isWildcardCharacter(activeChar)))) {
@ -274,13 +273,13 @@ public class WildcardStringParser {
runnerState = newState; runnerState = newState;
// Special setting of the last free-range state for the last element // Special setting of the last free-range state for the last element
if (runnerState.mAutomatonStateNumber == mStringMask.length() - 1) { if (runnerState.mAutomatonStateNumber == stringMask.length() - 1) {
runnerState.mLastFreeRangeState = lastFreeRangeState; runnerState.mLastFreeRangeState = lastFreeRangeState;
} }
} }
// Initiate some statistics // Initiate some statistics
mTotalNumberOfStringsParsed = 0; totalNumberOfStringsParsed = 0;
return true; return true;
} }
@ -317,7 +316,7 @@ public class WildcardStringParser {
* @return the string mask used for building the parser automaton. * @return the string mask used for building the parser automaton.
*/ */
public String getStringMask() { public String getStringMask() {
return mStringMask; return stringMask;
} }
/** /**
@ -329,16 +328,16 @@ public class WildcardStringParser {
*/ */
public boolean parseString(final String pStringToParse) { public boolean parseString(final String pStringToParse) {
if (mDebugging) { if (debugging) {
out.println("parsing \"" + pStringToParse + "\"..."); out.println("parsing \"" + pStringToParse + "\"...");
} }
// Update statistics // Update statistics
mTotalNumberOfStringsParsed++; totalNumberOfStringsParsed++;
// Check string to be parsed for nullness // Check string to be parsed for nullness
if (pStringToParse == null) { if (pStringToParse == null) {
if (mDebugging) { if (debugging) {
out.println("string to be parsed is null - rejection!"); out.println("string to be parsed is null - rejection!");
} }
return false; return false;
@ -349,21 +348,21 @@ public class WildcardStringParser {
// Check string to be parsed // Check string to be parsed
if (!parsableString.checkString()) { if (!parsableString.checkString()) {
if (mDebugging) { if (debugging) {
out.println("one or more characters in string to be parsed are not legal characters - rejection!"); out.println("one or more characters in string to be parsed are not legal characters - rejection!");
} }
return false; return false;
} }
// Check if automaton is correctly initialized // Check if automaton is correctly initialized
if (!mInitialized) { if (!initialized) {
System.err.println("automaton is not initialized - rejection!"); System.err.println("automaton is not initialized - rejection!");
return false; return false;
} }
// Check if automaton is trivial (accepts all strings) // Check if automaton is trivial (accepts all strings)
if (isTrivialAutomaton()) { if (isTrivialAutomaton()) {
if (mDebugging) { if (debugging) {
out.println("automaton represents a trivial string mask (accepts all strings) - acceptance!"); out.println("automaton represents a trivial string mask (accepts all strings) - acceptance!");
} }
return true; return true;
@ -371,7 +370,7 @@ public class WildcardStringParser {
// Check if string to be parsed is empty // Check if string to be parsed is empty
if (parsableString.isEmpty()) { if (parsableString.isEmpty()) {
if (mDebugging) { if (debugging) {
out.println("string to be parsed is empty and not trivial automaton - rejection!"); out.println("string to be parsed is empty and not trivial automaton - rejection!");
} }
return false; return false;
@ -384,12 +383,12 @@ public class WildcardStringParser {
WildcardStringParserState runnerState = null; WildcardStringParserState runnerState = null;
// Accepted by the first state? // Accepted by the first state?
if ((parsableString.mCharArray[0] == mInitialState.mChar) || isWildcardCharacter(mInitialState.mChar)) { if ((parsableString.mCharArray[0] == initialState.mChar) || isWildcardCharacter(initialState.mChar)) {
runnerState = mInitialState; runnerState = initialState;
parsableString.mIndex = 0; parsableString.mIndex = 0;
} }
else { else {
if (mDebugging) { if (debugging) {
out.println("cannot enter first automaton state - rejection!"); out.println("cannot enter first automaton state - rejection!");
} }
return false; return false;
@ -402,23 +401,23 @@ public class WildcardStringParser {
// Perform parsing according to the rules above // Perform parsing according to the rules above
for (int i = 0; i < parsableString.length(); i++) { for (int i = 0; i < parsableString.length(); i++) {
if (mDebugging) { if (debugging) {
out.println(); out.println();
} }
if (mDebugging) { if (debugging) {
out.println("parsing - index number " + i + ", active char: '" out.println("parsing - index number " + i + ", active char: '"
+ parsableString.getActiveChar() + "' char string index: " + parsableString.mIndex + parsableString.getActiveChar() + "' char string index: " + parsableString.mIndex
+ " number of chars since last free-range state: " + numberOfParsedCharactersRead_SinceLastFreePassState); + " number of chars since last free-range state: " + numberOfParsedCharactersRead_SinceLastFreePassState);
} }
if (mDebugging) { if (debugging) {
out.println("parsing - state: " + runnerState.mAutomatonStateNumber + " '" out.println("parsing - state: " + runnerState.mAutomatonStateNumber + " '"
+ runnerState.mChar + "' - no of free-pass chars read: " + numberOfFreePassCharactersRead_SinceLastFreePassState); + runnerState.mChar + "' - no of free-pass chars read: " + numberOfFreePassCharactersRead_SinceLastFreePassState);
} }
if (mDebugging) { if (debugging) {
out.println("parsing - hasPerformedFreeRangeMovement: " + hasPerformedFreeRangeMovement); out.println("parsing - hasPerformedFreeRangeMovement: " + hasPerformedFreeRangeMovement);
} }
if (runnerState.mNextState == null) { if (runnerState.mNextState == null) {
if (mDebugging) { if (debugging) {
out.println("parsing - runnerState.mNextState == null"); out.println("parsing - runnerState.mNextState == null");
} }
@ -429,14 +428,14 @@ public class WildcardStringParser {
if (hasPerformedFreeRangeMovement) { if (hasPerformedFreeRangeMovement) {
if (parsableString.reachedEndOfString()) { if (parsableString.reachedEndOfString()) {
if (numberOfFreePassCharactersRead_SinceLastFreePassState > numberOfParsedCharactersRead_SinceLastFreePassState) { if (numberOfFreePassCharactersRead_SinceLastFreePassState > numberOfParsedCharactersRead_SinceLastFreePassState) {
if (mDebugging) { if (debugging) {
out.println( out.println(
"no subsequent state (final state) and the state represents '*' - end of parsing string, but not enough characters read - rejection!"); "no subsequent state (final state) and the state represents '*' - end of parsing string, but not enough characters read - rejection!");
} }
return false; return false;
} }
else { else {
if (mDebugging) { if (debugging) {
out.println( out.println(
"no subsequent state (final state) and the state represents '*' - end of parsing string and enough characters read - acceptance!"); "no subsequent state (final state) and the state represents '*' - end of parsing string and enough characters read - acceptance!");
} }
@ -445,7 +444,7 @@ public class WildcardStringParser {
} }
else { else {
if (numberOfFreePassCharactersRead_SinceLastFreePassState > numberOfParsedCharactersRead_SinceLastFreePassState) { if (numberOfFreePassCharactersRead_SinceLastFreePassState > numberOfParsedCharactersRead_SinceLastFreePassState) {
if (mDebugging) { if (debugging) {
out.println( out.println(
"no subsequent state (final state) and the state represents '*' - not the end of parsing string and not enough characters read - read next character"); "no subsequent state (final state) and the state represents '*' - not the end of parsing string and not enough characters read - read next character");
} }
@ -453,7 +452,7 @@ public class WildcardStringParser {
numberOfParsedCharactersRead_SinceLastFreePassState++; numberOfParsedCharactersRead_SinceLastFreePassState++;
} }
else { else {
if (mDebugging) { if (debugging) {
out.println( out.println(
"no subsequent state (final state) and the state represents '*' - not the end of parsing string, but enough characters read - acceptance!"); "no subsequent state (final state) and the state represents '*' - not the end of parsing string, but enough characters read - acceptance!");
} }
@ -462,7 +461,7 @@ public class WildcardStringParser {
} }
} }
else { else {
if (mDebugging) { if (debugging) {
out.println("no subsequent state (final state) and the state represents '*' - no skipping performed - acceptance!"); out.println("no subsequent state (final state) and the state represents '*' - no skipping performed - acceptance!");
} }
return true; return true;
@ -475,25 +474,25 @@ public class WildcardStringParser {
// Special free-range skipping check // Special free-range skipping check
if ((hasPerformedFreeRangeMovement) if ((hasPerformedFreeRangeMovement)
&& (numberOfFreePassCharactersRead_SinceLastFreePassState > numberOfParsedCharactersRead_SinceLastFreePassState)) { && (numberOfFreePassCharactersRead_SinceLastFreePassState > numberOfParsedCharactersRead_SinceLastFreePassState)) {
if (mDebugging) { if (debugging) {
out.println( out.println(
"no subsequent state (final state) and skipping has been performed and end of parsing string, but not enough characters read - rejection!"); "no subsequent state (final state) and skipping has been performed and end of parsing string, but not enough characters read - rejection!");
} }
return false; return false;
} }
if (mDebugging) { if (debugging) {
out.println("no subsequent state (final state) and the end of the string to test is reached - acceptance!"); out.println("no subsequent state (final state) and the end of the string to test is reached - acceptance!");
} }
return true; return true;
} }
else { else {
if (mDebugging) { if (debugging) {
out.println("parsing - escaping process..."); out.println("parsing - escaping process...");
} }
} }
} }
else { else {
if (mDebugging) { if (debugging) {
out.println("parsing - runnerState.mNextState != null"); out.println("parsing - runnerState.mNextState != null");
} }
@ -514,19 +513,19 @@ public class WildcardStringParser {
// Special Case: if the mask is at the end // Special Case: if the mask is at the end
if (runnerState.mNextState == null) { if (runnerState.mNextState == null) {
if (mDebugging) { if (debugging) {
out.println(); out.println();
} }
if (mDebugging) { if (debugging) {
out.println("parsing - index number " + i + ", active char: '" out.println("parsing - index number " + i + ", active char: '"
+ parsableString.getActiveChar() + "' char string index: " + parsableString.mIndex + parsableString.getActiveChar() + "' char string index: " + parsableString.mIndex
+ " number of chars since last free-range state: " + numberOfParsedCharactersRead_SinceLastFreePassState); + " number of chars since last free-range state: " + numberOfParsedCharactersRead_SinceLastFreePassState);
} }
if (mDebugging) { if (debugging) {
out.println("parsing - state: " + runnerState.mAutomatonStateNumber + " '" out.println("parsing - state: " + runnerState.mAutomatonStateNumber + " '"
+ runnerState.mChar + "' - no of free-pass chars read: " + numberOfFreePassCharactersRead_SinceLastFreePassState); + runnerState.mChar + "' - no of free-pass chars read: " + numberOfFreePassCharactersRead_SinceLastFreePassState);
} }
if (mDebugging) { if (debugging) {
out.println("parsing - hasPerformedFreeRangeMovement: " out.println("parsing - hasPerformedFreeRangeMovement: "
+ hasPerformedFreeRangeMovement); + hasPerformedFreeRangeMovement);
} }
@ -569,14 +568,14 @@ public class WildcardStringParser {
numberOfParsedCharactersRead_SinceLastFreePassState++; numberOfParsedCharactersRead_SinceLastFreePassState++;
} }
else { else {
if (mDebugging) { if (debugging) {
out.println("the next state does not represent the same character as the next character in the string to test, and there are no last-free-range-state - rejection!"); out.println("the next state does not represent the same character as the next character in the string to test, and there are no last-free-range-state - rejection!");
} }
return false; return false;
} }
} }
} }
if (mDebugging) { if (debugging) {
out.println("finished reading parsing string and not at any final state - rejection!"); out.println("finished reading parsing string and not at any final state - rejection!");
} }
return false; return false;
@ -595,18 +594,18 @@ public class WildcardStringParser {
StringBuilder buffer = new StringBuilder(); StringBuilder buffer = new StringBuilder();
if (!mInitialized) { if (!initialized) {
buffer.append(getClass().getName()); buffer.append(getClass().getName());
buffer.append(": Not initialized properly!"); buffer.append(": Not initialized properly!");
buffer.append("\n"); buffer.append("\n");
buffer.append("\n"); buffer.append("\n");
} }
else { else {
WildcardStringParserState runnerState = mInitialState; WildcardStringParserState runnerState = initialState;
buffer.append(getClass().getName()); buffer.append(getClass().getName());
buffer.append(": String mask "); buffer.append(": String mask ");
buffer.append(mStringMask); buffer.append(stringMask);
buffer.append("\n"); buffer.append("\n");
buffer.append("\n"); buffer.append("\n");
buffer.append(" Automaton: "); buffer.append(" Automaton: ");
@ -630,7 +629,7 @@ public class WildcardStringParser {
buffer.append("\n"); buffer.append("\n");
buffer.append(" Format: <state index>: <character> (<last free state>)"); buffer.append(" Format: <state index>: <character> (<last free state>)");
buffer.append("\n"); buffer.append("\n");
buffer.append(" Number of strings parsed: " + mTotalNumberOfStringsParsed); buffer.append(" Number of strings parsed: " + totalNumberOfStringsParsed);
buffer.append("\n"); buffer.append("\n");
} }
return buffer.toString(); return buffer.toString();
@ -647,7 +646,7 @@ public class WildcardStringParser {
if (pObject instanceof WildcardStringParser) { if (pObject instanceof WildcardStringParser) {
WildcardStringParser externalParser = (WildcardStringParser) pObject; WildcardStringParser externalParser = (WildcardStringParser) pObject;
return ((externalParser.mInitialized == this.mInitialized) && (externalParser.mStringMask == this.mStringMask)); return ((externalParser.initialized == this.initialized) && (externalParser.stringMask == this.stringMask));
} }
return super.equals(pObject); return super.equals(pObject);
} }
@ -665,8 +664,8 @@ public class WildcardStringParser {
protected Object clone() throws CloneNotSupportedException { protected Object clone() throws CloneNotSupportedException {
if (mInitialized) { if (initialized) {
return new WildcardStringParser(mStringMask); return new WildcardStringParser(stringMask);
} }
return null; return null;
} }

View File

@ -93,7 +93,7 @@ interface QuickDraw {
int SUB_OVER = 38; int SUB_OVER = 38;
int AD_MIN = 39; int AD_MIN = 39;
int GRAYISH_TEXT_OR = 49; int GRAYISH_TEXT_OR = 49;
// int MASK = 64; // ?! From Käry's code.. // int MASK = 64; // ?! From Käry's code..
/* /*
* Text face masks. * Text face masks.