本文整理汇总了Java中com.sun.org.apache.regexp.internal.RE类的典型用法代码示例。如果您正苦于以下问题:Java RE类的具体用法?Java RE怎么用?Java RE使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RE类属于com.sun.org.apache.regexp.internal包,在下文中一共展示了RE类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: nodeInsert
import com.sun.org.apache.regexp.internal.RE; //导入依赖的package包/类
/**
* Inserts a node with a given opcode and opdata at insertAt. The node relative next
* pointer is initialized to 0.
* @param opcode Opcode for new node
* @param opdata Opdata for new node (only the low 16 bits are currently used)
* @param insertAt Index at which to insert the new node in the program
*/
void nodeInsert(char opcode, int opdata, int insertAt)
{
// Make room for a new node
ensure(RE.nodeSize);
// Move everything from insertAt to the end down nodeSize elements
System.arraycopy(instruction, insertAt, instruction, insertAt + RE.nodeSize, lenInstruction - insertAt);
instruction[insertAt + RE.offsetOpcode] = opcode;
instruction[insertAt + RE.offsetOpdata] = (char)opdata;
instruction[insertAt + RE.offsetNext] = 0;
lenInstruction += RE.nodeSize;
}
示例2: setNextOfEnd
import com.sun.org.apache.regexp.internal.RE; //导入依赖的package包/类
/**
* Appends a node to the end of a node chain
* @param node Start of node chain to traverse
* @param pointTo Node to have the tail of the chain point to
*/
void setNextOfEnd(int node, int pointTo)
{
// Traverse the chain until the next offset is 0
int next = instruction[node + RE.offsetNext];
// while the 'node' is not the last in the chain
// and the 'node' is not the last in the program.
while ( next != 0 && node < lenInstruction )
{
// if the node we are supposed to point to is in the chain then
// point to the end of the program instead.
// Michael McCallum <[email protected]>
// FIXME: // This is a _hack_ to stop infinite programs.
// I believe that the implementation of the reluctant matches is wrong but
// have not worked out a better way yet.
if ( node == pointTo ) {
pointTo = lenInstruction;
}
node += next;
next = instruction[node + RE.offsetNext];
}
// if we have reached the end of the program then dont set the pointTo.
// im not sure if this will break any thing but passes all the tests.
if ( node < lenInstruction ) {
// Point the last node in the chain to pointTo.
instruction[node + RE.offsetNext] = (char)(short)(pointTo - node);
}
}
示例3: node
import com.sun.org.apache.regexp.internal.RE; //导入依赖的package包/类
/**
* Adds a new node
* @param opcode Opcode for node
* @param opdata Opdata for node (only the low 16 bits are currently used)
* @return Index of new node in program
*/
int node(char opcode, int opdata)
{
// Make room for a new node
ensure(RE.nodeSize);
// Add new node at end
instruction[lenInstruction + RE.offsetOpcode] = opcode;
instruction[lenInstruction + RE.offsetOpdata] = (char)opdata;
instruction[lenInstruction + RE.offsetNext] = 0;
lenInstruction += RE.nodeSize;
// Return index of new node
return lenInstruction - RE.nodeSize;
}
示例4: compareFields
import com.sun.org.apache.regexp.internal.RE; //导入依赖的package包/类
public static boolean compareFields(final FixMessageType.Field inField1, final FixMessageType.Field inField2) {
if (StringUtils.isBlank(inField1.getValue())) {
return true;
} else if (inField1.isValueRegGxp()) {
return new RE(inField1.getValue()).match(inField2.getValue());
} else {
if (isDouble(inField1.getValue()) || isDouble(inField2.getValue())) {
// compare double value
return compareDouble(inField1.getValue(), inField2.getValue());
} else {
return StringUtils.equals(inField1.getValue(), inField2.getValue());
}
}
}
示例5: compareFiled
import com.sun.org.apache.regexp.internal.RE; //导入依赖的package包/类
protected boolean compareFiled(final FixMessageType.Field f, final FixMessageType.Field modelField) {
if (modelField.isValueRegGxp()) {
return new RE(modelField.getValue()).match(f.getValue());
} else {
return StringUtils.equals(f.getValue(), modelField.getValue());
}
}
示例6: terminal
import com.sun.org.apache.regexp.internal.RE; //导入依赖的package包/类
/**
* Match a terminal node.
* @param flags Flags
* @return Index of terminal node (closeable)
* @exception RESyntaxException Thrown if the regular expression has invalid syntax.
*/
int terminal(int[] flags) throws RESyntaxException
{
switch (pattern.charAt(idx))
{
case RE.OP_EOL:
case RE.OP_BOL:
case RE.OP_ANY:
return node(pattern.charAt(idx++), 0);
case '[':
return characterClass();
case '(':
return expr(flags);
case ')':
syntaxError("Unexpected close paren");
case '|':
internalError();
case ']':
syntaxError("Mismatched class");
case 0:
syntaxError("Unexpected end of input");
case '?':
case '+':
case '{':
case '*':
syntaxError("Missing operand to closure");
case '\\':
{
// Don't forget, escape() advances the input stream!
int idxBeforeEscape = idx;
// Switch on escaped character
switch (escape())
{
case ESC_CLASS:
case ESC_COMPLEX:
flags[0] &= ~NODE_NULLABLE;
return node(RE.OP_ESCAPE, pattern.charAt(idx - 1));
case ESC_BACKREF:
{
char backreference = (char)(pattern.charAt(idx - 1) - '0');
if (parens <= backreference)
{
syntaxError("Bad backreference");
}
flags[0] |= NODE_NULLABLE;
return node(RE.OP_BACKREF, backreference);
}
default:
// We had a simple escape and we want to have it end up in
// an atom, so we back up and fall though to the default handling
idx = idxBeforeEscape;
flags[0] &= ~NODE_NULLABLE;
break;
}
}
}
// Everything above either fails or returns.
// If it wasn't one of the above, it must be the start of an atom.
flags[0] &= ~NODE_NULLABLE;
return atom();
}
示例7: branch
import com.sun.org.apache.regexp.internal.RE; //导入依赖的package包/类
/**
* Compile one branch of an or operator (implements concatenation)
* @param flags Flags passed by reference
* @return Pointer to branch node
* @exception RESyntaxException Thrown if the regular expression has invalid syntax.
*/
int branch(int[] flags) throws RESyntaxException
{
// Get each possibly closured piece and concat
int node;
int ret = node(RE.OP_BRANCH, 0);
int chain = -1;
int[] closureFlags = new int[1];
boolean nullable = true;
while (idx < len && pattern.charAt(idx) != '|' && pattern.charAt(idx) != ')')
{
// Get new node
closureFlags[0] = NODE_NORMAL;
node = closure(closureFlags);
if (closureFlags[0] == NODE_NORMAL)
{
nullable = false;
}
// If there's a chain, append to the end
if (chain != -1)
{
setNextOfEnd(chain, node);
}
// Chain starts at current
chain = node;
}
// If we don't run loop, make a nothing node
if (chain == -1)
{
node(RE.OP_NOTHING, 0);
}
// Set nullable flag for this branch
if (nullable)
{
flags[0] |= NODE_NULLABLE;
}
return ret;
}
示例8: compare
import com.sun.org.apache.regexp.internal.RE; //导入依赖的package包/类
@Override
public boolean compare(String value, String pattern) {
validateNullValues(value, pattern);
return new RE(pattern).match(value);
}