@Override public void init(SortedKeyValueIterator<Key,Value> source, Map<String,String> options, IteratorEnvironment env) throws IOException { super.init(source, options, env); setEncoder(options); }
@Override public boolean validateOptions(Map<String,String> options) { if (!super.validateOptions(options)) return false; try { setEncoder(options); } catch (Exception e) { throw new IllegalArgumentException("bad encoder option", e); } return true; }
private void setEncoder(Map<String,String> options) { String type = options.get(TYPE); if (type == null) throw new IllegalArgumentException("no type specified"); if (type.startsWith(CLASS_PREFIX)) { setEncoder(type.substring(CLASS_PREFIX.length())); testEncoder(42L); } else { switch (Type.valueOf(type)) { case VARLEN: setEncoder(VAR_LEN_ENCODER); return; case FIXEDLEN: setEncoder(FIXED_LEN_ENCODER); return; case STRING: setEncoder(STRING_ENCODER); return; default: throw new IllegalArgumentException(); } } }
@Override public boolean validateOptions(Map<String,String> options) { if (super.validateOptions(options) == false) return false; try { setEncoder(options); } catch (Exception e) { throw new IllegalArgumentException("bad encoder option", e); } return true; }
@Override public void init(SortedKeyValueIterator<Key,Value> source, Map<String,String> options, IteratorEnvironment env) throws IOException { super.init(source, options, env); setEncoder(options); }
private void setEncoder(Map<String,String> options) { String type = options.get(TYPE); if (type == null) throw new IllegalArgumentException("no type specified"); if (type.startsWith(CLASS_PREFIX)) { setEncoder(type.substring(CLASS_PREFIX.length())); testEncoder(42l); } else { switch (Type.valueOf(type)) { case VARLEN: setEncoder(VAR_LEN_ENCODER); return; case FIXEDLEN: setEncoder(FIXED_LEN_ENCODER); return; case STRING: setEncoder(STRING_ENCODER); return; default: throw new IllegalArgumentException(); } } }