MCPcopy Create free account
hub / github.com/dumbledore/AlbiteREADER / loadBookmarks

Method loadBookmarks

src/org/albite/book/model/book/Book.java:253–341  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

251 }
252
253 private void loadBookmarks() throws IOException, BookException {
254
255 if (bookmarksFile == null) {
256 return;
257 }
258
259 /*
260 * Loading bookmarks
261 */
262 InputStream in = bookmarksFile.openInputStream();
263
264 KXmlParser parser = null;
265 Document doc = null;
266 Element root;
267 Element kid;
268
269 try {
270 parser = new KXmlParser();
271 parser.setInput(new InputStreamReader(in, "UTF-8"));
272
273 doc = new Document();
274 doc.parse(parser);
275 parser = null;
276 } catch (XmlPullParserException e) {
277 parser = null;
278 doc = null;
279 throw new BookException("Wrong XML data.");
280 }
281
282 try {
283
284 /*
285 * root element
286 */
287 root = doc.getRootElement();
288
289 int childCount = root.getChildCount();
290
291 for (int i = 0; i < childCount ; i++ ) {
292 if (root.getType(i) != Node.ELEMENT) {
293 continue;
294 }
295
296 kid = root.getElement(i);
297
298 final int chapter =
299 readIntFromXML(kid, USERDATA_CHAPTER_ATTRIB);
300
301 int position =
302 readIntFromXML(kid, USERDATA_POSITION_ATTRIB);
303
304 if (position < 0) {
305 position = 0;
306 }
307
308 if (kid.getName().equals(USERDATA_BOOKMARK_TAG)) {
309
310 String text = kid.getText(0);

Callers 1

loadUserDataMethod · 0.95

Calls 15

setInputMethod · 0.95
parseMethod · 0.95
getRootElementMethod · 0.95
readIntFromXMLMethod · 0.95
getNameMethod · 0.95
getChapterMethod · 0.95
getChildCountMethod · 0.80
addBookmarkMethod · 0.80
deleteAllMethod · 0.80
openInputStreamMethod · 0.45
getTypeMethod · 0.45
getElementMethod · 0.45

Tested by

no test coverage detected