public void endElement()

in fop-core/src/main/java/org/apache/fop/render/afp/extensions/AFPExtensionHandler.java [84:169]


    public void endElement(String uri, String localName, String qName) throws SAXException {
        if (AFPExtensionAttachment.CATEGORY.equals(uri)) {
            if (AFPElementMapping.INCLUDE_FORM_MAP.equals(localName)) {
                AFPIncludeFormMap formMap = new AFPIncludeFormMap();
                String name = lastAttributes.getValue("name");
                formMap.setName(name);
                String src = lastAttributes.getValue("src");
                try {
                    formMap.setSrc(new URI(src));
                } catch (URISyntaxException e) {
                    throw new SAXException("Invalid URI: " + src, e);
                }
                this.returnedObject = formMap;
            } else if (AFPElementMapping.INCLUDE_PAGE_OVERLAY.equals(localName)) {
                AFPPageOverlay afpPageOverlay = new AFPPageOverlay();
                this.returnedObject = afpPageOverlay;
                String name = lastAttributes.getValue("name");
                if (name != null) {
                    returnedObject.setName(name);
                }
                String x = lastAttributes.getValue("x");
                if (x != null) {
                    afpPageOverlay.setX(Integer.parseInt(x));
                }
                String y = lastAttributes.getValue("y");
                if (y != null) {
                    afpPageOverlay.setY(Integer.parseInt(y));
                }
            } else if (AFPElementMapping.INCLUDE_PAGE_SEGMENT.equals(localName)) {
                AFPPageSegmentSetup pageSetupExtn = null;

                pageSetupExtn = new AFPPageSegmentSetup(localName);
                this.returnedObject = pageSetupExtn;

                String name = lastAttributes.getValue("name");
                if (name != null) {
                    returnedObject.setName(name);
                }
                String value = lastAttributes.getValue("value");
                if (value != null && pageSetupExtn != null) {
                    pageSetupExtn.setValue(value);
                }

                String resourceSrc = lastAttributes.getValue("resource-file");
                if (resourceSrc != null && pageSetupExtn != null) {
                    pageSetupExtn.setResourceSrc(resourceSrc);
                }

                if (content.length() > 0 && pageSetupExtn != null) {
                    pageSetupExtn.setContent(content.toString());
                    content.setLength(0); //Reset text buffer (see characters())
                }
            } else {
                AFPPageSetup pageSetupExtn = null;
                if (AFPElementMapping.INVOKE_MEDIUM_MAP.equals(localName)) {
                    this.returnedObject = new AFPInvokeMediumMap();
                } else {
                    pageSetupExtn = new AFPPageSetup(localName);
                    this.returnedObject = pageSetupExtn;
                }
                String name = lastAttributes.getValue(AFPPageSetup.ATT_NAME);
                if (name != null) {
                    returnedObject.setName(name);
                }
                String value = lastAttributes.getValue(AFPPageSetup.ATT_VALUE);
                if (value != null && pageSetupExtn != null) {
                    pageSetupExtn.setValue(value);
                }
                String placement = lastAttributes.getValue(AFPPageSetup.ATT_PLACEMENT);
                if (placement != null && placement.length() > 0) {
                    pageSetupExtn.setPlacement(ExtensionPlacement.fromXMLValue(placement));
                }

                String encoding =  lastAttributes.getValue("encoding");
                if (encoding != null && pageSetupExtn != null) {
                    pageSetupExtn.setEncoding(Integer.parseInt(encoding));
                }

                if (content.length() > 0 && pageSetupExtn != null) {
                    pageSetupExtn.setContent(content.toString());
                    content.setLength(0); //Reset text buffer (see characters())
                }
            }

        }
    }