Package org.mizartools.utility.xml

Examples of org.mizartools.utility.xml.XMLElement


        return priority;
    }

    public LinkedList<XMLElement> getXMLElementList() {
        LinkedList<XMLElement> xmlElementList = new LinkedList<XMLElement>();
        XMLElement xmlElement = new XMLElement(NAME);
        if (this.kind != null) {
            XMLAttribute xmlAttribute = new XMLAttribute("kind", this.kind.name());
            xmlElement.getXMLAttributeList().add(xmlAttribute);
        }
        if (this.symbolnr != null) {
            XMLAttribute xmlAttribute = new XMLAttribute("symbolnr", this.symbolnr);
            xmlElement.getXMLAttributeList().add(xmlAttribute);
        }
        if (this.value != null) {
            XMLAttribute xmlAttribute = new XMLAttribute("value", this.value);
            xmlElement.getXMLAttributeList().add(xmlAttribute);
        }
        boolean isEmpty = true;
        xmlElement.setEmpty(isEmpty);
        xmlElementList.add(xmlElement);
        if (!isEmpty) {
            xmlElement = new XMLElement(NAME);
            xmlElement.setEndElement(true);
            xmlElementList.add(xmlElement);
        }
        return xmlElementList;
    }
View Full Code Here


        return parentNode;
    }

    public static PartialDef newInstance(INode parentNode, LinkedList<XMLElement> xmlElementList) throws ElementParseException {
        PartialDef partialDef = new PartialDef(parentNode);
        XMLElement xmlElement = xmlElementList.poll();
        if (!xmlElement.getName().equals(NAME)){
            throw new ElementParseException(ElementParseException.NOT_VALID_ELEMENT, "XMLElement is a " + xmlElement.getName() + " not a " + NAME, xmlElementList);
        }

        if (!xmlElement.isEmpty()){
            while (true){
                xmlElement = xmlElementList.peek();
                if (xmlElement == null){
                    throw new ElementParseException(ElementParseException.UNEXPECTED_END_OF_FILE, "Unexpected end of XMLElement list");
                }
                if (xmlElement.getName().equals(NAME) && xmlElement.isEndElement()){
                    xmlElement = xmlElementList.poll();
                    break;
                }
                if (Formula.isFormula(xmlElement.getName()) && partialDef.formula1 == null && partialDef.term == null) {
                    partialDef.formula1 = Formula.newInstance(partialDef, xmlElementList);
                } else if (Term.isTerm(xmlElement.getName())){
                    if (partialDef.term == null) {
                        partialDef.term = Term.newInstance(partialDef, xmlElementList);
                    } else {
                        throw new ElementParseException(ElementParseException.DUPLICATE_ELEMENT, "XMLElement list contains a duplicated <Term> in element " + NAME, xmlElementList);
                    }
                } else if (Formula.isFormula(xmlElement.getName())){
                    if (partialDef.formula2 == null) {
                        partialDef.formula2 = Formula.newInstance(partialDef, xmlElementList);
                    } else {
                        throw new ElementParseException(ElementParseException.DUPLICATE_ELEMENT, "XMLElement list contains a duplicated <Formula> in element " + NAME, xmlElementList);
                    }
                } else
                    throw new ElementParseException(ElementParseException.NOT_VALID_ELEMENT, "The XMLElement " + xmlElement.getName() + " is not valid in " + NAME, xmlElementList);
            }
        }

        return partialDef;
    }
View Full Code Here

        return partialDef;
    }

    public LinkedList<XMLElement> getXMLElementList() {
        LinkedList<XMLElement> xmlElementList = new LinkedList<XMLElement>();
        XMLElement xmlElement = new XMLElement(NAME);
        boolean isEmpty = !(formula1 != null
         || term != null || formula2 != null);
        xmlElement.setEmpty(isEmpty);
        xmlElementList.add(xmlElement);
        if (this.formula1 != null){
            xmlElementList.addAll(this.formula1.getXMLElementList());
        }
        if (this.term != null){
            xmlElementList.addAll(this.term.getXMLElementList());
        }
        if (this.formula2 != null){
            xmlElementList.addAll(this.formula2.getXMLElementList());
        }
        if (!isEmpty) {
            xmlElement = new XMLElement(NAME);
            xmlElement.setEndElement(true);
            xmlElementList.add(xmlElement);
        }
        return xmlElementList;
    }
View Full Code Here

        return parentNode;
    }

    public static Func newInstance(INode parentNode, LinkedList<XMLElement> xmlElementList) throws ElementParseException {
        Func func = new Func(parentNode);
        XMLElement xmlElement = xmlElementList.poll();
        if (!xmlElement.getName().equals(NAME)){
            throw new ElementParseException(ElementParseException.NOT_VALID_ELEMENT, "XMLElement is a " + xmlElement.getName() + " not a " + NAME, xmlElementList);
        }
        for (XMLAttribute xmlAttribute : xmlElement.getXMLAttributeList()){
            if (xmlAttribute.getName().equals("kind")){
                if (func.kind == null){
                    if (Kind.valueOf(xmlAttribute.getValue()) != null) {
                        func.kind = Kind.valueOf(xmlAttribute.getValue());
                    } else
                        throw new ElementParseException(ElementParseException.NOT_VALID_TYPE_OF_ATTRIBUTE_ELEMENT, "XMLElement has an attribute " + xmlAttribute.getName() + " with an invalid type", xmlElementList);
                } else {
                    throw new ElementParseException(ElementParseException.DUPLICATE_ATTRIBUTE_ELEMENT, "XMLElement has a duplicate attribute " + xmlAttribute.getName(), xmlElementList);
                }
            } else
            if (xmlAttribute.getName().equals("nr")){
                if (func.nr == null){
                    try {func.nr = Integer.parseInt(xmlAttribute.getValue());}
                    catch (Exception e) {throw new ElementParseException(ElementParseException.NOT_VALID_TYPE_OF_ATTRIBUTE_ELEMENT, "XMLElement has an attribute " + xmlAttribute.getName() + " with an invalid type", xmlElementList);};
                } else {
                    throw new ElementParseException(ElementParseException.DUPLICATE_ATTRIBUTE_ELEMENT, "XMLElement has a duplicate attribute " + xmlAttribute.getName(), xmlElementList);
                }
            } else
            if (xmlAttribute.getName().equals("absnr")){
                if (func.absnr == null){
                    try {func.absnr = Integer.parseInt(xmlAttribute.getValue());}
                    catch (Exception e) {throw new ElementParseException(ElementParseException.NOT_VALID_TYPE_OF_ATTRIBUTE_ELEMENT, "XMLElement has an attribute " + xmlAttribute.getName() + " with an invalid type", xmlElementList);};
                } else {
                    throw new ElementParseException(ElementParseException.DUPLICATE_ATTRIBUTE_ELEMENT, "XMLElement has a duplicate attribute " + xmlAttribute.getName(), xmlElementList);
                }
            } else
            if (xmlAttribute.getName().equals("aid")){
                if (func.aid == null){
                    func.aid = xmlAttribute.getValue();
                } else {
                    throw new ElementParseException(ElementParseException.DUPLICATE_ATTRIBUTE_ELEMENT, "XMLElement has a duplicate attribute " + xmlAttribute.getName(), xmlElementList);
                }
            } else
            if (xmlAttribute.getName().equals("pid")){
                if (func.pid == null){
                    try {func.pid = Integer.parseInt(xmlAttribute.getValue());}
                    catch (Exception e) {throw new ElementParseException(ElementParseException.NOT_VALID_TYPE_OF_ATTRIBUTE_ELEMENT, "XMLElement has an attribute " + xmlAttribute.getName() + " with an invalid type", xmlElementList);};
                } else {
                    throw new ElementParseException(ElementParseException.DUPLICATE_ATTRIBUTE_ELEMENT, "XMLElement has a duplicate attribute " + xmlAttribute.getName(), xmlElementList);
                }
            } else
                throw new ElementParseException(ElementParseException.NOT_VALID_ATTRIBUTE_ELEMENT, "XMLElement has not a valid attribute " + xmlAttribute.getName(), xmlElementList);
        }

        if (!xmlElement.isEmpty()){
            while (true){
                xmlElement = xmlElementList.peek();
                if (xmlElement == null){
                    throw new ElementParseException(ElementParseException.UNEXPECTED_END_OF_FILE, "Unexpected end of XMLElement list");
                }
                if (xmlElement.getName().equals(NAME) && xmlElement.isEndElement()){
                    xmlElement = xmlElementList.poll();
                    break;
                }
                if (Term.isTerm(xmlElement.getName())){
                    func.termList.add(Term.newInstance(func, xmlElementList));
                } else
                    throw new ElementParseException(ElementParseException.NOT_VALID_ELEMENT, "The XMLElement " + xmlElement.getName() + " is not valid in " + NAME, xmlElementList);
            }
        }

        return func;
    }
View Full Code Here

        return func;
    }

    public LinkedList<XMLElement> getXMLElementList() {
        LinkedList<XMLElement> xmlElementList = new LinkedList<XMLElement>();
        XMLElement xmlElement = new XMLElement(NAME);
        if (this.kind != null) {
            XMLAttribute xmlAttribute = new XMLAttribute("kind", this.kind.name());
            xmlElement.getXMLAttributeList().add(xmlAttribute);
        }
        if (this.nr != null) {
            XMLAttribute xmlAttribute = new XMLAttribute("nr", this.nr);
            xmlElement.getXMLAttributeList().add(xmlAttribute);
        }
        if (this.absnr != null) {
            XMLAttribute xmlAttribute = new XMLAttribute("absnr", this.absnr);
            xmlElement.getXMLAttributeList().add(xmlAttribute);
        }
        if (this.aid != null) {
            XMLAttribute xmlAttribute = new XMLAttribute("aid", this.aid);
            xmlElement.getXMLAttributeList().add(xmlAttribute);
        }
        if (this.pid != null) {
            XMLAttribute xmlAttribute = new XMLAttribute("pid", this.pid);
            xmlElement.getXMLAttributeList().add(xmlAttribute);
        }
        boolean isEmpty = !(!termList.isEmpty());
        xmlElement.setEmpty(isEmpty);
        xmlElementList.add(xmlElement);
        for (Term term : this.termList){
            xmlElementList.addAll(term.getXMLElementList());
        }
        if (!isEmpty) {
            xmlElement = new XMLElement(NAME);
            xmlElement.setEndElement(true);
            xmlElementList.add(xmlElement);
        }
        return xmlElementList;
    }
View Full Code Here

        return parentNode;
    }

    public static Var newInstance(INode parentNode, LinkedList<XMLElement> xmlElementList) throws ElementParseException {
        Var var = new Var(parentNode);
        XMLElement xmlElement = xmlElementList.poll();
        if (!xmlElement.getName().equals(NAME)){
            throw new ElementParseException(ElementParseException.NOT_VALID_ELEMENT, "XMLElement is a " + xmlElement.getName() + " not a " + NAME, xmlElementList);
        }
        for (XMLAttribute xmlAttribute : xmlElement.getXMLAttributeList()){
            if (xmlAttribute.getName().equals("nr")){
                if (var.nr == null){
                    try {var.nr = Integer.parseInt(xmlAttribute.getValue());}
                    catch (Exception e) {throw new ElementParseException(ElementParseException.NOT_VALID_TYPE_OF_ATTRIBUTE_ELEMENT, "XMLElement has an attribute " + xmlAttribute.getName() + " with an invalid type", xmlElementList);};
                } else {
                    throw new ElementParseException(ElementParseException.DUPLICATE_ATTRIBUTE_ELEMENT, "XMLElement has a duplicate attribute " + xmlAttribute.getName(), xmlElementList);
                }
            } else
                throw new ElementParseException(ElementParseException.NOT_VALID_ATTRIBUTE_ELEMENT, "XMLElement has not a valid attribute " + xmlAttribute.getName(), xmlElementList);
        }

        if (!xmlElement.isEmpty()){
            while (true){
                xmlElement = xmlElementList.peek();
                if (xmlElement == null){
                    throw new ElementParseException(ElementParseException.UNEXPECTED_END_OF_FILE, "Unexpected end of XMLElement list");
                }
                if (xmlElement.getName().equals(NAME) && xmlElement.isEndElement()){
                    xmlElement = xmlElementList.poll();
                    break;
                }
                throw new ElementParseException(ElementParseException.NOT_VALID_ELEMENT, "The XMLElement " + xmlElement.getName() + " is not valid in " + NAME, xmlElementList);
            }
        }

        return var;
    }
View Full Code Here

        return var;
    }

    public LinkedList<XMLElement> getXMLElementList() {
        LinkedList<XMLElement> xmlElementList = new LinkedList<XMLElement>();
        XMLElement xmlElement = new XMLElement(NAME);
        if (this.nr != null) {
            XMLAttribute xmlAttribute = new XMLAttribute("nr", this.nr);
            xmlElement.getXMLAttributeList().add(xmlAttribute);
        }
        boolean isEmpty = true;
        xmlElement.setEmpty(isEmpty);
        xmlElementList.add(xmlElement);
        if (!isEmpty) {
            xmlElement = new XMLElement(NAME);
            xmlElement.setEndElement(true);
            xmlElementList.add(xmlElement);
        }
        return xmlElementList;
    }
View Full Code Here

        return parentNode;
    }

    public static Symbols newInstance(INode parentNode, LinkedList<XMLElement> xmlElementList) throws ElementParseException {
        Symbols symbols = new Symbols(parentNode);
        XMLElement xmlElement = xmlElementList.poll();
        if (!xmlElement.getName().equals(NAME)){
            throw new ElementParseException(ElementParseException.NOT_VALID_ELEMENT, "XMLElement is a " + xmlElement.getName() + " not a " + NAME, xmlElementList);
        }
        for (XMLAttribute xmlAttribute : xmlElement.getXMLAttributeList()){
            if (xmlAttribute.getName().equals("aid")){
                if (symbols.aid == null){
                  symbols.aid = xmlAttribute.getValue();
                } else {
                    throw new ElementParseException(ElementParseException.DUPLICATE_ATTRIBUTE_ELEMENT, "XMLElement has a duplicate attribute " + xmlAttribute.getName(), xmlElementList);
                }
            } else
            if (xmlAttribute.getName().equals("mizfiles")){
                if (symbols.mizfiles == null){
                  symbols.mizfiles = xmlAttribute.getValue();
                } else {
                    throw new ElementParseException(ElementParseException.DUPLICATE_ATTRIBUTE_ELEMENT, "XMLElement has a duplicate attribute " + xmlAttribute.getName(), xmlElementList);
                }
            } else
                throw new ElementParseException(ElementParseException.NOT_VALID_ATTRIBUTE_ELEMENT, "XMLElement has not a valid attribute " + xmlAttribute.getName(), xmlElementList);
        }

        if (!xmlElement.isEmpty()){
            while (true){
                xmlElement = xmlElementList.peek();
                if (xmlElement == null){
                    throw new ElementParseException(ElementParseException.UNEXPECTED_END_OF_FILE, "Unexpected end of XMLElement list");
                }
                if (xmlElement.getName().equals(NAME) && xmlElement.isEndElement()){
                    xmlElement = xmlElementList.poll();
                    break;
                }
                if (xmlElement.getName().equals("Symbol")){
                    symbols.symbolList.add(Symbol.newInstance(symbols, xmlElementList));
                } else
                    throw new ElementParseException(ElementParseException.NOT_VALID_ELEMENT, "The XMLElement " + xmlElement.getName() + " is not valid in " + NAME, xmlElementList);
            }
        }

        return symbols;
    }
View Full Code Here

        return symbols;
    }

    public LinkedList<XMLElement> getXMLElementList() {
        LinkedList<XMLElement> xmlElementList = new LinkedList<XMLElement>();
        XMLElement xmlElement = new XMLElement(NAME);
        if (this.aid != null) {
            XMLAttribute xmlAttribute = new XMLAttribute("aid", this.aid);
            xmlElement.getXMLAttributeList().add(xmlAttribute);
        }
        if (this.mizfiles != null) {
            XMLAttribute xmlAttribute = new XMLAttribute("mizfiles", this.mizfiles);
            xmlElement.getXMLAttributeList().add(xmlAttribute);
        }
        boolean isEmpty = !(!symbolList.isEmpty());
        xmlElement.setEmpty(isEmpty);
        xmlElementList.add(xmlElement);
        for (Symbol symbol : this.symbolList){
            xmlElementList.addAll(symbol.getXMLElementList());
        }
        if (!isEmpty) {
            xmlElement = new XMLElement(NAME);
            xmlElement.setEndElement(true);
            xmlElementList.add(xmlElement);
        }
        return xmlElementList;
    }
View Full Code Here

        return parentNode;
    }

    public static Monomial newInstance(INode parentNode, LinkedList<XMLElement> xmlElementList) throws ElementParseException {
        Monomial monomial = new Monomial(parentNode);
        XMLElement xmlElement = xmlElementList.poll();
        if (!xmlElement.getName().equals(NAME)){
            throw new ElementParseException(ElementParseException.NOT_VALID_ELEMENT, "XMLElement is a " + xmlElement.getName() + " not a " + NAME, xmlElementList);
        }

        if (!xmlElement.isEmpty()){
            while (true){
                xmlElement = xmlElementList.peek();
                if (xmlElement == null){
                    throw new ElementParseException(ElementParseException.UNEXPECTED_END_OF_FILE, "Unexpected end of XMLElement list");
                }
                if (xmlElement.getName().equals(NAME) && xmlElement.isEndElement()){
                    xmlElement = xmlElementList.poll();
                    break;
                }
                if (Number.isNumber(xmlElement.getName())){
                    if (monomial.number == null) {
                        monomial.number = Number.newInstance(monomial, xmlElementList);
                    } else {
                        throw new ElementParseException(ElementParseException.DUPLICATE_ELEMENT, "XMLElement list contains a duplicated <Number> in element " + NAME, xmlElementList);
                    }
                } else if (xmlElement.getName().equals("PoweredVar")){
                    monomial.poweredVarList.add(PoweredVar.newInstance(monomial, xmlElementList));
                } else
                    throw new ElementParseException(ElementParseException.NOT_VALID_ELEMENT, "The XMLElement " + xmlElement.getName() + " is not valid in " + NAME, xmlElementList);
            }
        }

        return monomial;
    }
View Full Code Here

TOP

Related Classes of org.mizartools.utility.xml.XMLElement

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.