@Override public Object decode(List<Object> parts, State state) { NestedDecoderState s = getDecoder(state); int index = s.getIndex(); index += s.incPartsIndex(); if (fixedIndex != null && parts.isEmpty()) { s.resetPartsIndex(); } if (index == -1 || (fixedIndex != null && state.getLevel() == 0)) { return decoders[decoders.length-1].decode(parts, state); } Object res = decoders[index].decode(parts, state); if (res == null) { index = s.incIndex() + s.getPartsIndex(); return decoders[index].decode(parts, state); } // TODO refactor it! Decoder<Object> decoder = decoders[index].getDecoder(0, state); if (decoder == RESET_INDEX) { s.setIndex(-1); } return res; }
NestedDecoderState s = getDecoder(state); if (fixedIndex != null) { s.setIndex(fixedIndex); } else { s.incIndex(); s.resetPartsIndex(); int index = getDecoder(state).getIndex(); if (index == -1) { getDecoder(state).setIndex(0); index = 0; if (decoder == RESET) { NestedDecoderState s = getDecoder(state); s.setIndex(0); int ind = s.getIndex(); return decoders[ind].getDecoder(paramNum, state); s.setIndex(1); int ind = s.getIndex(); return decoders[ind].getDecoder(paramNum, state);
@Override public Object decode(List<Object> parts, State state) { NestedDecoderState s = getDecoder(state); int index = s.getIndex(); index += s.incPartsIndex(); if (fixedIndex != null && parts.isEmpty()) { s.resetPartsIndex(); } if (index == -1 || (fixedIndex != null && state.getLevel() == 0)) { return decoders[decoders.length-1].decode(parts, state); } Object res = decoders[index].decode(parts, state); if (res == null) { index = s.incIndex() + s.getPartsIndex(); return decoders[index].decode(parts, state); } // TODO refactor it! Decoder<Object> decoder = decoders[index].getDecoder(0, state); if (decoder == RESET_INDEX) { s.setIndex(-1); } return res; }
@Override public DecoderState copy() { return new NestedDecoderState(index); }
protected final NestedDecoderState getDecoder(State state) { NestedDecoderState ds = state.getDecoderState(); if (ds == null) { ds = new NestedDecoderState(); state.setDecoderState(ds); } return ds; }
NestedDecoderState s = getDecoder(state); if (fixedIndex != null) { s.setIndex(fixedIndex); } else { s.incIndex(); s.resetPartsIndex(); int index = getDecoder(state).getIndex(); if (index == -1) { getDecoder(state).setIndex(0); index = 0; if (decoder == RESET) { NestedDecoderState s = getDecoder(state); s.setIndex(0); int ind = s.getIndex(); return decoders[ind].getDecoder(paramNum, state); s.setIndex(1); int ind = s.getIndex(); return decoders[ind].getDecoder(paramNum, state);
NestedDecoderState s = getDecoder(state); if (fixedIndex != null) { s.setIndex(fixedIndex); } else { s.incIndex(); s.resetPartsIndex(); int index = getDecoder(state).getIndex(); if (index == -1) { getDecoder(state).setIndex(0); index = 0; if (decoder == RESET) { NestedDecoderState s = getDecoder(state); s.setIndex(0); int ind = s.getIndex(); return decoders[ind].getDecoder(paramNum, state); s.setIndex(1); int ind = s.getIndex(); return decoders[ind].getDecoder(paramNum, state);
@Override public Object decode(List<Object> parts, State state) { NestedDecoderState s = getDecoder(state); int index = s.getIndex(); index += s.incPartsIndex(); if (fixedIndex != null && parts.isEmpty()) { s.resetPartsIndex(); } if (index == -1 || (fixedIndex != null && state.getLevel() == 0)) { return decoders[decoders.length-1].decode(parts, state); } Object res = decoders[index].decode(parts, state); if (res == null) { index = s.incIndex() + s.getPartsIndex(); return decoders[index].decode(parts, state); } // TODO refactor it! Decoder<Object> decoder = decoders[index].getDecoder(0, state); if (decoder == RESET_INDEX) { s.setIndex(-1); } return res; }
@Override public DecoderState copy() { return new NestedDecoderState(index); }
protected final NestedDecoderState getDecoder(State state) { NestedDecoderState ds = state.getDecoderState(); if (ds == null) { ds = new NestedDecoderState(); state.setDecoderState(ds); } return ds; }
protected final NestedDecoderState getDecoder(State state) { NestedDecoderState ds = state.getDecoderState(); if (ds == null) { ds = new NestedDecoderState(); state.setDecoderState(ds); } return ds; }
@Override public DecoderState copy() { return new NestedDecoderState(index); }