Package com.lightcrafts.utils.xml

Examples of com.lightcrafts.utils.xml.XMLException


            // readLine() returned null the first time it was called.
            throw new IOException(LOCALE.get("EmptyFileError", file.getName()));
        }

        if (! matcher.matches()) {
            throw new XMLException(LOCALE.get("MissingImageTagError"));
        }
        String path = matcher.replaceFirst("$1");
        if (path.length() == 0) {
            throw new XMLException(LOCALE.get("MissingImagePathError"));
        }
        imageFile = new File(matcher.replaceFirst("$1"));

        String relativePath = matcher.replaceFirst("$3");
        // The relative path attribute was introduced in LZN version 3,
View Full Code Here


        }
        if (tag.equals(getTag(Elliptic))) {
            curve = new EllipticCurve();
        }
        if (curve == null) {
            throw new XMLException("Unknown curve type: " + tag);
        }
        curve.restore(node);
        return curve;
    }
View Full Code Here

        try {
            final int value = Integer.parseInt(node.getAttribute(OpacityTag));
            slider.setValue(value);
        }
        catch (NumberFormatException e) {
            throw new XMLException(
                "Value at attribute \"" + OpacityTag + "\" is not a number", e
            );
        }
        final String modeName = node.getAttribute(ModeTag);
        for ( LayerMode mode : layerModes ) {
            if ( modeName.equals( mode.getName() ) ) {
                setMode( mode );
                return;
            }
        }
        throw new XMLException(
            "Value at attribute \"" + ModeTag + "\" is not a valid layer mode"
        );
    }
View Full Code Here

                colorSelectionToControls( cs, false );
                m_op.setColorSelection( cs );
                m_currentEdit = new ColorSelectionEdit();
            }
            catch ( IllegalArgumentException e ) {
                throw new XMLException( e );
            }
        }
    }
View Full Code Here

    private void validate() throws XMLException {
        // Explore the structure of the XmlDocument enough to make sure the
        // other methods of this class will not encounter XMLExceptions.
        XmlNode controls = getControlNode();
        if (controls == null) {
            throw new XMLException("No Control node");
        }
        XmlNode[] tools = getToolNodes();
        XmlNode[] regions = getRegionNodes();
        if (tools.length != regions.length) {
            throw new XMLException("Tool tags do not match region tags");
        }
    }
View Full Code Here

    public void restore(XmlNode node) throws XMLException {
        try {
            width = Float.parseFloat(node.getAttribute(WidthTag));
        }
        catch (NumberFormatException e) {
            throw new XMLException("Invalid curve width", e);
        }
        points.clear();
        XmlNode[] children = node.getChildren();
        for (int n=0; n<children.length; n++) {
            XmlNode child = children[n];
            if (child.getName().equals(PointTag)) {
                try {
                    double x = Double.parseDouble(child.getAttribute("x"));
                    double y = Double.parseDouble(child.getAttribute("y"));
                    Point2D p = new Point2D.Double(x, y);
                    points.add(p);
                }
                catch (NumberFormatException e) {
                    throw new XMLException("Invalid curve coordinates", e);
                }
            }
        }
        updateShapes();
View Full Code Here

                value = node.getAttribute(DenominatorTag);
                denominator = Integer.parseInt(value);
                return;
            }
            else {
                throw new XMLException(
                    "Unexpected attribute: " + key
                );
            }
        }
        catch (NumberFormatException e) {
            throw new XMLException(
                "Not a number :\"" + value + "\"", e
            );
        }
    }
View Full Code Here

            curve.restore(curveNode);
            curveNumbers.put(count++, curve);
        }
        XmlNode[] compNodes = node.getChildren(ComponentTag);
        if (compNodes.length != comps.size()) {
            throw new XMLException(
                "The number of regions doesn't match the number of tools"
            );
        }
        removeCurves();
        Iterator compIter = comps.iterator();
        for (XmlNode compNode : compNodes) {
            CurveComponent comp = (CurveComponent) compIter.next();
            XmlNode[] refNodes = compNode.getChildren(ReferenceTag);
            for (XmlNode refNode : refNodes) {
                String attr = refNode.getAttribute(IndexTag);
                Integer index;
                try {
                    index = Integer.valueOf(attr);
                }
                catch (NumberFormatException e) {
                    throw new XMLException("Not a number: " + attr, e);
                }
                Curve curve = curveNumbers.get(index);
                if (curve == null) {
                    throw new XMLException(
                        "Curve index out of bounds: " + attr
                    );
                }
                addCurve(comp, curve);
            }
View Full Code Here

            curve.restore(curveNode);
            curveNumbers.put(count++, curve);
        }
        XmlNode[] compNodes = node.getChildren(ComponentTag);
        if (compNodes.length != comps.size()) {
            throw new XMLException(
                "The number of regions doesn't match the number of tools"
            );
        }
        Iterator compIter = comps.iterator();
        for (XmlNode compNode : compNodes) {
            CurveComponent comp = (CurveComponent) compIter.next();
            XmlNode[] refNodes = compNode.getChildren(ReferenceTag);
            for (XmlNode refNode : refNodes) {
                String attr = refNode.getAttribute(IndexTag);
                Integer index;
                try {
                    index = Integer.valueOf(attr);
                }
                catch (NumberFormatException e) {
                    throw new XMLException("Expected a number: " + attr, e);
                }
                Curve curve = curveNumbers.get(index);
                if (curve == null) {
                    throw new XMLException("Not a valid curve index: " + attr);
                }
                addCurve(comp, curve);
            }
        }
        isRestoring = false;
View Full Code Here

        }
        catch (XMLException e) {
            // Give up.
        }
        // Nothing worked out:
        throw new XMLException("No valid SaveOptions data");
    }
View Full Code Here

TOP

Related Classes of com.lightcrafts.utils.xml.XMLException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.