Пример #1
0
    @SuppressWarnings("unchecked")
    @Override
    protected void _readFrom(SerializationContext ctx, Object inst, BinaryInput src)
        throws IOException, IllegalArgumentException, IllegalAccessException {
      try {
        final int size = _size_ind.getArraySize(src, inst, _field);
        Object ar = _field.get(inst);
        if (ar == null || Array.getLength(ar) != size)
          ar = Array.newInstance(_component_type, size);

        for (int i = 0; i < size; i++) {
          Object component_inst = _component_instor.getConcreteClassInstance(inst, inst, _field);
          if (component_inst == null) {
            Array.set(ar, i, null);
          } else if (_component_type_ba != null) {
            Array.set(ar, i, _component_type_ba.readFrom(ctx, component_inst, src));
          } else {
            Array.set(
                ar,
                i,
                _ba_fac
                    .getBinaryAccessor(component_inst.getClass())
                    .readFrom(ctx, component_inst, src));
          }
        }
        _field.set(inst, ar);
      } catch (Exception e) {
        throw new IOException(e);
      }
    }
Пример #2
0
    public _MA(final BinaryAccessorFactory ba_fac, final Field f) throws Exception {
      super(f);
      _size_ind = ArraySizeIndicator.getArraySizeIndicator(f);
      _ba_fac = ba_fac;
      _component_type = f.getType().getComponentType();

      final ExternStructArray esa = f.getAnnotation(ExternStructArray.class);
      if (esa != null && esa.value() != null) {
        _component_instor =
            FieldObjectInstantiator.getResolver(
                _component_type, f.getDeclaringClass(), esa.value());
        _component_type_ba = null;
      } else {
        _component_instor = FieldObjectInstantiator.getResolver(_component_type, null, null);
        _component_type_ba = ba_fac.getBinaryAccessor(_component_type);
      }
    }