当前位置: 首页>>代码示例>>Java>>正文


Java PatternSyntaxException.printStackTrace方法代码示例

本文整理汇总了Java中java.util.regex.PatternSyntaxException.printStackTrace方法的典型用法代码示例。如果您正苦于以下问题:Java PatternSyntaxException.printStackTrace方法的具体用法?Java PatternSyntaxException.printStackTrace怎么用?Java PatternSyntaxException.printStackTrace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.regex.PatternSyntaxException的用法示例。


在下文中一共展示了PatternSyntaxException.printStackTrace方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: toPatterns

import java.util.regex.PatternSyntaxException; //导入方法依赖的package包/类
Pattern[] toPatterns(String[] regexStrings) {
    if (regexStrings == null)
        return new Pattern[0];
    List<Pattern> patterns = new ArrayList<Pattern>();
    for (String pattern : regexStrings) {
        try {
            patterns.add(Pattern.compile(pattern));
        } catch (PatternSyntaxException pse) {
            ByteArrayOutputStream bs = new ByteArrayOutputStream();
            PrintStream ps = new PrintStream(bs);
            try {
                pse.printStackTrace(ps);
                logger.logDebug(String.format("%s: %s", this.getClass()
                        .getName(), bs.toString()));
            } finally {
                ps.close();
            }
        }
    }
    return patterns.toArray(new Pattern[patterns.size()]);
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:22,代码来源:IllegalRequestParameterFilter.java

示例2: getParameters

import java.util.regex.PatternSyntaxException; //导入方法依赖的package包/类
@Override
public List<String> getParameters(String template) {

    List<String> parameters = new ArrayList<>();
    try {
        Pattern regex = Pattern.compile(REGEX);
        Matcher matcher = regex.matcher(template);
        while (matcher.find())
        {
            parameters.add(matcher.group(1));
        }
    }catch (PatternSyntaxException e)
    {
        e.printStackTrace();
    }
    return parameters;
}
 
开发者ID:PestaKit,项目名称:microservice-email,代码行数:18,代码来源:TemplateServiceImp.java

示例3: cmdSplit

import java.util.regex.PatternSyntaxException; //导入方法依赖的package包/类
private void cmdSplit(String cmd){
	
	try {
		cmds = cmd.split("\\n+");
	} catch (PatternSyntaxException e) {
		e.printStackTrace();
	}
	
}
 
开发者ID:ivangundampc,项目名称:SleepOnLan,代码行数:10,代码来源:Commander.java

示例4: shouldThrow

import java.util.regex.PatternSyntaxException; //导入方法依赖的package包/类
private void shouldThrow(String... globs) {
  for (String glob : globs) {
    try {
      GlobPattern.compile(glob);
    }
    catch (PatternSyntaxException e) {
      e.printStackTrace();
      continue;
    }
    assertTrue("glob "+ glob +" should throw", false);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:13,代码来源:TestGlobPattern.java

示例5: wildcardToPattern

import java.util.regex.PatternSyntaxException; //导入方法依赖的package包/类
/**
 * Creates a regular expression pattern that matches a "wildcard" pattern.
 *
 * @param wildcard The wildcard pattern.
 * @param matchCase Whether the pattern should be case sensitive.
 * @param escapeStartChar Whether to escape a starting <code>'^'</code>
 *        character.
 * @return The pattern.
 */
public static Pattern wildcardToPattern(String wildcard, boolean matchCase,
		boolean escapeStartChar) {

	int flags = RSyntaxUtilities.getPatternFlags(matchCase, 0);

	StringBuilder sb = new StringBuilder();
	for (int i=0; i<wildcard.length(); i++) {
		char ch = wildcard.charAt(i);
		switch (ch) {
			case '*':
				sb.append(".*");
				break;
			case '?':
				sb.append('.');
				break;
			case '^':
				if (i>0 || escapeStartChar) {
					sb.append('\\');
				}
				sb.append('^');
				break;
			case '\\':
			case '.': case '|':
			case '+': case '-':
			case '$':
			case '[': case ']':
			case '{': case '}':
			case '(': case ')':
				sb.append('\\').append(ch);
				break;
			default:
				sb.append(ch);
				break;
		}
	}

	Pattern p = null;
	try {
		p = Pattern.compile(sb.toString(), flags);
	} catch (PatternSyntaxException pse) {
		pse.printStackTrace();
		p = Pattern.compile(".+");
	}

	return p;

}
 
开发者ID:Thecarisma,项目名称:powertext,代码行数:57,代码来源:RSyntaxUtilities.java

示例6: listCustomizations

import java.util.regex.PatternSyntaxException; //导入方法依赖的package包/类
/** This method will list the customizations added to a code generated file.
 * @param file the code generated file.
 * @param writer the customizations will be written to this writer.
 * @param customizationFilter the customizations will be filtered based on this paramter. If no value is passed, then all the customizations will be listed.
 * @throws IOException if any IO error occurs.
 * @throws SourceDecomposerException if the file is malformed or if it cannot be decomposed.
 */
public static void listCustomizations(File file, BufferedWriter writer, String customizationFilter)
throws IOException, SourceDecomposerException {
    System.out.println("Processing file... " + file);
    SourceDecomposer sd = new SourceDecomposer(new BufferedReader(new FileReader(file)));
    Collection elements = sd.getCollection();
    boolean headerWritten = false;
    if (elements != null) {
        for (Iterator itr = elements.iterator(); itr.hasNext();) {
            Object obj = itr.next();
            if (obj instanceof SourceDecomposer.GuardedBorder) {
                SourceDecomposer.GuardedBorder gb = (SourceDecomposer.GuardedBorder) obj;
                
                // Check the name of the customization block against the filter
                if (customizationFilter != null && customizationFilter.length() > 0) {
                    try {
                        // Ignore this customization, if it does not match the filter
                        if (!Pattern.matches(customizationFilter, gb.getKey()))
                            continue;
                    } catch (PatternSyntaxException e) {
                        e.printStackTrace();
                        throw new IllegalArgumentException("Invalid customizationFilter passed: " + customizationFilter);
                    }
                }
                
                // Strip the borders from the contents
                StringHelper.Line line = null;
                StringBuffer buf = new StringBuffer();
                PushbackReader reader = new PushbackReader(new StringReader(gb.getContents()));
                while ((line = StringHelper.readLine(reader)) != null) {
                    if (line.getContents().indexOf(SourceDecomposer.FIRST) < 0 && line.getContents().indexOf(SourceDecomposer.LAST) < 0)
                        buf.append(line);
                }
                String contents = buf.toString().trim();
                
                // Only write if the contents are not empty
                if (contents.length() > 0) {
                    if (!headerWritten) {
                        writer.write("===============================================================================\n");
                        writer.write(file.getPath());
                        writer.write("\n===============================================================================\n");
                        headerWritten = true;
                    }
                    writer.write("* " + gb.getKey() + '\n');
                    writer.write(contents);
                    writer.write("\n\n");
                    writer.flush();
                }
            }
        }
    }
}
 
开发者ID:jaffa-projects,项目名称:jaffa-framework,代码行数:59,代码来源:SourceDecomposerUtils.java


注:本文中的java.util.regex.PatternSyntaxException.printStackTrace方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。