Package org.lilyproject.util.location

Examples of org.lilyproject.util.location.LocatedException


            if (node instanceof Element && node.getLocalName().equals(name) && node.getNamespaceURI() == null) {
                return (Element)node;
            }
        }
        if (required) {
            throw new LocatedException("Missing element " + name + " in " + element.getLocalName(), LocationAttributes.getLocation(element));
        } else {
            return null;
        }
    }
View Full Code Here


    }

    public static String getAttribute(Element element, String name, boolean required) throws Exception {
        if (!element.hasAttribute(name)) {
            if (required) {
                throw new LocatedException("Missing attribute " + name + " on element " + element.getLocalName(), LocationAttributes.getLocation(element));
            } else {
                return null;
            }
        }
View Full Code Here

        }
    }

    public static int getIntegerAttribute(Element element, String name) throws Exception {
        if (!element.hasAttribute(name)) {
            throw new LocatedException("Missing attribute " + name + " on element " + element.getLocalName(), LocationAttributes.getLocation(element));
        } else {
            String value = element.getAttribute(name);
            try {
                return Integer.parseInt(value);
            } catch (NumberFormatException e) {
                throw new LocatedException("Invalid integer value " + value + " in attribute " + name, LocationAttributes.getLocation(element));
            }
        }
    }
View Full Code Here

            return defaultValue;
        } else {
            try {
                return Integer.parseInt(value);
            } catch (NumberFormatException e) {
                throw new LocatedException("Invalid integer value " + value + " in attribute " + name, LocationAttributes.getLocation(element));
            }
        }
    }
View Full Code Here

                text.append(node.getNodeValue());
            }
        }

        if (required && text.length() == 0) {
            throw new LocatedException("Missing text content in element " + element.getLocalName(), LocationAttributes.getLocation(element));
        } else if (text.length() == 0) {
            return null;
        } else {
            return text.toString();
        }
View Full Code Here

TOP

Related Classes of org.lilyproject.util.location.LocatedException

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.