diff options
author | Frankie B <git@diskfloppy.me> | 2024-05-10 00:32:34 +0100 |
---|---|---|
committer | Frankie B <git@diskfloppy.me> | 2024-05-10 00:32:34 +0100 |
commit | 3faced7068a8401b57be8949e80ce4f4da4a0fb5 (patch) | |
tree | 32e76b06780fe6c14ddb4917d3ad0b222fa9c596 /src/com/wilko/jaim/FLAPFrame.java | |
parent | a1dff2cb8d33b17bc5981f1638cd50266713e98f (diff) |
Format all code, add editorconfig
Diffstat (limited to 'src/com/wilko/jaim/FLAPFrame.java')
-rw-r--r-- | src/com/wilko/jaim/FLAPFrame.java | 136 |
1 files changed, 63 insertions, 73 deletions
diff --git a/src/com/wilko/jaim/FLAPFrame.java b/src/com/wilko/jaim/FLAPFrame.java index 3abc3d8..bef422d 100644 --- a/src/com/wilko/jaim/FLAPFrame.java +++ b/src/com/wilko/jaim/FLAPFrame.java @@ -1,4 +1,4 @@ -/* +/* * (C) 2002 Paul Wilkinson wilko@users.sourceforge.net * * This program is free software; you can redistribute it and/or modify @@ -26,94 +26,84 @@ package com.wilko.jaim; /** - * - * @author paulw + * @author paulw * @version $Revision: 1.4 $ */ public abstract class FLAPFrame { - public static final int FLAP_FRAME_SIGNON=1; - public static final int FLAP_FRAME_DATA=2; - public static final int FLAP_FRAME_ERROR=3; - public static final int FLAP_FRAME_SIGNOFF=4; - public static final int FLAP_FRAME_KEEP_ALIVE=5; - public static final int FLAP_DATA_OFFSET=6; - + public static final int FLAP_FRAME_SIGNON = 1; + public static final int FLAP_FRAME_DATA = 2; + public static final int FLAP_FRAME_ERROR = 3; + public static final int FLAP_FRAME_SIGNOFF = 4; + public static final int FLAP_FRAME_KEEP_ALIVE = 5; + public static final int FLAP_DATA_OFFSET = 6; + protected byte[] frame; protected int fLen; - - /** Creates new FLAPFrame */ + + /** + * Creates new FLAPFrame + */ public FLAPFrame() { initialise(); } - - protected void setFrameData(byte b[]) - { - frame=new byte[b.length]; - fLen=b.length; - System.arraycopy(b,0,frame,0,b.length); - } - - protected void initialise() - { + + protected void initialise() { frame = new byte[8192]; - frame[0]=(byte)'*'; - frame[1]=0; - frame[2]=0; - frame[3]=0; - frame[4]=0; - frame[5]=0; - fLen=6; - + frame[0] = (byte) '*'; + frame[1] = 0; + frame[2] = 0; + frame[3] = 0; + frame[4] = 0; + frame[5] = 0; + fLen = 6; + + } + + public int getSequence() { + return ((frame[2] & 0xff) * 256 + (frame[3] & 0xff)); } - - public void setSequence(int sequence) - { - frame[2]=(byte)((sequence/256)&0xff); - frame[3]=(byte)(sequence&0xff); + + public void setSequence(int sequence) { + frame[2] = (byte) ((sequence / 256) & 0xff); + frame[3] = (byte) (sequence & 0xff); } - - public int getSequence() - { - return((frame[2]&0xff)*256+(frame[3]&0xff)); + + public int getLength() { + return ((frame[4] & 0xff) * 256 + (frame[5] & 0xff)); } - - public int getLength() - { - return((frame[4]&0xff)*256+(frame[5]&0xff)); + + public void setLength(int length) { + frame[4] = (byte) (length / 256); + frame[5] = (byte) (length & 0xff); + fLen = length + FLAP_DATA_OFFSET; } - - public void setLength(int length) - { - frame[4]=(byte)(length/256); - frame[5]=(byte)(length&0xff); - fLen=length+FLAP_DATA_OFFSET; + + public byte[] getFrameData() { + byte[] b = new byte[fLen]; + System.arraycopy(frame, 0, b, 0, fLen); + return (b); } - - public byte[] getFrameData() - { - byte[] b=new byte[fLen]; - System.arraycopy(frame,0,b,0,fLen); - return(b); + + protected void setFrameData(byte[] b) { + frame = new byte[b.length]; + fLen = b.length; + System.arraycopy(b, 0, frame, 0, b.length); + } + + public String toString() { + StringBuffer temp = new StringBuffer(); + for (int i = 0; i < fLen; i++) { + int k = frame[i] & 0xff; + if (k < 16) { + temp.append("0" + Integer.toHexString(k) + " "); + } else { + temp.append(Integer.toHexString(k) + " "); + } + } + return (temp.toString()); } - public String toString() - { - StringBuffer temp=new StringBuffer(); - for (int i=0;i<fLen;i++) - { - int k=frame[i]&0xff; - if (k<16) - { - temp.append("0"+Integer.toHexString(k)+" "); - } - else - { - temp.append(Integer.toHexString(k)+" "); - } - } - return(temp.toString()); -} public abstract int getFLAPFrameType(); - + } |