本文整理汇总了Java中java.text.ParseException.initCause方法的典型用法代码示例。如果您正苦于以下问题:Java ParseException.initCause方法的具体用法?Java ParseException.initCause怎么用?Java ParseException.initCause使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.text.ParseException
的用法示例。
在下文中一共展示了ParseException.initCause方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: wrapRecognitionException
import java.text.ParseException; //导入方法依赖的package包/类
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;
}
示例2: wrapTokenStreamException
import java.text.ParseException; //导入方法依赖的package包/类
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;
}
示例3: from
import java.text.ParseException; //导入方法依赖的package包/类
/**
* 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;
}
}
示例4: parse
import java.text.ParseException; //导入方法依赖的package包/类
@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();
}
}
示例5: parse
import java.text.ParseException; //导入方法依赖的package包/类
@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();
}
}
示例6: parseLeniently
import java.text.ParseException; //导入方法依赖的package包/类
/**
* 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;
}
}
}
示例7: stringToValue
import java.text.ParseException; //导入方法依赖的package包/类
@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;
}
}
示例8: getNodeElementDto
import java.text.ParseException; //导入方法依赖的package包/类
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;
}
}
示例9: setParseError
import java.text.ParseException; //导入方法依赖的package包/类
private void setParseError(String reason, Exception e) throws ParseException {
ParseException newExc = makeParseException(reason + ": " + e.getMessage());
newExc.initCause(e);
throw newExc;
}