Package org.mizartools.utility.xml

Examples of org.mizartools.utility.xml.XMLElement


        return privPred;
    }

    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 = !(!termList.isEmpty()
         || formula != null);
        xmlElement.setEmpty(isEmpty);
        xmlElementList.add(xmlElement);
        for (Term term : this.termList){
            xmlElementList.addAll(term.getXMLElementList());
        }
        if (this.formula != null){
            xmlElementList.addAll(this.formula.getXMLElementList());
        }
        if (!isEmpty) {
            xmlElement = new XMLElement(NAME);
            xmlElement.setEndElement(true);
            xmlElementList.add(xmlElement);
        }
        return xmlElementList;
    }
View Full Code Here


        return parentNode;
    }

    public static SymbolCount newInstance(INode parentNode, LinkedList<XMLElement> xmlElementList) throws ElementParseException {
        SymbolCount symbolCount = new SymbolCount(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 (symbolCount.kind == null){
                    if (Kind.valueOf(xmlAttribute.getValue()) != null) {
                        symbolCount.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 (symbolCount.nr == null){
                    try {symbolCount.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 symbolCount;
    }
View Full Code Here

        return symbolCount;
    }

    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);
        }
        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 SupposeBlock newInstance(INode parentNode, LinkedList<XMLElement> xmlElementList) throws ElementParseException {
        SupposeBlock supposeBlock = new SupposeBlock(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 (supposeBlock.line == null){
                    try {supposeBlock.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 (supposeBlock.col == null){
                    try {supposeBlock.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()){
          boolean isFirst = true;
            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 (isFirst) {
                    if (xmlElement.getName().equals("BlockThesis")){
                      supposeBlock.isBlockThesisFirst = true
                    }
                  isFirst = false;
                }
                if (xmlElement.getName().equals("BlockThesis")){
                    if (supposeBlock.blockThesis == null) {
                        supposeBlock.blockThesis = BlockThesis.newInstance(supposeBlock, xmlElementList);
                    } else {
                        throw new ElementParseException(ElementParseException.DUPLICATE_ELEMENT, "XMLElement list contains a duplicated <BlockThesis> in element " + NAME, xmlElementList);
                    }
                } else if (xmlElement.getName().equals("Suppose")){
                    if (supposeBlock.suppose == null) {
                        supposeBlock.suppose = Suppose.newInstance(supposeBlock, xmlElementList);
                    } else {
                        throw new ElementParseException(ElementParseException.DUPLICATE_ELEMENT, "XMLElement list contains a duplicated <Suppose> in element " + NAME, xmlElementList);
                    }
                } else if (xmlElement.getName().equals("Thesis")){
                    if (supposeBlock.thesis == null) {
                        supposeBlock.thesis = Thesis.newInstance(supposeBlock, xmlElementList);
                    } else {
                        throw new ElementParseException(ElementParseException.DUPLICATE_ELEMENT, "XMLElement list contains a duplicated <Thesis> in element " + NAME, xmlElementList);
                    }
                } else if (ReasoningItem.isReasoningItem(xmlElement.getName())){
                    supposeBlock.reasoningItemList.add(ReasoningItem.newInstance(supposeBlock, xmlElementList));
                } else if (xmlElement.getName().equals("PerCasesReasoning")){
                    if (supposeBlock.perCasesReasoning == null) {
                      supposeBlock.perCasesReasoning = PerCasesReasoning.newInstance(supposeBlock, xmlElementList);
                    } else {
                        throw new ElementParseException(ElementParseException.DUPLICATE_ELEMENT, "XMLElement list contains a duplicated <PerCasesReasoning> in element " + NAME, xmlElementList);
                    }
                } else if (xmlElement.getName().equals("EndPosition")){
                    if (supposeBlock.endPosition == null) {
                        supposeBlock.endPosition = EndPosition.newInstance(supposeBlock, 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 supposeBlock;
    }
View Full Code Here

        return supposeBlock;
    }

    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 = (blockThesis == null
         && suppose == null && thesis == null
         && reasoningItemList.isEmpty() && endPosition == null);
        xmlElement.setEmpty(isEmpty);
        xmlElementList.add(xmlElement);
        if (this.isBlockThesisFirst){
            if (this.blockThesis != null){
                xmlElementList.addAll(this.blockThesis.getXMLElementList());
            }
            if (this.suppose != null){
                xmlElementList.addAll(this.suppose.getXMLElementList());
            }
            if (this.thesis != null){
                xmlElementList.addAll(this.thesis.getXMLElementList());
            }
            for (ReasoningItem reasoningItem : reasoningItemList){
                xmlElementList.addAll(reasoningItem.getXMLElementList());
            }
            if (this.perCasesReasoning != null){
                xmlElementList.addAll(this.perCasesReasoning.getXMLElementList());
            }
            if (this.endPosition != null){
                xmlElementList.addAll(this.endPosition.getXMLElementList());
            }
        } else {
            if (this.suppose != null){
                xmlElementList.addAll(this.suppose.getXMLElementList());
            }
            for (ReasoningItem reasoningItem : reasoningItemList){
                xmlElementList.addAll(reasoningItem.getXMLElementList());
            }
            if (this.perCasesReasoning != null){
                xmlElementList.addAll(this.perCasesReasoning.getXMLElementList());
            }
            if (this.endPosition != null){
                xmlElementList.addAll(this.endPosition.getXMLElementList());
            }
            if (this.blockThesis != null){
                xmlElementList.addAll(this.blockThesis.getXMLElementList());
            }
        }
        if (!isEmpty) {
            xmlElement = new XMLElement(NAME);
            xmlElement.setEndElement(true);
            xmlElementList.add(xmlElement);
        }
        return xmlElementList;
    }
View Full Code Here

        return parentNode;
    }

    public static Article newInstance(INode parentNode, LinkedList<XMLElement> xmlElementList) throws ElementParseException {
        Article article = new Article(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 (article.aid == null){
                    article.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 (article.mizfiles == null){
                    article.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("DefinitionBlock")){
                    article.elementList.add(DefinitionBlock.newInstance(article, xmlElementList));
                } else if (xmlElement.getName().equals("RegistrationBlock")){
                  article.elementList.add(RegistrationBlock.newInstance(article, xmlElementList));
                } else if (xmlElement.getName().equals("NotationBlock")){
                  article.elementList.add(NotationBlock.newInstance(article, xmlElementList));
                } else if (xmlElement.getName().equals("Reservation")){
                  article.elementList.add(Reservation.newInstance(article, xmlElementList));
                } else if (xmlElement.getName().equals("SchemeBlock")){
                  article.elementList.add(SchemeBlock.newInstance(article, xmlElementList));
                } else if (xmlElement.getName().equals("JustifiedTheorem")){
                  article.elementList.add(JustifiedTheorem.newInstance(article, xmlElementList));
                } else if (xmlElement.getName().equals("DefTheorem")){
                  article.elementList.add(DefTheorem.newInstance(article, xmlElementList));
                } else if (xmlElement.getName().equals("Definiens")){
                  article.elementList.add(Definiens.newInstance(article, xmlElementList));
                } else if (xmlElement.getName().equals("Canceled")){
                  article.elementList.add(Canceled.newInstance(article, xmlElementList));
                } else if (xmlElement.getName().equals("Section")){
                  article.elementList.add(Section.newInstance(article, xmlElementList));
                } else if (AuxiliaryItem.isAuxiliaryItem(xmlElement.getName())) {
                  article.elementList.add(AuxiliaryItem.newInstance(article, xmlElementList));
                } else
                    throw new ElementParseException(ElementParseException.NOT_VALID_ELEMENT, "The XMLElement " + xmlElement.getName() + " is not valid in " + NAME, xmlElementList);
            }
        }

        return article;
    }
View Full Code Here

        return article;
    }

    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 = this.elementList.isEmpty();
        xmlElement.setEmpty(isEmpty);
        xmlElementList.add(xmlElement);
        for (IElement iElement : this.elementList){
            xmlElementList.addAll(iElement.getXMLElementList());
        }
        if (!isEmpty) {
            xmlElement = new XMLElement(NAME);
            xmlElement.setEndElement(true);
            xmlElementList.add(xmlElement);
        }
        return xmlElementList;
    }
View Full Code Here

        return parentNode;
    }

    public static SchemeInstantiation newInstance(INode parentNode, LinkedList<XMLElement> xmlElementList) throws ElementParseException {
        SchemeInstantiation schemeInstantiation = new SchemeInstantiation(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("FuncInstance")){
                    schemeInstantiation.funcInstanceList.add(FuncInstance.newInstance(schemeInstantiation, xmlElementList));
                } else if (xmlElement.getName().equals("PredInstance")){
                    schemeInstantiation.predInstanceList.add(PredInstance.newInstance(schemeInstantiation, xmlElementList));
                } else
                    throw new ElementParseException(ElementParseException.NOT_VALID_ELEMENT, "The XMLElement " + xmlElement.getName() + " is not valid in " + NAME, xmlElementList);
            }
        }

        return schemeInstantiation;
    }
View Full Code Here

        return schemeInstantiation;
    }

    public LinkedList<XMLElement> getXMLElementList() {
        LinkedList<XMLElement> xmlElementList = new LinkedList<XMLElement>();
        XMLElement xmlElement = new XMLElement(NAME);
        boolean isEmpty = !(!funcInstanceList.isEmpty()
         || !predInstanceList.isEmpty());
        xmlElement.setEmpty(isEmpty);
        xmlElementList.add(xmlElement);
        for (FuncInstance funcInstance : this.funcInstanceList){
            xmlElementList.addAll(funcInstance.getXMLElementList());
        }
        for (PredInstance predInstance : this.predInstanceList){
            xmlElementList.addAll(predInstance.getXMLElementList());
        }
        if (!isEmpty) {
            xmlElement = new XMLElement(NAME);
            xmlElement.setEndElement(true);
            xmlElementList.add(xmlElement);
        }
        return xmlElementList;
    }
View Full Code Here

        return parentNode;
    }

    public static Pred newInstance(INode parentNode, LinkedList<XMLElement> xmlElementList) throws ElementParseException {
        Pred pred = new Pred(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 (pred.kind == null){
                    if (Kind.valueOf(xmlAttribute.getValue()) != null) {
                        pred.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 (pred.nr == null){
                    try {pred.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 (pred.absnr == null){
                    try {pred.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 (pred.aid == null){
                    pred.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 (pred.pid == null){
                    try {pred.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())){
                    pred.termList.add(Term.newInstance(pred, xmlElementList));
                } else
                    throw new ElementParseException(ElementParseException.NOT_VALID_ELEMENT, "The XMLElement " + xmlElement.getName() + " is not valid in " + NAME, xmlElementList);
            }
        }

        return pred;
    }
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.