Package org.eclipse.xtext.conversion

Examples of org.eclipse.xtext.conversion.ValueConverterException


  }
 
  public static String parseVersionRange(final String string, final INode node) {
    boolean _isEmpty = Strings.isEmpty(string);
    if (_isEmpty) {
      throw new ValueConverterException("Couldn\'t convert empty string to a VersionRange value.", node, null);
    }
    boolean _equalsIgnoreCase = "lazy".equalsIgnoreCase(string);
    boolean _not = (!_equalsIgnoreCase);
    if (_not) {
      try {
        final VersionRange value = new VersionRange(string);
        return value.toString();
      } catch (final Throwable _t) {
        if (_t instanceof IllegalArgumentException) {
          final IllegalArgumentException e = (IllegalArgumentException)_t;
          throw new ValueConverterException((("Couldn\'t convert \'" + string) + "\' to a VersionRange value."), node, e);
        } else {
          throw Exceptions.sneakyThrow(_t);
        }
      }
    } else {
View Full Code Here


   * @throws ValueConverterException if the given input is {@code null}, empty or does not represent an hexadecimal
   * number.
   */
  @Override public Long toValue(String string, INode node) throws ValueConverterException {
    if (isEmpty(string)) {
      throw new ValueConverterException("Couldn't convert empty string to long.", node, null);
    }
    if (!startsWithValidPrefix(string)) {
      throw parsingError(string, node);
    }
    String withoutZeroX = removeZeroX(string);
View Full Code Here

  private ValueConverterException parsingError(String string, INode node) {
    return parsingError(string, node, null);
  }

  private ValueConverterException parsingError(String string, INode node, Exception cause) {
    return new ValueConverterException("Couldn't convert '" + string + "' to long.", node, cause);
  }
View Full Code Here

  private String toValue(String string) {
    return removeLineBreaks(string, LineTransformation.INSTANCE);
  }

  private ValueConverterException parsingError(String string, INode node, Exception cause) {
    return new ValueConverterException("Couldn't convert '" + string + "' to String.", node, cause);
  }
View Full Code Here

   * @return the new {@code int}.
   * @throws ValueConverterException if the given input is {@code null}, empty or does not represent an integer number.
   */
  @Override public Long toValue(String string, INode node) throws ValueConverterException {
    if (isEmpty(string)) {
      throw new ValueConverterException("Couldn't convert empty string to long.", node, null);
    }
    try {
      return Long.parseLong(string, 10);
    } catch (NumberFormatException e) {
      return parseUsingBigInteger(string, node);
View Full Code Here

      throw parsingError(string, node, e);
    }
  }

  private ValueConverterException parsingError(String string, INode node, Exception cause) {
    return new ValueConverterException("Couldn't convert '" + string + "' to long.", node, cause);
  }
View Full Code Here

   * @throws ValueConverterException if the given input is {@code null}, empty or does not represent a floating-point
   * number.
   */
  @Override public Double toValue(String string, INode node) throws ValueConverterException {
    if (isEmpty(string)) {
      throw new ValueConverterException("Couldn't convert empty string to double.", node, null);
    }
    Double predefinedValue = PREDEFINED_VALUES.get(string);
    if (predefinedValue != null) {
      return predefinedValue;
    }
View Full Code Here

      throw parsingError(string, node, e);
    }
  }

  private ValueConverterException parsingError(String string, INode node, Exception cause) {
    return new ValueConverterException("Couldn't convert '" + string + "' to double.", node, cause);
  }
View Full Code Here

      public String toValue(String string, INode node)
          throws ValueConverterException {
        if( string.length() == 4 || string.length() == 7 ) {
          return string.substring(1);
        }
        throw new ValueConverterException("'" + string + "' is not a valid RGB color code", node, null);
      }
    };
  }
View Full Code Here

      return null;
    try {
      string = string.trim();
      return string.substring(3, string.length() - 3);
    } catch (IllegalArgumentException e) {
      throw new ValueConverterException(e.getMessage(), node, e);
    }
  }
View Full Code Here

TOP

Related Classes of org.eclipse.xtext.conversion.ValueConverterException

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.