Package org.fest.swing.exception

Examples of org.fest.swing.exception.ParsingException


  public @Nonnull KeyStrokeMappingProvider parse(@Nonnull String fileName) {
    checkNotNullOrEmpty(fileName);
    try {
      return parse(fileAsStream(fileName));
    } catch (IOException e) {
      throw new ParsingException(concat("An I/O error ocurred while parsing file ", fileName), e);
    }
  }
View Full Code Here


  }

  private @Nonnull InputStream fileAsStream(String file) {
    InputStream stream = currentThread().getContextClassLoader().getResourceAsStream(file);
    if (stream == null) {
      throw new ParsingException(String.format("Unable to open file %s", file));
    }
    return stream;
  }
View Full Code Here

  public @Nonnull KeyStrokeMappingProvider parse(@Nonnull File file) {
    assertThat(file).isFile();
    try {
      return parse(fileAsStream(file));
    } catch (IOException e) {
      throw new ParsingException(concat("An I/O error ocurred while parsing file ", file), e);
    }
  }
View Full Code Here

  private @Nonnull InputStream fileAsStream(@Nonnull File file) {
    try {
      return new FileInputStream(file);
    } catch (FileNotFoundException e) {
      String msg = String.format("The file %s was not found", file.getPath());
      throw new ParsingException(msg, e);
    }
  }
View Full Code Here

  @VisibleForTesting
  @Nonnull KeyStrokeMapping mappingFrom(@Nonnull String line) {
    String[] parts = line.trim().split(",");
    if (parts.length != 3) {
      String msg = String.format("Line '%s' does not conform with pattern '{char}, {keycode}, {modifiers}'", line);
      throw new ParsingException(msg);
    }
    char character = characterFrom(parts[0].trim());
    int keyCode = keyCodeFrom(parts[1].trim());
    int modifiers = modifiersFrom(parts[2].trim());
    return mapping(character, keyCode, modifiers);
View Full Code Here

      return SPECIAL_MAPPINGS.get(s);
    }
    if (s.length() == 1) {
      return s.charAt(0);
    }
    throw new ParsingException(String.format("The text '%s' should have a single character", s));
  }
View Full Code Here

  private static int keyCodeFrom(@Nonnull String s) {
    try {
      Integer keyCode = field("VK_" + s).ofType(int.class).in(KeyEvent.class).get();
      return checkNotNull(keyCode);
    } catch (ReflectionError e) {
      throw new ParsingException(concat("Unable to retrieve key code from text ", quote(s)), e.getCause());
    }
  }
View Full Code Here

    }
    try {
      Integer modifiers = field(s).ofType(int.class).in(InputEvent.class).get();
      return checkNotNull(modifiers);
    } catch (ReflectionError e) {
      throw new ParsingException(concat("Unable to retrieve modifiers from text ", quote(s)), e.getCause());
    }
  }
View Full Code Here

  public KeyStrokeMappingProvider parse(String file) {
    validate(file);
    try {
      return parse(fileAsStream(file));
    } catch (IOException e) {
      throw new ParsingException(concat("An I/O error ocurred while parsing file ", file), e);
    }
  }
View Full Code Here

      throw new IllegalArgumentException("The name of the file to parse should not be an empty string");
  }

  private InputStream fileAsStream(String file) {
    InputStream stream = currentThread().getContextClassLoader().getResourceAsStream(file);
    if (stream == null) throw new ParsingException(concat("Unable to open file ", file));
    return stream;
  }
View Full Code Here

TOP

Related Classes of org.fest.swing.exception.ParsingException

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.