Class DFACaptureGroupPartialTransition
- All Implemented Interfaces:
JsonConvertible
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classstatic final class -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final byte[]static final DFACaptureGroupPartialTransition.IndexOperation[]static final DFACaptureGroupPartialTransition.LastGroupUpdate[]static final int -
Method Summary
Modifier and TypeMethodDescriptionvoidapply(TRegexDFAExecutorNode executor, DFACaptureGroupTrackingData d, int currentIndex) voidapply(TRegexDFAExecutorNode executor, DFACaptureGroupTrackingData d, int currentIndex, boolean preFinal, boolean export) voidapplyFinalStateTransition(TRegexDFAExecutorNode executor, DFACaptureGroupTrackingData d, int currentIndex) create(DFAGenerator dfaGen, byte[] reorderSwaps, byte[] arrayCopies, DFACaptureGroupPartialTransition.IndexOperation[] indexUpdates, DFACaptureGroupPartialTransition.IndexOperation[] indexClears, DFACaptureGroupPartialTransition.LastGroupUpdate[] lastGroupUpdates, byte preReorderFinalStateResultIndex) Creates a newDFACaptureGroupPartialTransition.booleanbooleanbyte[]intgetCost()intgetId()byte[]inthashCode()intersect(DFACaptureGroupPartialTransition[] transitions) booleanisEmpty()toJson()toString()
-
Field Details
-
FINAL_STATE_RESULT_INDEX
public static final int FINAL_STATE_RESULT_INDEX- See Also:
-
EMPTY
public static final byte[] EMPTY -
EMPTY_INDEX_OPS
-
EMPTY_LAST_GROUP_UPDATES
-
-
Method Details
-
create
public static DFACaptureGroupPartialTransition create(DFAGenerator dfaGen, byte[] reorderSwaps, byte[] arrayCopies, DFACaptureGroupPartialTransition.IndexOperation[] indexUpdates, DFACaptureGroupPartialTransition.IndexOperation[] indexClears, DFACaptureGroupPartialTransition.LastGroupUpdate[] lastGroupUpdates, byte preReorderFinalStateResultIndex) Creates a newDFACaptureGroupPartialTransition. All numeric values stored in this class refer to indices of the first or second dimension ofDFACaptureGroupTrackingData.resultsand are stored asbyteto save space. This is OK since the dimensions ofDFACaptureGroupTrackingData.resultsare capped byTRegexOptions.TRegexMaxNumberOfNFAStatesInOneDFATransition(1st dimension) andTRegexOptions.TRegexMaxNumberOfCaptureGroupsForDFA* 2(2nd dimension, times two because we need two array slots per capture group, one for the beginning and one for the end).
Although we treatDFACaptureGroupTrackingData.resultsas a 2D-array here, it is actually flattened into one dimension for performance. For that reason, we additionally haveDFACaptureGroupTrackingData.currentResultOrder, which stores the offset of every "row" in the 2D-array. We need to be able to reorder the rows of the 2D-array, and we do that by simply reorderingDFACaptureGroupTrackingData.currentResultOrder.
Example:
IfDFACaptureGroupTrackingData.resultsis a 3x2 array, thenDFACaptureGroupTrackingData.currentResultOrderwill initially contain [0, 2, 4]. If we want to swap the first two rows of the 2D array,DFACaptureGroupTrackingData.currentResultOrderbecomes [2, 0, 4].- Parameters:
reorderSwaps- reorderDFACaptureGroupTrackingData.currentResultOrderusing a sequence of swap operations described in this array. Every two elements in this array denote one swap operation.Example:
IfcurrentResultOrder = DFACaptureGroupTrackingData#currentResultOrderandreorderSwaps = [0, 1, 1, 2], thencurrentResultOrder[0]will be swapped withcurrentResultOrder[1], andcurrentResultOrder[1]will be swapped withcurrentResultOrder[2], in that order.arrayCopies- copy rows ofDFACaptureGroupTrackingData.results(1st dimension) as described in this array. Every two elements in this array denote one copy operation, where the first element is the source, and the second is the target. The copy operations will be applied after the reordering ofDFACaptureGroupTrackingData.currentResultOrderwithreorderSwaps.Example:
Ifresults = DFACaptureGroupTrackingData#resultsandarrayCopies = [0, 1, 2, 3], then the contents ofresults[0]will be copied intoresults[1], and the contents ofresults[2]will be copied intoresults[3].indexUpdates- denotes which index of which array inDFACaptureGroupTrackingData.resultsshall be updated tocurrentIndexinapply(TRegexDFAExecutorNode, DFACaptureGroupTrackingData, int),applyPreFinalStateTransition(TRegexDFAExecutorNode, DFACaptureGroupTrackingData, int, boolean)andapplyFinalStateTransition(TRegexDFAExecutorNode, DFACaptureGroupTrackingData, int). In every row (1st dimension element) of this 2D array, the first value is the index of one row inDFACaptureGroupTrackingData.results, all following values are indices in that row that shall be set tocurrentIndex.Example:
Ifresults = DFACaptureGroupTrackingData#resultsandindexUpdates = [[0, 1, 2], [3, 4]], thenresults[0][1],results[0][2]andresults[3][4]will be set tocurrentIndex.indexClears- denotes which index of which array inDFACaptureGroupTrackingData.resultsshall be updated to0inapply(TRegexDFAExecutorNode, DFACaptureGroupTrackingData, int),applyPreFinalStateTransition(TRegexDFAExecutorNode, DFACaptureGroupTrackingData, int, boolean)andapplyFinalStateTransition(TRegexDFAExecutorNode, DFACaptureGroupTrackingData, int), analogous toindexUpdates.preReorderFinalStateResultIndex- denotes the row (1st dimension element) ofDFACaptureGroupTrackingData.resultsthat corresponds to the NFA final state before the reordering given byreorderSwapsis applied. This is needed inapplyPreFinalStateTransition(TRegexDFAExecutorNode, DFACaptureGroupTrackingData, int, boolean)whenTRegexDFAExecutorNode.isSearching()istrue, because in that case we need to be able to apply copy the current result corresponding to the NFA final state without doing any reordering.- Returns:
- a new
DFACaptureGroupPartialTransition, or a static empty instance if all arguments are empty or zero.
-
intersect
public static DFACaptureGroupPartialTransition intersect(DFACaptureGroupPartialTransition[] transitions) -
subtract
-
getEmptyInstance
-
isEmpty
public boolean isEmpty() -
getId
public int getId() -
doesReorderResults
public boolean doesReorderResults() -
getReorderSwaps
public byte[] getReorderSwaps() -
getArrayCopies
public byte[] getArrayCopies() -
getIndexUpdates
-
getIndexClears
-
getLastGroupUpdates
-
getCost
public int getCost() -
apply
-
apply
public void apply(TRegexDFAExecutorNode executor, DFACaptureGroupTrackingData d, int currentIndex, boolean preFinal, boolean export) -
applyFinalStateTransition
public void applyFinalStateTransition(TRegexDFAExecutorNode executor, DFACaptureGroupTrackingData d, int currentIndex) -
equals
-
hashCode
-
toString
-
toJson
- Specified by:
toJsonin interfaceJsonConvertible
-