Esempio n. 1
0
 public static BlurAnalyzer create(InputStream inputStream) throws IOException {
   TMemoryInputTransport trans = new TMemoryInputTransport(getBytes(inputStream));
   TJSONProtocol protocol = new TJSONProtocol(trans);
   AnalyzerDefinition analyzerDefinition = new AnalyzerDefinition();
   try {
     analyzerDefinition.read(protocol);
   } catch (TException e) {
     throw new RuntimeException(e);
   }
   trans.close();
   return new BlurAnalyzer(analyzerDefinition);
 }
 @SuppressWarnings("unchecked")
 private <T extends TBase<?, ?>> T fromBytes(byte[] data, Class<T> clazz) {
   try {
     if (data == null) {
       return null;
     }
     TBase<?, ?> base = clazz.newInstance();
     TMemoryInputTransport trans = new TMemoryInputTransport(data);
     TJSONProtocol protocol = new TJSONProtocol(trans);
     base.read(protocol);
     trans.close();
     return (T) base;
   } catch (InstantiationException e) {
     throw new RuntimeException(e);
   } catch (IllegalAccessException e) {
     throw new RuntimeException(e);
   } catch (TException e) {
     throw new RuntimeException(e);
   }
 }