src/main/java/org/helm/notation2/parser/simplepolymerssection/SimplePolymersNotationParser.java
@Override
  public void doAction(char cha) throws SimplePolymerSectionException, NotationException{
    /* simple polymer notation is finished; can also be empty */
    if (cha == '}' && checkBracketsParenthesis()) {
      // initialize object - normal monomer type
      if (!(monomer.equals(""))) {
        LOG.info("Monomer unit is read:");
        _parser.notationContainer.getCurrentPolymer().getPolymerElements().addMonomerNotation(monomer);
        _parser.setState(new BetweenParser(_parser));
      } else {
        throw new SimplePolymerSectionException("Monomer unit is missing: ");
      }
    } else if (cha == '.' && checkBracketsParenthesis()) {
      /*
       * a new monomer unit is starting. This is only valid for peptide and rna
       * not for chem and blob
       */
      if (monomer != "") {
        if (_parser.isPeptideOrRna()) {
          LOG.info("Monomer unit is read: " + monomer);
          LOG.info("New monomer unit is starting:");
          _parser.notationContainer.getCurrentPolymer().getPolymerElements().addMonomerNotation(monomer);
          _parser.setState(new SimplePolymersNotationParser(_parser));
        } else {
          LOG.error("Only one monomer unit is allowed: " + monomer);
          throw new SimplePolymerSectionException("Only one monomer unit is allowed: " + monomer);
        }
      } else {
        LOG.error("Monomer unit is missing: " + monomer);
        throw new SimplePolymerSectionException("Monomer unit is missing: " + monomer);
      }

    } /* an additional annotation is given */ else if (cha == '"' && checkBracketsParenthesis()) {
      if (monomer != "") {
        LOG.info("Monomer unit is read: " + monomer);
        LOG.info("Annotation for monomer unit is starting:");
        _parser.notationContainer.getCurrentPolymer().getPolymerElements().addMonomerNotation(monomer);
        _parser.setState(new InlineAnnotationsParser(_parser, 11));
      } else {
        LOG.error("Monomer unit is missing:");
        throw new SimplePolymerSectionException("Monomer unit is missing:");
      }
    } else if (cha == '\'' && checkBracketsParenthesis()) {
      /*
       * the monomer unit is being repeated. This is only valid for peptide and
       * rna not for chem and blob
       */
      if (monomer != "") {
        if (_parser.isPeptideOrRna()) {
          LOG.info("Monomer unit is read: " + monomer);
          _parser.notationContainer.getCurrentPolymer().getPolymerElements().addMonomerNotation(monomer);
          _parser.setState(new RepeatingMonomerParser(_parser));
        } else {
          LOG.error("Monomer unit shall be not repeated: ");
          throw new SimplePolymerSectionException("Monomer unit shall be not repeated: ");
        }
      } else {
        LOG.error("Monomer unit is missing");
        throw new SimplePolymerSectionException("Monomer unit is missing");
      }

    } /* check all brackets */ else if (cha == '[' || cha == ']' || cha == '(' || cha == ')') {
      monomer += cha;
      if (cha == '[') {
        bracketCounterOpen += 1;
      } else if (cha == ']') {
        bracketCounterClose += 1;
      } else if (cha == '(') {
        parenthesisCounterOpen += 1;

      } else {
        parenthesisCounterClose += 1;

      }
    } /* add characters */ else {
      monomer += cha;
    }

  }
@Override
  public void doAction(char cha) throws SimplePolymerSectionException, NotationException{
    /* simple polymer notation is finished; can also be empty */
    if (cha == '}' && checkBracketsParenthesis()) {
      // initialize object - normal monomer type
      if (!(monomer.equals(""))) {
        LOG.info("Monomer unit is read:");
        _parser.notationContainer.getCurrentPolymer().getPolymerElements().addMonomerNotation(monomer);
        _parser.setState(new BetweenParser(_parser));
      } else {
        throw new SimplePolymerSectionException("Monomer unit is missing: ");
      }
    } else if (cha == '.' && checkBracketsParenthesis()) {
      /*
       * a new monomer unit is starting. This is only valid for peptide and rna
       * not for chem and blob
       */
      if (monomer != "") {
        if (_parser.isPeptideOrRna()) {
          LOG.info("Monomer unit is read: " + monomer);
          LOG.info("New monomer unit is starting:");
          _parser.notationContainer.getCurrentPolymer().getPolymerElements().addMonomerNotation(monomer);
          _parser.setState(new SimplePolymersNotationParser(_parser));
        } else {
          LOG.error("Only one monomer unit is allowed: " + monomer);
          throw new SimplePolymerSectionException("Only one monomer unit is allowed: " + monomer);
        }
      } else {
        LOG.error("Monomer unit is missing: " + monomer);
        throw new SimplePolymerSectionException("Monomer unit is missing: " + monomer);
      }

    } /* an additional annotation is given */ else if (cha == '"' && checkBracketsParenthesis()) {
      if (monomer != "") {
        LOG.info("Monomer unit is read: " + monomer);
        LOG.info("Annotation for monomer unit is starting:");
        _parser.notationContainer.getCurrentPolymer().getPolymerElements().addMonomerNotation(monomer);
        _parser.setState(new InlineAnnotationsParser(_parser, 11));
      } else {
        LOG.error("Monomer unit is missing:");
        throw new SimplePolymerSectionException("Monomer unit is missing:");
      }
    } else if (cha == '\'' && checkBracketsParenthesis()) {
      /*
       * the monomer unit is being repeated. This is only valid for peptide and
       * rna not for chem and blob
       */
      if (monomer != "") {
        if (_parser.isPeptideOrRna()) {
          LOG.info("Monomer unit is read: " + monomer);
          _parser.notationContainer.getCurrentPolymer().getPolymerElements().addMonomerNotation(monomer);
          _parser.setState(new RepeatingMonomerParser(_parser));
        } else {
          LOG.error("Monomer unit shall be not repeated: ");
          throw new SimplePolymerSectionException("Monomer unit shall be not repeated: ");
        }
      } else {
        LOG.error("Monomer unit is missing");
        throw new SimplePolymerSectionException("Monomer unit is missing");
      }

    } /* check all brackets */ else if (cha == '[' || cha == ']' || cha == '(' || cha == ')') {
      monomer += cha;
      if (cha == '[') {
        bracketCounterOpen += 1;
      } else if (cha == ']') {
        bracketCounterClose += 1;
      } else if (cha == '(') {
        parenthesisCounterOpen += 1;

      } else {
        parenthesisCounterClose += 1;

      }
    } /* add characters */ else {
      monomer += cha;
    }

  }
@ Override public void doAction ( char cha ) throws SimplePolymerSectionException , NotationException { /* simple polymer notation is finished; can also be empty */ if ( cha == ' ' && checkBracketsParenthesis ( ) ) { // initialize object - normal monomer type
 if ( ! ( monomer . equals ( "" ) ) ) { LOG . info ( "Monomer unit is read:" ) ; _parser . notationContainer . getCurrentPolymer ( ) . getPolymerElements ( ) . addMonomerNotation ( monomer ) ; _parser . setState ( new BetweenParser ( _parser ) ) ; } else { throw new SimplePolymerSectionException ( "Monomer unit is missing: " ) ; } } else if ( cha == ' ' && checkBracketsParenthesis ( ) ) { /*
       * a new monomer unit is starting. This is only valid for peptide and rna
       * not for chem and blob
       */ if ( monomer != "" ) { if ( _parser . isPeptideOrRna ( ) ) { LOG . info ( "Monomer unit is read: " + monomer ) ; LOG . info ( "New monomer unit is starting:" ) ; _parser . notationContainer . getCurrentPolymer ( ) . getPolymerElements ( ) . addMonomerNotation ( monomer ) ; _parser . setState ( new SimplePolymersNotationParser ( _parser ) ) ; } else { LOG . error ( "Only one monomer unit is allowed: " + monomer ) ; throw new SimplePolymerSectionException ( "Only one monomer unit is allowed: " + monomer ) ; } } else { LOG . error ( "Monomer unit is missing: " + monomer ) ; throw new SimplePolymerSectionException ( "Monomer unit is missing: " + monomer ) ; } } /* an additional annotation is given */ else if ( cha == ' ' && checkBracketsParenthesis ( ) ) { if ( monomer != "" ) { LOG . info ( "Monomer unit is read: " + monomer ) ; LOG . info ( "Annotation for monomer unit is starting:" ) ; _parser . notationContainer . getCurrentPolymer ( ) . getPolymerElements ( ) . addMonomerNotation ( monomer ) ; _parser . setState ( new InlineAnnotationsParser ( _parser , 11 ) ) ; } else { LOG . error ( "Monomer unit is missing:" ) ; throw new SimplePolymerSectionException ( "Monomer unit is missing:" ) ; } } else if ( cha == ' ' && checkBracketsParenthesis ( ) ) { /*
       * the monomer unit is being repeated. This is only valid for peptide and
       * rna not for chem and blob
       */ if ( monomer != "" ) { if ( _parser . isPeptideOrRna ( ) ) { LOG . info ( "Monomer unit is read: " + monomer ) ; _parser . notationContainer . getCurrentPolymer ( ) . getPolymerElements ( ) . addMonomerNotation ( monomer ) ; _parser . setState ( new RepeatingMonomerParser ( _parser ) ) ; } else { LOG . error ( "Monomer unit shall be not repeated: " ) ; throw new SimplePolymerSectionException ( "Monomer unit shall be not repeated: " ) ; } } else { LOG . error ( "Monomer unit is missing" ) ; throw new SimplePolymerSectionException ( "Monomer unit is missing" ) ; } } /* check all brackets */ else if ( cha == ' ' || cha == ' ' || cha == ' ' || cha == ' ' ) { monomer += cha ; if ( cha == ' ' ) { bracketCounterOpen += 1 ; } else if ( cha == ' ' ) { bracketCounterClose += 1 ; } else if ( cha == ' ' ) { parenthesisCounterOpen += 1 ; } else { parenthesisCounterClose += 1 ; } } /* add characters */ else { monomer += cha ; } }
{@inheritDoc}
@throws SimplePolymerSectionException is simple polymer section is not valid
@throws NotationException if notation is not valid
{