@Test(expectedExceptions = CacheException.class) public void testStringToKeyWithInvalidTransformer() { keyTransformationHandler.stringToKey("T:org.infinispan.InexistentTransformer:key1"); }
public Object stringToKey(String s) { char type = s.charAt(0); switch (type) { case 'S': return s.substring(2); case 'I': return Integer.valueOf(s.substring(2)); case 'Y': return Byte.valueOf(s.substring(2)); case 'L': return Long.valueOf(s.substring(2)); case 'X': return Short.valueOf(s.substring(2)); case 'D': return Double.valueOf(s.substring(2)); case 'F': return Float.valueOf(s.substring(2)); case 'B': return Boolean.valueOf(s.substring(2)); case 'C': return Character.valueOf(s.charAt(2)); case 'U': return UUID.fromString(s.substring(2)); case 'A': return Base64.getDecoder().decode(s.substring(2)); case 'T': int indexOfSecondDelimiter = s.indexOf(':', 2); String keyClassName = s.substring(2, indexOfSecondDelimiter); String keyAsString = s.substring(indexOfSecondDelimiter + 1); Transformer t = getTransformer(keyClassName); if (t != null) { return t.fromString(keyAsString); } else { throw CONTAINER.noTransformerForKey(keyClassName); } } throw new CacheException("Unknown key type metadata: " + type); }
KeyTransformationHandler { public Object stringToKey(String s) { char type = s.charAt(0); switch (type) { case 'S': return s.substring(2); case 'I': return Integer.valueOf(s.substring(2)); case 'Y': return Byte.valueOf(s.substring(2)); case 'L': return Long.valueOf(s.substring(2)); case 'X': return Short.valueOf(s.substring(2)); case 'D': return Double.valueOf(s.substring(2)); case 'F': return Float.valueOf(s.substring(2)); case 'B': return Boolean.valueOf(s.substring(2)); case 'C': return Character.valueOf(s.charAt(2)); case 'U': return UUID.fromString(s.substring(2)); case 'A': return Base64.getDecoder().decode(s.substring(2)); case 'T': int indexOfSecondDelimiter = s.indexOf(':', 2); String keyClassName = s.substring(2, indexOfSecondDelimiter); String keyAsString = s.substring(indexOfSecondDelimiter + 1); Transformer t = getTransformer(keyClassName); if (t != null) { return t.fromString(keyAsString); } else { throw CONTAINER.noTransformerForKey(keyClassName); } } throw new CacheException("Unknown key type metadata: " + type); } }
KeyTransformationHandler { public Object stringToKey(String s) { char type = s.charAt(0); switch (type) { case 'S': return s.substring(2); case 'I': return Integer.valueOf(s.substring(2)); case 'Y': return Byte.valueOf(s.substring(2)); case 'L': return Long.valueOf(s.substring(2)); case 'X': return Short.valueOf(s.substring(2)); case 'D': return Double.valueOf(s.substring(2)); case 'F': return Float.valueOf(s.substring(2)); case 'B': return Boolean.valueOf(s.substring(2)); case 'C': return Character.valueOf(s.charAt(2)); case 'U': return UUID.fromString(s.substring(2)); case 'A': return Base64.getDecoder().decode(s.substring(2)); case 'T': int indexOfSecondDelimiter = s.indexOf(':', 2); String keyClassName = s.substring(2, indexOfSecondDelimiter); String keyAsString = s.substring(indexOfSecondDelimiter + 1); Transformer t = getTransformer(keyClassName); if (t != null) { return t.fromString(keyAsString); } else { throw CONTAINER.noTransformerForKey(keyClassName); } } throw new CacheException("Unknown key type metadata: " + type); } KeyTransformationHandler(ClassLoader classLoader); }
KeyTransformationHandler { public Object stringToKey(String s) { char type = s.charAt(0); switch (type) { case 'S': return s.substring(2); case 'I': return Integer.valueOf(s.substring(2)); case 'Y': return Byte.valueOf(s.substring(2)); case 'L': return Long.valueOf(s.substring(2)); case 'X': return Short.valueOf(s.substring(2)); case 'D': return Double.valueOf(s.substring(2)); case 'F': return Float.valueOf(s.substring(2)); case 'B': return Boolean.valueOf(s.substring(2)); case 'C': return Character.valueOf(s.charAt(2)); case 'U': return UUID.fromString(s.substring(2)); case 'A': return Base64.getDecoder().decode(s.substring(2)); case 'T': int indexOfSecondDelimiter = s.indexOf(':', 2); String keyClassName = s.substring(2, indexOfSecondDelimiter); String keyAsString = s.substring(indexOfSecondDelimiter + 1); Transformer t = getTransformer(keyClassName); if (t != null) { return t.fromString(keyAsString); } else { throw CONTAINER.noTransformerForKey(keyClassName); } } throw new CacheException("Unknown key type metadata: " + type); } KeyTransformationHandler(ClassLoader classLoader); Object stringToKey(String s); String keyToString(Object key); void registerTransformer(Class<?> keyClass, Class<? extends Transformer> transformerClass); }
KeyTransformationHandler { public Object stringToKey(String s) { char type = s.charAt(0); switch (type) { case 'S': return s.substring(2); case 'I': return Integer.valueOf(s.substring(2)); case 'Y': return Byte.valueOf(s.substring(2)); case 'L': return Long.valueOf(s.substring(2)); case 'X': return Short.valueOf(s.substring(2)); case 'D': return Double.valueOf(s.substring(2)); case 'F': return Float.valueOf(s.substring(2)); case 'B': return Boolean.valueOf(s.substring(2)); case 'C': return Character.valueOf(s.charAt(2)); case 'U': return UUID.fromString(s.substring(2)); case 'A': return Base64.getDecoder().decode(s.substring(2)); case 'T': int indexOfSecondDelimiter = s.indexOf(':', 2); String keyClassName = s.substring(2, indexOfSecondDelimiter); String keyAsString = s.substring(indexOfSecondDelimiter + 1); Transformer t = getTransformer(keyClassName); if (t != null) { return t.fromString(keyAsString); } else { throw CONTAINER.noTransformerForKey(keyClassName); } } throw new CacheException("Unknown key type metadata: " + type); } KeyTransformationHandler(ClassLoader classLoader); Object stringToKey(String s); String keyToString(Object key); void registerTransformer(Class<?> keyClass, Class<? extends Transformer> transformerClass);  }