Examples of ParsingFailException


Examples of org.gbcpainter.loaders.level.ParsingFailException

        }
      }
    }

    if ( ! success ) {
      throw new ParsingFailException( "Can't find a valid decoder", lastException );
    }

    return parsingResult;
  }
View Full Code Here

Examples of org.gbcpainter.loaders.level.ParsingFailException

    StringTokenizer tokenizer = new StringTokenizer( line, DELIMITER );

    while ( tokenizer.hasMoreElements() ) {
      if ( tokenIndex == PIPE_TOKENS ) {
        throw new ParsingFailException( "Too many tokens" );
      }

      String token = tokenizer.nextToken();

      try {
        parsedInt = Integer.parseInt( token );
        if ( parsedInt < 0 ) {
          throw new NumberFormatException( "Negative number" );
        }
      } catch ( NumberFormatException e ) {
        throw new ParsingFailException( e );
      }


      lineParsingRawData[tokenIndex] = parsedInt;
      tokenIndex++;
    }

    if ( tokenIndex != PIPE_TOKENS ) {
      if ( tokenIndex == EXTERNAL_PIPE_TOKENS ) {
        lineParsingRawData[PIPE_TOKENS - 1] = EXTERNAL_FACE_PIPE_ID;
      } else {
        throw new ParsingFailException( "Not enough tokens: " + line );
      }

    }

    return lineParsingRawData;
View Full Code Here

Examples of org.gbcpainter.loaders.level.ParsingFailException

      monsterPosition.x = Integer.parseInt( token );
      if ( monsterPosition.x < 0 ) {
        throw new NumberFormatException( "Negative number" );
      }
    } catch ( NumberFormatException e ) {
      throw new ParsingFailException( e );
    }

    token = tokenizer.nextToken();

    try {
      monsterPosition.y = Integer.parseInt( token );
      if ( monsterPosition.y < 0 ) {
        throw new NumberFormatException( "Negative number" );
      }
    } catch ( NumberFormatException e ) {
      throw new ParsingFailException( e );
    }

    return new AbstractMap.SimpleEntry<>( monsterName, monsterPosition );

  }
View Full Code Here

Examples of org.gbcpainter.loaders.level.ParsingFailException

    String realData = parsingResult.toString();

    //Splits the file in lines
    List<String> lines = Arrays.asList( LINE_DELIMITER_PATTERN.split( realData ) );
    if ( lines.isEmpty() ) {
      throw new ParsingFailException( "Empty file" );
    }

    //Find player position first
    final Iterator<String> skipFirstLineTrick = lines.iterator();
    String firstLine;
    try {
      do {
        firstLine = skipFirstLineTrick.next();
        //Remove spaces
        firstLine = SPACE_PATTERN.matcher( firstLine ).replaceAll( "" );
      } while ( ! VALID_PLAYER_POSITION_PATTERN.matcher( firstLine ).matches() );

    } catch ( NoSuchElementException e ) {
      //If player position line couldn't be found...
      throw new ParsingFailException( "Can't find a valid player position", e );
    }

    try {
      final Point validPosition = parsePlayerPositionLine( firstLine );
      this.playerPosition.x = validPosition.x;
      this.playerPosition.y = validPosition.y;
    } catch ( NumberFormatException e ) {
      throw new ParsingFailException( e );
    }
    /* End of the parsing of the initial player position */

    /* Parse the other lines */
    while ( skipFirstLineTrick.hasNext() ) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.