Mercurial > 510Connectbot
diff src/org/tn5250j/framework/tn5250/ScreenField.java @ 112:77ac18bc1b2f
cleanup java formatting
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Wed, 18 Jun 2014 13:03:01 -0700 |
parents | 294435151b0c |
children | 29076621bab0 |
line wrap: on
line diff
--- a/src/org/tn5250j/framework/tn5250/ScreenField.java Wed Jun 18 13:00:19 2014 -0700 +++ b/src/org/tn5250j/framework/tn5250/ScreenField.java Wed Jun 18 13:03:01 2014 -0700 @@ -27,581 +27,515 @@ public class ScreenField { - protected ScreenField(Screen5250 s) { - - this.s = s; - - } - - protected ScreenField setField(int attr, int len, int ffw1, int ffw2, - int fcw1, int fcw2) { + protected ScreenField(Screen5250 s) { + this.s = s; + } - return setField(attr, - s.getCurrentRow() - 1, - s.getCurrentCol() - 1, - len, - ffw1, - ffw2, - fcw1, - fcw2); - } + protected ScreenField setField(int attr, int len, int ffw1, int ffw2, + int fcw1, int fcw2) { + return setField(attr, + s.getCurrentRow() - 1, + s.getCurrentCol() - 1, + len, + ffw1, + ffw2, + fcw1, + fcw2); + } - protected ScreenField setField(int attr, int row, int col, int len, int ffw1, int ffw2, - int fcw1, int fcw2) { - + protected ScreenField setField(int attr, int row, int col, int len, int ffw1, int ffw2, + int fcw1, int fcw2) { // startRow = row; // startCol = col; - cursorProg = 0; - fieldId = 0; - length = len; - startPos = (row * s.getColumns()) + col; - endPos = startPos + length - 1; - this.attr = attr; - setFFWs(ffw1,ffw2); - setFCWs(fcw1,fcw2); - - next = null; - prev = null; + cursorProg = 0; + fieldId = 0; + length = len; + startPos = (row * s.getColumns()) + col; + endPos = startPos + length - 1; + this.attr = attr; + setFFWs(ffw1, ffw2); + setFCWs(fcw1, fcw2); + next = null; + prev = null; + return this; + } - return this; - - } + public int getAttr() { + return attr; + } - public int getAttr(){ - return attr; - } - - public int getHighlightedAttr(){ - return (fcw2 & 0x0f) | 0x20; - } + public int getHighlightedAttr() { + return (fcw2 & 0x0f) | 0x20; + } - public int getLength(){ - return length; - } - - protected boolean setFFWs(int ffw1, int ffw2) { + public int getLength() { + return length; + } - this.ffw1 = ffw1; - this.ffw2 = ffw2; + protected boolean setFFWs(int ffw1, int ffw2) { + this.ffw1 = ffw1; + this.ffw2 = ffw2; + int adj = getAdjustment(); - int adj = getAdjustment(); - - if (adj > 0) { - checkCanSend = true; + if (adj > 0) { + checkCanSend = true; - switch (adj) { + switch (adj) { + case 5: + case 6: + rightAdjd = false; + break; - case 5: - case 6: - rightAdjd = false; - break; - case 7: - manditoried = false; - break; - } + case 7: + manditoried = false; + break; + } + } - } - mdt = (ffw1 & 0x8 ) == 0x8; + mdt = (ffw1 & 0x8) == 0x8; // if (mdt) // s.masterMDT = true; - return mdt; - } - - - public int getFFW1(){ - return ffw1; - } - public int getFFW2(){ - return ffw2; - } - - protected void setFCWs(int fcw1, int fcw2) { - - this.fcw1 = fcw1; - this.fcw2 = fcw2; - -// if ((fcw1 & 0x88) == 0x88) { - if (fcw1 == 0x88) { - - cursorProg = fcw2; - } - } - - public int getFCW1(){ - return fcw1; - } - - public int getFCW2(){ - return fcw2; - } - - public int getFieldLength(){ - return length; - } - - public int getCursorProgression() { - return cursorProg; - } - - public int getFieldId() { - return fieldId; - } - - protected void setFieldId(int fi) { - fieldId = fi; - } - - public int getCursorRow() { - - return cursorPos / s.getColumns(); - } - - public int getCursorCol() { - - return cursorPos % s.getColumns(); - } - - protected void changePos(int i) { - - cursorPos += i; - - } - - protected String getText() { - StringBuffer text = new StringBuffer(); - getKeyPos(endPos); - int x = length; - text.setLength(x); - while (x-- > 0) { - - // here we manipulate the unicode characters a little for attributes - // that are imbedded in input fields. We will offset them by unicode - // \uff00. All routines that process these fields will have to - // return them to their proper offsets. - // example: - // if we read an attribute byte of 32 for normal display the unicode - // character for this is \u0020 and the unicode character for - // a space is also \u0020 thus the offset. - if (s.planes.isAttributePlace(cursorPos)) { - text.setCharAt(x,(char)('\uff00' + s.planes.getCharAttr(cursorPos))); - } - else { - text.setCharAt(x,s.planes.getChar(cursorPos)); - } - changePos(-1); - - } - - // Since only the mdt of the first continued field is set we will get - // the text of the next continued field if we are dealing with continued - // fields. See routine setMDT for the whys of this. This is only - // executed if this is the first field of a continued field. - if (isContinued() && isContinuedFirst()) { - ScreenField sf = this; - do { - sf = sf.next; - text.append(sf.getText()); - } - while (!sf.isContinuedLast()); - - sf = null; - } - - return text.toString(); - - } - - public String getString() { + return mdt; + } - StringBuffer text = new StringBuffer(); - getKeyPos(endPos); - int x = length; - text.setLength(x); - while (x-- > 0) { + public int getFFW1() { + return ffw1; + } + public int getFFW2() { + return ffw2; + } + + protected void setFCWs(int fcw1, int fcw2) { + this.fcw1 = fcw1; + this.fcw2 = fcw2; + +// if ((fcw1 & 0x88) == 0x88) { + if (fcw1 == 0x88) { + cursorProg = fcw2; + } + } + + public int getFCW1() { + return fcw1; + } - // here we manipulate the unicode characters a little for attributes - // that are imbedded in input fields. We will offset them by unicode - // \uff00. All routines that process these fields will have to - // return them to their proper offsets. - // example: - // if we read an attribute byte of 32 for normal display the unicode - // character for this is \u0020 and the unicode character for - // a space is also \u0020 thus the offset. - if (s.planes.isAttributePlace(cursorPos)) { - text.setCharAt(x,(char)('\uff00' + s.planes.getCharAttr(cursorPos))); - } - else { - if (s.planes.getChar(cursorPos) < ' ') - text.setCharAt(x,' '); - else - text.setCharAt(x,s.planes.getChar(cursorPos)); - } - changePos(-1); + public int getFCW2() { + return fcw2; + } + + public int getFieldLength() { + return length; + } + + public int getCursorProgression() { + return cursorProg; + } - } + public int getFieldId() { + return fieldId; + } - // Since only the mdt of the first continued field is set we will get - // the text of the next continued field if we are dealing with continued - // fields. See routine setMDT for the whys of this. This is only - // executed if this is the first field of a continued field. - if (isContinued() && isContinuedFirst()) { - ScreenField sf = this; - do { - sf = sf.next; - text.append(sf.getString()); - } - while (!sf.isContinuedLast()); + protected void setFieldId(int fi) { + fieldId = fi; + } - sf = null; - } - - return text.toString(); + public int getCursorRow() { + return cursorPos / s.getColumns(); + } - } - - public void setFieldChar(char c) { + public int getCursorCol() { + return cursorPos % s.getColumns(); + } - int x = length; - cursorPos = startPos; - while (x-- > 0) { - s.planes.setChar(cursorPos,c); - changePos(1); - } + protected void changePos(int i) { + cursorPos += i; + } - } - - public void setFieldChar(int lastPos, char c) { + protected String getText() { + StringBuffer text = new StringBuffer(); + getKeyPos(endPos); + int x = length; + text.setLength(x); - int x = endPos - lastPos + 1; - cursorPos = lastPos; - while (x-- > 0) { - s.planes.setChar(cursorPos,c); - s.setDirty(cursorPos); - changePos(1); - } - } + while (x-- > 0) { + // here we manipulate the unicode characters a little for attributes + // that are imbedded in input fields. We will offset them by unicode + // \uff00. All routines that process these fields will have to + // return them to their proper offsets. + // example: + // if we read an attribute byte of 32 for normal display the unicode + // character for this is \u0020 and the unicode character for + // a space is also \u0020 thus the offset. + if (s.planes.isAttributePlace(cursorPos)) { + text.setCharAt(x, (char)('\uff00' + s.planes.getCharAttr(cursorPos))); + } + else { + text.setCharAt(x, s.planes.getChar(cursorPos)); + } - protected void setRightAdjusted() { - rightAdjd = true; - } - - protected void setManditoryEntered() { + changePos(-1); + } - manditoried = true; - } - - protected void resetMDT() { - mdt = false; + // Since only the mdt of the first continued field is set we will get + // the text of the next continued field if we are dealing with continued + // fields. See routine setMDT for the whys of this. This is only + // executed if this is the first field of a continued field. + if (isContinued() && isContinuedFirst()) { + ScreenField sf = this; - } - - protected void setMDT() { + do { + sf = sf.next; + text.append(sf.getText()); + } + while (!sf.isContinuedLast()); - // get the first field of a continued edit field if it is continued - if (isContinued() && !isContinuedFirst()) { - ScreenField sf = prev; - while (sf.isContinued() && !sf.isContinuedFirst()) { + sf = null; + } + + return text.toString(); + } - sf = sf.prev; - - } - sf.setMDT(); - sf = null; - } - else { - mdt = true; - } + public String getString() { + StringBuffer text = new StringBuffer(); + getKeyPos(endPos); + int x = length; + text.setLength(x); - } - - public boolean isBypassField() { - - return (ffw1 & 0x20) == 0x20; - - } - - public int getAdjustment () { + while (x-- > 0) { + // here we manipulate the unicode characters a little for attributes + // that are imbedded in input fields. We will offset them by unicode + // \uff00. All routines that process these fields will have to + // return them to their proper offsets. + // example: + // if we read an attribute byte of 32 for normal display the unicode + // character for this is \u0020 and the unicode character for + // a space is also \u0020 thus the offset. + if (s.planes.isAttributePlace(cursorPos)) { + text.setCharAt(x, (char)('\uff00' + s.planes.getCharAttr(cursorPos))); + } + else { + if (s.planes.getChar(cursorPos) < ' ') + text.setCharAt(x, ' '); + else + text.setCharAt(x, s.planes.getChar(cursorPos)); + } - return (ffw2 & 0x7); - } - - // is field exit required - public boolean isFER () { + changePos(-1); + } - return (ffw2 & 0x40) == 0x40; - } - - // is field manditory enter - public boolean isMandatoryEnter() { + // Since only the mdt of the first continued field is set we will get + // the text of the next continued field if we are dealing with continued + // fields. See routine setMDT for the whys of this. This is only + // executed if this is the first field of a continued field. + if (isContinued() && isContinuedFirst()) { + ScreenField sf = this; - return (ffw2 & 0x8) == 0x8; - - } - - public boolean isToUpper() { + do { + sf = sf.next; + text.append(sf.getString()); + } + while (!sf.isContinuedLast()); - return (ffw2 & 0x20) == 0x20; + sf = null; + } - } + return text.toString(); + } - // bits 5 - 7 - public int getFieldShift () { + public void setFieldChar(char c) { + int x = length; + cursorPos = startPos; - return (ffw1 & 0x7); - - } + while (x-- > 0) { + s.planes.setChar(cursorPos, c); + changePos(1); + } + } - public boolean isHiglightedEntry() { - - return (fcw1 == 0x89); - - } + public void setFieldChar(int lastPos, char c) { + int x = endPos - lastPos + 1; + cursorPos = lastPos; - public boolean isAutoEnter() { - - return (ffw2 & 0x80) == 0x80; - - } + while (x-- > 0) { + s.planes.setChar(cursorPos, c); + s.setDirty(cursorPos); + changePos(1); + } + } - public boolean isSignedNumeric () { + protected void setRightAdjusted() { + rightAdjd = true; + } - return (getFieldShift() == 7); - - } + protected void setManditoryEntered() { + manditoried = true; + } - public boolean isRightToLeft() { - return (getFieldShift() == 0x04); - } - - public boolean isNumeric () { + protected void resetMDT() { + mdt = false; + } - return (getFieldShift() == 3); + protected void setMDT() { + // get the first field of a continued edit field if it is continued + if (isContinued() && !isContinuedFirst()) { + ScreenField sf = prev; - } - - public boolean isDupEnabled() { + while (sf.isContinued() && !sf.isContinuedFirst()) { + sf = sf.prev; + } - return (ffw1 & 0x10) == 0x10; - - } - - public boolean isContinued() { + sf.setMDT(); + sf = null; + } + else { + mdt = true; + } + } - return (fcw1 & 0x86) == 0x86 && (fcw2 >= 1 && fcw2 <= 3) ; + public boolean isBypassField() { + return (ffw1 & 0x20) == 0x20; + } - } - - public boolean isContinuedFirst() { + public int getAdjustment() { + return (ffw2 & 0x7); + } - return (fcw1 & 0x86) == 0x86 && (fcw2 == 1); - - } - - public boolean isContinuedMiddle() { - - return (fcw1 & 0x86) == 0x86 && (fcw2 == 3); + // is field exit required + public boolean isFER() { + return (ffw2 & 0x40) == 0x40; + } - } - - public boolean isContinuedLast() { + // is field manditory enter + public boolean isMandatoryEnter() { + return (ffw2 & 0x8) == 0x8; + } - return (fcw1 & 0x86) == 0x86 && (fcw2 == 2); - - } - - protected boolean isCanSend() { + public boolean isToUpper() { + return (ffw2 & 0x20) == 0x20; + } - int adj = getAdjustment(); + // bits 5 - 7 + public int getFieldShift() { + return (ffw1 & 0x7); + } - // here we need to check the Field Exit Required value first before checking - // the adjustments. If the last character has been entered and we are - // now setting past the last position then we are allowed to process the - // the field without continuing. - if (isFER() && cursorPos > endPos) { - return true; - } + public boolean isHiglightedEntry() { + return (fcw1 == 0x89); + } - // signed numeric fields need to be checked as well. - if (isSignedNumeric() && cursorPos < endPos - 1) { - return false; - } + public boolean isAutoEnter() { + return (ffw2 & 0x80) == 0x80; + } - if (adj > 0) { - - switch (adj) { + public boolean isSignedNumeric() { + return (getFieldShift() == 7); + } - case 5: - case 6: - return rightAdjd; - case 7: - return manditoried; - default: - return true; - } + public boolean isRightToLeft() { + return (getFieldShift() == 0x04); + } - } - return true; - } + public boolean isNumeric() { + return (getFieldShift() == 3); + } - public boolean isSelectionField() { - - return isSelectionField; - - } + public boolean isDupEnabled() { + return (ffw1 & 0x10) == 0x10; + } - public void setSelectionFieldInfo(int type, int index, int position) { - - selectionFieldType = type; - selectionIndex = index; - selectionPos = position; - isSelectionField = true; + public boolean isContinued() { + return (fcw1 & 0x86) == 0x86 && (fcw2 >= 1 && fcw2 <= 3) ; + } - } - - protected int getKeyPos(int row1, int col1) { + public boolean isContinuedFirst() { + return (fcw1 & 0x86) == 0x86 && (fcw2 == 1); + } - int x = ((row1 * s.getColumns()) + col1); - int y = x - startPos(); - cursorPos = x; - - return y; - } - - protected int getKeyPos(int pos) { + public boolean isContinuedMiddle() { + return (fcw1 & 0x86) == 0x86 && (fcw2 == 3); + } - int y = pos - startPos(); - cursorPos = pos; - - return y; - } + public boolean isContinuedLast() { + return (fcw1 & 0x86) == 0x86 && (fcw2 == 2); + } - public int getCurrentPos() { + protected boolean isCanSend() { + int adj = getAdjustment(); - return cursorPos; - } - - public boolean withinField (int pos) { - - if (pos >= startPos && pos <= endPos) + // here we need to check the Field Exit Required value first before checking + // the adjustments. If the last character has been entered and we are + // now setting past the last position then we are allowed to process the + // the field without continuing. + if (isFER() && cursorPos > endPos) { return true; - return false; - - } + } - public int startPos() { + // signed numeric fields need to be checked as well. + if (isSignedNumeric() && cursorPos < endPos - 1) { + return false; + } - return startPos; - } + if (adj > 0) { + switch (adj) { + case 5: + case 6: + return rightAdjd; - /** - * Get the starting row of the field. Offset is 0 so row 6 returned - * is row 7 mapped to screen - * @return int starting row of the field offset 0 - */ - public int startRow() { + case 7: + return manditoried; - return startPos / s.getColumns(); + default: + return true; + } + } + + return true; + } + + public boolean isSelectionField() { + return isSelectionField; + } - } + public void setSelectionFieldInfo(int type, int index, int position) { + selectionFieldType = type; + selectionIndex = index; + selectionPos = position; + isSelectionField = true; + } - /** - * Get the starting column of the field. Offset is 0 so column 6 returned - * is column 7 mapped to screen - * @return int starting column of the field offset 0 - */ - public int startCol() { + protected int getKeyPos(int row1, int col1) { + int x = ((row1 * s.getColumns()) + col1); + int y = x - startPos(); + cursorPos = x; + return y; + } - return startPos % s.getColumns(); + protected int getKeyPos(int pos) { + int y = pos - startPos(); + cursorPos = pos; + return y; + } - } + public int getCurrentPos() { + return cursorPos; + } - public int endPos() { + public boolean withinField(int pos) { + if (pos >= startPos && pos <= endPos) + return true; - return endPos; + return false; + } - } + public int startPos() { + return startPos; + } - /** - * Sets the field's text plane to the specified string. If the string is - * shorter than the length of the field, the rest of the field is cleared. - * If the string is longer than the field, the text is truncated. A subsequent - * call to getText on this field will not show the changed text. To see the - * changed text, do a refresh on the iOhioFields collection and retrieve the - * refreshed field object. - * - * @param text - The text to be placed in the field's text plane. - */ - public void setString(String text) { + /** + * Get the starting row of the field. Offset is 0 so row 6 returned + * is row 7 mapped to screen + * @return int starting row of the field offset 0 + */ + public int startRow() { + return startPos / s.getColumns(); + } + + /** + * Get the starting column of the field. Offset is 0 so column 6 returned + * is column 7 mapped to screen + * @return int starting column of the field offset 0 + */ + public int startCol() { + return startPos % s.getColumns(); + } - int y = length; - cursorPos = startPos; - int len = text.length(); - char[] c = text.toCharArray(); - char tc = ' '; + public int endPos() { + return endPos; + } + + /** + * Sets the field's text plane to the specified string. If the string is + * shorter than the length of the field, the rest of the field is cleared. + * If the string is longer than the field, the text is truncated. A subsequent + * call to getText on this field will not show the changed text. To see the + * changed text, do a refresh on the iOhioFields collection and retrieve the + * refreshed field object. + * + * @param text - The text to be placed in the field's text plane. + */ + public void setString(String text) { + int y = length; + cursorPos = startPos; + int len = text.length(); + char[] c = text.toCharArray(); + char tc = ' '; - for (int x = 0; x < y; x++) { - tc = ' '; - if (x < len) { - tc = c[x]; - } - s.getPlanes().setChar(cursorPos,tc); - changePos(1); - } - setMDT(); - s.getScreenFields().setMasterMDT(); - } + for (int x = 0; x < y; x++) { + tc = ' '; + + if (x < len) { + tc = c[x]; + } + + s.getPlanes().setChar(cursorPos, tc); + changePos(1); + } + + setMDT(); + s.getScreenFields().setMasterMDT(); + } - public String toString() { - int fcw = (fcw1 & 0xff) << 8 | fcw2 & 0xff; - return "startRow = " + startRow() + " startCol = " + startCol() + - " length = " + length + " ffw1 = (0x" + Integer.toHexString(ffw1) + - ") ffw2 = (0x" + Integer.toHexString(ffw2) + - ") fcw1 = (0x" + Integer.toHexString(fcw1) + - ") fcw2 = (0x" + Integer.toHexString(fcw2) + - ") fcw = (" + Integer.toBinaryString(fcw) + - ") fcw hex = (0x" + Integer.toHexString(fcw) + - ") is bypass field = " + isBypassField() + - ") is autoenter = " + isAutoEnter() + - ") is manditoryenter = " + isMandatoryEnter() + - ") is field exit required = " + isFER() + - ") is Numeric = " + isNumeric() + - ") is Signed Numeric = " + isSignedNumeric() + - ") is cursor progression = " + (fcw1 == 0x88) + - ") next progression field = " + fcw2 + - ") field id " + fieldId + - " continued edit field = " + isContinued() + - " first continued edit field = " + isContinuedFirst() + - " middle continued edit field = " + isContinuedMiddle() + - " last continued edit field = " + isContinuedLast() + - " mdt = " + mdt; - } + public String toString() { + int fcw = (fcw1 & 0xff) << 8 | fcw2 & 0xff; + return "startRow = " + startRow() + " startCol = " + startCol() + + " length = " + length + " ffw1 = (0x" + Integer.toHexString(ffw1) + + ") ffw2 = (0x" + Integer.toHexString(ffw2) + + ") fcw1 = (0x" + Integer.toHexString(fcw1) + + ") fcw2 = (0x" + Integer.toHexString(fcw2) + + ") fcw = (" + Integer.toBinaryString(fcw) + + ") fcw hex = (0x" + Integer.toHexString(fcw) + + ") is bypass field = " + isBypassField() + + ") is autoenter = " + isAutoEnter() + + ") is manditoryenter = " + isMandatoryEnter() + + ") is field exit required = " + isFER() + + ") is Numeric = " + isNumeric() + + ") is Signed Numeric = " + isSignedNumeric() + + ") is cursor progression = " + (fcw1 == 0x88) + + ") next progression field = " + fcw2 + + ") field id " + fieldId + + " continued edit field = " + isContinued() + + " first continued edit field = " + isContinuedFirst() + + " middle continued edit field = " + isContinuedMiddle() + + " last continued edit field = " + isContinuedLast() + + " mdt = " + mdt; + } public int getStartPos() { return startPos; } - int startPos = 0; - int endPos = 0; - boolean mdt = false; - protected boolean checkCanSend; - protected boolean rightAdjd; - protected boolean manditoried; - boolean canSend = true; - int attr = 0; - int length = 0; - int ffw1 = 0; - int ffw2 = 0; - int fcw1 = 0; - int fcw2 = 0; - int cursorPos = 0; - Screen5250 s; - int cursorProg = 0; - int fieldId = 0; - ScreenField next = null; - ScreenField prev = null; - boolean isSelectionField; - int selectionFieldType; - int selectionIndex; - int selectionPos; + int startPos = 0; + int endPos = 0; + boolean mdt = false; + protected boolean checkCanSend; + protected boolean rightAdjd; + protected boolean manditoried; + boolean canSend = true; + int attr = 0; + int length = 0; + int ffw1 = 0; + int ffw2 = 0; + int fcw1 = 0; + int fcw2 = 0; + int cursorPos = 0; + Screen5250 s; + int cursorProg = 0; + int fieldId = 0; + ScreenField next = null; + ScreenField prev = null; + boolean isSelectionField; + int selectionFieldType; + int selectionIndex; + int selectionPos; } \ No newline at end of file