StaticSizeTrieURLPatternMapper extends BaseTrieURLPatternMapper<T> { @Override protected void put(String urlPattern, T value, boolean wildcard) { List<T> values = null; long[][][] trieMatrix = null; if (wildcard) { values = _wildcardValues; trieMatrix = _wildCardTrieMatrix; } else { values = _extensionValues; trieMatrix = _extensionTrieMatrix; } if ((!wildcard && (_extensionURLPatternsCount > 63)) || (wildcard && (_wildcardURLPatternCount > 63))) { throw new IllegalArgumentException( "Exceeding maximum number of allowed URL patterns"); } int index = 0; if (wildcard) { index = _wildcardURLPatternCount++; } else { index = _extensionURLPatternsCount++; } long bitmask = 1L << index; int column = 0; int row = 0; for (; row < urlPattern.length(); ++row) { char character; if (wildcard) { character = urlPattern.charAt(row); } else { character = urlPattern.charAt(urlPattern.length() - 1 - row); } column = character - ASCII_PRINTABLE_OFFSET; trieMatrix[0][row][column] |= bitmask; } trieMatrix[1][row - 1][column] |= bitmask; values.add(value); } StaticSizeTrieURLPatternMapper(Map<String, T> values);   }
@Override @Test public void testConstructor() { super.testConstructor(); try { Map<String, String> map = new HashMap<>(); for (int i = 0; i < 65; i++) { map.put("*.key" + i, "value" + i); } createURLPatternMapper(map); Assert.fail(); } catch (IllegalArgumentException illegalArgumentException) { } try { Map<String, String> map = new HashMap<>(); for (int i = 0; i < (Long.SIZE + 1); i++) { map.put("key" + i, "value" + i); } createURLPatternMapper(map); Assert.fail(); } catch (IllegalArgumentException illegalArgumentException) { } }
@Override @Test public void testGetValue() { super.testGetValue(); Map<String, String> map = new HashMap<>(); for (int i = 0; i < Long.SIZE; i++) { map.put("*.key" + i, "value" + i); } URLPatternMapper<String> urlPatternMapper = createURLPatternMapper(map); for (int i = 0; i < Long.SIZE; i++) { Assert.assertEquals( "value" + i, urlPatternMapper.getValue("*.key" + i)); } }