Skip to content

Commit 27118ab

Browse files
committed
Support for Multiple Parsers completed.
* kpdfsync version changed to 0.10.0. * Readme updated with new screenshot. * BugFix: Open Clippings file button was disabled before Parser selection. * AbstractKindleParserConstants, ParserResultFieldsFilter classes removed. These classes complicated the parser implementation, and added little benefit. For now V2 Parser overrides methods of V1. Looking for be a better solution!
1 parent d67ff53 commit 27118ab

File tree

9 files changed

+18
-164
lines changed

9 files changed

+18
-164
lines changed

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,20 @@ Here is the rough roadmap of the development.
4646

4747
----
4848

49+
- [X] Bug Fixes: Some minor fixes in UI
50+
- [X] Feature: Added new parser for reading older Kindle Clippings format.
51+
- [X] UI change to select different parsers.
52+
- [ ] **Alpha Release 4**
53+
54+
----
55+
4956
- [ ] Fine tune the rough edges in the supporting library.
5057
- [ ] Memory/Resource optimization.
5158
- [ ] Finalizing and optimizing the Graphical User Interface.
5259
- [ ] **Beta Release**
5360

5461
## Requirements
55-
- JRE 1.8 or higher
62+
- JRE 1.8 or higher __Note: JRE headless will not work.__
5663
- Linux, Windows
5764
- Mac OS
5865

build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ cp -r src/coderarjob/kpdfsync/poc/res $BIN_DIR/coderarjob/kpdfsync/poc || exit
6363
# -----------------------------------------------------------------------------
6464
# Replace placeholder information in resource files.
6565
# -----------------------------------------------------------------------------
66-
VER=0.9.0
66+
VER=0.10.0
6767
TAG=alpha
6868
buildid=$(date +%y%m%d)
6969

docs/images/screenshot_alpha.png

5.97 KB
Loading

src/coderarjob/kpdfsync/lib/clipparser/AbstractKindleParserConstants.java

Lines changed: 0 additions & 37 deletions
This file was deleted.

src/coderarjob/kpdfsync/lib/clipparser/AbstractParser.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ public abstract class AbstractParser
1818
/* Abstract protected methods */
1919
protected abstract boolean isTerminationLine (String linestr);
2020
protected abstract boolean parseLine(int linei, ParserResult res) throws Exception;
21-
//protected abstract AbstractKindleParserConstants getKindleParserConstants();
2221

2322
/* Protected fields */
2423
protected String mFileName;
@@ -29,7 +28,6 @@ public abstract class AbstractParser
2928
False indicates, no error, or file pointer has
3029
moved to the next block after the previous parsing
3130
error.*/
32-
//protected AbstractKindleParserConstants mConstants = null;
3331

3432
/* Private fields */
3533
private long mLastFilePointer;
@@ -88,7 +86,6 @@ public AbstractParser (String fileName) throws FileNotFoundException, IOExceptio
8886
this.mLastFilePointer = -1;
8987
this.mParserEvents = null;
9088
this.mIsInvalidState = false;
91-
//this.mConstants = getKindleParserConstants();
9289
}
9390

9491
/**
@@ -188,16 +185,6 @@ protected ParserException genParserException (String field)
188185
return new ParserException (errDes);
189186
}
190187

191-
/**
192-
* Checks if the specified line is the termination line.
193-
*/
194-
/*protected boolean isTerminationLine (String linestr)
195-
{
196-
assert (linestr != null);
197-
ParserResultFieldsFilter<Boolean> filter = mConstants.getTerminationLineFilter();
198-
return filter.getOrDefault(linestr, false);
199-
}*/
200-
201188
/**
202189
* Checks if End of File has been reached.
203190
*/

src/coderarjob/kpdfsync/lib/clipparser/KindleParserV1.java

Lines changed: 8 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -43,49 +43,6 @@ public String toString()
4343
}
4444

4545
/* Implementing abstract methods from AbstractParser*/
46-
protected boolean isTerminationLine (String linestr)
47-
{
48-
return linestr.toLowerCase().equals(TERMINATION_LINE_PATTERN);
49-
}
50-
51-
/*protected AbstractKindleParserConstants getKindleParserConstants ()
52-
{
53-
AbstractKindleParserConstants constants = new AbstractKindleParserConstants () {
54-
public ParserResultFieldsFilter<AnnotationType> getAnnotationTypeFilter(ParserResult res)
55-
{
56-
Hashtable<String, AnnotationType> ht = new Hashtable<>();
57-
ht.put("highlight", AnnotationType.HIGHLIGHT);
58-
ht.put("note", AnnotationType.NOTE);
59-
ht.put("bookmark", AnnotationType.BOOKMARK);
60-
61-
return new ParserResultFieldsFilter<> (2, ht);
62-
}
63-
64-
public ParserResultFieldsFilter<PageNumberType> getPageNumberTypeFilter(ParserResult res)
65-
{
66-
Hashtable<String, PageNumberType> ht = new Hashtable<>();
67-
ht.put("page", PageNumberType.PAGE_NUMBER);
68-
ht.put("location", PageNumberType.LOCATION_NUMBER);
69-
70-
return new ParserResultFieldsFilter<> (4, ht);
71-
}
72-
73-
public ParserResultFieldsFilter<Object> getPageOrLocationNumberFilter(ParserResult res)
74-
{
75-
return new ParserResultFieldsFilter<> (5, null);
76-
}
77-
78-
public ParserResultFieldsFilter<Boolean> getTerminationLineFilter()
79-
{
80-
Hashtable<String, Boolean> ht = new Hashtable<>();
81-
ht.put ("==========", true);
82-
return new ParserResultFieldsFilter<> (0, ht);
83-
}
84-
};
85-
86-
return constants;
87-
}*/
88-
8946
public String getParserVersion ()
9047
{
9148
return "1.0";
@@ -96,6 +53,14 @@ public String[] getSupportedKindleVersions ()
9653
return new String[] {"5.12.*", "newer"};
9754
}
9855

56+
/**
57+
* Checks if the specified line is the termination line.
58+
*/
59+
protected boolean isTerminationLine (String linestr)
60+
{
61+
return linestr.toLowerCase().equals(TERMINATION_LINE_PATTERN);
62+
}
63+
9964
/**
10065
* Parses each line of the current block.
10166
* Returns a ParserResult object with the parsed result.

src/coderarjob/kpdfsync/lib/clipparser/KindleParserV2.java

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -51,45 +51,6 @@ public String[] getSupportedKindleVersions ()
5151
return new String[] {"3.4.3", "older"};
5252
}
5353

54-
/*protected AbstractKindleParserConstants getKindleParserConstants ()
55-
{
56-
AbstractKindleParserConstants constants = new AbstractKindleParserConstants () {
57-
public ParserResultFieldsFilter<AnnotationType> getAnnotationTypeFilter(ParserResult res)
58-
{
59-
Hashtable<String, AnnotationType> ht = new Hashtable<>();
60-
ht.put("highlight", AnnotationType.HIGHLIGHT);
61-
ht.put("note", AnnotationType.NOTE);
62-
ht.put("bookmark", AnnotationType.BOOKMARK);
63-
64-
return new ParserResultFieldsFilter<> (1, ht);
65-
}
66-
67-
public ParserResultFieldsFilter<PageNumberType> getPageNumberTypeFilter(ParserResult res)
68-
{
69-
Hashtable<String, PageNumberType> ht = new Hashtable<>();
70-
ht.put("page", PageNumberType.PAGE_NUMBER);
71-
ht.put("location", PageNumberType.LOCATION_NUMBER);
72-
ht.put("loc.", PageNumberType.LOCATION_NUMBER);
73-
74-
return new ParserResultFieldsFilter<> (3, ht);
75-
}
76-
77-
public ParserResultFieldsFilter<Object> getPageOrLocationNumberFilter(ParserResult res)
78-
{
79-
return new ParserResultFieldsFilter<> (4, null);
80-
}
81-
82-
public ParserResultFieldsFilter<Boolean> getTerminationLineFilter()
83-
{
84-
Hashtable<String, Boolean> ht = new Hashtable<>();
85-
ht.put ("==========", true);
86-
return new ParserResultFieldsFilter<> (0, ht);
87-
}
88-
};
89-
90-
return constants;
91-
}*/
92-
9354
protected void parseAnnotationType (ParserResult result) throws IOException, ParserException
9455
{
9556
/* Read current line. Cannot be EOF.*/

src/coderarjob/kpdfsync/lib/clipparser/ParserResultFieldsFilter.java

Lines changed: 0 additions & 30 deletions
This file was deleted.

src/coderarjob/kpdfsync/poc/MainFrame.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,7 @@ public void run() {
744744
break;
745745
case CLIPPING_FILE_SELECTED:
746746
selectBookNameComboBox.removeAllItems ();
747+
browseClippingsFileButton.setEnabled (true);
747748
selectKindleVersionComboBox.setEnabled (true);
748749
parserKindleSupportInfoButton.setEnabled (false);
749750
break;

0 commit comments

Comments
 (0)