本文整理汇总了Java中org.apache.oro.text.regex.MalformedPatternException类的典型用法代码示例。如果您正苦于以下问题:Java MalformedPatternException类的具体用法?Java MalformedPatternException怎么用?Java MalformedPatternException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MalformedPatternException类属于org.apache.oro.text.regex包,在下文中一共展示了MalformedPatternException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: SSHShell
import org.apache.oro.text.regex.MalformedPatternException; //导入依赖的package包/类
/**
* Creates SSHShell.
*
* @param host the host name
* @param port the ssh port
* @param userName the ssh user name
* @param sshPrivateKey the ssh password
* @return the shell
* @throws JSchException
* @throws IOException
*/
private SSHShell(String host, int port, String userName, byte[] sshPrivateKey)
throws JSchException, IOException {
Closure expectClosure = getExpectClosure();
for (String linuxPromptPattern : new String[]{"\\>", "#", "~#", "~\\$"}) {
try {
Match match = new RegExpMatch(linuxPromptPattern, expectClosure);
linuxPromptMatches.add(match);
} catch (MalformedPatternException malformedEx) {
throw new RuntimeException(malformedEx);
}
}
JSch jsch = new JSch();
jsch.setKnownHosts(System.getProperty("user.home") + "/.ssh/known_hosts");
jsch.addIdentity(host, sshPrivateKey, (byte[]) null, (byte[]) null);
this.session = jsch.getSession(userName, host, port);
this.session.setConfig("StrictHostKeyChecking", "no");
this.session.setConfig("PreferredAuthentications", "publickey,keyboard-interactive,password");
session.connect(60000);
this.channel = (ChannelShell) session.openChannel("shell");
this.expect = new Expect4j(channel.getInputStream(), channel.getOutputStream());
channel.connect();
}
开发者ID:Azure-Samples,项目名称:acr-java-manage-azure-container-registry,代码行数:34,代码来源:SSHShell.java
示例2: SshShell
import org.apache.oro.text.regex.MalformedPatternException; //导入依赖的package包/类
/**
* Creates SSHShell.
*
* @param host the host name
* @param port the ssh port
* @param userName the ssh user name
* @param password the ssh password
* @return the shell
* @throws JSchException
* @throws IOException
*/
private SshShell(String host, int port, String userName, String password)
throws JSchException, IOException {
Closure expectClosure = getExpectClosure();
for (String linuxPromptPattern : new String[]{"\\>","#", "~#", "~\\$"}) {
try {
Match match = new RegExpMatch(linuxPromptPattern, expectClosure);
linuxPromptMatches.add(match);
} catch (MalformedPatternException malformedEx) {
throw new RuntimeException(malformedEx);
}
}
JSch jsch = new JSch();
this.session = jsch.getSession(userName, host, port);
session.setPassword(password);
Hashtable<String,String> config = new Hashtable<>();
config.put("StrictHostKeyChecking", "no");
session.setConfig(config);
session.connect(60000);
this.channel = (ChannelShell) session.openChannel("shell");
this.expect = new Expect4j(channel.getInputStream(), channel.getOutputStream());
channel.connect();
}
开发者ID:Azure,项目名称:azure-libraries-for-java,代码行数:34,代码来源:SshShell.java
示例3: SSHShell
import org.apache.oro.text.regex.MalformedPatternException; //导入依赖的package包/类
/**
* Creates SSHShell.
*
* @param host the host name
* @param port the ssh port
* @param userName the ssh user name
* @param password the ssh password
* @return the shell
* @throws JSchException
* @throws IOException
*/
private SSHShell(String host, int port, String userName, String password)
throws JSchException, IOException {
Closure expectClosure = getExpectClosure();
for (String linuxPromptPattern : new String[]{"\\>", "#", "~#", "~\\$"}) {
try {
Match match = new RegExpMatch(linuxPromptPattern, expectClosure);
linuxPromptMatches.add(match);
} catch (MalformedPatternException malformedEx) {
throw new RuntimeException(malformedEx);
}
}
JSch jsch = new JSch();
this.session = jsch.getSession(userName, host, port);
session.setPassword(password);
Hashtable<String, String> config = new Hashtable<>();
config.put("StrictHostKeyChecking", "no");
session.setConfig(config);
session.connect(60000);
this.channel = (ChannelShell) session.openChannel("shell");
this.expect = new Expect4j(channel.getInputStream(), channel.getOutputStream());
channel.connect();
}
开发者ID:Azure,项目名称:azure-libraries-for-java,代码行数:34,代码来源:SSHShell.java
示例4: convertStringToPattern
import org.apache.oro.text.regex.MalformedPatternException; //导入依赖的package包/类
/**
* 把字符串转成Pattern和UrlType
*
* @param perl5RegExp
* @return
*/
private URLPatternHolder convertStringToPattern(String line) {
URLPatternHolder holder = new URLPatternHolder();
Pattern compiledPattern;
Perl5Compiler compiler = new Perl5Compiler();
String perl5RegExp = line;
try {
compiledPattern = compiler.compile(perl5RegExp, Perl5Compiler.READ_ONLY_MASK);
holder.setCompiledPattern(compiledPattern);
} catch (MalformedPatternException mpe) {
throw new IllegalArgumentException("Malformed regular expression: " + perl5RegExp);
}
if (logger.isDebugEnabled()) {
logger.debug("Added regular expression: " + compiledPattern.getPattern().toString());
}
return holder;
}
开发者ID:luoyaogui,项目名称:otter-G,代码行数:24,代码来源:URLProtectedEditor.java
示例5: makeOroPattern
import org.apache.oro.text.regex.MalformedPatternException; //导入依赖的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;
}
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:19,代码来源:EntityComparisonOperator.java
示例6: createOrGetPerl5CompiledPattern
import org.apache.oro.text.regex.MalformedPatternException; //导入依赖的package包/类
/**
* Compiles and caches a Perl5 regexp pattern for the given string pattern.
* This would be of no benefits (and may bloat memory usage) if stringPattern is never the same.
* @param stringPattern a Perl5 pattern string
* @param caseSensitive case sensitive true/false
* @return a <code>Pattern</code> instance for the given string pattern
* @throws MalformedPatternException
*/
public static Pattern createOrGetPerl5CompiledPattern(String stringPattern, boolean caseSensitive) throws MalformedPatternException {
Pattern pattern = compiledPerl5Patterns.get(stringPattern);
if (pattern == null) {
Perl5Compiler compiler = new Perl5Compiler();
if (caseSensitive) {
pattern = compiler.compile(stringPattern, Perl5Compiler.READ_ONLY_MASK); // READ_ONLY_MASK guarantees immutability
} else {
pattern = compiler.compile(stringPattern, Perl5Compiler.CASE_INSENSITIVE_MASK | Perl5Compiler.READ_ONLY_MASK);
}
pattern = compiledPerl5Patterns.putIfAbsentAndGet(stringPattern, pattern);
if (Debug.verboseOn()) {
Debug.logVerbose("Compiled and cached the pattern: '" + stringPattern, module);
}
}
return pattern;
}
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:26,代码来源:PatternFactory.java
示例7: WildCardFilter
import org.apache.oro.text.regex.MalformedPatternException; //导入依赖的package包/类
/**
* @param wildcard
* @throws MalformedPatternException
*/
public WildCardFilter(String wildcard,boolean ignoreCase) throws MalformedPatternException {
this.wildcard=wildcard;
this.ignoreCase=ignoreCase;
StringBuffer sb = new StringBuffer(wildcard.length());
int len=wildcard.length();
for(int i=0;i<len;i++) {
char c = wildcard.charAt(i);
if(c == '*')sb.append(".*");
else if(c == '?') sb.append('.');
else if(specials.indexOf(c)!=-1)sb.append('\\').append(c);
else sb.append(c);
}
pattern=new Perl5Compiler().compile(ignoreCase?sb.toString().toLowerCase():sb.toString());
}
开发者ID:lucee,项目名称:extension-mongodb,代码行数:20,代码来源:WildCardFilter.java
示例8: getTaskPattern
import org.apache.oro.text.regex.MalformedPatternException; //导入依赖的package包/类
@Nullable
private Pattern getTaskPattern(String pattern) {
if (!Comparing.strEqual(pattern, myPattern)) {
myCompiledPattern = null;
myPattern = pattern;
}
if (myCompiledPattern == null) {
final String regex = "^.*" + NameUtil.buildRegexp(pattern, 0, true, true);
final Perl5Compiler compiler = new Perl5Compiler();
try {
myCompiledPattern = compiler.compile(regex);
}
catch (MalformedPatternException ignored) {
}
}
return myCompiledPattern;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:ListChooseByNameModel.java
示例9: create
import org.apache.oro.text.regex.MalformedPatternException; //导入依赖的package包/类
@Override
public Regex create(String pattern) {
org.apache.oro.text.regex.Perl5Compiler perl5Compiler = new org.apache.oro.text.regex.Perl5Compiler();
org.apache.oro.text.regex.Perl5Matcher perl5Matcher = new org.apache.oro.text.regex.Perl5Matcher();
org.apache.oro.text.regex.Pattern regexpr;
try {
regexpr = perl5Compiler.compile(pattern);
} catch (MalformedPatternException e) {
throw new IllegalArgumentException(e);
}
return new Regex() {
@Override
public boolean containsMatch(String string) {
return perl5Matcher.matches(string, regexpr);
}
};
}
开发者ID:gpanther,项目名称:regex-libraries-benchmarks,代码行数:19,代码来源:OroRegexFactory.java
示例10: WildCardFilter
import org.apache.oro.text.regex.MalformedPatternException; //导入依赖的package包/类
/**
* @param wildcard
* @throws MalformedPatternException
*/
public WildCardFilter(String wildcard,boolean ignoreCase) throws MalformedPatternException {
this.wildcard=wildcard;
StringBuilder sb = new StringBuilder(wildcard.length());
int len=wildcard.length();
for(int i=0;i<len;i++) {
char c = wildcard.charAt(i);
if(c == '*')sb.append(".*");
else if(c == '?') sb.append('.');
else if(specials.indexOf(c)!=-1)sb.append('\\').append(c);
else sb.append(c);
}
this.ignoreCase=ignoreCase;
pattern=new Perl5Compiler().compile(ignoreCase?StringUtil.toLowerCase(sb.toString()):sb.toString());
}
开发者ID:lucee,项目名称:Lucee4,代码行数:21,代码来源:WildCardFilter.java
示例11: indexOf
import org.apache.oro.text.regex.MalformedPatternException; //导入依赖的package包/类
/**
* return index of the first occurence of the pattern in input text
* @param strPattern pattern to search
* @param strInput text to search pattern
* @param offset
* @param caseSensitive
* @return position of the first occurence
* @throws MalformedPatternException
*/
public static int indexOf(String strPattern, String strInput, int offset, boolean caseSensitive) throws MalformedPatternException {
//Perl5Compiler compiler = new Perl5Compiler();
PatternMatcherInput input = new PatternMatcherInput(strInput);
Perl5Matcher matcher = new Perl5Matcher();
int compileOptions=caseSensitive ? 0 : Perl5Compiler.CASE_INSENSITIVE_MASK;
compileOptions+=Perl5Compiler.SINGLELINE_MASK;
if(offset < 1) offset = 1;
Pattern pattern = getPattern(strPattern,compileOptions);
//Pattern pattern = compiler.compile(strPattern,compileOptions);
if(offset <= strInput.length()) input.setCurrentOffset(offset - 1);
if(offset <= strInput.length() && matcher.contains(input, pattern)) {
return matcher.getMatch().beginOffset(0) + 1;
}
return 0;
}
开发者ID:lucee,项目名称:Lucee4,代码行数:30,代码来源:Perl5Util.java
示例12: get
import org.apache.oro.text.regex.MalformedPatternException; //导入依赖的package包/类
public synchronized List<String> get(String wildcard) throws MalformedPatternException, IOException {
synchronized (data) {
List<String> list=new ArrayList<String>();
Iterator<Entry<String, String>> it = data.entrySet().iterator();
WildCardFilter filter=new WildCardFilter( wildcard);
Entry<String, String> entry;
String value;
while(it.hasNext()) {
entry = it.next();
value= entry.getValue();
if(filter.accept(value)){
list.add(entry.getKey());
it.remove();
}
}
if(list.size()>0)JavaConverter.serialize(data, file);
return list;
}
}
开发者ID:lucee,项目名称:Lucee4,代码行数:20,代码来源:MetaData.java
示例13: WildCardFilter
import org.apache.oro.text.regex.MalformedPatternException; //导入依赖的package包/类
/**
* @param wildcard
* @throws MalformedPatternException
*/
public WildCardFilter(String wildcard,boolean ignoreCase) throws MalformedPatternException {
this.wildcard=wildcard;
this.ignoreCase=ignoreCase;
StringBuilder sb = new StringBuilder(wildcard.length());
int len=wildcard.length();
for(int i=0;i<len;i++) {
char c = wildcard.charAt(i);
if(c == '*')sb.append(".*");
else if(c == '?') sb.append('.');
else if(specials.indexOf(c)!=-1)sb.append('\\').append(c);
else sb.append(c);
}
pattern=new Perl5Compiler().compile(ignoreCase?sb.toString().toLowerCase():sb.toString());
}
开发者ID:lucee,项目名称:Lucee4,代码行数:20,代码来源:WildCardFilter.java
示例14: doRereplace
import org.apache.oro.text.regex.MalformedPatternException; //导入依赖的package包/类
protected String doRereplace( String _theString, String _theRE, String _theSubstr, boolean _casesensitive, boolean _replaceAll ) throws cfmRunTimeException{
int replaceCount = _replaceAll ? Util.SUBSTITUTE_ALL : 1;
PatternMatcher matcher = new Perl5Matcher();
Pattern pattern = null;
PatternCompiler compiler = new Perl5Compiler();
try {
if ( _casesensitive ){
pattern = compiler.compile( _theRE, Perl5Compiler.SINGLELINE_MASK );
}else{
pattern = compiler.compile( _theRE, Perl5Compiler.CASE_INSENSITIVE_MASK | Perl5Compiler.SINGLELINE_MASK );
}
} catch(MalformedPatternException e){ // definitely should happen since regexp is hardcoded
cfCatchData catchD = new cfCatchData();
catchD.setType( "Function" );
catchD.setMessage( "Internal Error" );
catchD.setDetail( "Invalid regular expression ( " + _theRE + " )" );
throw new cfmRunTimeException( catchD );
}
// Perform substitution and print result.
return Util.substitute(matcher, pattern, new Perl5Substitution( processSubstr( _theSubstr ) ), _theString, replaceCount );
}
开发者ID:OpenBD,项目名称:openbd-core,代码行数:25,代码来源:reReplace.java
示例15: convertTemplate
import org.apache.oro.text.regex.MalformedPatternException; //导入依赖的package包/类
/**
* 读入模版并将参数代进去.
*
* @param fileName
* the file name
* @param pattern
* the pattern
* @param values
* the values
* @return the string
* @throws MalformedPatternException
* the malformed pattern exception
*/
public static String convertTemplate(String fileName, String pattern, HashMap values) throws MalformedPatternException {
String record = null;
StringBuffer sb = new StringBuffer();
// int recCount = 0;
try {
FileReader fr = new FileReader(fileName);
BufferedReader br = new BufferedReader(fr);
record = new String();
while ((record = br.readLine()) != null) {
// recCount++;
// System.out.println(recCount + ": " + record);
sb.append(StringUtil.convert(record, pattern, values) + "\n");
}
br.close();
fr.close();
} catch (IOException e) {
System.out.println("oh! no, got an IOException error!");
e.printStackTrace();
}
return sb.toString();
}
开发者ID:8090boy,项目名称:gomall.la,代码行数:35,代码来源:StringConverter.java
示例16: convertTemplate
import org.apache.oro.text.regex.MalformedPatternException; //导入依赖的package包/类
/**
* 读入模版并将参数代进去.
*
* @param fileName
* the file name
* @param pattern
* the pattern
* @param values
* the values
* @return the string
* @throws MalformedPatternException
* the malformed pattern exception
*/
public static String convertTemplate(String fileName, String pattern, Map values) throws MalformedPatternException {
String record = null;
StringBuffer sb = new StringBuffer();
try {
File inFile = new File(fileName);
if (!inFile.exists()) {
return sb.toString();
}
FileInputStream fileInputStream = new FileInputStream(inFile);
BufferedReader inBufferedReader = new BufferedReader(new InputStreamReader(fileInputStream, "UTF-8"));
record = new String();
while ((record = inBufferedReader.readLine()) != null) {
sb.append(StringUtil.convert(record, pattern, values) + "\n");
}
inBufferedReader.close();
fileInputStream.close();
} catch (IOException e) {
System.out.println("got an IOException error!");
e.printStackTrace();
}
return sb.toString();
}
开发者ID:8090boy,项目名称:gomall.la,代码行数:37,代码来源:AppUtils.java
示例17: testNumber
import org.apache.oro.text.regex.MalformedPatternException; //导入依赖的package包/类
/**
* Test number.
*
* @param test
* the test
* @throws MalformedPatternException
* the malformed pattern exception
*/
private void testNumber(DynamicCode test) throws MalformedPatternException {
HashMap<String, Object> map = new HashMap<String, Object>();
map.put("id", "1");
map.put("id1", "2");
map.put("name", "hewq");
map.put("condition", "and moc = 1");
map.put("memo2", "df");
// String pattern = "\\$+[a-zA-Z]+\\$";
String text = " select * from t_scheme where 1==1 \n { and id = $id$ id1 = $id$ } \n { and name = $name$ } \n {$condition$} \n {! default value || and memo1 = $memo1$} \n { and memo2 = $memo2$} \n order by id ";
// String text = " select * from t_scheme where 1==1 { and id = $id$ } {
// and name = $name$ } {! default value || and memo1 = $memo1$}";
// String subString = test.getSubString(text, prefix,"}");
// System.out.println("subString = "+subString);
// String pattern = "\\#[a-zA-Z]+\\#";
String newText = test.convert(text, BLOCK_PATTERN, map);
System.out.println(newText);
}
开发者ID:8090boy,项目名称:gomall.la,代码行数:26,代码来源:DynamicCode.java
示例18: isValidSettings
import org.apache.oro.text.regex.MalformedPatternException; //导入依赖的package包/类
@Override
public List<ErrorData> isValidSettings(Map<Integer, Object> settings) {
List<ErrorData> errorDataList = new ArrayList<ErrorData>();
TTextBoxSettingsBean textBoxSettingsBean = (TTextBoxSettingsBean)settings.get(mapParameterCode);
//textBoxSettingsBean can be null when no settings was set (especially by system fields)
if (textBoxSettingsBean!=null) {
String patternString = textBoxSettingsBean.getDefaultText();
Perl5Compiler pc = new Perl5Compiler();
try {
/*Perl5Pattern pattern=(Perl5Pattern)*/pc.compile(patternString,Perl5Compiler.CASE_INSENSITIVE_MASK |Perl5Compiler.SINGLELINE_MASK);
} catch (MalformedPatternException e) {
LOGGER.error("Malformed Email Domain Pattern " + patternString);
errorDataList.add(new ErrorData("admin.user.profile.err.emailAddress.format"));
}
}
return errorDataList;
}
开发者ID:trackplus,项目名称:Genji,代码行数:18,代码来源:EmaiAddressDT.java
示例19: validateRegEx
import org.apache.oro.text.regex.MalformedPatternException; //导入依赖的package包/类
/**
* Helper method to validate the specified string does not contain anything other than
* that specified by the regular expression
* @param aErrors The errors object to populate
* @param aValue the string to check
* @param aRegEx the Perl based regular expression to check the value against
* @param aErrorCode the error code for getting the i8n failure message
* @param aValues the list of values to replace in the i8n messages
* @param aFailureMessage the default error message
*/
public static void validateRegEx(Errors aErrors, String aValue, String aRegEx, String aErrorCode, Object[] aValues, String aFailureMessage) {
if (aValue != null && aRegEx != null && !aRegEx.equals("") && !aValue.trim().equals("")) {
Perl5Compiler ptrnCompiler = new Perl5Compiler();
Perl5Matcher matcher = new Perl5Matcher();
try {
Perl5Pattern aCharPattern = (Perl5Pattern) ptrnCompiler.compile(aRegEx);
if (!matcher.contains(aValue, aCharPattern)) {
aErrors.reject(aErrorCode, aValues, aFailureMessage);
return;
}
}
catch (MalformedPatternException e) {
LogFactory.getLog(ValidatorUtil.class).fatal("Perl pattern malformed: pattern used was "+aRegEx +" : "+ e.getMessage(), e);
}
}
}
开发者ID:DIA-NZ,项目名称:webcurator,代码行数:28,代码来源:ValidatorUtil.java
示例20: isCreditCard
import org.apache.oro.text.regex.MalformedPatternException; //导入依赖的package包/类
public static boolean isCreditCard( String _cc ) throws MalformedPatternException{
// firstly check the number only contains numerics and separator chars
if ( !validateRE( "[0-9 \\.-]+", _cc ) ){
return false;
}
// now create string with just the digits contained
char[] ccChars = _cc.toCharArray();
StringBuilder numerics = new StringBuilder();
for ( int i = 0; i < ccChars.length; i++ ){
if ( ccChars[i] >= '0' && ccChars[i] <= '9' ){
numerics.append( ccChars[i] );
}
}
return checkLuhn( numerics.toString() );
}
开发者ID:OpenBD,项目名称:openbd-core,代码行数:18,代码来源:cfPARAM.java
注:本文中的org.apache.oro.text.regex.MalformedPatternException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论