Java Code Examples for java.text.ParseException.initCause()

The following are Jave code examples for showing how to use initCause() of the java.text.ParseException class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: directory-ldap-api   File: AbstractSchemaParser.java   View Source Code Vote up 5 votes
private ParseException wrapRecognitionException( String schemaDescription, RecognitionException re )
{
    String msg = I18n.err( errorCodeOnParseExceptionWithPosition, schemaDescription, re.getMessage(),
        re.getColumn() );
    LOG.error( msg );
    ParseException parseException = new ParseException( msg, re.getColumn() );
    parseException.initCause( re );
    return parseException;
}
 
Example 2
Project: directory-ldap-api   File: AbstractSchemaParser.java   View Source Code Vote up 5 votes
private ParseException wrapTokenStreamException( String schemaDescription, TokenStreamException tse )
{
    String msg = I18n.err( errorCodeOnParseException, schemaDescription, tse.getMessage() );
    LOG.error( msg );
    ParseException parseException = new ParseException( msg, 0 );
    parseException.initCause( tse );
    return parseException;
}
 
Example 3
Project: guava-mock   File: HostSpecifier.java   View Source Code Vote up 5 votes
/**
 * Attempts to return a {@code HostSpecifier} for the given string, throwing an exception if
 * parsing fails. Always use this method in preference to {@link #fromValid(String)} for a
 * specifier that is not already known to be valid.
 *
 * @throws ParseException if the specifier is not valid.
 */
public static HostSpecifier from(String specifier) throws ParseException {
  try {
    return fromValid(specifier);
  } catch (IllegalArgumentException e) {
    // Since the IAE can originate at several different points inside
    // fromValid(), we implement this method in terms of that one rather
    // than the reverse.

    ParseException parseException = new ParseException("Invalid host specifier: " + specifier, 0);
    parseException.initCause(e);
    throw parseException;
  }
}
 
Example 4
Project: lams   File: WordnetSynonymParser.java   View Source Code Vote up 5 votes
@Override
public void parse(Reader in) throws IOException, ParseException {
  LineNumberReader br = new LineNumberReader(in);
  try {
    String line = null;
    String lastSynSetID = "";
    CharsRef synset[] = new CharsRef[8];
    int synsetSize = 0;
    
    while ((line = br.readLine()) != null) {
      String synSetID = line.substring(2, 11);

      if (!synSetID.equals(lastSynSetID)) {
        addInternal(synset, synsetSize);
        synsetSize = 0;
      }

      if (synset.length <= synsetSize+1) {
        synset = Arrays.copyOf(synset, synset.length * 2);
      }
      
      synset[synsetSize] = parseSynonym(line, new CharsRefBuilder());
      synsetSize++;
      lastSynSetID = synSetID;
    }
    
    // final synset in the file
    addInternal(synset, synsetSize);
  } catch (IllegalArgumentException e) {
    ParseException ex = new ParseException("Invalid synonym rule at line " + br.getLineNumber(), 0);
    ex.initCause(e);
    throw ex;
  } finally {
    br.close();
  }
}
 
Example 5
Project: lams   File: SolrSynonymParser.java   View Source Code Vote up 5 votes
@Override
public void parse(Reader in) throws IOException, ParseException {
  LineNumberReader br = new LineNumberReader(in);
  try {
    addInternal(br);
  } catch (IllegalArgumentException e) {
    ParseException ex = new ParseException("Invalid synonym rule at line " + br.getLineNumber(), 0);
    ex.initCause(e);
    throw ex;
  } finally {
    br.close();
  }
}
 
Example 6
Project: lams   File: Version.java   View Source Code Vote up 5 votes
/**
 * Parse the given version number as a constant or dot based version.
 * <p>This method allows to use {@code "LUCENE_X_Y"} constant names,
 * or version numbers in the format {@code "x.y.z"}.
 *
 * @lucene.internal
 */
public static Version parseLeniently(String version) throws ParseException {
  String versionOrig = version;
  version = version.toUpperCase(Locale.ROOT);
  switch (version) {
    case "LATEST":
    case "LUCENE_CURRENT":
      return LATEST;
    case "LUCENE_4_0_0":
      return LUCENE_4_0_0;
    case "LUCENE_4_0_0_ALPHA":
      return LUCENE_4_0_0_ALPHA;
    case "LUCENE_4_0_0_BETA":
      return LUCENE_4_0_0_BETA;
    default:
      version = version
        .replaceFirst("^LUCENE_(\\d+)_(\\d+)_(\\d+)$", "$1.$2.$3")
        .replaceFirst("^LUCENE_(\\d+)_(\\d+)$", "$1.$2.0")
        .replaceFirst("^LUCENE_(\\d)(\\d)$", "$1.$2.0");
      try {
        return parse(version);
      } catch (ParseException pe) {
        ParseException pe2 = new ParseException("failed to parse lenient version string \"" + versionOrig + "\": " + pe.getMessage(), 0);
        pe2.initCause(pe);
        throw pe2;
      }
  }
}
 
Example 7
Project: OpenJSharp   File: ValueFormatter.java   View Source Code Vote up 5 votes
@Override
public Object stringToValue(String text) throws ParseException {
    try {
        return Integer.valueOf(text, this.radix);
    }
    catch (NumberFormatException nfe) {
        ParseException pe = new ParseException("illegal format", 0);
        pe.initCause(nfe);
        throw pe;
    }
}
 
Example 8
Project: jdk8u-jdk   File: ValueFormatter.java   View Source Code Vote up 5 votes
@Override
public Object stringToValue(String text) throws ParseException {
    try {
        return Integer.valueOf(text, this.radix);
    }
    catch (NumberFormatException nfe) {
        ParseException pe = new ParseException("illegal format", 0);
        pe.initCause(nfe);
        throw pe;
    }
}
 
Example 9
Project: openjdk-jdk10   File: ValueFormatter.java   View Source Code Vote up 5 votes
@Override
public Object stringToValue(String text) throws ParseException {
    try {
        return Integer.valueOf(text, this.radix);
    }
    catch (NumberFormatException nfe) {
        ParseException pe = new ParseException("illegal format", 0);
        pe.initCause(nfe);
        throw pe;
    }
}
 
Example 10
Project: openNaEF   File: InventoryIdDecoder.java   View Source Code Vote up 5 votes
public static NodeElementDto getNodeElementDto(String inventoryID) throws ParseException {
    List<String> arr = Util.splitWithEscape(inventoryID, ":");
    try {
        NodeDto node = NodeUtil.getNode(arr.get(1));
        String nodeElementName = arr.get(2);
        List<String> elemNames = splitElementName(nodeElementName);
        int level = 0;
        NodeElementDto result = getNodeElement(node.getSubElements(), elemNames, level);
        return result;
    } catch (Exception e) {
        ParseException ex = new ParseException(inventoryID, 0);
        ex.initCause(e);
        throw ex;
    }
}
 
Example 11
Project: googles-monorepo-demo   File: HostSpecifier.java   View Source Code Vote up 5 votes
/**
 * Attempts to return a {@code HostSpecifier} for the given string, throwing an exception if
 * parsing fails. Always use this method in preference to {@link #fromValid(String)} for a
 * specifier that is not already known to be valid.
 *
 * @throws ParseException if the specifier is not valid.
 */
public static HostSpecifier from(String specifier) throws ParseException {
  try {
    return fromValid(specifier);
  } catch (IllegalArgumentException e) {
    // Since the IAE can originate at several different points inside
    // fromValid(), we implement this method in terms of that one rather
    // than the reverse.

    ParseException parseException = new ParseException("Invalid host specifier: " + specifier, 0);
    parseException.initCause(e);
    throw parseException;
  }
}
 
Example 12
Project: fitnotifications   File: CollationRuleParser.java   View Source Code Vote up 4 votes
private void setParseError(String reason, Exception e) throws ParseException {
    ParseException newExc = makeParseException(reason + ": " + e.getMessage());
    newExc.initCause(e);
    throw newExc;
}