Package org.mizartools.utility.xml

Examples of org.mizartools.utility.xml.XMLElement


        return monomial;
    }

    public LinkedList<XMLElement> getXMLElementList() {
        LinkedList<XMLElement> xmlElementList = new LinkedList<XMLElement>();
        XMLElement xmlElement = new XMLElement(NAME);
        boolean isEmpty = !(number != null
         || !poweredVarList.isEmpty());
        xmlElement.setEmpty(isEmpty);
        xmlElementList.add(xmlElement);
        if (this.number != null){
            xmlElementList.addAll(this.number.getXMLElementList());
        }
        for (PoweredVar poweredVar : this.poweredVarList){
            xmlElementList.addAll(poweredVar.getXMLElementList());
        }
        if (!isEmpty) {
            xmlElement = new XMLElement(NAME);
            xmlElement.setEndElement(true);
            xmlElementList.add(xmlElement);
        }
        return xmlElementList;
    }
View Full Code Here


        return parentNode;
    }

    public static RegistrationBlock newInstance(INode parentNode, LinkedList<XMLElement> xmlElementList) throws ElementParseException {
        RegistrationBlock registrationBlock = new RegistrationBlock(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("line")){
                if (registrationBlock.line == null){
                    try {registrationBlock.line = 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("col")){
                if (registrationBlock.col == null){
                    try {registrationBlock.col = 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 (xmlElement.getName().equals("Let")){
                    registrationBlock.elementList.add(Let.newInstance(registrationBlock, xmlElementList));
                } else if (AuxiliaryItem.isAuxiliaryItem(xmlElement.getName())){
                    registrationBlock.elementList.add(AuxiliaryItem.newInstance(registrationBlock, xmlElementList));
                } else if (xmlElement.getName().equals("Registration")){
                    registrationBlock.elementList.add(Registration.newInstance(registrationBlock, xmlElementList));
                } else if (xmlElement.getName().equals("IdentifyRegistration")){
                    registrationBlock.elementList.add(IdentifyRegistration.newInstance(registrationBlock, xmlElementList));
                } else if (xmlElement.getName().equals("PropertyRegistration")){
                    registrationBlock.elementList.add(PropertyRegistration.newInstance(registrationBlock, xmlElementList));
                } else if (xmlElement.getName().equals("ReductionRegistration")){
                    registrationBlock.elementList.add(ReductionRegistration.newInstance(registrationBlock, xmlElementList));
                } else if (xmlElement.getName().equals("Canceled")){
                    registrationBlock.elementList.add(Canceled.newInstance(registrationBlock, xmlElementList));
                } else if (xmlElement.getName().equals("EndPosition")){
                    if (registrationBlock.endPosition == null) {
                        registrationBlock.endPosition = EndPosition.newInstance(registrationBlock, xmlElementList);
                    } else {
                        throw new ElementParseException(ElementParseException.DUPLICATE_ELEMENT, "XMLElement list contains a duplicated <EndPosition> in element " + NAME, xmlElementList);
                    }
                } else
                    throw new ElementParseException(ElementParseException.NOT_VALID_ELEMENT, "The XMLElement " + xmlElement.getName() + " is not valid in " + NAME, xmlElementList);
            }
        }

        return registrationBlock;
    }
View Full Code Here

        return registrationBlock;
    }

    public LinkedList<XMLElement> getXMLElementList() {
        LinkedList<XMLElement> xmlElementList = new LinkedList<XMLElement>();
        XMLElement xmlElement = new XMLElement(NAME);
        if (this.line != null) {
            XMLAttribute xmlAttribute = new XMLAttribute("line", this.line);
            xmlElement.getXMLAttributeList().add(xmlAttribute);
        }
        if (this.col != null) {
            XMLAttribute xmlAttribute = new XMLAttribute("col", this.col);
            xmlElement.getXMLAttributeList().add(xmlAttribute);
        }
        boolean isEmpty = (elementList.isEmpty() && endPosition != null);
        xmlElement.setEmpty(isEmpty);
        xmlElementList.add(xmlElement);
        for (IElement iElement : this.elementList){
            xmlElementList.addAll(iElement.getXMLElementList());
        }
        if (this.endPosition != null){
            xmlElementList.addAll(this.endPosition.getXMLElementList());
        }
        if (!isEmpty) {
            xmlElement = new XMLElement(NAME);
            xmlElement.setEndElement(true);
            xmlElementList.add(xmlElement);
        }
        return xmlElementList;
    }
View Full Code Here

        }
        return found;
    }

    public static CorrectnessCondition newInstance(INode parentNode, LinkedList<XMLElement> xmlElementList) throws ElementParseException {
        XMLElement xmlElement = xmlElementList.peek();
        if (!isCorrectnessCondition(xmlElement.getName())){
            throw new ElementParseException(ElementParseException.NOT_VALID_ELEMENT, "XMLElement is a " + xmlElement.getName() + " not a subclass of CorrectnessCondition", xmlElementList);
        }
        MySubclass mySubclass = MySubclass.valueOf(xmlElement.getName());
        switch (mySubclass) {
        case UnknownCorrCond: return UnknownCorrCond.newInstance(parentNode, xmlElementList);
        case Coherence: return Coherence.newInstance(parentNode, xmlElementList);
        case Compatibility: return Compatibility.newInstance(parentNode, xmlElementList);
        case Consistency: return Consistency.newInstance(parentNode, xmlElementList);
        case Existence: return Existence.newInstance(parentNode, xmlElementList);
        case Uniqueness: return Uniqueness.newInstance(parentNode, xmlElementList);
        default: throw new ElementParseException(ElementParseException.NOT_VALID_ELEMENT, "XMLElement is a " + xmlElement.getName() + " not a subclass of CorrectnessCondition", xmlElementList);
        }
    }
View Full Code Here

        return parentNode;
    }

    public static Property newInstance(INode parentNode, LinkedList<XMLElement> xmlElementList) throws ElementParseException {
        Property property = new Property(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 (property.aid == null){
                  property.aid = xmlAttribute.getValue();
                } else {
                    throw new ElementParseException(ElementParseException.DUPLICATE_ATTRIBUTE_ELEMENT, "XMLElement has a duplicate attribute " + xmlAttribute.getName(), xmlElementList);
                }
            } else
            if (xmlAttribute.getName().equals("nr")){
                if (property.nr == null){
                    try {property.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("x")){
                if (property.x == null){
                    try {property.x = 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 (xmlElement.getName().equals("ArgTypes")){
                    if (property.argTypes == null) {
                        property.argTypes = ArgTypes.newInstance(property, xmlElementList);
                    } else {
                        throw new ElementParseException(ElementParseException.DUPLICATE_ELEMENT, "XMLElement list contains a duplicated <ArgTypes> in element " + NAME, xmlElementList);
                    }
                } else
                if (xmlElement.getName().equals("Typ")){
                    if (property.typ == null) {
                        property.typ = Typ.newInstance(property, xmlElementList);
                    } else {
                        throw new ElementParseException(ElementParseException.DUPLICATE_ELEMENT, "XMLElement list contains a duplicated <Typ> in element " + NAME, xmlElementList);
                    }
                } else
                    throw new ElementParseException(ElementParseException.NOT_VALID_ELEMENT, "The XMLElement " + xmlElement.getName() + " is not valid in " + NAME, xmlElementList);
            }
        }

        return property;
    }
View Full Code Here

        return property;
    }

    public LinkedList<XMLElement> getXMLElementList() {
        LinkedList<XMLElement> xmlElementList = new LinkedList<XMLElement>();
        XMLElement xmlElement = new XMLElement(NAME);
        boolean isEmpty = !(argTypes != null || typ != null);
        xmlElement.setEmpty(isEmpty);
        xmlElementList.add(xmlElement);
        if (this.aid != null) {
            XMLAttribute xmlAttribute = new XMLAttribute("aid", this.aid);
            xmlElement.getXMLAttributeList().add(xmlAttribute);
        }
        if (this.nr != null) {
            XMLAttribute xmlAttribute = new XMLAttribute("nr", this.nr);
            xmlElement.getXMLAttributeList().add(xmlAttribute);
        }
        if (this.x != null) {
            XMLAttribute xmlAttribute = new XMLAttribute("x", this.x);
            xmlElement.getXMLAttributeList().add(xmlAttribute);
        }

        if (this.argTypes != null){
            xmlElementList.addAll(this.argTypes.getXMLElementList());
        }
        if (this.typ != null){
            xmlElementList.addAll(this.typ.getXMLElementList());
        }
        if (!isEmpty) {
            xmlElement = new XMLElement(NAME);
            xmlElement.setEndElement(true);
            xmlElementList.add(xmlElement);
        }
        return xmlElementList;
    }
View Full Code Here

        return parentNode;
    }

    public static Take newInstance(INode parentNode, LinkedList<XMLElement> xmlElementList) throws ElementParseException {
        Take take = new Take(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 (Term.isTerm(xmlElement.getName())){
                    if (take.term == null) {
                        take.term = Term.newInstance(take, xmlElementList);
                    } else {
                        throw new ElementParseException(ElementParseException.DUPLICATE_ELEMENT, "XMLElement list contains a duplicated <Term> in element " + NAME, xmlElementList);
                    }
                } else
                    throw new ElementParseException(ElementParseException.NOT_VALID_ELEMENT, "The XMLElement " + xmlElement.getName() + " is not valid in " + NAME, xmlElementList);
            }
        }

        return take;
    }
View Full Code Here

        return take;
    }

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

        return parentNode;
    }

    public static PropertyRegistration newInstance(INode parentNode, LinkedList<XMLElement> xmlElementList) throws ElementParseException {
        PropertyRegistration propertyRegistration = new PropertyRegistration(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 (xmlElement.getName().equals("Property")){
                    if (propertyRegistration.property == null) {
                        propertyRegistration.property = Property.newInstance(propertyRegistration, xmlElementList);
                    } else {
                        throw new ElementParseException(ElementParseException.DUPLICATE_ELEMENT, "XMLElement list contains a duplicated <Property> in element " + NAME, xmlElementList);
                    }
                } else
                if (xmlElement.getName().equals("Proposition")){
                    if (propertyRegistration.proposition == null) {
                        propertyRegistration.proposition = Proposition.newInstance(propertyRegistration, xmlElementList);
                    } else {
                        throw new ElementParseException(ElementParseException.DUPLICATE_ELEMENT, "XMLElement list contains a duplicated <Proposition> in element " + NAME, xmlElementList);
                    }
                } else
                if (xmlElement.getName().equals("Proof")){
                    if (propertyRegistration.proof == null) {
                        propertyRegistration.proof = Proof.newInstance(propertyRegistration, xmlElementList);
                    } else {
                        throw new ElementParseException(ElementParseException.DUPLICATE_ELEMENT, "XMLElement list contains a duplicated <Proof> in element " + NAME, xmlElementList);
                    }
                } else
                    throw new ElementParseException(ElementParseException.NOT_VALID_ELEMENT, "The XMLElement " + xmlElement.getName() + " is not valid in " + NAME, xmlElementList);
            }
        }

        return propertyRegistration;
    }
View Full Code Here

        return propertyRegistration;
    }

    public LinkedList<XMLElement> getXMLElementList() {
        LinkedList<XMLElement> xmlElementList = new LinkedList<XMLElement>();
        XMLElement xmlElement = new XMLElement(NAME);
        boolean isEmpty = !(property != null || proposition != null || proof != null);
        xmlElement.setEmpty(isEmpty);
        xmlElementList.add(xmlElement);
        if (this.property != null){
            xmlElementList.addAll(this.property.getXMLElementList());
        }
        if (this.proposition != null){
            xmlElementList.addAll(this.proposition.getXMLElementList());
        }
        if (this.proof != null){
            xmlElementList.addAll(this.proof.getXMLElementList());
        }

        if (!isEmpty) {
            xmlElement = new XMLElement(NAME);
            xmlElement.setEndElement(true);
            xmlElementList.add(xmlElement);
        }
        return xmlElementList;
    }
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.