1+ package main ;
2+
13import org .pmw .tinylog .Logger ;
24
35import java .util .ArrayList ;
46import java .util .Arrays ;
57import java .util .List ;
68
79/**
8- * Parser object which interprets a given text file and creates an interpreted 'Item' object
10+ * main. Parser object which interprets a given text file and creates an interpreted 'main. Item' object
911 */
1012public class Parser {
1113
@@ -32,13 +34,13 @@ public class Parser {
3234 public static String SUBJECT = "SUBJECT" ;
3335 public static String TITLE = "TITLE" ;
3436 public static String TYPE = "TYPE" ;
35- public static String [] ALL_OPTIONS =
37+ public static String [] ALL_OPTIONS =
3638 { AUDIENCE , COVERAGE , DATE , DESCRIPTION , FILENAME , FORMAT , IDENTIFIER , LANGUAGE ,
3739 NOTE , PUBLISHER , RELATION , RIGHTS , RIGHTSHOLDER , SUBJECT , TITLE , TYPE };
3840
3941 //modes
40- protected enum mode { CONTRIBUTORS , ARTICLES , SUBJECT , NULL }
41- private mode current_mode = mode .NULL ;
42+ public enum mode { CONTRIBUTORS , ARTICLES , SUBJECT , NULL }
43+ protected mode current_mode = mode .NULL ;
4244
4345 //critical elements
4446 private ArrayList <String > lsHeaderOptions ;
@@ -47,28 +49,16 @@ protected enum mode { CONTRIBUTORS, ARTICLES, SUBJECT, NULL }
4749 private String current_qualifier ;
4850
4951
52+
5053 // - constructors - //
5154
5255 /**
5356 * base constructor which initializes object state and sets defaults
5457 */
5558 public Parser (){
5659
57- //initialize header options
58- lsHeaderOptions = new ArrayList <String >();
59-
60- /* set to default header:
61- * 0: title | 'Title of the Issue'
62- * 1: relation.isPartOfSeries | 'Volume ##, Number ##, "
63- * 2: date.issued | '1993-03-26'
64- * 3: title.alternative | ''
65- * 4: filename | 'filename.pdf'
66- */
67- lsHeaderOptions .add (TITLE );
68- lsHeaderOptions .add (RELATION + SPLIT_OPTION + "ISPARTOFSERIES" );
69- lsHeaderOptions .add (DATE + SPLIT_OPTION + "ISSUED" );
70- lsHeaderOptions .add (TITLE + SPLIT_OPTION + "ALTERNATIVE" );
71- lsHeaderOptions .add (FILENAME );
60+ //initialize header
61+ initHeader ();
7262
7363 //initialize list of shared values
7464 lsShared = new ArrayList <String []>();
@@ -212,6 +202,24 @@ else if (current_mode == mode.CONTRIBUTORS) {
212202
213203 // - helpers - //
214204
205+ private void initHeader (){
206+ //initialize header options
207+ lsHeaderOptions = new ArrayList <String >();
208+
209+ /* set to default header:
210+ * 0: title | 'Title of the Issue'
211+ * 1: relation.isPartOfSeries | 'Volume ##, Number ##, "
212+ * 2: date.issued | '1993-03-26'
213+ * 3: title.alternative | ''
214+ * 4: filename | 'filename.pdf'
215+ */
216+ lsHeaderOptions .add (TITLE );
217+ lsHeaderOptions .add (RELATION + SPLIT_OPTION + "ISPARTOFSERIES" );
218+ lsHeaderOptions .add (DATE + SPLIT_OPTION + "ISSUED" );
219+ lsHeaderOptions .add (TITLE + SPLIT_OPTION + "ALTERNATIVE" );
220+ lsHeaderOptions .add (FILENAME );
221+ }
222+
215223 /**
216224 * check list of header options sent in to see if they are valid
217225 * @param lsOptions the set of custom options the user established for the header
@@ -250,7 +258,7 @@ private static boolean containsAny(String[] target, String given){
250258
251259 /* - Mode Entry - */
252260
253- protected static mode determineMode (String str ){
261+ public static mode determineMode (String str ){
254262
255263 if (matchTableOfContents (str ) ){ return mode .ARTICLES ; }
256264 else if (matchContributor (str )){ return mode .CONTRIBUTORS ; }
0 commit comments