本文整理汇总了Java中org.apache.regexp.RESyntaxException类的典型用法代码示例。如果您正苦于以下问题:Java RESyntaxException类的具体用法?Java RESyntaxException怎么用?Java RESyntaxException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RESyntaxException类属于org.apache.regexp包,在下文中一共展示了RESyntaxException类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: regexp
import org.apache.regexp.RESyntaxException; //导入依赖的package包/类
public static RBTerm regexp(final String re)
{
try
{
new RBJavaObjectCompoundTerm(new RE(re)
{
private static final long serialVersionUID = 1L;
public String toString()
{
return "/" + re + "/";
}
});
}
catch (RESyntaxException localRESyntaxException)
{
throw new Error("Regular expression syntax error");
}
}
示例2: stripWhiteSpace
import org.apache.regexp.RESyntaxException; //导入依赖的package包/类
private String stripWhiteSpace(String comment) {
StringBuffer buffer = new StringBuffer(comment);
try {
RE whiteSpaceRE = new RE("[:space:]");
for (int i = 0; i < buffer.length(); i++) {
int start = i;
int end = start + 1;
boolean foundWhiteSpace = false;
while (end < buffer.length() && whiteSpaceRE.match(buffer.substring(end - 1, end))) {
foundWhiteSpace = true;
end++;
}
if (foundWhiteSpace) {
buffer.replace(start, end - 1, " ");
}
}
} catch (RESyntaxException e) {
return comment;
}
return buffer.toString();
}
示例3: precalculate
import org.apache.regexp.RESyntaxException; //导入依赖的package包/类
/**
* Return an array of regular expression objects initialized from the
* specified argument, which must be <code>null</code> or a comma-delimited
* list of regular expression patterns.
*
* @param list The comma-separated list of patterns
*
* @exception IllegalArgumentException if one of the patterns has
* invalid syntax
*/
protected RE[] precalculate(String list) {
if (list == null)
return (new RE[0]);
list = list.trim();
if (list.length() < 1)
return (new RE[0]);
list += ",";
ArrayList reList = new ArrayList();
while (list.length() > 0) {
int comma = list.indexOf(',');
if (comma < 0)
break;
String pattern = list.substring(0, comma).trim();
try {
reList.add(new RE(pattern));
} catch (RESyntaxException e) {
throw new IllegalArgumentException
(sm.getString("requestFilterValve.syntax", pattern));
}
list = list.substring(comma + 1);
}
RE reArray[] = new RE[reList.size()];
return ((RE[]) reList.toArray(reArray));
}
示例4: getCompiledPattern
import org.apache.regexp.RESyntaxException; //导入依赖的package包/类
/**
* Compile the pattern.
*
* @param options the ant regexp options
* @return a compiled pattern
* @exception BuildException if an error occurs
*/
protected RE getCompiledPattern(int options)
throws BuildException {
int cOptions = getCompilerOptions(options);
try {
RE reg = new RE(pattern);
reg.setMatchFlags(cOptions);
return reg;
} catch (RESyntaxException e) {
throw new BuildException(e);
}
}
示例5: initExpandRe
import org.apache.regexp.RESyntaxException; //导入依赖的package包/类
/**
* Initializes the expansion regular expression. The exception is going to
* be thrown away if the RE can't be compiled, thus the compilation should
* be tested prior to runtime.
*/
protected void initExpandRe() {
try {
m_expandRE = new RE(NOTIFD_EXPANSION_PARM);
} catch (RESyntaxException e) {
// this shouldn't throw an exception, should be tested prior to
// runtime
log().error("failed to compile RE " + NOTIFD_EXPANSION_PARM, e);
// FIXME: wrap this in runtime exception since SOMETIMES we are using
// an incorrect version of regexp pulled from xalan that is doesn't
// extend RuntimeException only Exception. We really need to fix that.
// See Bug# 1736 in Bugzilla.
throw new RuntimeException(e);
}
}
示例6: canBlockBeSelected
import org.apache.regexp.RESyntaxException; //导入依赖的package包/类
public boolean canBlockBeSelected(Block block) {
if ((!bMultilineMerge) || (!bAccumulating)) {
return super.canBlockBeSelected(block);
}
else {
Rectangle selectionScreenZone = getSelectionScreenZone();
int selectionAttribute = getSelectionAttribute();
String selectionType = getSelectionType();
if ((selectionScreenZone.y != -1) && (block.line < selectionScreenZone.y)) {
Engine.logBeans.trace("Block not selected because of wrong selection screen zone (line out of range)");
return false;
}
if ((selectionScreenZone.x != -1) && (block.column < selectionScreenZone.x)) {
Engine.logBeans.trace("Block not selected because of wrong selection screen zone (column out of range)");
return false;
}
if ((selectionScreenZone.height != -1) && (block.line >= (selectionScreenZone.y + selectionScreenZone.height))) {
Engine.logBeans.trace("Block not selected because of wrong selection screen zone (height out of range)");
return false;
}
if (selectionAttribute != -1) {
boolean b1 = ((selectionAttribute & DONT_CARE_FOREGROUND_ATTRIBUTE) != 0 ? true : (block.attribute & Javelin.AT_INK) == (selectionAttribute & Javelin.AT_INK));
boolean b2 = ((selectionAttribute & DONT_CARE_BACKGROUND_ATTRIBUTE) != 0 ? true : (block.attribute & Javelin.AT_PAPER) == (selectionAttribute & Javelin.AT_PAPER));
boolean b3 = ((selectionAttribute & DONT_CARE_INTENSE_ATTRIBUTE) != 0 ? true : (block.attribute & Javelin.AT_BOLD) == (selectionAttribute & Javelin.AT_BOLD));
boolean b4 = ((selectionAttribute & DONT_CARE_UNDERLINED_ATTRIBUTE) != 0 ? true : (block.attribute & Javelin.AT_UNDERLINE) == (selectionAttribute & Javelin.AT_UNDERLINE));
boolean b5 = ((selectionAttribute & DONT_CARE_REVERSE_ATTRIBUTE) != 0 ? true : (block.attribute & Javelin.AT_INVERT) == (selectionAttribute & Javelin.AT_INVERT));
boolean b6 = ((selectionAttribute & DONT_CARE_BLINK_ATTRIBUTE) != 0 ? true : (block.attribute & Javelin.AT_BLINK) == (selectionAttribute & Javelin.AT_BLINK));
if (!(b1 && b2 && b3 && b4 && b5 && b6)) {
Engine.logBeans.trace("Block not selected because of wrong attributes\n" +
"AT_PAPER=" + b1 + "\n" +
"AT_INK=" + b2 + "\n" +
"AT_BOLD=" + b3 + "\n" +
"AT_INVERT=" + b4 + "\n" +
"AT_UNDERLINE=" + b5 + "\n" +
"AT_BLINK=" + b6 + "\n"
);
return false;
}
}
try {
RE regexp = new RE(selectionType);
if (!regexp.match(block.type)) return false;
}
catch(RESyntaxException e) {
Engine.logBeans.error("Unable to execute the regular expression for the selection of the block", e);
}
return true;
}
}
示例7: execute
import org.apache.regexp.RESyntaxException; //导入依赖的package包/类
/**
* Applies the extraction rule to the current iJavelin object.
*
* @param javelin the Javelin object.
* @param block the current block to analyze.
* @param blockFactory the block context of the current block.
* @param dom the XML DOM.
*
* @return an ExtractionRuleResult object containing the result of
* the query.
*/
protected JavelinExtractionRuleResult execute(iJavelin javelin, Block block, BlockFactory blockFactory, org.w3c.dom.Document dom) {
JavelinExtractionRuleResult xrs = new JavelinExtractionRuleResult();
Block curBlock;
Block tempBlock;
int blockLen;
xrs.hasMatched = false;
// If the object has just been deserialized, we must
// recreate the regular expression object.
if (regexp == null) {
try {
Engine.logBeans.debug("Setting regular expression to : " + regularExpression);
setRegularExpression(regularExpression);
}
catch (RESyntaxException e) {
Engine.logBeans.error("Unable to create the regular expression object", e);
}
}
curBlock = block;
do {
tempBlock = blockFactory.getNextBlock(curBlock);
if (canBlockBeSelected(curBlock)) {
if ((blockTag.length() == 0) || blockTag.equalsIgnoreCase(curBlock.tagName)) {
blockLen = curBlock.getText().trim().length();
if ((length == -1) || (blockLen == length)) {
// Avoid to try to match on empty strings
if (blockLen != 0 ) {
if (regexp.match(curBlock.getText())) {
blockFactory.removeBlock(curBlock);
xrs.hasMatched = true;
}
}
else {
blockFactory.removeBlock(curBlock);
xrs.hasMatched = true;
}
}
}
}
if (tempBlock == null)
break;
curBlock = tempBlock;
} while (true);
xrs.newCurrentBlock = curBlock;
return xrs;
}
示例8: setRegularExpression
import org.apache.regexp.RESyntaxException; //导入依赖的package包/类
/** Setter for property regularExpression.
* @param regularExpression New value of property regularExpression.
*/
public void setRegularExpression(String regularExpression) throws RESyntaxException {
regexp = new RE(regularExpression);
this.regularExpression = regularExpression;
}
示例9: setBorType
import org.apache.regexp.RESyntaxException; //导入依赖的package包/类
/** Setter for property borType.
* @param borType New value of property borType.
*/
public void setBorType(String borType) throws RESyntaxException {
borRE = new RE(borType);
this.borType = borType;
}
示例10: setEorType
import org.apache.regexp.RESyntaxException; //导入依赖的package包/类
/** Setter for property eorType.
* @param eorType New value of property eorType.
*/
public void setEorType(String eorType) throws RESyntaxException {
eorRE = new RE(eorType);
this.eorType = eorType;
}
示例11: FilesFilter
import org.apache.regexp.RESyntaxException; //导入依赖的package包/类
public FilesFilter()
throws RESyntaxException
{
setFiles("^$");
}
示例12: setFiles
import org.apache.regexp.RESyntaxException; //导入依赖的package包/类
public void setFiles(String aFilesPattern)
throws RESyntaxException
{
mFileRegexp = Utils.getRE(aFilesPattern);
}