public static Source getSource(String sourceLocation, Collection<Source> sources) { return getSource(sourceLocation, sources, true); } }
public static Deserializer loadFromFactory(Class<? extends DeserializerFactory> factory) { return ReflectionUtils.newInstance(factory).newInstance(); } }
public static Source getSource(String sourceLocation, Collection<Source> sources, boolean useCache) { Source source; if (useCache && (source = sourceMap.get(sourceLocation)) != null) { return source; } for (Source s : sources) { if (s.getSourceRegex().matcher(sourceLocation).matches()) { if (useCache) { sourceMap.put(sourceLocation, s); } return s; } } throw new SourceNotFoundException(sourceLocation); }
protected static long getTimestamp(String dvalue, TimeFieldType type) { long ts; switch (type) { case SECONDS: ts = (long) (Double.parseDouble(dvalue) * 1000); break; case MILLISECONDS: ts = (long) (Double.parseDouble(dvalue)); break; default: throw new OperationException("unsupported TimeFieldType"); } /* * Sanity Check */ try { return Time.toMilliseconds(ts); } catch (IllegalArgumentException e) { throw new OperationException(e); } }
public String getValue() { if (this.value == null) { return value; } /* * Ensure that the value is only decrypted once regardless of usage. This prevents KMS from * being called over and over from within the function to decrypt the same field. */ if (!this.decrypted) { try { this.value = Passwords.decrypt(this.value, Region.getRegion(this.region)); } catch (UnsupportedEncodingException e) { throw new ConfigurationException("Unable to decrypt", e); } this.decrypted = true; } return this.value; }
protected static long getTimestamp(String dvalue, TimeFieldType type) { long ts; switch (type) { case SECONDS: ts = (long) (Double.parseDouble(dvalue) * 1000); break; case MILLISECONDS: ts = (long) (Double.parseDouble(dvalue)); break; default: throw new OperationException("unsupported TimeFieldType"); } /* * Sanity Check */ try { return Time.toMilliseconds(ts); } catch (IllegalArgumentException e) { throw new OperationException(e); } }
public static Deserializer loadFromFactory(Class<? extends DeserializerFactory> factory) { return ReflectionUtils.newInstance(factory).newInstance(); } }
public static Source getSource(String sourceLocation, Collection<Source> sources) { return getSource(sourceLocation, sources, true); } }
public String getValue() { if (this.value == null) { return value; } /* * Ensure that the value is only decrypted once regardless of usage. This prevents KMS from * being called over and over from within the function to decrypt the same field. */ if (!this.decrypted) { try { this.value = Passwords.decrypt(this.value, Region.getRegion(this.region)); } catch (UnsupportedEncodingException e) { throw new ConfigurationException("Unable to decrypt", e); } this.decrypted = true; } return this.value; }
@Test public void testFromSeconds() { assertEquals(1484802359000L, Time.toMilliseconds(1484802359L)); }
public void setWrapperFactory(WrapperConfig config) { wrapperFactory = (WrapperFactory) ReflectionUtils.newInstance(config.getFactoryClass()); }
@Test(expected = IllegalArgumentException.class) public void testInvalid() { assertEquals(1484802359000L, Time.toMilliseconds(1484802L)); } }
public SerializerProcessor(Class<? extends SerializerFactory> clazz) { this(ReflectionUtils.newInstance(clazz).newInstance()); }
@Test public void testFromMicroseconds() { assertEquals(1484802359000L, Time.toMilliseconds(1484802359000000L)); }
public SerializerProcessor(Class<? extends SerializerFactory> clazz) { this(ReflectionUtils.newInstance(clazz).newInstance()); }
@Test public void testFromNanoseconds() { assertEquals(1484802359000L, Time.toMilliseconds(1484802359000000000L)); }
public void setWrapperFactory(WrapperConfig config) { wrapperFactory = (WrapperFactory) ReflectionUtils.newInstance(config.getFactoryClass()); }
@Test public void testFromMilliseconds() { assertEquals(1484802359000L, Time.toMilliseconds(1484802359000L)); }
@SuppressWarnings("unchecked") public T getFactory(ConfigurableFactoryConfig<?> factoryConfig) throws ClassNotFoundException { ConfigurableFactory factory = (ConfigurableFactory) ReflectionUtils.newInstance(factoryConfig.getFactoryClass()); factory.setConf(factoryConfig); logger.trace(factory.getClass().getName() + " initialized"); return (T) factory; } }
@SuppressWarnings("unchecked") public T getFactory(ConfigurableFactoryConfig<?> factoryConfig) throws ClassNotFoundException { ConfigurableFactory factory = (ConfigurableFactory) ReflectionUtils.newInstance(factoryConfig.getFactoryClass()); factory.setConf(factoryConfig); logger.trace(factory.getClass().getName() + " initialized"); return (T) factory; } }