Java Code Examples for org.w3c.dom.DOMException#toString()

The following examples show how to use org.w3c.dom.DOMException#toString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DOMInputCapsule.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public float[] readFloatArray(String name, float[] defVal) throws IOException {
    try {
        Element tmpEl;
        if (name != null) {
            tmpEl = findChildElement(currentElem, name);
        } else {
            tmpEl = currentElem;
        }
        if (tmpEl == null) {
            return defVal;
        }
        String sizeString = tmpEl.getAttribute("size");
        String[] strings = parseTokens(tmpEl.getAttribute("data"));
        if (sizeString.length() > 0) {
            int requiredSize = Integer.parseInt(sizeString);
            if (strings.length != requiredSize)
                throw new IOException("Wrong number of floats for '" + name
                        + "'.  size says " + requiredSize
                        + ", data contains " + strings.length);
        }
        float[] tmp = new float[strings.length];
        for (int i = 0; i < tmp.length; i++) {
            tmp[i] = Float.parseFloat(strings[i]);
        }
        return tmp;
    } catch (IOException ioe) {
        throw ioe;
    } catch (DOMException de) {
        IOException io = new IOException(de.toString());
        io.initCause(de);
        throw io;
    }
}
 
Example 2
Source File: DOMInputCapsule.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public boolean readBoolean(String name, boolean defVal) throws IOException {
    String tmpString = currentElem.getAttribute(name);
    if (tmpString == null || tmpString.length() < 1) return defVal;
    try {
        return Boolean.parseBoolean(tmpString);
    } catch (DOMException de) {
        IOException io = new IOException(de.toString());
        io.initCause(de);
        throw io;
    }
}
 
Example 3
Source File: DOMInputCapsule.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public boolean[] readBooleanArray(String name, boolean[] defVal) throws IOException {
    try {
        Element tmpEl;
        if (name != null) {
            tmpEl = findChildElement(currentElem, name);
        } else {
            tmpEl = currentElem;
        }
        if (tmpEl == null) {
            return defVal;
        }
        String sizeString = tmpEl.getAttribute("size");
        String[] strings = parseTokens(tmpEl.getAttribute("data"));
        if (sizeString.length() > 0) {
            int requiredSize = Integer.parseInt(sizeString);
            if (strings.length != requiredSize)
                throw new IOException("Wrong number of bools for '" + name
                        + "'.  size says " + requiredSize
                        + ", data contains " + strings.length);
        }
        boolean[] tmp = new boolean[strings.length];
        for (int i = 0; i < tmp.length; i++) {
            tmp[i] = Boolean.parseBoolean(strings[i]);
        }
        return tmp;
    } catch (IOException ioe) {
        throw ioe;
    } catch (DOMException de) {
        IOException io = new IOException(de.toString());
        io.initCause(de);
        throw io;
    }
}
 
Example 4
Source File: DOMInputCapsule.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public String readString(String name, String defVal) throws IOException {
    String tmpString = currentElem.getAttribute(name);
    if (tmpString == null || tmpString.length() < 1) return defVal;
    try {
        return decodeString(tmpString);
    } catch (DOMException de) {
        IOException io = new IOException(de.toString());
        io.initCause(de);
        throw io;
    }
}