Package org.mizartools.system

Examples of org.mizartools.system.ElementParseException


    public static PrivPred newInstance(INode parentNode, LinkedList<XMLElement> xmlElementList) throws ElementParseException {
        PrivPred privPred = new PrivPred(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 (privPred.nr == null){
                    try {privPred.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;
                }
                if (Term.isTerm(xmlElement.getName())){
                    privPred.termList.add(Term.newInstance(privPred, xmlElementList));
                } else if (Formula.isFormula(xmlElement.getName())){
                    if (privPred.formula == null) {
                        privPred.formula = Formula.newInstance(privPred, 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 privPred;
    }
View Full Code Here


    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

    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

      boolean thereAreCharacters = false;
      try {
        
        stream = new FileInputStream(file);
      } catch (FileNotFoundException e) {
        throw new ElementParseException(ElementParseException.FILE_NOT_FOUND, "Error opening the file " + file.toString());
      }
      XMLStreamReader parser;
      try {
        parser = xmlInputFactory.createXMLStreamReader(systemId, stream);
       
        while (parser.hasNext()){
          eventType = parser.next();
          switch (eventType) {
  //            case XMLStreamConstants.START_DOCUMENT:
  //                    break;
          case XMLStreamConstants.START_ELEMENT:
                  thereAreCharacters = false;
            currentXMLElement = new XMLElement(parser.getLocalName());
            if (parser.getAttributeCount() != 0){
              for(int i = 0; i < parser.getAttributeCount(); i++){
                currentXMLElement.getXMLAttributeList().add(new XMLAttribute(parser.getAttributeLocalName(i), parser.getAttributeValue(i)));
              }
            }
                  xmlElementList.add(currentXMLElement);
                  break;
  //            case XMLStreamConstants.ATTRIBUTE:
  //                    break;
  //            case XMLStreamConstants.END_DOCUMENT:
  //                    break;
                case XMLStreamConstants.END_ELEMENT:
                  if (thereAreCharacters){
              currentXMLElement = new XMLElement(parser.getLocalName());
              currentXMLElement.setEndElement(true);
                    xmlElementList.add(currentXMLElement);
                  } else
                  {
                    currentXMLElement.setEmpty(true);
                  }
            break;
                case XMLStreamConstants.CHARACTERS:
                  if (currentXMLElement.getCharacters() != null) {
                    currentXMLElement.setCharacters(currentXMLElement.getCharacters() + parser.getText());
                  } else {
                    currentXMLElement.setCharacters(parser.getText());
                  }
                  thereAreCharacters = true;
            break;
  //                  case XMLStreamConstants.CDATA:
  //              break;
  //                  case XMLStreamConstants.COMMENT:
  //              break;
  //                  case XMLStreamConstants.DTD:
  //              break;
  //                  case XMLStreamConstants.ENTITY_DECLARATION:
  //              break;
  //                  case XMLStreamConstants.ENTITY_REFERENCE:
  //              break;
  //                  case XMLStreamConstants.NAMESPACE:
  //              break;
  //                  case XMLStreamConstants.NOTATION_DECLARATION:
  //              break;
                case XMLStreamConstants.PROCESSING_INSTRUCTION:
                  if (parser.getPITarget() != null && parser.getPIData() != null)
                    processingInstructionList.add(parser.getPITarget() + " " + parser.getPIData());
            break;
  //                  case XMLStreamConstants.SPACE:
  //              break;
          }
        }
        parser.close();
      } catch (XMLStreamException e) {
        throw new ElementParseException(ElementParseException.XML_STREAM, "Impossible parsing file " + file.toString());
      }
      try {
        stream.close();
      } catch (IOException e) {
        throw new ElementParseException(ElementParseException.IO, "Error closing the file " + file.toString());
      }
    }
  } 
View Full Code Here

    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

    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

    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

    public static Implies newInstance(INode parentNode, LinkedList<XMLElement> xmlElementList) throws ElementParseException {
        Implies implies = new Implies(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("pid")){
                if (implies.pid == null){
                    try {implies.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 (Formula.isFormula(xmlElement.getName())){
                    if (implies.hypothesis == null) {
                        implies.hypothesis = Formula.newInstance(implies, xmlElementList);
                    } else if (implies.conclusion == null) {
                        implies.conclusion = Formula.newInstance(implies, xmlElementList);
                    } else {
                        throw new ElementParseException(ElementParseException.TOO_MANY_ELEMENTS, "XMLElement list contains too many elements <Formula> in element " + NAME, xmlElementList);
                    }
                } else
                    throw new ElementParseException(ElementParseException.NOT_VALID_ELEMENT, "The XMLElement " + xmlElement.getName() + " is not valid in " + NAME, xmlElementList);
            }
        }

        return implies;
    }
View Full Code Here

    public static EndPosition newInstance(INode parentNode, LinkedList<XMLElement> xmlElementList) throws ElementParseException {
        EndPosition endPosition = new EndPosition(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 (endPosition.line == null){
                    try {endPosition.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 (endPosition.col == null){
                    try {endPosition.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;
                }
                throw new ElementParseException(ElementParseException.NOT_VALID_ELEMENT, "The XMLElement " + xmlElement.getName() + " is not valid in " + NAME, xmlElementList);
            }
        }
        return endPosition;
    }
View Full Code Here

    public static Iff newInstance(INode parentNode, LinkedList<XMLElement> xmlElementList) throws ElementParseException {
        Iff iff = new Iff(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("pid")){
                if (iff.pid == null){
                    try {iff.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 (Formula.isFormula(xmlElement.getName())){
                    if (iff.formula1 == null) {
                        iff.formula1 = Formula.newInstance(iff, xmlElementList);
                    } else if (iff.formula2 == null) {
                        iff.formula2 = Formula.newInstance(iff, xmlElementList);
                    } else {
                        throw new ElementParseException(ElementParseException.TOO_MANY_ELEMENTS, "XMLElement list contains too many elements <Formula> in element " + NAME, xmlElementList);
                    }
                } else
                    throw new ElementParseException(ElementParseException.NOT_VALID_ELEMENT, "The XMLElement " + xmlElement.getName() + " is not valid in " + NAME, xmlElementList);
            }
        }

        return iff;
    }
View Full Code Here

TOP

Related Classes of org.mizartools.system.ElementParseException

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.