本文整理匯總了Java中java.util.regex.PatternSyntaxException.getMessage方法的典型用法代碼示例。如果您正苦於以下問題:Java PatternSyntaxException.getMessage方法的具體用法?Java PatternSyntaxException.getMessage怎麽用?Java PatternSyntaxException.getMessage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.util.regex.PatternSyntaxException
的用法示例。
在下文中一共展示了PatternSyntaxException.getMessage方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getAttributesArrayFromRegex
import java.util.regex.PatternSyntaxException; //導入方法依賴的package包/類
private Attribute[] getAttributesArrayFromRegex(Attributes attributes, String regex) throws OperatorException {
Pattern pattern = null;
try {
pattern = Pattern.compile(regex);
} catch (PatternSyntaxException e) {
throw new UserError(this, 206, regex, e.getMessage());
}
List<Attribute> attributeList = new LinkedList<>();
Iterator<Attribute> i = attributes.allAttributes();
while (i.hasNext()) {
Attribute attribute = i.next();
Matcher matcher = pattern.matcher(attribute.getName());
if (matcher.matches()) {
attributeList.add(attribute);
}
}
Attribute[] attributesArray = new Attribute[attributeList.size()];
attributesArray = attributeList.toArray(attributesArray);
return attributesArray;
}
示例2: getMatchingAttributes
import java.util.regex.PatternSyntaxException; //導入方法依賴的package包/類
private Attribute[] getMatchingAttributes(Attributes attributes, String regex) throws OperatorException {
Pattern pattern = null;
try {
pattern = Pattern.compile(regex);
} catch (PatternSyntaxException e) {
throw new UserError(this, 206, regex, e.getMessage());
}
List<Attribute> attributeList = new LinkedList<>();
Iterator<Attribute> iterator = attributes.allAttributes();
while (iterator.hasNext()) {
Attribute attribute = iterator.next();
if (pattern.matcher(attribute.getName()).matches()) {
attributeList.add(attribute);
}
}
// building array of attributes for faster access.
Attribute[] attributesArray = new Attribute[attributeList.size()];
attributesArray = attributeList.toArray(attributesArray);
return attributesArray;
}
示例3: setNamePattern
import java.util.regex.PatternSyntaxException; //導入方法依賴的package包/類
/**
* Optionally set a pattern to which all object names must conform
* @param namePattern a regular expression
*/
public void setNamePattern(String namePattern)
{
writeLock.lock();
try
{
this.namePattern = Pattern.compile(namePattern);
}
catch (PatternSyntaxException e)
{
throw new AlfrescoRuntimeException(
"Regular expression compilation failed for property 'namePrefix': " + e.getMessage(),
e);
}
finally
{
writeLock.unlock();
}
}
示例4: apply
import java.util.regex.PatternSyntaxException; //導入方法依賴的package包/類
@Override
public ExampleSet apply(ExampleSet exampleSet) throws OperatorException {
String splittingRegex = getParameterAsString(PARAMETER_SPLIT_PATTERN);
Pattern splittingPattern = null;
try {
splittingPattern = Pattern.compile(splittingRegex);
} catch (PatternSyntaxException e) {
throw new UserError(this, 206, splittingRegex, e.getMessage());
}
int type = getParameterAsInt(PARAMETER_SPLIT_MODE);
// Until version 6.0.3 there was thrown no UserError when attributes were missing.
// Compatibility check to avoid older processes to fail.
boolean errorOnMissing = getCompatibilityLevel().isAtMost(OPERATOR_VERSION_6_0_3) ? false : true;
for (Attribute attribute : attributeSubsetSelector.getAttributeSubset(exampleSet, false, errorOnMissing)) {
if (attribute.isNominal()) {
switch (type) {
case SPLIT_MODE_ORDERED:
orderedSplit(exampleSet, attribute, splittingPattern);
break;
case SPLIT_MODE_UNORDERED:
default:
unorderedSplit(exampleSet, attribute, splittingPattern);
break;
}
}
}
return exampleSet;
}
示例5: validateNewEntry
import java.util.regex.PatternSyntaxException; //導入方法依賴的package包/類
@Override
protected String validateNewEntry(String newEntry) {
try {
//noinspection ResultOfMethodCallIgnored
Pattern.compile(newEntry);
} catch (PatternSyntaxException e) {
return e.getMessage();
}
return null;
}
示例6: init
import java.util.regex.PatternSyntaxException; //導入方法依賴的package包/類
void init(String filePattern, PathFilter filter) throws IOException {
try {
userFilter = filter;
pattern = new GlobPattern(filePattern);
}
catch (PatternSyntaxException e) {
// Existing code expects IOException startWith("Illegal file pattern")
throw new IOException("Illegal file pattern: "+ e.getMessage(), e);
}
}
示例7: getContents
import java.util.regex.PatternSyntaxException; //導入方法依賴的package包/類
public HttpResponseContents getContents() throws HttpException {
try {
String className = getRequest().getParameter(ARGNAME_CLASS_NAME);
String getterMethodName = getRequest().getParameter(ARGNAME_GETTER_METHOD_NAME);
String resultPattern = getRequest().getParameter(ARGNAME_RESULT_PATTERN);
String historySizeStr = getRequest().getParameter(ARGNAME_HISTORY_SIZE);
if (className == null
|| getterMethodName == null
|| resultPattern == null) {
return getSearchFormHtml();
}
int historySize;
try {
historySize = historySizeStr == null || historySizeStr.equals("")
? DumpObjectResponse.DEFAULT_HISTORY_SIZE
: Integer.parseInt(historySizeStr);
} catch (NumberFormatException nfe) {
throw new HttpRequest.RequestException
("invalid number format, " + ARGNAME_HISTORY_SIZE + ": " + historySizeStr);
}
if (historySize < 1) {
throw new HttpRequest.RequestException
("invalid value, " + ARGNAME_HISTORY_SIZE + ": " + historySizeStr);
}
Class<?> targetClass = ClassNameMapper.resolveClass(className);
if (targetClass == null) {
throw new HttpRequest.RequestException("error", "class not found.");
}
Method getterMethod;
try {
getterMethod = targetClass.getMethod(getterMethodName, new Class[0]);
} catch (NoSuchMethodException nsme) {
throw new HttpRequest.RequestException("error", "method not found.");
}
Html result = new Html(UTF8);
result.setTitle(TITLE);
String transactionDescription
= ((TefHttpConnection) getRequest().getConnection())
.getTransactionDescription(getRequest());
TransactionContext.beginReadTransaction(transactionDescription);
ResultLine[] searchResult
= searchObjects(targetClass, getterMethod, resultPattern, historySize);
Arrays.sort(searchResult, new Comparator<ResultLine>() {
public int compare(ResultLine o1, ResultLine o2) {
return o1.methodResultString.compareTo(o2.methodResultString);
}
});
printResult(result, searchResult);
return result;
} catch (PatternSyntaxException pse) {
throw new HttpRequest.RequestException
("error", "pattern syntax error: " + pse.getMessage());
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
TransactionContext.close();
}
}