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

com.github.moaxcp.x11client.protocol.xprint.AttributNotifyEvent 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.X11Input;
import com.github.moaxcp.x11client.protocol.X11Output;
import com.github.moaxcp.x11client.protocol.XEvent;
import java.io.IOException;
import java.lang.Override;
import lombok.Builder;
import lombok.Value;

@Value
@Builder
public class AttributNotifyEvent implements XEvent {
  public static final byte NUMBER = 1;

  private boolean sentEvent;

  private byte detail;

  private short sequenceNumber;

  private int context;

  @Override
  public byte getResponseCode() {
    return NUMBER;
  }

  public static AttributNotifyEvent readAttributNotifyEvent(boolean sentEvent, X11Input in) throws
      IOException {
    byte detail = in.readCard8();
    short sequenceNumber = in.readCard16();
    int context = in.readCard32();
    in.readPad(24);
    AttributNotifyEvent.AttributNotifyEventBuilder javaBuilder = AttributNotifyEvent.builder();
    javaBuilder.detail(detail);
    javaBuilder.sequenceNumber(sequenceNumber);
    javaBuilder.context(context);

    javaBuilder.sentEvent(sentEvent);
    return javaBuilder.build();
  }

  @Override
  public void write(X11Output out) throws IOException {
    out.writeCard8(sentEvent ? 0b10000000 & NUMBER : NUMBER);
    out.writeCard8(detail);
    out.writeCard16(sequenceNumber);
    out.writeCard32(context);
    out.writePad(24);
  }

  @Override
  public int getSize() {
    return 32;
  }

  public static class AttributNotifyEventBuilder {
    public int getSize() {
      return 32;
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy