本文整理汇总了Java中gnu.inet.encoding.IDNAException类的典型用法代码示例。如果您正苦于以下问题:Java IDNAException类的具体用法?Java IDNAException怎么用?Java IDNAException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IDNAException类属于gnu.inet.encoding包,在下文中一共展示了IDNAException类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fixupDomainlabel
import gnu.inet.encoding.IDNAException; //导入依赖的package包/类
/**
* Fixup the domain label part of the authority.
*
* We're more lax than the spec. in that we allow underscores.
*
* @param label Domain label to fix.
* @return Return fixed domain label.
* @throws URIException
*/
private String fixupDomainlabel(String label)
throws URIException {
// apply IDN-punycoding, as necessary
try {
// TODO optimize: only apply when necessary, or
// keep cache of recent encodings
label = IDNA.toASCII(label);
} catch (IDNAException e) {
if(TextUtils.matches(ACCEPTABLE_ASCII_DOMAIN, label)) {
// domain name has ACE prefix, leading/trailing dash, or
// underscore -- but is still a name we wish to tolerate;
// simply continue
} else {
// problematic domain: neither ASCII acceptable characters
// nor IDN-punycodable, so throw exception
// TODO change to HeritrixURIException so distinguishable
// from URIExceptions in library code
URIException ue = new URIException(e+" "+label);
ue.initCause(e);
throw ue;
}
}
label = label.toLowerCase();
return label;
}
开发者ID:netarchivesuite,项目名称:netarchivesuite-svngit-migration,代码行数:36,代码来源:NetarchiveSuiteUURIFactory.java
示例2: fixupDomainlabel
import gnu.inet.encoding.IDNAException; //导入依赖的package包/类
/**
* Fixup the domain label part of the authority.
*
* We're more lax than the spec. in that we allow underscores.
*
* @param label Domain label to fix.
* @return Return fixed domain label.
* @throws URIException
*/
private String fixupDomainlabel(String label)
throws URIException {
// apply IDN-punycoding, as necessary
try {
// TODO: optimize: only apply when necessary, or
// keep cache of recent encodings
label = IDNA.toASCII(label);
} catch (IDNAException e) {
if(TextUtils.matches(ACCEPTABLE_ASCII_DOMAIN,label)) {
// domain name has ACE prefix, leading/trailing dash, or
// underscore -- but is still a name we wish to tolerate;
// simply continue
} else {
// problematic domain: neither ASCII acceptable characters
// nor IDN-punycodable, so throw exception
// TODO: change to HeritrixURIException so distinguishable
// from URIExceptions in library code
URIException ue = new URIException(e+" "+label);
ue.initCause(e);
throw ue;
}
}
label = label.toLowerCase();
return label;
}