Java 类com.lowagie.text.xml.XmlPeer 实例源码

项目:itext2    文件:EventsTest.java   
/**
 * We only alter the handling of some endtags.
 * 
 * @param uri
 *            the uri of the namespace
 * @param lname
 *            the local name of the tag
 * @param name
 *            the name of the tag
 */
public void endElement(String uri, String lname, String name) {
    if (myTags.containsKey(name)) {
        XmlPeer peer = (XmlPeer) myTags.get(name);
        // we don't want the document to be close
        // because we are going to add a page after the xml is parsed
        if (isDocumentRoot(peer.getTag())) {
            return;
        }
        handleEndingTags(peer.getTag());
        // we want to add a paragraph after the speaker chunk
        if ("SPEAKER".equals(name)) {
            try {
                TextElementArray previous = (TextElementArray) stack
                        .pop();
                previous.add(new Paragraph(16));
                stack.push(previous);
            } catch (EmptyStackException ese) {
            }
        }
    } else {
        handleEndingTags(name);
    }
}
项目:PDFTestForAndroid    文件:Events.java   
/**
 * We only alter the handling of some endtags.
 * 
 * @param uri
 *            the uri of the namespace
 * @param lname
 *            the local name of the tag
 * @param name
 *            the name of the tag
 */
public void endElement(String uri, String lname, String name) {
    if (myTags.containsKey(name)) {
        XmlPeer peer = (XmlPeer) myTags.get(name);
        // we don't want the document to be close
        // because we are going to add a page after the xml is parsed
        if (isDocumentRoot(peer.getTag())) {
            return;
        }
        handleEndingTags(peer.getTag());
        // we want to add a paragraph after the speaker chunk
        if ("SPEAKER".equals(name)) {
            try {
                TextElementArray previous = (TextElementArray) stack.pop();
                previous.add(new Paragraph(16));
                stack.push(previous);
            } catch (EmptyStackException ese) {
            }
        }
    } else {
        handleEndingTags(name);
    }
}
项目:itext2    文件:EventsTest.java   
/**
 * Constructs a TagMap based on an XML file and/or on XmlPeer objects
 * that are added.
 * 
 * @throws IOException
 */
public RomeoJulietMap() throws IOException {
    super(new FileInputStream(PdfTestBase.RESOURCES_DIR
            + "tagmapRomeoJuliet.xml"));
    XmlPeer peer = new XmlPeer(ElementTags.CHUNK, "SPEAKER");
    peer.addValue(Markup.CSS_KEY_FONTSIZE, "10");
    peer.addValue(Markup.CSS_KEY_FONTWEIGHT, Markup.CSS_VALUE_BOLD);
    peer.addValue(ElementTags.GENERICTAG, "");
    put(peer.getAlias(), peer);
}
项目:PDFTestForAndroid    文件:Events.java   
/**
 * Constructs a TagMap based on an XML file and/or on XmlPeer objects
 * that are added.
 * 
 * @throws IOException
 */
public RomeoJulietMap() throws IOException {
    //Can't use FileInputStream directly
    //super(new FileInputStream("tagmapRomeoJuliet.xml"));
    super(PdfTestRunner.getActivity().getResources().openRawResource(R.raw.tagmapromeojuliet));
    XmlPeer peer = new XmlPeer(ElementTags.CHUNK, "SPEAKER");
    peer.addValue(Markup.CSS_KEY_FONTSIZE, "10");
    peer.addValue(Markup.CSS_KEY_FONTWEIGHT, Markup.CSS_VALUE_BOLD);
    peer.addValue(ElementTags.GENERICTAG, "");
    put(peer.getAlias(), peer);
}
项目:itext2    文件:SAXmyHtmlHandler.java   
/**
 * This method gets called when an end tag is encountered.
 * 
 * @param uri
 *            the Uniform Resource Identifier
 * @param lname
 *            the local name (without prefix), or the empty string if
 *            Namespace processing is not being performed.
 * @param name
 *            the name of the tag that ends
 */

public void endElement(String uri, String lname, String name) {
    // System.err.println("End: " + name);
    name = name.toLowerCase();
    if (ElementTags.PARAGRAPH.equals(name)) {
        try {
            document.add((Element) stack.pop());
            return;
        } catch (DocumentException e) {
            throw new ExceptionConverter(e);
        }
    }
    if (HtmlTagMap.isHead(name)) {
        // we do nothing
        return;
    }
    if (HtmlTagMap.isTitle(name)) {
        if (currentChunk != null) {
            bodyAttributes.put(ElementTags.TITLE, currentChunk.getContent());
        }
        return;
    }
    if (HtmlTagMap.isMeta(name)) {
        // we do nothing
        return;
    }
    if (HtmlTagMap.isLink(name)) {
        // we do nothing
        return;
    }
    if (HtmlTagMap.isBody(name)) {
        // we do nothing
        return;
    }
    if (myTags.containsKey(name)) {
        XmlPeer peer = (XmlPeer) myTags.get(name);
        if (ElementTags.TABLE.equals(peer.getTag())) {
            tableBorder = false;
        }
        super.handleEndingTags(peer.getTag());
        return;
    }
    // super.handleEndingTags is replaced with handleEndingTags
    // suggestion by Ken Auer
    handleEndingTags(name);
}
项目:DroidText    文件:SAXmyHtmlHandler.java   
/**
 * This method gets called when an end tag is encountered.
 * 
 * @param uri
 *            the Uniform Resource Identifier
 * @param lname
 *            the local name (without prefix), or the empty string if
 *            Namespace processing is not being performed.
 * @param name
 *            the name of the tag that ends
 */

public void endElement(String uri, String lname, String name) {
    // System.err.println("End: " + name);
    name = name.toLowerCase();
    if (ElementTags.PARAGRAPH.equals(name)) {
        try {
            document.add((Element) stack.pop());
            return;
        } catch (DocumentException e) {
            throw new ExceptionConverter(e);
        }
    }
    if (HtmlTagMap.isHead(name)) {
        // we do nothing
        return;
    }
    if (HtmlTagMap.isTitle(name)) {
        if (currentChunk != null) {
            bodyAttributes.put(ElementTags.TITLE, currentChunk.getContent());
        }
        return;
    }
    if (HtmlTagMap.isMeta(name)) {
        // we do nothing
        return;
    }
    if (HtmlTagMap.isLink(name)) {
        // we do nothing
        return;
    }
    if (HtmlTagMap.isBody(name)) {
        // we do nothing
        return;
    }
    if (myTags.containsKey(name)) {
        XmlPeer peer = (XmlPeer) myTags.get(name);
        if (ElementTags.TABLE.equals(peer.getTag())) {
            tableBorder = false;
        }
        super.handleEndingTags(peer.getTag());
        return;
    }
    // super.handleEndingTags is replaced with handleEndingTags
    // suggestion by Ken Auer
    handleEndingTags(name);
}