| 857 | */ |
| 858 | // This is visible for testing. |
| 859 | List<byte[][]> findAllUTF8Submatch(final byte[] b, int n) { |
| 860 | final List<byte[][]> result = new ArrayList<byte[][]>(); |
| 861 | allMatches( |
| 862 | MachineInput.fromUTF8(b), |
| 863 | n, |
| 864 | new DeliverFunc() { |
| 865 | @Override |
| 866 | public void deliver(int[] match) { |
| 867 | byte[][] slice = new byte[match.length / 2][]; |
| 868 | for (int j = 0; j < slice.length; ++j) { |
| 869 | if (match[2 * j] >= 0) { |
| 870 | slice[j] = Utils.subarray(b, match[2 * j], match[2 * j + 1]); |
| 871 | } |
| 872 | } |
| 873 | result.add(slice); |
| 874 | } |
| 875 | }); |
| 876 | if (result.isEmpty()) { |
| 877 | return null; |
| 878 | } |
| 879 | return result; |
| 880 | } |
| 881 | |
| 882 | /** |
| 883 | * {@code findAllUTF8SubmatchIndex} is the <a href='#all'>All</a> version of |