* the responsibility of filling the note is something quite cohesive and hope
42
43
* the coupling involved won't do much damage. I guess time will tell.
43
44
*/
44
// FIXME This class needs love right now
45
45
public class NoteHandler extends DefaultHandler {
46
46
47
47
// position keepers
56
56
private boolean inSizeSmallTag = false;
57
57
private boolean inSizeLargeTag = false;
58
58
private boolean inSizeHugeTag = false;
59
private boolean inList = false;
60
private boolean inListItem = false;
59
61
60
// tag names
62
// -- Tomboy's notes XML tags names --
63
// Style related
61
64
private final static String NOTE_CONTENT = "note-content";
62
65
private final static String BOLD = "bold";
63
66
private final static String ITALIC = "italic";
64
67
private final static String STRIKETHROUGH = "strikethrough";
65
68
private final static String HIGHLIGHT = "highlight";
66
69
private final static String MONOSPACE = "monospace";
67
// Sizes are using a namespace identifier like <size:small></size:small>
70
// Sizes are using a namespace identifier size. Ex: <size:small></size:small>
68
71
private final static String NS_SIZE = "http://beatniksoftware.com/tomboy/size";
69
72
private final static String SMALL = "small";
70
73
private final static String LARGE = "large";
71
74
private final static String HUGE = "huge";
75
// List-related
76
// TODO nested lists are not supported
77
// I think that using a list integer instead of a boolean and incrementing or decrementing it depending on state would do it
78
private final static String LIST = "list";
79
private final static String LIST_ITEM = "list-item";
72
80
73
81
// accumulate notecontent is this var since it spans multiple xml tags
74
82
private SpannableStringBuilder ssb;
95
103
}
96
104
97
105
// if we are in note-content, keep and convert formatting tags
98
// TODO is XML CaSe SeNsItIve? if not change equals to equalsIgnoreCase
106
// TODO is XML CaSe SeNsItIve? if not change equals to equalsIgnoreCase and apply to endElement()
99
107
if (inNoteContentTag) {
100
108
if (localName.equals(BOLD)) {
101
109
inBoldTag = true;
116
124
} else if (localName.equals(HUGE)) {
117
125
inSizeHugeTag = true;
118
126
}
127
} else if (localName.equals(LIST)) {
128
inList = true;
129
} else if (localName.equals(LIST_ITEM)) {
130
inListItem = true;
119
131
}
120
132
}
121
133
153
165
inSizeLargeTag = false;
154
166
} else if (localName.equals(HUGE)) {
155
167
inSizeHugeTag = false;
156
}
168
}
169
} else if (localName.equals(LIST)) {
170
inList = false;
171
} else if (localName.equals(LIST_ITEM)) {
172
inListItem = false;
157
173
}
158
174
}
159
175
}
173
189
174
190
// apply style if required
175
191
// TODO I haven't tested nested tags yet
176
// TODO BulletSpan?
192
// TODO I've read somewhere in the SDK that instead of reusing members I should store it in a localized variable.. if performance becomes an issue here, think about that!