Package com.btaz.util.reader.xml.model

Examples of com.btaz.util.reader.xml.model.Element


    @Override
    public boolean matches(Node node) {
        if(node == null || ! (node instanceof Element)) {
            return false;
        }
        Element element = (Element) node;
        return nodename.equals(element.getName());
    }
View Full Code Here


    @Override
    public boolean matches(Node node) {
        if(! (node instanceof Element)) {
            return false;
        }
        Element element = (Element) node;
        switch(comparisonMode) {
            case NODENAME:
                if(nodename.equals("*") || nodename.equals(element.getName())) {
                    return true;
                }
                break;
            case NODENAME_NAME:
                if((nodename.equals("*") || nodename.equals(element.getName())) &&
                        (attributeName.equals("*") || element.hasAttribute(attributeName))) {
                    return true;
                }
                break;
            case NODENAME_NAME_VALUE:
                if((nodename.equals("*") || nodename.equals(element.getName()))
                        && (attributeName.equals("*") || attributeValue.equals(element.attributeValue(attributeName)))) {
                    return true;
                }
                break;
            default:
                return false;
View Full Code Here

    @Override
    public MatchType match(int level, Node node) {
        if(! (node instanceof Element)) {
            return MatchType.NOT_A_MATCH;
        }
        Element element = (Element) node;
        if(this.level != level) {
            return MatchType.NOT_A_MATCH;
        } else if(element.hasAttribute(attributeName)) {
            return MatchType.NODE_MATCH;
        }
        return MatchType.NOT_A_MATCH;
    }
View Full Code Here

    @Override
    public MatchType match(int level, Node node) {
        if(! (node instanceof Element)) {
            return MatchType.NOT_A_MATCH;
        }
        Element element = (Element) node;
        if(this.level != level) {
            return MatchType.NOT_A_MATCH;
        } else if(nodename.equals(element.getName())) {
            return MatchType.NODE_MATCH;
        }
        return MatchType.NOT_A_MATCH;
    }
View Full Code Here

        if(node instanceof Content) {
            return;
        }

        // is Element node
        Element element = (Element) node;
        MatchType matchType = queryMatchers.get(level).match(level, element);
        if(matchType == MatchType.NOT_A_MATCH) {
            // no reason to scan deeper
            //noinspection UnnecessaryReturnStatement
            return;
        } else if(matchType == MatchType.NODE_MATCH) {
            // we have a match
            if(level == queryMatchers.size()-1) {
                // full path match
                collector.add(node);
            } else {
                // scan deeper
                List<Node> childElements = element.getChildElements();
                for (Node childElement : childElements) {
                    treeWalker(childElement, level+1, queryMatchers, collector);
                }
            }
        } else {
View Full Code Here

                } else if(o1 instanceof Content && o2 instanceof Element) {
                    return 1;
                } else {
                    assert o1 instanceof Element;
                    assert o2 instanceof Element;
                    Element e1 = (Element) o1;
                    Element e2 = (Element) o2;
                    return e1.toString(true, true).compareTo(e2.toString(true, true));
                }
            }
        });
    }
View Full Code Here

            String textB = ((Content)b).getText();
            if(! textA.equals(textB)) {
                return new Difference(a, b, "Content is different");
            }
        } else if (a instanceof Element && b instanceof Element) {
            Element ea = (Element)a;
            Element eb = (Element)b;

            // - element name
            if(! ea.getName().equals(eb.getName())) {
                return new Difference(a, b, "Element names are different");
            }

            // - attributes names
            if(! ea.getAttributeNames().equals(eb.getAttributeNames())) {
                return new Difference(a, b, "Element attribute names are different");
            }

            // - attributes values
            for(int i=0; i<ea.getAttributeNames().size(); i++) {
                if(! ea.attributeValue(ea.getAttributeNames().get(i))
                        .equals(eb.attributeValue(eb.getAttributeNames().get(i)))) {
                    return new Difference(a, b, "Element attribute values are different");
                }
            }

            // - element type
            if(ea.isEmptyElementTag() != eb.isEmptyElementTag()) {
                return new Difference(a, b, "Empty element tags are different");
            }
        } else {
            return new Difference(a, b, "The nodes are different");
        }
View Full Code Here

    @Override
    public boolean matches(Node node) {
        if(node == null || ! (node instanceof Element)) {
            return false;
        }
        Element element = (Element) node;
        return nodename.equals(element.getName());
    }
View Full Code Here

    @Override
    public boolean matches(Node node) {
        if(node == null || ! (node instanceof Element)) {
            return false;
        }
        Element element = (Element) node;
        return element.attributeCount() > 0;
    }
View Full Code Here

            if(level == queryMatchers.size()-1) {
                // full path match
                collector.add(node);
            } else if(node instanceof Element) {
                // scan deeper
                Element element = (Element) node;
                List<Node> childElements = element.getChildElements();
                for (Node childElement : childElements) {
                    treeWalker(childElement, level+1, queryMatchers, collector);
                }
            }
        } else {
View Full Code Here

TOP

Related Classes of com.btaz.util.reader.xml.model.Element

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.