@Override public boolean endElementHandler(String tag) { tag = tag.toLowerCase().intern(); switch (myReadState) { case READ_NONE: break; case READ_MAP: if (TAG_NAVMAP == tag) { myReadState = READ_NONE; } break; case READ_POINT: if (TAG_NAVPOINT == tag) { NavPoint last = myPointStack.get(myPointStack.size() - 1); if (last.Text.length() == 0) { last.Text = "..."; } myNavigationMap.put(last.Order, last); myPointStack.remove(myPointStack.size() - 1); myReadState = (myPointStack.isEmpty()) ? READ_MAP : READ_POINT; } case READ_LABEL: if (TAG_NAVLABEL == tag) { myReadState = READ_POINT; } break; case READ_TEXT: if (TAG_TEXT == tag) { myReadState = READ_LABEL; } break; } return false; }
@Override public void characterDataHandler(char[] ch, int start, int length) { if (myReadState == READ_TEXT) { final ArrayList<NavPoint> stack = myPointStack; final NavPoint last = stack.get(stack.size() - 1); last.Text += new String(ch, start, length); } }
@Override public boolean startElementHandler(String tag, ZLStringMap attributes) { tag = tag.toLowerCase().intern(); switch (myReadState) { case READ_NONE: if (tag == TAG_NAVMAP) { myReadState = READ_MAP; } break; case READ_MAP: if (tag == TAG_NAVPOINT) { final String order = attributes.getValue(ATTRIBUTE_PLAYORDER); final int index = (order != null) ? atoi(order) : myPlayIndex++; myPointStack.add(new NavPoint(index, myPointStack.size())); myReadState = READ_POINT; } break; case READ_POINT: if (tag == TAG_NAVPOINT) { final String order = attributes.getValue(ATTRIBUTE_PLAYORDER); final int index = (order != null) ? atoi(order) : myPlayIndex++; myPointStack.add(new NavPoint(index, myPointStack.size())); } else if (tag == TAG_NAVLABEL) { myReadState = READ_LABEL; } else if (tag == TAG_CONTENT) { final int size = myPointStack.size(); if (size > 0) { myPointStack.get(size - 1).ContentHRef = ZLArchiveEntryFile.normalizeEntryName( myLocalPathPrefix + MiscUtil.decodeHtmlReference(attributes.getValue("src"))); } } break; case READ_LABEL: if (TAG_TEXT == tag) { myReadState = READ_TEXT; } break; case READ_TEXT: break; } return false; }
public boolean readDocument() { try { myStream = new ZLInputStreamWithOffset(myFile.getInputStream()); PdbHeader header = new PdbHeader(myStream); setMainTextModel(); myFont = FontType.FT_REGULAR; for (int index = 0; index < header.Offsets.length; ++index) { int currentOffset = myStream.offset(); int pit = header.Offsets[index]; if (currentOffset > pit) { break; } // myStream.seek(pit - currentOffset, false); myStream.skip(pit - currentOffset); if (myStream.offset() != pit) { break; } int recordSize = ((index != header.Offsets.length - 1) ? header.Offsets[index + 1] : myFileSize) - pit; readRecord(recordSize); } myStream.close(); } catch (IOException e) { return false; } for (Iterator it = myReferencedParagraphs.iterator(); it.hasNext(); ) { Pair pair = (Pair) it.next(); int first = (Integer) pair.myFirst; int second = (Integer) pair.mySecond; ArrayList /*<Integer>*/ list = (ArrayList) myParagraphMap.get(first); if (list != null) { for (int k = second; k < list.size(); ++k) { if (((Integer) ((Pair) list.get(k)).myFirst) != -1) { // addHyperlinkLabel(fromNumber(first) + '#' + fromNumber(second), // (Integer)list.get(k)); final Pair p = (Pair) list.get(k); // addHyperlinkLabel(fromNumber(first) + '#' + fromNumber(second), (Integer) p.mySecond, // (Integer) p.myFirst); break; } } } } myReferencedParagraphs.clear(); myParagraphMap.clear(); return true; }