本文整理汇总了Java中org.apache.oro.text.perl.Perl5Util类的典型用法代码示例。如果您正苦于以下问题:Java Perl5Util类的具体用法?Java Perl5Util怎么用?Java Perl5Util使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Perl5Util类属于org.apache.oro.text.perl包,在下文中一共展示了Perl5Util类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isValidPort
import org.apache.oro.text.perl.Perl5Util; //导入依赖的package包/类
private boolean isValidPort(String port) {
if (port != null) {
Perl5Util portMatcher = new Perl5Util();
if (!portMatcher.match("/^:(\\d{1,5})$/", port))
return false;
}
return true;
}
示例2: isValidAuthorityHostNoDot
import org.apache.oro.text.perl.Perl5Util; //导入依赖的package包/类
/**
* Check if the authority contains a valid hostname without "."
* characters and an optional port number
*
* @param authority
* @return <code>true</code> if the authority is valid
*/
private boolean isValidAuthorityHostNoDot(String authority) {
Perl5Util authorityMatcher = new Perl5Util();
if (authority != null
&& authorityMatcher.match(
"/^([a-zA-Z\\d\\-\\.]*)(:\\d*)?(.*)?/", authority)) {
String hostIP = authorityMatcher.group(1);
if (hostIP.indexOf('.') < 0) {
// the hostname contains no dot, add domain validation to check invalid hostname like "g08fnstd110825-"
DomainValidator domainValidator = DomainValidator.getInstance(true);
if(!domainValidator.isValid(hostIP)) {
return false;
}
String port = authorityMatcher.group(2);
if (!isValidPort(port)) {
return false;
}
String extra = authorityMatcher.group(3);
return GenericValidator.isBlankOrNull(extra);
} else {
return false;
}
} else {
return false;
}
}
示例3: makeOroPattern
import org.apache.oro.text.perl.Perl5Util; //导入依赖的package包/类
public static Pattern makeOroPattern(String sqlLike) {
Perl5Util perl5Util = new Perl5Util();
try {
sqlLike = perl5Util.substitute("s/([$^.+*?])/\\\\$1/g", sqlLike);
sqlLike = perl5Util.substitute("s/%/.*/g", sqlLike);
sqlLike = perl5Util.substitute("s/_/./g", sqlLike);
} catch (Throwable t) {
String errMsg = "Error in ORO pattern substitution for SQL like clause [" + sqlLike + "]: " + t.toString();
Debug.logError(t, errMsg, module);
throw new IllegalArgumentException(errMsg);
}
try {
return PatternFactory.createOrGetPerl5CompiledPattern(sqlLike, true);
} catch (MalformedPatternException e) {
Debug.logError(e, module);
}
return null;
}
示例4: setUp
import org.apache.oro.text.perl.Perl5Util; //导入依赖的package包/类
protected void setUp() throws Exception {
super.setUp();
loader = new AggregatingClassfileLoader();
buffer = new StringWriter();
printer = new XMLPrinter(new PrintWriter(buffer), XMLPrinter.DEFAULT_ENCODING, SPECIFIC_DTD_PREFIX);
reader = SAXParserFactory.newInstance().newSAXParser().getXMLReader();
boolean validate = Boolean.getBoolean("DEPENDENCYFINDER_TESTS_VALIDATE");
reader.setFeature("http://xml.org/sax/features/validation", validate);
reader.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", validate);
errorHandler = mock(ErrorHandler.class);
reader.setErrorHandler(errorHandler);
perl = new Perl5Util();
}
示例5: addTextLinks
import org.apache.oro.text.perl.Perl5Util; //导入依赖的package包/类
private void addTextLinks(List<Link> links, TextDocumentDomainObject textDocument, HttpServletRequest request) {
Map<Integer, TextDomainObject> texts = textDocument.getTexts();
for (Map.Entry<Integer, TextDomainObject> entry : texts.entrySet()) {
Integer textIndex = entry.getKey();
TextDomainObject text = entry.getValue();
String textString = text.getText();
Perl5Util perl5Util = new Perl5Util();
PatternMatcherInput patternMatcherInput = new PatternMatcherInput(textString);
while (matchesUrl(perl5Util, patternMatcherInput)) {
String url = perl5Util.group(1);
if (null == url) {
url = perl5Util.group(0);
}
Link link = new TextLink(textDocument, textIndex, url, request);
links.add(link);
}
}
}
示例6: splitMailBody
import org.apache.oro.text.perl.Perl5Util; //导入依赖的package包/类
public String splitMailBody(String rawBody)
{
try
{
if (StringUtils.isNotEmpty(getSplitRegex()))
{
Perl5Util perl5Util = new Perl5Util();
List parts = new ArrayList();
perl5Util.split(parts, getSplitRegex(), rawBody);
if (parts.size() > 1)
{
StringBuffer comment = new StringBuffer("\n");
comment.append(((String) parts.get(0)).trim());
comment.append("\n\n");
return comment.toString();
}
}
}
catch (Exception e)
{
log.warn("Failed to split email body. Appending raw content...", e);
}
return rawBody;
}
示例7: isValidAuthorityHostNoTld
import org.apache.oro.text.perl.Perl5Util; //导入依赖的package包/类
/**
* Check if the authority contains a hostname without top level domain
* and an optional port number
*
* @param authority
* @return <code>true</code> if the authority is valid
*/
private boolean isValidAuthorityHostNoTld(String authority) {
Perl5Util authorityMatcher = new Perl5Util();
if (authority != null
&& authorityMatcher.match(
"/^([a-zA-Z\\d\\-\\.]*)(:\\d*)?(.*)?/", authority)) {
String host = authorityMatcher.group(1);
if (host.indexOf('.') > 0) {
DomainValidator domainValidator = DomainValidator.getInstance();
// Make the host have a valid TLD, so that the "no TLD" host can pass the domain validation.
String patchedHost = host + ".com";
if(!domainValidator.isValid(patchedHost)) {
return false;
}
String port = authorityMatcher.group(2);
if (!isValidPort(port)) {
return false;
}
String extra = authorityMatcher.group(3);
return GenericValidator.isBlankOrNull(extra);
} else {
return false;
}
} else {
return false;
}
}
示例8: setUp
import org.apache.oro.text.perl.Perl5Util; //导入依赖的package包/类
protected void setUp() throws Exception {
super.setUp();
staxDriver = getStaxDriver();
staxDriver.setRepairingNamespace(false);
buffer = new StringWriter();
writer = staxDriver.createWriter(buffer);
perlUtil = new Perl5Util();
testInput = new X();
testInput.anInt = 9;
testInput.aStr = "zzz";
testInput.innerObj = new Y();
testInput.innerObj.yField = "ooo";
}
示例9: convertTemplate
import org.apache.oro.text.perl.Perl5Util; //导入依赖的package包/类
/**
* Apply find/replace regexes to our WM template
*/
public String convertTemplate(String template)
{
String contents = StringUtils.fileContentsToString(template);
// Overcome Velocity 0.71 limitation.
// HELP: Is this still necessary?
if (!contents.endsWith("\n"))
{
contents += "\n";
}
// Convert most markup.
Perl5Util perl = new Perl5Util();
for (int i = 0; i < perLineREs.length; i += 2)
{
contents = perl.substitute(makeSubstRE(i), contents);
}
// Convert closing curlies.
if (perl.match("m/javascript/i", contents))
{
// ASSUMPTION: JavaScript is indented, WM is not.
contents = perl.substitute("s/\n}/\n#end/g", contents);
}
else
{
contents = perl.substitute("s/(\n\\s*)}/$1#end/g", contents);
contents = perl.substitute("s/#end\\s*\n\\s*#else/#else/g",
contents);
}
return contents;
}
示例10: accept
import org.apache.oro.text.perl.Perl5Util; //导入依赖的package包/类
public boolean accept(File file) {
String filename = file.getName();
Perl5Util perl5Util = new Perl5Util();
if (perl5Util.match("/(?:(\\d+)(?:_(\\d+))?)(?:_se|\\.(.*))?/", filename)) {
String idStr = perl5Util.group(1);
String variantName = FileUtility.unescapeFilename(StringUtils.defaultString(perl5Util.group(3)));
String docVersionNo = perl5Util.group(2);
return accept(file,
Integer.parseInt(idStr),
docVersionNo == null ? 0 : Integer.parseInt(docVersionNo),
variantName);
}
return false;
}
示例11: matchesUrl
import org.apache.oro.text.perl.Perl5Util; //导入依赖的package包/类
boolean matchesUrl(Perl5Util perl5Util,
PatternMatcherInput patternMatcherInput) {
String urlWithoutSchemePattern = "[^\\s\"'()]+";
return perl5Util.match("m,\\bhttp://" + urlWithoutSchemePattern + "|\\bhref=[\"']?("
+ urlWithoutSchemePattern
+ "),i", patternMatcherInput);
}
示例12: getUrl
import org.apache.oro.text.perl.Perl5Util; //导入依赖的package包/类
public String getUrl() {
Perl5Util regexp = new Perl5Util();
if (!regexp.match("m!^\\w+:|^[/.]!", url)) {
String scheme = "http";
if (url.toLowerCase().startsWith("ftp.")) {
scheme = "ftp";
}
return scheme + "://" + url;
}
return url;
}
示例13: search
import org.apache.oro.text.perl.Perl5Util; //导入依赖的package包/类
/**
* return an HashMap of type <code>TfcTairObject</code>s
*/
public HashMap search(DBconnection conn) throws SQLException {
if ( search_from.equals ("symbol") ){
searchGeneSymbolTable(conn);
searchGeneTable (conn);
if ( searchResults.size() > 0 ){
next_page = "/jsp/processor/genesymbol/symbol_exists.jsp" ;
} else {
next_page = "/jsp/processor/genesymbol/symbol_registration.jsp" ;
}
}else if ( search_from.equals ("locus") ){
Vector locus_names = new Vector();
Perl5Util util = new Perl5Util();
locus_names = util.split ("/;/", search_terms);
ArrayList loci = new ArrayList ();
for (int i = 0; i< locus_names.size(); i++){
search_term = ((String)locus_names.get(i)).toUpperCase();
searchLocusTable (conn, loci) ;
}
if (loci.size()>0){
searchResults.put("locus",loci );
}
next_page = "/jsp/processor/genesymbol/select_loci.jsp" ;
}
return ( !searchResults.isEmpty() ) ? searchResults : null ;
}
示例14: removeTags
import org.apache.oro.text.perl.Perl5Util; //导入依赖的package包/类
public static String removeTags(String html) {
Perl5Util perl5util = new Perl5Util();
return perl5util.substitute("s!<.+?>!!g", html);
}
示例15: substitute
import org.apache.oro.text.perl.Perl5Util; //导入依赖的package包/类
/**
* Method that performs a regular expression substitution function.
* @param originalString the string that this method will operate on
* @param regularExpression the s/// substitution regular expression
* operation to perform on orignalString
* @return the result of performing the s/// operation on originalString
*/
private String substitute(String originalString,
String regularExpression) {
Perl5Util perlUtil = new Perl5Util();
String result = perlUtil.substitute(regularExpression, originalString);
return result;
}