Skip to content

Commit

Permalink
A litle code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Harrah (frizbog) committed Jul 2, 2016
1 parent c6ca414 commit e6948c2
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 56 deletions.
3 changes: 1 addition & 2 deletions src/main/java/org/gedcom4j/io/event/FileProgressEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@
*/
package org.gedcom4j.io.event;

import java.io.Serializable;
import java.util.EventObject;

/**
* An event to hold information about file processing progress.
*
* @author frizbog
*/
public class FileProgressEvent extends EventObject implements Serializable {
public class FileProgressEvent extends EventObject {

/**
* Serial version uid
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/org/gedcom4j/io/reader/GedcomFileReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,9 @@ private AbstractEncodingSpecificReader getEncodingSpecificReader() throws IOExce
* Could be ANSEL, ASCII, or UTF-8. Figure out which
*/
return anselAsciiOrUtf8();
} else {

throw new IOException("Does not appear to be a valid gedcom file - " + "doesn't begin with a zero or newline in any supported encoding, "
+ "and does not begin with a BOM marker for UTF-8 encoding. ");
}
throw new IOException("Does not appear to be a valid gedcom file - " + "doesn't begin with a zero or newline in any supported encoding, "
+ "and does not begin with a BOM marker for UTF-8 encoding. ");
}

}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/gedcom4j/parser/LinePieces.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ private void processLevel(int lineNum) throws GedcomParserException {
currCharIdx = 3; // Continue parsing at 4th character in line
}
} catch (NumberFormatException e) {
throw new GedcomParserException("Line " + lineNum + " does not begin with a 1 or 2 digit number for the level followed by a space: " + line);
throw new GedcomParserException("Line " + lineNum + " does not begin with a 1 or 2 digit number for the level followed by a space: " + line, e);
} catch (IndexOutOfBoundsException e) {
throw new GedcomParserException("Line " + lineNum + " does not begin with a 1 or 2 digit number for the level followed by a space: " + line);
throw new GedcomParserException("Line " + lineNum + " does not begin with a 1 or 2 digit number for the level followed by a space: " + line, e);
}
}

Expand Down
5 changes: 2 additions & 3 deletions src/main/java/org/gedcom4j/parser/StringTreeBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,10 @@ private boolean startsWithLevelAndSpace(int lineNum, String line) throws GedcomP
throw new GedcomParserException(
"Line " + lineNum + " does not begin with a 1 or 2 digit number for the level followed by a space: " + line);
}
} else {
throw new GedcomParserException("Line " + lineNum + " does not begin with a 1 or 2 digit number for the level followed by a space: " + line);
}
} catch (IndexOutOfBoundsException e) {
throw new GedcomParserException("Line " + lineNum + " does not begin with a 1 or 2 digit number for the level followed by a space: " + line);
} catch (IndexOutOfBoundsException e) {
throw new GedcomParserException("Line " + lineNum + " does not begin with a 1 or 2 digit number for the level followed by a space: " + line, e);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
*/
package org.gedcom4j.parser.event;

import java.io.Serializable;
import java.util.EventObject;

import org.gedcom4j.model.Gedcom;
Expand All @@ -31,7 +30,7 @@
*
* @author frizbog
*/
public class ParseProgressEvent extends EventObject implements Serializable {
public class ParseProgressEvent extends EventObject {

/**
* Serial version uid
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,8 @@ public int getGenerationCount(Individual descendant, Individual ancestor) {

if (lookForAncestor(descendant, ancestor) && genCount > 0) {
return genCount;
} else {
throw new IllegalArgumentException("Ancestor/descendant relationship not found for " + ancestor + " and "
+ descendant);
}
throw new IllegalArgumentException("Ancestor/descendant relationship not found for " + ancestor + " and " + descendant);
}

/**
Expand Down
63 changes: 33 additions & 30 deletions src/main/java/org/gedcom4j/relationship/SimplificationRules.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,40 @@
*/
final class SimplificationRules {

/**
* The rules for simplification
*/
static List<RelationshipName[]> rules = new ArrayList<RelationshipName[]>();

/**
* Private constructor prevents instantiation or subclassing
* <p>
* A list of 3-element arrays, containing rules on how to collapse complicated relationships down into simpler
* forms. Each row is an array of three {@link RelationshipName}s; let's call them r1, r2, and r3. Let's also assume
* there are three people: A, B, and C. If A is related to B by r1, and B is related to C by r2, then A is related
* to C as r3 and B can be removed.
* </p>
* <p>
* Example: Rule= <code>[FATHER, SON, BROTHER]</code>. Bob's FATHER is Jim; Jim's SON is Fred; therefore Bob's
* BROTHER is Fred.
* </p>
* <p>
* The order that these triplets appear in the list is the order in which the rules are applied. Rules that build on
* previous relationship simplifications should appear later in the list.
* </p>
*/
private SimplificationRules() {
super();

/* static initializer to load the list */
static {
mothersAndFathers();
siblings();
grandparentsAndGrandchildren();
greatGrandparentsAndGreatGrandchildren();
greatGreatGrandparentsAndGreatGreatGrandchildren();
greatGreatGreatGrandparentsAndGreatGreatGreatGrandchildren();
auntsUnclesNiecesNephews();
firstCousins();
greatAuntsUnclesNiecesNephews();
greatGreatAuntsUnclesNiecesNephews();
}

/**
Expand Down Expand Up @@ -325,34 +352,10 @@ private static void siblings() {
}

/**
* <p>
* A list of 3-element arrays, containing rules on how to collapse complicated relationships down into simpler
* forms. Each row is an array of three {@link RelationshipName}s; let's call them r1, r2, and r3. Let's also assume
* there are three people: A, B, and C. If A is related to B by r1, and B is related to C by r2, then A is related
* to C as r3 and B can be removed.
* </p>
* <p>
* Example: Rule= <code>[FATHER, SON, BROTHER]</code>. Bob's FATHER is Jim; Jim's SON is Fred; therefore Bob's
* BROTHER is Fred.
* </p>
* <p>
* The order that these triplets appear in the list is the order in which the rules are applied. Rules that build on
* previous relationship simplifications should appear later in the list.
* </p>
* Private constructor prevents instantiation or subclassing
*/

/* static initializer to load the list */
static {
mothersAndFathers();
siblings();
grandparentsAndGrandchildren();
greatGrandparentsAndGreatGrandchildren();
greatGreatGrandparentsAndGreatGreatGrandchildren();
greatGreatGreatGrandparentsAndGreatGreatGreatGrandchildren();
auntsUnclesNiecesNephews();
firstCousins();
greatAuntsUnclesNiecesNephews();
greatGreatAuntsUnclesNiecesNephews();
private SimplificationRules() {
super();
}

}
12 changes: 4 additions & 8 deletions src/main/java/org/gedcom4j/validate/AbstractValidator.java
Original file line number Diff line number Diff line change
Expand Up @@ -292,17 +292,15 @@ protected void checkStringList(List<String> stringList, String description, bool
addInfo("String list (" + description + ") contains null entry - removed", stringList);
stringList.remove(i);
continue;
} else {
addError("String list (" + description + ") contains null entry", stringList);
}
addError("String list (" + description + ") contains null entry", stringList);
} else if (!blanksAllowed && a.trim().length() == 0) {
if (rootValidator.autorepair == true) {
addInfo("String list (" + description + ") contains blank entry where none are allowed - removed", stringList);
stringList.remove(i);
continue;
} else {
addError("String list (" + description + ") contains blank entry where none are allowed", stringList);
}
addError("String list (" + description + ") contains blank entry where none are allowed", stringList);
}
i++;
}
Expand All @@ -328,17 +326,15 @@ protected void checkStringTagList(List<StringWithCustomTags> stringList, String
addInfo("String list (" + description + ") contains null entry - removed", stringList);
stringList.remove(i);
continue;
} else {
addError("String list (" + description + ") contains null entry", stringList);
}
addError("String list (" + description + ") contains null entry", stringList);
} else if (!blanksAllowed && a.value.trim().length() == 0) {
if (rootValidator.autorepair == true) {
addInfo("String list (" + description + ") contains blank entry where none are allowed - removed", stringList);
stringList.remove(i);
continue;
} else {
addError("String list (" + description + ") contains blank entry where none are allowed", stringList);
}
addError("String list (" + description + ") contains blank entry where none are allowed", stringList);
}
i++;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@
*/
package org.gedcom4j.writer.event;

import java.io.Serializable;
import java.util.EventObject;

/**
* An event to hold progress information about construction of GEDCOM strings
*
* @author frizbog
*/
public class ConstructProgressEvent extends EventObject implements Serializable {
public class ConstructProgressEvent extends EventObject {

/**
* Serial Version UID
Expand Down

0 comments on commit e6948c2

Please sign in to comment.