@Override public List<Pair<String, Props>> handle(final ResultSet rs) throws SQLException { if (!rs.next()) { return Collections.emptyList(); } final List<Pair<String, Props>> properties = new ArrayList<>(); do { final String name = rs.getString(3); final int eventType = rs.getInt(5); final byte[] dataBytes = rs.getBytes(6); final EncodingType encType = EncodingType.fromInteger(eventType); String propertyString = null; try { if (encType == EncodingType.GZIP) { // Decompress the sucker. propertyString = GZIPUtils.unGzipString(dataBytes, "UTF-8"); } else { propertyString = new String(dataBytes, "UTF-8"); } final Props props = PropsUtils.fromJSONString(propertyString); props.setSource(name); properties.add(new Pair<>(name, props)); } catch (final IOException e) { throw new SQLException(e); } } while (rs.next()); return properties; } }
SessionCache freshSessionCache() throws Exception { final Props props = PropsUtils.fromJSONString(propsString); return new SessionCache(props); }
@Override public List<Pair<String, Props>> handle(final ResultSet rs) throws SQLException { if (!rs.next()) { return Collections.emptyList(); } final List<Pair<String, Props>> properties = new ArrayList<>(); do { final String name = rs.getString(3); final int eventType = rs.getInt(5); final byte[] dataBytes = rs.getBytes(6); final EncodingType encType = EncodingType.fromInteger(eventType); String propertyString = null; try { if (encType == EncodingType.GZIP) { // Decompress the sucker. propertyString = GZIPUtils.unGzipString(dataBytes, "UTF-8"); } else { propertyString = new String(dataBytes, "UTF-8"); } final Props props = PropsUtils.fromJSONString(propertyString); props.setSource(name); properties.add(new Pair<>(name, props)); } catch (final IOException e) { throw new SQLException(e); } } while (rs.next()); return properties; } }
Props props = PropsUtils.fromJSONString(propertyString); props.setSource(name); properties.add(new Pair<String, Props>(name, props));