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

com.github.moaxcp.x11client.protocol.xprint.PrintPutDocumentData Maven / Gradle / Ivy

There is a newer version: 0.18.2
Show newest version
package com.github.moaxcp.x11client.protocol.xprint;

import com.github.moaxcp.x11client.protocol.OneWayRequest;
import com.github.moaxcp.x11client.protocol.X11Input;
import com.github.moaxcp.x11client.protocol.X11Output;
import java.io.IOException;
import java.lang.Byte;
import java.lang.Override;
import java.util.List;
import lombok.Builder;
import lombok.NonNull;
import lombok.Value;

@Value
@Builder
public class PrintPutDocumentData implements OneWayRequest {
  public static final byte OPCODE = 11;

  private int drawable;

  @NonNull
  private List data;

  @NonNull
  private List docFormat;

  @NonNull
  private List options;

  public byte getOpCode() {
    return OPCODE;
  }

  public static PrintPutDocumentData readPrintPutDocumentData(X11Input in) throws IOException {
    in.readPad(1);
    short length = in.readCard16();
    int drawable = in.readCard32();
    int lenData = in.readCard32();
    short lenFmt = in.readCard16();
    short lenOptions = in.readCard16();
    List data = in.readByte((int) (Integer.toUnsignedLong(lenData)));
    List docFormat = in.readChar(Short.toUnsignedInt(lenFmt));
    List options = in.readChar(Short.toUnsignedInt(lenOptions));
    PrintPutDocumentData.PrintPutDocumentDataBuilder javaBuilder = PrintPutDocumentData.builder();
    javaBuilder.drawable(drawable);
    javaBuilder.data(data);
    javaBuilder.docFormat(docFormat);
    javaBuilder.options(options);
    in.readPadAlign(javaBuilder.getSize());
    return javaBuilder.build();
  }

  @Override
  public void write(byte offset, X11Output out) throws IOException {
    out.writeCard8((byte)(Byte.toUnsignedInt(OPCODE) + Byte.toUnsignedInt(offset)));
    out.writePad(1);
    out.writeCard16((short) getLength());
    out.writeCard32(drawable);
    int lenData = data.size();
    out.writeCard32(lenData);
    short lenFmt = (short) docFormat.size();
    out.writeCard16(lenFmt);
    short lenOptions = (short) options.size();
    out.writeCard16(lenOptions);
    out.writeByte(data);
    out.writeChar(docFormat);
    out.writeChar(options);
    out.writePadAlign(getSize());
  }

  @Override
  public int getSize() {
    return 16 + 1 * data.size() + 1 * docFormat.size() + 1 * options.size();
  }

  public static class PrintPutDocumentDataBuilder {
    public int getSize() {
      return 16 + 1 * data.size() + 1 * docFormat.size() + 1 * options.size();
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy