com.github.moaxcp.x11client.protocol.sync.Systemcounter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of x11-client Show documentation
Show all versions of x11-client Show documentation
An x11 client implemented in java
package com.github.moaxcp.x11client.protocol.sync;
import com.github.moaxcp.x11client.protocol.X11Input;
import com.github.moaxcp.x11client.protocol.X11Output;
import com.github.moaxcp.x11client.protocol.XObject;
import com.github.moaxcp.x11client.protocol.XStruct;
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 Systemcounter implements XStruct {
private int counter;
@NonNull
private Int64 resolution;
@NonNull
private List name;
public static Systemcounter readSystemcounter(X11Input in) throws IOException {
int counter = in.readCard32();
Int64 resolution = Int64.readInt64(in);
short nameLen = in.readCard16();
List name = in.readChar(Short.toUnsignedInt(nameLen));
in.readPadAlign(Short.toUnsignedInt(nameLen));
Systemcounter.SystemcounterBuilder javaBuilder = Systemcounter.builder();
javaBuilder.counter(counter);
javaBuilder.resolution(resolution);
javaBuilder.name(name);
return javaBuilder.build();
}
@Override
public void write(X11Output out) throws IOException {
out.writeCard32(counter);
resolution.write(out);
short nameLen = (short) name.size();
out.writeCard16(nameLen);
out.writeChar(name);
out.writePadAlign(Short.toUnsignedInt(nameLen));
}
@Override
public int getSize() {
return 14 + 1 * name.size() + XObject.getSizeForPadAlign(4, 1 * name.size());
}
public static class SystemcounterBuilder {
public int getSize() {
return 14 + 1 * name.size() + XObject.getSizeForPadAlign(4, 1 * name.size());
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy