java.text.ParseException#initCause ( )源码实例Demo

下面列出了java.text.ParseException#initCause ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Time4A   文件: SimpleFormatter.java
@Override
public T parse(CharSequence text) throws ParseException {

    ParsePosition pp = new ParsePosition(0);
    T result;

    try {
        result = this.parseInternal(text, pp, null);

        if ((result == null) || (pp.getErrorIndex() > -1)) {
            throw new ParseException("Cannot parse: " + text, pp.getErrorIndex());
        }
    } catch (RuntimeException re) {
        ParseException pe = new ParseException(re.getMessage(), pp.getErrorIndex());
        pe.initCause(re);
        throw pe;
    }

    return result;

}
 
源代码2 项目: ant-ivy   文件: XmlReportParser.java
public void parse(File report) throws ParseException {
    if (!report.exists()) {
        throw new IllegalStateException("Report file '" + report.getAbsolutePath()
                + "' does not exist.");
    }

    parser = new SaxXmlReportParser(report);
    try {
        parser.parse();
    } catch (Exception e) {
        ParseException pe = new ParseException("failed to parse report: " + report + ": "
                + e.getMessage(), 0);
        pe.initCause(e);
        throw pe;
    }
}
 
源代码3 项目: Time4A   文件: SimpleFormatter.java
@Override
public T parse(CharSequence text, RawValues rawValues) throws ParseException {

    if (rawValues == null) {
        throw new NullPointerException("Missing raw values.");
    }

    ParsePosition pp = new ParsePosition(0);
    T result;

    try {
        result = this.parseInternal(text, pp, rawValues);

        if ((result == null) || (pp.getErrorIndex() > -1)) {
            throw new ParseException("Cannot parse: " + text, pp.getErrorIndex());
        }
    } catch (RuntimeException re) {
        ParseException pe = new ParseException(re.getMessage(), pp.getErrorIndex());
        pe.initCause(re);
        throw pe;
    }

    return result;

}
 
源代码4 项目: darklaf   文件: ColorValueFormatter.java
@Override
public Object stringToValue(final String text) throws ParseException {
    try {
        if (text.isEmpty()) {
            return model.getDefault(fieldIndex);
        }
        if (hex) {
            String hexStr = String.format("%1$-" + getHexLength() + "s", text).replaceAll(" ", "F");
            int r = Integer.valueOf(hexStr.substring(0, 2), 16);
            checkRange(r, 0, 255);
            int g = Integer.valueOf(hexStr.substring(2, 4), 16);
            checkRange(g, 0, 255);
            int b = Integer.valueOf(hexStr.substring(4, 6), 16);
            checkRange(b, 0, 255);
            int alpha = hexStr.length() >= 8
                    ? Integer.valueOf(hexStr.substring(6, 8), 16)
                    : 255;
            checkRange(alpha, 0, 255);
            return new Color(r, g, b, alpha);
        } else {
            int value = Integer.valueOf(text, this.radix);
            int min = model.getMinimum(fieldIndex);
            int max = model.getMaximum(fieldIndex);
            checkRange(value, min, max);
            return value;
        }
    } catch (NumberFormatException nfe) {
        ParseException pe = new ParseException("illegal format", 0);
        pe.initCause(nfe);
        throw pe;
    }
}
 
源代码5 项目: jdk1.8-source-analysis   文件: ValueFormatter.java
@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;
    }
}
 
源代码6 项目: Time4A   文件: Duration.java
private static long parseAmount(
    String period,
    String number,
    int index
) throws ParseException {

    try {
        return Long.parseLong(number);
    } catch (NumberFormatException nfe) {
        ParseException pe = new ParseException(period, index);
        pe.initCause(nfe);
        throw pe;
    }

}
 
源代码7 项目: lucene-solr   文件: SolrSynonymParser.java
@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();
  }
}
 
源代码8 项目: ant-ivy   文件: XmlModuleDescriptorParser.java
public void toIvyFile(InputStream is, Resource res, File destFile, ModuleDescriptor md)
        throws IOException, ParseException {
    try {
        Namespace ns = null;
        if (md instanceof DefaultModuleDescriptor) {
            DefaultModuleDescriptor dmd = (DefaultModuleDescriptor) md;
            ns = dmd.getNamespace();
        }
        XmlModuleDescriptorUpdater.update(
            is,
            res,
            destFile,
            new UpdateOptions().setSettings(IvyContext.getContext().getSettings())
                    .setStatus(md.getStatus())
                    .setRevision(md.getResolvedModuleRevisionId().getRevision())
                    .setPubdate(md.getResolvedPublicationDate()).setUpdateBranch(false)
                    .setNamespace(ns));
    } catch (SAXException e) {
        ParseException pe = new ParseException("exception occurred while parsing " + res, 0);
        pe.initCause(e);
        throw pe;
    } finally {
        if (is != null) {
            is.close();
        }
    }
}
 
源代码9 项目: jdk8u_jdk   文件: ValueFormatter.java
@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;
    }
}
 
源代码10 项目: TencentKona-8   文件: JFCParser.java
public static Configuration createConfiguration(String name, String content) throws IOException, ParseException {
    try {
        JFCParserHandler ch = new JFCParserHandler();
        parseXML(content, ch);
        return PrivateAccess.getInstance().newConfiguration(name, ch.label, ch.description, ch.provider, ch.settings, content);
    } catch (IllegalArgumentException iae) {
        throw new ParseException(iae.getMessage(), -1);
    } catch (SAXException e) {
        ParseException pe =  new ParseException("Error reading JFC file. " + e.getMessage(), -1);
        pe.initCause(e);
        throw pe;
    }
}
 
源代码11 项目: TencentKona-8   文件: ValueFormatter.java
@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;
    }
}
 
源代码12 项目: JDKSourceCode1.8   文件: ValueFormatter.java
@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;
    }
}
 
源代码13 项目: lucene-solr   文件: JavascriptErrorHandlingLexer.java
/**
 * Ensures the ANTLR lexer will throw an exception after the first error
 * @param lnvae the lexer exception
 */
@Override
public void recover(LexerNoViableAltException lnvae) {
  CharStream charStream = lnvae.getInputStream();
  int startIndex = lnvae.getStartIndex();
  String text = charStream.getText(Interval.of(startIndex, charStream.index()));

  ParseException parseException = new ParseException("unexpected character '" + getErrorDisplay(text) + "'" +
      " on line (" + _tokenStartLine + ") position (" + _tokenStartCharPositionInLine + ")", _tokenStartCharIndex);
  parseException.initCause(lnvae);
  throw new RuntimeException(parseException);
}
 
源代码14 项目: openjdk-jdk8u   文件: ValueFormatter.java
@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;
    }
}
 
源代码15 项目: openjdk-jdk8u-backup   文件: ValueFormatter.java
@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;
    }
}
 
源代码16 项目: openjdk-jdk9   文件: ValueFormatter.java
@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;
    }
}
 
源代码17 项目: Java8CN   文件: ValueFormatter.java
@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;
    }
}
 
源代码18 项目: hottub   文件: ValueFormatter.java
@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;
    }
}
 
源代码19 项目: fitnotifications   文件: CollationRuleParser.java
private void setParseError(String reason, Exception e) throws ParseException {
    ParseException newExc = makeParseException(reason + ": " + e.getMessage());
    newExc.initCause(e);
    throw newExc;
}
 
源代码20 项目: ant-ivy   文件: PomModuleDescriptorParser.java
private ParseException newParserException(Exception e) {
    Message.error(e.getMessage());
    ParseException pe = new ParseException(e.getMessage(), 0);
    pe.initCause(e);
    return pe;
}