All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.flybotix.hfr.codex.encode.UncompressedEncoder Maven / Gradle / Ivy

Go to download

A way for wifi robots and IoT devices to quickly send compressed data arrays across a network.

There is a newer version: 2019.1.11
Show newest version
package com.flybotix.hfr.codex.encode;

import java.nio.ByteBuffer;

import com.flybotix.hfr.codex.Codex;
import com.flybotix.hfr.codex.CodexOf;

public class UncompressedEncoder  & CodexOf> extends DefaultEncoder {

  public UncompressedEncoder(Class pEnum, IEncoderProperties pProps) {
    super(pEnum, pProps);
  }
  
  public AEncoder createClone() {
    return new UncompressedEncoder(getEnum(), mProps);
  }

  @Override
  protected boolean isCompressed() {
    return false;
  }

  @Override
  protected Codex decodeImpl(ByteBuffer pData) {
//    Codex result = new Codex<>(this);
    Codex result = new Codex<>(getDefaultValue(), getEnum());
    for(int dataidx = 0; dataidx < mLength; dataidx++) {
      result.set(dataidx, mProps.decodeSingle(pData));
    }
    return result;
  }

  @Override
  protected byte[] encodeImpl(Codex pData) {
    ByteBuffer bb = ByteBuffer.allocate(mProps.sizeOfSingle() * mLength);
    for(int dataidx = 0; dataidx < mLength; dataidx++) {
      mProps.encodeSingle(bb, pData.get(dataidx));
    }
    return  bb.array();
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy