Example usage for org.xml.sax SAXException SAXException

List of usage examples for org.xml.sax SAXException SAXException

Introduction

In this page you can find the example usage for org.xml.sax SAXException SAXException.

Prototype

public SAXException(Exception e) 

Source Link

Document

Create a new SAXException wrapping an existing exception.

Usage

From source file:org.apache.fop.complexscripts.fonts.ttx.TTXFile.java

private void mismatchedEntries(String[] en, int nce, int nse) throws SAXException {
    throw new SAXException(formatLocator() + ": element " + formatExpandedName(en)
            + " mismatched coverage and subtable entry counts, # coverages " + nce + ", # entries " + nse);
}

From source file:org.apache.fop.complexscripts.fonts.ttx.TTXFile.java

private void missingParameter(String[] en, String label) throws SAXException {
    throw new SAXException(
            formatLocator() + ": element " + formatExpandedName(en) + " missing " + label + " parameter");
}

From source file:org.apache.fop.complexscripts.fonts.ttx.TTXFile.java

private void duplicateParameter(String[] en, String label) throws SAXException {
    throw new SAXException(
            formatLocator() + ": element " + formatExpandedName(en) + " duplicate " + label + " parameter");
}

From source file:org.apache.fop.complexscripts.fonts.ttx.TTXFile.java

private void duplicateCoverageIndex(String[] en, int index) throws SAXException {
    throw new SAXException(formatLocator() + ": element " + formatExpandedName(en)
            + " duplicate coverage table index " + index);
}

From source file:org.apache.fop.complexscripts.fonts.ttx.TTXFile.java

private void missingCoverage(String[] en, String type, int expected) throws SAXException {
    throw new SAXException(formatLocator() + ": element " + formatExpandedName(en) + " missing " + type
            + " coverage table, expected " + ((expected > 0) ? expected : 1) + " table(s)");
}

From source file:org.apache.fop.complexscripts.fonts.ttx.TTXFile.java

private void missingTag(String[] en, String label) throws SAXException {
    throw new SAXException(
            formatLocator() + ": element " + formatExpandedName(en) + " missing " + label + " tag");
}

From source file:org.apache.fop.complexscripts.fonts.ttx.TTXFile.java

private void duplicateTag(String[] en, String label, String tag) throws SAXException {
    throw new SAXException(
            formatLocator() + ": element " + formatExpandedName(en) + " duplicate " + label + " tag: " + tag);
}

From source file:org.apache.fop.fonts.apps.TTFReader.java

/**
 * Bugzilla 40739, check that attr has a metrics-version attribute
 * compatible with ours.//from   w  w  w.j a  va  2  s .co m
 * @param attr attributes read from the root element of a metrics XML file
 * @throws SAXException if incompatible
 */
public static void checkMetricsVersion(Attributes attr) throws SAXException {
    String err = null;
    final String str = attr.getValue(METRICS_VERSION_ATTR);
    if (str == null) {
        err = "Missing " + METRICS_VERSION_ATTR + " attribute";
    } else {
        int version = 0;
        try {
            version = Integer.parseInt(str);
            if (version < METRICS_VERSION) {
                err = "Incompatible " + METRICS_VERSION_ATTR + " value (" + version + ", should be "
                        + METRICS_VERSION + ")";
            }
        } catch (NumberFormatException e) {
            err = "Invalid " + METRICS_VERSION_ATTR + " attribute value (" + str + ")";
        }
    }

    if (err != null) {
        throw new SAXException(
                err + " - please regenerate the font metrics file with " + "a more recent version of FOP.");
    }
}

From source file:org.apache.fop.render.afp.extensions.AFPExtensionHandler.java

/** {@inheritDoc} */
@Override//ww w  .j  a  va2 s  . c om
public void startElement(String uri, String localName, String qName, Attributes attributes)
        throws SAXException {
    boolean handled = false;
    if (AFPExtensionAttachment.CATEGORY.equals(uri)) {
        lastAttributes = new AttributesImpl(attributes);
        handled = true;
        if (localName.equals(AFPElementMapping.NO_OPERATION)
                || localName.equals(AFPElementMapping.TAG_LOGICAL_ELEMENT)
                || localName.equals(AFPElementMapping.INCLUDE_PAGE_OVERLAY)
                || localName.equals(AFPElementMapping.INCLUDE_PAGE_SEGMENT)
                || localName.equals(AFPElementMapping.INCLUDE_FORM_MAP)
                || localName.equals(AFPElementMapping.INVOKE_MEDIUM_MAP)) {
            //handled in endElement
        } else {
            handled = false;
        }
    }
    if (!handled) {
        if (AFPExtensionAttachment.CATEGORY.equals(uri)) {
            throw new SAXException("Unhandled element " + localName + " in namespace: " + uri);
        } else {
            log.warn("Unhandled element " + localName + " in namespace: " + uri);
        }
    }
}

From source file:org.apache.fop.render.intermediate.extensions.DocumentNavigationHandler.java

/** {@inheritDoc} */
public void startElement(String uri, String localName, String qName, Attributes attributes)
        throws SAXException {
    boolean handled = false;
    if (NAMESPACE.equals(uri)) {
        if (BOOKMARK_TREE.getLocalName().equals(localName)) {
            if (!objectStack.isEmpty()) {
                throw new SAXException(localName + " must be the root element!");
            }/*  w  w w  .ja  v  a  2 s . com*/
            BookmarkTree bookmarkTree = new BookmarkTree();
            objectStack.push(bookmarkTree);
        } else if (BOOKMARK.getLocalName().equals(localName)) {
            String title = attributes.getValue("title");
            String s = attributes.getValue("starting-state");
            boolean show = !"hide".equals(s);
            Bookmark b = new Bookmark(title, show, null);
            Object o = objectStack.peek();
            if (o instanceof AbstractAction) {
                AbstractAction action = (AbstractAction) objectStack.pop();
                o = objectStack.peek();
                ((Bookmark) o).setAction(action);
            }
            if (o instanceof BookmarkTree) {
                ((BookmarkTree) o).addBookmark(b);
            } else {
                ((Bookmark) o).addChildBookmark(b);
            }
            objectStack.push(b);
        } else if (NAMED_DESTINATION.getLocalName().equals(localName)) {
            if (!objectStack.isEmpty()) {
                throw new SAXException(localName + " must be the root element!");
            }
            String name = attributes.getValue("name");
            NamedDestination dest = new NamedDestination(name, null);
            objectStack.push(dest);
        } else if (LINK.getLocalName().equals(localName)) {
            if (!objectStack.isEmpty()) {
                throw new SAXException(localName + " must be the root element!");
            }
            Rectangle targetRect = XMLUtil.getAttributeAsRectangle(attributes, "rect");
            structureTreeElement = structureTreeElements
                    .get(attributes.getValue(InternalElementMapping.URI, InternalElementMapping.STRUCT_REF));
            Link link = new Link(null, targetRect);
            objectStack.push(link);
        } else if (GOTO_XY.getLocalName().equals(localName)) {
            String idref = attributes.getValue("idref");
            GoToXYAction action;
            if (idref != null) {
                action = new GoToXYAction(idref);
            } else {
                String id = attributes.getValue("id");
                int pageIndex = XMLUtil.getAttributeAsInt(attributes, "page-index");
                final Point location;
                if (pageIndex < 0) {
                    location = null;
                } else {
                    final int x = XMLUtil.getAttributeAsInt(attributes, "x");
                    final int y = XMLUtil.getAttributeAsInt(attributes, "y");
                    location = new Point(x, y);
                }
                action = new GoToXYAction(id, pageIndex, location);
            }
            if (structureTreeElement != null) {
                action.setStructureTreeElement(structureTreeElement);
            }
            objectStack.push(action);
        } else if (GOTO_URI.getLocalName().equals(localName)) {
            String id = attributes.getValue("id");
            String gotoURI = attributes.getValue("uri");
            String showDestination = attributes.getValue("show-destination");
            boolean newWindow = "new".equals(showDestination);
            URIAction action = new URIAction(gotoURI, newWindow);
            if (id != null) {
                action.setID(id);
            }
            if (structureTreeElement != null) {
                action.setStructureTreeElement(structureTreeElement);
            }
            objectStack.push(action);
        } else {
            throw new SAXException("Invalid element '" + localName + "' in namespace: " + uri);
        }
        handled = true;
    }
    if (!handled) {
        if (NAMESPACE.equals(uri)) {
            throw new SAXException("Unhandled element '" + localName + "' in namespace: " + uri);
        } else {
            log.warn("Unhandled element '" + localName + "' in namespace: " + uri);
        }
    }
}