# HG changeset patch # User Carl Byington # Date 1403121781 25200 # Node ID 77ac18bc1b2f0547ca96df3527ab35bc27f777cb # Parent 6a0ad4d384ea095670b3626a8d20058ad0a42b58 cleanup java formatting diff -r 6a0ad4d384ea -r 77ac18bc1b2f src/com/five_ten_sg/connectbot/HostEditorActivity.java --- a/src/com/five_ten_sg/connectbot/HostEditorActivity.java Wed Jun 18 13:00:19 2014 -0700 +++ b/src/com/five_ten_sg/connectbot/HostEditorActivity.java Wed Jun 18 13:03:01 2014 -0700 @@ -261,7 +261,6 @@ this.pref = new CursorPreferenceHack(HostDatabase.TABLE_HOSTS, hostId); this.pref.registerOnSharedPreferenceChangeListener(this); this.addPreferencesFromResource(R.xml.host_prefs); - // disable all preferences that are not applicable to this host findPreference(HostDatabase.FIELD_HOST_PUBKEYID).setEnabled(enableSSHFeatures); findPreference(HostDatabase.FIELD_HOST_USEAUTHAGENT).setEnabled(enableSSHFeatures); @@ -275,7 +274,6 @@ findPreference(HostDatabase.FIELD_HOST_WANTX11FORWARD).setEnabled(enableSSHFeatures); findPreference(HostDatabase.FIELD_HOST_X11HOST).setEnabled(enableSSHFeatures); findPreference(HostDatabase.FIELD_HOST_X11PORT).setEnabled(enableSSHFeatures); - // add all existing pubkeys to our listpreference for user to choose from // TODO: may be an issue here when this activity is recycled after adding a new pubkey // TODO: should consider moving into onStart, but we dont have a good way of resetting the listpref after filling once @@ -339,7 +337,9 @@ // for all text preferences, set hint as current database value for (String key : this.pref.values.keySet()) { if (key.equals(HostDatabase.FIELD_HOST_POSTLOGIN)) continue; + if (key.equals(HostDatabase.FIELD_HOST_EMULATION)) continue; + if (key.equals(HostDatabase.FIELD_HOST_MONITOR)) continue; Preference pref = this.findPreference(key); diff -r 6a0ad4d384ea -r 77ac18bc1b2f src/com/five_ten_sg/connectbot/HostListActivity.java --- a/src/com/five_ten_sg/connectbot/HostListActivity.java Wed Jun 18 13:00:19 2014 -0700 +++ b/src/com/five_ten_sg/connectbot/HostListActivity.java Wed Jun 18 13:03:01 2014 -0700 @@ -178,13 +178,14 @@ } makingShortcut = Intent.ACTION_CREATE_SHORTCUT.equals(getIntent().getAction()) - || Intent.ACTION_PICK.equals(getIntent().getAction()); + || Intent.ACTION_PICK.equals(getIntent().getAction()); // connect with hosts database and populate list hostdb = new HostDatabase(this); updateList(); sortedByColor = prefs.getBoolean(PreferenceConstants.SORT_BY_COLOR, false); registerForContextMenu(getListView()); getListView().setOnItemClickListener(new OnItemClickListener() { + public synchronized void onItemClick(AdapterView parent, View view, int position, long id) { // launch off to console details HostBean host = (HostBean) getListView().getItemAtPosition(position); diff -r 6a0ad4d384ea -r 77ac18bc1b2f src/com/five_ten_sg/connectbot/service/Relay.java --- a/src/com/five_ten_sg/connectbot/service/Relay.java Wed Jun 18 13:00:19 2014 -0700 +++ b/src/com/five_ten_sg/connectbot/service/Relay.java Wed Jun 18 13:03:01 2014 -0700 @@ -114,7 +114,9 @@ charWidth = bridge.charWidth; bytesToRead = byteBuffer.capacity() - byteBuffer.limit(); offset = byteBuffer.arrayOffset() + byteBuffer.limit(); + if (transport.willBlock()) buffer.testChanged(); + bytesRead = transport.read(byteArray, offset, bytesToRead); if (bytesRead > 0) { diff -r 6a0ad4d384ea -r 77ac18bc1b2f src/com/five_ten_sg/connectbot/service/TerminalBridge.java --- a/src/com/five_ten_sg/connectbot/service/TerminalBridge.java Wed Jun 18 13:00:19 2014 -0700 +++ b/src/com/five_ten_sg/connectbot/service/TerminalBridge.java Wed Jun 18 13:03:01 2014 -0700 @@ -176,7 +176,9 @@ this.host = host; this.homeDirectory = homeDirectory; emulation = host.getHostEmulation(); + if ((emulation == null) || (emulation.length() == 0)) emulation = manager.getEmulation(); + // create prompt helper to relay password and hostkey requests up to gui promptHelper = new PromptHelper(this); // create our default paint @@ -217,8 +219,8 @@ transport.setLinks(manager, this, homeDirectory, host, emulation); buffer = transport.getTransportBuffer(); keyListener = transport.getTerminalKeyListener(); + String monitor_init = host.getMonitor(); - String monitor_init = host.getMonitor(); if ((monitor_init != null) && (monitor_init.length() > 0)) { monitor = new TerminalMonitor(manager, buffer, keyListener, parent, monitor_init); } @@ -262,6 +264,7 @@ */ public Charset getCharset() { if (relay != null) return relay.getCharset(); + return keyListener.getCharset(); } @@ -272,6 +275,7 @@ */ public void setCharset(String encoding) { if (relay != null) relay.setCharset(encoding); + keyListener.setCharset(encoding); } @@ -419,6 +423,7 @@ // close the monitor if (monitor != null) monitor.Disconnect(); + monitor = null; } @@ -1385,6 +1390,7 @@ return true; } } + return super.dispatchKeyEvent(event); } }; diff -r 6a0ad4d384ea -r 77ac18bc1b2f src/com/five_ten_sg/connectbot/service/TerminalKeyListener.java --- a/src/com/five_ten_sg/connectbot/service/TerminalKeyListener.java Wed Jun 18 13:00:19 2014 -0700 +++ b/src/com/five_ten_sg/connectbot/service/TerminalKeyListener.java Wed Jun 18 13:03:01 2014 -0700 @@ -124,11 +124,13 @@ protected void sendEncoded(String s) { byte [] b = null; + try { b = s.getBytes(encoding); } - catch (UnsupportedEncodingException e){ + catch (UnsupportedEncodingException e) { } + if (b != null) buffer.write(b); } @@ -138,6 +140,7 @@ */ public boolean onKey(View v, int keyCode, KeyEvent event) { Log.d(TAG, String.format("onKey with key %d", keyCode)); + try { // skip keys if we aren't connected yet or have been disconnected if (bridge.isDisconnected()) return false; @@ -586,6 +589,7 @@ Log.d(TAG, "Input before connection established ignored."); return true; } + return false; } diff -r 6a0ad4d384ea -r 77ac18bc1b2f src/com/five_ten_sg/connectbot/service/TerminalMonitor.java --- a/src/com/five_ten_sg/connectbot/service/TerminalMonitor.java Wed Jun 18 13:00:19 2014 -0700 +++ b/src/com/five_ten_sg/connectbot/service/TerminalMonitor.java Wed Jun 18 13:03:01 2014 -0700 @@ -50,7 +50,7 @@ private boolean moved = false; // used to delay cursor moved notifications private int to_line = 0; // "" private int to_column = 0; // "" - private HashMap keymap = null; + private HashMap keymap = null; private IBinder bound = null; private Socket monitor_socket = null; private InputStream monitor_in = null; @@ -103,21 +103,25 @@ case MONITOR_CMD_SETFIELD: if (packet.length >= 4) setField(packet[1], packet[2], packet, 3); + break; case MONITOR_CMD_GETFIELD: if (packet.length == 4) getField(packet[1], packet[2], packet[3]); + break; case MONITOR_CMD_SCREENWATCH: if (packet.length == 4) screenWatch(packet[1], packet[2], packet[3]); + break; case MONITOR_CMD_DEPRESS: if (packet.length == 2) depress(packet[1]); + break; default: @@ -149,9 +153,12 @@ String x = " " + init; monitorWrite(MONITOR_CMD_INIT, x.toCharArray()); char [] c; + while (true) { c = pending_commands.poll(); + if (c == null) break; + monitorWrite(c[1], c); } } @@ -172,11 +179,10 @@ this.keyListener = keyListener; this.view = view; this.init = init; - // setup the windows->android keymapping // http://msdn.microsoft.com/en-us/library/windows/desktop/dd375731 // http://developer.android.com/reference/android/view/KeyEvent.html - keymap = new HashMap(); + keymap = new HashMap(); keymap.put(0x08, KeyEvent.KEYCODE_BACK); // vk_back keymap.put(0x09, KeyEvent.KEYCODE_TAB); // vk_tab keymap.put(0x0d, KeyEvent.KEYCODE_ENTER); // vk_return @@ -203,7 +209,6 @@ keymap.put(0x79, KeyEvent.KEYCODE_F10); // vk_f10 keymap.put(0x7a, KeyEvent.KEYCODE_F11); // vk_f11 keymap.put(0x7b, KeyEvent.KEYCODE_F12); // vk_f12 - // bind to the monitor service Intent intent = new Intent("com.five_ten_sg.connectbot.monitor.MonitorService"); parent.bindService(intent, monitor_connection, Context.BIND_AUTO_CREATE); @@ -302,10 +307,12 @@ arg[2] = lines; arg[3] = columns; int base = 4; + for (int i = 0; i < lines; i++) { System.arraycopy(buffer.charArray[buffer.screenBase + i], 0, arg, base, columns); base += columns; } + monitorWrite(cmd, arg); } @@ -343,6 +350,7 @@ modified = false; sendScreen(MONITOR_CMD_SCREENCHANGE); } + if (moved) { moved = false; cursorMoved(); @@ -363,9 +371,11 @@ Log.i(TAG, "setField()"); char[] da = new char[data.length - offset]; int i; - for (i=0; i mnemonics; public vt320x5250() { - this(80,24); + this(80, 24); } public vt320x5250(int width, int height) { @@ -84,7 +84,6 @@ controls.put(0x09, KEY_TAB); controls.put(0x0d, KEY_ENTER); controls.put(0x1b, KEY_ESCAPE); - mnemonics = new HashMap(); mnemonics.put(KEY_PAUSE , "[attn]"); mnemonics.put(KEY_F1 , "[pf1]"); @@ -147,6 +146,7 @@ @Override public void write(byte[] b) { if (bridge.monitor != null) bridge.monitor.hostData(b); + screen52.sendKeys(new String(b)); } @Override @@ -156,6 +156,7 @@ } else { if (bridge.monitor != null) bridge.monitor.hostData(b); + screen52.sendKeys(new String(new byte[] {(byte)b})); } } @@ -163,8 +164,10 @@ public void keyPressed(int keyCode, char keyChar, int modifiers) { if (mnemonics.containsKey(keyCode)) { String s = mnemonics.get(keyCode); + if (s != "") { if (bridge.monitor != null) bridge.monitor.hostData(s.getBytes()); + screen52.sendKeys(s); } } @@ -178,11 +181,13 @@ @Override public void putChar(int c, int l, char ch, int attributes) { if (bridge.monitor != null) bridge.monitor.screenChanged(l, c); + super.putChar(c, l, ch, attributes); } @Override public void setCursorPosition(int c, int l) { if (bridge.monitor != null) bridge.monitor.cursorMove(l, c); + super.setCursorPosition(c, l); redraw(); } @@ -190,23 +195,23 @@ public TN5250() { - super(); + super(); } /** * @return protocol part of the URI */ - public static String getProtocolName() { - return PROTOCOL; - } + public static String getProtocolName() { + return PROTOCOL; + } /** * Encode the current transport into a URI that can be passed via intent calls. * @return URI to host */ - public Uri getUri(String input) { + public Uri getUri(String input) { Matcher matcher = hostmask.matcher(input); if (!matcher.matches()) @@ -241,23 +246,26 @@ .append(Uri.encode(input)); Uri uri = Uri.parse(sb.toString()); return uri; - } + } - /** - * Causes transport to connect to the target host. After connecting but before a - * session is started, must call back to {@link TerminalBridge#onConnected()}. - * After that call a session may be opened. - */ - @Override - public void connect() { + /** + * Causes transport to connect to the target host. After connecting but before a + * session is started, must call back to {@link TerminalBridge#onConnected()}. + * After that call a session may be opened. + */ + @Override + public void connect() { screen52 = new Screen5250(); handler = new tnvt(screen52, true, false, bridge, manager); String encryption = host.getEncryption5250(); + if ((encryption == null) || (encryption.length() == 0)) encryption = "NONE"; + screen52.setVT(handler); screen52.setBuffer(buffer); connected = handler.connect(host.getHostname(), host.getPort(), encryption, homeDirectory, buffer); + if (connected) bridge.onConnected(); } diff -r 6a0ad4d384ea -r 77ac18bc1b2f src/com/five_ten_sg/connectbot/transport/Telnet.java --- a/src/com/five_ten_sg/connectbot/transport/Telnet.java Wed Jun 18 13:00:19 2014 -0700 +++ b/src/com/five_ten_sg/connectbot/transport/Telnet.java Wed Jun 18 13:03:01 2014 -0700 @@ -170,9 +170,11 @@ @Override public boolean willBlock() { if (is == null) return true; + try { return is.available() == 0; - } catch (Exception e) { + } + catch (Exception e) { return true; } } diff -r 6a0ad4d384ea -r 77ac18bc1b2f src/com/five_ten_sg/connectbot/transport/TransportFactory.java --- a/src/com/five_ten_sg/connectbot/transport/TransportFactory.java Wed Jun 18 13:00:19 2014 -0700 +++ b/src/com/five_ten_sg/connectbot/transport/TransportFactory.java Wed Jun 18 13:03:01 2014 -0700 @@ -68,7 +68,9 @@ "Attempting to discover URI for protocol=%s on input=%s", protocol, input)); AbsTransport t = getTransport(protocol); + if (t == null) return null; + return t.getUri(input); } @@ -85,7 +87,9 @@ public static boolean canForwardPorts(String protocol) { AbsTransport t = getTransport(protocol); + if (t == null) return false; + return t.canForwardPorts(); } @@ -96,7 +100,9 @@ */ public static String getFormatHint(String protocol, Context context) { AbsTransport t = getTransport(protocol); + if (t == null) return "???"; + return t.getFormatHint(context); } diff -r 6a0ad4d384ea -r 77ac18bc1b2f src/de/mud/terminal/vt320.java --- a/src/de/mud/terminal/vt320.java Wed Jun 18 13:00:19 2014 -0700 +++ b/src/de/mud/terminal/vt320.java Wed Jun 18 13:03:01 2014 -0700 @@ -72,7 +72,9 @@ // ignore line and column, just send the bytes to the host. int n = d.length; byte [] b = new byte [n]; - for (int i=0; i mnemonicMap = new HashMap(); - static { + public static final HashMap mnemonicMap = new HashMap(); + static { mnemonicMap.put("[backspace]", 1001); mnemonicMap.put("[backtab]", 1002); mnemonicMap.put("[up]", 1003); mnemonicMap.put("[down]", 1004); mnemonicMap.put("[left]", 1005); - mnemonicMap.put("[right]", 1006); mnemonicMap.put("[delete]", 1007); mnemonicMap.put("[tab]", 1008); mnemonicMap.put("[eof]", 1009); mnemonicMap.put("[eraseeof]", 1010); - mnemonicMap.put("[erasefld]", 1011); mnemonicMap.put("[insert]", 1012); mnemonicMap.put("[home]", 1013); mnemonicMap.put("[keypad0]", 1014); mnemonicMap.put("[keypad1]", 1015); - mnemonicMap.put("[keypad2]", 1016); mnemonicMap.put("[keypad3]", 1017); mnemonicMap.put("[keypad4]", 1018); mnemonicMap.put("[keypad5]", 1019); mnemonicMap.put("[keypad6]", 1020); - mnemonicMap.put("[keypad7]", 1021); mnemonicMap.put("[keypad8]", 1022); mnemonicMap.put("[keypad9]", 1023); mnemonicMap.put("[keypad.]", 1024); mnemonicMap.put("[keypad,]", 1025); - mnemonicMap.put("[keypad-]", 1026); mnemonicMap.put("[fldext]", 1027); mnemonicMap.put("[field+]", 1028); mnemonicMap.put("[field-]", 1029); mnemonicMap.put("[bof]", 1030); - mnemonicMap.put("[enter]", 0xF1); mnemonicMap.put("[pf1]", 0x31); mnemonicMap.put("[pf2]", 0x32); mnemonicMap.put("[pf3]", 0x33); mnemonicMap.put("[pf4]", 0x34); - mnemonicMap.put("[pf5]", 0x35); mnemonicMap.put("[pf6]", 0x36); mnemonicMap.put("[pf7]", 0x37); mnemonicMap.put("[pf8]", 0x38); mnemonicMap.put("[pf9]", 0x39); - mnemonicMap.put("[pf10]", 0x3A); mnemonicMap.put("[pf11]", 0x3B); mnemonicMap.put("[pf12]", 0x3C); mnemonicMap.put("[pf13]", 0xB1); mnemonicMap.put("[pf14]", 0xB2); - mnemonicMap.put("[pf15]", 0xB3); mnemonicMap.put("[pf16]", 0xB4); mnemonicMap.put("[pf17]", 0xB5); mnemonicMap.put("[pf18]", 0xB6); mnemonicMap.put("[pf19]", 0xB7); - mnemonicMap.put("[pf20]", 0xB8); mnemonicMap.put("[pf21]", 0xB9); mnemonicMap.put("[pf22]", 0xBA); mnemonicMap.put("[pf23]", 0xBB); mnemonicMap.put("[pf24]", 0xBC); - mnemonicMap.put("[clear]", 0xBD); mnemonicMap.put("[help]", 0xF3); mnemonicMap.put("[pgup]", 0xF4); mnemonicMap.put("[pgdown]", 0xF5); mnemonicMap.put("[rollleft]", 0xD9); - mnemonicMap.put("[rollright]", 0xDA); mnemonicMap.put("[hostprint]", 0xF6); mnemonicMap.put("[pa1]", 0x6C); mnemonicMap.put("[pa2]", 0x6E); mnemonicMap.put("[pa3]", 0x6B); - mnemonicMap.put("[sysreq]", 1031); mnemonicMap.put("[reset]", 1032); mnemonicMap.put("[nextword]", 1033); mnemonicMap.put("[prevword]", 1034); mnemonicMap.put("[copy]", 1035); - mnemonicMap.put("[paste]", 1036); mnemonicMap.put("[attn]", 1037); mnemonicMap.put("[markup]", 1038); mnemonicMap.put("[markdown]", 1039); mnemonicMap.put("[markleft]", 1040); - mnemonicMap.put("[markright]", 1041); mnemonicMap.put("[dupfield]", 1042); mnemonicMap.put("[newline]", 1043); mnemonicMap.put("[jumpnext]", 5000); mnemonicMap.put("[jumpprev]", 5001); - mnemonicMap.put("[opennew]", 5002); mnemonicMap.put("[togcon]", 5003); mnemonicMap.put("[hotspots]", 5004); mnemonicMap.put("[gui]", 5005); mnemonicMap.put("[dspmsgs]", 5006); - mnemonicMap.put("[dspattr]", 5007); mnemonicMap.put("[print]", 5008); mnemonicMap.put("[cursor]", 5009); mnemonicMap.put("[debug]", 5010); mnemonicMap.put("[close]", 5011); - mnemonicMap.put("[transfer]", 5012); mnemonicMap.put("[e-mail]", 5013); mnemonicMap.put("[runscript]", 5014); mnemonicMap.put("[spoolfile]", 5015); mnemonicMap.put("[quick-mail]", 5016); - mnemonicMap.put("[open-same]", 5017); mnemonicMap.put("[fastcursordown]", 5018); mnemonicMap.put("[fastcursorup]", 5019); @@ -308,301 +290,301 @@ mnemonicMap.put("[fastcursorleft]", 5021); }; - public static final String MNEMONIC_CLEAR = "[clear]"; - public static final String MNEMONIC_ENTER = "[enter]"; - public static final String MNEMONIC_HELP = "[help]"; - public static final String MNEMONIC_PAGE_DOWN = "[pgdown]"; - public static final String MNEMONIC_PAGE_UP = "[pgup]"; - public static final String MNEMONIC_PRINT = "[hostprint]"; - public static final String MNEMONIC_PF1 = "[pf1]"; - public static final String MNEMONIC_PF2 = "[pf2]"; - public static final String MNEMONIC_PF3 = "[pf3]"; - public static final String MNEMONIC_PF4 = "[pf4]"; - public static final String MNEMONIC_PF5 = "[pf5]"; - public static final String MNEMONIC_PF6 = "[pf6]"; - public static final String MNEMONIC_PF7 = "[pf7]"; - public static final String MNEMONIC_PF8 = "[pf8]"; - public static final String MNEMONIC_PF9 = "[pf9]"; - public static final String MNEMONIC_PF10 = "[pf10]"; - public static final String MNEMONIC_PF11 = "[pf11]"; - public static final String MNEMONIC_PF12 = "[pf12]"; - public static final String MNEMONIC_PF13 = "[pf13]"; - public static final String MNEMONIC_PF14 = "[pf14]"; - public static final String MNEMONIC_PF15 = "[pf15]"; - public static final String MNEMONIC_PF16 = "[pf16]"; - public static final String MNEMONIC_PF17 = "[pf17]"; - public static final String MNEMONIC_PF18 = "[pf18]"; - public static final String MNEMONIC_PF19 = "[pf19]"; - public static final String MNEMONIC_PF20 = "[pf20]"; - public static final String MNEMONIC_PF21 = "[pf21]"; - public static final String MNEMONIC_PF22 = "[pf22]"; - public static final String MNEMONIC_PF23 = "[pf23]"; - public static final String MNEMONIC_PF24 = "[pf24]"; - public static final String MNEMONIC_BACK_SPACE = "[backspace]"; - public static final String MNEMONIC_BACK_TAB = "[backtab]"; - public static final String MNEMONIC_UP = "[up]"; - public static final String MNEMONIC_DOWN = "[down]"; - public static final String MNEMONIC_LEFT = "[left]"; - public static final String MNEMONIC_RIGHT = "[right]"; - public static final String MNEMONIC_DELETE = "[delete]"; - public static final String MNEMONIC_TAB = "[tab]"; - public static final String MNEMONIC_END_OF_FIELD = "[eof]"; - public static final String MNEMONIC_ERASE_EOF = "[eraseeof]"; - public static final String MNEMONIC_ERASE_FIELD = "[erasefld]"; - public static final String MNEMONIC_INSERT = "[insert]"; - public static final String MNEMONIC_HOME = "[home]"; - public static final String MNEMONIC_KEYPAD0 = "[keypad0]"; - public static final String MNEMONIC_KEYPAD1 = "[keypad1]"; - public static final String MNEMONIC_KEYPAD2 = "[keypad2]"; - public static final String MNEMONIC_KEYPAD3 = "[keypad3]"; - public static final String MNEMONIC_KEYPAD4 = "[keypad4]"; - public static final String MNEMONIC_KEYPAD5 = "[keypad5]"; - public static final String MNEMONIC_KEYPAD6 = "[keypad6]"; - public static final String MNEMONIC_KEYPAD7 = "[keypad7]"; - public static final String MNEMONIC_KEYPAD8 = "[keypad8]"; - public static final String MNEMONIC_KEYPAD9 = "[keypad9]"; - public static final String MNEMONIC_KEYPAD_PERIOD = "[keypad.]"; - public static final String MNEMONIC_KEYPAD_COMMA = "[keypad,]"; - public static final String MNEMONIC_KEYPAD_MINUS = "[keypad-]"; - public static final String MNEMONIC_FIELD_EXIT = "[fldext]"; - public static final String MNEMONIC_FIELD_PLUS = "[field+]"; - public static final String MNEMONIC_FIELD_MINUS = "[field-]"; - public static final String MNEMONIC_BEGIN_OF_FIELD = "[bof]"; - public static final String MNEMONIC_PA1 = "[pa1]"; - public static final String MNEMONIC_PA2 = "[pa2]"; - public static final String MNEMONIC_PA3 = "[pa3]"; - public static final String MNEMONIC_SYSREQ = "[sysreq]"; - public static final String MNEMONIC_RESET = "[reset]"; - public static final String MNEMONIC_NEXTWORD = "[nextword]"; - public static final String MNEMONIC_PREVWORD = "[prevword]"; - public static final String MNEMONIC_ATTN = "[attn]"; - public static final String MNEMONIC_MARK_LEFT = "[markleft]"; - public static final String MNEMONIC_MARK_RIGHT = "[markright]"; - public static final String MNEMONIC_MARK_UP = "[markup]"; - public static final String MNEMONIC_MARK_DOWN = "[markdown]"; - public static final String MNEMONIC_DUP_FIELD = "[dupfield]"; - public static final String MNEMONIC_NEW_LINE = "[newline]"; - public static final String MNEMONIC_JUMP_NEXT = "[jumpnext]"; - public static final String MNEMONIC_JUMP_PREV = "[jumpprev]"; - public static final String MNEMONIC_OPEN_NEW = "[opennew]"; - public static final String MNEMONIC_TOGGLE_CONNECTION = "[togcon]"; - public static final String MNEMONIC_HOTSPOTS = "[hotspots]"; - public static final String MNEMONIC_GUI = "[gui]"; - public static final String MNEMONIC_DISP_MESSAGES = "[dspmsgs]"; - public static final String MNEMONIC_DISP_ATTRIBUTES = "[dspattr]"; - public static final String MNEMONIC_PRINT_SCREEN = "[print]"; - public static final String MNEMONIC_CURSOR = "[cursor]"; - public static final String MNEMONIC_DEBUG = "[debug]"; - public static final String MNEMONIC_CLOSE = "[close]"; - public static final String MNEMONIC_E_MAIL = "[e-mail]"; - public static final String MNEMONIC_COPY = "[copy]"; - public static final String MNEMONIC_PASTE = "[paste]"; - public static final String MNEMONIC_FILE_TRANSFER = "[transfer]"; - public static final String MNEMONIC_RUN_SCRIPT = "[runscript]"; - public static final String MNEMONIC_SPOOL_FILE = "[spoolfile]"; - public static final String MNEMONIC_QUICK_MAIL = "[quick-mail]"; - public static final String MNEMONIC_OPEN_SAME = "[open-same]"; - public static final String MNEMONIC_FAST_CURSOR_DOWN = "[fastcursordown]"; - public static final String MNEMONIC_FAST_CURSOR_UP = "[fastcursorup]"; - public static final String MNEMONIC_FAST_CURSOR_RIGHT = "[fastcursorright]"; - public static final String MNEMONIC_FAST_CURSOR_LEFT = "[fastcursorleft]"; + public static final String MNEMONIC_CLEAR = "[clear]"; + public static final String MNEMONIC_ENTER = "[enter]"; + public static final String MNEMONIC_HELP = "[help]"; + public static final String MNEMONIC_PAGE_DOWN = "[pgdown]"; + public static final String MNEMONIC_PAGE_UP = "[pgup]"; + public static final String MNEMONIC_PRINT = "[hostprint]"; + public static final String MNEMONIC_PF1 = "[pf1]"; + public static final String MNEMONIC_PF2 = "[pf2]"; + public static final String MNEMONIC_PF3 = "[pf3]"; + public static final String MNEMONIC_PF4 = "[pf4]"; + public static final String MNEMONIC_PF5 = "[pf5]"; + public static final String MNEMONIC_PF6 = "[pf6]"; + public static final String MNEMONIC_PF7 = "[pf7]"; + public static final String MNEMONIC_PF8 = "[pf8]"; + public static final String MNEMONIC_PF9 = "[pf9]"; + public static final String MNEMONIC_PF10 = "[pf10]"; + public static final String MNEMONIC_PF11 = "[pf11]"; + public static final String MNEMONIC_PF12 = "[pf12]"; + public static final String MNEMONIC_PF13 = "[pf13]"; + public static final String MNEMONIC_PF14 = "[pf14]"; + public static final String MNEMONIC_PF15 = "[pf15]"; + public static final String MNEMONIC_PF16 = "[pf16]"; + public static final String MNEMONIC_PF17 = "[pf17]"; + public static final String MNEMONIC_PF18 = "[pf18]"; + public static final String MNEMONIC_PF19 = "[pf19]"; + public static final String MNEMONIC_PF20 = "[pf20]"; + public static final String MNEMONIC_PF21 = "[pf21]"; + public static final String MNEMONIC_PF22 = "[pf22]"; + public static final String MNEMONIC_PF23 = "[pf23]"; + public static final String MNEMONIC_PF24 = "[pf24]"; + public static final String MNEMONIC_BACK_SPACE = "[backspace]"; + public static final String MNEMONIC_BACK_TAB = "[backtab]"; + public static final String MNEMONIC_UP = "[up]"; + public static final String MNEMONIC_DOWN = "[down]"; + public static final String MNEMONIC_LEFT = "[left]"; + public static final String MNEMONIC_RIGHT = "[right]"; + public static final String MNEMONIC_DELETE = "[delete]"; + public static final String MNEMONIC_TAB = "[tab]"; + public static final String MNEMONIC_END_OF_FIELD = "[eof]"; + public static final String MNEMONIC_ERASE_EOF = "[eraseeof]"; + public static final String MNEMONIC_ERASE_FIELD = "[erasefld]"; + public static final String MNEMONIC_INSERT = "[insert]"; + public static final String MNEMONIC_HOME = "[home]"; + public static final String MNEMONIC_KEYPAD0 = "[keypad0]"; + public static final String MNEMONIC_KEYPAD1 = "[keypad1]"; + public static final String MNEMONIC_KEYPAD2 = "[keypad2]"; + public static final String MNEMONIC_KEYPAD3 = "[keypad3]"; + public static final String MNEMONIC_KEYPAD4 = "[keypad4]"; + public static final String MNEMONIC_KEYPAD5 = "[keypad5]"; + public static final String MNEMONIC_KEYPAD6 = "[keypad6]"; + public static final String MNEMONIC_KEYPAD7 = "[keypad7]"; + public static final String MNEMONIC_KEYPAD8 = "[keypad8]"; + public static final String MNEMONIC_KEYPAD9 = "[keypad9]"; + public static final String MNEMONIC_KEYPAD_PERIOD = "[keypad.]"; + public static final String MNEMONIC_KEYPAD_COMMA = "[keypad,]"; + public static final String MNEMONIC_KEYPAD_MINUS = "[keypad-]"; + public static final String MNEMONIC_FIELD_EXIT = "[fldext]"; + public static final String MNEMONIC_FIELD_PLUS = "[field+]"; + public static final String MNEMONIC_FIELD_MINUS = "[field-]"; + public static final String MNEMONIC_BEGIN_OF_FIELD = "[bof]"; + public static final String MNEMONIC_PA1 = "[pa1]"; + public static final String MNEMONIC_PA2 = "[pa2]"; + public static final String MNEMONIC_PA3 = "[pa3]"; + public static final String MNEMONIC_SYSREQ = "[sysreq]"; + public static final String MNEMONIC_RESET = "[reset]"; + public static final String MNEMONIC_NEXTWORD = "[nextword]"; + public static final String MNEMONIC_PREVWORD = "[prevword]"; + public static final String MNEMONIC_ATTN = "[attn]"; + public static final String MNEMONIC_MARK_LEFT = "[markleft]"; + public static final String MNEMONIC_MARK_RIGHT = "[markright]"; + public static final String MNEMONIC_MARK_UP = "[markup]"; + public static final String MNEMONIC_MARK_DOWN = "[markdown]"; + public static final String MNEMONIC_DUP_FIELD = "[dupfield]"; + public static final String MNEMONIC_NEW_LINE = "[newline]"; + public static final String MNEMONIC_JUMP_NEXT = "[jumpnext]"; + public static final String MNEMONIC_JUMP_PREV = "[jumpprev]"; + public static final String MNEMONIC_OPEN_NEW = "[opennew]"; + public static final String MNEMONIC_TOGGLE_CONNECTION = "[togcon]"; + public static final String MNEMONIC_HOTSPOTS = "[hotspots]"; + public static final String MNEMONIC_GUI = "[gui]"; + public static final String MNEMONIC_DISP_MESSAGES = "[dspmsgs]"; + public static final String MNEMONIC_DISP_ATTRIBUTES = "[dspattr]"; + public static final String MNEMONIC_PRINT_SCREEN = "[print]"; + public static final String MNEMONIC_CURSOR = "[cursor]"; + public static final String MNEMONIC_DEBUG = "[debug]"; + public static final String MNEMONIC_CLOSE = "[close]"; + public static final String MNEMONIC_E_MAIL = "[e-mail]"; + public static final String MNEMONIC_COPY = "[copy]"; + public static final String MNEMONIC_PASTE = "[paste]"; + public static final String MNEMONIC_FILE_TRANSFER = "[transfer]"; + public static final String MNEMONIC_RUN_SCRIPT = "[runscript]"; + public static final String MNEMONIC_SPOOL_FILE = "[spoolfile]"; + public static final String MNEMONIC_QUICK_MAIL = "[quick-mail]"; + public static final String MNEMONIC_OPEN_SAME = "[open-same]"; + public static final String MNEMONIC_FAST_CURSOR_DOWN = "[fastcursordown]"; + public static final String MNEMONIC_FAST_CURSOR_UP = "[fastcursorup]"; + public static final String MNEMONIC_FAST_CURSOR_RIGHT = "[fastcursorright]"; + public static final String MNEMONIC_FAST_CURSOR_LEFT = "[fastcursorleft]"; - // AID-Generating Keys - public static final int AID_CLEAR = 0xBD; - public static final int AID_ENTER = 0xF1; - public static final int AID_HELP = 0xF3; - public static final int AID_ROLL_UP = 0xF4; - public static final int AID_ROLL_DOWN = 0xF5; - public static final int AID_ROLL_LEFT = 0xD9; - public static final int AID_ROLL_RIGHT = 0xDA; - public static final int AID_PRINT = 0xF6; - public static final int AID_PF1 = 0x31; - public static final int AID_PF2 = 0x32; - public static final int AID_PF3 = 0x33; - public static final int AID_PF4 = 0x34; - public static final int AID_PF5 = 0x35; - public static final int AID_PF6 = 0x36; - public static final int AID_PF7 = 0x37; - public static final int AID_PF8 = 0x38; - public static final int AID_PF9 = 0x39; - public static final int AID_PF10 = 0x3A; - public static final int AID_PF11 = 0x3B; - public static final int AID_PF12 = 0x3C; - public static final int AID_PF13 = 0xB1; - public static final int AID_PF14 = 0xB2; - public static final int AID_PF15 = 0xB3; - public static final int AID_PF16 = 0xB4; - public static final int AID_PF17 = 0xB5; - public static final int AID_PF18 = 0xB6; - public static final int AID_PF19 = 0xB7; - public static final int AID_PF20 = 0xB8; - public static final int AID_PF21 = 0xB9; - public static final int AID_PF22 = 0xBA; - public static final int AID_PF23 = 0xBB; - public static final int AID_PF24 = 0xBC; + // AID-Generating Keys + public static final int AID_CLEAR = 0xBD; + public static final int AID_ENTER = 0xF1; + public static final int AID_HELP = 0xF3; + public static final int AID_ROLL_UP = 0xF4; + public static final int AID_ROLL_DOWN = 0xF5; + public static final int AID_ROLL_LEFT = 0xD9; + public static final int AID_ROLL_RIGHT = 0xDA; + public static final int AID_PRINT = 0xF6; + public static final int AID_PF1 = 0x31; + public static final int AID_PF2 = 0x32; + public static final int AID_PF3 = 0x33; + public static final int AID_PF4 = 0x34; + public static final int AID_PF5 = 0x35; + public static final int AID_PF6 = 0x36; + public static final int AID_PF7 = 0x37; + public static final int AID_PF8 = 0x38; + public static final int AID_PF9 = 0x39; + public static final int AID_PF10 = 0x3A; + public static final int AID_PF11 = 0x3B; + public static final int AID_PF12 = 0x3C; + public static final int AID_PF13 = 0xB1; + public static final int AID_PF14 = 0xB2; + public static final int AID_PF15 = 0xB3; + public static final int AID_PF16 = 0xB4; + public static final int AID_PF17 = 0xB5; + public static final int AID_PF18 = 0xB6; + public static final int AID_PF19 = 0xB7; + public static final int AID_PF20 = 0xB8; + public static final int AID_PF21 = 0xB9; + public static final int AID_PF22 = 0xBA; + public static final int AID_PF23 = 0xBB; + public static final int AID_PF24 = 0xBC; - // negative response categories - public static final int NR_REQUEST_REJECT = 0x08; - public static final int NR_REQUEST_ERROR = 0x10; - public static final int NR_STATE_ERROR = 0x20; - public static final int NR_USAGE_ERROR = 0x40; - public static final int NR_PATH_ERROR = 0x80; + // negative response categories + public static final int NR_REQUEST_REJECT = 0x08; + public static final int NR_REQUEST_ERROR = 0x10; + public static final int NR_STATE_ERROR = 0x20; + public static final int NR_USAGE_ERROR = 0x40; + public static final int NR_PATH_ERROR = 0x80; - // commands - public static final byte CMD_WRITE_TO_DISPLAY = 0x11; // 17 - public static final byte CMD_CLEAR_UNIT = 0x40; // 64 - public static final byte CMD_CLEAR_UNIT_ALTERNATE = 0x20; // 32 - public static final byte CMD_CLEAR_FORMAT_TABLE = 0x50; // 80 - public static final byte CMD_READ_INPUT_FIELDS = 0x42; // 66 - public static final byte CMD_READ_MDT_FIELDS = 0x52; // 82 - public static final byte CMD_READ_MDT_IMMEDIATE_ALT = (byte)0x83; // 131 + // commands + public static final byte CMD_WRITE_TO_DISPLAY = 0x11; // 17 + public static final byte CMD_CLEAR_UNIT = 0x40; // 64 + public static final byte CMD_CLEAR_UNIT_ALTERNATE = 0x20; // 32 + public static final byte CMD_CLEAR_FORMAT_TABLE = 0x50; // 80 + public static final byte CMD_READ_INPUT_FIELDS = 0x42; // 66 + public static final byte CMD_READ_MDT_FIELDS = 0x52; // 82 + public static final byte CMD_READ_MDT_IMMEDIATE_ALT = (byte)0x83; // 131 // public static final byte CMD_READ_MDT_FIELDS_ALT = (byte)0x82; // 130 // public static final byte CMD_READ_IMMEDIATE = 0x72; // 114 - public static final byte CMD_READ_SCREEN_IMMEDIATE = 0x62; // 98 - public static final byte CMD_WRITE_STRUCTURED_FIELD = (byte)243; // (byte)0xF3 -13 - public static final byte CMD_SAVE_SCREEN = 0x02; // 02 - public static final byte CMD_RESTORE_SCREEN = 0x12; // 18 - public static final byte CMD_WRITE_ERROR_CODE = 0x21; // 33 - public static final byte CMD_WRITE_ERROR_CODE_TO_WINDOW = 0x22; // 34 - public static final byte CMD_ROLL = 0x23; // 35 - public static final byte CMD_READ_SCREEN_TO_PRINT = (byte)0x66; // 102 + public static final byte CMD_READ_SCREEN_IMMEDIATE = 0x62; // 98 + public static final byte CMD_WRITE_STRUCTURED_FIELD = (byte)243; // (byte)0xF3 -13 + public static final byte CMD_SAVE_SCREEN = 0x02; // 02 + public static final byte CMD_RESTORE_SCREEN = 0x12; // 18 + public static final byte CMD_WRITE_ERROR_CODE = 0x21; // 33 + public static final byte CMD_WRITE_ERROR_CODE_TO_WINDOW = 0x22; // 34 + public static final byte CMD_ROLL = 0x23; // 35 + public static final byte CMD_READ_SCREEN_TO_PRINT = (byte)0x66; // 102 - // PLANES - public static final int PLANE_TEXT = 1; - public static final int PLANE_COLOR = 2; - public static final int PLANE_FIELD = 3; - public static final int PLANE_EXTENDED = 4; - public static final int PLANE_EXTENDED_GRAPHIC = 5; - public static final int PLANE_EXTENDED_FIELD = 6; - public static final int PLANE_ATTR = 7; - public static final int PLANE_IS_ATTR_PLACE = 8; + // PLANES + public static final int PLANE_TEXT = 1; + public static final int PLANE_COLOR = 2; + public static final int PLANE_FIELD = 3; + public static final int PLANE_EXTENDED = 4; + public static final int PLANE_EXTENDED_GRAPHIC = 5; + public static final int PLANE_EXTENDED_FIELD = 6; + public static final int PLANE_ATTR = 7; + public static final int PLANE_IS_ATTR_PLACE = 8; - // COLOR_BG - public static final char COLOR_BG_BLACK = 0; - public static final char COLOR_BG_BLUE = 1; - public static final char COLOR_BG_GREEN = 2; - public static final char COLOR_BG_CYAN = 3; - public static final char COLOR_BG_RED = 4; - public static final char COLOR_BG_MAGENTA = 5; - public static final char COLOR_BG_YELLOW = 6; - public static final char COLOR_BG_WHITE = 7; + // COLOR_BG + public static final char COLOR_BG_BLACK = 0; + public static final char COLOR_BG_BLUE = 1; + public static final char COLOR_BG_GREEN = 2; + public static final char COLOR_BG_CYAN = 3; + public static final char COLOR_BG_RED = 4; + public static final char COLOR_BG_MAGENTA = 5; + public static final char COLOR_BG_YELLOW = 6; + public static final char COLOR_BG_WHITE = 7; - // COLOR_FG - public static final char COLOR_FG_BLACK = 0; - public static final char COLOR_FG_BLUE = 1; - public static final char COLOR_FG_GREEN = 2; - public static final char COLOR_FG_CYAN = 3; - public static final char COLOR_FG_RED = 4; - public static final char COLOR_FG_MAGENTA = 5; - public static final char COLOR_FG_YELLOW = 6; - public static final char COLOR_FG_WHITE = 7; - public static final char COLOR_FG_GRAY = 8; - public static final char COLOR_FG_LIGHT_BLUE = 9; - public static final char COLOR_FG_LIGHT_GREEN = 0xA; - public static final char COLOR_FG_LIGHT_CYAN = 0xB; - public static final char COLOR_FG_LIGHT_RED = 0xC; - public static final char COLOR_FG_LIGHT_MAGENTA = 0xD; - public static final char COLOR_FG_BROWN = 0xE; - public static final char COLOR_FG_WHITE_HIGH = 0xF; + // COLOR_FG + public static final char COLOR_FG_BLACK = 0; + public static final char COLOR_FG_BLUE = 1; + public static final char COLOR_FG_GREEN = 2; + public static final char COLOR_FG_CYAN = 3; + public static final char COLOR_FG_RED = 4; + public static final char COLOR_FG_MAGENTA = 5; + public static final char COLOR_FG_YELLOW = 6; + public static final char COLOR_FG_WHITE = 7; + public static final char COLOR_FG_GRAY = 8; + public static final char COLOR_FG_LIGHT_BLUE = 9; + public static final char COLOR_FG_LIGHT_GREEN = 0xA; + public static final char COLOR_FG_LIGHT_CYAN = 0xB; + public static final char COLOR_FG_LIGHT_RED = 0xC; + public static final char COLOR_FG_LIGHT_MAGENTA = 0xD; + public static final char COLOR_FG_BROWN = 0xE; + public static final char COLOR_FG_WHITE_HIGH = 0xF; - public static final int EXTENDED_5250_REVERSE = 0x10; - public static final int EXTENDED_5250_UNDERLINE = 0x08; - public static final int EXTENDED_5250_BLINK = 0x04; - public static final int EXTENDED_5250_COL_SEP = 0x02; - public static final int EXTENDED_5250_NON_DSP = 0x01; + public static final int EXTENDED_5250_REVERSE = 0x10; + public static final int EXTENDED_5250_UNDERLINE = 0x08; + public static final int EXTENDED_5250_BLINK = 0x04; + public static final int EXTENDED_5250_COL_SEP = 0x02; + public static final int EXTENDED_5250_NON_DSP = 0x01; - public static final char ATTR_32 = (COLOR_BG_BLACK << 8 & 0xff00) | - (COLOR_FG_GREEN & 0xff); - public static final char ATTR_33 = (COLOR_BG_GREEN << 8 & 0xff00) | - (COLOR_FG_BLACK & 0xff); - public static final char ATTR_34 = (COLOR_BG_BLACK << 8 & 0xff00) | - (COLOR_FG_WHITE & 0xff); - public static final char ATTR_35 = (COLOR_BG_WHITE << 8 & 0xff00) | - (COLOR_FG_BLACK & 0xff); - public static final char ATTR_36 = (COLOR_BG_BLACK << 8 & 0xff00) | - (COLOR_FG_GREEN & 0xff); - public static final char ATTR_37 = (COLOR_BG_GREEN << 8 & 0xff00) | - (COLOR_FG_BLACK & 0xff); - public static final char ATTR_38 = (COLOR_BG_BLACK << 8 & 0xff00) | - (COLOR_FG_WHITE & 0xff); - public static final char ATTR_40 = (COLOR_BG_BLACK << 8 & 0xff00) | - (COLOR_FG_RED & 0xff); - public static final char ATTR_41 = (COLOR_BG_RED << 8 & 0xff00) | - (COLOR_FG_BLACK & 0xff); - public static final char ATTR_42 = (COLOR_BG_BLACK << 8 & 0xff00) | - (COLOR_FG_RED & 0xff); - public static final char ATTR_43 = (COLOR_BG_RED << 8 & 0xff00) | - (COLOR_FG_BLACK & 0xff); + public static final char ATTR_32 = (COLOR_BG_BLACK << 8 & 0xff00) | + (COLOR_FG_GREEN & 0xff); + public static final char ATTR_33 = (COLOR_BG_GREEN << 8 & 0xff00) | + (COLOR_FG_BLACK & 0xff); + public static final char ATTR_34 = (COLOR_BG_BLACK << 8 & 0xff00) | + (COLOR_FG_WHITE & 0xff); + public static final char ATTR_35 = (COLOR_BG_WHITE << 8 & 0xff00) | + (COLOR_FG_BLACK & 0xff); + public static final char ATTR_36 = (COLOR_BG_BLACK << 8 & 0xff00) | + (COLOR_FG_GREEN & 0xff); + public static final char ATTR_37 = (COLOR_BG_GREEN << 8 & 0xff00) | + (COLOR_FG_BLACK & 0xff); + public static final char ATTR_38 = (COLOR_BG_BLACK << 8 & 0xff00) | + (COLOR_FG_WHITE & 0xff); + public static final char ATTR_40 = (COLOR_BG_BLACK << 8 & 0xff00) | + (COLOR_FG_RED & 0xff); + public static final char ATTR_41 = (COLOR_BG_RED << 8 & 0xff00) | + (COLOR_FG_BLACK & 0xff); + public static final char ATTR_42 = (COLOR_BG_BLACK << 8 & 0xff00) | + (COLOR_FG_RED & 0xff); + public static final char ATTR_43 = (COLOR_BG_RED << 8 & 0xff00) | + (COLOR_FG_BLACK & 0xff); - public static final char ATTR_44 = (COLOR_BG_BLACK << 8 & 0xff00) | - (COLOR_FG_RED & 0xff); - public static final char ATTR_45 = ( COLOR_BG_RED << 8 & 0xff00) | - ( COLOR_FG_BLACK & 0xff); - public static final char ATTR_46 = (COLOR_BG_BLACK << 8 & 0xff00) | - (COLOR_FG_RED & 0xff); + public static final char ATTR_44 = (COLOR_BG_BLACK << 8 & 0xff00) | + (COLOR_FG_RED & 0xff); + public static final char ATTR_45 = (COLOR_BG_RED << 8 & 0xff00) | + (COLOR_FG_BLACK & 0xff); + public static final char ATTR_46 = (COLOR_BG_BLACK << 8 & 0xff00) | + (COLOR_FG_RED & 0xff); - public static final char ATTR_48 = (COLOR_BG_BLACK << 8 & 0xff00) | - (COLOR_FG_CYAN & 0xff); - public static final char ATTR_49 = (COLOR_BG_CYAN << 8 & 0xff00) | - (COLOR_FG_BLACK & 0xff); - public static final char ATTR_50 = (COLOR_BG_BLACK << 8 & 0xff00) | - (COLOR_FG_YELLOW & 0xff); + public static final char ATTR_48 = (COLOR_BG_BLACK << 8 & 0xff00) | + (COLOR_FG_CYAN & 0xff); + public static final char ATTR_49 = (COLOR_BG_CYAN << 8 & 0xff00) | + (COLOR_FG_BLACK & 0xff); + public static final char ATTR_50 = (COLOR_BG_BLACK << 8 & 0xff00) | + (COLOR_FG_YELLOW & 0xff); - public static final char ATTR_51 = (COLOR_BG_YELLOW << 8 & 0xff00) | - (COLOR_FG_BLACK & 0xff); - public static final char ATTR_52 = ( COLOR_BG_BLACK << 8 & 0xff00) | - ( COLOR_FG_CYAN & 0xff); - public static final char ATTR_53 = ( COLOR_BG_CYAN << 8 & 0xff00) | - ( COLOR_FG_BLACK & 0xff); - public static final char ATTR_54 = ( COLOR_BG_BLACK << 8 & 0xff00) | - ( COLOR_FG_YELLOW & 0xff); - public static final char ATTR_56 = ( COLOR_BG_BLACK << 8 & 0xff00) | - ( COLOR_FG_MAGENTA & 0xff); - public static final char ATTR_57 = ( COLOR_BG_MAGENTA << 8 & 0xff00) | - ( COLOR_FG_BLACK & 0xff); - public static final char ATTR_58 = ( COLOR_BG_BLACK << 8 & 0xff00) | - ( COLOR_FG_BLUE & 0xff); - public static final char ATTR_59 = ( COLOR_BG_BLUE << 8 & 0xff00) | - ( COLOR_FG_BLACK & 0xff); - public static final char ATTR_60 = ( COLOR_BG_BLACK << 8 & 0xff00) | - ( COLOR_FG_MAGENTA & 0xff); - public static final char ATTR_61 = ( COLOR_BG_MAGENTA << 8 & 0xff00) | - ( COLOR_FG_BLACK & 0xff); - public static final char ATTR_62 = ( COLOR_BG_BLACK << 8 & 0xff00) | - ( COLOR_FG_BLUE & 0xff); + public static final char ATTR_51 = (COLOR_BG_YELLOW << 8 & 0xff00) | + (COLOR_FG_BLACK & 0xff); + public static final char ATTR_52 = (COLOR_BG_BLACK << 8 & 0xff00) | + (COLOR_FG_CYAN & 0xff); + public static final char ATTR_53 = (COLOR_BG_CYAN << 8 & 0xff00) | + (COLOR_FG_BLACK & 0xff); + public static final char ATTR_54 = (COLOR_BG_BLACK << 8 & 0xff00) | + (COLOR_FG_YELLOW & 0xff); + public static final char ATTR_56 = (COLOR_BG_BLACK << 8 & 0xff00) | + (COLOR_FG_MAGENTA & 0xff); + public static final char ATTR_57 = (COLOR_BG_MAGENTA << 8 & 0xff00) | + (COLOR_FG_BLACK & 0xff); + public static final char ATTR_58 = (COLOR_BG_BLACK << 8 & 0xff00) | + (COLOR_FG_BLUE & 0xff); + public static final char ATTR_59 = (COLOR_BG_BLUE << 8 & 0xff00) | + (COLOR_FG_BLACK & 0xff); + public static final char ATTR_60 = (COLOR_BG_BLACK << 8 & 0xff00) | + (COLOR_FG_MAGENTA & 0xff); + public static final char ATTR_61 = (COLOR_BG_MAGENTA << 8 & 0xff00) | + (COLOR_FG_BLACK & 0xff); + public static final char ATTR_62 = (COLOR_BG_BLACK << 8 & 0xff00) | + (COLOR_FG_BLUE & 0xff); - public static final int NO_GUI = 0; - public static final int UPPER_LEFT = 1; - public static final int UPPER = 2; - public static final int UPPER_RIGHT = 3; - public static final int GUI_LEFT = 4; - public static final int GUI_RIGHT = 5; - public static final int LOWER_LEFT = 6; - public static final int BOTTOM = 7; - public static final int LOWER_RIGHT = 8; - public static final int FIELD_LEFT = 9; - public static final int FIELD_RIGHT = 10; - public static final int FIELD_MIDDLE = 11; - public static final int FIELD_ONE = 12; - public static final int BUTTON_LEFT = 13; - public static final int BUTTON_RIGHT = 14; - public static final int BUTTON_MIDDLE = 15; - public static final int BUTTON_ONE = 16; - public static final int BUTTON_LEFT_UP = 17; - public static final int BUTTON_RIGHT_UP = 18; - public static final int BUTTON_MIDDLE_UP = 19; - public static final int BUTTON_ONE_UP = 20; - public static final int BUTTON_LEFT_DN = 21; - public static final int BUTTON_RIGHT_DN = 22; - public static final int BUTTON_MIDDLE_DN = 23; - public static final int BUTTON_ONE_DN = 24; - public static final int BUTTON_LEFT_EB = 25; - public static final int BUTTON_RIGHT_EB = 26; - public static final int BUTTON_MIDDLE_EB = 27; - public static final int BUTTON_SB_UP = 28; - public static final int BUTTON_SB_DN = 29; - public static final int BUTTON_SB_GUIDE = 30; - public static final int BUTTON_SB_THUMB = 31; - public static final int BUTTON_LAST = 31; + public static final int NO_GUI = 0; + public static final int UPPER_LEFT = 1; + public static final int UPPER = 2; + public static final int UPPER_RIGHT = 3; + public static final int GUI_LEFT = 4; + public static final int GUI_RIGHT = 5; + public static final int LOWER_LEFT = 6; + public static final int BOTTOM = 7; + public static final int LOWER_RIGHT = 8; + public static final int FIELD_LEFT = 9; + public static final int FIELD_RIGHT = 10; + public static final int FIELD_MIDDLE = 11; + public static final int FIELD_ONE = 12; + public static final int BUTTON_LEFT = 13; + public static final int BUTTON_RIGHT = 14; + public static final int BUTTON_MIDDLE = 15; + public static final int BUTTON_ONE = 16; + public static final int BUTTON_LEFT_UP = 17; + public static final int BUTTON_RIGHT_UP = 18; + public static final int BUTTON_MIDDLE_UP = 19; + public static final int BUTTON_ONE_UP = 20; + public static final int BUTTON_LEFT_DN = 21; + public static final int BUTTON_RIGHT_DN = 22; + public static final int BUTTON_MIDDLE_DN = 23; + public static final int BUTTON_ONE_DN = 24; + public static final int BUTTON_LEFT_EB = 25; + public static final int BUTTON_RIGHT_EB = 26; + public static final int BUTTON_MIDDLE_EB = 27; + public static final int BUTTON_SB_UP = 28; + public static final int BUTTON_SB_DN = 29; + public static final int BUTTON_SB_GUIDE = 30; + public static final int BUTTON_SB_THUMB = 31; + public static final int BUTTON_LAST = 31; } diff -r 6a0ad4d384ea -r 77ac18bc1b2f src/org/tn5250j/encoding/AbstractCodePage.java --- a/src/org/tn5250j/encoding/AbstractCodePage.java Wed Jun 18 13:00:19 2014 -0700 +++ b/src/org/tn5250j/encoding/AbstractCodePage.java Wed Jun 18 13:03:01 2014 -0700 @@ -33,13 +33,13 @@ */ public abstract class AbstractCodePage implements ICodePage { - protected AbstractCodePage(String encoding) { - this.encoding = encoding; - } + protected AbstractCodePage(String encoding) { + this.encoding = encoding; + } - public String getEncoding() { - return encoding; - } + public String getEncoding() { + return encoding; + } - protected String encoding; + protected String encoding; } diff -r 6a0ad4d384ea -r 77ac18bc1b2f src/org/tn5250j/encoding/BuiltInCodePageFactory.java --- a/src/org/tn5250j/encoding/BuiltInCodePageFactory.java Wed Jun 18 13:00:19 2014 -0700 +++ b/src/org/tn5250j/encoding/BuiltInCodePageFactory.java Wed Jun 18 13:03:01 2014 -0700 @@ -60,90 +60,97 @@ */ class BuiltInCodePageFactory { private static final String TAG = "BuiltInCodePageFactory"; - private static BuiltInCodePageFactory singleton; + private static BuiltInCodePageFactory singleton; - private final List> clazzes = new ArrayList>(); + private final List> clazzes = new ArrayList>(); - private BuiltInCodePageFactory() { - register(); - } + private BuiltInCodePageFactory() { + register(); + } - public static synchronized final BuiltInCodePageFactory getInstance() { - if (singleton == null) { - singleton = new BuiltInCodePageFactory(); - } - return singleton; - } + public static synchronized final BuiltInCodePageFactory getInstance() { + if (singleton == null) { + singleton = new BuiltInCodePageFactory(); + } + + return singleton; + } - private void register() { - clazzes.add(CCSID37.class); - clazzes.add(CCSID273.class); - clazzes.add(CCSID277.class); - clazzes.add(CCSID278.class); - clazzes.add(CCSID280.class); - clazzes.add(CCSID284.class); - clazzes.add(CCSID285.class); - clazzes.add(CCSID297.class); - clazzes.add(CCSID424.class); - clazzes.add(CCSID500.class); - clazzes.add(CCSID870.class); - clazzes.add(CCSID871.class); - clazzes.add(CCSID875.class); - clazzes.add(CCSID1025.class); - clazzes.add(CCSID1026.class); - clazzes.add(CCSID1112.class); - clazzes.add(CCSID1140.class); - clazzes.add(CCSID1141.class); - clazzes.add(CCSID1147.class); - clazzes.add(CCSID1148.class); - } + private void register() { + clazzes.add(CCSID37.class); + clazzes.add(CCSID273.class); + clazzes.add(CCSID277.class); + clazzes.add(CCSID278.class); + clazzes.add(CCSID280.class); + clazzes.add(CCSID284.class); + clazzes.add(CCSID285.class); + clazzes.add(CCSID297.class); + clazzes.add(CCSID424.class); + clazzes.add(CCSID500.class); + clazzes.add(CCSID870.class); + clazzes.add(CCSID871.class); + clazzes.add(CCSID875.class); + clazzes.add(CCSID1025.class); + clazzes.add(CCSID1026.class); + clazzes.add(CCSID1112.class); + clazzes.add(CCSID1140.class); + clazzes.add(CCSID1141.class); + clazzes.add(CCSID1147.class); + clazzes.add(CCSID1148.class); + } + + /** + * @return unsorted list of available code pages + */ + public String[] getAvailableCodePages() { + HashSet cpset = new HashSet(); + + for (Class clazz : clazzes) { + final ICodepageConverter converter = getConverterFromClassName(clazz); - /** - * @return unsorted list of available code pages - */ - public String[] getAvailableCodePages() { - HashSet cpset = new HashSet(); - for (Class clazz : clazzes) { - final ICodepageConverter converter = getConverterFromClassName(clazz); - if (converter != null) { - cpset.add(converter.getName()); - } - } - return cpset.toArray(new String[cpset.size()]); - } + if (converter != null) { + cpset.add(converter.getName()); + } + } + + return cpset.toArray(new String[cpset.size()]); + } + + /** + * @param encoding + * @return an {@link ICodePage} object OR null, of not found + */ + public ICodePage getCodePage(String encoding) { + for (Class clazz : clazzes) { + final ICodepageConverter converter = getConverterFromClassName(clazz); + + if (converter != null && converter.getName().equals(encoding)) { + return converter; + } + } - /** - * @param encoding - * @return an {@link ICodePage} object OR null, of not found - */ - public ICodePage getCodePage(String encoding) { - for (Class clazz : clazzes) { - final ICodepageConverter converter = getConverterFromClassName(clazz); - if (converter != null && converter.getName().equals(encoding)) { - return converter; - } - } - return null; - } + return null; + } - /** - * Lazy loading converters takes time, - * but doesn't happen so often and saves memory. - * - * @param clazz {@link ICodepageConverter} - * @return - */ - private ICodepageConverter getConverterFromClassName(Class clazz) { - try { - final Constructor constructor = clazz.getConstructor(new Class[0]); - final ICodepageConverter converter = (ICodepageConverter) constructor.newInstance(); - converter.init(); - return converter; - } catch (Exception e) { - Log.e(TAG,"Couldn't load code page converter class:" + clazz.getCanonicalName(), e); - return null; - } - } + /** + * Lazy loading converters takes time, + * but doesn't happen so often and saves memory. + * + * @param clazz {@link ICodepageConverter} + * @return + */ + private ICodepageConverter getConverterFromClassName(Class clazz) { + try { + final Constructor constructor = clazz.getConstructor(new Class[0]); + final ICodepageConverter converter = (ICodepageConverter) constructor.newInstance(); + converter.init(); + return converter; + } + catch (Exception e) { + Log.e(TAG, "Couldn't load code page converter class:" + clazz.getCanonicalName(), e); + return null; + } + } } diff -r 6a0ad4d384ea -r 77ac18bc1b2f src/org/tn5250j/encoding/CharMappings.java --- a/src/org/tn5250j/encoding/CharMappings.java Wed Jun 18 13:00:19 2014 -0700 +++ b/src/org/tn5250j/encoding/CharMappings.java Wed Jun 18 13:03:01 2014 -0700 @@ -36,50 +36,56 @@ */ public class CharMappings { - public static final String DFT_ENC = "37"; - public static final int NATIVE_CP = 0; - public static final int TOOLBOX_CP = 1; + public static final String DFT_ENC = "37"; + public static final int NATIVE_CP = 0; + public static final int TOOLBOX_CP = 1; - private static final HashMap map = new HashMap(); + private static final HashMap map = new HashMap(); + + public static String[] getAvailableCodePages() { + Set cpset = new HashSet(); // no double entries - public static String[] getAvailableCodePages() { - Set cpset = new HashSet(); // no double entries - for (String cp : BuiltInCodePageFactory.getInstance().getAvailableCodePages()) { - cpset.add(cp); - } - for (String cp : ToolboxCodePageFactory.getInstance().getAvailableCodePages()) { - cpset.add(cp); - } - String[] cparray = cpset.toArray(new String[cpset.size()]); - Arrays.sort(cparray); - return cparray; - } + for (String cp : BuiltInCodePageFactory.getInstance().getAvailableCodePages()) { + cpset.add(cp); + } + + for (String cp : ToolboxCodePageFactory.getInstance().getAvailableCodePages()) { + cpset.add(cp); + } + + String[] cparray = cpset.toArray(new String[cpset.size()]); + Arrays.sort(cparray); + return cparray; + } - public static ICodePage getCodePage(String encoding) { - if (map.containsKey(encoding)) { - return map.get(encoding); - } + public static ICodePage getCodePage(String encoding) { + if (map.containsKey(encoding)) { + return map.get(encoding); + } + + ICodePage cp = BuiltInCodePageFactory.getInstance().getCodePage(encoding); - ICodePage cp = BuiltInCodePageFactory.getInstance().getCodePage(encoding); - if (cp != null) { - map.put(encoding, cp); - return cp; - } + if (cp != null) { + map.put(encoding, cp); + return cp; + } + + cp = ToolboxCodePageFactory.getInstance().getCodePage(encoding); - cp = ToolboxCodePageFactory.getInstance().getCodePage(encoding); - if (cp != null) { - map.put(encoding, cp); - return cp; - } + if (cp != null) { + map.put(encoding, cp); + return cp; + } + + cp = JavaCodePageFactory.getCodePage(encoding); - cp = JavaCodePageFactory.getCodePage(encoding); - if (cp != null) { - map.put(encoding, cp); - return cp; - } + if (cp != null) { + map.put(encoding, cp); + return cp; + } - // unsupported codepage ==> return default - return BuiltInCodePageFactory.getInstance().getCodePage(DFT_ENC); - } + // unsupported codepage ==> return default + return BuiltInCodePageFactory.getInstance().getCodePage(DFT_ENC); + } } diff -r 6a0ad4d384ea -r 77ac18bc1b2f src/org/tn5250j/encoding/ICodePage.java --- a/src/org/tn5250j/encoding/ICodePage.java Wed Jun 18 13:00:19 2014 -0700 +++ b/src/org/tn5250j/encoding/ICodePage.java Wed Jun 18 13:03:01 2014 -0700 @@ -2,21 +2,21 @@ public interface ICodePage { - /** - * Convert a single byte (or maybe more bytes which representing one character) to a Unicode character. - * - * @param index - * @return - */ - public abstract char ebcdic2uni(int index); + /** + * Convert a single byte (or maybe more bytes which representing one character) to a Unicode character. + * + * @param index + * @return + */ + public abstract char ebcdic2uni(int index); - /** - * Convert a Unicode character in it's byte representation. - * Therefore, only 8bit codepages are supported. - * - * @param index - * @return - */ - public abstract byte uni2ebcdic(char index); + /** + * Convert a Unicode character in it's byte representation. + * Therefore, only 8bit codepages are supported. + * + * @param index + * @return + */ + public abstract byte uni2ebcdic(char index); } diff -r 6a0ad4d384ea -r 77ac18bc1b2f src/org/tn5250j/encoding/JavaCodePageFactory.java --- a/src/org/tn5250j/encoding/JavaCodePageFactory.java Wed Jun 18 13:00:19 2014 -0700 +++ b/src/org/tn5250j/encoding/JavaCodePageFactory.java Wed Jun 18 13:03:01 2014 -0700 @@ -33,60 +33,66 @@ /* package */ class JavaCodePageFactory extends AbstractCodePage { - private final CharsetEncoder encoder; - private final CharsetDecoder decoder; + private final CharsetEncoder encoder; + private final CharsetDecoder decoder; - /* package */ JavaCodePageFactory(String encoding, CharsetEncoder encoder, CharsetDecoder decoder) { - super(encoding); - this.encoder = encoder; - this.decoder = decoder; - } + /* package */ JavaCodePageFactory(String encoding, CharsetEncoder encoder, CharsetDecoder decoder) { + super(encoding); + this.encoder = encoder; + this.decoder = decoder; + } - /* (non-Javadoc) - * @see org.tn5250j.encoding.CodePage#ebcdic2uni(int) - */ - public char ebcdic2uni(int codepoint) { - try { - final ByteBuffer in = ByteBuffer.wrap(new byte[] { (byte) codepoint }); - final CharBuffer out = this.decoder.decode(in); - return out.get(0); - } catch (Exception cce) { - return ' '; - } - } + /* (non-Javadoc) + * @see org.tn5250j.encoding.CodePage#ebcdic2uni(int) + */ + public char ebcdic2uni(int codepoint) { + try { + final ByteBuffer in = ByteBuffer.wrap(new byte[] { (byte) codepoint }); + final CharBuffer out = this.decoder.decode(in); + return out.get(0); + } + catch (Exception cce) { + return ' '; + } + } - /* (non-Javadoc) - * @see org.tn5250j.encoding.CodePage#uni2ebcdic(char) - */ - public byte uni2ebcdic(char character) { - try { - final CharBuffer in = CharBuffer.wrap(new char[] {character}); - final ByteBuffer out = this.encoder.encode(in); - return out.get(0); - } catch (Exception cce) { - return 0x0; - } - } + /* (non-Javadoc) + * @see org.tn5250j.encoding.CodePage#uni2ebcdic(char) + */ + public byte uni2ebcdic(char character) { + try { + final CharBuffer in = CharBuffer.wrap(new char[] {character}); + final ByteBuffer out = this.encoder.encode(in); + return out.get(0); + } + catch (Exception cce) { + return 0x0; + } + } - /** - * @param encoding - * @return A new {@link CodePage} object OR null, if not available. - */ - /* package */ static ICodePage getCodePage(final String encoding) { - CharsetDecoder dec = null; - CharsetEncoder enc = null; - try { - final Charset cs = java.nio.charset.Charset.forName(encoding); - dec = cs.newDecoder(); - enc = cs.newEncoder(); - } catch (Exception e) { - enc = null; - dec = null; - } - if ((enc != null) && (dec != null)) { - return new JavaCodePageFactory(encoding, enc, dec); - } - return null; - } + /** + * @param encoding + * @return A new {@link CodePage} object OR null, if not available. + */ + /* package */ static ICodePage getCodePage(final String encoding) { + CharsetDecoder dec = null; + CharsetEncoder enc = null; + + try { + final Charset cs = java.nio.charset.Charset.forName(encoding); + dec = cs.newDecoder(); + enc = cs.newEncoder(); + } + catch (Exception e) { + enc = null; + dec = null; + } + + if ((enc != null) && (dec != null)) { + return new JavaCodePageFactory(encoding, enc, dec); + } + + return null; + } } \ No newline at end of file diff -r 6a0ad4d384ea -r 77ac18bc1b2f src/org/tn5250j/encoding/ToolboxCodePageFactory.java --- a/src/org/tn5250j/encoding/ToolboxCodePageFactory.java Wed Jun 18 13:00:19 2014 -0700 +++ b/src/org/tn5250j/encoding/ToolboxCodePageFactory.java Wed Jun 18 13:03:01 2014 -0700 @@ -34,121 +34,131 @@ class ToolboxCodePageFactory { private static final String TAG = "ToolboxCodePageFactory"; - private final static String[] CODEPAGES = { "Big5", "Cp037", "Cp273", "Cp277", "Cp278", - "Cp280", "Cp284", "Cp285", "Cp297", "Cp420", "Cp424", "Cp437", - "Cp500", "Cp737", "Cp775", "Cp838", "Cp850", "Cp852", "Cp855", - "Cp856", "Cp857", "Cp858", "Cp860", "Cp861", "Cp862", "Cp863", - "Cp864", "Cp865", "Cp866", "Cp868", "Cp869", "Cp870", - "Cp871", "Cp874", "Cp875", "Cp918", "Cp921", "Cp922", - "Cp923", // IBM Latin-9. - "Cp930", "Cp933", "Cp935", "Cp937", "Cp939", "Cp942", "Cp943", - "Cp948", "Cp949", "Cp950", "Cp964", "Cp970", "Cp1006", "Cp1025", - "Cp1026", "Cp1046", "Cp1097", "Cp1098", "Cp1112", "Cp1122", - "Cp1123", "Cp1124", "Cp1140", "Cp1141", "Cp1142", "Cp1143", - "Cp1144", "Cp1145", "Cp1146", "Cp1147", "Cp1148", "Cp1149", - "Cp1252", "Cp1250", "Cp1251", "Cp1253", "Cp1254", "Cp1255", - "Cp1256", "Cp1257", "Cp1258", "Cp1381", "Cp1383", "Cp33722" }; + private final static String[] CODEPAGES = { "Big5", "Cp037", "Cp273", "Cp277", "Cp278", + "Cp280", "Cp284", "Cp285", "Cp297", "Cp420", "Cp424", "Cp437", + "Cp500", "Cp737", "Cp775", "Cp838", "Cp850", "Cp852", "Cp855", + "Cp856", "Cp857", "Cp858", "Cp860", "Cp861", "Cp862", "Cp863", + "Cp864", "Cp865", "Cp866", "Cp868", "Cp869", "Cp870", + "Cp871", "Cp874", "Cp875", "Cp918", "Cp921", "Cp922", + "Cp923", // IBM Latin-9. + "Cp930", "Cp933", "Cp935", "Cp937", "Cp939", "Cp942", "Cp943", + "Cp948", "Cp949", "Cp950", "Cp964", "Cp970", "Cp1006", "Cp1025", + "Cp1026", "Cp1046", "Cp1097", "Cp1098", "Cp1112", "Cp1122", + "Cp1123", "Cp1124", "Cp1140", "Cp1141", "Cp1142", "Cp1143", + "Cp1144", "Cp1145", "Cp1146", "Cp1147", "Cp1148", "Cp1149", + "Cp1252", "Cp1250", "Cp1251", "Cp1253", "Cp1254", "Cp1255", + "Cp1256", "Cp1257", "Cp1258", "Cp1381", "Cp1383", "Cp33722" + }; - private static final String CONVERTER_NAME = "com.ibm.as400.access.CharConverter"; - private static final String TOBYTES_NAME = "stringToByteArray"; - private static final String TOSTRING_NAME = "byteArrayToString"; + private static final String CONVERTER_NAME = "com.ibm.as400.access.CharConverter"; + private static final String TOBYTES_NAME = "stringToByteArray"; + private static final String TOSTRING_NAME = "byteArrayToString"; - private static ToolboxCodePageFactory singleton; + private static ToolboxCodePageFactory singleton; - private ToolboxCodePageFactory() { - /* private for singleton */ - } + private ToolboxCodePageFactory() { + /* private for singleton */ + } - public static synchronized ToolboxCodePageFactory getInstance() { - if (singleton == null) { - singleton = new ToolboxCodePageFactory(); - } - return singleton; - } + public static synchronized ToolboxCodePageFactory getInstance() { + if (singleton == null) { + singleton = new ToolboxCodePageFactory(); + } + + return singleton; + } - /** - * @return - */ - public String[] getAvailableCodePages() { - try { - final ClassLoader loader = getClassLoader(); - Class.forName(CONVERTER_NAME, false, loader); - return CODEPAGES; - } catch (Exception e) { - Log.i(TAG,"Couldn't locate JT400 Toolbox in classpath. Charset converters can't be used."); - return new String[0]; - } - } + /** + * @return + */ + public String[] getAvailableCodePages() { + try { + final ClassLoader loader = getClassLoader(); + Class.forName(CONVERTER_NAME, false, loader); + return CODEPAGES; + } + catch (Exception e) { + Log.i(TAG, "Couldn't locate JT400 Toolbox in classpath. Charset converters can't be used."); + return new String[0]; + } + } - /** - * @param encoding - * @return - */ - public ICodePage getCodePage(String encoding) { - try { - ClassLoader loader = getClassLoader(); - Class conv_class = Class.forName(CONVERTER_NAME, true, loader); - Constructor conv_constructor = conv_class.getConstructor(new Class[] { String.class }); - Method toBytes_method = conv_class.getMethod(TOBYTES_NAME, new Class[] { String.class }); - Method toString_method = conv_class.getMethod(TOSTRING_NAME, new Class[] { byte[].class }); - Object convobj = conv_constructor.newInstance(new Object[] { encoding }); - return new ToolboxConverterProxy(convobj, toBytes_method, toString_method); - } catch (Exception e) { - Log.w(TAG,"Can't load charset converter from JT400 Toolbox for code page " + encoding, e); - return null; - } - } + /** + * @param encoding + * @return + */ + public ICodePage getCodePage(String encoding) { + try { + ClassLoader loader = getClassLoader(); + Class conv_class = Class.forName(CONVERTER_NAME, true, loader); + Constructor conv_constructor = conv_class.getConstructor(new Class[] { String.class }); + Method toBytes_method = conv_class.getMethod(TOBYTES_NAME, new Class[] { String.class }); + Method toString_method = conv_class.getMethod(TOSTRING_NAME, new Class[] { byte[].class }); + Object convobj = conv_constructor.newInstance(new Object[] { encoding }); + return new ToolboxConverterProxy(convobj, toBytes_method, toString_method); + } + catch (Exception e) { + Log.w(TAG, "Can't load charset converter from JT400 Toolbox for code page " + encoding, e); + return null; + } + } + + private static final ClassLoader getClassLoader() { + ClassLoader loader = ToolboxCodePageFactory.class.getClassLoader(); - private static final ClassLoader getClassLoader() { - ClassLoader loader = ToolboxCodePageFactory.class.getClassLoader(); - if (loader == null) { - loader = ClassLoader.getSystemClassLoader(); - } - return loader; - } + if (loader == null) { + loader = ClassLoader.getSystemClassLoader(); + } - private static class ToolboxConverterProxy implements ICodePage { + return loader; + } + + private static class ToolboxConverterProxy implements ICodePage { - private final Object converter; - private final Method tobytesMethod; - private final Method tostringMethod; + private final Object converter; + private final Method tobytesMethod; + private final Method tostringMethod; - private ToolboxConverterProxy(Object converterObject, Method tobytesMethod, Method tostringMethod) { - super(); - this.converter = converterObject; - this.tobytesMethod = tobytesMethod; - this.tostringMethod = tostringMethod; - } + private ToolboxConverterProxy(Object converterObject, Method tobytesMethod, Method tostringMethod) { + super(); + this.converter = converterObject; + this.tobytesMethod = tobytesMethod; + this.tostringMethod = tostringMethod; + } + + public char ebcdic2uni(int index) { + Object result; - public char ebcdic2uni(int index) { - Object result; - try { - result = tostringMethod.invoke(converter, new Object[] { new byte[] { (byte) (index & 0xFF) } }); - } catch (Throwable t) { - result = null; - } + try { + result = tostringMethod.invoke(converter, new Object[] { new byte[] { (byte)(index & 0xFF) } }); + } + catch (Throwable t) { + result = null; + } - if (result == null) - return 0x00; + if (result == null) + return 0x00; - return ((String) result).charAt(0); - } + return ((String) result).charAt(0); + } - public byte uni2ebcdic(char index) { - Object result; - try { - result = tobytesMethod.invoke(converter, new Object[] { new String(new char[] { index }) }); - } catch (Throwable t) { - result = null; - } + public byte uni2ebcdic(char index) { + Object result; - if (result == null) - return 0x00; + try { + result = tobytesMethod.invoke(converter, new Object[] { new String(new char[] { index }) }); + } + catch (Throwable t) { + result = null; + } - return ((byte[]) result)[0]; - } - } + if (result == null) + return 0x00; + + return ((byte[]) result)[0]; + } + } } \ No newline at end of file diff -r 6a0ad4d384ea -r 77ac18bc1b2f src/org/tn5250j/encoding/builtin/CCSID1025.java --- a/src/org/tn5250j/encoding/builtin/CCSID1025.java Wed Jun 18 13:00:19 2014 -0700 +++ b/src/org/tn5250j/encoding/builtin/CCSID1025.java Wed Jun 18 13:03:01 2014 -0700 @@ -1,13 +1,13 @@ /** * $Id$ - * + * * Title: tn5250J * Copyright: Copyright (c) 2001,2009 * Company: * @author: master_jaf * * Description: - * Alternative (extended) implementation of a codepage converter CCSID 1025<->Unicode. + * Alternative (extended) implementation of a codepage converter CCSID 1025<->Unicode. * * * This program is free software; you can redistribute it and/or modify @@ -34,62 +34,63 @@ */ public final class CCSID1025 extends CodepageConverterAdapter { - public final static String NAME = "1025"; - public final static String DESCR = "Cyrillic Multilingual"; + public final static String NAME = "1025"; + public final static String DESCR = "Cyrillic Multilingual"; - /* - * Char maps manually extracted from JTOpen v6.4. Because char maps can't be - * covered by any license, this should legal. - */ - private static final char[] codepage = { '\u0000', '\u0001', '\u0002', - '\u0003', '\u009C', '\t', '\u0086', '\u007F', '\u0097', '\u008D', - '\u008E', '\u000B', '\f', '\r', '\u000E', '\u000F', '\u0010', - '\u0011', '\u0012', '\u0013', '\u009D', '\u0085', '\u0008', - '\u0087', '\u0018', '\u0019', '\u0092', '\u008F', '\u001C', - '\u001D', '\u001E', '\u001F', '\u0080', '\u0081', '\u0082', - '\u0083', '\u0084', '\n', '\u0017', '\u001B', '\u0088', '\u0089', - '\u008A', '\u008B', '\u008C', '\u0005', '\u0006', '\u0007', - '\u0090', '\u0091', '\u0016', '\u0093', '\u0094', '\u0095', - '\u0096', '\u0004', '\u0098', '\u0099', '\u009A', '\u009B', - '\u0014', '\u0015', '\u009E', '\u001A', ' ', '\u00A0', '\u0452', - '\u0453', '\u0451', '\u0454', '\u0455', '\u0456', '\u0457', - '\u0458', '[', '.', '<', '(', '+', '!', '&', '\u0459', '\u045A', - '\u045B', '\u045C', '\u045E', '\u045F', '\u042A', '\u2116', - '\u0402', ']', '$', '*', ')', ';', '^', '-', '/', '\u0403', - '\u0401', '\u0404', '\u0405', '\u0406', '\u0407', '\u0408', - '\u0409', '|', ',', '%', '_', '>', '?', '\u040A', '\u040B', - '\u040C', '\u00AD', '\u040E', '\u040F', '\u044E', '\u0430', - '\u0431', '`', ':', '#', '@', '\'', '=', '"', '\u0446', 'a', 'b', - 'c', 'd', 'e', 'f', 'g', 'h', 'i', '\u0434', '\u0435', '\u0444', - '\u0433', '\u0445', '\u0438', '\u0439', 'j', 'k', 'l', 'm', 'n', - 'o', 'p', 'q', 'r', '\u043A', '\u043B', '\u043C', '\u043D', - '\u043E', '\u043F', '\u044F', '~', 's', 't', 'u', 'v', 'w', 'x', - 'y', 'z', '\u0440', '\u0441', '\u0442', '\u0443', '\u0436', - '\u0432', '\u044C', '\u044B', '\u0437', '\u0448', '\u044D', - '\u0449', '\u0447', '\u044A', '\u042E', '\u0410', '\u0411', - '\u0426', '\u0414', '\u0415', '\u0424', '\u0413', '{', 'A', 'B', - 'C', 'D', 'E', 'F', 'G', 'H', 'I', '\u0425', '\u0418', '\u0419', - '\u041A', '\u041B', '\u041C', '}', 'J', 'K', 'L', 'M', 'N', 'O', - 'P', 'Q', 'R', '\u041D', '\u041E', '\u041F', '\u042F', '\u0420', - '\u0421', '\\', '\u00A7', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', - '\u0422', '\u0423', '\u0416', '\u0412', '\u042C', '\u042B', '0', - '1', '2', '3', '4', '5', '6', '7', '8', '9', '\u0417', '\u0428', - '\u042D', '\u0429', '\u0427', '\u009F', }; + /* + * Char maps manually extracted from JTOpen v6.4. Because char maps can't be + * covered by any license, this should legal. + */ + private static final char[] codepage = { '\u0000', '\u0001', '\u0002', + '\u0003', '\u009C', '\t', '\u0086', '\u007F', '\u0097', '\u008D', + '\u008E', '\u000B', '\f', '\r', '\u000E', '\u000F', '\u0010', + '\u0011', '\u0012', '\u0013', '\u009D', '\u0085', '\u0008', + '\u0087', '\u0018', '\u0019', '\u0092', '\u008F', '\u001C', + '\u001D', '\u001E', '\u001F', '\u0080', '\u0081', '\u0082', + '\u0083', '\u0084', '\n', '\u0017', '\u001B', '\u0088', '\u0089', + '\u008A', '\u008B', '\u008C', '\u0005', '\u0006', '\u0007', + '\u0090', '\u0091', '\u0016', '\u0093', '\u0094', '\u0095', + '\u0096', '\u0004', '\u0098', '\u0099', '\u009A', '\u009B', + '\u0014', '\u0015', '\u009E', '\u001A', ' ', '\u00A0', '\u0452', + '\u0453', '\u0451', '\u0454', '\u0455', '\u0456', '\u0457', + '\u0458', '[', '.', '<', '(', '+', '!', '&', '\u0459', '\u045A', + '\u045B', '\u045C', '\u045E', '\u045F', '\u042A', '\u2116', + '\u0402', ']', '$', '*', ')', ';', '^', '-', '/', '\u0403', + '\u0401', '\u0404', '\u0405', '\u0406', '\u0407', '\u0408', + '\u0409', '|', ',', '%', '_', '>', '?', '\u040A', '\u040B', + '\u040C', '\u00AD', '\u040E', '\u040F', '\u044E', '\u0430', + '\u0431', '`', ':', '#', '@', '\'', '=', '"', '\u0446', 'a', 'b', + 'c', 'd', 'e', 'f', 'g', 'h', 'i', '\u0434', '\u0435', '\u0444', + '\u0433', '\u0445', '\u0438', '\u0439', 'j', 'k', 'l', 'm', 'n', + 'o', 'p', 'q', 'r', '\u043A', '\u043B', '\u043C', '\u043D', + '\u043E', '\u043F', '\u044F', '~', 's', 't', 'u', 'v', 'w', 'x', + 'y', 'z', '\u0440', '\u0441', '\u0442', '\u0443', '\u0436', + '\u0432', '\u044C', '\u044B', '\u0437', '\u0448', '\u044D', + '\u0449', '\u0447', '\u044A', '\u042E', '\u0410', '\u0411', + '\u0426', '\u0414', '\u0415', '\u0424', '\u0413', '{', 'A', 'B', + 'C', 'D', 'E', 'F', 'G', 'H', 'I', '\u0425', '\u0418', '\u0419', + '\u041A', '\u041B', '\u041C', '}', 'J', 'K', 'L', 'M', 'N', 'O', + 'P', 'Q', 'R', '\u041D', '\u041E', '\u041F', '\u042F', '\u0420', + '\u0421', '\\', '\u00A7', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', + '\u0422', '\u0423', '\u0416', '\u0412', '\u042C', '\u042B', '0', + '1', '2', '3', '4', '5', '6', '7', '8', '9', '\u0417', '\u0428', + '\u042D', '\u0429', '\u0427', '\u009F', + }; - public String getName() { - return NAME; - } + public String getName() { + return NAME; + } - public String getDescription() { - return DESCR; - } + public String getDescription() { + return DESCR; + } - public String getEncoding() { - return NAME; - } + public String getEncoding() { + return NAME; + } - @Override - protected char[] getCodePage() { - return codepage; - } + @Override + protected char[] getCodePage() { + return codepage; + } } diff -r 6a0ad4d384ea -r 77ac18bc1b2f src/org/tn5250j/encoding/builtin/CCSID1026.java --- a/src/org/tn5250j/encoding/builtin/CCSID1026.java Wed Jun 18 13:00:19 2014 -0700 +++ b/src/org/tn5250j/encoding/builtin/CCSID1026.java Wed Jun 18 13:03:01 2014 -0700 @@ -1,13 +1,13 @@ /** * $Id$ - * + * * Title: tn5250J * Copyright: Copyright (c) 2001,2009 * Company: * @author: master_jaf * * Description: - * Alternative (extended) implementation of a codepage converter CCSID 1026<->Unicode. + * Alternative (extended) implementation of a codepage converter CCSID 1026<->Unicode. * * * This program is free software; you can redistribute it and/or modify @@ -34,62 +34,63 @@ */ public final class CCSID1026 extends CodepageConverterAdapter { - public final static String NAME = "1026"; - public final static String DESCR = "Turkey Latin 5"; + public final static String NAME = "1026"; + public final static String DESCR = "Turkey Latin 5"; - /* - * Char maps manually extracted from JTOpen v6.4. Because char maps can't be - * covered by any license, this should legal. - */ - private static final char[] codepage = { '\u0000', '\u0001', '\u0002', - '\u0003', '\u009C', '\t', '\u0086', '\u007F', '\u0097', '\u008D', - '\u008E', '\u000B', '\f', '\r', '\u000E', '\u000F', '\u0010', - '\u0011', '\u0012', '\u0013', '\u009D', '\u0085', '\u0008', - '\u0087', '\u0018', '\u0019', '\u0092', '\u008F', '\u001C', - '\u001D', '\u001E', '\u001F', '\u0080', '\u0081', '\u0082', - '\u0083', '\u0084', '\n', '\u0017', '\u001B', '\u0088', '\u0089', - '\u008A', '\u008B', '\u008C', '\u0005', '\u0006', '\u0007', - '\u0090', '\u0091', '\u0016', '\u0093', '\u0094', '\u0095', - '\u0096', '\u0004', '\u0098', '\u0099', '\u009A', '\u009B', - '\u0014', '\u0015', '\u009E', '\u001A', ' ', '\u00A0', '\u00E2', - '\u00E4', '\u00E0', '\u00E1', '\u00E3', '\u00E5', '{', '\u00F1', - '\u00C7', '.', '<', '(', '+', '!', '&', '\u00E9', '\u00EA', - '\u00EB', '\u00E8', '\u00ED', '\u00EE', '\u00EF', '\u00EC', - '\u00DF', '\u011E', '\u0130', '*', ')', ';', '^', '-', '/', - '\u00C2', '\u00C4', '\u00C0', '\u00C1', '\u00C3', '\u00C5', '[', - '\u00D1', '\u015F', ',', '%', '_', '>', '?', '\u00F8', '\u00C9', - '\u00CA', '\u00CB', '\u00C8', '\u00CD', '\u00CE', '\u00CF', - '\u00CC', '\u0131', ':', '\u00D6', '\u015E', '\'', '=', '\u00DC', - '\u00D8', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', '\u00AB', - '\u00BB', '}', '`', '\u00A6', '\u00B1', '\u00B0', 'j', 'k', 'l', - 'm', 'n', 'o', 'p', 'q', 'r', '\u00AA', '\u00BA', '\u00E6', - '\u00B8', '\u00C6', '\u00A4', '\u00B5', '\u00F6', 's', 't', 'u', - 'v', 'w', 'x', 'y', 'z', '\u00A1', '\u00BF', ']', '$', '@', - '\u00AE', '\u00A2', '\u00A3', '\u00A5', '\u00B7', '\u00A9', - '\u00A7', '\u00B6', '\u00BC', '\u00BD', '\u00BE', '\u00AC', '|', - '\u00AF', '\u00A8', '\u00B4', '\u00D7', '\u00E7', 'A', 'B', 'C', - 'D', 'E', 'F', 'G', 'H', 'I', '\u00AD', '\u00F4', '~', '\u00F2', - '\u00F3', '\u00F5', '\u011F', 'J', 'K', 'L', 'M', 'N', 'O', 'P', - 'Q', 'R', '\u00B9', '\u00FB', '\\', '\u00F9', '\u00FA', '\u00FF', - '\u00FC', '\u00F7', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', - '\u00B2', '\u00D4', '#', '\u00D2', '\u00D3', '\u00D5', '0', '1', - '2', '3', '4', '5', '6', '7', '8', '9', '\u00B3', '\u00DB', '"', - '\u00D9', '\u00DA', '\u009F', }; + /* + * Char maps manually extracted from JTOpen v6.4. Because char maps can't be + * covered by any license, this should legal. + */ + private static final char[] codepage = { '\u0000', '\u0001', '\u0002', + '\u0003', '\u009C', '\t', '\u0086', '\u007F', '\u0097', '\u008D', + '\u008E', '\u000B', '\f', '\r', '\u000E', '\u000F', '\u0010', + '\u0011', '\u0012', '\u0013', '\u009D', '\u0085', '\u0008', + '\u0087', '\u0018', '\u0019', '\u0092', '\u008F', '\u001C', + '\u001D', '\u001E', '\u001F', '\u0080', '\u0081', '\u0082', + '\u0083', '\u0084', '\n', '\u0017', '\u001B', '\u0088', '\u0089', + '\u008A', '\u008B', '\u008C', '\u0005', '\u0006', '\u0007', + '\u0090', '\u0091', '\u0016', '\u0093', '\u0094', '\u0095', + '\u0096', '\u0004', '\u0098', '\u0099', '\u009A', '\u009B', + '\u0014', '\u0015', '\u009E', '\u001A', ' ', '\u00A0', '\u00E2', + '\u00E4', '\u00E0', '\u00E1', '\u00E3', '\u00E5', '{', '\u00F1', + '\u00C7', '.', '<', '(', '+', '!', '&', '\u00E9', '\u00EA', + '\u00EB', '\u00E8', '\u00ED', '\u00EE', '\u00EF', '\u00EC', + '\u00DF', '\u011E', '\u0130', '*', ')', ';', '^', '-', '/', + '\u00C2', '\u00C4', '\u00C0', '\u00C1', '\u00C3', '\u00C5', '[', + '\u00D1', '\u015F', ',', '%', '_', '>', '?', '\u00F8', '\u00C9', + '\u00CA', '\u00CB', '\u00C8', '\u00CD', '\u00CE', '\u00CF', + '\u00CC', '\u0131', ':', '\u00D6', '\u015E', '\'', '=', '\u00DC', + '\u00D8', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', '\u00AB', + '\u00BB', '}', '`', '\u00A6', '\u00B1', '\u00B0', 'j', 'k', 'l', + 'm', 'n', 'o', 'p', 'q', 'r', '\u00AA', '\u00BA', '\u00E6', + '\u00B8', '\u00C6', '\u00A4', '\u00B5', '\u00F6', 's', 't', 'u', + 'v', 'w', 'x', 'y', 'z', '\u00A1', '\u00BF', ']', '$', '@', + '\u00AE', '\u00A2', '\u00A3', '\u00A5', '\u00B7', '\u00A9', + '\u00A7', '\u00B6', '\u00BC', '\u00BD', '\u00BE', '\u00AC', '|', + '\u00AF', '\u00A8', '\u00B4', '\u00D7', '\u00E7', 'A', 'B', 'C', + 'D', 'E', 'F', 'G', 'H', 'I', '\u00AD', '\u00F4', '~', '\u00F2', + '\u00F3', '\u00F5', '\u011F', 'J', 'K', 'L', 'M', 'N', 'O', 'P', + 'Q', 'R', '\u00B9', '\u00FB', '\\', '\u00F9', '\u00FA', '\u00FF', + '\u00FC', '\u00F7', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', + '\u00B2', '\u00D4', '#', '\u00D2', '\u00D3', '\u00D5', '0', '1', + '2', '3', '4', '5', '6', '7', '8', '9', '\u00B3', '\u00DB', '"', + '\u00D9', '\u00DA', '\u009F', + }; - public String getName() { - return NAME; - } + public String getName() { + return NAME; + } - public String getDescription() { - return DESCR; - } + public String getDescription() { + return DESCR; + } - public String getEncoding() { - return NAME; - } + public String getEncoding() { + return NAME; + } - @Override - protected char[] getCodePage() { - return codepage; - } + @Override + protected char[] getCodePage() { + return codepage; + } } diff -r 6a0ad4d384ea -r 77ac18bc1b2f src/org/tn5250j/encoding/builtin/CCSID1112.java --- a/src/org/tn5250j/encoding/builtin/CCSID1112.java Wed Jun 18 13:00:19 2014 -0700 +++ b/src/org/tn5250j/encoding/builtin/CCSID1112.java Wed Jun 18 13:03:01 2014 -0700 @@ -1,13 +1,13 @@ /** * $Id$ - * + * * Title: tn5250J * Copyright: Copyright (c) 2001,2009 * Company: * @author: master_jaf * * Description: - * Alternative (extended) implementation of a codepage converter CCSID 1112<->Unicode. + * Alternative (extended) implementation of a codepage converter CCSID 1112<->Unicode. * * * This program is free software; you can redistribute it and/or modify @@ -34,62 +34,63 @@ */ public final class CCSID1112 extends CodepageConverterAdapter { - public final static String NAME = "1112"; - public final static String DESCR = "Baltic, Multilingual"; + public final static String NAME = "1112"; + public final static String DESCR = "Baltic, Multilingual"; - /* - * Char maps manually extracted from JTOpen v6.4. Because char maps can't be - * covered by any license, this should legal. - */ - private static final char[] codepage = { '\u0000', '\u0001', '\u0002', - '\u0003', '\u009C', '\t', '\u0086', '\u007F', '\u0097', '\u008D', - '\u008E', '\u000B', '\f', '\r', '\u000E', '\u000F', '\u0010', - '\u0011', '\u0012', '\u0013', '\u009D', '\u0085', '\u0008', - '\u0087', '\u0018', '\u0019', '\u0092', '\u008F', '\u001C', - '\u001D', '\u001E', '\u001F', '\u0080', '\u0081', '\u0082', - '\u0083', '\u0084', '\n', '\u0017', '\u001B', '\u0088', '\u0089', - '\u008A', '\u008B', '\u008C', '\u0005', '\u0006', '\u0007', - '\u0090', '\u0091', '\u0016', '\u0093', '\u0094', '\u0095', - '\u0096', '\u0004', '\u0098', '\u0099', '\u009A', '\u009B', - '\u0014', '\u0015', '\u009E', '\u001A', ' ', '\u00A0', '\u0161', - '\u00E4', '\u0105', '\u012F', '\u016B', '\u00E5', '\u0113', - '\u017E', '\u00A2', '.', '<', '(', '+', '|', '&', '\u00E9', - '\u0119', '\u0117', '\u010D', '\u0173', '\u201E', '\u201C', - '\u0123', '\u00DF', '!', '$', '*', ')', ';', '\u00AC', '-', '/', - '\u0160', '\u00C4', '\u0104', '\u012E', '\u016A', '\u00C5', - '\u0112', '\u017D', '\u00A6', ',', '%', '_', '>', '?', '\u00F8', - '\u00C9', '\u0118', '\u0116', '\u010C', '\u0172', '\u012A', - '\u013B', '\u0122', '`', ':', '#', '@', '\'', '=', '"', '\u00D8', - 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', '\u00AB', '\u00BB', - '\u0101', '\u017C', '\u0144', '\u00B1', '\u00B0', 'j', 'k', 'l', - 'm', 'n', 'o', 'p', 'q', 'r', '\u0156', '\u0157', '\u00E6', - '\u0137', '\u00C6', '\u00A4', '\u00B5', '~', 's', 't', 'u', 'v', - 'w', 'x', 'y', 'z', '\u201D', '\u017A', '\u0100', '\u017B', - '\u0143', '\u00AE', '^', '\u00A3', '\u012B', '\u00B7', '\u00A9', - '\u00A7', '\u00B6', '\u00BC', '\u00BD', '\u00BE', '[', ']', - '\u0179', '\u0136', '\u013C', '\u00D7', '{', 'A', 'B', 'C', 'D', - 'E', 'F', 'G', 'H', 'I', '\u00AD', '\u014D', '\u00F6', '\u0146', - '\u00F3', '\u00F5', '}', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', - 'R', '\u00B9', '\u0107', '\u00FC', '\u0142', '\u015B', '\u2019', - '\\', '\u00F7', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '\u00B2', - '\u014C', '\u00D6', '\u0145', '\u00D3', '\u00D5', '0', '1', '2', - '3', '4', '5', '6', '7', '8', '9', '\u00B3', '\u0106', '\u00DC', - '\u0141', '\u015A', '\u009F', }; + /* + * Char maps manually extracted from JTOpen v6.4. Because char maps can't be + * covered by any license, this should legal. + */ + private static final char[] codepage = { '\u0000', '\u0001', '\u0002', + '\u0003', '\u009C', '\t', '\u0086', '\u007F', '\u0097', '\u008D', + '\u008E', '\u000B', '\f', '\r', '\u000E', '\u000F', '\u0010', + '\u0011', '\u0012', '\u0013', '\u009D', '\u0085', '\u0008', + '\u0087', '\u0018', '\u0019', '\u0092', '\u008F', '\u001C', + '\u001D', '\u001E', '\u001F', '\u0080', '\u0081', '\u0082', + '\u0083', '\u0084', '\n', '\u0017', '\u001B', '\u0088', '\u0089', + '\u008A', '\u008B', '\u008C', '\u0005', '\u0006', '\u0007', + '\u0090', '\u0091', '\u0016', '\u0093', '\u0094', '\u0095', + '\u0096', '\u0004', '\u0098', '\u0099', '\u009A', '\u009B', + '\u0014', '\u0015', '\u009E', '\u001A', ' ', '\u00A0', '\u0161', + '\u00E4', '\u0105', '\u012F', '\u016B', '\u00E5', '\u0113', + '\u017E', '\u00A2', '.', '<', '(', '+', '|', '&', '\u00E9', + '\u0119', '\u0117', '\u010D', '\u0173', '\u201E', '\u201C', + '\u0123', '\u00DF', '!', '$', '*', ')', ';', '\u00AC', '-', '/', + '\u0160', '\u00C4', '\u0104', '\u012E', '\u016A', '\u00C5', + '\u0112', '\u017D', '\u00A6', ',', '%', '_', '>', '?', '\u00F8', + '\u00C9', '\u0118', '\u0116', '\u010C', '\u0172', '\u012A', + '\u013B', '\u0122', '`', ':', '#', '@', '\'', '=', '"', '\u00D8', + 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', '\u00AB', '\u00BB', + '\u0101', '\u017C', '\u0144', '\u00B1', '\u00B0', 'j', 'k', 'l', + 'm', 'n', 'o', 'p', 'q', 'r', '\u0156', '\u0157', '\u00E6', + '\u0137', '\u00C6', '\u00A4', '\u00B5', '~', 's', 't', 'u', 'v', + 'w', 'x', 'y', 'z', '\u201D', '\u017A', '\u0100', '\u017B', + '\u0143', '\u00AE', '^', '\u00A3', '\u012B', '\u00B7', '\u00A9', + '\u00A7', '\u00B6', '\u00BC', '\u00BD', '\u00BE', '[', ']', + '\u0179', '\u0136', '\u013C', '\u00D7', '{', 'A', 'B', 'C', 'D', + 'E', 'F', 'G', 'H', 'I', '\u00AD', '\u014D', '\u00F6', '\u0146', + '\u00F3', '\u00F5', '}', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', + 'R', '\u00B9', '\u0107', '\u00FC', '\u0142', '\u015B', '\u2019', + '\\', '\u00F7', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '\u00B2', + '\u014C', '\u00D6', '\u0145', '\u00D3', '\u00D5', '0', '1', '2', + '3', '4', '5', '6', '7', '8', '9', '\u00B3', '\u0106', '\u00DC', + '\u0141', '\u015A', '\u009F', + }; - public String getName() { - return NAME; - } + public String getName() { + return NAME; + } - public String getDescription() { - return DESCR; - } + public String getDescription() { + return DESCR; + } - public String getEncoding() { - return NAME; - } + public String getEncoding() { + return NAME; + } - @Override - protected char[] getCodePage() { - return codepage; - } + @Override + protected char[] getCodePage() { + return codepage; + } } diff -r 6a0ad4d384ea -r 77ac18bc1b2f src/org/tn5250j/encoding/builtin/CCSID1140.java --- a/src/org/tn5250j/encoding/builtin/CCSID1140.java Wed Jun 18 13:00:19 2014 -0700 +++ b/src/org/tn5250j/encoding/builtin/CCSID1140.java Wed Jun 18 13:03:01 2014 -0700 @@ -1,13 +1,13 @@ /** * $Id$ - * + * * Title: tn5250J * Copyright: Copyright (c) 2001,2009 * Company: * @author: master_jaf * * Description: - * Alternative (extended) implementation of a codepage converter CCSID 1140<->Unicode. + * Alternative (extended) implementation of a codepage converter CCSID 1140<->Unicode. * * * This program is free software; you can redistribute it and/or modify @@ -34,62 +34,63 @@ */ public final class CCSID1140 extends CodepageConverterAdapter { - public final static String NAME = "1140"; - public final static String DESCR = "ECECP: USA, Canada, Netherlands, Portugal, Brazil, Australia, New Zealand"; + public final static String NAME = "1140"; + public final static String DESCR = "ECECP: USA, Canada, Netherlands, Portugal, Brazil, Australia, New Zealand"; - /* - * Char maps manually extracted from JTOpen v6.4. Because char maps can't be - * covered by any license, this should legal. - */ - private static final char[] codepage = { '\u0000', '\u0001', '\u0002', - '\u0003', '\u009C', '\t', '\u0086', '\u007F', '\u0097', '\u008D', - '\u008E', '\u000B', '\f', '\r', '\u000E', '\u000F', '\u0010', - '\u0011', '\u0012', '\u0013', '\u009D', '\u0085', '\u0008', - '\u0087', '\u0018', '\u0019', '\u0092', '\u008F', '\u001C', - '\u001D', '\u001E', '\u001F', '\u0080', '\u0081', '\u0082', - '\u0083', '\u0084', '\n', '\u0017', '\u001B', '\u0088', '\u0089', - '\u008A', '\u008B', '\u008C', '\u0005', '\u0006', '\u0007', - '\u0090', '\u0091', '\u0016', '\u0093', '\u0094', '\u0095', - '\u0096', '\u0004', '\u0098', '\u0099', '\u009A', '\u009B', - '\u0014', '\u0015', '\u009E', '\u001A', ' ', '\u00A0', '\u00E2', - '\u00E4', '\u00E0', '\u00E1', '\u00E3', '\u00E5', '\u00E7', - '\u00F1', '\u00A2', '.', '<', '(', '+', '|', '&', '\u00E9', - '\u00EA', '\u00EB', '\u00E8', '\u00ED', '\u00EE', '\u00EF', - '\u00EC', '\u00DF', '!', '$', '*', ')', ';', '\u00AC', '-', '/', - '\u00C2', '\u00C4', '\u00C0', '\u00C1', '\u00C3', '\u00C5', - '\u00C7', '\u00D1', '\u00A6', ',', '%', '_', '>', '?', '\u00F8', - '\u00C9', '\u00CA', '\u00CB', '\u00C8', '\u00CD', '\u00CE', - '\u00CF', '\u00CC', '`', ':', '#', '@', '\'', '=', '"', '\u00D8', - 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', '\u00AB', '\u00BB', - '\u00F0', '\u00FD', '\u00FE', '\u00B1', '\u00B0', 'j', 'k', 'l', - 'm', 'n', 'o', 'p', 'q', 'r', '\u00AA', '\u00BA', '\u00E6', - '\u00B8', '\u00C6', '\u20AC', '\u00B5', '~', 's', 't', 'u', 'v', - 'w', 'x', 'y', 'z', '\u00A1', '\u00BF', '\u00D0', '\u00DD', - '\u00DE', '\u00AE', '^', '\u00A3', '\u00A5', '\u00B7', '\u00A9', - '\u00A7', '\u00B6', '\u00BC', '\u00BD', '\u00BE', '[', ']', - '\u00AF', '\u00A8', '\u00B4', '\u00D7', '{', 'A', 'B', 'C', 'D', - 'E', 'F', 'G', 'H', 'I', '\u00AD', '\u00F4', '\u00F6', '\u00F2', - '\u00F3', '\u00F5', '}', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', - 'R', '\u00B9', '\u00FB', '\u00FC', '\u00F9', '\u00FA', '\u00FF', - '\\', '\u00F7', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '\u00B2', - '\u00D4', '\u00D6', '\u00D2', '\u00D3', '\u00D5', '0', '1', '2', - '3', '4', '5', '6', '7', '8', '9', '\u00B3', '\u00DB', '\u00DC', - '\u00D9', '\u00DA', '\u009F', }; + /* + * Char maps manually extracted from JTOpen v6.4. Because char maps can't be + * covered by any license, this should legal. + */ + private static final char[] codepage = { '\u0000', '\u0001', '\u0002', + '\u0003', '\u009C', '\t', '\u0086', '\u007F', '\u0097', '\u008D', + '\u008E', '\u000B', '\f', '\r', '\u000E', '\u000F', '\u0010', + '\u0011', '\u0012', '\u0013', '\u009D', '\u0085', '\u0008', + '\u0087', '\u0018', '\u0019', '\u0092', '\u008F', '\u001C', + '\u001D', '\u001E', '\u001F', '\u0080', '\u0081', '\u0082', + '\u0083', '\u0084', '\n', '\u0017', '\u001B', '\u0088', '\u0089', + '\u008A', '\u008B', '\u008C', '\u0005', '\u0006', '\u0007', + '\u0090', '\u0091', '\u0016', '\u0093', '\u0094', '\u0095', + '\u0096', '\u0004', '\u0098', '\u0099', '\u009A', '\u009B', + '\u0014', '\u0015', '\u009E', '\u001A', ' ', '\u00A0', '\u00E2', + '\u00E4', '\u00E0', '\u00E1', '\u00E3', '\u00E5', '\u00E7', + '\u00F1', '\u00A2', '.', '<', '(', '+', '|', '&', '\u00E9', + '\u00EA', '\u00EB', '\u00E8', '\u00ED', '\u00EE', '\u00EF', + '\u00EC', '\u00DF', '!', '$', '*', ')', ';', '\u00AC', '-', '/', + '\u00C2', '\u00C4', '\u00C0', '\u00C1', '\u00C3', '\u00C5', + '\u00C7', '\u00D1', '\u00A6', ',', '%', '_', '>', '?', '\u00F8', + '\u00C9', '\u00CA', '\u00CB', '\u00C8', '\u00CD', '\u00CE', + '\u00CF', '\u00CC', '`', ':', '#', '@', '\'', '=', '"', '\u00D8', + 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', '\u00AB', '\u00BB', + '\u00F0', '\u00FD', '\u00FE', '\u00B1', '\u00B0', 'j', 'k', 'l', + 'm', 'n', 'o', 'p', 'q', 'r', '\u00AA', '\u00BA', '\u00E6', + '\u00B8', '\u00C6', '\u20AC', '\u00B5', '~', 's', 't', 'u', 'v', + 'w', 'x', 'y', 'z', '\u00A1', '\u00BF', '\u00D0', '\u00DD', + '\u00DE', '\u00AE', '^', '\u00A3', '\u00A5', '\u00B7', '\u00A9', + '\u00A7', '\u00B6', '\u00BC', '\u00BD', '\u00BE', '[', ']', + '\u00AF', '\u00A8', '\u00B4', '\u00D7', '{', 'A', 'B', 'C', 'D', + 'E', 'F', 'G', 'H', 'I', '\u00AD', '\u00F4', '\u00F6', '\u00F2', + '\u00F3', '\u00F5', '}', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', + 'R', '\u00B9', '\u00FB', '\u00FC', '\u00F9', '\u00FA', '\u00FF', + '\\', '\u00F7', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '\u00B2', + '\u00D4', '\u00D6', '\u00D2', '\u00D3', '\u00D5', '0', '1', '2', + '3', '4', '5', '6', '7', '8', '9', '\u00B3', '\u00DB', '\u00DC', + '\u00D9', '\u00DA', '\u009F', + }; - public String getName() { - return NAME; - } + public String getName() { + return NAME; + } - public String getDescription() { - return DESCR; - } + public String getDescription() { + return DESCR; + } - public String getEncoding() { - return NAME; - } + public String getEncoding() { + return NAME; + } - @Override - protected char[] getCodePage() { - return codepage; - } + @Override + protected char[] getCodePage() { + return codepage; + } } diff -r 6a0ad4d384ea -r 77ac18bc1b2f src/org/tn5250j/encoding/builtin/CCSID1141.java --- a/src/org/tn5250j/encoding/builtin/CCSID1141.java Wed Jun 18 13:00:19 2014 -0700 +++ b/src/org/tn5250j/encoding/builtin/CCSID1141.java Wed Jun 18 13:03:01 2014 -0700 @@ -1,13 +1,13 @@ /** * $Id$ - * + * * Title: tn5250J * Copyright: Copyright (c) 2001,2009 * Company: * @author: master_jaf * * Description: - * Alternative (extended) implementation of a codepage converter CCSID 1141<->Unicode. + * Alternative (extended) implementation of a codepage converter CCSID 1141<->Unicode. * * * This program is free software; you can redistribute it and/or modify @@ -34,62 +34,63 @@ */ public final class CCSID1141 extends CodepageConverterAdapter { - public final static String NAME = "1141"; - public final static String DESCR = "ECECP: Austria, Germany"; + public final static String NAME = "1141"; + public final static String DESCR = "ECECP: Austria, Germany"; - /* - * Char maps manually extracted from JTOpen v6.4. Because char maps can't be - * covered by any license, this should legal. - */ - private static final char[] codepage = { '\u0000', '\u0001', '\u0002', - '\u0003', '\u009C', '\t', '\u0086', '\u007F', '\u0097', '\u008D', - '\u008E', '\u000B', '\f', '\r', '\u000E', '\u000F', '\u0010', - '\u0011', '\u0012', '\u0013', '\u009D', '\u0085', '\u0008', - '\u0087', '\u0018', '\u0019', '\u0092', '\u008F', '\u001C', - '\u001D', '\u001E', '\u001F', '\u0080', '\u0081', '\u0082', - '\u0083', '\u0084', '\n', '\u0017', '\u001B', '\u0088', '\u0089', - '\u008A', '\u008B', '\u008C', '\u0005', '\u0006', '\u0007', - '\u0090', '\u0091', '\u0016', '\u0093', '\u0094', '\u0095', - '\u0096', '\u0004', '\u0098', '\u0099', '\u009A', '\u009B', - '\u0014', '\u0015', '\u009E', '\u001A', ' ', '\u00A0', '\u00E2', - '{', '\u00E0', '\u00E1', '\u00E3', '\u00E5', '\u00E7', '\u00F1', - '\u00C4', '.', '<', '(', '+', '!', '&', '\u00E9', '\u00EA', - '\u00EB', '\u00E8', '\u00ED', '\u00EE', '\u00EF', '\u00EC', '~', - '\u00DC', '$', '*', ')', ';', '^', '-', '/', '\u00C2', '[', - '\u00C0', '\u00C1', '\u00C3', '\u00C5', '\u00C7', '\u00D1', - '\u00F6', ',', '%', '_', '>', '?', '\u00F8', '\u00C9', '\u00CA', - '\u00CB', '\u00C8', '\u00CD', '\u00CE', '\u00CF', '\u00CC', '`', - ':', '#', '\u00A7', '\'', '=', '"', '\u00D8', 'a', 'b', 'c', 'd', - 'e', 'f', 'g', 'h', 'i', '\u00AB', '\u00BB', '\u00F0', '\u00FD', - '\u00FE', '\u00B1', '\u00B0', 'j', 'k', 'l', 'm', 'n', 'o', 'p', - 'q', 'r', '\u00AA', '\u00BA', '\u00E6', '\u00B8', '\u00C6', - '\u20AC', '\u00B5', '\u00DF', 's', 't', 'u', 'v', 'w', 'x', 'y', - 'z', '\u00A1', '\u00BF', '\u00D0', '\u00DD', '\u00DE', '\u00AE', - '\u00A2', '\u00A3', '\u00A5', '\u00B7', '\u00A9', '@', '\u00B6', - '\u00BC', '\u00BD', '\u00BE', '\u00AC', '|', '\u00AF', '\u00A8', - '\u00B4', '\u00D7', '\u00E4', 'A', 'B', 'C', 'D', 'E', 'F', 'G', - 'H', 'I', '\u00AD', '\u00F4', '\u00A6', '\u00F2', '\u00F3', - '\u00F5', '\u00FC', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', - '\u00B9', '\u00FB', '}', '\u00F9', '\u00FA', '\u00FF', '\u00D6', - '\u00F7', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '\u00B2', - '\u00D4', '\\', '\u00D2', '\u00D3', '\u00D5', '0', '1', '2', '3', - '4', '5', '6', '7', '8', '9', '\u00B3', '\u00DB', ']', '\u00D9', - '\u00DA', '\u009F', }; + /* + * Char maps manually extracted from JTOpen v6.4. Because char maps can't be + * covered by any license, this should legal. + */ + private static final char[] codepage = { '\u0000', '\u0001', '\u0002', + '\u0003', '\u009C', '\t', '\u0086', '\u007F', '\u0097', '\u008D', + '\u008E', '\u000B', '\f', '\r', '\u000E', '\u000F', '\u0010', + '\u0011', '\u0012', '\u0013', '\u009D', '\u0085', '\u0008', + '\u0087', '\u0018', '\u0019', '\u0092', '\u008F', '\u001C', + '\u001D', '\u001E', '\u001F', '\u0080', '\u0081', '\u0082', + '\u0083', '\u0084', '\n', '\u0017', '\u001B', '\u0088', '\u0089', + '\u008A', '\u008B', '\u008C', '\u0005', '\u0006', '\u0007', + '\u0090', '\u0091', '\u0016', '\u0093', '\u0094', '\u0095', + '\u0096', '\u0004', '\u0098', '\u0099', '\u009A', '\u009B', + '\u0014', '\u0015', '\u009E', '\u001A', ' ', '\u00A0', '\u00E2', + '{', '\u00E0', '\u00E1', '\u00E3', '\u00E5', '\u00E7', '\u00F1', + '\u00C4', '.', '<', '(', '+', '!', '&', '\u00E9', '\u00EA', + '\u00EB', '\u00E8', '\u00ED', '\u00EE', '\u00EF', '\u00EC', '~', + '\u00DC', '$', '*', ')', ';', '^', '-', '/', '\u00C2', '[', + '\u00C0', '\u00C1', '\u00C3', '\u00C5', '\u00C7', '\u00D1', + '\u00F6', ',', '%', '_', '>', '?', '\u00F8', '\u00C9', '\u00CA', + '\u00CB', '\u00C8', '\u00CD', '\u00CE', '\u00CF', '\u00CC', '`', + ':', '#', '\u00A7', '\'', '=', '"', '\u00D8', 'a', 'b', 'c', 'd', + 'e', 'f', 'g', 'h', 'i', '\u00AB', '\u00BB', '\u00F0', '\u00FD', + '\u00FE', '\u00B1', '\u00B0', 'j', 'k', 'l', 'm', 'n', 'o', 'p', + 'q', 'r', '\u00AA', '\u00BA', '\u00E6', '\u00B8', '\u00C6', + '\u20AC', '\u00B5', '\u00DF', 's', 't', 'u', 'v', 'w', 'x', 'y', + 'z', '\u00A1', '\u00BF', '\u00D0', '\u00DD', '\u00DE', '\u00AE', + '\u00A2', '\u00A3', '\u00A5', '\u00B7', '\u00A9', '@', '\u00B6', + '\u00BC', '\u00BD', '\u00BE', '\u00AC', '|', '\u00AF', '\u00A8', + '\u00B4', '\u00D7', '\u00E4', 'A', 'B', 'C', 'D', 'E', 'F', 'G', + 'H', 'I', '\u00AD', '\u00F4', '\u00A6', '\u00F2', '\u00F3', + '\u00F5', '\u00FC', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', + '\u00B9', '\u00FB', '}', '\u00F9', '\u00FA', '\u00FF', '\u00D6', + '\u00F7', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '\u00B2', + '\u00D4', '\\', '\u00D2', '\u00D3', '\u00D5', '0', '1', '2', '3', + '4', '5', '6', '7', '8', '9', '\u00B3', '\u00DB', ']', '\u00D9', + '\u00DA', '\u009F', + }; - public String getName() { - return NAME; - } + public String getName() { + return NAME; + } - public String getDescription() { - return DESCR; - } + public String getDescription() { + return DESCR; + } - public String getEncoding() { - return NAME; - } + public String getEncoding() { + return NAME; + } - @Override - protected char[] getCodePage() { - return codepage; - } + @Override + protected char[] getCodePage() { + return codepage; + } } diff -r 6a0ad4d384ea -r 77ac18bc1b2f src/org/tn5250j/encoding/builtin/CCSID1147.java --- a/src/org/tn5250j/encoding/builtin/CCSID1147.java Wed Jun 18 13:00:19 2014 -0700 +++ b/src/org/tn5250j/encoding/builtin/CCSID1147.java Wed Jun 18 13:03:01 2014 -0700 @@ -1,13 +1,13 @@ /** * $Id$ - * + * * Title: tn5250J * Copyright: Copyright (c) 2001,2009 * Company: * @author: master_jaf * * Description: - * Alternative (extended) implementation of a codepage converter CCSID 1147<->Unicode. + * Alternative (extended) implementation of a codepage converter CCSID 1147<->Unicode. * * * This program is free software; you can redistribute it and/or modify @@ -34,62 +34,63 @@ */ public final class CCSID1147 extends CodepageConverterAdapter { - public final static String NAME = "1147"; - public final static String DESCR = "ECECP: France"; + public final static String NAME = "1147"; + public final static String DESCR = "ECECP: France"; - /* - * Char maps manually extracted from JTOpen v6.4. Because char maps can't be - * covered by any license, this should legal. - */ - private static final char[] codepage = { '\u0000', '\u0001', '\u0002', - '\u0003', '\u009C', '\t', '\u0086', '\u007F', '\u0097', '\u008D', - '\u008E', '\u000B', '\f', '\r', '\u000E', '\u000F', '\u0010', - '\u0011', '\u0012', '\u0013', '\u009D', '\u0085', '\u0008', - '\u0087', '\u0018', '\u0019', '\u0092', '\u008F', '\u001C', - '\u001D', '\u001E', '\u001F', '\u0080', '\u0081', '\u0082', - '\u0083', '\u0084', '\n', '\u0017', '\u001B', '\u0088', '\u0089', - '\u008A', '\u008B', '\u008C', '\u0005', '\u0006', '\u0007', - '\u0090', '\u0091', '\u0016', '\u0093', '\u0094', '\u0095', - '\u0096', '\u0004', '\u0098', '\u0099', '\u009A', '\u009B', - '\u0014', '\u0015', '\u009E', '\u001A', ' ', '\u00A0', '\u00E2', - '\u00E4', '@', '\u00E1', '\u00E3', '\u00E5', '\\', '\u00F1', - '\u00B0', '.', '<', '(', '+', '!', '&', '{', '\u00EA', '\u00EB', - '}', '\u00ED', '\u00EE', '\u00EF', '\u00EC', '\u00DF', '\u00A7', - '$', '*', ')', ';', '^', '-', '/', '\u00C2', '\u00C4', '\u00C0', - '\u00C1', '\u00C3', '\u00C5', '\u00C7', '\u00D1', '\u00F9', ',', - '%', '_', '>', '?', '\u00F8', '\u00C9', '\u00CA', '\u00CB', - '\u00C8', '\u00CD', '\u00CE', '\u00CF', '\u00CC', '\u00B5', ':', - '\u00A3', '\u00E0', '\'', '=', '"', '\u00D8', 'a', 'b', 'c', 'd', - 'e', 'f', 'g', 'h', 'i', '\u00AB', '\u00BB', '\u00F0', '\u00FD', - '\u00FE', '\u00B1', '[', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', - 'r', '\u00AA', '\u00BA', '\u00E6', '\u00B8', '\u00C6', '\u20AC', - '`', '\u00A8', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '\u00A1', - '\u00BF', '\u00D0', '\u00DD', '\u00DE', '\u00AE', '\u00A2', '#', - '\u00A5', '\u00B7', '\u00A9', ']', '\u00B6', '\u00BC', '\u00BD', - '\u00BE', '\u00AC', '|', '\u00AF', '~', '\u00B4', '\u00D7', - '\u00E9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', '\u00AD', - '\u00F4', '\u00F6', '\u00F2', '\u00F3', '\u00F5', '\u00E8', 'J', - 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', '\u00B9', '\u00FB', - '\u00FC', '\u00A6', '\u00FA', '\u00FF', '\u00E7', '\u00F7', 'S', - 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '\u00B2', '\u00D4', '\u00D6', - '\u00D2', '\u00D3', '\u00D5', '0', '1', '2', '3', '4', '5', '6', - '7', '8', '9', '\u00B3', '\u00DB', '\u00DC', '\u00D9', '\u00DA', - '\u009F', }; + /* + * Char maps manually extracted from JTOpen v6.4. Because char maps can't be + * covered by any license, this should legal. + */ + private static final char[] codepage = { '\u0000', '\u0001', '\u0002', + '\u0003', '\u009C', '\t', '\u0086', '\u007F', '\u0097', '\u008D', + '\u008E', '\u000B', '\f', '\r', '\u000E', '\u000F', '\u0010', + '\u0011', '\u0012', '\u0013', '\u009D', '\u0085', '\u0008', + '\u0087', '\u0018', '\u0019', '\u0092', '\u008F', '\u001C', + '\u001D', '\u001E', '\u001F', '\u0080', '\u0081', '\u0082', + '\u0083', '\u0084', '\n', '\u0017', '\u001B', '\u0088', '\u0089', + '\u008A', '\u008B', '\u008C', '\u0005', '\u0006', '\u0007', + '\u0090', '\u0091', '\u0016', '\u0093', '\u0094', '\u0095', + '\u0096', '\u0004', '\u0098', '\u0099', '\u009A', '\u009B', + '\u0014', '\u0015', '\u009E', '\u001A', ' ', '\u00A0', '\u00E2', + '\u00E4', '@', '\u00E1', '\u00E3', '\u00E5', '\\', '\u00F1', + '\u00B0', '.', '<', '(', '+', '!', '&', '{', '\u00EA', '\u00EB', + '}', '\u00ED', '\u00EE', '\u00EF', '\u00EC', '\u00DF', '\u00A7', + '$', '*', ')', ';', '^', '-', '/', '\u00C2', '\u00C4', '\u00C0', + '\u00C1', '\u00C3', '\u00C5', '\u00C7', '\u00D1', '\u00F9', ',', + '%', '_', '>', '?', '\u00F8', '\u00C9', '\u00CA', '\u00CB', + '\u00C8', '\u00CD', '\u00CE', '\u00CF', '\u00CC', '\u00B5', ':', + '\u00A3', '\u00E0', '\'', '=', '"', '\u00D8', 'a', 'b', 'c', 'd', + 'e', 'f', 'g', 'h', 'i', '\u00AB', '\u00BB', '\u00F0', '\u00FD', + '\u00FE', '\u00B1', '[', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', + 'r', '\u00AA', '\u00BA', '\u00E6', '\u00B8', '\u00C6', '\u20AC', + '`', '\u00A8', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '\u00A1', + '\u00BF', '\u00D0', '\u00DD', '\u00DE', '\u00AE', '\u00A2', '#', + '\u00A5', '\u00B7', '\u00A9', ']', '\u00B6', '\u00BC', '\u00BD', + '\u00BE', '\u00AC', '|', '\u00AF', '~', '\u00B4', '\u00D7', + '\u00E9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', '\u00AD', + '\u00F4', '\u00F6', '\u00F2', '\u00F3', '\u00F5', '\u00E8', 'J', + 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', '\u00B9', '\u00FB', + '\u00FC', '\u00A6', '\u00FA', '\u00FF', '\u00E7', '\u00F7', 'S', + 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '\u00B2', '\u00D4', '\u00D6', + '\u00D2', '\u00D3', '\u00D5', '0', '1', '2', '3', '4', '5', '6', + '7', '8', '9', '\u00B3', '\u00DB', '\u00DC', '\u00D9', '\u00DA', + '\u009F', + }; - public String getName() { - return NAME; - } + public String getName() { + return NAME; + } - public String getDescription() { - return DESCR; - } + public String getDescription() { + return DESCR; + } - public String getEncoding() { - return NAME; - } + public String getEncoding() { + return NAME; + } - @Override - protected char[] getCodePage() { - return codepage; - } + @Override + protected char[] getCodePage() { + return codepage; + } } diff -r 6a0ad4d384ea -r 77ac18bc1b2f src/org/tn5250j/encoding/builtin/CCSID1148.java --- a/src/org/tn5250j/encoding/builtin/CCSID1148.java Wed Jun 18 13:00:19 2014 -0700 +++ b/src/org/tn5250j/encoding/builtin/CCSID1148.java Wed Jun 18 13:03:01 2014 -0700 @@ -1,13 +1,13 @@ /** * $Id$ - * + * * Title: tn5250J * Copyright: Copyright (c) 2001,2009 * Company: * @author: master_jaf * * Description: - * Alternative (extended) implementation of a codepage converter CCSID 1148<->Unicode. + * Alternative (extended) implementation of a codepage converter CCSID 1148<->Unicode. * * * This program is free software; you can redistribute it and/or modify @@ -34,62 +34,63 @@ */ public final class CCSID1148 extends CodepageConverterAdapter { - public final static String NAME = "1148"; - public final static String DESCR = "ECECP: International 1"; + public final static String NAME = "1148"; + public final static String DESCR = "ECECP: International 1"; - /* - * Char maps manually extracted from JTOpen v6.4. Because char maps can't be - * covered by any license, this should legal. - */ - private static final char[] codepage = { '\u0000', '\u0001', '\u0002', - '\u0003', '\u009C', '\t', '\u0086', '\u007F', '\u0097', '\u008D', - '\u008E', '\u000B', '\f', '\r', '\u000E', '\u000F', '\u0010', - '\u0011', '\u0012', '\u0013', '\u009D', '\u0085', '\u0008', - '\u0087', '\u0018', '\u0019', '\u0092', '\u008F', '\u001C', - '\u001D', '\u001E', '\u001F', '\u0080', '\u0081', '\u0082', - '\u0083', '\u0084', '\n', '\u0017', '\u001B', '\u0088', '\u0089', - '\u008A', '\u008B', '\u008C', '\u0005', '\u0006', '\u0007', - '\u0090', '\u0091', '\u0016', '\u0093', '\u0094', '\u0095', - '\u0096', '\u0004', '\u0098', '\u0099', '\u009A', '\u009B', - '\u0014', '\u0015', '\u009E', '\u001A', ' ', '\u00A0', '\u00E2', - '\u00E4', '\u00E0', '\u00E1', '\u00E3', '\u00E5', '\u00E7', - '\u00F1', '[', '.', '<', '(', '+', '!', '&', '\u00E9', '\u00EA', - '\u00EB', '\u00E8', '\u00ED', '\u00EE', '\u00EF', '\u00EC', - '\u00DF', ']', '$', '*', ')', ';', '^', '-', '/', '\u00C2', - '\u00C4', '\u00C0', '\u00C1', '\u00C3', '\u00C5', '\u00C7', - '\u00D1', '\u00A6', ',', '%', '_', '>', '?', '\u00F8', '\u00C9', - '\u00CA', '\u00CB', '\u00C8', '\u00CD', '\u00CE', '\u00CF', - '\u00CC', '`', ':', '#', '@', '\'', '=', '"', '\u00D8', 'a', 'b', - 'c', 'd', 'e', 'f', 'g', 'h', 'i', '\u00AB', '\u00BB', '\u00F0', - '\u00FD', '\u00FE', '\u00B1', '\u00B0', 'j', 'k', 'l', 'm', 'n', - 'o', 'p', 'q', 'r', '\u00AA', '\u00BA', '\u00E6', '\u00B8', - '\u00C6', '\u20AC', '\u00B5', '~', 's', 't', 'u', 'v', 'w', 'x', - 'y', 'z', '\u00A1', '\u00BF', '\u00D0', '\u00DD', '\u00DE', - '\u00AE', '\u00A2', '\u00A3', '\u00A5', '\u00B7', '\u00A9', - '\u00A7', '\u00B6', '\u00BC', '\u00BD', '\u00BE', '\u00AC', '|', - '\u00AF', '\u00A8', '\u00B4', '\u00D7', '{', 'A', 'B', 'C', 'D', - 'E', 'F', 'G', 'H', 'I', '\u00AD', '\u00F4', '\u00F6', '\u00F2', - '\u00F3', '\u00F5', '}', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', - 'R', '\u00B9', '\u00FB', '\u00FC', '\u00F9', '\u00FA', '\u00FF', - '\\', '\u00F7', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '\u00B2', - '\u00D4', '\u00D6', '\u00D2', '\u00D3', '\u00D5', '0', '1', '2', - '3', '4', '5', '6', '7', '8', '9', '\u00B3', '\u00DB', '\u00DC', - '\u00D9', '\u00DA', '\u009F', }; + /* + * Char maps manually extracted from JTOpen v6.4. Because char maps can't be + * covered by any license, this should legal. + */ + private static final char[] codepage = { '\u0000', '\u0001', '\u0002', + '\u0003', '\u009C', '\t', '\u0086', '\u007F', '\u0097', '\u008D', + '\u008E', '\u000B', '\f', '\r', '\u000E', '\u000F', '\u0010', + '\u0011', '\u0012', '\u0013', '\u009D', '\u0085', '\u0008', + '\u0087', '\u0018', '\u0019', '\u0092', '\u008F', '\u001C', + '\u001D', '\u001E', '\u001F', '\u0080', '\u0081', '\u0082', + '\u0083', '\u0084', '\n', '\u0017', '\u001B', '\u0088', '\u0089', + '\u008A', '\u008B', '\u008C', '\u0005', '\u0006', '\u0007', + '\u0090', '\u0091', '\u0016', '\u0093', '\u0094', '\u0095', + '\u0096', '\u0004', '\u0098', '\u0099', '\u009A', '\u009B', + '\u0014', '\u0015', '\u009E', '\u001A', ' ', '\u00A0', '\u00E2', + '\u00E4', '\u00E0', '\u00E1', '\u00E3', '\u00E5', '\u00E7', + '\u00F1', '[', '.', '<', '(', '+', '!', '&', '\u00E9', '\u00EA', + '\u00EB', '\u00E8', '\u00ED', '\u00EE', '\u00EF', '\u00EC', + '\u00DF', ']', '$', '*', ')', ';', '^', '-', '/', '\u00C2', + '\u00C4', '\u00C0', '\u00C1', '\u00C3', '\u00C5', '\u00C7', + '\u00D1', '\u00A6', ',', '%', '_', '>', '?', '\u00F8', '\u00C9', + '\u00CA', '\u00CB', '\u00C8', '\u00CD', '\u00CE', '\u00CF', + '\u00CC', '`', ':', '#', '@', '\'', '=', '"', '\u00D8', 'a', 'b', + 'c', 'd', 'e', 'f', 'g', 'h', 'i', '\u00AB', '\u00BB', '\u00F0', + '\u00FD', '\u00FE', '\u00B1', '\u00B0', 'j', 'k', 'l', 'm', 'n', + 'o', 'p', 'q', 'r', '\u00AA', '\u00BA', '\u00E6', '\u00B8', + '\u00C6', '\u20AC', '\u00B5', '~', 's', 't', 'u', 'v', 'w', 'x', + 'y', 'z', '\u00A1', '\u00BF', '\u00D0', '\u00DD', '\u00DE', + '\u00AE', '\u00A2', '\u00A3', '\u00A5', '\u00B7', '\u00A9', + '\u00A7', '\u00B6', '\u00BC', '\u00BD', '\u00BE', '\u00AC', '|', + '\u00AF', '\u00A8', '\u00B4', '\u00D7', '{', 'A', 'B', 'C', 'D', + 'E', 'F', 'G', 'H', 'I', '\u00AD', '\u00F4', '\u00F6', '\u00F2', + '\u00F3', '\u00F5', '}', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', + 'R', '\u00B9', '\u00FB', '\u00FC', '\u00F9', '\u00FA', '\u00FF', + '\\', '\u00F7', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '\u00B2', + '\u00D4', '\u00D6', '\u00D2', '\u00D3', '\u00D5', '0', '1', '2', + '3', '4', '5', '6', '7', '8', '9', '\u00B3', '\u00DB', '\u00DC', + '\u00D9', '\u00DA', '\u009F', + }; - public String getName() { - return NAME; - } + public String getName() { + return NAME; + } - public String getDescription() { - return DESCR; - } + public String getDescription() { + return DESCR; + } - public String getEncoding() { - return NAME; - } + public String getEncoding() { + return NAME; + } - @Override - protected char[] getCodePage() { - return codepage; - } + @Override + protected char[] getCodePage() { + return codepage; + } } diff -r 6a0ad4d384ea -r 77ac18bc1b2f src/org/tn5250j/encoding/builtin/CCSID273.java --- a/src/org/tn5250j/encoding/builtin/CCSID273.java Wed Jun 18 13:00:19 2014 -0700 +++ b/src/org/tn5250j/encoding/builtin/CCSID273.java Wed Jun 18 13:03:01 2014 -0700 @@ -1,13 +1,13 @@ /** * $Id$ - * + * * Title: tn5250J * Copyright: Copyright (c) 2001,2009 * Company: * @author: master_jaf * * Description: - * Alternative (extended) implementation of a codepage converter CCSID 273<->Unicode. + * Alternative (extended) implementation of a codepage converter CCSID 273<->Unicode. * * * This program is free software; you can redistribute it and/or modify @@ -35,63 +35,64 @@ */ public final class CCSID273 extends CodepageConverterAdapter { - public final static String NAME = "273"; - public final static String DESCR = "CECP: Austria, Germany"; + public final static String NAME = "273"; + public final static String DESCR = "CECP: Austria, Germany"; - /* - * Char maps manually extracted from JTOpen v6.4. Because char maps can't be - * covered by any license, this should legal. - */ - private static final char[] codepage = { '\u0000', '\u0001', '\u0002', - '\u0003', '\u009C', '\t', '\u0086', '\u007F', '\u0097', '\u008D', - '\u008E', '\u000B', '\f', '\r', '\u000E', '\u000F', '\u0010', - '\u0011', '\u0012', '\u0013', '\u009D', '\u0085', '\u0008', - '\u0087', '\u0018', '\u0019', '\u0092', '\u008F', '\u001C', - '\u001D', '\u001E', '\u001F', '\u0080', '\u0081', '\u0082', - '\u0083', '\u0084', '\n', '\u0017', '\u001B', '\u0088', '\u0089', - '\u008A', '\u008B', '\u008C', '\u0005', '\u0006', '\u0007', - '\u0090', '\u0091', '\u0016', '\u0093', '\u0094', '\u0095', - '\u0096', '\u0004', '\u0098', '\u0099', '\u009A', '\u009B', - '\u0014', '\u0015', '\u009E', '\u001A', ' ', '\u00A0', '\u00E2', - '{', '\u00E0', '\u00E1', '\u00E3', '\u00E5', '\u00E7', '\u00F1', - '\u00C4', '.', '<', '(', '+', '!', '&', '\u00E9', '\u00EA', - '\u00EB', '\u00E8', '\u00ED', '\u00EE', '\u00EF', '\u00EC', '~', - '\u00DC', '$', '*', ')', ';', '^', '-', '/', '\u00C2', '[', - '\u00C0', '\u00C1', '\u00C3', '\u00C5', '\u00C7', '\u00D1', - '\u00F6', ',', '%', '_', '>', '?', '\u00F8', '\u00C9', '\u00CA', - '\u00CB', '\u00C8', '\u00CD', '\u00CE', '\u00CF', '\u00CC', '`', - ':', '#', '\u00A7', '\'', '=', '"', '\u00D8', 'a', 'b', 'c', 'd', - 'e', 'f', 'g', 'h', 'i', '\u00AB', '\u00BB', '\u00F0', '\u00FD', - '\u00FE', '\u00B1', '\u00B0', 'j', 'k', 'l', 'm', 'n', 'o', 'p', - 'q', 'r', '\u00AA', '\u00BA', '\u00E6', '\u00B8', '\u00C6', - '\u00A4', '\u00B5', '\u00DF', 's', 't', 'u', 'v', 'w', 'x', 'y', - 'z', '\u00A1', '\u00BF', '\u00D0', '\u00DD', '\u00DE', '\u00AE', - '\u00A2', '\u00A3', '\u00A5', '\u00B7', '\u00A9', '@', '\u00B6', - '\u00BC', '\u00BD', '\u00BE', '\u00AC', '|', '\u00AF', '\u00A8', - '\u00B4', '\u00D7', '\u00E4', 'A', 'B', 'C', 'D', 'E', 'F', 'G', - 'H', 'I', '\u00AD', '\u00F4', '\u00A6', '\u00F2', '\u00F3', - '\u00F5', '\u00FC', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', - '\u00B9', '\u00FB', '}', '\u00F9', '\u00FA', '\u00FF', '\u00D6', - '\u00F7', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '\u00B2', - '\u00D4', '\\', '\u00D2', '\u00D3', '\u00D5', '0', '1', '2', '3', - '4', '5', '6', '7', '8', '9', '\u00B3', '\u00DB', ']', '\u00D9', - '\u00DA', '\u009F', }; + /* + * Char maps manually extracted from JTOpen v6.4. Because char maps can't be + * covered by any license, this should legal. + */ + private static final char[] codepage = { '\u0000', '\u0001', '\u0002', + '\u0003', '\u009C', '\t', '\u0086', '\u007F', '\u0097', '\u008D', + '\u008E', '\u000B', '\f', '\r', '\u000E', '\u000F', '\u0010', + '\u0011', '\u0012', '\u0013', '\u009D', '\u0085', '\u0008', + '\u0087', '\u0018', '\u0019', '\u0092', '\u008F', '\u001C', + '\u001D', '\u001E', '\u001F', '\u0080', '\u0081', '\u0082', + '\u0083', '\u0084', '\n', '\u0017', '\u001B', '\u0088', '\u0089', + '\u008A', '\u008B', '\u008C', '\u0005', '\u0006', '\u0007', + '\u0090', '\u0091', '\u0016', '\u0093', '\u0094', '\u0095', + '\u0096', '\u0004', '\u0098', '\u0099', '\u009A', '\u009B', + '\u0014', '\u0015', '\u009E', '\u001A', ' ', '\u00A0', '\u00E2', + '{', '\u00E0', '\u00E1', '\u00E3', '\u00E5', '\u00E7', '\u00F1', + '\u00C4', '.', '<', '(', '+', '!', '&', '\u00E9', '\u00EA', + '\u00EB', '\u00E8', '\u00ED', '\u00EE', '\u00EF', '\u00EC', '~', + '\u00DC', '$', '*', ')', ';', '^', '-', '/', '\u00C2', '[', + '\u00C0', '\u00C1', '\u00C3', '\u00C5', '\u00C7', '\u00D1', + '\u00F6', ',', '%', '_', '>', '?', '\u00F8', '\u00C9', '\u00CA', + '\u00CB', '\u00C8', '\u00CD', '\u00CE', '\u00CF', '\u00CC', '`', + ':', '#', '\u00A7', '\'', '=', '"', '\u00D8', 'a', 'b', 'c', 'd', + 'e', 'f', 'g', 'h', 'i', '\u00AB', '\u00BB', '\u00F0', '\u00FD', + '\u00FE', '\u00B1', '\u00B0', 'j', 'k', 'l', 'm', 'n', 'o', 'p', + 'q', 'r', '\u00AA', '\u00BA', '\u00E6', '\u00B8', '\u00C6', + '\u00A4', '\u00B5', '\u00DF', 's', 't', 'u', 'v', 'w', 'x', 'y', + 'z', '\u00A1', '\u00BF', '\u00D0', '\u00DD', '\u00DE', '\u00AE', + '\u00A2', '\u00A3', '\u00A5', '\u00B7', '\u00A9', '@', '\u00B6', + '\u00BC', '\u00BD', '\u00BE', '\u00AC', '|', '\u00AF', '\u00A8', + '\u00B4', '\u00D7', '\u00E4', 'A', 'B', 'C', 'D', 'E', 'F', 'G', + 'H', 'I', '\u00AD', '\u00F4', '\u00A6', '\u00F2', '\u00F3', + '\u00F5', '\u00FC', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', + '\u00B9', '\u00FB', '}', '\u00F9', '\u00FA', '\u00FF', '\u00D6', + '\u00F7', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '\u00B2', + '\u00D4', '\\', '\u00D2', '\u00D3', '\u00D5', '0', '1', '2', '3', + '4', '5', '6', '7', '8', '9', '\u00B3', '\u00DB', ']', '\u00D9', + '\u00DA', '\u009F', + }; - public String getName() { - return NAME; - } - - public String getDescription() { - return DESCR; - } + public String getName() { + return NAME; + } + + public String getDescription() { + return DESCR; + } - public String getEncoding() { - return NAME; - } + public String getEncoding() { + return NAME; + } - @Override - protected char[] getCodePage() { - return codepage; - } + @Override + protected char[] getCodePage() { + return codepage; + } } diff -r 6a0ad4d384ea -r 77ac18bc1b2f src/org/tn5250j/encoding/builtin/CCSID277.java --- a/src/org/tn5250j/encoding/builtin/CCSID277.java Wed Jun 18 13:00:19 2014 -0700 +++ b/src/org/tn5250j/encoding/builtin/CCSID277.java Wed Jun 18 13:03:01 2014 -0700 @@ -1,13 +1,13 @@ /** * $Id$ - * + * * Title: tn5250J * Copyright: Copyright (c) 2001,2009 * Company: * @author: master_jaf * * Description: - * Alternative (extended) implementation of a codepage converter CCSID 277<->Unicode. + * Alternative (extended) implementation of a codepage converter CCSID 277<->Unicode. * * * This program is free software; you can redistribute it and/or modify @@ -34,62 +34,63 @@ */ public final class CCSID277 extends CodepageConverterAdapter { - public final static String NAME = "277"; - public final static String DESCR = "CECP: Denmark, Norway"; + public final static String NAME = "277"; + public final static String DESCR = "CECP: Denmark, Norway"; - /* - * Char maps manually extracted from JTOpen v6.4. Because char maps can't be - * covered by any license, this should legal. - */ - private static final char[] codepage = { '\u0000', '\u0001', '\u0002', - '\u0003', '\u009C', '\t', '\u0086', '\u007F', '\u0097', '\u008D', - '\u008E', '\u000B', '\f', '\r', '\u000E', '\u000F', '\u0010', - '\u0011', '\u0012', '\u0013', '\u009D', '\u0085', '\u0008', - '\u0087', '\u0018', '\u0019', '\u0092', '\u008F', '\u001C', - '\u001D', '\u001E', '\u001F', '\u0080', '\u0081', '\u0082', - '\u0083', '\u0084', '\n', '\u0017', '\u001B', '\u0088', '\u0089', - '\u008A', '\u008B', '\u008C', '\u0005', '\u0006', '\u0007', - '\u0090', '\u0091', '\u0016', '\u0093', '\u0094', '\u0095', - '\u0096', '\u0004', '\u0098', '\u0099', '\u009A', '\u009B', - '\u0014', '\u0015', '\u009E', '\u001A', ' ', '\u00A0', '\u00E2', - '\u00E4', '\u00E0', '\u00E1', '\u00E3', '}', '\u00E7', '\u00F1', - '#', '.', '<', '(', '+', '!', '&', '\u00E9', '\u00EA', '\u00EB', - '\u00E8', '\u00ED', '\u00EE', '\u00EF', '\u00EC', '\u00DF', - '\u00A4', '\u00C5', '*', ')', ';', '^', '-', '/', '\u00C2', - '\u00C4', '\u00C0', '\u00C1', '\u00C3', '$', '\u00C7', '\u00D1', - '\u00F8', ',', '%', '_', '>', '?', '\u00A6', '\u00C9', '\u00CA', - '\u00CB', '\u00C8', '\u00CD', '\u00CE', '\u00CF', '\u00CC', '`', - ':', '\u00C6', '\u00D8', '\'', '=', '"', '@', 'a', 'b', 'c', 'd', - 'e', 'f', 'g', 'h', 'i', '\u00AB', '\u00BB', '\u00F0', '\u00FD', - '\u00FE', '\u00B1', '\u00B0', 'j', 'k', 'l', 'm', 'n', 'o', 'p', - 'q', 'r', '\u00AA', '\u00BA', '{', '\u00B8', '[', ']', '\u00B5', - '\u00FC', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '\u00A1', - '\u00BF', '\u00D0', '\u00DD', '\u00DE', '\u00AE', '\u00A2', - '\u00A3', '\u00A5', '\u00B7', '\u00A9', '\u00A7', '\u00B6', - '\u00BC', '\u00BD', '\u00BE', '\u00AC', '|', '\u00AF', '\u00A8', - '\u00B4', '\u00D7', '\u00E6', 'A', 'B', 'C', 'D', 'E', 'F', 'G', - 'H', 'I', '\u00AD', '\u00F4', '\u00F6', '\u00F2', '\u00F3', - '\u00F5', '\u00E5', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', - '\u00B9', '\u00FB', '~', '\u00F9', '\u00FA', '\u00FF', '\\', - '\u00F7', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '\u00B2', - '\u00D4', '\u00D6', '\u00D2', '\u00D3', '\u00D5', '0', '1', '2', - '3', '4', '5', '6', '7', '8', '9', '\u00B3', '\u00DB', '\u00DC', - '\u00D9', '\u00DA', '\u009F', }; + /* + * Char maps manually extracted from JTOpen v6.4. Because char maps can't be + * covered by any license, this should legal. + */ + private static final char[] codepage = { '\u0000', '\u0001', '\u0002', + '\u0003', '\u009C', '\t', '\u0086', '\u007F', '\u0097', '\u008D', + '\u008E', '\u000B', '\f', '\r', '\u000E', '\u000F', '\u0010', + '\u0011', '\u0012', '\u0013', '\u009D', '\u0085', '\u0008', + '\u0087', '\u0018', '\u0019', '\u0092', '\u008F', '\u001C', + '\u001D', '\u001E', '\u001F', '\u0080', '\u0081', '\u0082', + '\u0083', '\u0084', '\n', '\u0017', '\u001B', '\u0088', '\u0089', + '\u008A', '\u008B', '\u008C', '\u0005', '\u0006', '\u0007', + '\u0090', '\u0091', '\u0016', '\u0093', '\u0094', '\u0095', + '\u0096', '\u0004', '\u0098', '\u0099', '\u009A', '\u009B', + '\u0014', '\u0015', '\u009E', '\u001A', ' ', '\u00A0', '\u00E2', + '\u00E4', '\u00E0', '\u00E1', '\u00E3', '}', '\u00E7', '\u00F1', + '#', '.', '<', '(', '+', '!', '&', '\u00E9', '\u00EA', '\u00EB', + '\u00E8', '\u00ED', '\u00EE', '\u00EF', '\u00EC', '\u00DF', + '\u00A4', '\u00C5', '*', ')', ';', '^', '-', '/', '\u00C2', + '\u00C4', '\u00C0', '\u00C1', '\u00C3', '$', '\u00C7', '\u00D1', + '\u00F8', ',', '%', '_', '>', '?', '\u00A6', '\u00C9', '\u00CA', + '\u00CB', '\u00C8', '\u00CD', '\u00CE', '\u00CF', '\u00CC', '`', + ':', '\u00C6', '\u00D8', '\'', '=', '"', '@', 'a', 'b', 'c', 'd', + 'e', 'f', 'g', 'h', 'i', '\u00AB', '\u00BB', '\u00F0', '\u00FD', + '\u00FE', '\u00B1', '\u00B0', 'j', 'k', 'l', 'm', 'n', 'o', 'p', + 'q', 'r', '\u00AA', '\u00BA', '{', '\u00B8', '[', ']', '\u00B5', + '\u00FC', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '\u00A1', + '\u00BF', '\u00D0', '\u00DD', '\u00DE', '\u00AE', '\u00A2', + '\u00A3', '\u00A5', '\u00B7', '\u00A9', '\u00A7', '\u00B6', + '\u00BC', '\u00BD', '\u00BE', '\u00AC', '|', '\u00AF', '\u00A8', + '\u00B4', '\u00D7', '\u00E6', 'A', 'B', 'C', 'D', 'E', 'F', 'G', + 'H', 'I', '\u00AD', '\u00F4', '\u00F6', '\u00F2', '\u00F3', + '\u00F5', '\u00E5', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', + '\u00B9', '\u00FB', '~', '\u00F9', '\u00FA', '\u00FF', '\\', + '\u00F7', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '\u00B2', + '\u00D4', '\u00D6', '\u00D2', '\u00D3', '\u00D5', '0', '1', '2', + '3', '4', '5', '6', '7', '8', '9', '\u00B3', '\u00DB', '\u00DC', + '\u00D9', '\u00DA', '\u009F', + }; - public String getName() { - return NAME; - } + public String getName() { + return NAME; + } - public String getDescription() { - return DESCR; - } + public String getDescription() { + return DESCR; + } - public String getEncoding() { - return NAME; - } + public String getEncoding() { + return NAME; + } - @Override - protected char[] getCodePage() { - return codepage; - } + @Override + protected char[] getCodePage() { + return codepage; + } } diff -r 6a0ad4d384ea -r 77ac18bc1b2f src/org/tn5250j/encoding/builtin/CCSID278.java --- a/src/org/tn5250j/encoding/builtin/CCSID278.java Wed Jun 18 13:00:19 2014 -0700 +++ b/src/org/tn5250j/encoding/builtin/CCSID278.java Wed Jun 18 13:03:01 2014 -0700 @@ -1,13 +1,13 @@ /** * $Id$ - * + * * Title: tn5250J * Copyright: Copyright (c) 2001,2009 * Company: * @author: master_jaf * * Description: - * Alternative (extended) implementation of a codepage converter CCSID 278<->Unicode. + * Alternative (extended) implementation of a codepage converter CCSID 278<->Unicode. * * * This program is free software; you can redistribute it and/or modify @@ -34,62 +34,63 @@ */ public final class CCSID278 extends CodepageConverterAdapter { - public final static String NAME = "278"; - public final static String DESCR = "CECP: Finland, Sweden"; + public final static String NAME = "278"; + public final static String DESCR = "CECP: Finland, Sweden"; - /* - * Char maps manually extracted from JTOpen v6.4. Because char maps can't be - * covered by any license, this should legal. - */ - private static final char[] codepage = { '\u0000', '\u0001', '\u0002', - '\u0003', '\u009C', '\t', '\u0086', '\u007F', '\u0097', '\u008D', - '\u008E', '\u000B', '\f', '\r', '\u000E', '\u000F', '\u0010', - '\u0011', '\u0012', '\u0013', '\u009D', '\u0085', '\u0008', - '\u0087', '\u0018', '\u0019', '\u0092', '\u008F', '\u001C', - '\u001D', '\u001E', '\u001F', '\u0080', '\u0081', '\u0082', - '\u0083', '\u0084', '\n', '\u0017', '\u001B', '\u0088', '\u0089', - '\u008A', '\u008B', '\u008C', '\u0005', '\u0006', '\u0007', - '\u0090', '\u0091', '\u0016', '\u0093', '\u0094', '\u0095', - '\u0096', '\u0004', '\u0098', '\u0099', '\u009A', '\u009B', - '\u0014', '\u0015', '\u009E', '\u001A', ' ', '\u00A0', '\u00E2', - '{', '\u00E0', '\u00E1', '\u00E3', '}', '\u00E7', '\u00F1', - '\u00A7', '.', '<', '(', '+', '!', '&', '`', '\u00EA', '\u00EB', - '\u00E8', '\u00ED', '\u00EE', '\u00EF', '\u00EC', '\u00DF', - '\u00A4', '\u00C5', '*', ')', ';', '^', '-', '/', '\u00C2', '#', - '\u00C0', '\u00C1', '\u00C3', '$', '\u00C7', '\u00D1', '\u00F6', - ',', '%', '_', '>', '?', '\u00F8', '\\', '\u00CA', '\u00CB', - '\u00C8', '\u00CD', '\u00CE', '\u00CF', '\u00CC', '\u00E9', ':', - '\u00C4', '\u00D6', '\'', '=', '"', '\u00D8', 'a', 'b', 'c', 'd', - 'e', 'f', 'g', 'h', 'i', '\u00AB', '\u00BB', '\u00F0', '\u00FD', - '\u00FE', '\u00B1', '\u00B0', 'j', 'k', 'l', 'm', 'n', 'o', 'p', - 'q', 'r', '\u00AA', '\u00BA', '\u00E6', '\u00B8', '\u00C6', ']', - '\u00B5', '\u00FC', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', - '\u00A1', '\u00BF', '\u00D0', '\u00DD', '\u00DE', '\u00AE', - '\u00A2', '\u00A3', '\u00A5', '\u00B7', '\u00A9', '[', '\u00B6', - '\u00BC', '\u00BD', '\u00BE', '\u00AC', '|', '\u00AF', '\u00A8', - '\u00B4', '\u00D7', '\u00E4', 'A', 'B', 'C', 'D', 'E', 'F', 'G', - 'H', 'I', '\u00AD', '\u00F4', '\u00A6', '\u00F2', '\u00F3', - '\u00F5', '\u00E5', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', - '\u00B9', '\u00FB', '~', '\u00F9', '\u00FA', '\u00FF', '\u00C9', - '\u00F7', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '\u00B2', - '\u00D4', '@', '\u00D2', '\u00D3', '\u00D5', '0', '1', '2', '3', - '4', '5', '6', '7', '8', '9', '\u00B3', '\u00DB', '\u00DC', - '\u00D9', '\u00DA', '\u009F' }; + /* + * Char maps manually extracted from JTOpen v6.4. Because char maps can't be + * covered by any license, this should legal. + */ + private static final char[] codepage = { '\u0000', '\u0001', '\u0002', + '\u0003', '\u009C', '\t', '\u0086', '\u007F', '\u0097', '\u008D', + '\u008E', '\u000B', '\f', '\r', '\u000E', '\u000F', '\u0010', + '\u0011', '\u0012', '\u0013', '\u009D', '\u0085', '\u0008', + '\u0087', '\u0018', '\u0019', '\u0092', '\u008F', '\u001C', + '\u001D', '\u001E', '\u001F', '\u0080', '\u0081', '\u0082', + '\u0083', '\u0084', '\n', '\u0017', '\u001B', '\u0088', '\u0089', + '\u008A', '\u008B', '\u008C', '\u0005', '\u0006', '\u0007', + '\u0090', '\u0091', '\u0016', '\u0093', '\u0094', '\u0095', + '\u0096', '\u0004', '\u0098', '\u0099', '\u009A', '\u009B', + '\u0014', '\u0015', '\u009E', '\u001A', ' ', '\u00A0', '\u00E2', + '{', '\u00E0', '\u00E1', '\u00E3', '}', '\u00E7', '\u00F1', + '\u00A7', '.', '<', '(', '+', '!', '&', '`', '\u00EA', '\u00EB', + '\u00E8', '\u00ED', '\u00EE', '\u00EF', '\u00EC', '\u00DF', + '\u00A4', '\u00C5', '*', ')', ';', '^', '-', '/', '\u00C2', '#', + '\u00C0', '\u00C1', '\u00C3', '$', '\u00C7', '\u00D1', '\u00F6', + ',', '%', '_', '>', '?', '\u00F8', '\\', '\u00CA', '\u00CB', + '\u00C8', '\u00CD', '\u00CE', '\u00CF', '\u00CC', '\u00E9', ':', + '\u00C4', '\u00D6', '\'', '=', '"', '\u00D8', 'a', 'b', 'c', 'd', + 'e', 'f', 'g', 'h', 'i', '\u00AB', '\u00BB', '\u00F0', '\u00FD', + '\u00FE', '\u00B1', '\u00B0', 'j', 'k', 'l', 'm', 'n', 'o', 'p', + 'q', 'r', '\u00AA', '\u00BA', '\u00E6', '\u00B8', '\u00C6', ']', + '\u00B5', '\u00FC', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', + '\u00A1', '\u00BF', '\u00D0', '\u00DD', '\u00DE', '\u00AE', + '\u00A2', '\u00A3', '\u00A5', '\u00B7', '\u00A9', '[', '\u00B6', + '\u00BC', '\u00BD', '\u00BE', '\u00AC', '|', '\u00AF', '\u00A8', + '\u00B4', '\u00D7', '\u00E4', 'A', 'B', 'C', 'D', 'E', 'F', 'G', + 'H', 'I', '\u00AD', '\u00F4', '\u00A6', '\u00F2', '\u00F3', + '\u00F5', '\u00E5', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', + '\u00B9', '\u00FB', '~', '\u00F9', '\u00FA', '\u00FF', '\u00C9', + '\u00F7', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '\u00B2', + '\u00D4', '@', '\u00D2', '\u00D3', '\u00D5', '0', '1', '2', '3', + '4', '5', '6', '7', '8', '9', '\u00B3', '\u00DB', '\u00DC', + '\u00D9', '\u00DA', '\u009F' + }; - public String getName() { - return NAME; - } + public String getName() { + return NAME; + } - public String getDescription() { - return DESCR; - } + public String getDescription() { + return DESCR; + } - public String getEncoding() { - return NAME; - } + public String getEncoding() { + return NAME; + } - @Override - protected char[] getCodePage() { - return codepage; - } + @Override + protected char[] getCodePage() { + return codepage; + } } diff -r 6a0ad4d384ea -r 77ac18bc1b2f src/org/tn5250j/encoding/builtin/CCSID280.java --- a/src/org/tn5250j/encoding/builtin/CCSID280.java Wed Jun 18 13:00:19 2014 -0700 +++ b/src/org/tn5250j/encoding/builtin/CCSID280.java Wed Jun 18 13:03:01 2014 -0700 @@ -1,13 +1,13 @@ /** * $Id$ - * + * * Title: tn5250J * Copyright: Copyright (c) 2001,2009 * Company: * @author: master_jaf * * Description: - * Alternative (extended) implementation of a codepage converter CCSID 280<->Unicode. + * Alternative (extended) implementation of a codepage converter CCSID 280<->Unicode. * * * This program is free software; you can redistribute it and/or modify @@ -34,62 +34,63 @@ */ public final class CCSID280 extends CodepageConverterAdapter { - public final static String NAME = "280"; - public final static String DESCR = "CECP: Italy"; + public final static String NAME = "280"; + public final static String DESCR = "CECP: Italy"; - /* - * Char maps manually extracted from JTOpen v6.4. Because char maps can't be - * covered by any license, this should legal. - */ - private static final char[] codepage = { '\u0000', '\u0001', '\u0002', - '\u0003', '\u009C', '\t', '\u0086', '\u007F', '\u0097', '\u008D', - '\u008E', '\u000B', '\f', '\r', '\u000E', '\u000F', '\u0010', - '\u0011', '\u0012', '\u0013', '\u009D', '\u0085', '\u0008', - '\u0087', '\u0018', '\u0019', '\u0092', '\u008F', '\u001C', - '\u001D', '\u001E', '\u001F', '\u0080', '\u0081', '\u0082', - '\u0083', '\u0084', '\n', '\u0017', '\u001B', '\u0088', '\u0089', - '\u008A', '\u008B', '\u008C', '\u0005', '\u0006', '\u0007', - '\u0090', '\u0091', '\u0016', '\u0093', '\u0094', '\u0095', - '\u0096', '\u0004', '\u0098', '\u0099', '\u009A', '\u009B', - '\u0014', '\u0015', '\u009E', '\u001A', ' ', '\u00A0', '\u00E2', - '\u00E4', '{', '\u00E1', '\u00E3', '\u00E5', '\\', '\u00F1', - '\u00B0', '.', '<', '(', '+', '!', '&', ']', '\u00EA', '\u00EB', - '}', '\u00ED', '\u00EE', '\u00EF', '~', '\u00DF', '\u00E9', '$', - '*', ')', ';', '^', '-', '/', '\u00C2', '\u00C4', '\u00C0', - '\u00C1', '\u00C3', '\u00C5', '\u00C7', '\u00D1', '\u00F2', ',', - '%', '_', '>', '?', '\u00F8', '\u00C9', '\u00CA', '\u00CB', - '\u00C8', '\u00CD', '\u00CE', '\u00CF', '\u00CC', '\u00F9', ':', - '\u00A3', '\u00A7', '\'', '=', '"', '\u00D8', 'a', 'b', 'c', 'd', - 'e', 'f', 'g', 'h', 'i', '\u00AB', '\u00BB', '\u00F0', '\u00FD', - '\u00FE', '\u00B1', '[', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', - 'r', '\u00AA', '\u00BA', '\u00E6', '\u00B8', '\u00C6', '\u00A4', - '\u00B5', '\u00EC', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', - '\u00A1', '\u00BF', '\u00D0', '\u00DD', '\u00DE', '\u00AE', - '\u00A2', '#', '\u00A5', '\u00B7', '\u00A9', '@', '\u00B6', - '\u00BC', '\u00BD', '\u00BE', '\u00AC', '|', '\u00AF', '\u00A8', - '\u00B4', '\u00D7', '\u00E0', 'A', 'B', 'C', 'D', 'E', 'F', 'G', - 'H', 'I', '\u00AD', '\u00F4', '\u00F6', '\u00A6', '\u00F3', - '\u00F5', '\u00E8', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', - '\u00B9', '\u00FB', '\u00FC', '`', '\u00FA', '\u00FF', '\u00E7', - '\u00F7', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '\u00B2', - '\u00D4', '\u00D6', '\u00D2', '\u00D3', '\u00D5', '0', '1', '2', - '3', '4', '5', '6', '7', '8', '9', '\u00B3', '\u00DB', '\u00DC', - '\u00D9', '\u00DA', '\u009F' }; + /* + * Char maps manually extracted from JTOpen v6.4. Because char maps can't be + * covered by any license, this should legal. + */ + private static final char[] codepage = { '\u0000', '\u0001', '\u0002', + '\u0003', '\u009C', '\t', '\u0086', '\u007F', '\u0097', '\u008D', + '\u008E', '\u000B', '\f', '\r', '\u000E', '\u000F', '\u0010', + '\u0011', '\u0012', '\u0013', '\u009D', '\u0085', '\u0008', + '\u0087', '\u0018', '\u0019', '\u0092', '\u008F', '\u001C', + '\u001D', '\u001E', '\u001F', '\u0080', '\u0081', '\u0082', + '\u0083', '\u0084', '\n', '\u0017', '\u001B', '\u0088', '\u0089', + '\u008A', '\u008B', '\u008C', '\u0005', '\u0006', '\u0007', + '\u0090', '\u0091', '\u0016', '\u0093', '\u0094', '\u0095', + '\u0096', '\u0004', '\u0098', '\u0099', '\u009A', '\u009B', + '\u0014', '\u0015', '\u009E', '\u001A', ' ', '\u00A0', '\u00E2', + '\u00E4', '{', '\u00E1', '\u00E3', '\u00E5', '\\', '\u00F1', + '\u00B0', '.', '<', '(', '+', '!', '&', ']', '\u00EA', '\u00EB', + '}', '\u00ED', '\u00EE', '\u00EF', '~', '\u00DF', '\u00E9', '$', + '*', ')', ';', '^', '-', '/', '\u00C2', '\u00C4', '\u00C0', + '\u00C1', '\u00C3', '\u00C5', '\u00C7', '\u00D1', '\u00F2', ',', + '%', '_', '>', '?', '\u00F8', '\u00C9', '\u00CA', '\u00CB', + '\u00C8', '\u00CD', '\u00CE', '\u00CF', '\u00CC', '\u00F9', ':', + '\u00A3', '\u00A7', '\'', '=', '"', '\u00D8', 'a', 'b', 'c', 'd', + 'e', 'f', 'g', 'h', 'i', '\u00AB', '\u00BB', '\u00F0', '\u00FD', + '\u00FE', '\u00B1', '[', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', + 'r', '\u00AA', '\u00BA', '\u00E6', '\u00B8', '\u00C6', '\u00A4', + '\u00B5', '\u00EC', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', + '\u00A1', '\u00BF', '\u00D0', '\u00DD', '\u00DE', '\u00AE', + '\u00A2', '#', '\u00A5', '\u00B7', '\u00A9', '@', '\u00B6', + '\u00BC', '\u00BD', '\u00BE', '\u00AC', '|', '\u00AF', '\u00A8', + '\u00B4', '\u00D7', '\u00E0', 'A', 'B', 'C', 'D', 'E', 'F', 'G', + 'H', 'I', '\u00AD', '\u00F4', '\u00F6', '\u00A6', '\u00F3', + '\u00F5', '\u00E8', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', + '\u00B9', '\u00FB', '\u00FC', '`', '\u00FA', '\u00FF', '\u00E7', + '\u00F7', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '\u00B2', + '\u00D4', '\u00D6', '\u00D2', '\u00D3', '\u00D5', '0', '1', '2', + '3', '4', '5', '6', '7', '8', '9', '\u00B3', '\u00DB', '\u00DC', + '\u00D9', '\u00DA', '\u009F' + }; - public String getName() { - return NAME; - } + public String getName() { + return NAME; + } - public String getDescription() { - return DESCR; - } + public String getDescription() { + return DESCR; + } - public String getEncoding() { - return NAME; - } + public String getEncoding() { + return NAME; + } - @Override - protected char[] getCodePage() { - return codepage; - } + @Override + protected char[] getCodePage() { + return codepage; + } } diff -r 6a0ad4d384ea -r 77ac18bc1b2f src/org/tn5250j/encoding/builtin/CCSID284.java --- a/src/org/tn5250j/encoding/builtin/CCSID284.java Wed Jun 18 13:00:19 2014 -0700 +++ b/src/org/tn5250j/encoding/builtin/CCSID284.java Wed Jun 18 13:03:01 2014 -0700 @@ -1,13 +1,13 @@ /** * $Id$ - * + * * Title: tn5250J * Copyright: Copyright (c) 2001,2009 * Company: * @author: master_jaf * * Description: - * Alternative (extended) implementation of a codepage converter CCSID 284<->Unicode. + * Alternative (extended) implementation of a codepage converter CCSID 284<->Unicode. * * * This program is free software; you can redistribute it and/or modify @@ -34,62 +34,63 @@ */ public final class CCSID284 extends CodepageConverterAdapter { - public final static String NAME = "284"; - public final static String DESCR = "CECP: Spain, Latin America (Spanish)"; + public final static String NAME = "284"; + public final static String DESCR = "CECP: Spain, Latin America (Spanish)"; - /* - * Char maps manually extracted from JTOpen v6.4. Because char maps can't be - * covered by any license, this should legal. - */ - private static final char[] codepage = { '\u0000', '\u0001', '\u0002', - '\u0003', '\u009C', '\t', '\u0086', '\u007F', '\u0097', '\u008D', - '\u008E', '\u000B', '\f', '\r', '\u000E', '\u000F', '\u0010', - '\u0011', '\u0012', '\u0013', '\u009D', '\u0085', '\u0008', - '\u0087', '\u0018', '\u0019', '\u0092', '\u008F', '\u001C', - '\u001D', '\u001E', '\u001F', '\u0080', '\u0081', '\u0082', - '\u0083', '\u0084', '\n', '\u0017', '\u001B', '\u0088', '\u0089', - '\u008A', '\u008B', '\u008C', '\u0005', '\u0006', '\u0007', - '\u0090', '\u0091', '\u0016', '\u0093', '\u0094', '\u0095', - '\u0096', '\u0004', '\u0098', '\u0099', '\u009A', '\u009B', - '\u0014', '\u0015', '\u009E', '\u001A', ' ', '\u00A0', '\u00E2', - '\u00E4', '\u00E0', '\u00E1', '\u00E3', '\u00E5', '\u00E7', - '\u00A6', '[', '.', '<', '(', '+', '|', '&', '\u00E9', '\u00EA', - '\u00EB', '\u00E8', '\u00ED', '\u00EE', '\u00EF', '\u00EC', - '\u00DF', ']', '$', '*', ')', ';', '\u00AC', '-', '/', '\u00C2', - '\u00C4', '\u00C0', '\u00C1', '\u00C3', '\u00C5', '\u00C7', '#', - '\u00F1', ',', '%', '_', '>', '?', '\u00F8', '\u00C9', '\u00CA', - '\u00CB', '\u00C8', '\u00CD', '\u00CE', '\u00CF', '\u00CC', '`', - ':', '\u00D1', '@', '\'', '=', '"', '\u00D8', 'a', 'b', 'c', 'd', - 'e', 'f', 'g', 'h', 'i', '\u00AB', '\u00BB', '\u00F0', '\u00FD', - '\u00FE', '\u00B1', '\u00B0', 'j', 'k', 'l', 'm', 'n', 'o', 'p', - 'q', 'r', '\u00AA', '\u00BA', '\u00E6', '\u00B8', '\u00C6', - '\u00A4', '\u00B5', '\u00A8', 's', 't', 'u', 'v', 'w', 'x', 'y', - 'z', '\u00A1', '\u00BF', '\u00D0', '\u00DD', '\u00DE', '\u00AE', - '\u00A2', '\u00A3', '\u00A5', '\u00B7', '\u00A9', '\u00A7', - '\u00B6', '\u00BC', '\u00BD', '\u00BE', '^', '!', '\u00AF', '~', - '\u00B4', '\u00D7', '{', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', - 'I', '\u00AD', '\u00F4', '\u00F6', '\u00F2', '\u00F3', '\u00F5', - '}', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', '\u00B9', - '\u00FB', '\u00FC', '\u00F9', '\u00FA', '\u00FF', '\\', '\u00F7', - 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '\u00B2', '\u00D4', - '\u00D6', '\u00D2', '\u00D3', '\u00D5', '0', '1', '2', '3', '4', - '5', '6', '7', '8', '9', '\u00B3', '\u00DB', '\u00DC', '\u00D9', - '\u00DA', '\u009F', }; + /* + * Char maps manually extracted from JTOpen v6.4. Because char maps can't be + * covered by any license, this should legal. + */ + private static final char[] codepage = { '\u0000', '\u0001', '\u0002', + '\u0003', '\u009C', '\t', '\u0086', '\u007F', '\u0097', '\u008D', + '\u008E', '\u000B', '\f', '\r', '\u000E', '\u000F', '\u0010', + '\u0011', '\u0012', '\u0013', '\u009D', '\u0085', '\u0008', + '\u0087', '\u0018', '\u0019', '\u0092', '\u008F', '\u001C', + '\u001D', '\u001E', '\u001F', '\u0080', '\u0081', '\u0082', + '\u0083', '\u0084', '\n', '\u0017', '\u001B', '\u0088', '\u0089', + '\u008A', '\u008B', '\u008C', '\u0005', '\u0006', '\u0007', + '\u0090', '\u0091', '\u0016', '\u0093', '\u0094', '\u0095', + '\u0096', '\u0004', '\u0098', '\u0099', '\u009A', '\u009B', + '\u0014', '\u0015', '\u009E', '\u001A', ' ', '\u00A0', '\u00E2', + '\u00E4', '\u00E0', '\u00E1', '\u00E3', '\u00E5', '\u00E7', + '\u00A6', '[', '.', '<', '(', '+', '|', '&', '\u00E9', '\u00EA', + '\u00EB', '\u00E8', '\u00ED', '\u00EE', '\u00EF', '\u00EC', + '\u00DF', ']', '$', '*', ')', ';', '\u00AC', '-', '/', '\u00C2', + '\u00C4', '\u00C0', '\u00C1', '\u00C3', '\u00C5', '\u00C7', '#', + '\u00F1', ',', '%', '_', '>', '?', '\u00F8', '\u00C9', '\u00CA', + '\u00CB', '\u00C8', '\u00CD', '\u00CE', '\u00CF', '\u00CC', '`', + ':', '\u00D1', '@', '\'', '=', '"', '\u00D8', 'a', 'b', 'c', 'd', + 'e', 'f', 'g', 'h', 'i', '\u00AB', '\u00BB', '\u00F0', '\u00FD', + '\u00FE', '\u00B1', '\u00B0', 'j', 'k', 'l', 'm', 'n', 'o', 'p', + 'q', 'r', '\u00AA', '\u00BA', '\u00E6', '\u00B8', '\u00C6', + '\u00A4', '\u00B5', '\u00A8', 's', 't', 'u', 'v', 'w', 'x', 'y', + 'z', '\u00A1', '\u00BF', '\u00D0', '\u00DD', '\u00DE', '\u00AE', + '\u00A2', '\u00A3', '\u00A5', '\u00B7', '\u00A9', '\u00A7', + '\u00B6', '\u00BC', '\u00BD', '\u00BE', '^', '!', '\u00AF', '~', + '\u00B4', '\u00D7', '{', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', + 'I', '\u00AD', '\u00F4', '\u00F6', '\u00F2', '\u00F3', '\u00F5', + '}', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', '\u00B9', + '\u00FB', '\u00FC', '\u00F9', '\u00FA', '\u00FF', '\\', '\u00F7', + 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '\u00B2', '\u00D4', + '\u00D6', '\u00D2', '\u00D3', '\u00D5', '0', '1', '2', '3', '4', + '5', '6', '7', '8', '9', '\u00B3', '\u00DB', '\u00DC', '\u00D9', + '\u00DA', '\u009F', + }; - public String getName() { - return NAME; - } + public String getName() { + return NAME; + } - public String getDescription() { - return DESCR; - } + public String getDescription() { + return DESCR; + } - public String getEncoding() { - return NAME; - } + public String getEncoding() { + return NAME; + } - @Override - protected char[] getCodePage() { - return codepage; - } + @Override + protected char[] getCodePage() { + return codepage; + } } diff -r 6a0ad4d384ea -r 77ac18bc1b2f src/org/tn5250j/encoding/builtin/CCSID285.java --- a/src/org/tn5250j/encoding/builtin/CCSID285.java Wed Jun 18 13:00:19 2014 -0700 +++ b/src/org/tn5250j/encoding/builtin/CCSID285.java Wed Jun 18 13:03:01 2014 -0700 @@ -1,13 +1,13 @@ /** * $Id$ - * + * * Title: tn5250J * Copyright: Copyright (c) 2001,2009 * Company: * @author: master_jaf * * Description: - * Alternative (extended) implementation of a codepage converter CCSID 285<->Unicode. + * Alternative (extended) implementation of a codepage converter CCSID 285<->Unicode. * * * This program is free software; you can redistribute it and/or modify @@ -34,62 +34,63 @@ */ public final class CCSID285 extends CodepageConverterAdapter { - public final static String NAME = "285"; - public final static String DESCR = "CECP: United Kingdom"; + public final static String NAME = "285"; + public final static String DESCR = "CECP: United Kingdom"; - /* - * Char maps manually extracted from JTOpen v6.4. Because char maps can't be - * covered by any license, this should legal. - */ - private static final char[] codepage = { '\u0000', '\u0001', '\u0002', - '\u0003', '\u009C', '\t', '\u0086', '\u007F', '\u0097', '\u008D', - '\u008E', '\u000B', '\f', '\r', '\u000E', '\u000F', '\u0010', - '\u0011', '\u0012', '\u0013', '\u009D', '\u0085', '\u0008', - '\u0087', '\u0018', '\u0019', '\u0092', '\u008F', '\u001C', - '\u001D', '\u001E', '\u001F', '\u0080', '\u0081', '\u0082', - '\u0083', '\u0084', '\n', '\u0017', '\u001B', '\u0088', '\u0089', - '\u008A', '\u008B', '\u008C', '\u0005', '\u0006', '\u0007', - '\u0090', '\u0091', '\u0016', '\u0093', '\u0094', '\u0095', - '\u0096', '\u0004', '\u0098', '\u0099', '\u009A', '\u009B', - '\u0014', '\u0015', '\u009E', '\u001A', ' ', '\u00A0', '\u00E2', - '\u00E4', '\u00E0', '\u00E1', '\u00E3', '\u00E5', '\u00E7', - '\u00F1', '$', '.', '<', '(', '+', '|', '&', '\u00E9', '\u00EA', - '\u00EB', '\u00E8', '\u00ED', '\u00EE', '\u00EF', '\u00EC', - '\u00DF', '!', '\u00A3', '*', ')', ';', '\u00AC', '-', '/', - '\u00C2', '\u00C4', '\u00C0', '\u00C1', '\u00C3', '\u00C5', - '\u00C7', '\u00D1', '\u00A6', ',', '%', '_', '>', '?', '\u00F8', - '\u00C9', '\u00CA', '\u00CB', '\u00C8', '\u00CD', '\u00CE', - '\u00CF', '\u00CC', '`', ':', '#', '@', '\'', '=', '"', '\u00D8', - 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', '\u00AB', '\u00BB', - '\u00F0', '\u00FD', '\u00FE', '\u00B1', '\u00B0', 'j', 'k', 'l', - 'm', 'n', 'o', 'p', 'q', 'r', '\u00AA', '\u00BA', '\u00E6', - '\u00B8', '\u00C6', '\u00A4', '\u00B5', '\u00AF', 's', 't', 'u', - 'v', 'w', 'x', 'y', 'z', '\u00A1', '\u00BF', '\u00D0', '\u00DD', - '\u00DE', '\u00AE', '\u00A2', '[', '\u00A5', '\u00B7', '\u00A9', - '\u00A7', '\u00B6', '\u00BC', '\u00BD', '\u00BE', '^', ']', '~', - '\u00A8', '\u00B4', '\u00D7', '{', 'A', 'B', 'C', 'D', 'E', 'F', - 'G', 'H', 'I', '\u00AD', '\u00F4', '\u00F6', '\u00F2', '\u00F3', - '\u00F5', '}', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', - '\u00B9', '\u00FB', '\u00FC', '\u00F9', '\u00FA', '\u00FF', '\\', - '\u00F7', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '\u00B2', - '\u00D4', '\u00D6', '\u00D2', '\u00D3', '\u00D5', '0', '1', '2', - '3', '4', '5', '6', '7', '8', '9', '\u00B3', '\u00DB', '\u00DC', - '\u00D9', '\u00DA', '\u009F', }; + /* + * Char maps manually extracted from JTOpen v6.4. Because char maps can't be + * covered by any license, this should legal. + */ + private static final char[] codepage = { '\u0000', '\u0001', '\u0002', + '\u0003', '\u009C', '\t', '\u0086', '\u007F', '\u0097', '\u008D', + '\u008E', '\u000B', '\f', '\r', '\u000E', '\u000F', '\u0010', + '\u0011', '\u0012', '\u0013', '\u009D', '\u0085', '\u0008', + '\u0087', '\u0018', '\u0019', '\u0092', '\u008F', '\u001C', + '\u001D', '\u001E', '\u001F', '\u0080', '\u0081', '\u0082', + '\u0083', '\u0084', '\n', '\u0017', '\u001B', '\u0088', '\u0089', + '\u008A', '\u008B', '\u008C', '\u0005', '\u0006', '\u0007', + '\u0090', '\u0091', '\u0016', '\u0093', '\u0094', '\u0095', + '\u0096', '\u0004', '\u0098', '\u0099', '\u009A', '\u009B', + '\u0014', '\u0015', '\u009E', '\u001A', ' ', '\u00A0', '\u00E2', + '\u00E4', '\u00E0', '\u00E1', '\u00E3', '\u00E5', '\u00E7', + '\u00F1', '$', '.', '<', '(', '+', '|', '&', '\u00E9', '\u00EA', + '\u00EB', '\u00E8', '\u00ED', '\u00EE', '\u00EF', '\u00EC', + '\u00DF', '!', '\u00A3', '*', ')', ';', '\u00AC', '-', '/', + '\u00C2', '\u00C4', '\u00C0', '\u00C1', '\u00C3', '\u00C5', + '\u00C7', '\u00D1', '\u00A6', ',', '%', '_', '>', '?', '\u00F8', + '\u00C9', '\u00CA', '\u00CB', '\u00C8', '\u00CD', '\u00CE', + '\u00CF', '\u00CC', '`', ':', '#', '@', '\'', '=', '"', '\u00D8', + 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', '\u00AB', '\u00BB', + '\u00F0', '\u00FD', '\u00FE', '\u00B1', '\u00B0', 'j', 'k', 'l', + 'm', 'n', 'o', 'p', 'q', 'r', '\u00AA', '\u00BA', '\u00E6', + '\u00B8', '\u00C6', '\u00A4', '\u00B5', '\u00AF', 's', 't', 'u', + 'v', 'w', 'x', 'y', 'z', '\u00A1', '\u00BF', '\u00D0', '\u00DD', + '\u00DE', '\u00AE', '\u00A2', '[', '\u00A5', '\u00B7', '\u00A9', + '\u00A7', '\u00B6', '\u00BC', '\u00BD', '\u00BE', '^', ']', '~', + '\u00A8', '\u00B4', '\u00D7', '{', 'A', 'B', 'C', 'D', 'E', 'F', + 'G', 'H', 'I', '\u00AD', '\u00F4', '\u00F6', '\u00F2', '\u00F3', + '\u00F5', '}', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', + '\u00B9', '\u00FB', '\u00FC', '\u00F9', '\u00FA', '\u00FF', '\\', + '\u00F7', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '\u00B2', + '\u00D4', '\u00D6', '\u00D2', '\u00D3', '\u00D5', '0', '1', '2', + '3', '4', '5', '6', '7', '8', '9', '\u00B3', '\u00DB', '\u00DC', + '\u00D9', '\u00DA', '\u009F', + }; - public String getName() { - return NAME; - } + public String getName() { + return NAME; + } - public String getDescription() { - return DESCR; - } + public String getDescription() { + return DESCR; + } - public String getEncoding() { - return NAME; - } + public String getEncoding() { + return NAME; + } - @Override - protected char[] getCodePage() { - return codepage; - } + @Override + protected char[] getCodePage() { + return codepage; + } } diff -r 6a0ad4d384ea -r 77ac18bc1b2f src/org/tn5250j/encoding/builtin/CCSID297.java --- a/src/org/tn5250j/encoding/builtin/CCSID297.java Wed Jun 18 13:00:19 2014 -0700 +++ b/src/org/tn5250j/encoding/builtin/CCSID297.java Wed Jun 18 13:03:01 2014 -0700 @@ -1,13 +1,13 @@ /** * $Id$ - * + * * Title: tn5250J * Copyright: Copyright (c) 2001,2009 * Company: * @author: master_jaf * * Description: - * Alternative (extended) implementation of a codepage converter CCSID 297<->Unicode. + * Alternative (extended) implementation of a codepage converter CCSID 297<->Unicode. * * * This program is free software; you can redistribute it and/or modify @@ -34,62 +34,63 @@ */ public final class CCSID297 extends CodepageConverterAdapter { - public final static String NAME = "297"; - public final static String DESCR = "CECP: France"; + public final static String NAME = "297"; + public final static String DESCR = "CECP: France"; - /* - * Char maps manually extracted from JTOpen v6.4. Because char maps can't be - * covered by any license, this should legal. - */ - private static final char[] codepage = { '\u0000', '\u0001', '\u0002', - '\u0003', '\u009C', '\t', '\u0086', '\u007F', '\u0097', '\u008D', - '\u008E', '\u000B', '\f', '\r', '\u000E', '\u000F', '\u0010', - '\u0011', '\u0012', '\u0013', '\u009D', '\u0085', '\u0008', - '\u0087', '\u0018', '\u0019', '\u0092', '\u008F', '\u001C', - '\u001D', '\u001E', '\u001F', '\u0080', '\u0081', '\u0082', - '\u0083', '\u0084', '\n', '\u0017', '\u001B', '\u0088', '\u0089', - '\u008A', '\u008B', '\u008C', '\u0005', '\u0006', '\u0007', - '\u0090', '\u0091', '\u0016', '\u0093', '\u0094', '\u0095', - '\u0096', '\u0004', '\u0098', '\u0099', '\u009A', '\u009B', - '\u0014', '\u0015', '\u009E', '\u001A', ' ', '\u00A0', '\u00E2', - '\u00E4', '@', '\u00E1', '\u00E3', '\u00E5', '\\', '\u00F1', - '\u00B0', '.', '<', '(', '+', '!', '&', '{', '\u00EA', '\u00EB', - '}', '\u00ED', '\u00EE', '\u00EF', '\u00EC', '\u00DF', '\u00A7', - '$', '*', ')', ';', '^', '-', '/', '\u00C2', '\u00C4', '\u00C0', - '\u00C1', '\u00C3', '\u00C5', '\u00C7', '\u00D1', '\u00F9', ',', - '%', '_', '>', '?', '\u00F8', '\u00C9', '\u00CA', '\u00CB', - '\u00C8', '\u00CD', '\u00CE', '\u00CF', '\u00CC', '\u00B5', ':', - '\u00A3', '\u00E0', '\'', '=', '"', '\u00D8', 'a', 'b', 'c', 'd', - 'e', 'f', 'g', 'h', 'i', '\u00AB', '\u00BB', '\u00F0', '\u00FD', - '\u00FE', '\u00B1', '[', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', - 'r', '\u00AA', '\u00BA', '\u00E6', '\u00B8', '\u00C6', '\u00A4', - '`', '\u00A8', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '\u00A1', - '\u00BF', '\u00D0', '\u00DD', '\u00DE', '\u00AE', '\u00A2', '#', - '\u00A5', '\u00B7', '\u00A9', ']', '\u00B6', '\u00BC', '\u00BD', - '\u00BE', '\u00AC', '|', '\u00AF', '~', '\u00B4', '\u00D7', - '\u00E9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', '\u00AD', - '\u00F4', '\u00F6', '\u00F2', '\u00F3', '\u00F5', '\u00E8', 'J', - 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', '\u00B9', '\u00FB', - '\u00FC', '\u00A6', '\u00FA', '\u00FF', '\u00E7', '\u00F7', 'S', - 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '\u00B2', '\u00D4', '\u00D6', - '\u00D2', '\u00D3', '\u00D5', '0', '1', '2', '3', '4', '5', '6', - '7', '8', '9', '\u00B3', '\u00DB', '\u00DC', '\u00D9', '\u00DA', - '\u009F', }; + /* + * Char maps manually extracted from JTOpen v6.4. Because char maps can't be + * covered by any license, this should legal. + */ + private static final char[] codepage = { '\u0000', '\u0001', '\u0002', + '\u0003', '\u009C', '\t', '\u0086', '\u007F', '\u0097', '\u008D', + '\u008E', '\u000B', '\f', '\r', '\u000E', '\u000F', '\u0010', + '\u0011', '\u0012', '\u0013', '\u009D', '\u0085', '\u0008', + '\u0087', '\u0018', '\u0019', '\u0092', '\u008F', '\u001C', + '\u001D', '\u001E', '\u001F', '\u0080', '\u0081', '\u0082', + '\u0083', '\u0084', '\n', '\u0017', '\u001B', '\u0088', '\u0089', + '\u008A', '\u008B', '\u008C', '\u0005', '\u0006', '\u0007', + '\u0090', '\u0091', '\u0016', '\u0093', '\u0094', '\u0095', + '\u0096', '\u0004', '\u0098', '\u0099', '\u009A', '\u009B', + '\u0014', '\u0015', '\u009E', '\u001A', ' ', '\u00A0', '\u00E2', + '\u00E4', '@', '\u00E1', '\u00E3', '\u00E5', '\\', '\u00F1', + '\u00B0', '.', '<', '(', '+', '!', '&', '{', '\u00EA', '\u00EB', + '}', '\u00ED', '\u00EE', '\u00EF', '\u00EC', '\u00DF', '\u00A7', + '$', '*', ')', ';', '^', '-', '/', '\u00C2', '\u00C4', '\u00C0', + '\u00C1', '\u00C3', '\u00C5', '\u00C7', '\u00D1', '\u00F9', ',', + '%', '_', '>', '?', '\u00F8', '\u00C9', '\u00CA', '\u00CB', + '\u00C8', '\u00CD', '\u00CE', '\u00CF', '\u00CC', '\u00B5', ':', + '\u00A3', '\u00E0', '\'', '=', '"', '\u00D8', 'a', 'b', 'c', 'd', + 'e', 'f', 'g', 'h', 'i', '\u00AB', '\u00BB', '\u00F0', '\u00FD', + '\u00FE', '\u00B1', '[', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', + 'r', '\u00AA', '\u00BA', '\u00E6', '\u00B8', '\u00C6', '\u00A4', + '`', '\u00A8', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '\u00A1', + '\u00BF', '\u00D0', '\u00DD', '\u00DE', '\u00AE', '\u00A2', '#', + '\u00A5', '\u00B7', '\u00A9', ']', '\u00B6', '\u00BC', '\u00BD', + '\u00BE', '\u00AC', '|', '\u00AF', '~', '\u00B4', '\u00D7', + '\u00E9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', '\u00AD', + '\u00F4', '\u00F6', '\u00F2', '\u00F3', '\u00F5', '\u00E8', 'J', + 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', '\u00B9', '\u00FB', + '\u00FC', '\u00A6', '\u00FA', '\u00FF', '\u00E7', '\u00F7', 'S', + 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '\u00B2', '\u00D4', '\u00D6', + '\u00D2', '\u00D3', '\u00D5', '0', '1', '2', '3', '4', '5', '6', + '7', '8', '9', '\u00B3', '\u00DB', '\u00DC', '\u00D9', '\u00DA', + '\u009F', + }; - public String getName() { - return NAME; - } + public String getName() { + return NAME; + } - public String getDescription() { - return DESCR; - } + public String getDescription() { + return DESCR; + } - public String getEncoding() { - return NAME; - } + public String getEncoding() { + return NAME; + } - @Override - protected char[] getCodePage() { - return codepage; - } + @Override + protected char[] getCodePage() { + return codepage; + } } diff -r 6a0ad4d384ea -r 77ac18bc1b2f src/org/tn5250j/encoding/builtin/CCSID37.java --- a/src/org/tn5250j/encoding/builtin/CCSID37.java Wed Jun 18 13:00:19 2014 -0700 +++ b/src/org/tn5250j/encoding/builtin/CCSID37.java Wed Jun 18 13:03:01 2014 -0700 @@ -1,13 +1,13 @@ /** * $Id$ - * + * * Title: tn5250J * Copyright: Copyright (c) 2001,2009 * Company: * @author: master_jaf * * Description: - * Alternative (extended) implementation of a codepage converter CCSID 37<->Unicode. + * Alternative (extended) implementation of a codepage converter CCSID 37<->Unicode. * * * This program is free software; you can redistribute it and/or modify @@ -35,64 +35,65 @@ */ public final class CCSID37 extends CodepageConverterAdapter { - public final static String NAME = "37"; - public final static String DESCR = "CECP: USA, Canada (ESA*), Netherlands, Portugal, Brazil, Australia, New Zealand"; + public final static String NAME = "37"; + public final static String DESCR = "CECP: USA, Canada (ESA*), Netherlands, Portugal, Brazil, Australia, New Zealand"; - /* - * Char maps manually extracted from JTOpen v6.4. Because char maps can't be - * covered by any license, this should legal. - */ - private static final char[] codepage = { '\u0000', '\u0001', '\u0002', - '\u0003', '\u009C', '\t', '\u0086', '\u007F', '\u0097', '\u008D', - '\u008E', '\u000B', '\f', '\r', '\u000E', '\u000F', '\u0010', - '\u0011', '\u0012', '\u0013', '\u009D', '\u0085', '\u0008', - '\u0087', '\u0018', '\u0019', '\u0092', '\u008F', '\u001C', - '\u001D', '\u001E', '\u001F', '\u0080', '\u0081', '\u0082', - '\u0083', '\u0084', '\n', '\u0017', '\u001B', '\u0088', '\u0089', - '\u008A', '\u008B', '\u008C', '\u0005', '\u0006', '\u0007', - '\u0090', '\u0091', '\u0016', '\u0093', '\u0094', '\u0095', - '\u0096', '\u0004', '\u0098', '\u0099', '\u009A', '\u009B', - '\u0014', '\u0015', '\u009E', '\u001A', ' ', '\u00A0', '\u00E2', - '\u00E4', '\u00E0', '\u00E1', '\u00E3', '\u00E5', '\u00E7', - '\u00F1', '\u00A2', '.', '<', '(', '+', '|', '&', '\u00E9', - '\u00EA', '\u00EB', '\u00E8', '\u00ED', '\u00EE', '\u00EF', - '\u00EC', '\u00DF', '!', '$', '*', ')', ';', '\u00AC', '-', '/', - '\u00C2', '\u00C4', '\u00C0', '\u00C1', '\u00C3', '\u00C5', - '\u00C7', '\u00D1', '\u00A6', ',', '%', '_', '>', '?', '\u00F8', - '\u00C9', '\u00CA', '\u00CB', '\u00C8', '\u00CD', '\u00CE', - '\u00CF', '\u00CC', '`', ':', '#', '@', '\'', '=', '"', '\u00D8', - 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', '\u00AB', '\u00BB', - '\u00F0', '\u00FD', '\u00FE', '\u00B1', '\u00B0', 'j', 'k', 'l', - 'm', 'n', 'o', 'p', 'q', 'r', '\u00AA', '\u00BA', '\u00E6', - '\u00B8', '\u00C6', '\u00A4', '\u00B5', '~', 's', 't', 'u', 'v', - 'w', 'x', 'y', 'z', '\u00A1', '\u00BF', '\u00D0', '\u00DD', - '\u00DE', '\u00AE', '^', '\u00A3', '\u00A5', '\u00B7', '\u00A9', - '\u00A7', '\u00B6', '\u00BC', '\u00BD', '\u00BE', '[', ']', - '\u00AF', '\u00A8', '\u00B4', '\u00D7', '{', 'A', 'B', 'C', 'D', - 'E', 'F', 'G', 'H', 'I', '\u00AD', '\u00F4', '\u00F6', '\u00F2', - '\u00F3', '\u00F5', '}', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', - 'R', '\u00B9', '\u00FB', '\u00FC', '\u00F9', '\u00FA', '\u00FF', - '\\', '\u00F7', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '\u00B2', - '\u00D4', '\u00D6', '\u00D2', '\u00D3', '\u00D5', '0', '1', '2', - '3', '4', '5', '6', '7', '8', '9', '\u00B3', '\u00DB', '\u00DC', - '\u00D9', '\u00DA', '\u009F', }; + /* + * Char maps manually extracted from JTOpen v6.4. Because char maps can't be + * covered by any license, this should legal. + */ + private static final char[] codepage = { '\u0000', '\u0001', '\u0002', + '\u0003', '\u009C', '\t', '\u0086', '\u007F', '\u0097', '\u008D', + '\u008E', '\u000B', '\f', '\r', '\u000E', '\u000F', '\u0010', + '\u0011', '\u0012', '\u0013', '\u009D', '\u0085', '\u0008', + '\u0087', '\u0018', '\u0019', '\u0092', '\u008F', '\u001C', + '\u001D', '\u001E', '\u001F', '\u0080', '\u0081', '\u0082', + '\u0083', '\u0084', '\n', '\u0017', '\u001B', '\u0088', '\u0089', + '\u008A', '\u008B', '\u008C', '\u0005', '\u0006', '\u0007', + '\u0090', '\u0091', '\u0016', '\u0093', '\u0094', '\u0095', + '\u0096', '\u0004', '\u0098', '\u0099', '\u009A', '\u009B', + '\u0014', '\u0015', '\u009E', '\u001A', ' ', '\u00A0', '\u00E2', + '\u00E4', '\u00E0', '\u00E1', '\u00E3', '\u00E5', '\u00E7', + '\u00F1', '\u00A2', '.', '<', '(', '+', '|', '&', '\u00E9', + '\u00EA', '\u00EB', '\u00E8', '\u00ED', '\u00EE', '\u00EF', + '\u00EC', '\u00DF', '!', '$', '*', ')', ';', '\u00AC', '-', '/', + '\u00C2', '\u00C4', '\u00C0', '\u00C1', '\u00C3', '\u00C5', + '\u00C7', '\u00D1', '\u00A6', ',', '%', '_', '>', '?', '\u00F8', + '\u00C9', '\u00CA', '\u00CB', '\u00C8', '\u00CD', '\u00CE', + '\u00CF', '\u00CC', '`', ':', '#', '@', '\'', '=', '"', '\u00D8', + 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', '\u00AB', '\u00BB', + '\u00F0', '\u00FD', '\u00FE', '\u00B1', '\u00B0', 'j', 'k', 'l', + 'm', 'n', 'o', 'p', 'q', 'r', '\u00AA', '\u00BA', '\u00E6', + '\u00B8', '\u00C6', '\u00A4', '\u00B5', '~', 's', 't', 'u', 'v', + 'w', 'x', 'y', 'z', '\u00A1', '\u00BF', '\u00D0', '\u00DD', + '\u00DE', '\u00AE', '^', '\u00A3', '\u00A5', '\u00B7', '\u00A9', + '\u00A7', '\u00B6', '\u00BC', '\u00BD', '\u00BE', '[', ']', + '\u00AF', '\u00A8', '\u00B4', '\u00D7', '{', 'A', 'B', 'C', 'D', + 'E', 'F', 'G', 'H', 'I', '\u00AD', '\u00F4', '\u00F6', '\u00F2', + '\u00F3', '\u00F5', '}', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', + 'R', '\u00B9', '\u00FB', '\u00FC', '\u00F9', '\u00FA', '\u00FF', + '\\', '\u00F7', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '\u00B2', + '\u00D4', '\u00D6', '\u00D2', '\u00D3', '\u00D5', '0', '1', '2', + '3', '4', '5', '6', '7', '8', '9', '\u00B3', '\u00DB', '\u00DC', + '\u00D9', '\u00DA', '\u009F', + }; - - public String getName() { - return NAME; - } - - public String getDescription() { - return DESCR; - } + + public String getName() { + return NAME; + } + + public String getDescription() { + return DESCR; + } - public String getEncoding() { - return NAME; - } + public String getEncoding() { + return NAME; + } - @Override - protected char[] getCodePage() { - return codepage; - } + @Override + protected char[] getCodePage() { + return codepage; + } } diff -r 6a0ad4d384ea -r 77ac18bc1b2f src/org/tn5250j/encoding/builtin/CCSID424.java --- a/src/org/tn5250j/encoding/builtin/CCSID424.java Wed Jun 18 13:00:19 2014 -0700 +++ b/src/org/tn5250j/encoding/builtin/CCSID424.java Wed Jun 18 13:03:01 2014 -0700 @@ -1,13 +1,13 @@ /** * $Id$ - * + * * Title: tn5250J * Copyright: Copyright (c) 2001,2009 * Company: * @author: master_jaf * * Description: - * Alternative (extended) implementation of a codepage converter CCSID 424<->Unicode. + * Alternative (extended) implementation of a codepage converter CCSID 424<->Unicode. * * * This program is free software; you can redistribute it and/or modify @@ -34,62 +34,63 @@ */ public final class CCSID424 extends CodepageConverterAdapter { - public final static String NAME = "424"; - public final static String DESCR = "Hebrew"; + public final static String NAME = "424"; + public final static String DESCR = "Hebrew"; - /* - * Char maps manually extracted from JTOpen v6.4. Because char maps can't be - * covered by any license, this should legal. - */ - private static final char[] codepage = { '\u0000', '\u0001', '\u0002', - '\u0003', '\u009C', '\t', '\u0086', '\u007F', '\u0097', '\u008D', - '\u008E', '\u000B', '\f', '\r', '\u000E', '\u000F', '\u0010', - '\u0011', '\u0012', '\u0013', '\u009D', '\u0085', '\u0008', - '\u0087', '\u0018', '\u0019', '\u0092', '\u008F', '\u001C', - '\u001D', '\u001E', '\u001F', '\u0080', '\u0081', '\u0082', - '\u0083', '\u0084', '\n', '\u0017', '\u001B', '\u0088', '\u0089', - '\u008A', '\u008B', '\u008C', '\u0005', '\u0006', '\u0007', - '\u0090', '\u0091', '\u0016', '\u0093', '\u0094', '\u0095', - '\u0096', '\u0004', '\u0098', '\u0099', '\u009A', '\u009B', - '\u0014', '\u0015', '\u009E', '\u001A', ' ', '\u05D0', '\u05D1', - '\u05D2', '\u05D3', '\u05D4', '\u05D5', '\u05D6', '\u05D7', - '\u05D8', '\u00A2', '.', '<', '(', '+', '|', '&', '\u05D9', - '\u05DA', '\u05DB', '\u05DC', '\u05DD', '\u05DE', '\u05DF', - '\u05E0', '\u05E1', '!', '$', '*', ')', ';', '\u00AC', '-', '/', - '\u05E2', '\u05E3', '\u05E4', '\u05E5', '\u05E6', '\u05E7', - '\u05E8', '\u05E9', '\u00A6', ',', '%', '_', '>', '?', '\u001A', - '\u05EA', '\u001A', '\u001A', '\u00A0', '\u001A', '\u001A', - '\u001A', '\u2017', '`', ':', '#', '@', '\'', '=', '"', '\u001A', - 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', '\u00AB', '\u00BB', - '\u001A', '\u001A', '\u001A', '\u00B1', '\u00B0', 'j', 'k', 'l', - 'm', 'n', 'o', 'p', 'q', 'r', '\u001A', '\u001A', '\u20AC', - '\u00B8', '\u20AA', '\u00A4', '\u00B5', '~', 's', 't', 'u', 'v', - 'w', 'x', 'y', 'z', '\u001A', '\u001A', '\u001A', '\u001A', - '\u001A', '\u00AE', '^', '\u00A3', '\u00A5', '\u2022', '\u00A9', - '\u00A7', '\u00B6', '\u00BC', '\u00BD', '\u00BE', '[', ']', - '\u203E', '\u00A8', '\u00B4', '\u00D7', '{', 'A', 'B', 'C', 'D', - 'E', 'F', 'G', 'H', 'I', '\u00AD', '\u001A', '\u001A', '\u001A', - '\u001A', '\u001A', '}', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', - 'R', '\u00B9', '\u202D', '\u202E', '\u202C', '\u001A', '\u001A', - '\\', '\u00F7', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '\u00B2', - '\u001A', '\u001A', '\u001A', '\u001A', '\u001A', '0', '1', '2', - '3', '4', '5', '6', '7', '8', '9', '\u00B3', '\u202A', '\u202B', - '\u200E', '\u200F', '\u009F', }; + /* + * Char maps manually extracted from JTOpen v6.4. Because char maps can't be + * covered by any license, this should legal. + */ + private static final char[] codepage = { '\u0000', '\u0001', '\u0002', + '\u0003', '\u009C', '\t', '\u0086', '\u007F', '\u0097', '\u008D', + '\u008E', '\u000B', '\f', '\r', '\u000E', '\u000F', '\u0010', + '\u0011', '\u0012', '\u0013', '\u009D', '\u0085', '\u0008', + '\u0087', '\u0018', '\u0019', '\u0092', '\u008F', '\u001C', + '\u001D', '\u001E', '\u001F', '\u0080', '\u0081', '\u0082', + '\u0083', '\u0084', '\n', '\u0017', '\u001B', '\u0088', '\u0089', + '\u008A', '\u008B', '\u008C', '\u0005', '\u0006', '\u0007', + '\u0090', '\u0091', '\u0016', '\u0093', '\u0094', '\u0095', + '\u0096', '\u0004', '\u0098', '\u0099', '\u009A', '\u009B', + '\u0014', '\u0015', '\u009E', '\u001A', ' ', '\u05D0', '\u05D1', + '\u05D2', '\u05D3', '\u05D4', '\u05D5', '\u05D6', '\u05D7', + '\u05D8', '\u00A2', '.', '<', '(', '+', '|', '&', '\u05D9', + '\u05DA', '\u05DB', '\u05DC', '\u05DD', '\u05DE', '\u05DF', + '\u05E0', '\u05E1', '!', '$', '*', ')', ';', '\u00AC', '-', '/', + '\u05E2', '\u05E3', '\u05E4', '\u05E5', '\u05E6', '\u05E7', + '\u05E8', '\u05E9', '\u00A6', ',', '%', '_', '>', '?', '\u001A', + '\u05EA', '\u001A', '\u001A', '\u00A0', '\u001A', '\u001A', + '\u001A', '\u2017', '`', ':', '#', '@', '\'', '=', '"', '\u001A', + 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', '\u00AB', '\u00BB', + '\u001A', '\u001A', '\u001A', '\u00B1', '\u00B0', 'j', 'k', 'l', + 'm', 'n', 'o', 'p', 'q', 'r', '\u001A', '\u001A', '\u20AC', + '\u00B8', '\u20AA', '\u00A4', '\u00B5', '~', 's', 't', 'u', 'v', + 'w', 'x', 'y', 'z', '\u001A', '\u001A', '\u001A', '\u001A', + '\u001A', '\u00AE', '^', '\u00A3', '\u00A5', '\u2022', '\u00A9', + '\u00A7', '\u00B6', '\u00BC', '\u00BD', '\u00BE', '[', ']', + '\u203E', '\u00A8', '\u00B4', '\u00D7', '{', 'A', 'B', 'C', 'D', + 'E', 'F', 'G', 'H', 'I', '\u00AD', '\u001A', '\u001A', '\u001A', + '\u001A', '\u001A', '}', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', + 'R', '\u00B9', '\u202D', '\u202E', '\u202C', '\u001A', '\u001A', + '\\', '\u00F7', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '\u00B2', + '\u001A', '\u001A', '\u001A', '\u001A', '\u001A', '0', '1', '2', + '3', '4', '5', '6', '7', '8', '9', '\u00B3', '\u202A', '\u202B', + '\u200E', '\u200F', '\u009F', + }; - public String getName() { - return NAME; - } + public String getName() { + return NAME; + } - public String getDescription() { - return DESCR; - } + public String getDescription() { + return DESCR; + } - public String getEncoding() { - return NAME; - } + public String getEncoding() { + return NAME; + } - @Override - protected char[] getCodePage() { - return codepage; - } + @Override + protected char[] getCodePage() { + return codepage; + } } diff -r 6a0ad4d384ea -r 77ac18bc1b2f src/org/tn5250j/encoding/builtin/CCSID500.java --- a/src/org/tn5250j/encoding/builtin/CCSID500.java Wed Jun 18 13:00:19 2014 -0700 +++ b/src/org/tn5250j/encoding/builtin/CCSID500.java Wed Jun 18 13:03:01 2014 -0700 @@ -1,13 +1,13 @@ /** * $Id$ - * + * * Title: tn5250J * Copyright: Copyright (c) 2001,2009 * Company: * @author: master_jaf * * Description: - * Alternative (extended) implementation of a codepage converter CCSID 500<->Unicode. + * Alternative (extended) implementation of a codepage converter CCSID 500<->Unicode. * * * This program is free software; you can redistribute it and/or modify @@ -34,62 +34,63 @@ */ public final class CCSID500 extends CodepageConverterAdapter { - public final static String NAME = "500"; - public final static String DESCR = "CECP: Belgium, Canada (AS/400*), Switzerland, International Latin-1"; + public final static String NAME = "500"; + public final static String DESCR = "CECP: Belgium, Canada (AS/400*), Switzerland, International Latin-1"; - /* - * Char maps manually extracted from JTOpen v6.4. Because char maps can't be - * covered by any license, this should legal. - */ - private static final char[] codepage = { '\u0000', '\u0001', '\u0002', - '\u0003', '\u009C', '\t', '\u0086', '\u007F', '\u0097', '\u008D', - '\u008E', '\u000B', '\f', '\r', '\u000E', '\u000F', '\u0010', - '\u0011', '\u0012', '\u0013', '\u009D', '\u0085', '\u0008', - '\u0087', '\u0018', '\u0019', '\u0092', '\u008F', '\u001C', - '\u001D', '\u001E', '\u001F', '\u0080', '\u0081', '\u0082', - '\u0083', '\u0084', '\n', '\u0017', '\u001B', '\u0088', '\u0089', - '\u008A', '\u008B', '\u008C', '\u0005', '\u0006', '\u0007', - '\u0090', '\u0091', '\u0016', '\u0093', '\u0094', '\u0095', - '\u0096', '\u0004', '\u0098', '\u0099', '\u009A', '\u009B', - '\u0014', '\u0015', '\u009E', '\u001A', ' ', '\u00A0', '\u00E2', - '\u00E4', '\u00E0', '\u00E1', '\u00E3', '\u00E5', '\u00E7', - '\u00F1', '[', '.', '<', '(', '+', '!', '&', '\u00E9', '\u00EA', - '\u00EB', '\u00E8', '\u00ED', '\u00EE', '\u00EF', '\u00EC', - '\u00DF', ']', '$', '*', ')', ';', '^', '-', '/', '\u00C2', - '\u00C4', '\u00C0', '\u00C1', '\u00C3', '\u00C5', '\u00C7', - '\u00D1', '\u00A6', ',', '%', '_', '>', '?', '\u00F8', '\u00C9', - '\u00CA', '\u00CB', '\u00C8', '\u00CD', '\u00CE', '\u00CF', - '\u00CC', '`', ':', '#', '@', '\'', '=', '"', '\u00D8', 'a', 'b', - 'c', 'd', 'e', 'f', 'g', 'h', 'i', '\u00AB', '\u00BB', '\u00F0', - '\u00FD', '\u00FE', '\u00B1', '\u00B0', 'j', 'k', 'l', 'm', 'n', - 'o', 'p', 'q', 'r', '\u00AA', '\u00BA', '\u00E6', '\u00B8', - '\u00C6', '\u00A4', '\u00B5', '~', 's', 't', 'u', 'v', 'w', 'x', - 'y', 'z', '\u00A1', '\u00BF', '\u00D0', '\u00DD', '\u00DE', - '\u00AE', '\u00A2', '\u00A3', '\u00A5', '\u00B7', '\u00A9', - '\u00A7', '\u00B6', '\u00BC', '\u00BD', '\u00BE', '\u00AC', '|', - '\u00AF', '\u00A8', '\u00B4', '\u00D7', '{', 'A', 'B', 'C', 'D', - 'E', 'F', 'G', 'H', 'I', '\u00AD', '\u00F4', '\u00F6', '\u00F2', - '\u00F3', '\u00F5', '}', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', - 'R', '\u00B9', '\u00FB', '\u00FC', '\u00F9', '\u00FA', '\u00FF', - '\\', '\u00F7', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '\u00B2', - '\u00D4', '\u00D6', '\u00D2', '\u00D3', '\u00D5', '0', '1', '2', - '3', '4', '5', '6', '7', '8', '9', '\u00B3', '\u00DB', '\u00DC', - '\u00D9', '\u00DA', '\u009F', }; + /* + * Char maps manually extracted from JTOpen v6.4. Because char maps can't be + * covered by any license, this should legal. + */ + private static final char[] codepage = { '\u0000', '\u0001', '\u0002', + '\u0003', '\u009C', '\t', '\u0086', '\u007F', '\u0097', '\u008D', + '\u008E', '\u000B', '\f', '\r', '\u000E', '\u000F', '\u0010', + '\u0011', '\u0012', '\u0013', '\u009D', '\u0085', '\u0008', + '\u0087', '\u0018', '\u0019', '\u0092', '\u008F', '\u001C', + '\u001D', '\u001E', '\u001F', '\u0080', '\u0081', '\u0082', + '\u0083', '\u0084', '\n', '\u0017', '\u001B', '\u0088', '\u0089', + '\u008A', '\u008B', '\u008C', '\u0005', '\u0006', '\u0007', + '\u0090', '\u0091', '\u0016', '\u0093', '\u0094', '\u0095', + '\u0096', '\u0004', '\u0098', '\u0099', '\u009A', '\u009B', + '\u0014', '\u0015', '\u009E', '\u001A', ' ', '\u00A0', '\u00E2', + '\u00E4', '\u00E0', '\u00E1', '\u00E3', '\u00E5', '\u00E7', + '\u00F1', '[', '.', '<', '(', '+', '!', '&', '\u00E9', '\u00EA', + '\u00EB', '\u00E8', '\u00ED', '\u00EE', '\u00EF', '\u00EC', + '\u00DF', ']', '$', '*', ')', ';', '^', '-', '/', '\u00C2', + '\u00C4', '\u00C0', '\u00C1', '\u00C3', '\u00C5', '\u00C7', + '\u00D1', '\u00A6', ',', '%', '_', '>', '?', '\u00F8', '\u00C9', + '\u00CA', '\u00CB', '\u00C8', '\u00CD', '\u00CE', '\u00CF', + '\u00CC', '`', ':', '#', '@', '\'', '=', '"', '\u00D8', 'a', 'b', + 'c', 'd', 'e', 'f', 'g', 'h', 'i', '\u00AB', '\u00BB', '\u00F0', + '\u00FD', '\u00FE', '\u00B1', '\u00B0', 'j', 'k', 'l', 'm', 'n', + 'o', 'p', 'q', 'r', '\u00AA', '\u00BA', '\u00E6', '\u00B8', + '\u00C6', '\u00A4', '\u00B5', '~', 's', 't', 'u', 'v', 'w', 'x', + 'y', 'z', '\u00A1', '\u00BF', '\u00D0', '\u00DD', '\u00DE', + '\u00AE', '\u00A2', '\u00A3', '\u00A5', '\u00B7', '\u00A9', + '\u00A7', '\u00B6', '\u00BC', '\u00BD', '\u00BE', '\u00AC', '|', + '\u00AF', '\u00A8', '\u00B4', '\u00D7', '{', 'A', 'B', 'C', 'D', + 'E', 'F', 'G', 'H', 'I', '\u00AD', '\u00F4', '\u00F6', '\u00F2', + '\u00F3', '\u00F5', '}', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', + 'R', '\u00B9', '\u00FB', '\u00FC', '\u00F9', '\u00FA', '\u00FF', + '\\', '\u00F7', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '\u00B2', + '\u00D4', '\u00D6', '\u00D2', '\u00D3', '\u00D5', '0', '1', '2', + '3', '4', '5', '6', '7', '8', '9', '\u00B3', '\u00DB', '\u00DC', + '\u00D9', '\u00DA', '\u009F', + }; - public String getName() { - return NAME; - } + public String getName() { + return NAME; + } - public String getDescription() { - return DESCR; - } + public String getDescription() { + return DESCR; + } - public String getEncoding() { - return NAME; - } + public String getEncoding() { + return NAME; + } - @Override - protected char[] getCodePage() { - return codepage; - } + @Override + protected char[] getCodePage() { + return codepage; + } } diff -r 6a0ad4d384ea -r 77ac18bc1b2f src/org/tn5250j/encoding/builtin/CCSID870.java --- a/src/org/tn5250j/encoding/builtin/CCSID870.java Wed Jun 18 13:00:19 2014 -0700 +++ b/src/org/tn5250j/encoding/builtin/CCSID870.java Wed Jun 18 13:03:01 2014 -0700 @@ -1,13 +1,13 @@ /** * $Id$ - * + * * Title: tn5250J * Copyright: Copyright (c) 2001,2009 * Company: * @author: master_jaf * * Description: - * Alternative (extended) implementation of a codepage converter CCSID 870<->Unicode. + * Alternative (extended) implementation of a codepage converter CCSID 870<->Unicode. * * * This program is free software; you can redistribute it and/or modify @@ -34,62 +34,63 @@ */ public final class CCSID870 extends CodepageConverterAdapter { - public final static String NAME = "870"; - public final static String DESCR = "Latin 2 - EBCDIC Multilingual"; + public final static String NAME = "870"; + public final static String DESCR = "Latin 2 - EBCDIC Multilingual"; - /* - * Char maps manually extracted from JTOpen v6.4. Because char maps can't be - * covered by any license, this should legal. - */ - private static final char[] codepage = { '\u0000', '\u0001', '\u0002', - '\u0003', '\u009C', '\t', '\u0086', '\u007F', '\u0097', '\u008D', - '\u008E', '\u000B', '\f', '\r', '\u000E', '\u000F', '\u0010', - '\u0011', '\u0012', '\u0013', '\u009D', '\u0085', '\u0008', - '\u0087', '\u0018', '\u0019', '\u0092', '\u008F', '\u001C', - '\u001D', '\u001E', '\u001F', '\u0080', '\u0081', '\u0082', - '\u0083', '\u0084', '\n', '\u0017', '\u001B', '\u0088', '\u0089', - '\u008A', '\u008B', '\u008C', '\u0005', '\u0006', '\u0007', - '\u0090', '\u0091', '\u0016', '\u0093', '\u0094', '\u0095', - '\u0096', '\u0004', '\u0098', '\u0099', '\u009A', '\u009B', - '\u0014', '\u0015', '\u009E', '\u001A', ' ', '\u00A0', '\u00E2', - '\u00E4', '\u0163', '\u00E1', '\u0103', '\u010D', '\u00E7', - '\u0107', '[', '.', '<', '(', '+', '!', '&', '\u00E9', '\u0119', - '\u00EB', '\u016F', '\u00ED', '\u00EE', '\u013E', '\u013A', - '\u00DF', ']', '$', '*', ')', ';', '^', '-', '/', '\u00C2', - '\u00C4', '\u02DD', '\u00C1', '\u0102', '\u010C', '\u00C7', - '\u0106', '|', ',', '%', '_', '>', '?', '\u02C7', '\u00C9', - '\u0118', '\u00CB', '\u016E', '\u00CD', '\u00CE', '\u013D', - '\u0139', '`', ':', '#', '@', '\'', '=', '"', '\u02D8', 'a', 'b', - 'c', 'd', 'e', 'f', 'g', 'h', 'i', '\u015B', '\u0148', '\u0111', - '\u00FD', '\u0159', '\u015F', '\u00B0', 'j', 'k', 'l', 'm', 'n', - 'o', 'p', 'q', 'r', '\u0142', '\u0144', '\u0161', '\u00B8', - '\u02DB', '\u00A4', '\u0105', '~', 's', 't', 'u', 'v', 'w', 'x', - 'y', 'z', '\u015A', '\u0147', '\u0110', '\u00DD', '\u0158', - '\u015E', '\u02D9', '\u0104', '\u017C', '\u0162', '\u017B', - '\u00A7', '\u017E', '\u017A', '\u017D', '\u0179', '\u0141', - '\u0143', '\u0160', '\u00A8', '\u00B4', '\u00D7', '{', 'A', 'B', - 'C', 'D', 'E', 'F', 'G', 'H', 'I', '\u00AD', '\u00F4', '\u00F6', - '\u0155', '\u00F3', '\u0151', '}', 'J', 'K', 'L', 'M', 'N', 'O', - 'P', 'Q', 'R', '\u011A', '\u0171', '\u00FC', '\u0165', '\u00FA', - '\u011B', '\\', '\u00F7', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', - '\u010F', '\u00D4', '\u00D6', '\u0154', '\u00D3', '\u0150', '0', - '1', '2', '3', '4', '5', '6', '7', '8', '9', '\u010E', '\u0170', - '\u00DC', '\u0164', '\u00DA', '\u009F', }; + /* + * Char maps manually extracted from JTOpen v6.4. Because char maps can't be + * covered by any license, this should legal. + */ + private static final char[] codepage = { '\u0000', '\u0001', '\u0002', + '\u0003', '\u009C', '\t', '\u0086', '\u007F', '\u0097', '\u008D', + '\u008E', '\u000B', '\f', '\r', '\u000E', '\u000F', '\u0010', + '\u0011', '\u0012', '\u0013', '\u009D', '\u0085', '\u0008', + '\u0087', '\u0018', '\u0019', '\u0092', '\u008F', '\u001C', + '\u001D', '\u001E', '\u001F', '\u0080', '\u0081', '\u0082', + '\u0083', '\u0084', '\n', '\u0017', '\u001B', '\u0088', '\u0089', + '\u008A', '\u008B', '\u008C', '\u0005', '\u0006', '\u0007', + '\u0090', '\u0091', '\u0016', '\u0093', '\u0094', '\u0095', + '\u0096', '\u0004', '\u0098', '\u0099', '\u009A', '\u009B', + '\u0014', '\u0015', '\u009E', '\u001A', ' ', '\u00A0', '\u00E2', + '\u00E4', '\u0163', '\u00E1', '\u0103', '\u010D', '\u00E7', + '\u0107', '[', '.', '<', '(', '+', '!', '&', '\u00E9', '\u0119', + '\u00EB', '\u016F', '\u00ED', '\u00EE', '\u013E', '\u013A', + '\u00DF', ']', '$', '*', ')', ';', '^', '-', '/', '\u00C2', + '\u00C4', '\u02DD', '\u00C1', '\u0102', '\u010C', '\u00C7', + '\u0106', '|', ',', '%', '_', '>', '?', '\u02C7', '\u00C9', + '\u0118', '\u00CB', '\u016E', '\u00CD', '\u00CE', '\u013D', + '\u0139', '`', ':', '#', '@', '\'', '=', '"', '\u02D8', 'a', 'b', + 'c', 'd', 'e', 'f', 'g', 'h', 'i', '\u015B', '\u0148', '\u0111', + '\u00FD', '\u0159', '\u015F', '\u00B0', 'j', 'k', 'l', 'm', 'n', + 'o', 'p', 'q', 'r', '\u0142', '\u0144', '\u0161', '\u00B8', + '\u02DB', '\u00A4', '\u0105', '~', 's', 't', 'u', 'v', 'w', 'x', + 'y', 'z', '\u015A', '\u0147', '\u0110', '\u00DD', '\u0158', + '\u015E', '\u02D9', '\u0104', '\u017C', '\u0162', '\u017B', + '\u00A7', '\u017E', '\u017A', '\u017D', '\u0179', '\u0141', + '\u0143', '\u0160', '\u00A8', '\u00B4', '\u00D7', '{', 'A', 'B', + 'C', 'D', 'E', 'F', 'G', 'H', 'I', '\u00AD', '\u00F4', '\u00F6', + '\u0155', '\u00F3', '\u0151', '}', 'J', 'K', 'L', 'M', 'N', 'O', + 'P', 'Q', 'R', '\u011A', '\u0171', '\u00FC', '\u0165', '\u00FA', + '\u011B', '\\', '\u00F7', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', + '\u010F', '\u00D4', '\u00D6', '\u0154', '\u00D3', '\u0150', '0', + '1', '2', '3', '4', '5', '6', '7', '8', '9', '\u010E', '\u0170', + '\u00DC', '\u0164', '\u00DA', '\u009F', + }; - public String getName() { - return NAME; - } + public String getName() { + return NAME; + } - public String getDescription() { - return DESCR; - } + public String getDescription() { + return DESCR; + } - public String getEncoding() { - return NAME; - } + public String getEncoding() { + return NAME; + } - @Override - protected char[] getCodePage() { - return codepage; - } + @Override + protected char[] getCodePage() { + return codepage; + } } diff -r 6a0ad4d384ea -r 77ac18bc1b2f src/org/tn5250j/encoding/builtin/CCSID871.java --- a/src/org/tn5250j/encoding/builtin/CCSID871.java Wed Jun 18 13:00:19 2014 -0700 +++ b/src/org/tn5250j/encoding/builtin/CCSID871.java Wed Jun 18 13:03:01 2014 -0700 @@ -1,13 +1,13 @@ /** * $Id$ - * + * * Title: tn5250J * Copyright: Copyright (c) 2001,2009 * Company: * @author: master_jaf * * Description: - * Alternative (extended) implementation of a codepage converter CCSID 871<->Unicode. + * Alternative (extended) implementation of a codepage converter CCSID 871<->Unicode. * * * This program is free software; you can redistribute it and/or modify @@ -34,62 +34,63 @@ */ public final class CCSID871 extends CodepageConverterAdapter { - public final static String NAME = "871"; - public final static String DESCR = "CECP: Iceland"; + public final static String NAME = "871"; + public final static String DESCR = "CECP: Iceland"; - /* - * Char maps manually extracted from JTOpen v6.4. Because char maps can't be - * covered by any license, this should legal. - */ - private static final char[] codepage = { '\u0000', '\u0001', '\u0002', - '\u0003', '\u009C', '\t', '\u0086', '\u007F', '\u0097', '\u008D', - '\u008E', '\u000B', '\f', '\r', '\u000E', '\u000F', '\u0010', - '\u0011', '\u0012', '\u0013', '\u009D', '\u0085', '\u0008', - '\u0087', '\u0018', '\u0019', '\u0092', '\u008F', '\u001C', - '\u001D', '\u001E', '\u001F', '\u0080', '\u0081', '\u0082', - '\u0083', '\u0084', '\n', '\u0017', '\u001B', '\u0088', '\u0089', - '\u008A', '\u008B', '\u008C', '\u0005', '\u0006', '\u0007', - '\u0090', '\u0091', '\u0016', '\u0093', '\u0094', '\u0095', - '\u0096', '\u0004', '\u0098', '\u0099', '\u009A', '\u009B', - '\u0014', '\u0015', '\u009E', '\u001A', ' ', '\u00A0', '\u00E2', - '\u00E4', '\u00E0', '\u00E1', '\u00E3', '\u00E5', '\u00E7', - '\u00F1', '\u00DE', '.', '<', '(', '+', '!', '&', '\u00E9', - '\u00EA', '\u00EB', '\u00E8', '\u00ED', '\u00EE', '\u00EF', - '\u00EC', '\u00DF', '\u00C6', '$', '*', ')', ';', '\u00D6', '-', - '/', '\u00C2', '\u00C4', '\u00C0', '\u00C1', '\u00C3', '\u00C5', - '\u00C7', '\u00D1', '\u00A6', ',', '%', '_', '>', '?', '\u00F8', - '\u00C9', '\u00CA', '\u00CB', '\u00C8', '\u00CD', '\u00CE', - '\u00CF', '\u00CC', '\u00F0', ':', '#', '\u00D0', '\'', '=', '"', - '\u00D8', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', '\u00AB', - '\u00BB', '`', '\u00FD', '{', '\u00B1', '\u00B0', 'j', 'k', 'l', - 'm', 'n', 'o', 'p', 'q', 'r', '\u00AA', '\u00BA', '}', '\u00B8', - ']', '\u00A4', '\u00B5', '\u00F6', 's', 't', 'u', 'v', 'w', 'x', - 'y', 'z', '\u00A1', '\u00BF', '@', '\u00DD', '[', '\u00AE', - '\u00A2', '\u00A3', '\u00A5', '\u00B7', '\u00A9', '\u00A7', - '\u00B6', '\u00BC', '\u00BD', '\u00BE', '\u00AC', '|', '\u00AF', - '\u00A8', '\\', '\u00D7', '\u00FE', 'A', 'B', 'C', 'D', 'E', 'F', - 'G', 'H', 'I', '\u00AD', '\u00F4', '~', '\u00F2', '\u00F3', - '\u00F5', '\u00E6', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', - '\u00B9', '\u00FB', '\u00FC', '\u00F9', '\u00FA', '\u00FF', - '\u00B4', '\u00F7', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', - '\u00B2', '\u00D4', '^', '\u00D2', '\u00D3', '\u00D5', '0', '1', - '2', '3', '4', '5', '6', '7', '8', '9', '\u00B3', '\u00DB', - '\u00DC', '\u00D9', '\u00DA', '\u009F', }; + /* + * Char maps manually extracted from JTOpen v6.4. Because char maps can't be + * covered by any license, this should legal. + */ + private static final char[] codepage = { '\u0000', '\u0001', '\u0002', + '\u0003', '\u009C', '\t', '\u0086', '\u007F', '\u0097', '\u008D', + '\u008E', '\u000B', '\f', '\r', '\u000E', '\u000F', '\u0010', + '\u0011', '\u0012', '\u0013', '\u009D', '\u0085', '\u0008', + '\u0087', '\u0018', '\u0019', '\u0092', '\u008F', '\u001C', + '\u001D', '\u001E', '\u001F', '\u0080', '\u0081', '\u0082', + '\u0083', '\u0084', '\n', '\u0017', '\u001B', '\u0088', '\u0089', + '\u008A', '\u008B', '\u008C', '\u0005', '\u0006', '\u0007', + '\u0090', '\u0091', '\u0016', '\u0093', '\u0094', '\u0095', + '\u0096', '\u0004', '\u0098', '\u0099', '\u009A', '\u009B', + '\u0014', '\u0015', '\u009E', '\u001A', ' ', '\u00A0', '\u00E2', + '\u00E4', '\u00E0', '\u00E1', '\u00E3', '\u00E5', '\u00E7', + '\u00F1', '\u00DE', '.', '<', '(', '+', '!', '&', '\u00E9', + '\u00EA', '\u00EB', '\u00E8', '\u00ED', '\u00EE', '\u00EF', + '\u00EC', '\u00DF', '\u00C6', '$', '*', ')', ';', '\u00D6', '-', + '/', '\u00C2', '\u00C4', '\u00C0', '\u00C1', '\u00C3', '\u00C5', + '\u00C7', '\u00D1', '\u00A6', ',', '%', '_', '>', '?', '\u00F8', + '\u00C9', '\u00CA', '\u00CB', '\u00C8', '\u00CD', '\u00CE', + '\u00CF', '\u00CC', '\u00F0', ':', '#', '\u00D0', '\'', '=', '"', + '\u00D8', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', '\u00AB', + '\u00BB', '`', '\u00FD', '{', '\u00B1', '\u00B0', 'j', 'k', 'l', + 'm', 'n', 'o', 'p', 'q', 'r', '\u00AA', '\u00BA', '}', '\u00B8', + ']', '\u00A4', '\u00B5', '\u00F6', 's', 't', 'u', 'v', 'w', 'x', + 'y', 'z', '\u00A1', '\u00BF', '@', '\u00DD', '[', '\u00AE', + '\u00A2', '\u00A3', '\u00A5', '\u00B7', '\u00A9', '\u00A7', + '\u00B6', '\u00BC', '\u00BD', '\u00BE', '\u00AC', '|', '\u00AF', + '\u00A8', '\\', '\u00D7', '\u00FE', 'A', 'B', 'C', 'D', 'E', 'F', + 'G', 'H', 'I', '\u00AD', '\u00F4', '~', '\u00F2', '\u00F3', + '\u00F5', '\u00E6', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', + '\u00B9', '\u00FB', '\u00FC', '\u00F9', '\u00FA', '\u00FF', + '\u00B4', '\u00F7', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', + '\u00B2', '\u00D4', '^', '\u00D2', '\u00D3', '\u00D5', '0', '1', + '2', '3', '4', '5', '6', '7', '8', '9', '\u00B3', '\u00DB', + '\u00DC', '\u00D9', '\u00DA', '\u009F', + }; - public String getName() { - return NAME; - } + public String getName() { + return NAME; + } - public String getDescription() { - return DESCR; - } + public String getDescription() { + return DESCR; + } - public String getEncoding() { - return NAME; - } + public String getEncoding() { + return NAME; + } - @Override - protected char[] getCodePage() { - return codepage; - } + @Override + protected char[] getCodePage() { + return codepage; + } } diff -r 6a0ad4d384ea -r 77ac18bc1b2f src/org/tn5250j/encoding/builtin/CCSID875.java --- a/src/org/tn5250j/encoding/builtin/CCSID875.java Wed Jun 18 13:00:19 2014 -0700 +++ b/src/org/tn5250j/encoding/builtin/CCSID875.java Wed Jun 18 13:03:01 2014 -0700 @@ -1,13 +1,13 @@ /** * $Id$ - * + * * Title: tn5250J * Copyright: Copyright (c) 2001,2009 * Company: * @author: master_jaf * * Description: - * Alternative (extended) implementation of a codepage converter CCSID 875<->Unicode. + * Alternative (extended) implementation of a codepage converter CCSID 875<->Unicode. * * * This program is free software; you can redistribute it and/or modify @@ -34,62 +34,63 @@ */ public final class CCSID875 extends CodepageConverterAdapter { - public final static String NAME = "875"; - public final static String DESCR = "Greek"; + public final static String NAME = "875"; + public final static String DESCR = "Greek"; - /* - * Char maps manually extracted from JTOpen v6.4. Because char maps can't be - * covered by any license, this should legal. - */ - private static final char[] codepage = { '\u0000', '\u0001', '\u0002', - '\u0003', '\u009C', '\t', '\u0086', '\u007F', '\u0097', '\u008D', - '\u008E', '\u000B', '\f', '\r', '\u000E', '\u000F', '\u0010', - '\u0011', '\u0012', '\u0013', '\u009D', '\u0085', '\u0008', - '\u0087', '\u0018', '\u0019', '\u0092', '\u008F', '\u001C', - '\u001D', '\u001E', '\u001F', '\u0080', '\u0081', '\u0082', - '\u0083', '\u0084', '\n', '\u0017', '\u001B', '\u0088', '\u0089', - '\u008A', '\u008B', '\u008C', '\u0005', '\u0006', '\u0007', - '\u0090', '\u0091', '\u0016', '\u0093', '\u0094', '\u0095', - '\u0096', '\u0004', '\u0098', '\u0099', '\u009A', '\u009B', - '\u0014', '\u0015', '\u009E', '\u001A', ' ', '\u0391', '\u0392', - '\u0393', '\u0394', '\u0395', '\u0396', '\u0397', '\u0398', - '\u0399', '[', '.', '<', '(', '+', '!', '&', '\u039A', '\u039B', - '\u039C', '\u039D', '\u039E', '\u039F', '\u03A0', '\u03A1', - '\u03A3', ']', '$', '*', ')', ';', '^', '-', '/', '\u03A4', - '\u03A5', '\u03A6', '\u03A7', '\u03A8', '\u03A9', '\u03AA', - '\u03AB', '|', ',', '%', '_', '>', '?', '\u00A8', '\u0386', - '\u0388', '\u0389', '\u00A0', '\u038A', '\u038C', '\u038E', - '\u038F', '`', ':', '#', '@', '\'', '=', '"', '\u0385', 'a', 'b', - 'c', 'd', 'e', 'f', 'g', 'h', 'i', '\u03B1', '\u03B2', '\u03B3', - '\u03B4', '\u03B5', '\u03B6', '\u00B0', 'j', 'k', 'l', 'm', 'n', - 'o', 'p', 'q', 'r', '\u03B7', '\u03B8', '\u03B9', '\u03BA', - '\u03BB', '\u03BC', '\u00B4', '~', 's', 't', 'u', 'v', 'w', 'x', - 'y', 'z', '\u03BD', '\u03BE', '\u03BF', '\u03C0', '\u03C1', - '\u03C3', '\u00A3', '\u03AC', '\u03AD', '\u03AE', '\u03CA', - '\u03AF', '\u03CC', '\u03CD', '\u03CB', '\u03CE', '\u03C2', - '\u03C4', '\u03C5', '\u03C6', '\u03C7', '\u03C8', '{', 'A', 'B', - 'C', 'D', 'E', 'F', 'G', 'H', 'I', '\u00AD', '\u03C9', '\u0390', - '\u03B0', '\u2018', '\u2015', '}', 'J', 'K', 'L', 'M', 'N', 'O', - 'P', 'Q', 'R', '\u00B1', '\u00BD', '\u001A', '\u0387', '\u2019', - '\u00A6', '\\', '\u001A', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', - '\u00B2', '\u00A7', '\u001A', '\u001A', '\u00AB', '\u00AC', '0', - '1', '2', '3', '4', '5', '6', '7', '8', '9', '\u00B3', '\u00A9', - '\u001A', '\u001A', '\u00BB', '\u009F', }; + /* + * Char maps manually extracted from JTOpen v6.4. Because char maps can't be + * covered by any license, this should legal. + */ + private static final char[] codepage = { '\u0000', '\u0001', '\u0002', + '\u0003', '\u009C', '\t', '\u0086', '\u007F', '\u0097', '\u008D', + '\u008E', '\u000B', '\f', '\r', '\u000E', '\u000F', '\u0010', + '\u0011', '\u0012', '\u0013', '\u009D', '\u0085', '\u0008', + '\u0087', '\u0018', '\u0019', '\u0092', '\u008F', '\u001C', + '\u001D', '\u001E', '\u001F', '\u0080', '\u0081', '\u0082', + '\u0083', '\u0084', '\n', '\u0017', '\u001B', '\u0088', '\u0089', + '\u008A', '\u008B', '\u008C', '\u0005', '\u0006', '\u0007', + '\u0090', '\u0091', '\u0016', '\u0093', '\u0094', '\u0095', + '\u0096', '\u0004', '\u0098', '\u0099', '\u009A', '\u009B', + '\u0014', '\u0015', '\u009E', '\u001A', ' ', '\u0391', '\u0392', + '\u0393', '\u0394', '\u0395', '\u0396', '\u0397', '\u0398', + '\u0399', '[', '.', '<', '(', '+', '!', '&', '\u039A', '\u039B', + '\u039C', '\u039D', '\u039E', '\u039F', '\u03A0', '\u03A1', + '\u03A3', ']', '$', '*', ')', ';', '^', '-', '/', '\u03A4', + '\u03A5', '\u03A6', '\u03A7', '\u03A8', '\u03A9', '\u03AA', + '\u03AB', '|', ',', '%', '_', '>', '?', '\u00A8', '\u0386', + '\u0388', '\u0389', '\u00A0', '\u038A', '\u038C', '\u038E', + '\u038F', '`', ':', '#', '@', '\'', '=', '"', '\u0385', 'a', 'b', + 'c', 'd', 'e', 'f', 'g', 'h', 'i', '\u03B1', '\u03B2', '\u03B3', + '\u03B4', '\u03B5', '\u03B6', '\u00B0', 'j', 'k', 'l', 'm', 'n', + 'o', 'p', 'q', 'r', '\u03B7', '\u03B8', '\u03B9', '\u03BA', + '\u03BB', '\u03BC', '\u00B4', '~', 's', 't', 'u', 'v', 'w', 'x', + 'y', 'z', '\u03BD', '\u03BE', '\u03BF', '\u03C0', '\u03C1', + '\u03C3', '\u00A3', '\u03AC', '\u03AD', '\u03AE', '\u03CA', + '\u03AF', '\u03CC', '\u03CD', '\u03CB', '\u03CE', '\u03C2', + '\u03C4', '\u03C5', '\u03C6', '\u03C7', '\u03C8', '{', 'A', 'B', + 'C', 'D', 'E', 'F', 'G', 'H', 'I', '\u00AD', '\u03C9', '\u0390', + '\u03B0', '\u2018', '\u2015', '}', 'J', 'K', 'L', 'M', 'N', 'O', + 'P', 'Q', 'R', '\u00B1', '\u00BD', '\u001A', '\u0387', '\u2019', + '\u00A6', '\\', '\u001A', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', + '\u00B2', '\u00A7', '\u001A', '\u001A', '\u00AB', '\u00AC', '0', + '1', '2', '3', '4', '5', '6', '7', '8', '9', '\u00B3', '\u00A9', + '\u001A', '\u001A', '\u00BB', '\u009F', + }; - public String getName() { - return NAME; - } + public String getName() { + return NAME; + } - public String getDescription() { - return DESCR; - } + public String getDescription() { + return DESCR; + } - public String getEncoding() { - return NAME; - } + public String getEncoding() { + return NAME; + } - @Override - protected char[] getCodePage() { - return codepage; - } + @Override + protected char[] getCodePage() { + return codepage; + } } diff -r 6a0ad4d384ea -r 77ac18bc1b2f src/org/tn5250j/encoding/builtin/CodepageConverterAdapter.java --- a/src/org/tn5250j/encoding/builtin/CodepageConverterAdapter.java Wed Jun 18 13:00:19 2014 -0700 +++ b/src/org/tn5250j/encoding/builtin/CodepageConverterAdapter.java Wed Jun 18 13:03:01 2014 -0700 @@ -1,6 +1,6 @@ /** * $Id$ - * + * * Title: tn5250J * Copyright: Copyright (c) 2001,2009 * Company: @@ -30,53 +30,56 @@ /** * Adapter class for converters using 8bit codepages. - * + * * @author master_jaf */ public abstract class CodepageConverterAdapter implements ICodepageConverter { - - private char[] codepage = null; - private int[] reverse_codepage = null; - - /* (non-Javadoc) - * @see org.tn5250j.cp.ICodepageConverter#init() - */ - public ICodepageConverter init() { - codepage = getCodePage(); - - int size = 0; - for (int i=0; i dsq; - private byte[] abyte2; - private FileOutputStream fw; - private BufferedOutputStream dw; - private boolean dumpBytes = false; - private ICodePage codePage; + private tnvt vt; + private BufferedInputStream bin; + private ByteArrayOutputStream baosin; + private Thread me; + private byte[] saveStream; + private final BlockingQueue dsq; + private byte[] abyte2; + private FileOutputStream fw; + private BufferedOutputStream dw; + private boolean dumpBytes = false; + private ICodePage codePage; - public DataStreamProducer(tnvt vt, BufferedInputStream bin, BlockingQueue queue, byte[] init) { - this.bin = bin; - this.vt = vt; - baosin = new ByteArrayOutputStream(); - dsq = queue; - abyte2 = init; - } - - public void setInputStream(ByteArrayOutputStream is) { - - baosin = is; - - } + public DataStreamProducer(tnvt vt, BufferedInputStream bin, BlockingQueue queue, byte[] init) { + this.bin = bin; + this.vt = vt; + baosin = new ByteArrayOutputStream(); + dsq = queue; + abyte2 = init; + } - public final void run() { - - boolean done = false; - - me = Thread.currentThread(); + public void setInputStream(ByteArrayOutputStream is) { + baosin = is; + } - // load the first response screen - loadStream(abyte2, 0); + public final void run() { + boolean done = false; + me = Thread.currentThread(); + // load the first response screen + loadStream(abyte2, 0); - while (!done) { - try { - - byte[] abyte0 = readIncoming(); + while (!done) { + try { + byte[] abyte0 = readIncoming(); - // WVL - LDC : 17/05/2004 : Device name negotiations send TIMING MARK - // Restructured to the readIncoming() method to return null - // on TIMING MARK. Don't process in that case (abyte0 == null)! - if (abyte0 != null) - { - // WVL - LDC : 16/07/2003 : TR.000345 - // When the socket has been closed, the reading returns - // no bytes (an empty byte arrray). - // But the loadStream fails on this, so we check it here! - if (abyte0.length > 0) - { - loadStream(abyte0, 0); - } - // WVL - LDC : 16/07/2003 : TR.000345 - // Returning no bytes means the input buffer has - // reached end-of-stream, so we do a disconnect! - else - { - done = true; - vt.disconnect(); - } - } + // WVL - LDC : 17/05/2004 : Device name negotiations send TIMING MARK + // Restructured to the readIncoming() method to return null + // on TIMING MARK. Don't process in that case (abyte0 == null)! + if (abyte0 != null) { + // WVL - LDC : 16/07/2003 : TR.000345 + // When the socket has been closed, the reading returns + // no bytes (an empty byte arrray). + // But the loadStream fails on this, so we check it here! + if (abyte0.length > 0) { + loadStream(abyte0, 0); + } + // WVL - LDC : 16/07/2003 : TR.000345 + // Returning no bytes means the input buffer has + // reached end-of-stream, so we do a disconnect! + else { + done = true; + vt.disconnect(); + } + } + } + catch (SocketException se) { + Log.w(TAG, " DataStreamProducer thread interrupted and stopping " + se.getMessage()); + done = true; + } + catch (IOException ioe) { + Log.w(TAG, ioe.getMessage()); - } - - catch (SocketException se) { - Log.w(TAG," DataStreamProducer thread interrupted and stopping " + se.getMessage()); - done = true; - } - - catch (IOException ioe) { + if (me.isInterrupted()) + done = true; + } + catch (Exception ex) { + Log.w(TAG, ex.getMessage()); - Log.w(TAG,ioe.getMessage()); - if (me.isInterrupted()) - done = true; - - } - catch (Exception ex) { - - Log.w(TAG,ex.getMessage()); - if (me.isInterrupted()) - done = true; - - } - } + if (me.isInterrupted()) + done = true; + } + } } - private final void loadStream(byte abyte0[], int i) { + private final void loadStream(byte abyte0[], int i) { + int j = 0; + int size = 0; - int j = 0; - int size = 0; - if (saveStream == null) { - j = (abyte0[i] & 0xff) << 8 | abyte0[i + 1] & 0xff; - size = abyte0.length; - } - else { - size = saveStream.length + abyte0.length; - byte[] inter = new byte[size]; - System.arraycopy(saveStream, 0, inter, 0, saveStream.length); - System.arraycopy(abyte0, 0, inter, saveStream.length, abyte0.length); - abyte0 = new byte[size]; - System.arraycopy(inter, 0, abyte0, 0, size); - saveStream = null; - inter = null; - j = (abyte0[i] & 0xff) << 8 | abyte0[i + 1] & 0xff; - Log.d(TAG,"partial stream found"); - } + if (saveStream == null) { + j = (abyte0[i] & 0xff) << 8 | abyte0[i + 1] & 0xff; + size = abyte0.length; + } + else { + size = saveStream.length + abyte0.length; + byte[] inter = new byte[size]; + System.arraycopy(saveStream, 0, inter, 0, saveStream.length); + System.arraycopy(abyte0, 0, inter, saveStream.length, abyte0.length); + abyte0 = new byte[size]; + System.arraycopy(inter, 0, abyte0, 0, size); + saveStream = null; + inter = null; + j = (abyte0[i] & 0xff) << 8 | abyte0[i + 1] & 0xff; + Log.d(TAG, "partial stream found"); + } - if (j > size) { - saveStream = new byte[abyte0.length]; - System.arraycopy(abyte0, 0, saveStream, 0, abyte0.length); - Log.d(TAG,"partial stream saved"); - } - else { - byte abyte1[]; - try { - abyte1 = new byte[j + 2]; + if (j > size) { + saveStream = new byte[abyte0.length]; + System.arraycopy(abyte0, 0, saveStream, 0, abyte0.length); + Log.d(TAG, "partial stream saved"); + } + else { + byte abyte1[]; - System.arraycopy(abyte0, i, abyte1, 0, j + 2); - dsq.put(abyte1); - if(abyte0.length > abyte1.length + i) - loadStream(abyte0, i + j + 2); - } - catch (Exception ex) { + try { + abyte1 = new byte[j + 2]; + System.arraycopy(abyte0, i, abyte1, 0, j + 2); + dsq.put(abyte1); - Log.w(TAG,"load stream error " + ex.getMessage()); - // ex.printStackTrace(); - // dump(abyte0); - - } - } - } + if (abyte0.length > abyte1.length + i) + loadStream(abyte0, i + j + 2); + } + catch (Exception ex) { + Log.w(TAG, "load stream error " + ex.getMessage()); + // ex.printStackTrace(); + // dump(abyte0); + } + } + } - public final byte[] readIncoming() - throws IOException { - - boolean done = false; - boolean negotiate = false; + public final byte[] readIncoming() + throws IOException { + boolean done = false; + boolean negotiate = false; + baosin.reset(); + int j = -1; + int i = 0; - baosin.reset(); - int j = -1; - int i = 0; - - while(!done) { - i = bin.read(); + while (!done) { + i = bin.read(); - // WVL - LDC : 16/07/2003 : TR.000345 - // The inStream return -1 when end-of-stream is reached. This - // happens e.g. when the connection is closed from the AS/400. - // So we stop in this case! - // ==> an empty byte array is returned from this method. - if (i == -1) // nothing read! - { - done = true; - vt.disconnect(); - continue; - } + // WVL - LDC : 16/07/2003 : TR.000345 + // The inStream return -1 when end-of-stream is reached. This + // happens e.g. when the connection is closed from the AS/400. + // So we stop in this case! + // ==> an empty byte array is returned from this method. + if (i == -1) { // nothing read! + done = true; + vt.disconnect(); + continue; + } - // We use the values instead of the static values IAC and EOR - // because they are defined as bytes. - // - // The > if(i != 255 || j != 255) < is a hack for the double FF FF's - // that are being returned. I do not know why this is like this and - // can not find any documentation for it. It is also being returned - // on my Client Access tcp dump as well so they are handling it. - // - // my5250 - // 0000: 00 50 DA 44 C8 45 42 00 00 00 00 24 08 00 45 00 .P.D.EB....$..E. - // 0010: 04 2A BC F9 00 00 40 06 D0 27 C1 A8 33 04 C1 A8 .*....@..'..3... - // 0020: 33 58 00 17 04 18 6F A2 83 CB 00 1E D1 BA 50 18 3X....o.......P. - // 0030: 20 00 8A 9A 00 00 03 FF FF 12 A0 00 00 04 00 00 ............... - // --------------------------- || || ------------------------------------- - // 0040: 03 04 40 04 11 00 20 01 07 00 00 00 18 00 00 10 ..@... ......... + // We use the values instead of the static values IAC and EOR + // because they are defined as bytes. + // + // The > if(i != 255 || j != 255) < is a hack for the double FF FF's + // that are being returned. I do not know why this is like this and + // can not find any documentation for it. It is also being returned + // on my Client Access tcp dump as well so they are handling it. + // + // my5250 + // 0000: 00 50 DA 44 C8 45 42 00 00 00 00 24 08 00 45 00 .P.D.EB....$..E. + // 0010: 04 2A BC F9 00 00 40 06 D0 27 C1 A8 33 04 C1 A8 .*....@..'..3... + // 0020: 33 58 00 17 04 18 6F A2 83 CB 00 1E D1 BA 50 18 3X....o.......P. + // 0030: 20 00 8A 9A 00 00 03 FF FF 12 A0 00 00 04 00 00 ............... + // --------------------------- || || ------------------------------------- + // 0040: 03 04 40 04 11 00 20 01 07 00 00 00 18 00 00 10 ..@... ......... + + if (j == 255 && i == 255) { + j = -1; + continue; + } + + baosin.write(i); - if(j == 255 && i == 255) { - j = -1; - continue; - } - baosin.write(i); - // check for end of record EOR and IAC - FFEF - if(j == 255 && i == 239) - done = true; + // check for end of record EOR and IAC - FFEF + if (j == 255 && i == 239) + done = true; - // This is to check for the TELNET TIMING MARK OPTION - // rfc860 explains this in more detail. When we receive it - // we will negotiate with the server by sending a WONT'T TIMING-MARK - // This will let the server know that we processed the information - // and are just waiting for the user to enter some data so keep the - // socket alive. This is more or less a AYT (ARE YOU THERE) or not. - if(i == 253 && j == 255) { - done = true; - negotiate = true; + // This is to check for the TELNET TIMING MARK OPTION + // rfc860 explains this in more detail. When we receive it + // we will negotiate with the server by sending a WONT'T TIMING-MARK + // This will let the server know that we processed the information + // and are just waiting for the user to enter some data so keep the + // socket alive. This is more or less a AYT (ARE YOU THERE) or not. + if (i == 253 && j == 255) { + done = true; + negotiate = true; + } + + j = i; } - j = i; - } - - // after the initial negotiation we might get other options such as - // timing marks ?????????????? do we ???????????? look at telnet spec - // yes we do. rfc860 explains about timing marks. - // WVL - LDC : 17/05/2004 : Device name negotiations send TIMING MARK - // to existing device! - // Handled incorrectly: we cannot continue processing the TIMING MARK DO - // after we have handled it in the vt.negotiate() - // We should not return the bytes; - // ==> restructured to return null after negotiation! - // Impacts the run method! Added the null check. - byte[] rBytes = baosin.toByteArray(); + // after the initial negotiation we might get other options such as + // timing marks ?????????????? do we ???????????? look at telnet spec + // yes we do. rfc860 explains about timing marks. + // WVL - LDC : 17/05/2004 : Device name negotiations send TIMING MARK + // to existing device! + // Handled incorrectly: we cannot continue processing the TIMING MARK DO + // after we have handled it in the vt.negotiate() + // We should not return the bytes; + // ==> restructured to return null after negotiation! + // Impacts the run method! Added the null check. + byte[] rBytes = baosin.toByteArray(); - if (dumpBytes) { - dump(rBytes); - } + if (dumpBytes) { + dump(rBytes); + } - if (negotiate) { + if (negotiate) { // get the negotiation option baosin.write(bin.read()); vt.negotiate(rBytes); + return null; + } - return null; - } - return rBytes; - } - - protected final void toggleDebug (ICodePage cp) { + return rBytes; + } - if (codePage == null) - codePage = cp; + protected final void toggleDebug(ICodePage cp) { + if (codePage == null) + codePage = cp; + + dumpBytes = !dumpBytes; - dumpBytes = !dumpBytes; - if (dumpBytes) { - - try { - if (fw == null) { - fw = new FileOutputStream("log.txt"); - dw = new BufferedOutputStream(fw); + if (dumpBytes) { + try { + if (fw == null) { + fw = new FileOutputStream("log.txt"); + dw = new BufferedOutputStream(fw); + } } - } - catch (FileNotFoundException fnfe) { - Log.w(TAG,fnfe.getMessage()); - } - - } - else { - - try { + catch (FileNotFoundException fnfe) { + Log.w(TAG, fnfe.getMessage()); + } + } + else { + try { + if (dw != null) + dw.close(); - if (dw != null) - dw.close(); - if (fw != null) - fw.close(); - dw = null; - fw = null; - codePage = null; - } - catch(IOException ioe) { + if (fw != null) + fw.close(); + + dw = null; + fw = null; + codePage = null; + } + catch (IOException ioe) { + Log.w(TAG, ioe.getMessage()); + } + } - Log.w(TAG,ioe.getMessage()); - } - } - - Log.i(TAG,"Data Stream output is now " + dumpBytes); - } + Log.i(TAG, "Data Stream output is now " + dumpBytes); + } - public void dump (byte[] abyte0) { - try { - - Log.i(TAG,"\n Buffer Dump of data from AS400: "); - dw.write("\r\n Buffer Dump of data from AS400: ".getBytes()); - - StringBuffer h = new StringBuffer(); - for (int x = 0; x < abyte0.length; x++) { - if (x % 16 == 0) { - System.out.println(" " + h.toString()); - dw.write((" " + h.toString() + "\r\n").getBytes()); + public void dump(byte[] abyte0) { + try { + Log.i(TAG, "\n Buffer Dump of data from AS400: "); + dw.write("\r\n Buffer Dump of data from AS400: ".getBytes()); + StringBuffer h = new StringBuffer(); - h.setLength(0); - h.append("+0000"); - h.setLength(5 - Integer.toHexString(x).length()); - h.append(Integer.toHexString(x).toUpperCase()); + for (int x = 0; x < abyte0.length; x++) { + if (x % 16 == 0) { + System.out.println(" " + h.toString()); + dw.write((" " + h.toString() + "\r\n").getBytes()); + h.setLength(0); + h.append("+0000"); + h.setLength(5 - Integer.toHexString(x).length()); + h.append(Integer.toHexString(x).toUpperCase()); + System.out.print(h.toString()); + dw.write(h.toString().getBytes()); + h.setLength(0); + } - System.out.print(h.toString()); - dw.write(h.toString().getBytes()); + char ac = codePage.ebcdic2uni(abyte0[x]); - h.setLength(0); - } - char ac = codePage.ebcdic2uni(abyte0[x]); - if (ac < ' ') - h.append('.'); - else - h.append(ac); - if (x % 4 == 0) { - System.out.print(" "); - dw.write((" ").getBytes()); + if (ac < ' ') + h.append('.'); + else + h.append(ac); + if (x % 4 == 0) { + System.out.print(" "); + dw.write((" ").getBytes()); + } + + if (Integer.toHexString(abyte0[x] & 0xff).length() == 1) { + System.out.print("0" + Integer.toHexString(abyte0[x] & 0xff).toUpperCase()); + dw.write(("0" + Integer.toHexString(abyte0[x] & 0xff).toUpperCase()).getBytes()); + } + else { + System.out.print(Integer.toHexString(abyte0[x] & 0xff).toUpperCase()); + dw.write((Integer.toHexString(abyte0[x] & 0xff).toUpperCase()).getBytes()); + } } - if (Integer.toHexString(abyte0[x] & 0xff).length() == 1){ - System.out.print("0" + Integer.toHexString(abyte0[x] & 0xff).toUpperCase()); - dw.write(("0" + Integer.toHexString(abyte0[x] & 0xff).toUpperCase()).getBytes()); - - } - else { - System.out.print(Integer.toHexString(abyte0[x] & 0xff).toUpperCase()); - dw.write((Integer.toHexString(abyte0[x] & 0xff).toUpperCase()).getBytes()); - } - - } - System.out.println(); - dw.write("\r\n".getBytes()); - - dw.flush(); - } - catch(EOFException _ex) { } - catch(Exception _ex) { - Log.w(TAG,"Cannot dump from host\n\r"); - } - - } + System.out.println(); + dw.write("\r\n".getBytes()); + dw.flush(); + } + catch (EOFException _ex) { } + catch (Exception _ex) { + Log.w(TAG, "Cannot dump from host\n\r"); + } + } // public void dumpBytes() { // byte shit[] = bk.buffer; diff -r 6a0ad4d384ea -r 77ac18bc1b2f src/org/tn5250j/framework/tn5250/KbdTypesCodePages.java --- a/src/org/tn5250j/framework/tn5250/KbdTypesCodePages.java Wed Jun 18 13:00:19 2014 -0700 +++ b/src/org/tn5250j/framework/tn5250/KbdTypesCodePages.java Wed Jun 18 13:03:01 2014 -0700 @@ -1,112 +1,112 @@ package org.tn5250j.framework.tn5250; /** - * IBM i 7.1 Information Center > Programmierung > i5/OS globalization > Globalization reference information > Keyboard reference information - * + * IBM i 7.1 Information Center > Programmierung > i5/OS globalization > Globalization reference information > Keyboard reference information + * * @see National language keyboard types and SBCS code pages */ public enum KbdTypesCodePages { - - ALI("Albanian","ALI","697","500","500"), - CLB("Arabic","CLB","235","420","420"), - AGB("Austrian/ German","AGB","697","273","273"), - AGE("Austrian/ German","AGB","695","1141","1141"), - AGI("Austrian/German (MNCS)","AGI","697","500","500"), - BLI("Belgian MNCS","BLI","697","500","500"), - BRB("Brazilian Portuguese","BRB","697","37","37"), - BGB("Bulgarian","BGB","1150","1025","1025"), - CAB("Canadian French","CAB","341","260","65535"), - CAI("Canadian French MNCS","CAI","697","500","500"), -// YGI("Croatian","YGI","959","870","870"), - CYB("Cyrillic","CYB","960","880","880"), - CSB("Czech","CSB","959","870","870"), - DMB("Danish","DMB","697","277","277"), - DMI("Danish MNCS","DMI","697","500","500"), - FNB("Finnish/Swedish","FNB","697","278","278"), - FNI("Finnish/Swedish MNCS","FNI","697","500","500"), - FAB("French (Azerty)","FAB","697","297","297"), - FAI("French (Azerty) MNCS","FAI","697","500","500"), - FQB("French (Qwerty)","FQB","697","297","297"), - FQI("French (Qwerty) MNCS","FQI","697","500","500"), - GNB("Greek (See note 2.)","GNB","925","875","875"), - NCB("Hebrew","NCB","941","424","424"), - HNB("Hungarian","HNB","959","870","870"), - ICB("Icelandic","ICB","697","871","871"), - ICI("Icelandic MNCS","ICI","697","500","500"), - INB("International","INB","697","500","500"), - INBX("International-X","INB","697","500","500-ch"), -// INB("International MNCS","INB","697","500","500"), - IRB("Farsi (Iran)","IRB","1219","1097","1097"), - ITB("Italian","ITB","697","280","280"), - ITI("Italian MNCS","ITI","697","500","500"), - JEB("Japanese-English","JEB","697","281","65535"), - JEI("Japanese- English MNCS","JEI","697","500","500"), - JKB("Japanese Kanji and Katakana","JKB","1172","290","5026"), -// JUB("Japanese Kanji and US English","JUB","697","37","See note 3."), - KAB("Japanese Katakana","KAB","332","290","290"), - JPB("Japanese Latin Extended","JPB","1172","1027","1027"), - KOB("Korean","KOB","1173","833","833"), - ROB("Latin 2","ROB","959","870","870"), - MKB("Macedonian","MKB","1150","1025","1025"), - NEB("Dutch (Netherlands)","NEB","697","37","37"), - NEI("Dutch (Netherlands) MNCS","NEI","697","500","500"), - NWB("Norwegian","NWB","697","277","277"), - NWI("Norwegian MNCS","NWI","697","500","500"), - PLB("Polish","PLB","959","870","870"), - PLBX("Polish 870-pl","PLB","959","870","870-pl"), // Workaround, to catch up Java codepage '870-pl' - PRB("Portuguese","PRB","697","37","37"), - PRI("Portuguese MNCS","PRI","697","500","500"), - RMB("Romanian","RMB","959","870","870"), - RUB("Russian","RUB","1150","1025","1025"), - SQB("Serbian, Cyrillic","SQB","1150","1025","1025"), - YGI("Serbian, Latin","YGI","959","870","870"), - RCB("Simplified Chinese","RCB","1174","836","836"), - SKB("Slovakian","SKB","959","870","870"), - SKBX("Slovakian 870-sk","SKB","959","870","870-sk"), // Workaround, to catch up Java codepage '870-sk' -// YGI("Slovenian","YGI","959","870","870"), - SPB("Spanish","SPB","697","284","284"), - SPI("Spanish MNCS","SPI","697","500","500"), - SSB("Spanish Speaking","SSB","697","284","284"), - SSI("Spanish Speaking MNCS","SSI","697","500","500"), - SWB("Swedish","SWB","697","278","278"), - SWI("Swedish MNCS","SWI","697","500","500"), - SFI("French (Switzerland) MNCS","SFI","697","500","500"), - SGI("German (Switzerland) MNCS","SGI","697","500","500"), - THB("Thai","THB","1176","838","838"), - TAB("Traditional Chinese","TAB","1175","37","937"), - TKB("Turkish (Qwerty)","TKB","1152","1026","1026"), - TRB("Turkish (F)","TRB","1152","1026","1026"), - UKB("English (United Kingdom)","UKB","697","285","285"), - UKI("English (United Kingdom) MNCS","UKI","697","500","500"), - USB("English (United States and Canada)","USB","697","37","37"), - USI("English (United States and Canada) MNCS","USI","697","500","500"); - - public final String description; - public final String kbdType; - public final String charset; - public final String codepage; - public final String ccsid; - - /** - * @param description - * @param kbdType - * @param charset - * @param codepage - * @param ccsid - */ - private KbdTypesCodePages(String description, String kbdType, String charset, String codepage, String ccsid) { - this.description = description; - this.kbdType = kbdType; - this.charset = charset; - this.codepage = codepage; - this.ccsid = ccsid; - } - @Override - public String toString() { - return "[description=" + description + ", kbdType=" + kbdType - + ", charset=" + charset + ", codepage=" + codepage - + ", ccsid=" + ccsid + "]"; - } + ALI("Albanian", "ALI", "697", "500", "500"), + CLB("Arabic", "CLB", "235", "420", "420"), + AGB("Austrian/ German", "AGB", "697", "273", "273"), + AGE("Austrian/ German", "AGB", "695", "1141", "1141"), + AGI("Austrian/German (MNCS)", "AGI", "697", "500", "500"), + BLI("Belgian MNCS", "BLI", "697", "500", "500"), + BRB("Brazilian Portuguese", "BRB", "697", "37", "37"), + BGB("Bulgarian", "BGB", "1150", "1025", "1025"), + CAB("Canadian French", "CAB", "341", "260", "65535"), + CAI("Canadian French MNCS", "CAI", "697", "500", "500"), +// YGI("Croatian","YGI","959","870","870"), + CYB("Cyrillic", "CYB", "960", "880", "880"), + CSB("Czech", "CSB", "959", "870", "870"), + DMB("Danish", "DMB", "697", "277", "277"), + DMI("Danish MNCS", "DMI", "697", "500", "500"), + FNB("Finnish/Swedish", "FNB", "697", "278", "278"), + FNI("Finnish/Swedish MNCS", "FNI", "697", "500", "500"), + FAB("French (Azerty)", "FAB", "697", "297", "297"), + FAI("French (Azerty) MNCS", "FAI", "697", "500", "500"), + FQB("French (Qwerty)", "FQB", "697", "297", "297"), + FQI("French (Qwerty) MNCS", "FQI", "697", "500", "500"), + GNB("Greek (See note 2.)", "GNB", "925", "875", "875"), + NCB("Hebrew", "NCB", "941", "424", "424"), + HNB("Hungarian", "HNB", "959", "870", "870"), + ICB("Icelandic", "ICB", "697", "871", "871"), + ICI("Icelandic MNCS", "ICI", "697", "500", "500"), + INB("International", "INB", "697", "500", "500"), + INBX("International-X", "INB", "697", "500", "500-ch"), +// INB("International MNCS","INB","697","500","500"), + IRB("Farsi (Iran)", "IRB", "1219", "1097", "1097"), + ITB("Italian", "ITB", "697", "280", "280"), + ITI("Italian MNCS", "ITI", "697", "500", "500"), + JEB("Japanese-English", "JEB", "697", "281", "65535"), + JEI("Japanese- English MNCS", "JEI", "697", "500", "500"), + JKB("Japanese Kanji and Katakana", "JKB", "1172", "290", "5026"), +// JUB("Japanese Kanji and US English","JUB","697","37","See note 3."), + KAB("Japanese Katakana", "KAB", "332", "290", "290"), + JPB("Japanese Latin Extended", "JPB", "1172", "1027", "1027"), + KOB("Korean", "KOB", "1173", "833", "833"), + ROB("Latin 2", "ROB", "959", "870", "870"), + MKB("Macedonian", "MKB", "1150", "1025", "1025"), + NEB("Dutch (Netherlands)", "NEB", "697", "37", "37"), + NEI("Dutch (Netherlands) MNCS", "NEI", "697", "500", "500"), + NWB("Norwegian", "NWB", "697", "277", "277"), + NWI("Norwegian MNCS", "NWI", "697", "500", "500"), + PLB("Polish", "PLB", "959", "870", "870"), + PLBX("Polish 870-pl", "PLB", "959", "870", "870-pl"), // Workaround, to catch up Java codepage '870-pl' + PRB("Portuguese", "PRB", "697", "37", "37"), + PRI("Portuguese MNCS", "PRI", "697", "500", "500"), + RMB("Romanian", "RMB", "959", "870", "870"), + RUB("Russian", "RUB", "1150", "1025", "1025"), + SQB("Serbian, Cyrillic", "SQB", "1150", "1025", "1025"), + YGI("Serbian, Latin", "YGI", "959", "870", "870"), + RCB("Simplified Chinese", "RCB", "1174", "836", "836"), + SKB("Slovakian", "SKB", "959", "870", "870"), + SKBX("Slovakian 870-sk", "SKB", "959", "870", "870-sk"), // Workaround, to catch up Java codepage '870-sk' +// YGI("Slovenian","YGI","959","870","870"), + SPB("Spanish", "SPB", "697", "284", "284"), + SPI("Spanish MNCS", "SPI", "697", "500", "500"), + SSB("Spanish Speaking", "SSB", "697", "284", "284"), + SSI("Spanish Speaking MNCS", "SSI", "697", "500", "500"), + SWB("Swedish", "SWB", "697", "278", "278"), + SWI("Swedish MNCS", "SWI", "697", "500", "500"), + SFI("French (Switzerland) MNCS", "SFI", "697", "500", "500"), + SGI("German (Switzerland) MNCS", "SGI", "697", "500", "500"), + THB("Thai", "THB", "1176", "838", "838"), + TAB("Traditional Chinese", "TAB", "1175", "37", "937"), + TKB("Turkish (Qwerty)", "TKB", "1152", "1026", "1026"), + TRB("Turkish (F)", "TRB", "1152", "1026", "1026"), + UKB("English (United Kingdom)", "UKB", "697", "285", "285"), + UKI("English (United Kingdom) MNCS", "UKI", "697", "500", "500"), + USB("English (United States and Canada)", "USB", "697", "37", "37"), + USI("English (United States and Canada) MNCS", "USI", "697", "500", "500"); + + public final String description; + public final String kbdType; + public final String charset; + public final String codepage; + public final String ccsid; + + /** + * @param description + * @param kbdType + * @param charset + * @param codepage + * @param ccsid + */ + private KbdTypesCodePages(String description, String kbdType, String charset, String codepage, String ccsid) { + this.description = description; + this.kbdType = kbdType; + this.charset = charset; + this.codepage = codepage; + this.ccsid = ccsid; + } + + @Override + public String toString() { + return "[description=" + description + ", kbdType=" + kbdType + + ", charset=" + charset + ", codepage=" + codepage + + ", ccsid=" + ccsid + "]"; + } } diff -r 6a0ad4d384ea -r 77ac18bc1b2f src/org/tn5250j/framework/tn5250/KeyStrokenizer.java --- a/src/org/tn5250j/framework/tn5250/KeyStrokenizer.java Wed Jun 18 13:00:19 2014 -0700 +++ b/src/org/tn5250j/framework/tn5250/KeyStrokenizer.java Wed Jun 18 13:03:01 2014 -0700 @@ -34,125 +34,127 @@ - public KeyStrokenizer() { + public KeyStrokenizer() { + sb = new StringBuffer(); + setKeyStrokes(null); + } - sb = new StringBuffer(); - setKeyStrokes(null); - } + public void setKeyStrokes(String strokes) { + if (strokes != null) { + keyStrokes.setLength(0); + Log.d(TAG, "set " + keyStrokes); + length = strokes.length(); + } + else { + keyStrokes = new StringBuffer(); + length = 0; + } - public void setKeyStrokes (String strokes) { + keyStrokes.append(strokes); + index = 0; + } - if (strokes != null) { - keyStrokes.setLength(0); - Log.d(TAG,"set "+ keyStrokes); - length = strokes.length(); - } - else { + public boolean hasMoreKeyStrokes() { + return length > index; + } - keyStrokes = new StringBuffer(); - length = 0; + public String nextKeyStroke() { + String s = ""; + boolean gotOne = false; + + if (length > index) { + sb.setLength(0); + char c = keyStrokes.charAt(index); - } - keyStrokes.append(strokes); - index = 0; + switch (c) { + case '[': + sb.append(c); + index++; - } - - public boolean hasMoreKeyStrokes() { - return length > index; - } + // we need to throw an error here + if (index >= length) { + Log.w(TAG, " mnemonic key was incomplete :1 " + + "at position " + index + " len " + length); + } + else { + c = keyStrokes.charAt(index); - public String nextKeyStroke() { + if (c == '[') + index++; + else { + while (!gotOne) { + if (c == ']') { // did we find an ending + sb.append(c); + index++; + gotOne = true; + } + else { + sb.append(c); + index++; - String s = ""; - boolean gotOne = false; - if(length > index) { - sb.setLength(0); - - char c = keyStrokes.charAt(index); - switch(c) { - case '[': - sb.append(c); - index++; + // we need to throw an error here because we did not + // find an ending for the potential mnemonic + if (index >= length) { + Log.w(TAG, + " mnemonic key was incomplete ending not found :2 " + + "at position " + index); + } - // we need to throw an error here - if(index >= length) { - Log.w(TAG," mnemonic key was incomplete :1 " + - "at position " + index + " len " + length ); - } - else { - c = keyStrokes.charAt(index); + c = keyStrokes.charAt(index); + } + } + } + } + + break; + + case ']': + index++; - if(c == '[') - index++; - else { - while(!gotOne) { + if (index >= length) { + Log.w(TAG, + " mnemonic key was incomplete ending not found :3 " + + "at position " + index); + sb.append(c); + index++; + } + else { + c = keyStrokes.charAt(index); - if(c == ']') { // did we find an ending - sb.append(c); - index++; - gotOne = true; + if (c == ']') { + sb.append(c); + index++; } else { - sb.append(c); - index++; - // we need to throw an error here because we did not - // find an ending for the potential mnemonic - if(index >= length) { - Log.w(TAG, - " mnemonic key was incomplete ending not found :2 " + - "at position " + index); - } - c = keyStrokes.charAt(index); + Log.w(TAG, + " mnemonic key was incomplete beginning not found :4 " + + "at position " + index); } - } - } - } - break; + } + + break; - case ']': - index++; - if(index >= length) { - Log.w(TAG, - " mnemonic key was incomplete ending not found :3 " + - "at position " + index); - sb.append(c); - index++; + default: + sb.append(c); + index++; + break; + } - } - else { - c = keyStrokes.charAt(index); - if(c == ']') { - sb.append(c); - index++; - } - else { - Log.w(TAG, - " mnemonic key was incomplete beginning not found :4 " + - "at position " + index); - } - } - break; - default: - sb.append(c); - index++; - break; - } - if(sb != null) { - s = new String(sb); - } + if (sb != null) { + s = new String(sb); + } + } - } - Log.d(TAG,"next "+ keyStrokes); - - return s; - } + Log.d(TAG, "next " + keyStrokes); + return s; + } - public String getUnprocessedKeyStroked() { - if(index >= length) { - return null; - } - return keyStrokes.substring(index); - } + public String getUnprocessedKeyStroked() { + if (index >= length) { + return null; + } + + return keyStrokes.substring(index); + } } \ No newline at end of file diff -r 6a0ad4d384ea -r 77ac18bc1b2f src/org/tn5250j/framework/tn5250/Rect.java --- a/src/org/tn5250j/framework/tn5250/Rect.java Wed Jun 18 13:00:19 2014 -0700 +++ b/src/org/tn5250j/framework/tn5250/Rect.java Wed Jun 18 13:03:01 2014 -0700 @@ -1,6 +1,6 @@ /** * $Id: Rect.java 1092 2011-01-16 20:27:56Z master_jaf $ - * + * * Title: tn5250J * Copyright: Copyright (c) 2001,2009 * Company: @@ -33,29 +33,29 @@ */ public class Rect { - /* default */ int x; - /* default */ int y; - /* default */ int height; - /* default */ int width; - - /** - * @param rect - */ - public void setBounds(Rect rect) { - setBounds(rect.x, rect.y, rect.width, rect.height); - } - + /* default */ int x; + /* default */ int y; + /* default */ int height; + /* default */ int width; + + /** + * @param rect + */ + public void setBounds(Rect rect) { + setBounds(rect.x, rect.y, rect.width, rect.height); + } + /** * @param x the new X coordinate for the upper-left corner of this rectangle * @param y the new Y coordinate for the upper-left corner of this rectangle * @param width the new width for this rectangle * @param height the new height for this rectangle */ - public void setBounds(int x, int y, int width, int height) { - this.x = x; - this.y = y; - this.width = width; - this.height = height; - } + public void setBounds(int x, int y, int width, int height) { + this.x = x; + this.y = y; + this.width = width; + this.height = height; + } } diff -r 6a0ad4d384ea -r 77ac18bc1b2f src/org/tn5250j/framework/tn5250/Screen5250.java --- a/src/org/tn5250j/framework/tn5250/Screen5250.java Wed Jun 18 13:00:19 2014 -0700 +++ b/src/org/tn5250j/framework/tn5250/Screen5250.java Wed Jun 18 13:03:01 2014 -0700 @@ -101,34 +101,27 @@ public Screen5250() { - //Added by Barry this.keybuf = new StringBuffer(); try { jbInit(); - } catch (Exception ex) { - Log.w(TAG,"In constructor: ", ex); + } + catch (Exception ex) { + Log.w(TAG, "In constructor: ", ex); } } void jbInit() throws Exception { - lastAttr = 32; - // default number of rows and columns numRows = 24; numCols = 80; - setCursor(1, 1); // set initial cursor position - oia = new ScreenOIA(this); oia.setKeyBoardLocked(true); - lenScreen = numRows * numCols; - - planes = new ScreenPlanes(this,numRows); - + planes = new ScreenPlanes(this, numRows); screenFields = new ScreenFields(this); strokenizer = new KeyStrokenizer(); } @@ -142,29 +135,23 @@ } protected final void setRowsCols(int rows, int cols) { - int oldRows = numRows; int oldCols = numCols; - // default number of rows and columns numRows = rows; numCols = cols; - lenScreen = numRows * numCols; - planes.setSize(rows); // If they are not the same then we need to inform the listeners that // the size changed. if (oldRows != numRows || oldCols != numCols) fireScreenSizeChanged(); - } public boolean isCursorActive() { return cursorActive; - } public boolean isCursorShown() { @@ -197,8 +184,7 @@ StringBuilder sb = new StringBuilder(); Rect workR = new Rect(); workR.setBounds(area); - Log.d(TAG,"Copying " + workR); - + Log.d(TAG, "Copying " + workR); // loop through all the screen characters to send them to the clip board int m = workR.x; int i = 0; @@ -207,9 +193,11 @@ while (workR.height-- > 0) { t = workR.width; i = workR.y; + while (t-- > 0) { // only copy printable characters (in this case >= ' ') char c = planes.getChar(getPos(m - 1, i - 1)); + if (c >= ' ' && (planes.screenExtended[getPos(m - 1, i - 1)] & EXTENDED_5250_NON_DSP) == 0) sb.append(c); @@ -218,9 +206,11 @@ i++; } + sb.append('\n'); m++; } + return sb.toString(); } @@ -231,40 +221,32 @@ * @see {@link #copyText(Rectangle)} */ public final void pasteText(String content, boolean special) { - Log.d(TAG,"Pasting, special:"+special); + Log.d(TAG, "Pasting, special:" + special); setCursorActive(false); - StringBuilder sb = new StringBuilder(content); StringBuilder pd = new StringBuilder(); - // character counters within the string to be pasted. int nextChar = 0; int nChars = sb.length(); - int lr = getRow(lastPos); int lc = getCol(lastPos); resetDirty(lastPos); - int cpos = lastPos; int length = getScreenLength(); - char c = 0; boolean setIt; - // save our current place within the FFT. screenFields.saveCurrentField(); for (int x = nextChar; x < nChars; x++) { - c = sb.charAt(x); if ((c == '\n') || (c == '\r')) { - - Log.i(TAG,"pasted cr-lf>" + pd + "<"); + Log.i(TAG, "pasted cr-lf>" + pd + "<"); pd.setLength(0); // if we read in a cr lf in the data stream we need to go // to the starting column of the next row and start from there - cpos = getPos(getRow(cpos)+1,lc); + cpos = getPos(getRow(cpos) + 1, lc); // If we go paste the end of the screen then let's start over from // the beginning of the screen space. @@ -272,7 +254,6 @@ cpos = 0; } else { - // we will default to set the character always. setIt = true; @@ -288,9 +269,11 @@ setDirty(cpos); screenFields.setCurrentFieldMDT(); } + // If we placed a character then we go to the next position. if (setIt) cpos++; + // we will append the information to our debug buffer. pd.append(c); } @@ -298,17 +281,14 @@ // if we have anything else not logged then log it out. if (pd.length() > 0) - Log.i(TAG,"pasted >" + pd + "<"); + Log.i(TAG, "pasted >" + pd + "<"); // restore out position within the FFT. screenFields.restoreCurrentField(); updateDirty(); - // restore our cursor position. setCursor(lr + 1, lc + 1); - setCursorActive(true); - } /** @@ -340,45 +320,38 @@ * @return vector string of numberic values */ public final Vector sumThem(boolean which, Rect area) { - StringBuilder sb = new StringBuilder(); Rect workR = new Rect(); workR.setBounds(area); - // gui.rubberband.reset(); // gui.repaint(); - - Log.d(TAG,"Summing"); - + Log.d(TAG, "Summing"); // obtain the decimal format for parsing DecimalFormat df = (DecimalFormat) NumberFormat.getInstance(); - DecimalFormatSymbols dfs = df.getDecimalFormatSymbols(); if (which) { dfs.setDecimalSeparator('.'); dfs.setGroupingSeparator(','); - } else { + } + else { dfs.setDecimalSeparator(','); dfs.setGroupingSeparator('.'); } df.setDecimalFormatSymbols(dfs); - Vector sumVector = new Vector(); - // loop through all the screen characters to send them to the clip board int m = workR.x; int i = 0; int t = 0; - double sum = 0.0; while (workR.height-- > 0) { t = workR.width; i = workR.y; + while (t-- > 0) { - // only copy printable numeric characters (in this case >= ' ') // char c = screen[getPos(m - 1, i - 1)].getChar(); char c = planes.getChar(getPos(m - 1, i - 1)); @@ -389,6 +362,7 @@ if (((c >= '0' && c <= '9') || c == '.' || c == ',' || c == '-')) { sb.append(c); } + i++; } @@ -397,21 +371,24 @@ sb.insert(0, '-'); sb.deleteCharAt(sb.length() - 1); } + try { Number n = df.parse(sb.toString()); // System.out.println(s + " " + n.doubleValue()); - sumVector.add(new Double(n.doubleValue())); sum += n.doubleValue(); - } catch (ParseException pe) { - Log.w(TAG,pe.getMessage() + " at " - + pe.getErrorOffset()); + } + catch (ParseException pe) { + Log.w(TAG, pe.getMessage() + " at " + + pe.getErrorOffset()); } } + sb.setLength(0); m++; } - Log.d(TAG,"" + sum); + + Log.d(TAG, "" + sum); return sumVector; } @@ -425,108 +402,119 @@ * @param pos */ public boolean moveCursor(int pos) { - if (!oia.isKeyBoardLocked()) { - if (pos < 0) return false; + // because getRowColFromPoint returns offset of 1,1 we need to // translate to offset 0,0 // pos -= (numCols + 1); - int g = planes.getWhichGUI(pos); // lets check for hot spots if (g >= BUTTON_LEFT && g <= BUTTON_LAST) { StringBuffer aid = new StringBuffer(); boolean aidFlag = true; + switch (g) { - case BUTTON_RIGHT: - case BUTTON_MIDDLE: - while (planes.getWhichGUI(--pos) != BUTTON_LEFT) { - } - case BUTTON_LEFT: - if (planes.getChar(pos) == 'F') { - pos++; - } else - aidFlag = false; - - if (planes.getChar(pos + 1) != '=' - && planes.getChar(pos + 1) != '.' - && planes.getChar(pos + 1) != '/') { - Log.d(TAG," Hotspot clicked!!! we will send characters " - + planes.getChar(pos) + " " + planes.getChar(pos+1)); - aid.append(planes.getChar(pos)); - aid.append(planes.getChar(pos + 1)); - } else { - Log.d(TAG," Hotspot clicked!!! we will send character " - + planes.getChar(pos)); - aid.append(planes.getChar(pos)); - } - break; - + case BUTTON_RIGHT: + case BUTTON_MIDDLE: + while (planes.getWhichGUI(--pos) != BUTTON_LEFT) { + } + + case BUTTON_LEFT: + if (planes.getChar(pos) == 'F') { + pos++; + } + else + aidFlag = false; + + if (planes.getChar(pos + 1) != '=' + && planes.getChar(pos + 1) != '.' + && planes.getChar(pos + 1) != '/') { + Log.d(TAG, " Hotspot clicked!!! we will send characters " + + planes.getChar(pos) + " " + planes.getChar(pos + 1)); + aid.append(planes.getChar(pos)); + aid.append(planes.getChar(pos + 1)); + } + else { + Log.d(TAG, " Hotspot clicked!!! we will send character " + + planes.getChar(pos)); + aid.append(planes.getChar(pos)); + } + + break; } + if (aidFlag) { switch (g) { - - case BUTTON_LEFT_UP: - case BUTTON_MIDDLE_UP: - case BUTTON_RIGHT_UP: - case BUTTON_ONE_UP: - case BUTTON_SB_UP: - case BUTTON_SB_GUIDE: - sessionVT.sendAidKey(AID_ROLL_UP); - break; - - case BUTTON_LEFT_DN: - case BUTTON_MIDDLE_DN: - case BUTTON_RIGHT_DN: - case BUTTON_ONE_DN: - case BUTTON_SB_DN: - case BUTTON_SB_THUMB: - - sessionVT.sendAidKey(AID_ROLL_DOWN); - break; - case BUTTON_LEFT_EB: - case BUTTON_MIDDLE_EB: - case BUTTON_RIGHT_EB: - StringBuffer eb = new StringBuffer(); - while (planes.getWhichGUI(pos--) != BUTTON_LEFT_EB) - ; - while (planes.getWhichGUI(pos++) != BUTTON_RIGHT_EB) { - eb.append(planes.getChar(pos)); - } - sessionVT.showURL(eb.toString()); - // take out the log statement when we are sure it is - // working - Log.i(TAG,"Send to external Browser: " + eb.toString()); - break; - - default: - int aidKey = Integer.parseInt(aid.toString()); - if (aidKey >= 1 && aidKey <= 12) - sessionVT.sendAidKey(0x30 + aidKey); - if (aidKey >= 13 && aidKey <= 24) - sessionVT.sendAidKey(0xB0 + (aidKey - 12)); + case BUTTON_LEFT_UP: + case BUTTON_MIDDLE_UP: + case BUTTON_RIGHT_UP: + case BUTTON_ONE_UP: + case BUTTON_SB_UP: + case BUTTON_SB_GUIDE: + sessionVT.sendAidKey(AID_ROLL_UP); + break; + + case BUTTON_LEFT_DN: + case BUTTON_MIDDLE_DN: + case BUTTON_RIGHT_DN: + case BUTTON_ONE_DN: + case BUTTON_SB_DN: + case BUTTON_SB_THUMB: + sessionVT.sendAidKey(AID_ROLL_DOWN); + break; + + case BUTTON_LEFT_EB: + case BUTTON_MIDDLE_EB: + case BUTTON_RIGHT_EB: + StringBuffer eb = new StringBuffer(); + + while (planes.getWhichGUI(pos--) != BUTTON_LEFT_EB) + ; + + while (planes.getWhichGUI(pos++) != BUTTON_RIGHT_EB) { + eb.append(planes.getChar(pos)); + } + + sessionVT.showURL(eb.toString()); + // take out the log statement when we are sure it is + // working + Log.i(TAG, "Send to external Browser: " + eb.toString()); + break; + + default: + int aidKey = Integer.parseInt(aid.toString()); + + if (aidKey >= 1 && aidKey <= 12) + sessionVT.sendAidKey(0x30 + aidKey); + + if (aidKey >= 13 && aidKey <= 24) + sessionVT.sendAidKey(0xB0 + (aidKey - 12)); } - } else { + } + else { if (screenFields.getCurrentField() != null) { int xPos = screenFields.getCurrentField().startPos(); + for (int x = 0; x < aid.length(); x++) { // System.out.println(sr + "," + (sc + x) + " " + // aid.charAt(x)); planes.setChar(xPos + x , aid.charAt(x)); } + // System.out.println(aid); screenFields.setCurrentFieldMDT(); sessionVT.sendAidKey(AID_ENTER); } - } + // return back to the calling routine that the cursor was not moved // but something else here was done like aid keys or the such return false; } + // this is a note to not execute this code here when we // implement // the remain after edit function option. @@ -536,12 +524,12 @@ // } else { goto_XY(pos); isInField(lastPos); - // return back to the calling object that the cursor was indeed // moved with in the screen object return true; // } } + return false; } @@ -562,19 +550,19 @@ */ private int getMnemonicValue(String mnem) { if (mnemonicMap.containsKey(mnem)) return mnemonicMap.get(mnem); + return 0; } protected void setPrehelpState(boolean setErrorCode, boolean lockKeyboard, - boolean unlockIfLocked) { + boolean unlockIfLocked) { if (oia.isKeyBoardLocked() && unlockIfLocked) oia.setKeyBoardLocked(false); else oia.setKeyBoardLocked(lockKeyboard); + bufferedKeys = null; oia.setKeysBuffered(false); - - } /** @@ -583,13 +571,13 @@ * @param activate */ public void setCursorActive(boolean activate) { - // System.out.println("cursor active " + updateCursorLoc + " " + // cursorActive + " " + activate); if (cursorActive && !activate) { setCursorOff(); cursorActive = activate; - } else { + } + else { if (!cursorActive && activate) { cursorActive = activate; setCursorOn(); @@ -609,12 +597,10 @@ * Set the cursor off */ public void setCursorOff() { - cursorShown = false; updateCursorLoc(); // System.out.println("cursor off " + updateCursorLoc + " " + // cursorActive); - } /** @@ -935,6 +921,7 @@ * @see #sendAid * */ + public synchronized void sendKeys(String text) { Log.d(TAG, "sendKeys() " + text); this.keybuf.append(text); @@ -951,8 +938,8 @@ setCursorActive(false); simulateMnemonic(getMnemonicValue(text)); setCursorActive(true); - - } else { + } + else { if (isStatusErrorCode()) { sessionVT.signalBell(); return; @@ -962,24 +949,26 @@ if (bufferedKeys == null) bufferedKeys = text; else bufferedKeys += text; + return; } - - } else { - + } + else { if (oia.isKeysBuffered()) { if (bufferedKeys != null) { text = bufferedKeys + text; } + // if (text.length() == 0) { oia.setKeysBuffered(false); // } bufferedKeys = null; - } + // check to see if position is in a field and if it is then change // current field to that field isInField(lastPos, true); + if (text.length() == 1 && !text.equals("[") && !text.equals("]")) { // setCursorOff2(); setCursorActive(false); @@ -987,33 +976,31 @@ setCursorActive(true); // setCursorOn2(); // System.out.println(" text one"); - - } else { - + } + else { strokenizer.setKeyStrokes(text); String s; boolean done = false; - // setCursorOff2(); setCursorActive(false); + while (!done) { // while (strokenizer.hasMoreKeyStrokes() && !keyboardLocked // && // !isStatusErrorCode() && !done) { if (strokenizer.hasMoreKeyStrokes()) { - // check to see if position is in a field and if it is // then change // current field to that field isInField(lastPos, true); s = strokenizer.nextKeyStroke(); + if (s.length() == 1) { // setCursorOn(); // if (!keysBuffered) { // System.out.println(" s two" + s); // setCursorOn(); // } - // try { new Thread().sleep(400);} catch // (InterruptedException ie) {} simulateKeyStroke(s.charAt(0)); @@ -1023,7 +1010,8 @@ // System.out.println(" s two" + s); // setCursorOn(); // } - } else { + } + else { simulateMnemonic(getMnemonicValue(s)); // if (!cursorActive && !keysBuffered) { // System.out.println(" m one"); @@ -1032,24 +1020,23 @@ } if (oia.isKeyBoardLocked()) { - bufferedKeys = strokenizer - .getUnprocessedKeyStroked(); + .getUnprocessedKeyStroked(); + if (bufferedKeys != null) { oia.setKeysBuffered(true); - } + done = true; } - } - else { // setCursorActive(true); // setCursorOn(); done = true; } } + setCursorActive(true); } } @@ -1099,7 +1086,6 @@ * @see #AID_PF24 */ public void sendAid(int aidKey) { - sessionVT.sendAidKey(aidKey); } @@ -1108,425 +1094,440 @@ * */ protected void resetError() { - restoreErrorLine(); setStatus(STATUS_ERROR_CODE, STATUS_VALUE_OFF, ""); - } protected boolean simulateMnemonic(int mnem) { - boolean simulated = false; switch (mnem) { - - case AID_CLEAR: - case AID_ENTER: - case AID_PF1: - case AID_PF2: - case AID_PF3: - case AID_PF4: - case AID_PF5: - case AID_PF6: - case AID_PF7: - case AID_PF8: - case AID_PF9: - case AID_PF10: - case AID_PF11: - case AID_PF12: - case AID_PF13: - case AID_PF14: - case AID_PF15: - case AID_PF16: - case AID_PF17: - case AID_PF18: - case AID_PF19: - case AID_PF20: - case AID_PF21: - case AID_PF22: - case AID_PF23: - case AID_PF24: - case AID_ROLL_DOWN: - case AID_ROLL_UP: - case AID_ROLL_LEFT: - case AID_ROLL_RIGHT: - - if (!screenFields.isCanSendAid()) { - displayError(ERR_ENTER_NO_ALLOWED); - } else - sendAid(mnem); - simulated = true; - - break; - case AID_HELP: - sessionVT.sendHelpRequest(); - simulated = true; - break; - - case AID_PRINT: - sessionVT.hostPrint(1); - simulated = true; - break; - - case BACK_SPACE: - if (screenFields.getCurrentField() != null - && screenFields.withinCurrentField(lastPos) - && !screenFields.isCurrentFieldBypassField()) { - - if (screenFields.getCurrentField().startPos() == lastPos) { - if (backspaceError) - displayError(ERR_CURSOR_PROTECTED); + case AID_CLEAR: + case AID_ENTER: + case AID_PF1: + case AID_PF2: + case AID_PF3: + case AID_PF4: + case AID_PF5: + case AID_PF6: + case AID_PF7: + case AID_PF8: + case AID_PF9: + case AID_PF10: + case AID_PF11: + case AID_PF12: + case AID_PF13: + case AID_PF14: + case AID_PF15: + case AID_PF16: + case AID_PF17: + case AID_PF18: + case AID_PF19: + case AID_PF20: + case AID_PF21: + case AID_PF22: + case AID_PF23: + case AID_PF24: + case AID_ROLL_DOWN: + case AID_ROLL_UP: + case AID_ROLL_LEFT: + case AID_ROLL_RIGHT: + if (!screenFields.isCanSendAid()) { + displayError(ERR_ENTER_NO_ALLOWED); + } + else + sendAid(mnem); + + simulated = true; + break; + + case AID_HELP: + sessionVT.sendHelpRequest(); + simulated = true; + break; + + case AID_PRINT: + sessionVT.hostPrint(1); + simulated = true; + break; + + case BACK_SPACE: + if (screenFields.getCurrentField() != null + && screenFields.withinCurrentField(lastPos) + && !screenFields.isCurrentFieldBypassField()) { + if (screenFields.getCurrentField().startPos() == lastPos) { + if (backspaceError) + displayError(ERR_CURSOR_PROTECTED); + else { + gotoFieldPrev(); + goto_XY(screenFields.getCurrentField().endPos()); + updateDirty(); + } + } else { - gotoFieldPrev(); - goto_XY(screenFields.getCurrentField().endPos()); + screenFields.getCurrentField().getKeyPos(lastPos); + screenFields.getCurrentField().changePos(-1); + resetDirty(screenFields.getCurrentField().getCurrentPos()); + shiftLeft(screenFields.getCurrentField().getCurrentPos()); updateDirty(); + screenFields.setCurrentFieldMDT(); + simulated = true; } } else { + displayError(ERR_CURSOR_PROTECTED); + } + + break; + + case BACK_TAB: + if (screenFields.getCurrentField() != null + && screenFields.isCurrentFieldHighlightedEntry()) { + resetDirty(screenFields.getCurrentField().startPos); + gotoFieldPrev(); + updateDirty(); + } + else + gotoFieldPrev(); + + if (screenFields.isCurrentFieldContinued()) { + do { + gotoFieldPrev(); + } + while (screenFields.isCurrentFieldContinuedMiddle() + || screenFields.isCurrentFieldContinuedLast()); + } + + isInField(lastPos); + simulated = true; + break; + + case UP: + case MARK_UP: + process_XY(lastPos - numCols); + simulated = true; + break; + + case DOWN: + case MARK_DOWN: + process_XY(lastPos + numCols); + simulated = true; + break; + + case LEFT: + case MARK_LEFT: + process_XY(lastPos - 1); + simulated = true; + break; + + case RIGHT: + case MARK_RIGHT: + process_XY(lastPos + 1); + simulated = true; + break; + + case NEXTWORD: + gotoNextWord(); + simulated = true; + break; + + case PREVWORD: + gotoPrevWord(); + simulated = true; + break; + + case DELETE: + if (screenFields.getCurrentField() != null + && screenFields.withinCurrentField(lastPos) + && !screenFields.isCurrentFieldBypassField()) { + resetDirty(lastPos); screenFields.getCurrentField().getKeyPos(lastPos); - screenFields.getCurrentField().changePos(-1); - resetDirty(screenFields.getCurrentField().getCurrentPos()); - shiftLeft(screenFields.getCurrentField().getCurrentPos()); + shiftLeft(screenFields.getCurrentFieldPos()); + screenFields.setCurrentFieldMDT(); updateDirty(); - screenFields.setCurrentFieldMDT(); + simulated = true; + } + else { + displayError(ERR_CURSOR_PROTECTED); + } + + break; + + case TAB: + if (screenFields.getCurrentField() != null + && !screenFields.isCurrentFieldContinued()) { + if (screenFields.isCurrentFieldHighlightedEntry()) { + resetDirty(screenFields.getCurrentField().startPos); + gotoFieldNext(); + updateDirty(); + } + else + gotoFieldNext(); + } + else { + do { + gotoFieldNext(); + } + while (screenFields.getCurrentField() != null + && (screenFields.isCurrentFieldContinuedMiddle() || screenFields + .isCurrentFieldContinuedLast())); + } + + isInField(lastPos); + simulated = true; + break; + + case EOF: + if (screenFields.getCurrentField() != null + && screenFields.withinCurrentField(lastPos) + && !screenFields.isCurrentFieldBypassField()) { + int where = endOfField(screenFields.getCurrentField() + .startPos(), true); + + if (where > 0) { + setCursor((where / numCols) + 1, (where % numCols) + 1); + } simulated = true; } - } else { - displayError(ERR_CURSOR_PROTECTED); - - } - break; - case BACK_TAB: - - if (screenFields.getCurrentField() != null - && screenFields.isCurrentFieldHighlightedEntry()) { - resetDirty(screenFields.getCurrentField().startPos); - gotoFieldPrev(); - updateDirty(); - } else - gotoFieldPrev(); - - if (screenFields.isCurrentFieldContinued()) { - do { - gotoFieldPrev(); - } while (screenFields.isCurrentFieldContinuedMiddle() - || screenFields.isCurrentFieldContinuedLast()); - } - isInField(lastPos); - simulated = true; - break; - case UP: - case MARK_UP: - process_XY(lastPos - numCols); - simulated = true; - break; - case DOWN: - case MARK_DOWN: - process_XY(lastPos + numCols); - simulated = true; - break; - case LEFT: - case MARK_LEFT: - process_XY(lastPos - 1); - simulated = true; - break; - case RIGHT: - case MARK_RIGHT: - process_XY(lastPos + 1); - simulated = true; - break; - case NEXTWORD: - gotoNextWord(); - simulated = true; - break; - case PREVWORD: - gotoPrevWord(); - simulated = true; - break; - case DELETE: - if (screenFields.getCurrentField() != null - && screenFields.withinCurrentField(lastPos) - && !screenFields.isCurrentFieldBypassField()) { + else { + displayError(ERR_CURSOR_PROTECTED); + } resetDirty(lastPos); - screenFields.getCurrentField().getKeyPos(lastPos); - shiftLeft(screenFields.getCurrentFieldPos()); - screenFields.setCurrentFieldMDT(); - updateDirty(); - simulated = true; - } else { - displayError(ERR_CURSOR_PROTECTED); - } - - break; - case TAB: - - if (screenFields.getCurrentField() != null - && !screenFields.isCurrentFieldContinued()) { - if (screenFields.isCurrentFieldHighlightedEntry()) { - resetDirty(screenFields.getCurrentField().startPos); - gotoFieldNext(); + break; + + case ERASE_EOF: + if (screenFields.getCurrentField() != null + && screenFields.withinCurrentField(lastPos) + && !screenFields.isCurrentFieldBypassField()) { + int where = lastPos; + resetDirty(lastPos); + + if (fieldExit()) { + screenFields.setCurrentFieldMDT(); + + if (!screenFields.isCurrentFieldContinued()) { + gotoFieldNext(); + } + else { + do { + gotoFieldNext(); + + if (screenFields.isCurrentFieldContinued()) + fieldExit(); + } + while (screenFields.isCurrentFieldContinuedMiddle() + || screenFields.isCurrentFieldContinuedLast()); + } + } + updateDirty(); - } else - gotoFieldNext(); - } else { - do { - gotoFieldNext(); - } while (screenFields.getCurrentField() != null - && (screenFields.isCurrentFieldContinuedMiddle() || screenFields - .isCurrentFieldContinuedLast())); - } - - isInField(lastPos); - simulated = true; - - break; - case EOF: - if (screenFields.getCurrentField() != null - && screenFields.withinCurrentField(lastPos) - && !screenFields.isCurrentFieldBypassField()) { - int where = endOfField(screenFields.getCurrentField() - .startPos(), true); - if (where > 0) { - setCursor((where / numCols) + 1, (where % numCols) + 1); + goto_XY(where); + simulated = true; + } + else { + displayError(ERR_CURSOR_PROTECTED); + } + + break; + + case ERASE_FIELD: + if (screenFields.getCurrentField() != null + && screenFields.withinCurrentField(lastPos) + && !screenFields.isCurrentFieldBypassField()) { + int where = lastPos; + lastPos = screenFields.getCurrentField().startPos(); + resetDirty(lastPos); + + if (fieldExit()) { + screenFields.setCurrentFieldMDT(); + + if (!screenFields.isCurrentFieldContinued()) { + gotoFieldNext(); + } + else { + do { + gotoFieldNext(); + + if (screenFields.isCurrentFieldContinued()) + fieldExit(); + } + while (screenFields.isCurrentFieldContinuedMiddle() + || screenFields.isCurrentFieldContinuedLast()); + } + } + + updateDirty(); + goto_XY(where); + simulated = true; + } + else { + displayError(ERR_CURSOR_PROTECTED); + } + + break; + + case INSERT: + // we toggle it + oia.setInsertMode(oia.isInsertMode() ? false : true); + break; + + case HOME: + + // position to the home position set + if (lastPos + numCols + 1 != homePos) { + goto_XY(homePos - numCols - 1); + // now check if we are in a field + isInField(lastPos); } - simulated = true; - } else { - displayError(ERR_CURSOR_PROTECTED); - } - resetDirty(lastPos); - - break; - case ERASE_EOF: - if (screenFields.getCurrentField() != null - && screenFields.withinCurrentField(lastPos) - && !screenFields.isCurrentFieldBypassField()) { - - int where = lastPos; - resetDirty(lastPos); - if (fieldExit()) { - screenFields.setCurrentFieldMDT(); - if (!screenFields.isCurrentFieldContinued()) { - gotoFieldNext(); - } else { - do { - gotoFieldNext(); - if (screenFields.isCurrentFieldContinued()) - fieldExit(); - } while (screenFields.isCurrentFieldContinuedMiddle() - || screenFields.isCurrentFieldContinuedLast()); + else + gotoField(1); + + break; + + case KEYPAD_0: + simulated = simulateKeyStroke('0'); + break; + + case KEYPAD_1: + simulated = simulateKeyStroke('1'); + break; + + case KEYPAD_2: + simulated = simulateKeyStroke('2'); + break; + + case KEYPAD_3: + simulated = simulateKeyStroke('3'); + break; + + case KEYPAD_4: + simulated = simulateKeyStroke('4'); + break; + + case KEYPAD_5: + simulated = simulateKeyStroke('5'); + break; + + case KEYPAD_6: + simulated = simulateKeyStroke('6'); + break; + + case KEYPAD_7: + simulated = simulateKeyStroke('7'); + break; + + case KEYPAD_8: + simulated = simulateKeyStroke('8'); + break; + + case KEYPAD_9: + simulated = simulateKeyStroke('9'); + break; + + case KEYPAD_PERIOD: + simulated = simulateKeyStroke('.'); + break; + + case KEYPAD_COMMA: + simulated = simulateKeyStroke(','); + break; + + case KEYPAD_MINUS: + if (screenFields.getCurrentField() != null + && screenFields.withinCurrentField(lastPos) + && !screenFields.isCurrentFieldBypassField()) { + int s = screenFields.getCurrentField().getFieldShift(); + + if (s == 3 || s == 5 || s == 7) { + planes.setChar(lastPos, '-'); + resetDirty(lastPos); + advancePos(); + + if (fieldExit()) { + screenFields.setCurrentFieldMDT(); + + if (!screenFields.isCurrentFieldContinued()) { + gotoFieldNext(); + } + else { + do { + gotoFieldNext(); + } + while (screenFields + .isCurrentFieldContinuedMiddle() + || screenFields + .isCurrentFieldContinuedLast()); + } + + simulated = true; + updateDirty(); + + if (screenFields.isCurrentFieldAutoEnter()) + sendAid(AID_ENTER); + } } - } - updateDirty(); - goto_XY(where); - simulated = true; - - } else { - displayError(ERR_CURSOR_PROTECTED); - } - - break; - case ERASE_FIELD: - if (screenFields.getCurrentField() != null - && screenFields.withinCurrentField(lastPos) - && !screenFields.isCurrentFieldBypassField()) { - - int where = lastPos; - lastPos = screenFields.getCurrentField().startPos(); - resetDirty(lastPos); - if (fieldExit()) { - screenFields.setCurrentFieldMDT(); - if (!screenFields.isCurrentFieldContinued()) { - gotoFieldNext(); - } else { - do { - gotoFieldNext(); - if (screenFields.isCurrentFieldContinued()) - fieldExit(); - } while (screenFields.isCurrentFieldContinuedMiddle() - || screenFields.isCurrentFieldContinuedLast()); + else { + displayError(ERR_FIELD_MINUS); } } - updateDirty(); - goto_XY(where); - simulated = true; - - } else { - displayError(ERR_CURSOR_PROTECTED); - } - - break; - case INSERT: - // we toggle it - oia.setInsertMode(oia.isInsertMode() ? false : true); - break; - case HOME: - // position to the home position set - if (lastPos + numCols + 1 != homePos) { - goto_XY(homePos - numCols - 1); - // now check if we are in a field - isInField(lastPos); - } else - gotoField(1); - break; - case KEYPAD_0: - simulated = simulateKeyStroke('0'); - break; - case KEYPAD_1: - simulated = simulateKeyStroke('1'); - break; - case KEYPAD_2: - simulated = simulateKeyStroke('2'); - break; - case KEYPAD_3: - simulated = simulateKeyStroke('3'); - break; - case KEYPAD_4: - simulated = simulateKeyStroke('4'); - break; - case KEYPAD_5: - simulated = simulateKeyStroke('5'); - break; - case KEYPAD_6: - simulated = simulateKeyStroke('6'); - break; - case KEYPAD_7: - simulated = simulateKeyStroke('7'); - break; - case KEYPAD_8: - simulated = simulateKeyStroke('8'); - break; - case KEYPAD_9: - simulated = simulateKeyStroke('9'); - break; - case KEYPAD_PERIOD: - simulated = simulateKeyStroke('.'); - break; - case KEYPAD_COMMA: - simulated = simulateKeyStroke(','); - break; - case KEYPAD_MINUS: - if (screenFields.getCurrentField() != null - && screenFields.withinCurrentField(lastPos) - && !screenFields.isCurrentFieldBypassField()) { - - int s = screenFields.getCurrentField().getFieldShift(); - if (s == 3 || s == 5 || s == 7) { - planes.setChar(lastPos,'-'); - + else { + displayError(ERR_CURSOR_PROTECTED); + } + + break; + + case FIELD_EXIT: + if (screenFields.getCurrentField() != null + && screenFields.withinCurrentField(lastPos) + && !screenFields.isCurrentFieldBypassField()) { resetDirty(lastPos); - advancePos(); - if (fieldExit()) { - screenFields.setCurrentFieldMDT(); - if (!screenFields.isCurrentFieldContinued()) { - gotoFieldNext(); - } else { - do { - gotoFieldNext(); - } while (screenFields - .isCurrentFieldContinuedMiddle() - || screenFields - .isCurrentFieldContinuedLast()); - } - simulated = true; - updateDirty(); - if (screenFields.isCurrentFieldAutoEnter()) - sendAid(AID_ENTER); - - } - } else { - displayError(ERR_FIELD_MINUS); - - } - } else { - displayError(ERR_CURSOR_PROTECTED); - } - - break; - case FIELD_EXIT: - if (screenFields.getCurrentField() != null - && screenFields.withinCurrentField(lastPos) - && !screenFields.isCurrentFieldBypassField()) { - - resetDirty(lastPos); - - boolean autoFE = screenFields.isCurrentFieldAutoEnter(); - - if (fieldExit()) { - screenFields.setCurrentFieldMDT(); - if (!screenFields.isCurrentFieldContinued() && - !screenFields.isCurrentFieldAutoEnter()) { - gotoFieldNext(); - } else { - do { - gotoFieldNext(); - if (screenFields.isCurrentFieldContinued()) - fieldExit(); - } while (screenFields.isCurrentFieldContinuedMiddle() - || screenFields.isCurrentFieldContinuedLast()); - } - } - - updateDirty(); - simulated = true; - if (autoFE) - sendAid(AID_ENTER); - - } else { - displayError(ERR_CURSOR_PROTECTED); - } - - break; - case FIELD_PLUS: - if (screenFields.getCurrentField() != null - && screenFields.withinCurrentField(lastPos) - && !screenFields.isCurrentFieldBypassField()) { - - resetDirty(lastPos); - - boolean autoFE = screenFields.isCurrentFieldAutoEnter(); - if (fieldExit()) { - screenFields.setCurrentFieldMDT(); - if (!screenFields.isCurrentFieldContinued() && - !screenFields.isCurrentFieldAutoEnter()) { - gotoFieldNext(); - } else { - do { - gotoFieldNext(); - } while (screenFields.isCurrentFieldContinuedMiddle() - || screenFields.isCurrentFieldContinuedLast()); - } - } - updateDirty(); - simulated = true; - - if (autoFE) - sendAid(AID_ENTER); - - } else { - displayError(ERR_CURSOR_PROTECTED); - } - - break; - case FIELD_MINUS: - if (screenFields.getCurrentField() != null - && screenFields.withinCurrentField(lastPos) - && !screenFields.isCurrentFieldBypassField()) { - - int s = screenFields.getCurrentField().getFieldShift(); - if (s == 3 || s == 5 || s == 7) { - planes.setChar(lastPos, '-'); - - resetDirty(lastPos); - advancePos(); - boolean autoFE = screenFields.isCurrentFieldAutoEnter(); if (fieldExit()) { screenFields.setCurrentFieldMDT(); - if (!screenFields.isCurrentFieldContinued() - && !screenFields.isCurrentFieldAutoEnter()) { + + if (!screenFields.isCurrentFieldContinued() && + !screenFields.isCurrentFieldAutoEnter()) { + gotoFieldNext(); + } + else { + do { + gotoFieldNext(); + + if (screenFields.isCurrentFieldContinued()) + fieldExit(); + } + while (screenFields.isCurrentFieldContinuedMiddle() + || screenFields.isCurrentFieldContinuedLast()); + } + } + + updateDirty(); + simulated = true; + + if (autoFE) + sendAid(AID_ENTER); + } + else { + displayError(ERR_CURSOR_PROTECTED); + } + + break; + + case FIELD_PLUS: + if (screenFields.getCurrentField() != null + && screenFields.withinCurrentField(lastPos) + && !screenFields.isCurrentFieldBypassField()) { + resetDirty(lastPos); + boolean autoFE = screenFields.isCurrentFieldAutoEnter(); + + if (fieldExit()) { + screenFields.setCurrentFieldMDT(); + + if (!screenFields.isCurrentFieldContinued() && + !screenFields.isCurrentFieldAutoEnter()) { gotoFieldNext(); } else { @@ -1537,159 +1538,223 @@ || screenFields.isCurrentFieldContinuedLast()); } } + updateDirty(); simulated = true; + if (autoFE) sendAid(AID_ENTER); - + } + else { + displayError(ERR_CURSOR_PROTECTED); + } + + break; + + case FIELD_MINUS: + if (screenFields.getCurrentField() != null + && screenFields.withinCurrentField(lastPos) + && !screenFields.isCurrentFieldBypassField()) { + int s = screenFields.getCurrentField().getFieldShift(); + + if (s == 3 || s == 5 || s == 7) { + planes.setChar(lastPos, '-'); + resetDirty(lastPos); + advancePos(); + boolean autoFE = screenFields.isCurrentFieldAutoEnter(); + + if (fieldExit()) { + screenFields.setCurrentFieldMDT(); + + if (!screenFields.isCurrentFieldContinued() + && !screenFields.isCurrentFieldAutoEnter()) { + gotoFieldNext(); + } + else { + do { + gotoFieldNext(); + } + while (screenFields.isCurrentFieldContinuedMiddle() + || screenFields.isCurrentFieldContinuedLast()); + } + } + + updateDirty(); + simulated = true; + + if (autoFE) + sendAid(AID_ENTER); + } + else { + displayError(ERR_FIELD_MINUS); + } + } + else { + displayError(ERR_CURSOR_PROTECTED); + } + + break; + + case BOF: + if (screenFields.getCurrentField() != null + && screenFields.withinCurrentField(lastPos) + && !screenFields.isCurrentFieldBypassField()) { + int where = screenFields.getCurrentField().startPos(); + + if (where > 0) { + goto_XY(where); + } + + simulated = true; } else { - displayError(ERR_FIELD_MINUS); - + displayError(ERR_CURSOR_PROTECTED); } - } - else { - displayError(ERR_CURSOR_PROTECTED); - } - - break; - case BOF: - if (screenFields.getCurrentField() != null - && screenFields.withinCurrentField(lastPos) - && !screenFields.isCurrentFieldBypassField()) { - int where = screenFields.getCurrentField().startPos(); - if (where > 0) { - goto_XY(where); + + resetDirty(lastPos); + break; + + case SYSREQ: + sessionVT.systemRequest(); + simulated = true; + break; + + case RESET: + if (isStatusErrorCode()) { + resetError(); + isInField(lastPos); + updateDirty(); } + else { + setPrehelpState(false, oia.isKeyBoardLocked(), false); + } + + simulated = true; + break; + + case ATTN: + sessionVT.sendAttentionKey(); simulated = true; - } else { - displayError(ERR_CURSOR_PROTECTED); - } - resetDirty(lastPos); - - break; - case SYSREQ: - sessionVT.systemRequest(); - simulated = true; - break; - case RESET: - if (isStatusErrorCode()) { - resetError(); - isInField(lastPos); - updateDirty(); - } else { - setPrehelpState(false, oia.isKeyBoardLocked(), false); - } - simulated = true; - break; - case ATTN: - sessionVT.sendAttentionKey(); - simulated = true; - break; - case DUP_FIELD: - if (screenFields.getCurrentField() != null - && screenFields.withinCurrentField(lastPos) - && !screenFields.isCurrentFieldBypassField()) { - - if (screenFields.isCurrentFieldDupEnabled()) { - resetDirty(lastPos); - screenFields.getCurrentField().setFieldChar(lastPos, - (char) 0x1C); - screenFields.setCurrentFieldMDT(); - gotoFieldNext(); - updateDirty(); - simulated = true; - } else { - displayError(ERR_DUP_KEY_NOT_ALLOWED); + break; + + case DUP_FIELD: + if (screenFields.getCurrentField() != null + && screenFields.withinCurrentField(lastPos) + && !screenFields.isCurrentFieldBypassField()) { + if (screenFields.isCurrentFieldDupEnabled()) { + resetDirty(lastPos); + screenFields.getCurrentField().setFieldChar(lastPos, + (char) 0x1C); + screenFields.setCurrentFieldMDT(); + gotoFieldNext(); + updateDirty(); + simulated = true; + } + else { + displayError(ERR_DUP_KEY_NOT_ALLOWED); + } + } + else { + displayError(ERR_CURSOR_PROTECTED); } - } else { - displayError(ERR_CURSOR_PROTECTED); - } - - break; - case NEW_LINE: - if (screenFields.getSize() > 0) { - int startRow = getRow(lastPos) + 1; - int startPos = lastPos; - - if (startRow == getRows()) - startRow = 0; - - setCursor(++startRow, 1); - - if (!isInField() && screenFields.getCurrentField() != null - && !screenFields.isCurrentFieldBypassField()) { - while (!isInField() - && screenFields.getCurrentField() != null + + break; + + case NEW_LINE: + if (screenFields.getSize() > 0) { + int startRow = getRow(lastPos) + 1; + int startPos = lastPos; + + if (startRow == getRows()) + startRow = 0; + + setCursor(++startRow, 1); + + if (!isInField() && screenFields.getCurrentField() != null && !screenFields.isCurrentFieldBypassField()) { - - // lets keep going - advancePos(); - - // Have we looped the screen? - if (lastPos == startPos) { - // if so then go back to starting point - goto_XY(startPos); - break; + while (!isInField() + && screenFields.getCurrentField() != null + && !screenFields.isCurrentFieldBypassField()) { + // lets keep going + advancePos(); + + // Have we looped the screen? + if (lastPos == startPos) { + // if so then go back to starting point + goto_XY(startPos); + break; + } } } } - } - simulated = true; - break; - case FAST_CURSOR_DOWN: - int rowNow = (getCurrentRow()-1) + 3; - if (rowNow > getRows()-1) - rowNow = rowNow - getRows(); - this.goto_XY(getPos(rowNow,getCurrentCol()-1)); - simulated = true; - break; - case FAST_CURSOR_UP: - rowNow = (getCurrentRow()-1) - 3; - if (rowNow < 0) - rowNow = (getRows()) + rowNow; - this.goto_XY(getPos(rowNow,getCurrentCol()-1)); - simulated = true; - break; - case FAST_CURSOR_LEFT: - int colNow = (getCurrentCol()-1) - 3; - rowNow = getCurrentRow()-1; - if (colNow <= 0) { - colNow = getColumns() + colNow; - rowNow--; - } - if (rowNow < 0) - rowNow = getRows() - 1; - - process_XY(getPos(rowNow,colNow)); - simulated = true; - break; - case FAST_CURSOR_RIGHT: - colNow = (getCurrentCol()-1) + 3; - rowNow = getCurrentRow()-1; - if (colNow >= getColumns()) { - colNow = colNow - getColumns(); - rowNow++; - } - if (rowNow > getRows() - 1) - rowNow = getRows() - rowNow; - - process_XY(getPos(rowNow,colNow)); - simulated = true; - break; - default: - Log.i(TAG," Mnemonic not supported " + mnem); - break; - + + simulated = true; + break; + + case FAST_CURSOR_DOWN: + int rowNow = (getCurrentRow() - 1) + 3; + + if (rowNow > getRows() - 1) + rowNow = rowNow - getRows(); + + this.goto_XY(getPos(rowNow, getCurrentCol() - 1)); + simulated = true; + break; + + case FAST_CURSOR_UP: + rowNow = (getCurrentRow() - 1) - 3; + + if (rowNow < 0) + rowNow = (getRows()) + rowNow; + + this.goto_XY(getPos(rowNow, getCurrentCol() - 1)); + simulated = true; + break; + + case FAST_CURSOR_LEFT: + int colNow = (getCurrentCol() - 1) - 3; + rowNow = getCurrentRow() - 1; + + if (colNow <= 0) { + colNow = getColumns() + colNow; + rowNow--; + } + + if (rowNow < 0) + rowNow = getRows() - 1; + + process_XY(getPos(rowNow, colNow)); + simulated = true; + break; + + case FAST_CURSOR_RIGHT: + colNow = (getCurrentCol() - 1) + 3; + rowNow = getCurrentRow() - 1; + + if (colNow >= getColumns()) { + colNow = colNow - getColumns(); + rowNow++; + } + + if (rowNow > getRows() - 1) + rowNow = getRows() - rowNow; + + process_XY(getPos(rowNow, colNow)); + simulated = true; + break; + + default: + Log.i(TAG, " Mnemonic not supported " + mnem); + break; } return simulated; } protected boolean simulateKeyStroke(char c) { - if (isStatusErrorCode() && !Character.isISOControl(c) && !keyProcessed) { if (resetRequired) return false; + resetError(); } @@ -1699,57 +1764,62 @@ boolean autoEnter = false; if (!Character.isISOControl(c)) { - if (screenFields.getCurrentField() != null && screenFields.withinCurrentField(lastPos) && !screenFields.isCurrentFieldBypassField()) { - if (screenFields.isCurrentFieldFER() && !screenFields.withinCurrentField(screenFields .getCurrentFieldPos()) - && lastPos == screenFields.getCurrentField().endPos() - && screenFields.getCurrentFieldPos() > screenFields - .getCurrentField().endPos()) { - + && lastPos == screenFields.getCurrentField().endPos() + && screenFields.getCurrentFieldPos() > screenFields + .getCurrentField().endPos()) { displayError(ERR_FIELD_EXIT_INVALID); feError = true; return false; } switch (screenFields.getCurrentFieldShift()) { - case 0: // Alpha shift - case 2: // Numeric Shift - case 4: // Kakana Shift - updateField = true; - break; - case 1: // Alpha Only - if (Character.isLetter(c) || c == ',' || c == '-' - || c == '.' || c == ' ') - updateField = true; - break; - case 3: // Numeric only - if (Character.isDigit(c) || c == '+' || c == ',' - || c == '-' || c == '.' || c == ' ') + case 0: // Alpha shift + case 2: // Numeric Shift + case 4: // Kakana Shift updateField = true; - else - numericError = true; - break; - case 5: // Digits only - if (Character.isDigit(c)) - updateField = true; - else - displayError(ERR_NUMERIC_09); - break; - case 7: // Signed numeric - if (Character.isDigit(c) || c == '+' || c == '-') - if (lastPos == screenFields.getCurrentField().endPos() - && (c != '+' && c != '-')) - displayError(ERR_INVALID_SIGN); + break; + + case 1: // Alpha Only + if (Character.isLetter(c) || c == ',' || c == '-' + || c == '.' || c == ' ') + updateField = true; + + break; + + case 3: // Numeric only + if (Character.isDigit(c) || c == '+' || c == ',' + || c == '-' || c == '.' || c == ' ') + updateField = true; else + numericError = true; + + break; + + case 5: // Digits only + if (Character.isDigit(c)) updateField = true; - else - displayError(ERR_NUMERIC_09); - break; + else + displayError(ERR_NUMERIC_09); + + break; + + case 7: // Signed numeric + if (Character.isDigit(c) || c == '+' || c == '-') + if (lastPos == screenFields.getCurrentField().endPos() + && (c != '+' && c != '-')) + displayError(ERR_INVALID_SIGN); + else + updateField = true; + else + displayError(ERR_NUMERIC_09); + + break; } if (updateField) { @@ -1764,29 +1834,26 @@ .endPos()) shiftRight(lastPos); else { - displayError(ERR_NO_ROOM_INSERT); updatePos = false; } - } if (updatePos) { screenFields.getCurrentField().getKeyPos( - getRow(lastPos), getCol(lastPos)); + getRow(lastPos), getCol(lastPos)); screenFields.getCurrentField().changePos(1); - - planes.setChar(lastPos,c); - + planes.setChar(lastPos, c); screenFields.setCurrentFieldMDT(); // if we have gone passed the end of the field then goto // the next field if (!screenFields.withinCurrentField(screenFields - .getCurrentFieldPos())) { + .getCurrentFieldPos())) { if (screenFields.isCurrentFieldAutoEnter()) { autoEnter = true; - } else if (!screenFields.isCurrentFieldFER()) + } + else if (!screenFields.isCurrentFieldFER()) gotoFieldNext(); else { // screenFields.getCurrentField().changePos(1); @@ -1799,28 +1866,29 @@ // if (feError) // displayError(ERR_FIELD_EXIT_INVALID); } - - } else + } + else setCursor(screenFields.getCurrentField() - .getCursorRow() + 1, screenFields - .getCurrentField().getCursorCol() + 1); - + .getCursorRow() + 1, screenFields + .getCurrentField().getCursorCol() + 1); } fireScreenChanged(); if (autoEnter) sendAid(AID_ENTER); - } else { + } + else { if (numericError) { displayError(ERR_NUMERIC_ONLY); } } - } else { + } + else { displayError(ERR_CURSOR_PROTECTED); } - } + return updatePos; } @@ -1859,7 +1927,6 @@ * */ private int endOfField(int pos, boolean posSpace) { - int endPos = screenFields.getCurrentField().endPos(); int fePos = endPos; // get the number of characters to the right @@ -1867,28 +1934,25 @@ // first lets get the real ending point without spaces and the such while (planes.getChar(endPos) <= ' ' && count-- > 0) { - endPos--; } if (endPos == fePos) { - return endPos; - } + screenFields.getCurrentField().getKeyPos(endPos); + if (posSpace) screenFields.getCurrentField().changePos(+1); + return screenFields.getCurrentFieldPos(); - } private boolean fieldExit() { - int pos = lastPos; boolean mdt = false; int end = endOfField(false); // get the ending position of the first // non blank character in field - ScreenField sf = screenFields.getCurrentField(); if (sf.isMandatoryEnter() && end == sf.startPos()) { @@ -1902,7 +1966,6 @@ // Maybe this should be changed to not update the current cursor position // of the field. int currentPos = sf.getCurrentPos(); - // get the number of characters to the right int count = (end - sf.startPos()) - sf.getKeyPos(pos); @@ -1926,6 +1989,7 @@ // place the count as -1. if (count == -1) { int s = sf.getFieldShift(); + if (s == 3 || s == 5 || s == 7) { mdt = true; } @@ -1934,26 +1998,23 @@ int adj = sf.getAdjustment(); if (adj != 0) { - switch (adj) { - - case 5: - rightAdjustField('0'); - sf.setRightAdjusted(); - break; - case 6: - rightAdjustField(' '); - sf.setRightAdjusted(); - - break; - case 7: - sf.setManditoryEntered(); - break; - + case 5: + rightAdjustField('0'); + sf.setRightAdjusted(); + break; + + case 6: + rightAdjustField(' '); + sf.setRightAdjusted(); + break; + + case 7: + sf.setManditoryEntered(); + break; } } else { - // we need to right adjust signed numeric fields as well. if (sf.isSignedNumeric()) { rightAdjustField(' '); @@ -1964,132 +2025,115 @@ } private void rightAdjustField(char fill) { - int end = endOfField(false); // get the ending position of the first // non blank character in field - // get the number of characters to the right int count = screenFields.getCurrentField().endPos() - end; // subtract 1 from count for signed numeric - note for later if (screenFields.getCurrentField().isSignedNumeric()) { - if (planes.getChar(end -1) != '-') + if (planes.getChar(end - 1) != '-') count--; } int pos = screenFields.getCurrentField().startPos(); while (count-- >= 0) { - shiftRight(pos); - planes.setChar(pos,fill); - + planes.setChar(pos, fill); setDirty(pos); - } - } private void shiftLeft(int sPos) { - int endPos = 0; - int pos = sPos; int pPos = sPos; - ScreenField sf = screenFields.getCurrentField(); int end; int count; + do { end = endOfField(pPos, false); // get the ending position of the // first // non blank character in field - count = (end - screenFields.getCurrentField().startPos()) - - screenFields.getCurrentField().getKeyPos(pPos); + - screenFields.getCurrentField().getKeyPos(pPos); // now we loop through and shift the remaining characters to the // left while (count-- > 0) { pos++; - planes.setChar(pPos,planes.getChar(pos)); + planes.setChar(pPos, planes.getChar(pos)); setDirty(pPos); pPos = pos; - } if (screenFields.isCurrentFieldContinued()) { gotoFieldNext(); + if (screenFields.getCurrentField().isContinuedFirst()) break; pos = screenFields.getCurrentField().startPos(); - planes.setChar(pPos,planes.getChar(pos)); + planes.setChar(pPos, planes.getChar(pos)); setDirty(pPos); - pPos = pos; - } - } while (screenFields.isCurrentFieldContinued() + } + while (screenFields.isCurrentFieldContinued() && !screenFields.getCurrentField().isContinuedFirst()); if (end >= 0 && count >= -1) { - endPos = end; - } else { + } + else { endPos = sPos; - } screenFields.setCurrentField(sf); - planes.setChar(endPos,initChar); + planes.setChar(endPos, initChar); setDirty(endPos); goto_XY(screenFields.getCurrentFieldPos()); sf = null; - } private void shiftRight(int sPos) { - int end = endOfField(true); // get the ending position of the first // non blank character in field int pos = end; int pPos = end; - int count = end - sPos; // now we loop through and shift the remaining characters to the right while (count-- > 0) { - pos--; planes.setChar(pPos, planes.getChar(pos)); setDirty(pPos); - pPos = pos; } } public int getRow(int pos) { - // if (pos == 0) // return 1; - int row = pos / numCols; if (row < 0) { - row = lastPos / numCols; } + if (row > (lenScreen / numCols) - 1) row = (lenScreen / numCols) - 1; return row; - } public int getCol(int pos) { int col = pos % (getColumns()); + if (col > 0) return col; + return 0; } @@ -2101,7 +2145,6 @@ * @return */ public int getPos(int row, int col) { - return (row * numCols) + col; } @@ -2112,10 +2155,8 @@ * @return int */ public int getCurrentPos() { - // return lastPos + numCols + 1; return lastPos + 1; - } /** @@ -2185,13 +2226,12 @@ homePos = lastPos + numCols + 1; pendingInsert = true; sessionVT.sendNegResponse2(ec); - } private void process_XY(int pos) { - if (pos < 0) pos = lenScreen + pos; + if (pos > lenScreen - 1) pos = pos - lenScreen; @@ -2213,19 +2253,21 @@ // other keys will reset the field position so that entering over the // last character will not cause an error but replace that character or // just plain move the cursor if the key was to do that. - ScreenField sf = screenFields.getCurrentField(); + if (feError) { feError = false; sf.changePos(-1); - } else { - if (sf != null&& sf.isFER()){ + } + else { + if (sf != null && sf.isFER()) { if ((sf.getCurrentPos() > sf.endPos())) { if (sf.withinField(pos)) { sf.getKeyPos(pos); return; } + sf.getKeyPos(sf.endPos()); } } @@ -2235,7 +2277,6 @@ } public boolean isUsingGuiInterface() { - return guiInterface; } @@ -2246,7 +2287,6 @@ */ protected boolean isInField() { - return isInField(lastPos, true); } @@ -2261,7 +2301,6 @@ * @return true or false */ public boolean isInField(int pos, boolean chgToField) { - return screenFields.isInField(pos, chgToField); } @@ -2275,7 +2314,6 @@ * @return true or false */ public boolean isInField(int pos) { - return screenFields.isInField(pos, true); } @@ -2289,7 +2327,6 @@ * @return true or false */ public boolean isInField(int row, int col) { - return isInField(row, col, true); } @@ -2315,7 +2352,6 @@ * @return int value of screen length */ public int getScreenLength() { - return lenScreen; } @@ -2325,9 +2361,7 @@ * @return number of rows */ public int getRows() { - return numRows; - } /** @@ -2336,9 +2370,7 @@ * @return number of columns */ public int getColumns() { - return numCols; - } /** @@ -2347,9 +2379,7 @@ * @return the cursor current row position 1,1 based */ public int getCurrentRow() { - return (lastPos / numCols) + 1; - } /** @@ -2358,9 +2388,7 @@ * @return the cursor current column position 1,1 based */ public int getCurrentCol() { - return (lastPos % numCols) + 1; - } /** @@ -2370,9 +2398,7 @@ * @return last position */ protected int getLastPos() { - return lastPos; - } /** @@ -2405,13 +2431,15 @@ for (int x = 0; x < lenScreen; x++) { c = planes.getChar(x); + // only draw printable characters (in this case >= ' ') if ((c >= ' ') && (!planes.isAttributePlace(x))) { sac[x] = c; // TODO: implement the underline check here // if (screen[x].underLine && c <= ' ') // sac[x] = '_'; - } else + } + else sac[x] = ' '; } @@ -2420,20 +2448,20 @@ public char[] getData(int startRow, int startCol, int endRow, int endCol, int plane) { try { - int from = getPos(startRow,startCol); - int to = getPos(endRow,endCol); + int from = getPos(startRow, startCol); + int to = getPos(endRow, endCol); + if (from > to) { - int f = from; to = f; from = f; } - return planes.getPlaneData(from,to,plane); + + return planes.getPlaneData(from, to, plane); } catch (Exception oe) { return null; } - } /** @@ -2458,11 +2486,11 @@ * @return The number of characters copied to the buffer * @throws OhioException */ + public synchronized int GetScreen(char buffer[], int bufferLength, int plane) // throws OhioException { { - return GetScreen(buffer,bufferLength,0,lenScreen,plane); - + return GetScreen(buffer, bufferLength, 0, lenScreen, plane); } /** @@ -2489,12 +2517,12 @@ * @return The number of characters copied to the buffer * @throws OhioException */ + public synchronized int GetScreen(char buffer[], int bufferLength, int from, - int length, int plane) + int length, int plane) // throws OhioException { { - - return planes.GetScreen(buffer,bufferLength, from, length, plane); + return planes.GetScreen(buffer, bufferLength, from, length, plane); } /** @@ -2523,13 +2551,14 @@ * @return The number of characters copied to the buffer. * @throws OhioException */ + public synchronized int GetScreen(char buffer[], int bufferLength, int row, - int col, int length, int plane) + int col, int length, int plane) // throws OhioException { { // Call GetScreen function after converting row and column to // a position. - return planes.GetScreen(buffer,bufferLength, row, col, length, plane); + return planes.GetScreen(buffer, bufferLength, row, col, length, plane); } /** @@ -2562,12 +2591,12 @@ * @return The number of characters copied to the buffer * @throws OhioException */ + public synchronized int GetScreenRect(char buffer[], int bufferLength, - int startPos, int endPos, int plane) + int startPos, int endPos, int plane) // throws OhioException { { return planes.GetScreenRect(buffer, bufferLength, startPos, endPos, plane); - } /** @@ -2602,14 +2631,14 @@ * @return The number characters copied to the buffer * @throws OhioException */ + public synchronized int GetScreenRect(char buffer[], int bufferLength, - int startRow, int startCol, - int endRow, int endCol, int plane) + int startRow, int startCol, + int endRow, int endCol, int plane) // throws OhioException { { - return planes.GetScreenRect(buffer, bufferLength, startRow, startCol, endRow, - endCol, plane); + endCol, plane); } public synchronized boolean[] getActiveAidKeys() { @@ -2618,7 +2647,6 @@ protected synchronized void setScreenData(String text, int location) { // throws OhioException { - if (location < 0 || location > lenScreen) { return; // throw new OhioException(sessionVT.getSessionConfiguration(), @@ -2626,13 +2654,13 @@ } int pos = location; - int l = text.length(); boolean updated = false; boolean flag = false; - int x =0; + int x = 0; + for (; x < l; x++) { - if (isInField(pos + x,true)) { + if (isInField(pos + x, true)) { if (!screenFields.getCurrentField().isBypassField()) { if (!flag) { screenFields.getCurrentField().setMDT(); @@ -2646,13 +2674,13 @@ setDirty(pos + x); } } - } + lastPos = pos + x; + if (updated) { fireScreenChanged(); } - } /** @@ -2682,10 +2710,12 @@ */ public void setField(int l, int c, char [] data) { ScreenField cf; + if (l >= 0) { int position = l * numCols + c; isInField(position, true); } + if ((data != null) && (data.length > 0)) { cf = screenFields.getCurrentField(); cf.setString(new String(data)); @@ -2693,6 +2723,7 @@ setDirty(lastPos); setDirty(lastPos + cf.getLength()); } + updateDirty(); } @@ -2704,7 +2735,6 @@ * @return true or false whether it was sucessful */ public boolean gotoField(int f) { - int sizeFields = screenFields.getSize(); if (f > sizeFields || f <= 0) @@ -2713,10 +2743,9 @@ screenFields.setCurrentField(screenFields.getField(f - 1)); while (screenFields.isCurrentFieldBypassField() && f < sizeFields) { - screenFields.setCurrentField(screenFields.getField(f++)); - } + return gotoField(screenFields.getCurrentField()); } @@ -2733,6 +2762,7 @@ goto_XY(f.startPos()); return true; } + return false; } @@ -2741,16 +2771,17 @@ * */ private void gotoNextWord() { - int pos = lastPos; if (planes.getChar(lastPos) > ' ') { advancePos(); + // get the next space character while (planes.getChar(lastPos) > ' ' && pos != lastPos) { advancePos(); } - } else + } + else advancePos(); // now that we are positioned on the next space character get the @@ -2758,7 +2789,6 @@ while (planes.getChar(lastPos) <= ' ' && pos != lastPos) { advancePos(); } - } /** @@ -2767,19 +2797,19 @@ * */ private void gotoPrevWord() { - int pos = lastPos; - changePos(-1); // position previous white space character while (planes.getChar(lastPos) <= ' ') { changePos(-1); + if (pos == lastPos) break; } changePos(-1); + // get the previous space character while (planes.getChar(lastPos) > ' ' && pos != lastPos) { changePos(-1); @@ -2787,7 +2817,6 @@ // and position one position more should give us the beginning of word advancePos(); - } /** @@ -2796,7 +2825,6 @@ * @see org.tn5250j.ScreenFields */ private void gotoFieldNext() { - if (screenFields.isCurrentFieldHighlightedEntry()) unsetFieldHighlighted(screenFields.getCurrentField()); @@ -2812,7 +2840,6 @@ * @see org.tn5250j.ScreenFields */ private void gotoFieldPrev() { - if (screenFields.isCurrentFieldHighlightedEntry()) unsetFieldHighlighted(screenFields.getCurrentField()); @@ -2820,7 +2847,6 @@ if (screenFields.isCurrentFieldHighlightedEntry()) setFieldHighlighted(screenFields.getCurrentField()); - } /* *** NEVER USED LOCALLY ************************************************** */ @@ -2860,29 +2886,27 @@ * @param lr */ protected void createWindow(int depth, int width, int type, boolean gui, - int monoAttr, int colorAttr, int ul, int upper, int ur, int left, - int right, int ll, int bottom, int lr) { - + int monoAttr, int colorAttr, int ul, int upper, int ur, int left, + int right, int ll, int bottom, int lr) { int c = getCol(lastPos); int w = 0; width++; - w = width; // set leading attribute byte // screen[lastPos].setCharAndAttr(initChar, initAttr, true); planes.setScreenCharAndAttr(lastPos, initChar, initAttr, true); setDirty(lastPos); - advancePos(); // set upper left // screen[lastPos].setCharAndAttr((char) ul, colorAttr, false); planes.setScreenCharAndAttr(lastPos, (char) ul, colorAttr, false); + if (gui) { // screen[lastPos].setUseGUI(UPPER_LEFT); planes.setUseGUI(lastPos, UPPER_LEFT); } + setDirty(lastPos); - advancePos(); // draw top row @@ -2890,120 +2914,119 @@ while (w-- >= 0) { // screen[lastPos].setCharAndAttr((char) upper, colorAttr, false); planes.setScreenCharAndAttr(lastPos, (char) upper, colorAttr, false); + if (gui) { // screen[lastPos].setUseGUI(UPPER); - planes.setUseGUI(lastPos,UPPER); + planes.setUseGUI(lastPos, UPPER); } + setDirty(lastPos); advancePos(); } // set upper right // screen[lastPos].setCharAndAttr((char) ur, colorAttr, false); - planes.setScreenCharAndAttr(lastPos,(char) ur, colorAttr, false); + planes.setScreenCharAndAttr(lastPos, (char) ur, colorAttr, false); if (gui) { // screen[lastPos].setUseGUI(UPPER_RIGHT); planes.setUseGUI(lastPos, UPPER_RIGHT); } + setDirty(lastPos); advancePos(); - // set ending attribute byte - planes.setScreenCharAndAttr(lastPos,initChar, initAttr, true); - + planes.setScreenCharAndAttr(lastPos, initChar, initAttr, true); setDirty(lastPos); - lastPos = ((getRow(lastPos) + 1) * numCols) + c; // now handle body of window while (depth-- > 0) { - // set leading attribute byte - planes.setScreenCharAndAttr(lastPos,initChar, initAttr, true); + planes.setScreenCharAndAttr(lastPos, initChar, initAttr, true); setDirty(lastPos); advancePos(); - // set left planes.setScreenCharAndAttr(lastPos, (char) left, colorAttr, false); if (gui) { - planes.setUseGUI(lastPos,GUI_LEFT); + planes.setUseGUI(lastPos, GUI_LEFT); } + setDirty(lastPos); advancePos(); - w = width; + // fill it in while (w-- >= 0) { // screen[lastPos].setCharAndAttr(initChar, initAttr, true); - planes.setScreenCharAndAttr(lastPos,initChar, initAttr, true); + planes.setScreenCharAndAttr(lastPos, initChar, initAttr, true); // screen[lastPos].setUseGUI(NO_GUI); - planes.setUseGUI(lastPos,NO_GUI); + planes.setUseGUI(lastPos, NO_GUI); setDirty(lastPos); advancePos(); } // set right // screen[lastPos].setCharAndAttr((char) right, colorAttr, false); - planes.setScreenCharAndAttr(lastPos,(char) right, colorAttr, false); + planes.setScreenCharAndAttr(lastPos, (char) right, colorAttr, false); + if (gui) { // screen[lastPos].setUseGUI(RIGHT); - planes.setUseGUI(lastPos,GUI_RIGHT); + planes.setUseGUI(lastPos, GUI_RIGHT); } setDirty(lastPos); advancePos(); - // set ending attribute byte // screen[lastPos].setCharAndAttr(initChar, initAttr, true); - planes.setScreenCharAndAttr(lastPos,initChar, initAttr, true); + planes.setScreenCharAndAttr(lastPos, initChar, initAttr, true); setDirty(lastPos); - lastPos = ((getRow(lastPos) + 1) * numCols) + c; } // set leading attribute byte // screen[lastPos].setCharAndAttr(initChar, initAttr, true); - planes.setScreenCharAndAttr(lastPos,initChar, initAttr, true); + planes.setScreenCharAndAttr(lastPos, initChar, initAttr, true); setDirty(lastPos); advancePos(); - // set lower left // screen[lastPos].setCharAndAttr((char) ll, colorAttr, false); - planes.setScreenCharAndAttr(lastPos,(char) ll, colorAttr, false); + planes.setScreenCharAndAttr(lastPos, (char) ll, colorAttr, false); + if (gui) { // screen[lastPos].setUseGUI(LOWER_LEFT); - planes.setUseGUI(lastPos,LOWER_LEFT); + planes.setUseGUI(lastPos, LOWER_LEFT); } + setDirty(lastPos); advancePos(); - w = width; // draw bottom row while (w-- >= 0) { - planes.setScreenCharAndAttr(lastPos,(char) bottom, colorAttr, false); + planes.setScreenCharAndAttr(lastPos, (char) bottom, colorAttr, false); + if (gui) { - planes.setUseGUI(lastPos,BOTTOM); + planes.setUseGUI(lastPos, BOTTOM); } + setDirty(lastPos); advancePos(); } // set lower right planes.setScreenCharAndAttr(lastPos, (char) lr, colorAttr, false); + if (gui) { - planes.setUseGUI(lastPos,LOWER_RIGHT); + planes.setUseGUI(lastPos, LOWER_RIGHT); } setDirty(lastPos); advancePos(); - // set ending attribute byte - planes.setScreenCharAndAttr(lastPos,initChar, initAttr, true); + planes.setScreenCharAndAttr(lastPos, initChar, initAttr, true); setDirty(lastPos); - } /** @@ -3019,9 +3042,8 @@ * @param sbSize */ protected void createScrollBar(int flag, int totalRowScrollable, - int totalColScrollable, int sliderRowPos, int sliderColPos, - int sbSize) { - + int totalColScrollable, int sliderRowPos, int sliderColPos, + int sbSize) { // System.out.println("Scrollbar flag: " + flag + // " scrollable Rows: " + totalRowScrollable + // " scrollable Cols: " + totalColScrollable + @@ -3030,28 +3052,27 @@ // " size: " + sbSize + // " row: " + getRow(lastPos) + // " col: " + getCol(lastPos)); - int sp = lastPos; int size = sbSize - 2; - - int thumbPos = (int) (size * ((float) sliderColPos / (float) totalColScrollable)); + int thumbPos = (int)(size * ((float) sliderColPos / (float) totalColScrollable)); // System.out.println(thumbPos); - planes.setScreenCharAndAttr(sp,' ', 32, false); - planes.setUseGUI(sp,BUTTON_SB_UP); - + planes.setScreenCharAndAttr(sp, ' ', 32, false); + planes.setUseGUI(sp, BUTTON_SB_UP); int ctr = 0; + while (ctr < size) { sp += numCols; - planes.setScreenCharAndAttr(sp,' ', 32, false); + planes.setScreenCharAndAttr(sp, ' ', 32, false); + if (ctr == thumbPos) - planes.setUseGUI(sp,BUTTON_SB_THUMB); + planes.setUseGUI(sp, BUTTON_SB_THUMB); else planes.setUseGUI(sp, BUTTON_SB_GUIDE); + ctr++; } + sp += numCols; - - planes.setScreenCharAndAttr(sp, ' ', 32, false); planes.setUseGUI(sp, BUTTON_SB_DN); } @@ -3068,27 +3089,27 @@ * @param title */ protected void writeWindowTitle(int pos, int depth, int width, - byte orientation, int monoAttr, int colorAttr, StringBuffer title) { - + byte orientation, int monoAttr, int colorAttr, StringBuffer title) { int len = title.length(); // get bit 0 and 1 for interrogation switch (orientation & 0xc0) { - case 0x40: // right - pos += (4 + width - len); - break; - case 0x80: // left - pos += 2; - break; - default: // center - // this is to place the position to the first text position of the - // window - // the position passed in is the first attribute position, the next - // is the border character and then there is another attribute after - // that. - pos += (3 + ((width / 2) - (len / 2))); - break; - + case 0x40: // right + pos += (4 + width - len); + break; + + case 0x80: // left + pos += 2; + break; + + default: // center + // this is to place the position to the first text position of the + // window + // the position passed in is the first attribute position, the next + // is the border character and then there is another attribute after + // that. + pos += (3 + ((width / 2) - (len / 2))); + break; } // if bit 2 is on then this is a footer @@ -3101,7 +3122,6 @@ for (int x = 0; x < len; x++) { planes.setChar(pos, title.charAt(x)); planes.setUseGUI(pos++, NO_GUI); - } } @@ -3119,7 +3139,6 @@ * @param bottomLine */ protected void rollScreen(int direction, int topLine, int bottomLine) { - // get the number of lines which are the last 5 bits /* int lines = direction & 0x7F; */ // get the direction of the roll which is the first bit @@ -3127,7 +3146,6 @@ // 1 - down int updown = direction & 0x80; final int lines = direction & 0x7F; - // calculate the reference points for the move. int start = this.getPos(topLine - 1, 0); int end = this.getPos(bottomLine - 1, numCols - 1); @@ -3136,53 +3154,62 @@ // System.out.println(" starting roll"); // dumpScreen(); switch (updown) { - case 0: - // Now round em up and head em UP. - for (int x = start; x < end + numCols; x++) { - if (x + lines * numCols >= lenScreen) { - //Clear at the end - planes.setChar(x, ' '); - } else { - planes.setChar(x, planes.getChar(x + lines * numCols )); + case 0: + + // Now round em up and head em UP. + for (int x = start; x < end + numCols; x++) { + if (x + lines * numCols >= lenScreen) { + //Clear at the end + planes.setChar(x, ' '); + } + else { + planes.setChar(x, planes.getChar(x + lines * numCols)); + } } - } - break; - case 1: - // Now round em up and head em DOWN. - for (int x = end + numCols; x > 0; x--) { - if ((x - lines * numCols ) < 0 ) { - //Do nothing ... tooo small!!! - } else { - planes.setChar(x - lines * numCols, planes.getChar(x)); - //and clear - planes.setChar(x, ' '); + + break; + + case 1: + + // Now round em up and head em DOWN. + for (int x = end + numCols; x > 0; x--) { + if ((x - lines * numCols) < 0) { + //Do nothing ... tooo small!!! + } + else { + planes.setChar(x - lines * numCols, planes.getChar(x)); + //and clear + planes.setChar(x, ' '); + } } - } - break; - default: - Log.w(TAG," Invalid roll parameter - please report this"); + + break; + + default: + Log.w(TAG, " Invalid roll parameter - please report this"); } + // System.out.println(" end roll"); // dumpScreen(); - } public void dumpScreen() { - StringBuffer sb = new StringBuffer(); char[] s = getScreenAsChars(); int c = getColumns(); int l = getRows() * c; int col = 0; + for (int x = 0; x < l; x++, col++) { sb.append(s[x]); + if (col == c) { sb.append('\n'); col = 0; } } - Log.i(TAG,sb.toString()); - + + Log.i(TAG, sb.toString()); } /** @@ -3196,16 +3223,11 @@ * @param fcw2 - Field control word 2 */ protected void addField(int attr, int len, int ffw1, int ffw2, int fcw1, - int fcw2) { - + int fcw2) { lastAttr = attr; - planes.setScreenCharAndAttr(lastPos, initChar, lastAttr, true); - setDirty(lastPos); - advancePos(); - ScreenField sf = null; // from 14.6.12 for Start of Field Order 5940 function manual @@ -3213,32 +3235,30 @@ // starting address plus 1. if (screenFields.existsAtPos(lastPos)) { screenFields.setCurrentFieldFFWs(ffw1, ffw2); - } else { + } + else { sf = screenFields.setField(attr, getRow(lastPos), getCol(lastPos), - len, ffw1, ffw2, fcw1, fcw2); + len, ffw1, ffw2, fcw1, fcw2); lastPos = sf.startPos(); int x = len; - boolean gui = guiInterface; + if (sf.isBypassField()) gui = false; while (x-- > 0) { - if (planes.getChar(lastPos) == 0) planes.setScreenCharAndAttr(lastPos, ' ', lastAttr, false); else - planes.setScreenAttr(lastPos,lastAttr); + planes.setScreenAttr(lastPos, lastAttr); if (gui) { - planes.setUseGUI(lastPos,FIELD_MIDDLE); + planes.setUseGUI(lastPos, FIELD_MIDDLE); } // now we set the field plane attributes - planes.setScreenFieldAttr(lastPos,ffw1); - + planes.setScreenFieldAttr(lastPos, ffw1); advancePos(); - } if (gui) @@ -3248,26 +3268,22 @@ if (lastPos > 0) planes.setUseGUI(lastPos - 1, FIELD_RIGHT); else - planes.setUseGUI(lastPos,FIELD_RIGHT); - + planes.setUseGUI(lastPos, FIELD_RIGHT); } else { - planes.setUseGUI(lastPos - 1,FIELD_ONE); + planes.setUseGUI(lastPos - 1, FIELD_ONE); } // screen[lastPos].setCharAndAttr(initChar,initAttr,true); setEndingAttr(initAttr); - lastPos = sf.startPos(); } // if (fcw1 != 0 || fcw2 != 0) { - // System.out.println("lr = " + lastRow + " lc = " + lastCol + " " + // sf.toString()); // } sf = null; - } @@ -3365,19 +3381,15 @@ * */ protected void drawFields() { - ScreenField sf; - int sizeFields = screenFields.getSize(); + for (int x = 0; x < sizeFields; x++) { - sf = screenFields.getField(x); if (!sf.isBypassField()) { int pos = sf.startPos(); - int l = sf.length; - boolean f = true; if (l >= lenScreen) @@ -3385,24 +3397,23 @@ if (l > 1) { while (l-- > 0) { - if (guiInterface && f) { - planes.setUseGUI(pos,FIELD_LEFT); + planes.setUseGUI(pos, FIELD_LEFT); f = false; - } else { - - planes.setUseGUI(pos,FIELD_MIDDLE); - + } + else { + planes.setUseGUI(pos, FIELD_MIDDLE); } if (guiInterface && l == 0) { - planes.setUseGUI(pos,FIELD_RIGHT); + planes.setUseGUI(pos, FIELD_RIGHT); } setDirty(pos++); } - } else { - planes.setUseGUI(pos,FIELD_ONE); + } + else { + planes.setUseGUI(pos, FIELD_ONE); } } } @@ -3419,9 +3430,7 @@ * @see org.tn5250j.ScreenField.java */ protected void drawField(ScreenField sf) { - int pos = sf.startPos(); - int x = sf.length; while (x-- > 0) { @@ -3429,7 +3438,6 @@ } updateDirty(); - } /** @@ -3439,18 +3447,16 @@ * Field to be highlighted */ protected void setFieldHighlighted(ScreenField sf) { - int pos = sf.startPos(); - int x = sf.length; int na = sf.getHighlightedAttr(); while (x-- > 0) { - planes.setScreenAttr(pos,na); + planes.setScreenAttr(pos, na); setDirty(pos++); } + fireScreenChanged(); - } /** @@ -3461,34 +3467,36 @@ * Field to be unhighlighted */ protected void unsetFieldHighlighted(ScreenField sf) { - int pos = sf.startPos(); - int x = sf.length; int na = sf.getAttr(); while (x-- > 0) { - planes.setScreenAttr(pos,na); + planes.setScreenAttr(pos, na); setDirty(pos++); } + fireScreenChanged(); - } protected void setChar(int cByte) { if (lastPos > 0) { lastAttr = planes.getCharAttr(lastPos - 1); } + if (cByte > 0 && (char)cByte < ' ') { planes.setScreenCharAndAttr(lastPos, (char) 0x00, 33, false); setDirty(lastPos); advancePos(); - } else { + } + else { planes.setScreenCharAndAttr(lastPos, (char) cByte, lastAttr, false); setDirty(lastPos); + if (guiInterface && !isInField(lastPos, false)) { planes.setUseGUI(lastPos, NO_GUI); } + advancePos(); } } @@ -3501,7 +3509,6 @@ protected void setAttr(int cByte) { lastAttr = cByte; - // int sattr = screen[lastPos].getCharAttr(); // System.out.println("changing from " + sattr + " to attr " + lastAttr // + @@ -3509,10 +3516,8 @@ // 1)); planes.setScreenCharAndAttr(lastPos, initChar, lastAttr, true); setDirty(lastPos); - advancePos(); int pos = lastPos; - int times = 0; // sattr = screen[lastPos].getCharAttr(); // System.out.println(" next position after change " + sattr + " last @@ -3523,15 +3528,16 @@ while (planes.getCharAttr(lastPos) != lastAttr && !planes.isAttributePlace(lastPos)) { - planes.setScreenAttr(lastPos, lastAttr); + if (guiInterface && !isInField(lastPos, false)) { int g = planes.getWhichGUI(lastPos); + if (g >= FIELD_LEFT && g <= FIELD_ONE) - planes.setUseGUI(lastPos,NO_GUI); + planes.setUseGUI(lastPos, NO_GUI); } + setDirty(lastPos); - times++; advancePos(); } @@ -3540,27 +3546,21 @@ // if (times > 200) // System.out.println(" setAttr = " + times + " start = " + (sr + 1) + // "," + (sc + 1)); - lastPos = pos; } protected void setScreenCharAndAttr(char right, int colorAttr, boolean isAttr) { - - planes.setScreenCharAndAttr(lastPos,right, colorAttr, isAttr); + planes.setScreenCharAndAttr(lastPos, right, colorAttr, isAttr); setDirty(lastPos); advancePos(); - } protected void setScreenCharAndAttr(char right, int colorAttr, - int whichGui, boolean isAttr) { - - planes.setScreenCharAndAttr(lastPos,right, colorAttr, isAttr); - planes.setUseGUI(lastPos,whichGui); - + int whichGui, boolean isAttr) { + planes.setScreenCharAndAttr(lastPos, right, colorAttr, isAttr); + planes.setUseGUI(lastPos, whichGui); setDirty(lastPos); advancePos(); - } /** @@ -3576,24 +3576,17 @@ } protected void setDirty(int pos) { - - int minr = Math.min(getRow(pos),getRow(dirtyScreen.x)); - int minc = Math.min(getCol(pos),getCol(dirtyScreen.x)); - - int maxr = Math.max(getRow(pos),getRow(dirtyScreen.y)); - int maxc = Math.max(getCol(pos),getCol(dirtyScreen.y)); - - int x1 = getPos(minr,minc); - int x2 = getPos(maxr,maxc); - - dirtyScreen.setBounds(x1,x2,0,0); - + int minr = Math.min(getRow(pos), getRow(dirtyScreen.x)); + int minc = Math.min(getCol(pos), getCol(dirtyScreen.x)); + int maxr = Math.max(getRow(pos), getRow(dirtyScreen.y)); + int maxc = Math.max(getCol(pos), getCol(dirtyScreen.y)); + int x1 = getPos(minr, minc); + int x2 = getPos(maxr, maxc); + dirtyScreen.setBounds(x1, x2, 0, 0); } private void resetDirty(int pos) { - - dirtyScreen.setBounds(pos,pos,0,0); - + dirtyScreen.setBounds(pos, pos, 0, 0); } /** @@ -3615,10 +3608,11 @@ * @param i */ protected void changePos(int i) { - lastPos += i; + if (lastPos < 0) lastPos = lenScreen + lastPos; + if (lastPos > lenScreen - 1) lastPos = lastPos - lenScreen; @@ -3626,11 +3620,9 @@ // lastCol + "," + ((lastPos) % numCols) + "," + // ((lastRow * numCols) + lastCol) + "," + // (lastPos)); - } protected void goHome() { - // now we try to move to first input field according to // 14.6 WRITE TO DISPLAY Command // ? If the WTD command is valid, after the command is processed, @@ -3640,16 +3632,17 @@ // - The start of the first non-bypass input field defined in the // format table // - A default starting address of row 1 column 1. - if (pendingInsert && homePos > 0) { setCursor(getRow(homePos), getCol(homePos)); isInField(); // we now check if we are in a field - } else { + } + else { if (!gotoField(1)) { homePos = getPos(1, 1); setCursor(1, 1); isInField(0, 0); // we now check if we are in a field - } else { + } + else { homePos = getPos(getCurrentRow(), getCurrentCol()); } } @@ -3657,6 +3650,7 @@ protected void setPendingInsert(boolean flag, int icX, int icY) { pendingInsert = flag; + if (pendingInsert) { homePos = getPos(icX, icY); } @@ -3677,7 +3671,6 @@ * @param line */ protected void setErrorLine(int line) { - planes.setErrorLine(line); } @@ -3704,51 +3697,47 @@ * @see #saveErrorLine() */ protected void restoreErrorLine() { - if (planes.isErrorLineSaved()) { planes.restoreErrorLine(); - fireScreenChanged(planes.getErrorLine()-1,0,planes.getErrorLine()-1,numCols - 1); + fireScreenChanged(planes.getErrorLine() - 1, 0, planes.getErrorLine() - 1, numCols - 1); } } protected void setStatus(byte attr, byte value, String s) { - // set the status area switch (attr) { - - case STATUS_SYSTEM: - if (value == STATUS_VALUE_ON) { - oia.setInputInhibited(ScreenOIA.INPUTINHIBITED_SYSTEM_WAIT,ScreenOIA.OIA_LEVEL_INPUT_INHIBITED, s); - } - else { - oia.setInputInhibited(ScreenOIA.INPUTINHIBITED_NOTINHIBITED,ScreenOIA.OIA_LEVEL_NOT_INHIBITED,s); - } - break; - - case STATUS_ERROR_CODE: - if (value == STATUS_VALUE_ON) { - setPrehelpState(true, true, false); - oia.setInputInhibited(ScreenOIA.INPUTINHIBITED_SYSTEM_WAIT, - ScreenOIA.OIA_LEVEL_INPUT_ERROR,s); - - sessionVT.signalBell(); - } else { - oia.setInputInhibited(ScreenOIA.INPUTINHIBITED_NOTINHIBITED, - ScreenOIA.OIA_LEVEL_NOT_INHIBITED); - setPrehelpState(false, true, true); - homePos = saveHomePos; - saveHomePos = 0; - pendingInsert = false; - } - break; - + case STATUS_SYSTEM: + if (value == STATUS_VALUE_ON) { + oia.setInputInhibited(ScreenOIA.INPUTINHIBITED_SYSTEM_WAIT, ScreenOIA.OIA_LEVEL_INPUT_INHIBITED, s); + } + else { + oia.setInputInhibited(ScreenOIA.INPUTINHIBITED_NOTINHIBITED, ScreenOIA.OIA_LEVEL_NOT_INHIBITED, s); + } + + break; + + case STATUS_ERROR_CODE: + if (value == STATUS_VALUE_ON) { + setPrehelpState(true, true, false); + oia.setInputInhibited(ScreenOIA.INPUTINHIBITED_SYSTEM_WAIT, + ScreenOIA.OIA_LEVEL_INPUT_ERROR, s); + sessionVT.signalBell(); + } + else { + oia.setInputInhibited(ScreenOIA.INPUTINHIBITED_NOTINHIBITED, + ScreenOIA.OIA_LEVEL_NOT_INHIBITED); + setPrehelpState(false, true, true); + homePos = saveHomePos; + saveHomePos = 0; + pendingInsert = false; + } + + break; } } protected boolean isStatusErrorCode() { - return oia.getLevel() == ScreenOIA.OIA_LEVEL_INPUT_ERROR; - } /** @@ -3757,10 +3746,8 @@ * clears/initializes the screen character array. */ protected void clearAll() { - lastAttr = 32; lastPos = 0; - clearTable(); clearScreen(); planes.setScreenAttr(0, initAttr); @@ -3771,7 +3758,6 @@ * Clear the fields table */ protected void clearTable() { - oia.setKeyBoardLocked(true); screenFields.clearFFT(); planes.initalizeFieldPlanes(); @@ -3784,11 +3770,11 @@ * */ protected void clearGuiStuff() { - for (int x = 0; x < lenScreen; x++) { - planes.setUseGUI(x,NO_GUI); + planes.setUseGUI(x, NO_GUI); } - dirtyScreen.setBounds(0,lenScreen - 1,0,0); + + dirtyScreen.setBounds(0, lenScreen - 1, 0, 0); } /** @@ -3796,19 +3782,14 @@ * to all the positions on the screen */ protected void clearScreen() { - planes.initalizePlanes(); - - dirtyScreen.setBounds(0,lenScreen - 1,0,0); - + dirtyScreen.setBounds(0, lenScreen - 1, 0, 0); oia.clearScreen(); - } protected void restoreScreen() { - lastAttr = 32; - dirtyScreen.setBounds(0,lenScreen - 1,0,0); + dirtyScreen.setBounds(0, lenScreen - 1, 0, 0); updateDirty(); } @@ -3833,51 +3814,60 @@ 0xd, // light magenta/purple 0x3, // brown 0xf // bright white - }; + }; + for (int r = startRow; r <= endRow; r++) { for (int c = startCol; c <= endCol; c++) { - int p = getPos(r,c); + int p = getPos(r, c); char ch = planes.getChar(p); char co = planes.getCharColor(p); char at = planes.getCharExtended(p); boolean ia = planes.isAttributePlace(p); + if (ch < ' ') ch = ' '; + int bg = vt320color[(co >> 8) & 0x0f] + 1; int fg = vt320color[co & 0x0f] + 1; int ul = at & EXTENDED_5250_UNDERLINE; int nd = at & EXTENDED_5250_NON_DSP; int vt_attr = (fg << VDUBuffer.COLOR_FG_SHIFT) + (bg << VDUBuffer.COLOR_BG_SHIFT); + if (ul > 0) vt_attr |= VDUBuffer.UNDERLINE; + if (ia || (nd > 0)) vt_attr |= VDUBuffer.INVISIBLE; + buffer.putChar(c, r, ch, vt_attr); } } + buffer.redrawPassthru(); - dirtyScreen.setBounds(lenScreen,0,0,0); + dirtyScreen.setBounds(lenScreen, 0, 0, 0); } /** * repaint the dirty part of the screen * */ + private synchronized void fireScreenChanged() { if (dirtyScreen.x > dirtyScreen.y) { - Log.i(TAG," x < y " + dirtyScreen); + Log.i(TAG, " x < y " + dirtyScreen); return; } + fireScreenChanged(getRow(dirtyScreen.x), getCol(dirtyScreen.x), getRow(dirtyScreen.y), getCol(dirtyScreen.y)); - } /** * update the cursor position * */ + private synchronized void fireCursorChanged() { int l = getRow(lastPos); int c = getCol(lastPos); - buffer.setCursorPosition(c,l); + buffer.setCursorPosition(c, l); } /** @@ -3902,21 +3892,23 @@ */ public void repaintScreen() { setCursorOff(); - dirtyScreen.setBounds(0,lenScreen - 1,0,0); + dirtyScreen.setBounds(0, lenScreen - 1, 0, 0); updateDirty(); + // restore statuses that were on the screen before resize if (oia.getLevel() == ScreenOIA.OIA_LEVEL_INPUT_ERROR) { oia.setInputInhibited(ScreenOIA.INPUTINHIBITED_SYSTEM_WAIT, - ScreenOIA.OIA_LEVEL_INPUT_ERROR); + ScreenOIA.OIA_LEVEL_INPUT_ERROR); } if (oia.getLevel() == ScreenOIA.OIA_LEVEL_INPUT_INHIBITED) { oia.setInputInhibited(ScreenOIA.INPUTINHIBITED_SYSTEM_WAIT, - ScreenOIA.OIA_LEVEL_INPUT_INHIBITED); + ScreenOIA.OIA_LEVEL_INPUT_INHIBITED); } if (oia.isMessageWait()) oia.setMessageLightOn(); + setCursorOn(); } diff -r 6a0ad4d384ea -r 77ac18bc1b2f src/org/tn5250j/framework/tn5250/ScreenField.java --- 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 diff -r 6a0ad4d384ea -r 77ac18bc1b2f src/org/tn5250j/framework/tn5250/ScreenFields.java --- a/src/org/tn5250j/framework/tn5250/ScreenFields.java Wed Jun 18 13:00:19 2014 -0700 +++ b/src/org/tn5250j/framework/tn5250/ScreenFields.java Wed Jun 18 13:03:01 2014 -0700 @@ -35,690 +35,651 @@ public class ScreenFields { - private ScreenField[] screenFields; - private ScreenField currentField; - private ScreenField saveCurrent; - private int sizeFields; - private boolean cpfExists; - private int nextField; - private int fieldIds; - private Screen5250 screen; - private boolean masterMDT; - protected boolean currentModified; + private ScreenField[] screenFields; + private ScreenField currentField; + private ScreenField saveCurrent; + private int sizeFields; + private boolean cpfExists; + private int nextField; + private int fieldIds; + private Screen5250 screen; + private boolean masterMDT; + protected boolean currentModified; - public ScreenFields(Screen5250 s) { - - screen = s; - screenFields = new ScreenField[256]; - } + public ScreenFields(Screen5250 s) { + screen = s; + screenFields = new ScreenField[256]; + } - protected void clearFFT() { - - sizeFields = nextField = fieldIds = 0; - cpfExists = false; // clear the cursor progression fields flag - currentField = null; - masterMDT = false; - - } + protected void clearFFT() { + sizeFields = nextField = fieldIds = 0; + cpfExists = false; // clear the cursor progression fields flag + currentField = null; + masterMDT = false; + } - protected boolean existsAtPos(int lastPos) { - - ScreenField sf = null; + protected boolean existsAtPos(int lastPos) { + ScreenField sf = null; - // from 14.6.12 for Start of Field Order 5940 function manual - // examine the format table for an entry that begins at the current - // starting address plus 1. - for (int x = 0;x < sizeFields; x++) { - sf = screenFields[x]; + // from 14.6.12 for Start of Field Order 5940 function manual + // examine the format table for an entry that begins at the current + // starting address plus 1. + for (int x = 0; x < sizeFields; x++) { + sf = screenFields[x]; - if (lastPos == sf.startPos()) { - currentField = sf; - currentModified = false; - return true; - } + if (lastPos == sf.startPos()) { + currentField = sf; + currentModified = false; + return true; + } + } - } - - return false; - } + return false; + } - public boolean isMasterMDT() { - return masterMDT; - } + public boolean isMasterMDT() { + return masterMDT; + } - protected void setMasterMDT() { - masterMDT = true; - } + protected void setMasterMDT() { + masterMDT = true; + } - public boolean isCurrentField() { - return currentField == null; - } + public boolean isCurrentField() { + return currentField == null; + } - public boolean isCurrentFieldFER() { - return currentField.isFER(); - } + public boolean isCurrentFieldFER() { + return currentField.isFER(); + } - public boolean isCurrentFieldDupEnabled() { - return currentField.isDupEnabled(); - } + public boolean isCurrentFieldDupEnabled() { + return currentField.isDupEnabled(); + } - public boolean isCurrentFieldToUpper() { - return currentField.isToUpper(); - } + public boolean isCurrentFieldToUpper() { + return currentField.isToUpper(); + } - public boolean isCurrentFieldBypassField() { - return currentField.isBypassField(); - } + public boolean isCurrentFieldBypassField() { + return currentField.isBypassField(); + } - public boolean isCurrentFieldHighlightedEntry() { - if (currentField != null) - return currentField.isHiglightedEntry(); - else - return false; - } + public boolean isCurrentFieldHighlightedEntry() { + if (currentField != null) + return currentField.isHiglightedEntry(); + else + return false; + } - public boolean isCurrentFieldAutoEnter() { - return currentField.isAutoEnter(); - } + public boolean isCurrentFieldAutoEnter() { + return currentField.isAutoEnter(); + } - public boolean withinCurrentField(int pos) { - return currentField.withinField(pos); - } + public boolean withinCurrentField(int pos) { + return currentField.withinField(pos); + } - public boolean isCurrentFieldContinued() { - return currentField.isContinued(); - } + public boolean isCurrentFieldContinued() { + return currentField.isContinued(); + } - public boolean isCurrentFieldContinuedFirst() { - return currentField.isContinuedFirst(); - } + public boolean isCurrentFieldContinuedFirst() { + return currentField.isContinuedFirst(); + } - public boolean isCurrentFieldContinuedMiddle() { - return currentField.isContinuedMiddle(); - } + public boolean isCurrentFieldContinuedMiddle() { + return currentField.isContinuedMiddle(); + } - public boolean isCurrentFieldContinuedLast() { - return currentField.isContinuedLast(); - } + public boolean isCurrentFieldContinuedLast() { + return currentField.isContinuedLast(); + } - public boolean isCurrentFieldModified() { - return currentModified; - } + public boolean isCurrentFieldModified() { + return currentModified; + } - /** - * This routine is used to check if we can send the Aid key to the host - * - * Taken from Section 16.2.1.2 Enter/Rec Adv Key - * - * In the normal unlocked state, when the workstation operator presses the - * Enter/Rec Adv key: - * - * 1. The 5494 checks for the completion of mandatory-fill, self-check, and - * right-adjust fields when in an active field. (An active field is one in - * which the workstation operator has begun entering data.) If the - * requirements of the field have not been satisfied, an error occurs. - * - * @return - * - */ - public boolean isCanSendAid() { - - // We also have to check if we are still in the field. - if (currentField != null && - (currentField.getAdjustment() > 0 || currentField.isSignedNumeric()) - && currentModified && isInField() - && !currentField.isCanSend()) + /** + * This routine is used to check if we can send the Aid key to the host + * + * Taken from Section 16.2.1.2 Enter/Rec Adv Key + * + * In the normal unlocked state, when the workstation operator presses the + * Enter/Rec Adv key: + * + * 1. The 5494 checks for the completion of mandatory-fill, self-check, and + * right-adjust fields when in an active field. (An active field is one in + * which the workstation operator has begun entering data.) If the + * requirements of the field have not been satisfied, an error occurs. + * + * @return + * + */ + public boolean isCanSendAid() { + // We also have to check if we are still in the field. + if (currentField != null && + (currentField.getAdjustment() > 0 || currentField.isSignedNumeric()) + && currentModified && isInField() + && !currentField.isCanSend()) + return false; + else + return true; + } - return false; - else - return true; - - } + protected void saveCurrentField() { + saveCurrent = currentField; + } - protected void saveCurrentField() { - saveCurrent = currentField; - } - - protected void restoreCurrentField() { - currentField = saveCurrent; - } + protected void restoreCurrentField() { + currentField = saveCurrent; + } - protected void setCurrentField(ScreenField sf) { - currentField = sf; - } + protected void setCurrentField(ScreenField sf) { + currentField = sf; + } - protected void setCurrentFieldMDT() { - currentField.setMDT(); - currentModified = true; - masterMDT = true; - } + protected void setCurrentFieldMDT() { + currentField.setMDT(); + currentModified = true; + masterMDT = true; + } - protected void setCurrentFieldFFWs(int ffw1, int ffw2) { - - masterMDT = currentField.setFFWs(ffw1,ffw2); - - } + protected void setCurrentFieldFFWs(int ffw1, int ffw2) { + masterMDT = currentField.setFFWs(ffw1, ffw2); + } - protected ScreenField setField(int attr, int row, int col, int len, int ffw1, - int ffw2, int fcw1, int fcw2) { - - ScreenField sf = null; - screenFields[nextField] = new ScreenField(screen); - screenFields[nextField].setField(attr,row,col,len,ffw1,ffw2,fcw1,fcw2); - sf = screenFields[nextField++]; - - sizeFields++; - - - // set the field id if it is not a bypass field - // this is used for cursor progression - // changed this because of problems not allocating field id's for - // all fields. kjp 2002/10/21 + protected ScreenField setField(int attr, int row, int col, int len, int ffw1, + int ffw2, int fcw1, int fcw2) { + ScreenField sf = null; + screenFields[nextField] = new ScreenField(screen); + screenFields[nextField].setField(attr, row, col, len, ffw1, ffw2, fcw1, fcw2); + sf = screenFields[nextField++]; + sizeFields++; + // set the field id if it is not a bypass field + // this is used for cursor progression + // changed this because of problems not allocating field id's for + // all fields. kjp 2002/10/21 // if (!sf.isBypassField()) - sf.setFieldId(++fieldIds); + sf.setFieldId(++fieldIds); - // check if the cursor progression field flag should be set. + // check if the cursor progression field flag should be set. // if ((fcw1 & 0x88) == 0x88) - if (fcw1 == 0x88) - cpfExists = true; + if (fcw1 == 0x88) + cpfExists = true; - if (currentField != null) { - currentField.next = sf; - sf.prev = currentField; - } + if (currentField != null) { + currentField.next = sf; + sf.prev = currentField; + } - currentField = sf; + currentField = sf; - // check if the Modified Data Tag was set while creating the field - if (!masterMDT) - masterMDT = currentField.mdt; + // check if the Modified Data Tag was set while creating the field + if (!masterMDT) + masterMDT = currentField.mdt; - currentModified = false; + currentModified = false; + return currentField; + } - return currentField; - - } + public ScreenField getField(int index) { + return screenFields[index]; + } - public ScreenField getField(int index) { + public ScreenField getCurrentField() { + return currentField; + } - return screenFields[index]; - } - - public ScreenField getCurrentField() { - return currentField; - } + public int getCurrentFieldPos() { + return currentField.getCurrentPos(); + } - public int getCurrentFieldPos() { - return currentField.getCurrentPos(); - } + protected int getCurrentFieldShift() { + return currentField.getFieldShift(); + } - protected int getCurrentFieldShift() { - return currentField.getFieldShift(); - } + public String getCurrentFieldText() { + return currentField.getText(); + } - public String getCurrentFieldText() { - - return currentField.getText(); - } + public int getCurrentFieldHighlightedAttr() { + return currentField.getHighlightedAttr(); + } - public int getCurrentFieldHighlightedAttr(){ - return currentField.getHighlightedAttr(); - } - - public int getSize() { + public int getSize() { + return sizeFields; + } - return sizeFields; - } - - public int getFieldCount() { - - return sizeFields; - } + public int getFieldCount() { + return sizeFields; + } - protected boolean isInField(int pos) { - return isInField(pos,true); - } + protected boolean isInField(int pos) { + return isInField(pos, true); + } - protected boolean isInField() { - return isInField(screen.getLastPos(),true); - } + protected boolean isInField() { + return isInField(screen.getLastPos(), true); + } + + protected boolean isInField(int pos, boolean chgToField) { + ScreenField sf; - protected boolean isInField(int pos, boolean chgToField) { - - ScreenField sf; + for (int x = 0; x < sizeFields; x++) { + sf = screenFields[x]; - for (int x = 0;x < sizeFields; x++) { - sf = screenFields[x]; - - if (sf.withinField(pos)) { + if (sf.withinField(pos)) { + if (chgToField) { + if (!currentField.equals(sf)) + currentModified = false; - if (chgToField) { - if (!currentField.equals(sf)) - currentModified = false; - currentField = sf; + currentField = sf; + } + + return true; } - return true; - } - } - return false; + } + + return false; + } - } - - /** - * Searches the collection for the target string and returns the iOhioField - * object containing that string. The string must be totally contained - * within the field to be considered a match. - * - * @param targetString The target string. - * @param startPos The row and column where to start the search. The position - * is inclusive (for example, row 1, col 1 means that - * position 1,1 will be used as the starting location and - * 1,1 will be included in the search). - * @param length The length from startPos to include in the search. - * @param dir An OHIO_DIRECTION value: - * - * - * - * - * - * - * - * - *
Constant ValueDescription
OS_OHIO_DIRECTION_FORWARD 0Forward (beginning towards end)
OS_OHIO_DIRECTION_BACKWARD 1Backward (end towards beginning)
- * Constant Value Description - * ignoreCase - Indicates whether the search is case sensitive. - * True means that case will be ignored. False means the search will - * be case sensitive. - * @return If found, an iOhioField object containing the target string. If - * not found, returns a null. - */ - public ScreenField findByString (String targetString, - int startPos, - int length, - int dir, - boolean ignoreCase) { - - // first lets check if the string exists in the screen space + /** + * Searches the collection for the target string and returns the iOhioField + * object containing that string. The string must be totally contained + * within the field to be considered a match. + * + * @param targetString The target string. + * @param startPos The row and column where to start the search. The position + * is inclusive (for example, row 1, col 1 means that + * position 1,1 will be used as the starting location and + * 1,1 will be included in the search). + * @param length The length from startPos to include in the search. + * @param dir An OHIO_DIRECTION value: + * + * + * + * + * + * + * + * + *
Constant ValueDescription
OS_OHIO_DIRECTION_FORWARD 0Forward (beginning towards end)
OS_OHIO_DIRECTION_BACKWARD 1Backward (end towards beginning)
+ * Constant Value Description + * ignoreCase - Indicates whether the search is case sensitive. + * True means that case will be ignored. False means the search will + * be case sensitive. + * @return If found, an iOhioField object containing the target string. If + * not found, returns a null. + */ + public ScreenField findByString(String targetString, + int startPos, + int length, + int dir, + boolean ignoreCase) { + // first lets check if the string exists in the screen space // iOhioPosition pos = screen.findString(targetString, startPos, length, // dir, ignoreCase); - - // if it does exist then lets search the fields by the position that - // was found and return the results of that search. + // if it does exist then lets search the fields by the position that + // was found and return the results of that search. // if (pos != null) { - return findByPosition(startPos); + return findByPosition(startPos); // } - - //return null; - - } + //return null; + } - /** - * Searches the collection for the target position and returns the ScreenField - * object containing that position. - * - * @param targetPosition The target row and column expressed as a linear - * position within the presentation space. - * - * @return If found, a ScreenField object containing the target position. - * If not found, returns a null. - */ - public ScreenField findByPosition(int targetPosition) { + /** + * Searches the collection for the target position and returns the ScreenField + * object containing that position. + * + * @param targetPosition The target row and column expressed as a linear + * position within the presentation space. + * + * @return If found, a ScreenField object containing the target position. + * If not found, returns a null. + */ + public ScreenField findByPosition(int targetPosition) { + ScreenField sf = null; - ScreenField sf = null; - - for (int x = 0;x < sizeFields; x++) { - - sf = screenFields[x]; + for (int x = 0; x < sizeFields; x++) { + sf = screenFields[x]; - if (sf.withinField(targetPosition)) { - return sf; - } + if (sf.withinField(targetPosition)) { + return sf; + } + } - } - - return null; - } + return null; + } - /** - * Searches the collection for the target position and returns the ScreenField - * object containing that position. - * - * @param row The beginning row to start search with in the presentation space. - * @param col The beginning column to start search with in the presentation space. - * - * @return If found, a ScreenField object containing the target position. - * If not found, returns a null. - */ - public ScreenField findByPosition(int row, int col) { + /** + * Searches the collection for the target position and returns the ScreenField + * object containing that position. + * + * @param row The beginning row to start search with in the presentation space. + * @param col The beginning column to start search with in the presentation space. + * + * @return If found, a ScreenField object containing the target position. + * If not found, returns a null. + */ + public ScreenField findByPosition(int row, int col) { + return findByPosition(screen.getPos(row, col)); + } - return findByPosition(screen.getPos(row,col)); - } - - public ScreenField[] getFields () { + public ScreenField[] getFields() { + ScreenField[] fields = new ScreenField[sizeFields]; - ScreenField[] fields = new ScreenField[sizeFields]; - for (int x = 0; x < sizeFields; x++) { + for (int x = 0; x < sizeFields; x++) { + fields[x] = screenFields[x]; + } - fields[x] = screenFields[x]; - } - - return fields; - } + return fields; + } - public ScreenField getFirstInputField() { - - if (sizeFields <= 0) - return null; + public ScreenField getFirstInputField() { + if (sizeFields <= 0) + return null; - int f = 0; - ScreenField sf = screenFields[f]; + int f = 0; + ScreenField sf = screenFields[f]; - while (sf.isBypassField() && f++ < sizeFields) { - sf = screenFields[f]; - } + while (sf.isBypassField() && f++ < sizeFields) { + sf = screenFields[f]; + } - if (sf.isBypassField()) - return null; - else - return sf; - - } + if (sf.isBypassField()) + return null; + else + return sf; + } - public void gotoFieldNext() { - - // sanity check - we were getting null pointers after a restore of screen - // and cursor was not positioned on a field when returned - // *** Note *** to myself - // maybe this is fixed I will have to check this some time - int lastPos = screen.getLastPos(); + public void gotoFieldNext() { + // sanity check - we were getting null pointers after a restore of screen + // and cursor was not positioned on a field when returned + // *** Note *** to myself + // maybe this is fixed I will have to check this some time + int lastPos = screen.getLastPos(); - if (currentField == null && (sizeFields != 0) && !isInField(lastPos,true)) { - int pos = lastPos; - screen.setCursorOff(); - screen.advancePos(); - lastPos = screen.getLastPos(); - while (!isInField() && pos != lastPos) { + if (currentField == null && (sizeFields != 0) && !isInField(lastPos, true)) { + int pos = lastPos; + screen.setCursorOff(); screen.advancePos(); - } - screen.setCursorOn(); - } + lastPos = screen.getLastPos(); - // if we are still null do nothing - if (currentField == null) - return; + while (!isInField() && pos != lastPos) { + screen.advancePos(); + } - ScreenField sf = currentField; + screen.setCursorOn(); + } - if (!sf.withinField(lastPos)) { - screen.setCursorOff(); + // if we are still null do nothing + if (currentField == null) + return; - if (sizeFields > 0) { + ScreenField sf = currentField; - // lets get the current position so we can test if we have looped - // the screen and not found a valid field. - int pos = lastPos; - int savPos = lastPos; - boolean done = false; - do { - screen.advancePos(); - lastPos = screen.getLastPos(); - if (isInField(lastPos) - || pos==lastPos) { - if (!currentField.isBypassField()) { - screen.gotoField(currentField); - done = true; - } - } - } while ( !done && lastPos != savPos); - } - currentModified = false; - screen.setCursorOn(); + if (!sf.withinField(lastPos)) { + screen.setCursorOff(); + + if (sizeFields > 0) { + // lets get the current position so we can test if we have looped + // the screen and not found a valid field. + int pos = lastPos; + int savPos = lastPos; + boolean done = false; + + do { + screen.advancePos(); + lastPos = screen.getLastPos(); - } - else { - if (!cpfExists) { - do { - - sf = sf.next; + if (isInField(lastPos) + || pos == lastPos) { + if (!currentField.isBypassField()) { + screen.gotoField(currentField); + done = true; + } + } + } + while (!done && lastPos != savPos); } - while ( sf != null && sf.isBypassField()); - } - else { - int f = 0; - int cp = sf.getCursorProgression(); - - if (cp == 0) { - do { - - sf = sf.next; - } - while ( sf != null && sf.isBypassField()); - + currentModified = false; + screen.setCursorOn(); + } + else { + if (!cpfExists) { + do { + sf = sf.next; + } + while (sf != null && sf.isBypassField()); } else { - ScreenField sf1 = null; - boolean found = false; - while (!found && f < sizeFields) { + int f = 0; + int cp = sf.getCursorProgression(); - sf1 = screenFields[f++]; - if (sf1.getFieldId() == cp) - found = true; - } - if (found) - sf = sf1; - else { - do { - sf = sf.next; - } - while ( sf != null && sf.isBypassField()); + if (cp == 0) { + do { + sf = sf.next; + } + while (sf != null && sf.isBypassField()); + } + else { + ScreenField sf1 = null; + boolean found = false; + + while (!found && f < sizeFields) { + sf1 = screenFields[f++]; - } - sf1 = null; + if (sf1.getFieldId() == cp) + found = true; + } + + if (found) + sf = sf1; + else { + do { + sf = sf.next; + } + while (sf != null && sf.isBypassField()); + } + + sf1 = null; + } } - } - if (sf == null) - screen.gotoField(1); - else { - currentField = sf; - screen.gotoField(currentField); - } - - currentModified = false; - - } - } - - public void gotoFieldPrev() { - - ScreenField sf = currentField; - int lastPos = screen.getLastPos(); - if (!sf.withinField(lastPos)) { - screen.setCursorOff(); + if (sf == null) + screen.gotoField(1); + else { + currentField = sf; + screen.gotoField(currentField); + } - if (sizeFields > 0) { - // lets get the current position so we can test if we have looped - // the screen and not found a valid field. - int pos = lastPos; - int savPos = lastPos; - boolean done = false; + currentModified = false; + } + } - do { - screen.changePos(-1); - lastPos = screen.getLastPos(); + public void gotoFieldPrev() { + ScreenField sf = currentField; + int lastPos = screen.getLastPos(); - if (isInField(lastPos) - || (pos == lastPos)) { + if (!sf.withinField(lastPos)) { + screen.setCursorOff(); - if (!currentField.isBypassField()) { - screen.gotoField(currentField); - done = true; - } - } - } while ( !done && lastPos != savPos); - } - screen.setCursorOn(); + if (sizeFields > 0) { + // lets get the current position so we can test if we have looped + // the screen and not found a valid field. + int pos = lastPos; + int savPos = lastPos; + boolean done = false; + + do { + screen.changePos(-1); + lastPos = screen.getLastPos(); - } - else { - - if (sf.startPos() == lastPos) { - if (!cpfExists) { - - do { - sf = sf.prev; - } - while ( sf != null && sf.isBypassField()); + if (isInField(lastPos) + || (pos == lastPos)) { + if (!currentField.isBypassField()) { + screen.gotoField(currentField); + done = true; + } + } + } + while (!done && lastPos != savPos); } - else { - int f = 0; - int cp = sf.getFieldId(); - ScreenField sf1 = null; - boolean found = false; - while (!found && f < sizeFields) { + screen.setCursorOn(); + } + else { + if (sf.startPos() == lastPos) { + if (!cpfExists) { + do { + sf = sf.prev; + } + while (sf != null && sf.isBypassField()); + } + else { + int f = 0; + int cp = sf.getFieldId(); + ScreenField sf1 = null; + boolean found = false; + + while (!found && f < sizeFields) { + sf1 = screenFields[f++]; - sf1 = screenFields[f++]; - if (sf1.getCursorProgression() == cp) - found = true; - } - if (found) - sf = sf1; - else { - do { - sf = sf.prev; - } - while ( sf != null && sf.isBypassField()); - } - sf1 = null; + if (sf1.getCursorProgression() == cp) + found = true; + } + + if (found) + sf = sf1; + else { + do { + sf = sf.prev; + } + while (sf != null && sf.isBypassField()); + } + + sf1 = null; + } } - } - if (sf == null) { - int size = sizeFields; - sf = screenFields[size - 1]; - - while (sf.isBypassField() && size-- > 0) { - sf = screenFields[size]; - - } - } - currentField = sf; - currentModified = false; - screen.gotoField(currentField); - } - } + if (sf == null) { + int size = sizeFields; + sf = screenFields[size - 1]; - protected void readFormatTable(ByteArrayOutputStream baosp,int readType, ICodePage codePage) { - - ScreenField sf; - boolean isSigned = false; - char c; - - if (masterMDT) { + while (sf.isBypassField() && size-- > 0) { + sf = screenFields[size]; + } + } - StringBuffer sb = new StringBuffer(); - for (int x = 0; x < sizeFields; x++) { - isSigned = false; + currentField = sf; + currentModified = false; + screen.gotoField(currentField); + } + } - sf = screenFields[x]; + protected void readFormatTable(ByteArrayOutputStream baosp, int readType, ICodePage codePage) { + ScreenField sf; + boolean isSigned = false; + char c; - if (sf.mdt || (readType == CMD_READ_INPUT_FIELDS)) { - - sb.setLength(0); - sb.append(sf.getText()); + if (masterMDT) { + StringBuffer sb = new StringBuffer(); - - if (readType == CMD_READ_MDT_FIELDS || - readType == CMD_READ_MDT_IMMEDIATE_ALT) { - int len = sb.length() - 1; + for (int x = 0; x < sizeFields; x++) { + isSigned = false; + sf = screenFields[x]; - // we strip out all '\u0020' and less - while (len >= 0 && -// (sb.charAt(len) <= ' ' || sb.charAt(len) >= '\uff20' )) { - (sb.charAt(len) < ' ' || sb.charAt(len) >= '\uff20')) { + if (sf.mdt || (readType == CMD_READ_INPUT_FIELDS)) { + sb.setLength(0); + sb.append(sf.getText()); + + if (readType == CMD_READ_MDT_FIELDS || + readType == CMD_READ_MDT_IMMEDIATE_ALT) { + int len = sb.length() - 1; - // if we have the dup character and dup is enabled then we - // stop here - if (sb.charAt(len) == 0x1C && sf.isDupEnabled()) - break; + // we strip out all '\u0020' and less + while (len >= 0 && +// (sb.charAt(len) <= ' ' || sb.charAt(len) >= '\uff20' )) { + (sb.charAt(len) < ' ' || sb.charAt(len) >= '\uff20')) { + // if we have the dup character and dup is enabled then we + // stop here + if (sb.charAt(len) == 0x1C && sf.isDupEnabled()) + break; - sb.deleteCharAt(len--); - } - - } + sb.deleteCharAt(len--); + } + } // System.out.println("field " + sf.toString()); // System.out.println(">" + sb.toString() + "<"); // System.out.println(" field is all nulls"); - if (sf.isSignedNumeric() && sb.length() > 0 && sb.charAt(sb.length() - 1) == '-') { - isSigned = true; - sb.setLength(sb.length() - 1); - } + if (sf.isSignedNumeric() && sb.length() > 0 && sb.charAt(sb.length() - 1) == '-') { + isSigned = true; + sb.setLength(sb.length() - 1); + } - int len3 = sb.length(); + int len3 = sb.length(); - if (len3 > 0 || (readType == CMD_READ_MDT_FIELDS || - readType == CMD_READ_MDT_IMMEDIATE_ALT)) { - - if ((readType == CMD_READ_MDT_FIELDS || - readType == CMD_READ_MDT_IMMEDIATE_ALT)) { + if (len3 > 0 || (readType == CMD_READ_MDT_FIELDS || + readType == CMD_READ_MDT_IMMEDIATE_ALT)) { + if ((readType == CMD_READ_MDT_FIELDS || + readType == CMD_READ_MDT_IMMEDIATE_ALT)) { + baosp.write(17); // start of field data - baosp.write(17); // start of field data - if (sf.isSelectionField()) { - baosp.write(screen.getRow(sf.selectionPos)+1); - baosp.write(screen.getCol(sf.selectionPos)+1); - } - else { - baosp.write(sf.startRow()+1); - baosp.write(sf.startCol()+1); - } + if (sf.isSelectionField()) { + baosp.write(screen.getRow(sf.selectionPos) + 1); + baosp.write(screen.getCol(sf.selectionPos) + 1); + } + else { + baosp.write(sf.startRow() + 1); + baosp.write(sf.startCol() + 1); + } + } - } // int len = sb.length(); - if (sf.isSelectionField()) { - baosp.write(0); - baosp.write(sf.selectionIndex + 0x1F); + if (sf.isSelectionField()) { + baosp.write(0); + baosp.write(sf.selectionIndex + 0x1F); + } + else { + for (int k = 0; k < len3; k++) { + c = sb.charAt(k); - } - else { - for (int k = 0; k < len3; k++) { - c = sb.charAt(k); - // here we have to check for special instances of the - // characters in the string field. Attribute bytes - // are encoded with an offset of \uff00 - // This is a hack !!!!!!!!!!! - // See ScreenField object for a description - if (c < ' ' || c >= '\uff20') { + // here we have to check for special instances of the + // characters in the string field. Attribute bytes + // are encoded with an offset of \uff00 + // This is a hack !!!!!!!!!!! + // See ScreenField object for a description + if (c < ' ' || c >= '\uff20') { + // if it is an offset attribute byte we just pass + // it straight on to the output stream + if (c >= '\uff20' && c <= '\uff3f') { + baosp.write(c - '\uff00'); + } + else - // if it is an offset attribute byte we just pass - // it straight on to the output stream - if (c >= '\uff20' && c <= '\uff3f') { - baosp.write(c - '\uff00'); + // check for dup character + if (c == 0x1C) + baosp.write(c); + else + baosp.write(codePage.uni2ebcdic(' ')); + } + else { + if (isSigned && k == len3 - 1) { + baosp.write(0xd0 | (0x0f & c)); + } + else + baosp.write(codePage.uni2ebcdic(c)); + } + } } - else - // check for dup character - if (c == 0x1C) - baosp.write(c); - else - baosp.write(codePage.uni2ebcdic(' ')); - } - else { - if (isSigned && k == len3 - 1) { - baosp.write(0xd0 | (0x0f & c)); - } - else - baosp.write(codePage.uni2ebcdic(c)); - - } - } - } - } + } + } } - } - } - } + } + } } \ No newline at end of file diff -r 6a0ad4d384ea -r 77ac18bc1b2f src/org/tn5250j/framework/tn5250/ScreenOIA.java --- a/src/org/tn5250j/framework/tn5250/ScreenOIA.java Wed Jun 18 13:00:19 2014 -0700 +++ b/src/org/tn5250j/framework/tn5250/ScreenOIA.java Wed Jun 18 13:03:01 2014 -0700 @@ -35,260 +35,248 @@ * * */ -public class ScreenOIA - { - // OIA_LEVEL - public static final int OIA_LEVEL_INPUT_INHIBITED = 1; - public static final int OIA_LEVEL_NOT_INHIBITED = 2; - public static final int OIA_LEVEL_MESSAGE_LIGHT_ON = 3; - public static final int OIA_LEVEL_MESSAGE_LIGHT_OFF = 4; - public static final int OIA_LEVEL_AUDIBLE_BELL = 5; - public static final int OIA_LEVEL_INSERT_MODE = 6; - public static final int OIA_LEVEL_KEYBOARD = 7; - public static final int OIA_LEVEL_CLEAR_SCREEN = 8; - public static final int OIA_LEVEL_SCREEN_SIZE = 9; - public static final int OIA_LEVEL_INPUT_ERROR = 10; - public static final int OIA_LEVEL_KEYS_BUFFERED = 11; - public static final int OIA_LEVEL_SCRIPT = 12; +public class ScreenOIA { + // OIA_LEVEL + public static final int OIA_LEVEL_INPUT_INHIBITED = 1; + public static final int OIA_LEVEL_NOT_INHIBITED = 2; + public static final int OIA_LEVEL_MESSAGE_LIGHT_ON = 3; + public static final int OIA_LEVEL_MESSAGE_LIGHT_OFF = 4; + public static final int OIA_LEVEL_AUDIBLE_BELL = 5; + public static final int OIA_LEVEL_INSERT_MODE = 6; + public static final int OIA_LEVEL_KEYBOARD = 7; + public static final int OIA_LEVEL_CLEAR_SCREEN = 8; + public static final int OIA_LEVEL_SCREEN_SIZE = 9; + public static final int OIA_LEVEL_INPUT_ERROR = 10; + public static final int OIA_LEVEL_KEYS_BUFFERED = 11; + public static final int OIA_LEVEL_SCRIPT = 12; - // INPUTINHIBITED - public static final int INPUTINHIBITED_NOTINHIBITED = 0; - public static final int INPUTINHIBITED_SYSTEM_WAIT = 1; - public static final int INPUTINHIBITED_COMMCHECK = 2; - public static final int INPUTINHIBITED_PROGCHECK = 3; - public static final int INPUTINHIBITED_MACHINECHECK = 4; - public static final int INPUTINHIBITED_OTHER = 5; - - public ScreenOIA (Screen5250 screen) { + // INPUTINHIBITED + public static final int INPUTINHIBITED_NOTINHIBITED = 0; + public static final int INPUTINHIBITED_SYSTEM_WAIT = 1; + public static final int INPUTINHIBITED_COMMCHECK = 2; + public static final int INPUTINHIBITED_PROGCHECK = 3; + public static final int INPUTINHIBITED_MACHINECHECK = 4; + public static final int INPUTINHIBITED_OTHER = 5; - source = screen; - - } + public ScreenOIA(Screen5250 screen) { + source = screen; + } - public boolean isInsertMode() { + public boolean isInsertMode() { + return insertMode; + } - return insertMode; - } - - protected void setInsertMode(boolean mode) { + protected void setInsertMode(boolean mode) { + level = OIA_LEVEL_INSERT_MODE; + insertMode = mode; + fireOIAChanged(ScreenOIAListener.OIA_CHANGED_INSERT_MODE); + } - level = OIA_LEVEL_INSERT_MODE; - insertMode = mode; - fireOIAChanged(ScreenOIAListener.OIA_CHANGED_INSERT_MODE); - } + public int getCommCheckCode() { + return commCheck; + } - public int getCommCheckCode() { - - return commCheck; - } + public int getInputInhibited() { + return inputInhibited; + } - public int getInputInhibited() { - - return inputInhibited; - } + public int getMachineCheckCode() { + return machineCheck; + } - public int getMachineCheckCode() { + public int getOwner() { + return owner; + } - return machineCheck; - } + public int getProgCheckCode() { + return 0; + } - public int getOwner() { - return owner; - } - - public int getProgCheckCode() { - return 0; - } + /** + * Is the keyboard locked or not + * + * @return locked or not + */ + public boolean isKeyBoardLocked() { + return locked; + } - /** - * Is the keyboard locked or not - * - * @return locked or not - */ - public boolean isKeyBoardLocked() { - return locked; - } + public boolean isKeysBuffered() { + return keysBuffered; + } - public boolean isKeysBuffered() { - return keysBuffered; - } + public void setKeysBuffered(boolean kb) { + level = OIA_LEVEL_KEYS_BUFFERED; + boolean oldKB = keysBuffered; + keysBuffered = kb; + + if (keysBuffered != oldKB) + fireOIAChanged(ScreenOIAListener.OIA_CHANGED_KEYS_BUFFERED); + } - public void setKeysBuffered(boolean kb) { - level = OIA_LEVEL_KEYS_BUFFERED; - boolean oldKB = keysBuffered; - keysBuffered = kb; - if (keysBuffered != oldKB) - fireOIAChanged(ScreenOIAListener.OIA_CHANGED_KEYS_BUFFERED); - } + protected void setKeyBoardLocked(boolean lockIt) { + level = OIA_LEVEL_KEYBOARD; + boolean oldLocked = locked; + locked = lockIt; - protected void setKeyBoardLocked(boolean lockIt) { - level = OIA_LEVEL_KEYBOARD; - boolean oldLocked = locked; - locked = lockIt; - if (!lockIt) { + if (!lockIt) { + if (isKeysBuffered()) { + source.sendKeys(""); + } + } - if (isKeysBuffered()) { - source.sendKeys(""); - } - } + if (locked != oldLocked) + fireOIAChanged(ScreenOIAListener.OIA_CHANGED_KEYBOARD_LOCKED); + } + + public boolean isMessageWait() { + return messageWait; + } - if (locked != oldLocked) - fireOIAChanged(ScreenOIAListener.OIA_CHANGED_KEYBOARD_LOCKED); - } - - public boolean isMessageWait() { - return messageWait; - } + protected void setMessageLightOn() { + level = OIA_LEVEL_MESSAGE_LIGHT_ON; + messageWait = true; + fireOIAChanged(ScreenOIAListener.OIA_CHANGED_MESSAGELIGHT); + } - protected void setMessageLightOn() { - level = OIA_LEVEL_MESSAGE_LIGHT_ON; - messageWait = true; - fireOIAChanged(ScreenOIAListener.OIA_CHANGED_MESSAGELIGHT); - } + protected void setMessageLightOff() { + level = OIA_LEVEL_MESSAGE_LIGHT_OFF; + messageWait = false; + fireOIAChanged(ScreenOIAListener.OIA_CHANGED_MESSAGELIGHT); + } - protected void setMessageLightOff() { - level = OIA_LEVEL_MESSAGE_LIGHT_OFF; - messageWait = false; - fireOIAChanged(ScreenOIAListener.OIA_CHANGED_MESSAGELIGHT); - } + public void setScriptActive(boolean running) { + level = OIA_LEVEL_SCRIPT; + scriptRunning = running; + fireOIAChanged(ScreenOIAListener.OIA_CHANGED_SCRIPT); + } - public void setScriptActive(boolean running) { - level = OIA_LEVEL_SCRIPT; - scriptRunning = running; - fireOIAChanged(ScreenOIAListener.OIA_CHANGED_SCRIPT); - } + public boolean isScriptActive() { + return scriptRunning; + } - public boolean isScriptActive() { - return scriptRunning; - } + public void setAudibleBell() { + level = OIA_LEVEL_AUDIBLE_BELL; + fireOIAChanged(ScreenOIAListener.OIA_CHANGED_BELL); + } - public void setAudibleBell() { - level = OIA_LEVEL_AUDIBLE_BELL; - fireOIAChanged(ScreenOIAListener.OIA_CHANGED_BELL); - } + protected void clearScreen() { + level = OIA_LEVEL_CLEAR_SCREEN; + fireOIAChanged(ScreenOIAListener.OIA_CHANGED_CLEAR_SCREEN); + } - protected void clearScreen() { - level = OIA_LEVEL_CLEAR_SCREEN; - fireOIAChanged(ScreenOIAListener.OIA_CHANGED_CLEAR_SCREEN); - } - - /** - * Add a ScreenOIAListener to the listener list. - * - * @param listener The ScreenOIAListener to be added - */ - public void addOIAListener(ScreenOIAListener listener) { + /** + * Add a ScreenOIAListener to the listener list. + * + * @param listener The ScreenOIAListener to be added + */ + public void addOIAListener(ScreenOIAListener listener) { + if (listeners == null) { + listeners = new java.util.Vector(3); + } - if (listeners == null) { - listeners = new java.util.Vector(3); - } - listeners.addElement(listener); - - } + listeners.addElement(listener); + } - /** - * Remove a iOhioSessionListener from the listener list. - * - * @param listener The iOhioSessionListener to be removed - */ - public void removeOIAListener(ScreenOIAListener listener) { + /** + * Remove a iOhioSessionListener from the listener list. + * + * @param listener The iOhioSessionListener to be removed + */ + public void removeOIAListener(ScreenOIAListener listener) { + if (listeners == null) { + return; + } - if (listeners == null) { - return; - } - listeners.removeElement(listener); - } + listeners.removeElement(listener); + } - // object methods - public Screen5250 getSource() { - - return source; - } + // object methods + public Screen5250 getSource() { + return source; + } - public void setSource(Screen5250 screen) { - - source = screen; - - } + public void setSource(Screen5250 screen) { + source = screen; + } - public void setOwner(int newOwner) { - - owner = newOwner; + public void setOwner(int newOwner) { + owner = newOwner; + } - } - - public int getLevel() { + public int getLevel() { + return level; + } - return level; - } - - public String getInhibitedText() { - return inhibitedText; - } + public String getInhibitedText() { + return inhibitedText; + } - public void setInputInhibited(int inhibit , int whatCode) { - setInputInhibited(inhibit, whatCode, null); - } + public void setInputInhibited(int inhibit , int whatCode) { + setInputInhibited(inhibit, whatCode, null); + } - public void setInputInhibited(int inhibit , int whatCode, String message) { - - inputInhibited = inhibit; - level = OIA_LEVEL_INPUT_INHIBITED; - inhibitedText = message; + public void setInputInhibited(int inhibit , int whatCode, String message) { + inputInhibited = inhibit; + level = OIA_LEVEL_INPUT_INHIBITED; + inhibitedText = message; // if (saveInhibit != inhibit || saveInhibitLevel != whatCode) { - switch(inhibit) { - + switch (inhibit) { case INPUTINHIBITED_COMMCHECK : - commCheck = whatCode; - break; + commCheck = whatCode; + break; + case INPUTINHIBITED_PROGCHECK : // progCheck = whatCode; // never used - break; + break; + case INPUTINHIBITED_MACHINECHECK : - machineCheck = whatCode; - break; + machineCheck = whatCode; + break; + case INPUTINHIBITED_SYSTEM_WAIT : - level = whatCode; - break; + level = whatCode; + break; + case INPUTINHIBITED_NOTINHIBITED : - level = whatCode; - break; - } + level = whatCode; + break; + } - fireOIAChanged(ScreenOIAListener.OIA_CHANGED_INPUTINHIBITED); + fireOIAChanged(ScreenOIAListener.OIA_CHANGED_INPUTINHIBITED); // } - } - - /** - * Notify all registered listeners of the onOIAChanged event. - * - */ - private void fireOIAChanged(int change) { + } - if (listeners != null) { - int size = listeners.size(); - for (int i = 0; i < size; i++) { - ScreenOIAListener target = - listeners.elementAt(i); - target.onOIAChanged(this, change); - } - } - } + /** + * Notify all registered listeners of the onOIAChanged event. + * + */ + private void fireOIAChanged(int change) { + if (listeners != null) { + int size = listeners.size(); - private Vector listeners = null; - private boolean insertMode; - private boolean locked; - private boolean keysBuffered; - private int owner = 0; - private int level = 0; - private Screen5250 source = null; - private int commCheck = 0; - private int machineCheck = 0; - private boolean messageWait; - private boolean scriptRunning; - private int inputInhibited = INPUTINHIBITED_NOTINHIBITED; - private String inhibitedText; + for (int i = 0; i < size; i++) { + ScreenOIAListener target = + listeners.elementAt(i); + target.onOIAChanged(this, change); + } + } + } + + private Vector listeners = null; + private boolean insertMode; + private boolean locked; + private boolean keysBuffered; + private int owner = 0; + private int level = 0; + private Screen5250 source = null; + private int commCheck = 0; + private int machineCheck = 0; + private boolean messageWait; + private boolean scriptRunning; + private int inputInhibited = INPUTINHIBITED_NOTINHIBITED; + private String inhibitedText; } diff -r 6a0ad4d384ea -r 77ac18bc1b2f src/org/tn5250j/framework/tn5250/ScreenPlanes.java --- a/src/org/tn5250j/framework/tn5250/ScreenPlanes.java Wed Jun 18 13:00:19 2014 -0700 +++ b/src/org/tn5250j/framework/tn5250/ScreenPlanes.java Wed Jun 18 13:03:01 2014 -0700 @@ -31,794 +31,775 @@ public class ScreenPlanes { - private final Screen5250 scr; - private int screenSize; - private int numRows; - private int numCols; - private int errorLineNum; + private final Screen5250 scr; + private int screenSize; + private int numRows; + private int numCols; + private int errorLineNum; - private static final int initAttr = 32; - private static final char initChar = 0; + private static final int initAttr = 32; + private static final char initChar = 0; - protected char[] screen; // text plane - private char[] screenAttr; // attribute plane - private char[] screenGUI; // gui plane - private char[] screenIsAttr; - private char[] fieldExtended; - private char[] screenField; - private char[] screenColor; // color plane - protected char[] screenExtended; // extended plane - private char[] screenIsChanged; + protected char[] screen; // text plane + private char[] screenAttr; // attribute plane + private char[] screenGUI; // gui plane + private char[] screenIsAttr; + private char[] fieldExtended; + private char[] screenField; + private char[] screenColor; // color plane + protected char[] screenExtended; // extended plane + private char[] screenIsChanged; - private char[] initArray; + private char[] initArray; - private char[] errorLine; - private char[] errorLineAttr; - private char[] errorLineIsAttr; - private char[] errorLineGui; - - public ScreenPlanes(Screen5250 s5250, int size) { + private char[] errorLine; + private char[] errorLineAttr; + private char[] errorLineIsAttr; + private char[] errorLineGui; - scr = s5250; - setSize(size); - } - - protected void setSize(int newSize) { - - screenSize = newSize; + public ScreenPlanes(Screen5250 s5250, int size) { + scr = s5250; + setSize(size); + } - numCols = 80; - switch (newSize) { - case 24: - numRows = 24; - break; - case 27: - numRows = 27; - numCols = 132; - break; + protected void setSize(int newSize) { + screenSize = newSize; + numCols = 80; - } + switch (newSize) { + case 24: + numRows = 24; + break; - // this is used here when size changes - setErrorLine(numRows); + case 27: + numRows = 27; + numCols = 132; + break; + } - screenSize = numRows * numCols; - screen = new char[screenSize]; - screenAttr = new char[screenSize]; - screenIsAttr = new char[screenSize]; - screenGUI = new char[screenSize]; - screenColor = new char[screenSize]; - screenExtended = new char[screenSize]; - fieldExtended = new char[screenSize]; - screenIsChanged = new char[screenSize]; - screenField = new char[screenSize]; - - initArray = new char[screenSize]; + // this is used here when size changes + setErrorLine(numRows); + screenSize = numRows * numCols; + screen = new char[screenSize]; + screenAttr = new char[screenSize]; + screenIsAttr = new char[screenSize]; + screenGUI = new char[screenSize]; + screenColor = new char[screenSize]; + screenExtended = new char[screenSize]; + fieldExtended = new char[screenSize]; + screenIsChanged = new char[screenSize]; + screenField = new char[screenSize]; + initArray = new char[screenSize]; + initalizePlanes(); + } - initalizePlanes(); - } - - protected void setErrorLine (int line) { - - // * NOTE * for developers I have changed the send qry to pass different - // parameters to the host so check setsize for setting error line as well. - // - if (line == 0 || line > numRows) - errorLineNum = numRows; - else - errorLineNum = line; - } + protected void setErrorLine(int line) { + // * NOTE * for developers I have changed the send qry to pass different + // parameters to the host so check setsize for setting error line as well. + // + if (line == 0 || line > numRows) + errorLineNum = numRows; + else + errorLineNum = line; + } - /** - * Returns the current error line number - * - * @return current error line number - */ - protected int getErrorLine() { - return errorLineNum; - } - - protected void saveErrorLine() { - - // if there is already an error line saved then do not save it again - // This signifies that there was a previous error and the original error - // line was not restored yet. - if (errorLine == null) { - errorLine = new char[numCols]; - errorLineAttr = new char[numCols]; - errorLineIsAttr = new char[numCols]; - errorLineGui = new char[numCols]; + /** + * Returns the current error line number + * + * @return current error line number + */ + protected int getErrorLine() { + return errorLineNum; + } - int r = scr.getPos(errorLineNum-1,0); + protected void saveErrorLine() { + // if there is already an error line saved then do not save it again + // This signifies that there was a previous error and the original error + // line was not restored yet. + if (errorLine == null) { + errorLine = new char[numCols]; + errorLineAttr = new char[numCols]; + errorLineIsAttr = new char[numCols]; + errorLineGui = new char[numCols]; + int r = scr.getPos(errorLineNum - 1, 0); - for (int x = 0;x < numCols; x++) { - errorLine[x] = screen[r+x]; - errorLineAttr[x] = screenAttr[r+x]; - errorLineIsAttr[x] = screenIsAttr[r+x]; - errorLineGui[x] = screenGUI[r+x]; - } - } - } + for (int x = 0; x < numCols; x++) { + errorLine[x] = screen[r + x]; + errorLineAttr[x] = screenAttr[r + x]; + errorLineIsAttr[x] = screenIsAttr[r + x]; + errorLineGui[x] = screenGUI[r + x]; + } + } + } - /** - * Restores the error line characters from the save buffer. - * - * @see #saveErrorLine() - */ - protected void restoreErrorLine() { - - if (errorLine != null) { - int r = scr.getPos(errorLineNum - 1, 0); + /** + * Restores the error line characters from the save buffer. + * + * @see #saveErrorLine() + */ + protected void restoreErrorLine() { + if (errorLine != null) { + int r = scr.getPos(errorLineNum - 1, 0); - for (int x = 0; x < numCols - 1; x++) { - setScreenCharAndAttr(r+x,errorLine[x],errorLineAttr[x], - (errorLineIsAttr[x] == '1' ? true : false)); - screenGUI[x] = errorLineGui[x]; - } - - errorLine = null; - errorLineAttr = null; - errorLineIsAttr = null; - errorLineGui = null; - } - } + for (int x = 0; x < numCols - 1; x++) { + setScreenCharAndAttr(r + x, errorLine[x], errorLineAttr[x], + (errorLineIsAttr[x] == '1' ? true : false)); + screenGUI[x] = errorLineGui[x]; + } - protected boolean isErrorLineSaved() { - return errorLine == null ? false : true; - } - - protected void setScreenCharAndAttr(int pos, char c, int attr, boolean isAttr) { + errorLine = null; + errorLineAttr = null; + errorLineIsAttr = null; + errorLineGui = null; + } + } - screen[pos] = c; - screenAttr[pos] = (char)attr; - disperseAttribute(pos,attr); - screenIsAttr[pos] = (isAttr ? (char)1 : (char)0); - screenGUI[pos] = NO_GUI; + protected boolean isErrorLineSaved() { + return errorLine == null ? false : true; + } - } - - protected void setScreenAttr(int pos, int attr, boolean isAttr) { + protected void setScreenCharAndAttr(int pos, char c, int attr, boolean isAttr) { + screen[pos] = c; + screenAttr[pos] = (char)attr; + disperseAttribute(pos, attr); + screenIsAttr[pos] = (isAttr ? (char)1 : (char)0); + screenGUI[pos] = NO_GUI; + } - screenAttr[pos] = (char)attr; - screenIsAttr[pos] = isAttr ? (char)1 : (char)0; - disperseAttribute(pos,attr); - screenGUI[pos] = initChar; + protected void setScreenAttr(int pos, int attr, boolean isAttr) { + screenAttr[pos] = (char)attr; + screenIsAttr[pos] = isAttr ? (char)1 : (char)0; + disperseAttribute(pos, attr); + screenGUI[pos] = initChar; + } - } - - protected void setScreenAttr(int pos, int attr) { - - screenAttr[pos] = (char)attr; - //screenGUI[pos] = initChar; - disperseAttribute(pos,attr); + protected void setScreenAttr(int pos, int attr) { + screenAttr[pos] = (char)attr; + //screenGUI[pos] = initChar; + disperseAttribute(pos, attr); + } - } - - protected void setScreenFieldAttr(int pos, int attr) { + protected void setScreenFieldAttr(int pos, int attr) { + screenField[pos] = (char)attr; + } - screenField[pos] = (char)attr; - - } + protected final void setChar(int pos, char c) { + screenIsChanged[pos] = screen[pos] == c ? '0' : '1'; + screen[pos] = c; - protected final void setChar(int pos, char c) { - screenIsChanged[pos] = screen[pos] == c ? '0' : '1'; - screen[pos] = c; - if (screenIsAttr[pos] == 1) - setScreenCharAndAttr(pos,c,32,false); + if (screenIsAttr[pos] == 1) + setScreenCharAndAttr(pos, c, 32, false); + } - } + protected final char getChar(int pos) { + return screen[pos]; + } + + protected final char getCharColor(int pos) { + return screenColor[pos]; + } - protected final char getChar(int pos) { - return screen[pos]; - } + protected final int getCharAttr(int pos) { + return screenAttr[pos]; + } - protected final char getCharColor(int pos) { - return screenColor[pos]; - } + protected final char getCharExtended(int pos) { + return screenExtended[pos]; + } - protected final int getCharAttr(int pos) { - return screenAttr[pos]; - } + protected final boolean isAttributePlace(int pos) { + return screenIsAttr[pos] == 1 ? true : false; + } - protected final char getCharExtended(int pos) { - return screenExtended[pos]; - } - - protected final boolean isAttributePlace(int pos) { - return screenIsAttr[pos] == 1 ? true : false; - } + public final void setUseGUI(int pos, int which) { + screenIsChanged[pos] = screenGUI[pos] == which ? '0' : '1'; + screenGUI[pos] = (char)which; + } - public final void setUseGUI(int pos, int which) { + private void disperseAttribute(int pos, int attr) { + char c = 0; + char cs = 0; + char ul = 0; + char nd = 0; - screenIsChanged[pos] = screenGUI[pos] == which ? '0' : '1'; - screenGUI[pos] = (char)which; - } + if (attr == 0) + return; - private void disperseAttribute(int pos, int attr) { + switch (attr) { + case 32: // green normal + c = ATTR_32; + break; - char c = 0; - char cs = 0; - char ul = 0; - char nd = 0; - - if(attr == 0) - return; + case 33: // green/revers + c = ATTR_33; + break; - switch(attr) { - case 32: // green normal - c = ATTR_32; - break; + case 34: // white normal + c = ATTR_34; + break; - case 33: // green/revers - c = ATTR_33; - break; + case 35: // white/reverse + c = ATTR_35; + break; - case 34: // white normal - c = ATTR_34; - break; - - case 35: // white/reverse - c = ATTR_35; - break; + case 36: // green/underline + c = ATTR_36; + ul = EXTENDED_5250_UNDERLINE; + break; - case 36: // green/underline - c = ATTR_36; - ul = EXTENDED_5250_UNDERLINE; - break; + case 37: // green/reverse/underline + c = ATTR_37; + ul = EXTENDED_5250_UNDERLINE; + break; - case 37: // green/reverse/underline - c = ATTR_37; - ul = EXTENDED_5250_UNDERLINE; - break; + case 38: // white/underline + c = ATTR_38; + ul = EXTENDED_5250_UNDERLINE; + break; + + case 39: + nd = EXTENDED_5250_NON_DSP; + break; - case 38: // white/underline - c = ATTR_38; - ul = EXTENDED_5250_UNDERLINE; - break; + case 40: + case 42: // red/normal + c = ATTR_40; + break; - case 39: - nd = EXTENDED_5250_NON_DSP; - break; - - case 40: - case 42: // red/normal - c = ATTR_40; - break; + case 41: + case 43: // red/reverse + c = ATTR_41; + break; - case 41: - case 43: // red/reverse - c = ATTR_41; - break; + case 44: + case 46: // red/underline + c = ATTR_44; + ul = EXTENDED_5250_UNDERLINE; + break; - case 44: - case 46: // red/underline - c = ATTR_44; - ul = EXTENDED_5250_UNDERLINE; - break; + case 45: // red/reverse/underline + c = ATTR_45; + ul = EXTENDED_5250_UNDERLINE; + break; - case 45: // red/reverse/underline - c = ATTR_45; - ul = EXTENDED_5250_UNDERLINE; - break; + case 47: + nd = EXTENDED_5250_NON_DSP; + break; - case 47: - nd = EXTENDED_5250_NON_DSP; - break; + case 48: + c = ATTR_48; + cs = EXTENDED_5250_COL_SEP; + break; - case 48: - c = ATTR_48; - cs = EXTENDED_5250_COL_SEP; - break; - - case 49: - c = ATTR_49; - cs = EXTENDED_5250_COL_SEP; - break; + case 49: + c = ATTR_49; + cs = EXTENDED_5250_COL_SEP; + break; - case 50: - c = ATTR_50; - cs = EXTENDED_5250_COL_SEP; - break; + case 50: + c = ATTR_50; + cs = EXTENDED_5250_COL_SEP; + break; - case 51: - c = ATTR_51; - cs = EXTENDED_5250_COL_SEP; - break; + case 51: + c = ATTR_51; + cs = EXTENDED_5250_COL_SEP; + break; - case 52: - c = ATTR_52; - // colSep = true; - ul = EXTENDED_5250_UNDERLINE; - break; + case 52: + c = ATTR_52; + // colSep = true; + ul = EXTENDED_5250_UNDERLINE; + break; - case 53: - c = ATTR_53; - // colSep = true; - ul = EXTENDED_5250_UNDERLINE; - break; + case 53: + c = ATTR_53; + // colSep = true; + ul = EXTENDED_5250_UNDERLINE; + break; - case 54: - c = ATTR_54; - // colSep = true; - ul = EXTENDED_5250_UNDERLINE; - break; + case 54: + c = ATTR_54; + // colSep = true; + ul = EXTENDED_5250_UNDERLINE; + break; - case 55: - nd = EXTENDED_5250_NON_DSP; - break; + case 55: + nd = EXTENDED_5250_NON_DSP; + break; - case 56: // pink - c = ATTR_56; - break; + case 56: // pink + c = ATTR_56; + break; - case 57: // pink/reverse - c = ATTR_57; - break; + case 57: // pink/reverse + c = ATTR_57; + break; - case 58: // blue/reverse - c = ATTR_58; - break; + case 58: // blue/reverse + c = ATTR_58; + break; - case 59: // blue - c = ATTR_59; - break; + case 59: // blue + c = ATTR_59; + break; - case 60: // pink/underline - c = ATTR_60; - ul = EXTENDED_5250_UNDERLINE; - break; + case 60: // pink/underline + c = ATTR_60; + ul = EXTENDED_5250_UNDERLINE; + break; - case 61: // pink/reverse/underline - c = ATTR_61; - ul = EXTENDED_5250_UNDERLINE; - break; + case 61: // pink/reverse/underline + c = ATTR_61; + ul = EXTENDED_5250_UNDERLINE; + break; - case 62: // blue/underline - c = ATTR_62; - ul = EXTENDED_5250_UNDERLINE; - break; + case 62: // blue/underline + c = ATTR_62; + ul = EXTENDED_5250_UNDERLINE; + break; + + case 63: // nondisplay + nd = EXTENDED_5250_NON_DSP; + cs = EXTENDED_5250_COL_SEP; + break; - case 63: // nondisplay - nd = EXTENDED_5250_NON_DSP; - cs = EXTENDED_5250_COL_SEP; - break; - default: - c = ( COLOR_BG_BLACK << 8 & 0xff00) | - ( COLOR_FG_YELLOW & 0xff); - break; + default: + c = (COLOR_BG_BLACK << 8 & 0xff00) | + (COLOR_FG_YELLOW & 0xff); + break; + } - } - - screenColor[pos] = c; - screenExtended[pos] = (char)(ul | cs | nd); - } + screenColor[pos] = c; + screenExtended[pos] = (char)(ul | cs | nd); + } - protected void initalizePlanes () { - - char c = (COLOR_BG_BLACK << 8 & 0xff00) | - (COLOR_FG_GREEN & 0xff); + protected void initalizePlanes() { + char c = (COLOR_BG_BLACK << 8 & 0xff00) | + (COLOR_FG_GREEN & 0xff); - for (int y = 0;y < screenSize; y++) { - - screenAttr[y] = initAttr; - screenColor[y] = c; + for (int y = 0; y < screenSize; y++) { + screenAttr[y] = initAttr; + screenColor[y] = c; + } - } - - // here we will just copy the initialized plane onto the other planes - // using arraycopy which will be faster. I hope. + // here we will just copy the initialized plane onto the other planes + // using arraycopy which will be faster. I hope. + System.arraycopy(initArray, 0, screen, 0, screenSize); + System.arraycopy(initArray, 0, screenGUI, 0, screenSize); + System.arraycopy(initArray, 0, screenIsAttr, 0, screenSize); + System.arraycopy(initArray, 0, screenExtended, 0, screenSize); + System.arraycopy(initArray, 0, fieldExtended, 0, screenSize); + System.arraycopy(initArray, 0, screenField, 0, screenSize); + } - System.arraycopy(initArray,0,screen,0,screenSize); - System.arraycopy(initArray,0,screenGUI,0,screenSize); - System.arraycopy(initArray,0,screenIsAttr,0,screenSize); - System.arraycopy(initArray,0,screenExtended,0,screenSize); - System.arraycopy(initArray,0,fieldExtended,0,screenSize); - System.arraycopy(initArray,0,screenField,0,screenSize); - } + protected void initalizeFieldPlanes() { + System.arraycopy(initArray, 0, fieldExtended, 0, screenSize); + System.arraycopy(initArray, 0, screenField, 0, screenSize); + } + + protected final int getWhichGUI(int pos) { + return screenGUI[pos]; + } - protected void initalizeFieldPlanes () { - System.arraycopy(initArray,0,fieldExtended,0,screenSize); - System.arraycopy(initArray,0,screenField,0,screenSize); - } - - protected final int getWhichGUI(int pos) { + protected final boolean isChanged(int pos) { + return screenIsChanged[pos] == 0 ? false : true; + } - return screenGUI[pos]; - } - - protected final boolean isChanged(int pos) { - return screenIsChanged[pos] == 0 ? false : true; - } + protected final boolean isUseGui(int pos) { + return screenGUI[pos] == NO_GUI ? false : true; + } - protected final boolean isUseGui(int pos) { - return screenGUI[pos] == NO_GUI ? false : true; - } + /** + * Return the data associated with the plane that is passed. + * + * @param from Position from which to start + * @param to Position to end + * @param plane From which plane to obtain the data + * @return Character array containing the data requested + */ - /** - * Return the data associated with the plane that is passed. - * - * @param from Position from which to start - * @param to Position to end - * @param plane From which plane to obtain the data - * @return Character array containing the data requested - */ - protected synchronized char[] getPlaneData(int from, int to, int plane) { + protected synchronized char[] getPlaneData(int from, int to, int plane) { + int len = (to - from); + char[] planeChars = new char[len + 1]; - int len = (to - from); + switch (plane) { + case PLANE_TEXT: + System.arraycopy(screen, from, planeChars, 0, len); + break; - char[] planeChars = new char[len + 1]; + case PLANE_ATTR: + System.arraycopy(screenAttr, from, planeChars, 0, len); + break; - switch (plane) { - case PLANE_TEXT: - System.arraycopy(screen, from, planeChars, 0, len); - break; - case PLANE_ATTR: - System.arraycopy(screenAttr, from, planeChars, 0, len); - break; - case PLANE_COLOR: - System.arraycopy(screenColor, from, planeChars, 0, len); - break; - case PLANE_EXTENDED: - System.arraycopy(screenExtended, from, planeChars, 0, len); - break; - case PLANE_EXTENDED_GRAPHIC: - System.arraycopy(screenGUI, from, planeChars, 0, len); - break; - case PLANE_FIELD: - System.arraycopy(screenField, from, planeChars, 0, len); - break; - case PLANE_IS_ATTR_PLACE: - System.arraycopy(screenIsAttr, from, planeChars, 0, len); - break; - default: - System.arraycopy(screen, from, planeChars, 0, len); + case PLANE_COLOR: + System.arraycopy(screenColor, from, planeChars, 0, len); + break; + + case PLANE_EXTENDED: + System.arraycopy(screenExtended, from, planeChars, 0, len); + break; + + case PLANE_EXTENDED_GRAPHIC: + System.arraycopy(screenGUI, from, planeChars, 0, len); + break; - } - return planeChars; + case PLANE_FIELD: + System.arraycopy(screenField, from, planeChars, 0, len); + break; - } + case PLANE_IS_ATTR_PLACE: + System.arraycopy(screenIsAttr, from, planeChars, 0, len); + break; + + default: + System.arraycopy(screen, from, planeChars, 0, len); + } + + return planeChars; + } - /** - * Converts a linear presentation space position to its corresponding row. - * - * @param pos The position to be converted - * @return The row which corresponds to the position given - * @throws OhioException - */ - private int convertPosToRow(int pos) { - - return (pos / numCols) + 1; - - } + /** + * Converts a linear presentation space position to its corresponding row. + * + * @param pos The position to be converted + * @return The row which corresponds to the position given + * @throws OhioException + */ + private int convertPosToRow(int pos) { + return (pos / numCols) + 1; + } - /** - * Converts a linear presentation space position to its corresponding column. - * - * @param pos The position to be converted - * @return The column which corresponds to the position given - * @throws OhioException - */ - private int convertPosToColumn(int pos) { - - return (pos % numCols) + 1; + /** + * Converts a linear presentation space position to its corresponding column. + * + * @param pos The position to be converted + * @return The column which corresponds to the position given + * @throws OhioException + */ + private int convertPosToColumn(int pos) { + return (pos % numCols) + 1; + } - } - - /** - * - * Converts a row and column coordinate to its corresponding linear position. - * - * @param row - The row of the coordinate - * @param col - The column of the coordinate - * @return The linear position which corresponds to the coordinate given. - * @throws OhioException - */ - private int convertRowColToPos(int row, int col) { + /** + * + * Converts a row and column coordinate to its corresponding linear position. + * + * @param row - The row of the coordinate + * @param col - The column of the coordinate + * @return The linear position which corresponds to the coordinate given. + * @throws OhioException + */ + private int convertRowColToPos(int row, int col) { + return (row - 1) * numCols + col - 1; + } - return (row - 1) * numCols + col -1; - - } - + /** + *

+ * GetScreen retrieves the various planes associated with the presentation + * space. The data is returned as a linear array of character values in the + * array provided. The array is not terminated by a null character except + * when data is retrieved from the text plane, in which case a single null + * character is appended. + *

+ *

+ * The application must supply a buffer for the returned data and the length + * of the buffer. Data is returned starting from the beginning of the + * presentation space and continuing until the buffer is full or the entire + * plane has been copied. For text plane data, the buffer must include one + * extra position for the terminating null character. + *

+ * + * @param buffer + * @param bufferLength + * @param plane + * @return The number of characters copied to the buffer + * @throws OhioException + */ - /** - *

- * GetScreen retrieves the various planes associated with the presentation - * space. The data is returned as a linear array of character values in the - * array provided. The array is not terminated by a null character except - * when data is retrieved from the text plane, in which case a single null - * character is appended. - *

- *

- * The application must supply a buffer for the returned data and the length - * of the buffer. Data is returned starting from the beginning of the - * presentation space and continuing until the buffer is full or the entire - * plane has been copied. For text plane data, the buffer must include one - * extra position for the terminating null character. - *

- * - * @param buffer - * @param bufferLength - * @param plane - * @return The number of characters copied to the buffer - * @throws OhioException - */ - public synchronized int GetScreen(char buffer[], int bufferLength, int plane) { + public synchronized int GetScreen(char buffer[], int bufferLength, int plane) { + return GetScreen(buffer, bufferLength, 0, screenSize, plane); + } - return GetScreen(buffer,bufferLength,0,screenSize,plane); - - } + /** + *

+ * GetScreen retrieves the various planes associated with the presentation + * space. The data is returned as a linear array of character values in the + * array provided. The array is not terminated by a null character except + * when data is retrieved from the text plane, in which case a single null + * character is appended. + *

+ *

+ * The application must supply a buffer for the returned data and the length + * of the buffer. Data is returned starting from the given position and + * continuing until the specified number of characters have been copied, the + * buffer is full or the entire plane has been copied. For text plane data, + * the buffer must include one extra position for the terminating null character. + *

+ * + * @param buffer + * @param bufferLength + * @param from + * @param length + * @param plane + * @return The number of characters copied to the buffer + * @throws OhioException + */ - /** - *

- * GetScreen retrieves the various planes associated with the presentation - * space. The data is returned as a linear array of character values in the - * array provided. The array is not terminated by a null character except - * when data is retrieved from the text plane, in which case a single null - * character is appended. - *

- *

- * The application must supply a buffer for the returned data and the length - * of the buffer. Data is returned starting from the given position and - * continuing until the specified number of characters have been copied, the - * buffer is full or the entire plane has been copied. For text plane data, - * the buffer must include one extra position for the terminating null character. - *

- * - * @param buffer - * @param bufferLength - * @param from - * @param length - * @param plane - * @return The number of characters copied to the buffer - * @throws OhioException - */ - public synchronized int GetScreen(char buffer[], int bufferLength, int from, - int length, int plane) - { - // if(buffer == null) - // throw new OhioException(sessionVT.getSessionConfiguration(), - // OhioScreen.class.getName(), "osohio.screen.ohio00300", 1); - if(buffer == null) - return 0; + public synchronized int GetScreen(char buffer[], int bufferLength, int from, + int length, int plane) { + // if(buffer == null) + // throw new OhioException(sessionVT.getSessionConfiguration(), + // OhioScreen.class.getName(), "osohio.screen.ohio00300", 1); + if (buffer == null) + return 0; + + int min = Math.min(Math.min(buffer.length, bufferLength), screenSize); - int min = Math.min(Math.min(buffer.length, bufferLength), screenSize); - if ((from + min) > screenSize) { - min = screenSize - from; - } + if ((from + min) > screenSize) { + min = screenSize - from; + } + + char[] pd = getPlaneData(from, from + min, plane); + + if (pd != null) { + System.arraycopy(pd, 0, buffer, 0, min); + return pd.length; + } + + return 0; + } - char[] pd = getPlaneData(from,from + min,plane); - if(pd != null) { - System.arraycopy(pd, 0, buffer, 0, min); - return pd.length; - } - - return 0; - } + /** + *

+ * GetScreen retrieves the various planes associated with the presentation + * space. The data is returned as a linear array of character values in the + * array provided. The array is not terminated by a null character except + * when data is retrieved from the text plane, in which case a single null + * character is appended. + *

+ *

+ * The application must supply a buffer for the returned data and the length + * of the buffer. Data is returned starting from the given coordinates and + * continuing until the specified number of characters have been copied, + * the buffer is full, or the entire plane has been copied. For text plane + * data, the buffer must include one extra position for the terminating null + * character. + *

+ * + * @param buffer + * @param bufferLength + * @param row + * @param col + * @param length + * @param plane + * @return The number of characters copied to the buffer. + * @throws OhioException + */ - /** - *

- * GetScreen retrieves the various planes associated with the presentation - * space. The data is returned as a linear array of character values in the - * array provided. The array is not terminated by a null character except - * when data is retrieved from the text plane, in which case a single null - * character is appended. - *

- *

- * The application must supply a buffer for the returned data and the length - * of the buffer. Data is returned starting from the given coordinates and - * continuing until the specified number of characters have been copied, - * the buffer is full, or the entire plane has been copied. For text plane - * data, the buffer must include one extra position for the terminating null - * character. - *

- * - * @param buffer - * @param bufferLength - * @param row - * @param col - * @param length - * @param plane - * @return The number of characters copied to the buffer. - * @throws OhioException - */ - public synchronized int GetScreen(char buffer[], int bufferLength, int row, - int col, int length, int plane) - // throws OhioException { - { - // Call GetScreen function after converting row and column to - // a position. - return GetScreen(buffer,bufferLength, convertRowColToPos(row,col), - length, plane); - } + public synchronized int GetScreen(char buffer[], int bufferLength, int row, + int col, int length, int plane) + // throws OhioException { + { + // Call GetScreen function after converting row and column to + // a position. + return GetScreen(buffer, bufferLength, convertRowColToPos(row, col), + length, plane); + } - /** - *

- * GetScreenRect retrieves data from the various planes associated with the - * presentation space. The data is returned as a linear array of character - * values in the buffer provided. - *

- * - *

- * The application supplies two positions that represent opposing corners of - * a rectangle within the presentation space. The starting and ending - * positions can have any spatial relationship to each other. The data - * returned starts from the row containing the upper-most point to the row - * containing the lower-most point, and from the left-most column to the - * right-most column. - *

- *

- * The specified buffer must be at least large enough to contain the number - * of characters in the rectangle. If the buffer is too small, no data is - * copied and zero is returned by the method. Otherwise, the method returns - * the number of characters copied. - *

- * - * @param buffer - * @param bufferLength - * @param startPos - * @param endPos - * @param plane - * @return The number of characters copied to the buffer - * @throws OhioException - */ - protected int GetScreenRect(char buffer[], int bufferLength, - int startPos, int endPos, int plane) - // throws OhioException { - { - // We will use the row,col routine here because it is easier to use - // row colum than it is for position since I wrote the other first and - // am to lazy to implement it here - // Maybe it would be faster to do it the other way? - int startRow = convertPosToRow(startPos); - int startCol = convertPosToColumn(startPos); - int endRow = convertPosToRow(endPos); - int endCol = convertPosToColumn(endPos); - return GetScreenRect(buffer, bufferLength, startRow, startCol, - endRow, endCol, plane); + /** + *

+ * GetScreenRect retrieves data from the various planes associated with the + * presentation space. The data is returned as a linear array of character + * values in the buffer provided. + *

+ * + *

+ * The application supplies two positions that represent opposing corners of + * a rectangle within the presentation space. The starting and ending + * positions can have any spatial relationship to each other. The data + * returned starts from the row containing the upper-most point to the row + * containing the lower-most point, and from the left-most column to the + * right-most column. + *

+ *

+ * The specified buffer must be at least large enough to contain the number + * of characters in the rectangle. If the buffer is too small, no data is + * copied and zero is returned by the method. Otherwise, the method returns + * the number of characters copied. + *

+ * + * @param buffer + * @param bufferLength + * @param startPos + * @param endPos + * @param plane + * @return The number of characters copied to the buffer + * @throws OhioException + */ + protected int GetScreenRect(char buffer[], int bufferLength, + int startPos, int endPos, int plane) + // throws OhioException { + { + // We will use the row,col routine here because it is easier to use + // row colum than it is for position since I wrote the other first and + // am to lazy to implement it here + // Maybe it would be faster to do it the other way? + int startRow = convertPosToRow(startPos); + int startCol = convertPosToColumn(startPos); + int endRow = convertPosToRow(endPos); + int endCol = convertPosToColumn(endPos); + return GetScreenRect(buffer, bufferLength, startRow, startCol, + endRow, endCol, plane); + } - } + /** + *

+ * GetScreenRect retrieves data from the various planes associated with the + * presentation space. The data is returned as a linear array of character + * values in the buffer provided. The buffer is not terminated by a null + * character. + *

+ *

+ * The application supplies two coordinates that represent opposing corners + * of a rectangle within the presentation space. The starting and ending + * coordinates can have any spatial relationship to each other. The data + * returned starts from the row containing the upper-most point to the row + * containing the lower-most point, and from the left-most column to the + * right-most column. + *

+ *

+ * The specified buffer must be at least large enough to contain the number + * of characters in the rectangle. If the buffer is too small, no data is + * copied and zero is returned by the method. Otherwise, the method returns + * the number of characters copied. + *

+ * + * @param buffer + * @param bufferLength + * @param startRow + * @param startCol + * @param endRow + * @param endCol + * @param plane + * @return The number characters copied to the buffer + * @throws OhioException + */ + protected int GetScreenRect(char buffer[], int bufferLength, + int startRow, int startCol, + int endRow, int endCol, int plane) + // throws OhioException { + { + // number of bytes obtained + int numBytes = 0; - /** - *

- * GetScreenRect retrieves data from the various planes associated with the - * presentation space. The data is returned as a linear array of character - * values in the buffer provided. The buffer is not terminated by a null - * character. - *

- *

- * The application supplies two coordinates that represent opposing corners - * of a rectangle within the presentation space. The starting and ending - * coordinates can have any spatial relationship to each other. The data - * returned starts from the row containing the upper-most point to the row - * containing the lower-most point, and from the left-most column to the - * right-most column. - *

- *

- * The specified buffer must be at least large enough to contain the number - * of characters in the rectangle. If the buffer is too small, no data is - * copied and zero is returned by the method. Otherwise, the method returns - * the number of characters copied. - *

- * - * @param buffer - * @param bufferLength - * @param startRow - * @param startCol - * @param endRow - * @param endCol - * @param plane - * @return The number characters copied to the buffer - * @throws OhioException - */ - protected int GetScreenRect(char buffer[], int bufferLength, - int startRow, int startCol, - int endRow, int endCol, int plane) - // throws OhioException { - { - // number of bytes obtained - int numBytes = 0; + // lets check the row range. If they are reversed then we need to + // place them in the correct order. + if (startRow > endRow) { + int r = startRow; + startRow = endRow; + endRow = r; + } - // lets check the row range. If they are reversed then we need to - // place them in the correct order. - if(startRow > endRow) { - int r = startRow; - startRow = endRow; - endRow = r; - } - // lets check the column range. If they are reversed then we need to - // place them in the correct order. - if(startCol > endCol) { - int c = startCol; - startCol = endCol; - endCol = c; - } - int numCols = (endCol - startCol) + 1; - int numRows = (endRow - startRow) + 1; + // lets check the column range. If they are reversed then we need to + // place them in the correct order. + if (startCol > endCol) { + int c = startCol; + startCol = endCol; + endCol = c; + } - // lets make sure it is within the bounds of the character array passed - // if not the return as zero bytes where read as per documentation. - if(numCols * numRows <= bufferLength) { + int numCols = (endCol - startCol) + 1; + int numRows = (endRow - startRow) + 1; + + // lets make sure it is within the bounds of the character array passed + // if not the return as zero bytes where read as per documentation. + if (numCols * numRows <= bufferLength) { + // make sure it is one larger. I guess for other languanges to + // reference like in C which is terminated by a zero byte at the end + // of strings. + char cb[] = new char[numCols + 1]; + int charOffset = 0; + int bytes = 0; - // make sure it is one larger. I guess for other languanges to - // reference like in C which is terminated by a zero byte at the end - // of strings. - char cb[] = new char[numCols + 1]; - int charOffset = 0; - int bytes = 0; + // now let's loop through and get the screen information for + // each row; + for (int row = startRow; row <= endRow;) { + if ((bytes = GetScreen(cb, cb.length, row, startCol, numCols, plane)) != 0) { + System.arraycopy(cb, 0, buffer, charOffset, numCols); + } - // now let's loop through and get the screen information for - // each row; - for(int row = startRow; row <= endRow;) { - if((bytes = GetScreen(cb, cb.length, row, startCol, numCols, plane)) != 0) { - System.arraycopy(cb, 0, buffer, charOffset, numCols); - } - row++; - charOffset += numCols; - // make sure we count the number of bytes returned - numBytes += bytes; - } + row++; + charOffset += numCols; + // make sure we count the number of bytes returned + numBytes += bytes; + } + } + + return numBytes; + } - } - - return numBytes; - } + private int isOption(char[] screen, + int x, + int lenScreen, + int numPref, + int numSuff, + char suff) { + boolean hs = true; + int sp = x; + int os = 0; - private int isOption(char[] screen, - int x, - int lenScreen, - int numPref, - int numSuff, - char suff) { - boolean hs =true; - int sp = x; - int os = 0; - // check to the left for option - while (--sp >=0 && screen[sp] <= ' ' ) { + // check to the left for option + while (--sp >= 0 && screen[sp] <= ' ') { + if (x - sp > numPref || screen[sp] == suff || + screen[sp] == '.' || + screen[sp] == '*') { + hs = false; + break; + } + } + + // now lets check for how long the option is it has to be numPref or less + os = sp; - if (x - sp > numPref || screen[sp] == suff|| - screen[sp] == '.' || - screen[sp] == '*') { - hs =false; - break; - } - } + while (hs && --os > 0 && screen[os] > ' ') { + if (sp - os >= numPref || screen[os] == suff || + screen[os] == '.' || + screen[os] == '*') { + hs = false; + break; + } + } - // now lets check for how long the option is it has to be numPref or less - os = sp; - while (hs && --os > 0 && screen[os] > ' ' ) { + if (sp - os > 1 && !Character.isDigit(screen[os + 1])) { + hs = false; + } - if (sp - os >= numPref || screen[os] == suff || - screen[os] == '.' || - screen[os] == '*') { - hs = false; - break; - } - } - if (sp - os > 1 && !Character.isDigit(screen[os+1])) { - hs = false; - } + sp = x; - sp = x; + if (Character.isDigit(screen[sp + 1])) + hs = false; - if (Character.isDigit(screen[sp+1])) - hs = false; - // now lets make sure there are no more than numSuff spaces after option - while (hs && (++sp < lenScreen && screen[sp] <= ' ' - || screen[sp] == suff )) { - if (sp - x >= numSuff || screen[sp] == suff || - screen[sp] == '.' || - screen[sp] == '*') { - hs =false; - break; - } - } - if (hs && !Character.isLetterOrDigit(screen[sp])) - hs = false; - if (hs) { - return os; - } - return -1; - } + // now lets make sure there are no more than numSuff spaces after option + while (hs && (++sp < lenScreen && screen[sp] <= ' ' + || screen[sp] == suff)) { + if (sp - x >= numSuff || screen[sp] == suff || + screen[sp] == '.' || + screen[sp] == '*') { + hs = false; + break; + } + } + + if (hs && !Character.isLetterOrDigit(screen[sp])) + hs = false; + + if (hs) { + return os; + } + + return -1; + } } \ No newline at end of file diff -r 6a0ad4d384ea -r 77ac18bc1b2f src/org/tn5250j/framework/tn5250/Stream5250.java --- a/src/org/tn5250j/framework/tn5250/Stream5250.java Wed Jun 18 13:00:19 2014 -0700 +++ b/src/org/tn5250j/framework/tn5250/Stream5250.java Wed Jun 18 13:03:01 2014 -0700 @@ -43,131 +43,122 @@ } public Stream5250() { - buffer = null; - streamSize = 0; - opCode = 0; - dataStart = 0; - pos = dataStart; - } + buffer = null; + streamSize = 0; + opCode = 0; + dataStart = 0; + pos = dataStart; + } /** * This method takes a byte array and initializes the object information * to be used. - * + * * @param abyte0 */ public void initialize(byte abyte0[]) { - - buffer = abyte0; - // size without end of record 0xFF 0xEF - streamSize = (abyte0[0] & 0xff) << 8 | abyte0[1] & 0xff; - opCode = abyte0[9]; - dataStart = 6 + abyte0[6]; - pos = dataStart; - + buffer = abyte0; + // size without end of record 0xFF 0xEF + streamSize = (abyte0[0] & 0xff) << 8 | abyte0[1] & 0xff; + opCode = abyte0[9]; + dataStart = 6 + abyte0[6]; + pos = dataStart; } - + public final int getOpCode() { return opCode; } public final byte getNextByte() - throws Exception { - if(buffer == null || pos > buffer.length) + throws Exception { + if (buffer == null || pos > buffer.length) throw new Exception("Buffer length exceeded: " + pos); else return buffer[pos++]; } public final void setPrevByte() - throws Exception { - if(pos == 0) { + throws Exception { + if (pos == 0) { throw new Exception("Index equals zero."); } else { pos--; return; - } - } + } + } - /** - * Returns where we are in the buffer - * @return position in the buffer - */ - public final int getCurrentPos() { - return pos; - } + /** + * Returns where we are in the buffer + * @return position in the buffer + */ + public final int getCurrentPos() { + return pos; + } - public final byte getByteOffset(int off) - throws Exception { - - if(buffer == null || (pos + off ) > buffer.length) + public final byte getByteOffset(int off) + throws Exception { + if (buffer == null || (pos + off) > buffer.length) throw new Exception("Buffer length exceeded: " + pos); else return buffer[pos + off]; - - } + } - public final boolean size() { - return pos >= streamSize; - } + public final boolean size() { + return pos >= streamSize; + } - /** - * Determines if any more bytes are available in the buffer to be processed. - * @return yes or no - */ - public final boolean hasNext() { - + /** + * Determines if any more bytes are available in the buffer to be processed. + * @return yes or no + */ + public final boolean hasNext() { // return pos >= buffer.length; - return pos < streamSize; - } + return pos < streamSize; + } - /** - * This routine will retrieve a segment based on the first two bytes being - * the length of the segment. - * - * @return a new byte array containing the bytes of the segment. - * @throws Exception - */ - public final byte[] getSegment() throws Exception { - - // The first two bytes contain the length of the segment. - int length = ((buffer[pos] & 0xff )<< 8 | (buffer[pos+1] & 0xff)); - // allocate space for it. - byte[] segment = new byte[length]; - - getSegment(segment,length,true); - - return segment; - } + /** + * This routine will retrieve a segment based on the first two bytes being + * the length of the segment. + * + * @return a new byte array containing the bytes of the segment. + * @throws Exception + */ + public final byte[] getSegment() throws Exception { + // The first two bytes contain the length of the segment. + int length = ((buffer[pos] & 0xff) << 8 | (buffer[pos + 1] & 0xff)); + // allocate space for it. + byte[] segment = new byte[length]; + getSegment(segment, length, true); + return segment; + } - /** - * This routine will retrieve a byte array based on the first two bytes being - * the length of the segment. - * - * @param segment - byte array - * @param length - length of segment to return - * @param adjustPos - adjust the position of the buffer to the end of the seg - * ment - * @throws Exception - */ - public final void getSegment(byte[] segment, int length, boolean adjustPos) - throws Exception { + /** + * This routine will retrieve a byte array based on the first two bytes being + * the length of the segment. + * + * @param segment - byte array + * @param length - length of segment to return + * @param adjustPos - adjust the position of the buffer to the end of the seg + * ment + * @throws Exception + */ + public final void getSegment(byte[] segment, int length, boolean adjustPos) + throws Exception { + // If the length is larger than what is available throw an exception + if ((pos + length) > buffer.length) + throw new Exception("Buffer length exceeded: start " + pos + + " length " + length); - // If the length is larger than what is available throw an exception - if((pos + length ) > buffer.length) - throw new Exception("Buffer length exceeded: start " + pos - + " length " + length); - // use the system array copy to move the bytes from the buffer - // to the allocated byte array - System.arraycopy(buffer,pos,segment,0,length); + // use the system array copy to move the bytes from the buffer + // to the allocated byte array + System.arraycopy(buffer, pos, segment, 0, length); - // update the offset to be after the segment so the next byte can be read - if (adjustPos) - pos +=length; - - } + // update the offset to be after the segment so the next byte can be read + if (adjustPos) + pos += length; + } } diff -r 6a0ad4d384ea -r 77ac18bc1b2f src/org/tn5250j/framework/tn5250/WTDSFParser.java --- a/src/org/tn5250j/framework/tn5250/WTDSFParser.java Wed Jun 18 13:00:19 2014 -0700 +++ b/src/org/tn5250j/framework/tn5250/WTDSFParser.java Wed Jun 18 13:03:01 2014 -0700 @@ -53,143 +53,133 @@ */ public class WTDSFParser { private static final String TAG = "WTDSFParser"; - private Screen5250 screen52; - private tnvt vt; - private ICodePage codePage; - int pos; - byte[] segment; - int length; - boolean error; - boolean guiStructsExist; + private Screen5250 screen52; + private tnvt vt; + private ICodePage codePage; + int pos; + byte[] segment; + int length; + boolean error; + boolean guiStructsExist; - private final List guiStructs = new ArrayList(3); - private final List choices = new ArrayList(3); + private final List guiStructs = new ArrayList(3); + private final List choices = new ArrayList(3); - WTDSFParser (tnvt vt) { + WTDSFParser(tnvt vt) { + this.vt = vt; + screen52 = vt.screen52; + codePage = vt.codePage; + } - this.vt = vt; - screen52 = vt.screen52; - codePage = vt.codePage; - - } - - protected class ChoiceField { + protected class ChoiceField { - int x; - int y; - int row; - int col; - int width; - int height; - char mnemonic; - int fieldId; - int selectIndex; + int x; + int y; + int row; + int col; + int width; + int height; + char mnemonic; + int fieldId; + int selectIndex; - ChoiceField(int row, int col, int fldRow, int fldCol) { - x = row; - y = col; - row = fldRow; - col = fldCol; - } - } + ChoiceField(int row, int col, int fldRow, int fldCol) { + x = row; + y = col; + row = fldRow; + col = fldCol; + } + } - protected class Window { + protected class Window { - byte[] window; - int pos; + byte[] window; + int pos; - Window(byte[] seg, int pos) { - - //Log.i(TAG,"window created at " + pos); - window = seg; - this.pos = pos; - guiStructsExist = true; - } + Window(byte[] seg, int pos) { + //Log.i(TAG,"window created at " + pos); + window = seg; + this.pos = pos; + guiStructsExist = true; + } - } - - protected void addChoiceField(int row,int col,int fldRow, int fldCol, String text) { - - ChoiceField cf = new ChoiceField(row,col, fldRow, fldCol); - cf.fieldId = screen52.getScreenFields().getCurrentField().getFieldId(); - choices.add(cf); + } - } - - protected boolean isGuisExists () { + protected void addChoiceField(int row, int col, int fldRow, int fldCol, String text) { + ChoiceField cf = new ChoiceField(row, col, fldRow, fldCol); + cf.fieldId = screen52.getScreenFields().getCurrentField().getFieldId(); + choices.add(cf); + } - return guiStructsExist; + protected boolean isGuisExists() { + return guiStructsExist; + } - } + protected byte[] getSegmentAtPos(int pos) { + int len = guiStructs.size(); - protected byte[] getSegmentAtPos(int pos) { - int len = guiStructs.size(); - for (int x = 0; x < len; x++) { - Window w = guiStructs.get(x); - if (w.pos == pos) - return w.window; - } + for (int x = 0; x < len; x++) { + Window w = guiStructs.get(x); - return null; + if (w.pos == pos) + return w.window; + } - } - - protected void clearGuiStructs() { + return null; + } - guiStructs.clear(); - } - - protected boolean parseWriteToDisplayStructuredField(byte[] seg) { - -// bk = vt.bk; + protected void clearGuiStructs() { + guiStructs.clear(); + } - error = false; - boolean done = false; - boolean windowDefined = false; + protected boolean parseWriteToDisplayStructuredField(byte[] seg) { +// bk = vt.bk; + error = false; + boolean done = false; + boolean windowDefined = false; // int nextone; - pos = 0; - segment = seg; - + pos = 0; + segment = seg; // try { - length = (( segment[pos++] & 0xff )<< 8 | (segment[pos++] & 0xff)); + length = ((segment[pos++] & 0xff) << 8 | (segment[pos++] & 0xff)); - while (!done) { + while (!done) { int s = segment[pos++] & 0xff; - switch (s) { - - case 0xD9: // Class Type 0xD9 - Create Window - switch (segment[pos++]) { - case 0x50: // Define Selection Field - - defineSelectionField(length); - done = true; - break; - case 0x51: // Create Window + switch (s) { + case 0xD9: // Class Type 0xD9 - Create Window + switch (segment[pos++]) { + case 0x50: // Define Selection Field + defineSelectionField(length); + done = true; + break; - guiStructs.add(new Window(segment, screen52.getLastPos())); + case 0x51: // Create Window + guiStructs.add(new Window(segment, screen52.getLastPos())); + boolean cr = false; + int rows = 0; + int cols = 0; - boolean cr = false; - int rows = 0; - int cols = 0; - // pull down not supported yet - if ((segment[pos++] & 0x80) == 0x80) - cr = true; // restrict cursor - pos++; // get reserved field pos 6 - pos++; // get reserved field pos 7 - rows = segment[pos++]; // get window depth rows pos 8 - cols = segment[pos++]; // get window width cols pos 9 - length -= 9; - if (length == 0) { - done = true; + // pull down not supported yet + if ((segment[pos++] & 0x80) == 0x80) + cr = true; // restrict cursor + + pos++; // get reserved field pos 6 + pos++; // get reserved field pos 7 + rows = segment[pos++]; // get window depth rows pos 8 + cols = segment[pos++]; // get window width cols pos 9 + length -= 9; + + if (length == 0) { + done = true; // System.out.println("Create Window"); // System.out.println(" restrict cursor " + cr); // System.out.println(" Depth = " + rows + " Width = " + cols); // screen52.createWindow(rows,cols,1,true,32,58, - createWindow(rows,cols,1,true,32,58, + createWindow(rows, cols, 1, true, 32, 58, '.', '.', '.', @@ -198,91 +188,97 @@ ':', '.', ':'); - windowDefined = true; - break; - } + windowDefined = true; + break; + } - // pos 10 is Minor Structure - int ml = 0; - int type = 0; - int lastPos = screen52.getLastPos(); + // pos 10 is Minor Structure + int ml = 0; + int type = 0; + int lastPos = screen52.getLastPos(); // if (cr) // screen52.setPendingInsert(true, // screen52.getCurrentRow(), // screen52.getCurrentCol()); - int mAttr = 0; - int cAttr = 0; - - while (length > 0) { + int mAttr = 0; + int cAttr = 0; - // get minor length - ml = ( segment[pos++] & 0xff ); - length -= ml; + while (length > 0) { + // get minor length + ml = (segment[pos++] & 0xff); + length -= ml; + // only normal windows are supported at this time + type = segment[pos++]; - // only normal windows are supported at this time - type = segment[pos++]; + switch (type) { + case 0x01 : // Border presentation + boolean gui = false; - switch (type) { + if ((segment[pos++] & 0x80) == 0x80) + gui = true; - case 0x01 : // Border presentation - boolean gui = false; - if ((segment[pos++] & 0x80) == 0x80) - gui = true; - mAttr = segment[pos++]; - cAttr = segment[pos++]; + mAttr = segment[pos++]; + cAttr = segment[pos++]; + char ul = '.'; + char upper = '.'; + char ur = '.'; + char left = ':'; + char right = ':'; + char ll = ':'; + char bottom = '.'; + char lr = ':'; - char ul = '.'; - char upper = '.'; - char ur = '.'; - char left = ':'; - char right = ':'; - char ll = ':'; - char bottom = '.'; - char lr = ':'; + // if minor length is greater than 5 then + // the border characters are specified + if (ml > 5) { + ul = codePage.ebcdic2uni(segment[pos++]); - // if minor length is greater than 5 then - // the border characters are specified - if (ml > 5) { - ul = codePage.ebcdic2uni(segment[pos++]); // ul = getASCIIChar(segment[pos++]); - if (ul == 0) - ul = '.'; + if (ul == 0) + ul = '.'; + + upper = codePage.ebcdic2uni(segment[pos++]); - upper = codePage.ebcdic2uni(segment[pos++]); // upper = getASCIIChar(segment[pos++]); - if (upper == 0) - upper = '.'; + if (upper == 0) + upper = '.'; + + ur = codePage.ebcdic2uni(segment[pos++]); - ur = codePage.ebcdic2uni(segment[pos++]); // ur = getASCIIChar(segment[pos++]); - if (ur == 0) - ur = '.'; + if (ur == 0) + ur = '.'; + + left = codePage.ebcdic2uni(segment[pos++]); - left = codePage.ebcdic2uni(segment[pos++]); // left = getASCIIChar(segment[pos++]); - if (left == 0) - left = ':'; + if (left == 0) + left = ':'; + + right = codePage.ebcdic2uni(segment[pos++]); - right = codePage.ebcdic2uni(segment[pos++]); // right = getASCIIChar(segment[pos++]); - if (right == 0) - right = ':'; + if (right == 0) + right = ':'; - ll = codePage.ebcdic2uni(segment[pos++]); + ll = codePage.ebcdic2uni(segment[pos++]); + // ll = getASCIIChar(segment[pos++]); - if (ll == 0) - ll = ':'; + if (ll == 0) + ll = ':'; - bottom = codePage.ebcdic2uni(segment[pos++]); + bottom = codePage.ebcdic2uni(segment[pos++]); + // bottom = getASCIIChar(segment[pos++]); - if (bottom == 0) - bottom = '.'; + if (bottom == 0) + bottom = '.'; - lr = codePage.ebcdic2uni(segment[pos++]); + lr = codePage.ebcdic2uni(segment[pos++]); + // lr = getASCIIChar(segment[pos++]); - if (lr == 0) - lr = ':'; - } + if (lr == 0) + lr = ':'; + } // System.out.println("Create Window"); // System.out.println(" restrict cursor " + cr); @@ -298,42 +294,43 @@ // " lr = " + lr // ); // screen52.createWindow(rows,cols,type,gui,mAttr,cAttr, - createWindow(rows,cols,type,gui,mAttr,cAttr, - ul, - upper, - ur, - left, - right, - ll, - bottom, - lr); - windowDefined = true; - break; - // - // The following shows the input for window with a title - // - // +0000 019A12A0 00000400 00020411 00200107 .?.?..?...?..?. - // +0010 00000018 00000011 06131500 37D95180 ........?.?..R?? - // +0020 00000A24 0D018023 23404040 40404040 ..??..??? - // +0030 40211000 000000D7 C2C1D9C4 C5D4D67A \uFFFD.....PBARDEMO: - // +0040 40D79996 879985A2 A2408281 99408485 Progress bar de - // +0050 94961108 1520D5A4 94828599 40968640 mo.???Number of - // +0060 8595A399 8985A24B 4B4B4B4B 4B7A2011 entries......:?. - // +0070 082E2040 404040F5 F0F06BF0 F0F02011 ?.? 500,000?. - // +0080 091520C3 A4999985 95A34085 95A399A8 \uFFFD??Current entry - // +0090 4095A494 8285994B 4B4B7A20 11092E20 number...:?.\uFFFD.? - // +00A0 40404040 4040F56B F0F0F020 110A1520 5,000?.??? - // +00B0 D9859481 89958995 87408595 A3998985 Remaining entrie - // +00C0 A24B4B4B 4B4B4B7A 20110A2E 20404040 s......:?.?.? - // +00D0 40F4F9F5 6BF0F0F0 20110C15 20E2A381 495,000?..??Sta - // +00E0 99A340A3 8994854B 4B4B4B4B 4B4B4B4B rt time......... - // +00F0 4B4B4B4B 7A20110C 2F2040F7 7AF5F37A ....:?...? 7:53: + createWindow(rows, cols, type, gui, mAttr, cAttr, + ul, + upper, + ur, + left, + right, + ll, + bottom, + lr); + windowDefined = true; + break; - case 0x10 : // Window title/footer - if (!windowDefined) { + // + // The following shows the input for window with a title + // + // +0000 019A12A0 00000400 00020411 00200107 .?.?..?...?..?. + // +0010 00000018 00000011 06131500 37D95180 ........?.?..R?? + // +0020 00000A24 0D018023 23404040 40404040 ..??..??? + // +0030 40211000 000000D7 C2C1D9C4 C5D4D67A \uFFFD.....PBARDEMO: + // +0040 40D79996 879985A2 A2408281 99408485 Progress bar de + // +0050 94961108 1520D5A4 94828599 40968640 mo.???Number of + // +0060 8595A399 8985A24B 4B4B4B4B 4B7A2011 entries......:?. + // +0070 082E2040 404040F5 F0F06BF0 F0F02011 ?.? 500,000?. + // +0080 091520C3 A4999985 95A34085 95A399A8 \uFFFD??Current entry + // +0090 4095A494 8285994B 4B4B7A20 11092E20 number...:?.\uFFFD.? + // +00A0 40404040 4040F56B F0F0F020 110A1520 5,000?.??? + // +00B0 D9859481 89958995 87408595 A3998985 Remaining entrie + // +00C0 A24B4B4B 4B4B4B7A 20110A2E 20404040 s......:?.?.? + // +00D0 40F4F9F5 6BF0F0F0 20110C15 20E2A381 495,000?..??Sta + // +00E0 99A340A3 8994854B 4B4B4B4B 4B4B4B4B rt time......... + // +00F0 4B4B4B4B 7A20110C 2F2040F7 7AF5F37A ....:?...? 7:53: + + case 0x10 : // Window title/footer + if (!windowDefined) { // screen52.createWindow(rows,cols,1,true,32,58, - guiStructs.add(new Window(segment, screen52.getLastPos())); - createWindow(rows,cols,1,true,32,58, + guiStructs.add(new Window(segment, screen52.getLastPos())); + createWindow(rows, cols, 1, true, 32, 58, '.', '.', '.', @@ -342,608 +339,562 @@ ':', '.', ':'); - windowDefined = true; - } - - byte orientation = segment[pos++]; - mAttr = segment[pos++]; - cAttr = segment[pos++]; + windowDefined = true; + } - //reserved - pos++; - ml -= 6; + byte orientation = segment[pos++]; + mAttr = segment[pos++]; + cAttr = segment[pos++]; + //reserved + pos++; + ml -= 6; + StringBuffer hfBuffer = new StringBuffer(ml); - StringBuffer hfBuffer = new StringBuffer(ml); - while (ml-- > 0) { - //LDC - 13/02/2003 - Convert it to unicode - hfBuffer.append(codePage.ebcdic2uni(segment[pos++])); + while (ml-- > 0) { + //LDC - 13/02/2003 - Convert it to unicode + hfBuffer.append(codePage.ebcdic2uni(segment[pos++])); // hfBuffer.append(getASCIIChar(segment[pos++])); - - } + } - Log.d(TAG, - " orientation " + Integer.toBinaryString(orientation) + - " mAttr " + mAttr + - " cAttr " + cAttr + - " Header/Footer " + hfBuffer); - screen52.writeWindowTitle(lastPos, - rows, - cols, - orientation, - mAttr, - cAttr, - hfBuffer); - break; - default: - Log.w(TAG,"Invalid Window minor structure"); - length = 0; - done = true; - } + Log.d(TAG, + " orientation " + Integer.toBinaryString(orientation) + + " mAttr " + mAttr + + " cAttr " + cAttr + + " Header/Footer " + hfBuffer); + screen52.writeWindowTitle(lastPos, + rows, + cols, + orientation, + mAttr, + cAttr, + hfBuffer); + break; - } - - done = true; + default: + Log.w(TAG, "Invalid Window minor structure"); + length = 0; + done = true; + } + } - break; - - case 0x53: // Scroll Bar - int sblen = 15; - byte sbflag = segment[pos++]; // flag position 5 + done = true; + break; - pos++; // reserved position 6 - - // position 7,8 - int totalRowScrollable = (( segment[pos++] & 0xff )<< 8 - | (segment[pos++] & 0xff)); - - // position 9,10 - int totalColScrollable = (( segment[pos++] & 0xff )<< 8 + case 0x53: // Scroll Bar + int sblen = 15; + byte sbflag = segment[pos++]; // flag position 5 + pos++; // reserved position 6 + // position 7,8 + int totalRowScrollable = ((segment[pos++] & 0xff) << 8 + | (segment[pos++] & 0xff)); + // position 9,10 + int totalColScrollable = ((segment[pos++] & 0xff) << 8 + | (segment[pos++] & 0xff)); + // position 11,12 + int sliderRowPos = ((segment[pos++] & 0xff) << 8 | (segment[pos++] & 0xff)); - - // position 11,12 - int sliderRowPos = (( segment[pos++] & 0xff )<< 8 + // position 13,14 + int sliderColPos = ((segment[pos++] & 0xff) << 8 | (segment[pos++] & 0xff)); - - // position 13,14 - int sliderColPos = (( segment[pos++] & 0xff )<< 8 - | (segment[pos++] & 0xff)); - - // position 15 - int sliderRC = segment[pos++]; + // position 15 + int sliderRC = segment[pos++]; + screen52.createScrollBar(sbflag, totalRowScrollable, + totalColScrollable, + sliderRowPos, + sliderColPos, + sliderRC); + length -= 15; + done = true; + break; - screen52.createScrollBar(sbflag,totalRowScrollable, - totalColScrollable, - sliderRowPos, - sliderColPos, - sliderRC); - length -= 15; - - done = true; - - break; - - case 0x5B: // Remove GUI ScrollBar field + case 0x5B: // Remove GUI ScrollBar field + pos++; // reserved must be set to off pos 5 + pos++; // reserved must be set to zero pos 6 + done = true; + break; - pos++; // reserved must be set to off pos 5 - pos++; // reserved must be set to zero pos 6 - - done = true; - break; + case 0x5F: // Remove All GUI Constructs + Log.i(TAG, "remove all gui contructs"); + clearGuiStructs(); + guiStructsExist = false; + int len = 4; + int d = 0; + length -= s; - case 0x5F: // Remove All GUI Constructs - Log.i(TAG,"remove all gui contructs"); - clearGuiStructs(); - guiStructsExist = false; - int len = 4; - int d = 0; - length -= s; - while (--len > 0) - d = segment[pos++]; + while (--len > 0) + d = segment[pos++]; + // if (length > 0) { // len = (segment[pos++] & 0xff )<< 8; // // while (--len > 0) // d = segment[pos++]; // } + screen52.clearGuiStuff(); + // per 14.6.13.4 documentation we should clear the + // format table after this command + screen52.clearTable(); + done = true; + break; - screen52.clearGuiStuff(); - // per 14.6.13.4 documentation we should clear the - // format table after this command - screen52.clearTable(); - done = true; - break; - case 0x59: // remove gui window - Log.i(TAG," remove window at " + screen52.getCurrentPos()); - done = true; - break; + case 0x59: // remove gui window + Log.i(TAG, " remove window at " + screen52.getCurrentPos()); + done = true; + break; - case 0x60: // Erase/Draw Grid Lines - not supported - // do not know what they are - // as of 03/11/2002 we should not be getting - // this anymore but I will leave it here - // just in case. + case 0x60: // Erase/Draw Grid Lines - not supported + // do not know what they are + // as of 03/11/2002 we should not be getting + // this anymore but I will leave it here + // just in case. // System.out.println("erase/draw grid lines " + length); - len = 6; - d = 0; - length -= 9; - while (--len > 0) - d = segment[pos++]; - if (length > 0) { - len = (segment[pos++] & 0xff )<< 8; + len = 6; + d = 0; + length -= 9; + + while (--len > 0) + d = segment[pos++]; + + if (length > 0) { + len = (segment[pos++] & 0xff) << 8; + + while (--len > 0) { + d = segment[pos++]; + } + } + + done = true; + break; - while (--len > 0) { - d = segment[pos++]; - } - } - done = true; - break; - default: - vt.sendNegResponse(NR_REQUEST_ERROR,0x03,0x01,0x01,"invalid wtd structured field sub command " - + ( pos - 1)); + default: + vt.sendNegResponse(NR_REQUEST_ERROR, 0x03, 0x01, 0x01, "invalid wtd structured field sub command " + + (pos - 1)); // + bk.getByteOffset(-1)); - error = true; - break; - } - break; + error = true; + break; + } + + break; - default: - vt.sendNegResponse(NR_REQUEST_ERROR,0x03,0x01,0x01, - "invalid wtd structured field command " - + (pos - 1)); + default: + vt.sendNegResponse(NR_REQUEST_ERROR, 0x03, 0x01, 0x01, + "invalid wtd structured field command " + + (pos - 1)); // + bk.getByteOffset(-1)); - error = true; - break; + error = true; + break; } if (error) - done = true; + done = true; + } - } // } // catch (Exception e) {}; - - return error; - - } - - /** - * Creates a window on the screen - * - * @param depth - * @param width - * @param type - * @param gui - * @param monoAttr - * @param colorAttr - * @param ul - * @param upper - * @param ur - * @param left - * @param right - * @param ll - * @param bottom - * @param lr - */ - protected void createWindow(int depth, int width, int type, boolean gui, - int monoAttr, int colorAttr, int ul, int upper, int ur, int left, - int right, int ll, int bottom, int lr) { - - int lastPos = screen52.getLastPos(); - int numCols = screen52.getColumns(); - - int c = screen52.getCol(lastPos); - int w = 0; - width++; + return error; + } - w = width; - char initChar = Screen5250.initChar; - int initAttr = Screen5250.initAttr; - - // set leading attribute byte - screen52.setScreenCharAndAttr(initChar, initAttr, true); - - // set upper left - if (gui) { - screen52.setScreenCharAndAttr((char) ul, colorAttr, UPPER_LEFT, false); - } - else { - screen52.setScreenCharAndAttr((char) ul, colorAttr, false); - } + /** + * Creates a window on the screen + * + * @param depth + * @param width + * @param type + * @param gui + * @param monoAttr + * @param colorAttr + * @param ul + * @param upper + * @param ur + * @param left + * @param right + * @param ll + * @param bottom + * @param lr + */ + protected void createWindow(int depth, int width, int type, boolean gui, + int monoAttr, int colorAttr, int ul, int upper, int ur, int left, + int right, int ll, int bottom, int lr) { + int lastPos = screen52.getLastPos(); + int numCols = screen52.getColumns(); + int c = screen52.getCol(lastPos); + int w = 0; + width++; + w = width; + char initChar = Screen5250.initChar; + int initAttr = Screen5250.initAttr; + // set leading attribute byte + screen52.setScreenCharAndAttr(initChar, initAttr, true); - // draw top row - while (w-- >= 0) { - if (gui) { - screen52.setScreenCharAndAttr((char) upper, colorAttr, UPPER,false); - } - else { - screen52.setScreenCharAndAttr((char) upper, colorAttr, false); - } - } + // set upper left + if (gui) { + screen52.setScreenCharAndAttr((char) ul, colorAttr, UPPER_LEFT, false); + } + else { + screen52.setScreenCharAndAttr((char) ul, colorAttr, false); + } - // set upper right - if (gui) { - screen52.setScreenCharAndAttr((char) ur, colorAttr, UPPER_RIGHT, false); - } - else { - screen52.setScreenCharAndAttr((char) ur, colorAttr, false); + // draw top row + while (w-- >= 0) { + if (gui) { + screen52.setScreenCharAndAttr((char) upper, colorAttr, UPPER, false); + } + else { + screen52.setScreenCharAndAttr((char) upper, colorAttr, false); + } + } - } + // set upper right + if (gui) { + screen52.setScreenCharAndAttr((char) ur, colorAttr, UPPER_RIGHT, false); + } + else { + screen52.setScreenCharAndAttr((char) ur, colorAttr, false); + } - // set ending attribute byte - screen52.setScreenCharAndAttr(initChar, initAttr, true); + // set ending attribute byte + screen52.setScreenCharAndAttr(initChar, initAttr, true); + lastPos = ((screen52.getRow(lastPos) + 1) * numCols) + c; + screen52.goto_XY(lastPos); - lastPos = ((screen52.getRow(lastPos) + 1) * numCols) + c; - screen52.goto_XY(lastPos); - - // now handle body of window - while (depth-- > 0) { + // now handle body of window + while (depth-- > 0) { + // set leading attribute byte + screen52.setScreenCharAndAttr(initChar, initAttr, true); - // set leading attribute byte - screen52.setScreenCharAndAttr(initChar, initAttr, true); - // set left - if (gui) { - screen52.setScreenCharAndAttr((char) left, colorAttr, GUI_LEFT, false); - } - else { - screen52.setScreenCharAndAttr((char) left, colorAttr, false); - - } + // set left + if (gui) { + screen52.setScreenCharAndAttr((char) left, colorAttr, GUI_LEFT, false); + } + else { + screen52.setScreenCharAndAttr((char) left, colorAttr, false); + } - w = width - 2; - screen52.setScreenCharAndAttr(initChar, initAttr, NO_GUI, true); - // fill it in - while (w-- >= 0) { -// if (!planes.isUseGui(screen52.getLastPos())) - screen52.setScreenCharAndAttr(initChar, initAttr, NO_GUI, false); - } - screen52.setScreenCharAndAttr(initChar, initAttr, NO_GUI, true); + w = width - 2; + screen52.setScreenCharAndAttr(initChar, initAttr, NO_GUI, true); - // set right - if (gui) { - screen52.setScreenCharAndAttr((char) right, colorAttr, GUI_RIGHT, false); + // fill it in + while (w-- >= 0) { +// if (!planes.isUseGui(screen52.getLastPos())) + screen52.setScreenCharAndAttr(initChar, initAttr, NO_GUI, false); + } + + screen52.setScreenCharAndAttr(initChar, initAttr, NO_GUI, true); - } - else { - screen52.setScreenCharAndAttr((char) right, colorAttr, false); - - } - - screen52.setScreenCharAndAttr(initChar, initAttr, true); + // set right + if (gui) { + screen52.setScreenCharAndAttr((char) right, colorAttr, GUI_RIGHT, false); + } + else { + screen52.setScreenCharAndAttr((char) right, colorAttr, false); + } - lastPos = ((screen52.getRow(lastPos) + 1) * numCols) + c; - screen52.goto_XY(lastPos); - } + screen52.setScreenCharAndAttr(initChar, initAttr, true); + lastPos = ((screen52.getRow(lastPos) + 1) * numCols) + c; + screen52.goto_XY(lastPos); + } - // set leading attribute byte - screen52.setScreenCharAndAttr(initChar, initAttr, true); - if (gui) { - screen52.setScreenCharAndAttr((char) ll, colorAttr, LOWER_LEFT, false); + // set leading attribute byte + screen52.setScreenCharAndAttr(initChar, initAttr, true); - } - else { - screen52.setScreenCharAndAttr((char) ll, colorAttr, false); + if (gui) { + screen52.setScreenCharAndAttr((char) ll, colorAttr, LOWER_LEFT, false); + } + else { + screen52.setScreenCharAndAttr((char) ll, colorAttr, false); + } - } - w = width; + w = width; - // draw bottom row - while (w-- >= 0) { - if (gui) { - screen52.setScreenCharAndAttr((char) bottom, colorAttr, BOTTOM, false); - } - else { - screen52.setScreenCharAndAttr((char) bottom, colorAttr, false); - - } - } + // draw bottom row + while (w-- >= 0) { + if (gui) { + screen52.setScreenCharAndAttr((char) bottom, colorAttr, BOTTOM, false); + } + else { + screen52.setScreenCharAndAttr((char) bottom, colorAttr, false); + } + } - // set lower right - if (gui) { - screen52.setScreenCharAndAttr((char) lr, colorAttr, LOWER_RIGHT, false); - } - else { - screen52.setScreenCharAndAttr((char) lr, colorAttr, false); - } - - // set ending attribute byte - screen52.setScreenCharAndAttr(initChar, initAttr, true); - - } + // set lower right + if (gui) { + screen52.setScreenCharAndAttr((char) lr, colorAttr, LOWER_RIGHT, false); + } + else { + screen52.setScreenCharAndAttr((char) lr, colorAttr, false); + } -/* *** NEVER USED LOCALLY ************************************************** */ -// private void clearWindowBody(ScreenPlanes planes, int startPos, int depth, int width) { -// -// int lastPos = startPos; -// char initChar = Screen5250.initChar; -// int initAttr = Screen5250.initAttr; -// -// // now handle body of window -// while (depth-- > 0) { -// -// // set leading attribute byte -//// planes.setScreenCharAndAttr(lastPos,initChar, initAttr, true); -//// setDirty(lastPos); -//// advancePos(); -//// -//// // set left -//// planes.setScreenCharAndAttr(lastPos, (char) left, colorAttr, false); -//// -//// if (gui) { -//// planes.setUseGUI(lastPos,GUI_LEFT); -//// } -//// setDirty(lastPos); -//// advancePos(); -// -// int w = width; -// // fill it in -// while (w-- >= 0) { -//// screen[lastPos].setCharAndAttr(initChar, initAttr, true); -// planes.setScreenCharAndAttr(lastPos,initChar, initAttr, true); -//// screen[lastPos].setUseGUI(NO_GUI); -// planes.setUseGUI(lastPos,NO_GUI); -//// setDirty(lastPos); -// lastPos++; -// advancePos(); -// } -// -//// // set right -//// // screen[lastPos].setCharAndAttr((char) right, colorAttr, false); -//// planes.setScreenCharAndAttr(lastPos,(char) right, colorAttr, false); -//// if (gui) { -//// // screen[lastPos].setUseGUI(RIGHT); -//// planes.setUseGUI(lastPos,GUI_RIGHT); -//// } -//// -//// setDirty(lastPos); -//// advancePos(); -//// -//// // set ending attribute byte -//// // screen[lastPos].setCharAndAttr(initChar, initAttr, true); -//// planes.setScreenCharAndAttr(lastPos,initChar, initAttr, true); -//// setDirty(lastPos); -// -// lastPos = startPos; -// } -// -// } + // set ending attribute byte + screen52.setScreenCharAndAttr(initChar, initAttr, true); + } -/* *** NEVER USED LOCALLY ************************************************** */ -// private void setDirty(int pos) { + /* *** NEVER USED LOCALLY ************************************************** */ +// private void clearWindowBody(ScreenPlanes planes, int startPos, int depth, int width) { // -// screen52.setDirty(pos); +// int lastPos = startPos; +// char initChar = Screen5250.initChar; +// int initAttr = Screen5250.initAttr; +// +// // now handle body of window +// while (depth-- > 0) { // -// } - -/* *** NEVER USED LOCALLY ************************************************** */ -// private void advancePos() { +// // set leading attribute byte +//// planes.setScreenCharAndAttr(lastPos,initChar, initAttr, true); +//// setDirty(lastPos); +//// advancePos(); +//// +//// // set left +//// planes.setScreenCharAndAttr(lastPos, (char) left, colorAttr, false); +//// +//// if (gui) { +//// planes.setUseGUI(lastPos,GUI_LEFT); +//// } +//// setDirty(lastPos); +//// advancePos(); // -// screen52.advancePos(); -// } - - private void defineSelectionField(int majLen) { - - // 0030: 20 00 2C 3E 00 00 00 69 12 A0 00 00 04 00 00 03 .,>...i........ - // 0040: 04 40 04 11 00 28 01 07 00 00 00 19 00 00 04 11 .@...(.......... - // 0050: 14 19 15 00 48 D9 50 00 60 00 11 01 84 84 00 00 ....H.P.`....... - // 0060: 05 03 01 01 00 00 00 13 01 E0 00 21 00 21 00 3B ...........!.!.; - // 0070: 22 20 20 20 20 3A 24 20 20 3A 0B 10 08 00 E0 00 " :$ :...... - // 0080: D6 95 85 40 40 0B 10 08 00 E0 00 E3 A6 96 40 40 ...@@.........@@ - // 0090: 0B 10 08 00 E0 00 E3 88 99 85 85 04 52 00 00 FF ............R... - // 00A0: EF . - try { - int flag1 = segment[pos++]; // Flag byte 1 - byte 5 - int flag2 = segment[pos++]; // Flag byte 2 - byte 6 - int flag3 = segment[pos++]; // Flag byte 3 - byte 7 - int typeSelection = segment[pos++]; // Type of selection Field - byte 8 - - // GUI Device Characteristics: - // This byte is used if the target device is a GUI PWS or a GUI-like - // NWS. If neigher of these WS are the targets, this byte is ignored - int guiDevice = segment[pos++]; // byte 9 - int withMnemonic = segment[pos++]; // byte 10 - int noMnemonic = segment[pos++]; // byte 11 +// int w = width; +// // fill it in +// while (w-- >= 0) { +//// screen[lastPos].setCharAndAttr(initChar, initAttr, true); +// planes.setScreenCharAndAttr(lastPos,initChar, initAttr, true); +//// screen[lastPos].setUseGUI(NO_GUI); +// planes.setUseGUI(lastPos,NO_GUI); +//// setDirty(lastPos); +// lastPos++; +// advancePos(); +// } +// +//// // set right +//// // screen[lastPos].setCharAndAttr((char) right, colorAttr, false); +//// planes.setScreenCharAndAttr(lastPos,(char) right, colorAttr, false); +//// if (gui) { +//// // screen[lastPos].setUseGUI(RIGHT); +//// planes.setUseGUI(lastPos,GUI_RIGHT); +//// } +//// +//// setDirty(lastPos); +//// advancePos(); +//// +//// // set ending attribute byte +//// // screen[lastPos].setCharAndAttr(initChar, initAttr, true); +//// planes.setScreenCharAndAttr(lastPos,initChar, initAttr, true); +//// setDirty(lastPos); +// +// lastPos = startPos; +// } +// +// } - pos++; // Reserved - byte 12 - pos++; // Reserved - byte 13 - - int cols = segment[pos++]; // Text Size - byte 14 - int rows = segment[pos++]; // Rows - byte 15 + /* *** NEVER USED LOCALLY ************************************************** */ +// private void setDirty(int pos) { +// +// screen52.setDirty(pos); +// +// } - int maxColChoice = segment[pos++]; // byte 16 num of column choices - int padding = segment[pos++]; // byte 17 - int numSepChar = segment[pos++]; // byte 18 - int ctySepChar = segment[pos++]; // byte 19 - int cancelAID = segment[pos++]; // byte 20 + /* *** NEVER USED LOCALLY ************************************************** */ +// private void advancePos() { +// +// screen52.advancePos(); +// } - int cnt = 0; - int minLen = 0; - majLen -= 21; - Log.d(TAG," row: " + screen52.getCurrentRow() - + " col: " + screen52.getCurrentCol() - + " type " + typeSelection - + " gui " + guiDevice - + " withMnemonic " + Integer.toHexString(withMnemonic & 0xf0) - + " noMnemonic " + Integer.toHexString(noMnemonic & 0xf0) - + " noMnemonic " + Integer.toBinaryString(noMnemonic) - + " noMnemonicType " + Integer.toBinaryString((noMnemonic & 0xf0)) - + " noMnemonicSel " + Integer.toBinaryString((noMnemonic & 0x0f)) - + " maxcols " + maxColChoice - + " cols " + cols - + " rows " + rows); - int rowCtr = 0; - int colCtr = 0; - int chcRowStart = screen52.getCurrentRow(); - int chcColStart = screen52.getCurrentCol(); - int chcRow = chcRowStart; - int chcCol = chcColStart; - int chcPos = screen52.getPos(chcRow-1,chcCol); - + private void defineSelectionField(int majLen) { + // 0030: 20 00 2C 3E 00 00 00 69 12 A0 00 00 04 00 00 03 .,>...i........ + // 0040: 04 40 04 11 00 28 01 07 00 00 00 19 00 00 04 11 .@...(.......... + // 0050: 14 19 15 00 48 D9 50 00 60 00 11 01 84 84 00 00 ....H.P.`....... + // 0060: 05 03 01 01 00 00 00 13 01 E0 00 21 00 21 00 3B ...........!.!.; + // 0070: 22 20 20 20 20 3A 24 20 20 3A 0B 10 08 00 E0 00 " :$ :...... + // 0080: D6 95 85 40 40 0B 10 08 00 E0 00 E3 A6 96 40 40 ...@@.........@@ + // 0090: 0B 10 08 00 E0 00 E3 88 99 85 85 04 52 00 00 FF ............R... + // 00A0: EF . + try { + int flag1 = segment[pos++]; // Flag byte 1 - byte 5 + int flag2 = segment[pos++]; // Flag byte 2 - byte 6 + int flag3 = segment[pos++]; // Flag byte 3 - byte 7 + int typeSelection = segment[pos++]; // Type of selection Field - byte 8 + // GUI Device Characteristics: + // This byte is used if the target device is a GUI PWS or a GUI-like + // NWS. If neigher of these WS are the targets, this byte is ignored + int guiDevice = segment[pos++]; // byte 9 + int withMnemonic = segment[pos++]; // byte 10 + int noMnemonic = segment[pos++]; // byte 11 + pos++; // Reserved - byte 12 + pos++; // Reserved - byte 13 + int cols = segment[pos++]; // Text Size - byte 14 + int rows = segment[pos++]; // Rows - byte 15 + int maxColChoice = segment[pos++]; // byte 16 num of column choices + int padding = segment[pos++]; // byte 17 + int numSepChar = segment[pos++]; // byte 18 + int ctySepChar = segment[pos++]; // byte 19 + int cancelAID = segment[pos++]; // byte 20 + int cnt = 0; + int minLen = 0; + majLen -= 21; + Log.d(TAG, " row: " + screen52.getCurrentRow() + + " col: " + screen52.getCurrentCol() + + " type " + typeSelection + + " gui " + guiDevice + + " withMnemonic " + Integer.toHexString(withMnemonic & 0xf0) + + " noMnemonic " + Integer.toHexString(noMnemonic & 0xf0) + + " noMnemonic " + Integer.toBinaryString(noMnemonic) + + " noMnemonicType " + Integer.toBinaryString((noMnemonic & 0xf0)) + + " noMnemonicSel " + Integer.toBinaryString((noMnemonic & 0x0f)) + + " maxcols " + maxColChoice + + " cols " + cols + + " rows " + rows); + int rowCtr = 0; + int colCtr = 0; + int chcRowStart = screen52.getCurrentRow(); + int chcColStart = screen52.getCurrentCol(); + int chcRow = chcRowStart; + int chcCol = chcColStart; + int chcPos = screen52.getPos(chcRow - 1, chcCol); // client access //0000 00 04 ac 9e b9 35 00 01 02 32 bb 4e 08 00 45 00 .....5...2.N..E. //0010 00 3c 4f 8e 40 00 80 06 00 00 c1 a8 33 58 c1 a8 .= maxColChoice) { + //maxColChoice + colCtr++; - rowCtr++; - colCtr=0; - chcColStart = chcCol; - chcRowStart = chcRow + rowCtr; - if (rowCtr > rows) { - chcRowStart = chcRow; - rowCtr = 0; - chcColStart = chcColStart + 3 + cols + padding; - } - } - else { - chcColStart = chcColStart + padding + cols + 3; +// rowCtr++; + if (colCtr >= maxColChoice) { + rowCtr++; + colCtr = 0; + chcColStart = chcCol; + chcRowStart = chcRow + rowCtr; + + if (rowCtr > rows) { + chcRowStart = chcRow; + rowCtr = 0; + chcColStart = chcColStart + 3 + cols + padding; + } + } + else { + chcColStart = chcColStart + padding + cols + 3; // - } + } + + break; - break; - default: - for (cnt = 2;cnt < minLen; cnt++) { - - pos++; - } - - } + default: + for (cnt = 2; cnt < minLen; cnt++) { + pos++; + } + } - majLen -= minLen; + majLen -= minLen; + } + while (majLen > 0); + } + catch (Exception exc) { + Log.w(TAG, " defineSelectionField :", exc); + exc.printStackTrace(); + } + } - } while (majLen > 0); - } - catch (Exception exc) { - Log.w(TAG," defineSelectionField :", exc); - exc.printStackTrace(); - } - } - - // negotiating commands + // negotiating commands // private static final byte IAC = (byte)-1; // 255 FF // private static final byte DONT = (byte)-2; //254 FE // private static final byte DO = (byte)-3; //253 FD @@ -966,7 +917,7 @@ // private static final byte NEGOTIATE_ESC = (byte)2; // 2 // private static final byte USERVAR = (byte)3; // 3 - // miscellaneous + // miscellaneous // private static final byte ESC = 0x04; // 04 // private static final char char0 = 0; diff -r 6a0ad4d384ea -r 77ac18bc1b2f src/org/tn5250j/framework/tn5250/tnvt.java --- a/src/org/tn5250j/framework/tn5250/tnvt.java Wed Jun 18 13:00:19 2014 -0700 +++ b/src/org/tn5250j/framework/tn5250/tnvt.java Wed Jun 18 13:03:01 2014 -0700 @@ -98,14 +98,14 @@ public final class tnvt implements Runnable { private static final String TAG = "tnvt"; // negotiating commands - private static final byte IAC = (byte) -1; // 255 FF - private static final byte DONT = (byte) -2; //254 FE - private static final byte DO = (byte) -3; //253 FD - private static final byte WONT = (byte) -4; //252 FC - private static final byte WILL = (byte) -5; //251 FB - private static final byte SB = (byte) -6; //250 Sub Begin FA - private static final byte SE = (byte) -16; //240 Sub End F0 - private static final byte EOR = (byte) -17; //239 End of Record EF + private static final byte IAC = (byte) - 1; // 255 FF + private static final byte DONT = (byte) - 2; //254 FE + private static final byte DO = (byte) - 3; //253 FD + private static final byte WONT = (byte) - 4; //252 FC + private static final byte WILL = (byte) - 5; //251 FB + private static final byte SB = (byte) - 6; //250 Sub Begin FA + private static final byte SE = (byte) - 16; //240 Sub End F0 + private static final byte EOR = (byte) - 17; //239 End of Record EF private static final byte TERMINAL_TYPE = (byte) 24; // 18 private static final byte OPT_END_OF_RECORD = (byte) 25; // 19 private static final byte TRANSMIT_BINARY = (byte) 0; // 0 @@ -189,18 +189,22 @@ if (System.getProperties().containsKey("SESSION_CONNECT_USER")) { user = System.getProperties().getProperty("SESSION_CONNECT_USER"); + if (System.getProperties().containsKey("SESSION_CONNECT_PASSWORD")) password = System.getProperties().getProperty( - "SESSION_CONNECT_PASSWORD"); + "SESSION_CONNECT_PASSWORD"); + if (System.getProperties().containsKey("SESSION_CONNECT_LIBRARY")) library = System.getProperties().getProperty( - "SESSION_CONNECT_LIBRARY"); + "SESSION_CONNECT_LIBRARY"); + if (System.getProperties().containsKey("SESSION_CONNECT_MENU")) initialMenu = System.getProperties().getProperty( - "SESSION_CONNECT_MENU"); + "SESSION_CONNECT_MENU"); + if (System.getProperties().containsKey("SESSION_CONNECT_PROGRAM")) program = System.getProperties().getProperty( - "SESSION_CONNECT_PROGRAM"); + "SESSION_CONNECT_PROGRAM"); } baosp = new ByteArrayOutputStream(); @@ -209,12 +213,12 @@ public void showURL(String url) { if (url.indexOf("://") < 0) url = "http://" + url; + Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); manager.startActivity(intent); } public String getHostName() { - return hostname; } @@ -241,20 +245,19 @@ public boolean isSslSocket() { if (this.connected && this.sock != null && this.sock instanceof SSLSocket) { return true; - } else { + } + else { return false; } } public final void setProxy(String proxyHost, String proxyPort) { - Properties systemProperties = System.getProperties(); systemProperties.put("socksProxySet", "true"); systemProperties.put("socksProxyHost", proxyHost); systemProperties.put("socksProxyPort", proxyPort); - System.setProperties(systemProperties); - Log.i(TAG," socks set "); + Log.i(TAG, " socks set "); } public final boolean connect(String hostname, int port, String encryption, String homeDirectory, vt320 buffer) { @@ -265,16 +268,17 @@ try { screen52.getOIA().setInputInhibited(ScreenOIA.INPUTINHIBITED_SYSTEM_WAIT, - ScreenOIA.OIA_LEVEL_INPUT_INHIBITED,"X - Connecting"); - } catch (Exception exc) { - Log.w(TAG,"setStatus(ON) " + exc.getMessage()); + ScreenOIA.OIA_LEVEL_INPUT_INHIBITED, "X - Connecting"); + } + catch (Exception exc) { + Log.w(TAG, "setStatus(ON) " + exc.getMessage()); } SocketConnector sc = new SocketConnector(); sock = sc.createSocket(hostname, port, encryption, homeDirectory, bridge, manager); if (sock == null) { - Log.w(TAG,"I did not get a socket"); + Log.w(TAG, "I did not get a socket"); disconnect(); return false; } @@ -286,18 +290,19 @@ sock.setSoLinger(false, 0); InputStream in = sock.getInputStream(); OutputStream out = sock.getOutputStream(); - bin = new BufferedInputStream(in, 8192); bout = new BufferedOutputStream(out); - byte abyte0[]; + while (negotiate(abyte0 = readNegotiations())); + negotiated = true; + try { screen52.setCursorActive(false); - } catch (Exception excc) { - Log.w(TAG,"setCursorOff " + excc.getMessage()); - + } + catch (Exception excc) { + Log.w(TAG, "setCursorOff " + excc.getMessage()); } producer = new DataStreamProducer(this, bin, dsq, abyte0); @@ -309,35 +314,36 @@ try { screen52.getOIA().setInputInhibited(ScreenOIA.INPUTINHIBITED_NOTINHIBITED, - ScreenOIA.OIA_LEVEL_INPUT_INHIBITED); - } catch (Exception exc) { - Log.w(TAG,"setStatus(OFF) " + exc.getMessage()); + ScreenOIA.OIA_LEVEL_INPUT_INHIBITED); + } + catch (Exception exc) { + Log.w(TAG, "setStatus(OFF) " + exc.getMessage()); } keepTrucking = true; me = new Thread(this); me.start(); - - } catch (Exception exception) { + } + catch (Exception exception) { if (exception.getMessage() == null) exception.printStackTrace(); - Log.w(TAG,"connect() " + exception.getMessage()); + + Log.w(TAG, "connect() " + exception.getMessage()); if (sock == null) - Log.w(TAG,"I did not get a socket"); + Log.w(TAG, "I did not get a socket"); disconnect(); return false; } + return true; - } public final boolean disconnect() { - if (!connected) { screen52.getOIA().setInputInhibited(ScreenOIA.INPUTINHIBITED_SYSTEM_WAIT, - ScreenOIA.OIA_LEVEL_INPUT_INHIBITED,"X - Disconnected"); + ScreenOIA.OIA_LEVEL_INPUT_INHIBITED, "X - Disconnected"); return false; } @@ -348,20 +354,22 @@ } screen52.getOIA().setInputInhibited(ScreenOIA.INPUTINHIBITED_SYSTEM_WAIT, - ScreenOIA.OIA_LEVEL_INPUT_INHIBITED,"X - Disconnected"); + ScreenOIA.OIA_LEVEL_INPUT_INHIBITED, "X - Disconnected"); screen52.getOIA().setKeyBoardLocked(false); pendingUnlock = false; try { if (sock != null) { - Log.i(TAG,"Closing socket"); + Log.i(TAG, "Closing socket"); sock.close(); } + if (bin != null) bin.close(); + if (bout != null) bout.close(); + connected = false; firstScreen = false; - // WVL - LDC : TR.000345 : properly disconnect and clear screen // Is this the right place to set screen realestate on disconnect? //controller.getScreen().clearAll(); @@ -369,21 +377,24 @@ screen52.setCursorActive(false); screen52.clearAll(); screen52.restoreScreen(); - } catch (Exception exception) { - Log.w(TAG,exception.getMessage()); + } + catch (Exception exception) { + Log.w(TAG, exception.getMessage()); connected = false; devSeq = -1; return false; - } + devSeq = -1; return true; } private final ByteArrayOutputStream appendByteStream(byte abyte0[]) { ByteArrayOutputStream bytearrayoutputstream = new ByteArrayOutputStream(); + for (int i = 0; i < abyte0.length; i++) { bytearrayoutputstream.write(abyte0[i]); + if (abyte0[i] == -1) bytearrayoutputstream.write(-1); } @@ -393,9 +404,11 @@ private final byte[] readNegotiations() throws IOException { int i = bin.read(); + if (i < 0) { throw new IOException("Connection closed."); - } else { + } + else { int j = bin.available(); byte abyte0[] = new byte[j + 1]; abyte0[0] = (byte) i; @@ -405,7 +418,6 @@ } private final void writeByte(byte abyte0[]) throws IOException { - bout.write(abyte0); bout.flush(); } @@ -417,62 +429,57 @@ // } public final void sendHeartBeat() throws IOException { - byte[] b = { (byte) 0xff, (byte) 0xf1 }; bout.write(b); bout.flush(); } private final void readImmediate(int readType) { - if (screen52.isStatusErrorCode()) { screen52.restoreErrorLine(); screen52.setStatus(Screen5250.STATUS_ERROR_CODE, - Screen5250.STATUS_VALUE_OFF, null); + Screen5250.STATUS_VALUE_OFF, null); } if (!enhanced) { screen52.setCursorActive(false); } + // screen52.setStatus(Screen5250.STATUS_SYSTEM, // Screen5250.STATUS_VALUE_ON, null); screen52.getOIA().setInputInhibited(ScreenOIA.INPUTINHIBITED_SYSTEM_WAIT, - ScreenOIA.OIA_LEVEL_INPUT_INHIBITED); - + ScreenOIA.OIA_LEVEL_INPUT_INHIBITED); screen52.getOIA().setKeyBoardLocked(true); pendingUnlock = false; invited = false; - screen52.getScreenFields().readFormatTable(baosp, readType, codePage); try { - writeGDS(0, 3, baosp.toByteArray()); - } catch (IOException ioe) { - - Log.w(TAG,ioe.getMessage()); + } + catch (IOException ioe) { + Log.w(TAG, ioe.getMessage()); baosp.reset(); } + baosp.reset(); - } public final boolean sendAidKey(int aid) { - if (screen52.isStatusErrorCode()) { screen52.restoreErrorLine(); screen52.setStatus(Screen5250.STATUS_ERROR_CODE, - Screen5250.STATUS_VALUE_OFF, null); + Screen5250.STATUS_VALUE_OFF, null); } if (!enhanced) { screen52.setCursorActive(false); } + // screen52.setStatus(Screen5250.STATUS_SYSTEM, // Screen5250.STATUS_VALUE_ON, null); screen52.getOIA().setInputInhibited(ScreenOIA.INPUTINHIBITED_SYSTEM_WAIT, - ScreenOIA.OIA_LEVEL_INPUT_INHIBITED); - + ScreenOIA.OIA_LEVEL_INPUT_INHIBITED); screen52.getOIA().setKeyBoardLocked(true); pendingUnlock = false; invited = false; @@ -481,82 +488,99 @@ baosp.write(aid); if (dataIncluded(aid)) - screen52.getScreenFields().readFormatTable(baosp, readType, codePage); try { - writeGDS(0, 3, baosp.toByteArray()); - } catch (IOException ioe) { - - Log.w(TAG,ioe.getMessage()); + } + catch (IOException ioe) { + Log.w(TAG, ioe.getMessage()); baosp.reset(); return false; } + baosp.reset(); return true; - } private boolean dataIncluded(int aid) { - switch (aid) { - - case PF1: - return !dataIncluded[0]; - case PF2: - return !dataIncluded[1]; - case PF3: - return !dataIncluded[2]; - case PF4: - return !dataIncluded[3]; - case PF5: - return !dataIncluded[4]; - case PF6: - return !dataIncluded[5]; - case PF7: - return !dataIncluded[6]; - case PF8: - return !dataIncluded[7]; - case PF9: - return !dataIncluded[8]; - case PF10: - return !dataIncluded[9]; - case PF11: - return !dataIncluded[10]; - case PF12: - return !dataIncluded[11]; - case PF13: - return !dataIncluded[12]; - case PF14: - return !dataIncluded[13]; - case PF15: - return !dataIncluded[14]; - case PF16: - return !dataIncluded[15]; - case PF17: - return !dataIncluded[16]; - case PF18: - return !dataIncluded[17]; - case PF19: - return !dataIncluded[18]; - case PF20: - return !dataIncluded[19]; - case PF21: - return !dataIncluded[20]; - case PF22: - return !dataIncluded[21]; - case PF23: - return !dataIncluded[22]; - case PF24: - return !dataIncluded[23]; - - default: - return true; - + case PF1: + return !dataIncluded[0]; + + case PF2: + return !dataIncluded[1]; + + case PF3: + return !dataIncluded[2]; + + case PF4: + return !dataIncluded[3]; + + case PF5: + return !dataIncluded[4]; + + case PF6: + return !dataIncluded[5]; + + case PF7: + return !dataIncluded[6]; + + case PF8: + return !dataIncluded[7]; + + case PF9: + return !dataIncluded[8]; + + case PF10: + return !dataIncluded[9]; + + case PF11: + return !dataIncluded[10]; + + case PF12: + return !dataIncluded[11]; + + case PF13: + return !dataIncluded[12]; + + case PF14: + return !dataIncluded[13]; + + case PF15: + return !dataIncluded[14]; + + case PF16: + return !dataIncluded[15]; + + case PF17: + return !dataIncluded[16]; + + case PF18: + return !dataIncluded[17]; + + case PF19: + return !dataIncluded[18]; + + case PF20: + return !dataIncluded[19]; + + case PF21: + return !dataIncluded[20]; + + case PF22: + return !dataIncluded[21]; + + case PF23: + return !dataIncluded[22]; + + case PF24: + return !dataIncluded[23]; + + default: + return true; } - } /** @@ -566,7 +590,6 @@ * See notes inside method */ public final void sendHelpRequest() { - // Client sends header 000D12A0000004000003####F3FFEF // operation code 3 // row - first ## @@ -579,10 +602,11 @@ try { writeGDS(0, 3, baosp.toByteArray()); - } catch (IOException ioe) { - - Log.w(TAG,ioe.getMessage()); } + catch (IOException ioe) { + Log.w(TAG, ioe.getMessage()); + } + baosp.reset(); } @@ -593,7 +617,6 @@ * See notes inside method */ public final void sendAttentionKey() { - // Client sends header 000A12A000004400000FFEF // 0x40 -> 01000000 // @@ -606,12 +629,11 @@ // bit 7 - HLP // System.out.println("Attention key sent"); - try { writeGDS(0x40, 0, null); - } catch (IOException ioe) { - - Log.w(TAG,ioe.getMessage()); + } + catch (IOException ioe) { + Log.w(TAG, ioe.getMessage()); } } @@ -642,22 +664,26 @@ public final void systemRequest(String sr) { byte[] bytes = null; - if ( (sr != null) && (sr.length() > 0)) { + if ((sr != null) && (sr.length() > 0)) { // XXX: Not sure, if this is a sufficient check for 'clear dataq' if (sr.charAt(0) == '2') { dsq.clear(); } + for (int i = 0, l = sr.length(); i < l; i++) { baosp.write(codePage.uni2ebcdic(sr.charAt(i))); } + bytes = baosp.toByteArray(); } try { writeGDS(4, 0, bytes); - } catch (IOException ioe) { - Log.i(TAG,ioe.getMessage()); } + catch (IOException ioe) { + Log.i(TAG, ioe.getMessage()); + } + baosp.reset(); } @@ -668,11 +694,10 @@ * See notes inside method */ public final void cancelInvite() { - // screen52.setStatus(Screen5250.STATUS_SYSTEM, // Screen5250.STATUS_VALUE_ON, null); screen52.getOIA().setInputInhibited(ScreenOIA.INPUTINHIBITED_SYSTEM_WAIT, - ScreenOIA.OIA_LEVEL_INPUT_INHIBITED); + ScreenOIA.OIA_LEVEL_INPUT_INHIBITED); // from rfc1205 section 4.3 // Server: Sends header with the 000A12A0 00000400 000AFFEF @@ -684,27 +709,24 @@ // no longer invited. try { writeGDS(0, 10, null); - } catch (IOException ioe) { - - Log.w(TAG,ioe.getMessage()); } - + catch (IOException ioe) { + Log.w(TAG, ioe.getMessage()); + } } public final void hostPrint(int aid) { - if (screen52.isStatusErrorCode()) { screen52.restoreErrorLine(); screen52.setStatus(Screen5250.STATUS_ERROR_CODE, - Screen5250.STATUS_VALUE_OFF, null); + Screen5250.STATUS_VALUE_OFF, null); } screen52.setCursorActive(false); // screen52.setStatus(Screen5250.STATUS_SYSTEM, // Screen5250.STATUS_VALUE_ON, null); screen52.getOIA().setInputInhibited(ScreenOIA.INPUTINHIBITED_SYSTEM_WAIT, - ScreenOIA.OIA_LEVEL_INPUT_INHIBITED); - + ScreenOIA.OIA_LEVEL_INPUT_INHIBITED); // From client access ip capture // it seems to use an operation code of 3 and 4 // also note that the flag field that says reserved is being sent as @@ -721,17 +743,17 @@ // row - first ## // column - second ## // F6 - Print Aid Key - baosp.write(screen52.getCurrentRow()); baosp.write(screen52.getCurrentCol()); baosp.write(AID_PRINT); // aid key try { writeGDS(0, 3, baosp.toByteArray()); - } catch (IOException ioe) { - - Log.w(TAG,ioe.getMessage()); } + catch (IOException ioe) { + Log.w(TAG, ioe.getMessage()); + } + baosp.reset(); } @@ -742,7 +764,6 @@ // write gerneral data stream private final void writeGDS(int flags, int opcode, byte abyte0[]) throws IOException { - // Added to fix for JDK 1.4 this was null coming from another method. // There was a weird keyRelease event coming from another panel when // using a key instead of the mouse to select button. @@ -752,6 +773,7 @@ return; int length; + if (abyte0 != null) length = abyte0.length + 10; else @@ -759,25 +781,20 @@ // refer to rfc1205 - 5250 Telnet interface // Section 3. Data Stream Format - // Logical Record Length - 16 bits baosrsp.write(length >> 8); // Length LL baosrsp.write(length & 0xff); // LL - // Record Type - 16 bits // It should always be set to '12A0'X to indicate the // General Data Stream (GDS) record type. baosrsp.write(18); // 0x12 baosrsp.write(160); // 0xA0 - // the next 16 bits are not used baosrsp.write(0); // 0x00 baosrsp.write(0); // 0x00 - // The second part is meant to be variable in length // currently this portion is 4 octets long (1 byte or 8 bits for us ;-O) baosrsp.write(4); // 0x04 - baosrsp.write(flags); // flags // bit 0 - ERR // bit 1 - ATN Attention @@ -792,13 +809,10 @@ baosrsp.write(abyte0, 0, abyte0.length); baosrsp = appendByteStream(baosrsp.toByteArray()); - // make sure we indicate no more to be sent baosrsp.write(IAC); baosrsp.write(EOR); - baosrsp.writeTo(bout); - // byte[] b = new byte[baosrsp.size()]; // b = baosrsp.toByteArray(); // dump(b); @@ -808,7 +822,6 @@ } protected final int getOpCode() { - return bk.getOpCode(); } @@ -819,70 +832,63 @@ protected boolean[] getActiveAidKeys() { boolean aids[] = new boolean[dataIncluded.length]; - System.arraycopy(dataIncluded,0,aids,0,dataIncluded.length); + System.arraycopy(dataIncluded, 0, aids, 0, dataIncluded.length); return aids; } private final void setInvited() { - - Log.d(TAG,"invited"); + Log.d(TAG, "invited"); + if (!screen52.isStatusErrorCode()) screen52.getOIA().setInputInhibited(ScreenOIA.INPUTINHIBITED_NOTINHIBITED, - ScreenOIA.OIA_LEVEL_INPUT_INHIBITED); + ScreenOIA.OIA_LEVEL_INPUT_INHIBITED); invited = true; } // WVL - LDC : 05/08/2005 : TFX.006253 - Support STRPCCMD - private void strpccmd() - { - try - { + private void strpccmd() { + try { int str = 11; char c; ScreenPlanes planes = screen52.getPlanes(); c = planes.getChar(str); boolean waitFor = !(c == 'a'); - StringBuffer command = new StringBuffer(); - for (int i = str+1; i < 132; i++) - { + + for (int i = str + 1; i < 132; i++) { c = planes.getChar(i); + if (Character.isISOControl(c)) c = ' '; + command.append(c); } String cmd = command.toString().trim(); - run(cmd, waitFor); } - finally - { + finally { strpccmd = false; screen52.sendKeys(TN5250jConstants.MNEMONIC_ENTER); } } // WVL - LDC : 05/08/2005 : TFX.006253 - Support STRPCCMD - private void run(String cmd, boolean waitFor) - { - try - { - Log.d(TAG,"RUN cmd = " + cmd); - Log.d(TAG,"RUN wait = " + waitFor); - + private void run(String cmd, boolean waitFor) { + try { + Log.d(TAG, "RUN cmd = " + cmd); + Log.d(TAG, "RUN wait = " + waitFor); Runtime r = Runtime.getRuntime(); Process p = r.exec(cmd); - if (waitFor) - { + + if (waitFor) { int result = p.waitFor(); - Log.d(TAG,"RUN result = " + result); + Log.d(TAG, "RUN result = " + result); } } - catch (Throwable t) - { - Log.e(TAG,"exception",t); + catch (Throwable t) { + Log.e(TAG, "exception", t); } } @@ -921,7 +927,6 @@ private void scan() { // System.out.println("Checking command : " + // screen52.screen[1].getChar() + screen52.screen[2].getChar()); - // ScreenChar[] screen = screen52.screen; ScreenPlanes planes = screen52.getPlanes(); @@ -930,8 +935,9 @@ && (planes.getChar(STRSCAN + 2) != ' ')) { try { parseCommand(); - } catch (Throwable t) { - Log.i(TAG,"Exec cmd: " + t.getMessage()); + } + catch (Throwable t) { + Log.i(TAG, "Exec cmd: " + t.getMessage()); t.printStackTrace(); } } @@ -962,51 +968,48 @@ // after the #! sequence separated by a space from the rest // of the screen. char[] screen = screen52.getScreenAsChars(); + for (int s = STRSCAN + 2, i = s; i < screen.length; i++) { if (screen[i] == ' ') { String command = new String(screen, s, i - s); - // Skip all white spaces between the command and the rest of // the screen. //for (; (i < screen.length) && (screen[i] == ' '); i++); - String remainder = new String(screen, i + 1, screen.length - - (i + 1)); + - (i + 1)); //controller.fireScanned(command, remainder); - Log.i(TAG,"trying to run " + command + " " + remainder); + Log.i(TAG, "trying to run " + command + " " + remainder); break; } } } public void run() { - if (enhanced) sfParser = new WTDSFParser(this); bk = new Stream5250(); while (keepTrucking) { - try { Object e = dsq.poll(0L, TimeUnit.SECONDS); + if (e == null) { buffer.testChanged(); e = dsq.take(); }; + bk.initialize((byte[])e); - } catch (InterruptedException ie) { - Log.w(TAG," vt thread interrupted and stopping "); + } + catch (InterruptedException ie) { + Log.w(TAG, " vt thread interrupted and stopping "); keepTrucking = false; continue; } // lets play nicely with the others on the playground // me.yield(); - Thread.yield(); - invited = false; - screen52.setCursorActive(false); // System.out.println("operation code: " + bk.getOpCode()); @@ -1014,79 +1017,91 @@ continue; switch (bk.getOpCode()) { - case 00: - Log.d(TAG,"No operation"); - break; - case 1: - Log.d(TAG,"Invite Operation"); - parseIncoming(); - // screen52.setKeyboardLocked(false); - pendingUnlock = true; - cursorOn = true; - setInvited(); - break; - case 2: - Log.d(TAG,"Output Only"); - parseIncoming(); - screen52.updateDirty(); - break; - case 3: - Log.d(TAG,"Put/Get Operation"); - parseIncoming(); - setInvited(); - if (!firstScreen) { - firstScreen = true; - //controller.fireSessionChanged(TN5250jConstants.STATE_CONNECTED); - } - break; - case 4: - Log.d(TAG,"Save Screen Operation"); - parseIncoming(); - break; - - case 5: - Log.d(TAG,"Restore Screen Operation"); - parseIncoming(); - break; - case 6: - Log.d(TAG,"Read Immediate"); - sendAidKey(0); - break; - case 7: - Log.d(TAG,"Reserved"); - break; - case 8: - Log.d(TAG,"Read Screen Operation"); - try { - readScreen(); - } catch (IOException ex) { - Log.w(TAG,ex.getMessage()); - } - break; - - case 9: - Log.d(TAG,"Reserved"); - break; - - case 10: - Log.d(TAG,"Cancel Invite Operation"); - cancelInvite(); - break; - - case 11: - Log.d(TAG,"Turn on message light"); - screen52.getOIA().setMessageLightOn(); - screen52.setCursorActive(true); - - break; - case 12: - Log.d(TAG,"Turn off Message light"); - screen52.getOIA().setMessageLightOff(); - screen52.setCursorActive(true); - - break; - default: - break; + case 00: + Log.d(TAG, "No operation"); + break; + + case 1: + Log.d(TAG, "Invite Operation"); + parseIncoming(); + // screen52.setKeyboardLocked(false); + pendingUnlock = true; + cursorOn = true; + setInvited(); + break; + + case 2: + Log.d(TAG, "Output Only"); + parseIncoming(); + screen52.updateDirty(); + break; + + case 3: + Log.d(TAG, "Put/Get Operation"); + parseIncoming(); + setInvited(); + + if (!firstScreen) { + firstScreen = true; + //controller.fireSessionChanged(TN5250jConstants.STATE_CONNECTED); + } + + break; + + case 4: + Log.d(TAG, "Save Screen Operation"); + parseIncoming(); + break; + + case 5: + Log.d(TAG, "Restore Screen Operation"); + parseIncoming(); + break; + + case 6: + Log.d(TAG, "Read Immediate"); + sendAidKey(0); + break; + + case 7: + Log.d(TAG, "Reserved"); + break; + + case 8: + Log.d(TAG, "Read Screen Operation"); + + try { + readScreen(); + } + catch (IOException ex) { + Log.w(TAG, ex.getMessage()); + } + + break; + + case 9: + Log.d(TAG, "Reserved"); + break; + + case 10: + Log.d(TAG, "Cancel Invite Operation"); + cancelInvite(); + break; + + case 11: + Log.d(TAG, "Turn on message light"); + screen52.getOIA().setMessageLightOn(); + screen52.setCursorActive(true); + break; + + case 12: + Log.d(TAG, "Turn off Message light"); + screen52.getOIA().setMessageLightOff(); + screen52.setCursorActive(true); + break; + + default: + break; } if (screen52.isUsingGuiInterface()) @@ -1095,11 +1110,13 @@ try { if (!strpccmd) { screen52.updateDirty(); - } else { + } + else { strpccmd(); } - } catch (Exception exd) { - Log.w(TAG," tnvt.run: " + exd.getMessage()); + } + catch (Exception exd) { + Log.w(TAG, " tnvt.run: " + exd.getMessage()); exd.printStackTrace(); } @@ -1116,16 +1133,15 @@ // lets play nicely with the others on the playground //me.yield(); Thread.yield(); - } } public void dumpStuff() { - Log.d(TAG," Pending unlock " + pendingUnlock); - Log.d(TAG," Status Error " + screen52.isStatusErrorCode()); - Log.d(TAG," Keyboard Locked " + screen52.getOIA().isKeyBoardLocked()); - Log.d(TAG," Cursor On " + cursorOn); - Log.d(TAG," Cursor Active " + screen52.cursorActive); + Log.d(TAG, " Pending unlock " + pendingUnlock); + Log.d(TAG, " Status Error " + screen52.isStatusErrorCode()); + Log.d(TAG, " Keyboard Locked " + screen52.getOIA().isKeyBoardLocked()); + Log.d(TAG, " Cursor On " + cursorOn); + Log.d(TAG, " Cursor Active " + screen52.cursorActive); } @@ -1142,20 +1158,20 @@ int la = 32; int sac = 0; int len = rows * cols; - ScreenPlanes planes = screen52.planes; for (int y = 0; y < len; y++) { // save the screen data - if (planes.isAttributePlace(y)) { la = planes.getCharAttr(y); sa[sac++] = (byte) la; - } else { + } + else { if (planes.getCharAttr(y) != la) { la = planes.getCharAttr(y); sac--; sa[sac++] = (byte) la; } + //LDC: Check to see if it is an displayable character. If not, // do not convert the character. // The characters on screen are in unicode @@ -1163,8 +1179,10 @@ // (byte)codePage.uni2ebcdic(screen52.screen[y].getChar()); char ch = planes.getChar(y); byte byteCh = (byte) ch; + if (isDataUnicode(ch)) byteCh = codePage.uni2ebcdic(ch); + sa[sac++] = byteCh; } } @@ -1172,32 +1190,27 @@ private final void fillRegenerationBuffer(ByteArrayOutputStream sc, int rows, int cols) throws IOException { - int la = 32; int sac = 0; int len = rows * cols; - ScreenPlanes planes = screen52.planes; byte[] sa = new byte[len]; try { boolean guiExists = sfParser != null && sfParser.isGuisExists(); - for (int y = 0; y < len; y++) { // save the screen data - if (guiExists) { - byte[] guiSeg = sfParser.getSegmentAtPos(y); + if (guiSeg != null) { //Log.i(TAG," gui saved at " + y + " - " + screen52.getRow(y) + "," + // screen52.getCol(y)); - byte[] gsa = new byte[sa.length + guiSeg.length + 2]; - System.arraycopy(sa,0,gsa,0,sa.length); - System.arraycopy(guiSeg,0,gsa,sac+2,guiSeg.length); + System.arraycopy(sa, 0, gsa, 0, sa.length); + System.arraycopy(guiSeg, 0, gsa, sac + 2, guiSeg.length); sa = new byte[gsa.length]; - System.arraycopy(gsa,0,sa,0,gsa.length); + System.arraycopy(gsa, 0, sa, 0, gsa.length); sa[sac++] = (byte)0x04; sa[sac++] = (byte)0x11; sac += guiSeg.length; @@ -1205,15 +1218,18 @@ // continue; } } + if (planes.isAttributePlace(y)) { la = planes.getCharAttr(y); sa[sac++] = (byte) la; - } else { + } + else { if (planes.getCharAttr(y) != la) { la = planes.getCharAttr(y); sac--; sa[sac++] = (byte) la; } + //LDC: Check to see if it is an displayable character. If not, // do not convert the character. // The characters on screen are in unicode @@ -1221,79 +1237,78 @@ // (byte)codePage.uni2ebcdic(screen52.screen[y].getChar()); char ch = planes.getChar(y); byte byteCh = (byte) ch; + if (isDataUnicode(ch)) byteCh = codePage.uni2ebcdic(ch); + sa[sac++] = byteCh; } } } - catch(Exception exc) { - - Log.i(TAG,exc.getMessage()); + catch (Exception exc) { + Log.i(TAG, exc.getMessage()); exc.printStackTrace(); } + sc.write(sa); } public final void saveScreen() throws IOException { - ByteArrayOutputStream sc = new ByteArrayOutputStream(); sc.write(4); sc.write(0x12); // 18 sc.write(0); // 18 sc.write(0); // 18 - sc.write((byte) screen52.getRows()); // store the current size sc.write((byte) screen52.getColumns()); // "" - int cp = screen52.getCurrentPos(); // save off current position // fix below submitted by Mitch Blevins //int cp = screen52.getScreenFields().getCurrentFieldPos(); // save off current position - sc.write((byte) (cp >> 8 & 0xff)); // "" - sc.write((byte) (cp & 0xff)); // "" - - sc.write((byte) (screen52.homePos >> 8 & 0xff)); // save home pos - sc.write((byte) (screen52.homePos & 0xff)); // "" - + sc.write((byte)(cp >> 8 & 0xff)); // "" + sc.write((byte)(cp & 0xff)); // "" + sc.write((byte)(screen52.homePos >> 8 & 0xff)); // save home pos + sc.write((byte)(screen52.homePos & 0xff)); // "" int rows = screen52.getRows(); // store the current size int cols = screen52.getColumns(); // "" - // byte[] sa = new byte[rows * cols]; - fillRegenerationBuffer(sc,rows,cols); + fillRegenerationBuffer(sc, rows, cols); // fillScreenArray(sa, rows, cols); // // sc.write(sa); // sa = null; int sizeFields = screen52.getScreenFields().getSize(); - sc.write((byte) (sizeFields >> 8 & 0xff)); // "" - sc.write((byte) (sizeFields & 0xff)); // "" + sc.write((byte)(sizeFields >> 8 & 0xff)); // "" + sc.write((byte)(sizeFields & 0xff)); // "" if (sizeFields > 0) { int x = 0; int s = screen52.getScreenFields().getSize(); ScreenField sf = null; + while (x < s) { sf = screen52.getScreenFields().getField(x); sc.write((byte) sf.getAttr()); // attribute int sp = sf.startPos(); - sc.write((byte) (sp >> 8 & 0xff)); // "" - sc.write((byte) (sp & 0xff)); // "" + sc.write((byte)(sp >> 8 & 0xff)); // "" + sc.write((byte)(sp & 0xff)); // "" + if (sf.mdt) sc.write((byte) 1); else sc.write((byte) 0); - sc.write((byte) (sf.getLength() >> 8 & 0xff)); // "" - sc.write((byte) (sf.getLength() & 0xff)); // "" + + sc.write((byte)(sf.getLength() >> 8 & 0xff)); // "" + sc.write((byte)(sf.getLength() & 0xff)); // "" sc.write((byte) sf.getFFW1() & 0xff); sc.write((byte) sf.getFFW2() & 0xff); sc.write((byte) sf.getFCW1() & 0xff); sc.write((byte) sf.getFCW2() & 0xff); - Log.d(TAG,"Saved "); - Log.d(TAG,sf.toString()); - + Log.d(TAG, "Saved "); + Log.d(TAG, sf.toString()); x++; } + sf = null; } @@ -1305,13 +1320,13 @@ try { writeGDS(0, 3, sc.toByteArray()); - } catch (IOException ioe) { - - Log.w(TAG,ioe.getMessage()); + } + catch (IOException ioe) { + Log.w(TAG, ioe.getMessage()); } sc = null; - Log.d(TAG,"Save Screen end "); + Log.d(TAG, "Save Screen end "); } /** @@ -1320,37 +1335,37 @@ */ public final void restoreScreen() throws IOException { int which = 0; - ScreenPlanes planes = screen52.planes; try { - Log.d(TAG,"Restore "); - + Log.d(TAG, "Restore "); bk.getNextByte(); bk.getNextByte(); - int rows = bk.getNextByte() & 0xff; int cols = bk.getNextByte() & 0xff; int pos = bk.getNextByte() << 8 & 0xff00; // current position pos |= bk.getNextByte() & 0xff; int hPos = bk.getNextByte() << 8 & 0xff00; // home position hPos |= bk.getNextByte() & 0xff; + if ((rows != screen52.getRows()) || (cols != screen52.getColumns())) screen52.setRowsCols(rows, cols); + screen52.clearAll(); // initialize what we currenty have + if (sfParser != null && sfParser.isGuisExists()) sfParser.clearGuiStructs(); int b = 32; int la = 32; int len = rows * cols; + for (int y = 0; y < len; y++) { - b = bk.getNextByte(); + if (b == 0x04) { - - Log.i(TAG," gui restored at " + y + " - " + screen52.getRow(y) + "," + - screen52.getCol(y)); + Log.i(TAG, " gui restored at " + y + " - " + screen52.getRow(y) + "," + + screen52.getCol(y)); int command = bk.getNextByte(); byte[] seg = bk.getSegment(); @@ -1358,6 +1373,7 @@ screen52.goto_XY(y); sfParser.parseWriteToDisplayStructuredField(seg); } + y--; // screen52.goto_XY(y); } @@ -1365,10 +1381,10 @@ // b = bk.getNextByte(); if (planes.isUseGui(y)) continue; + if (isAttribute(b)) { planes.setScreenCharAndAttr(y, planes.getChar(y), b, true); la = b; - } else { //LDC - 12/02/2003 - Check to see if it is an displayable @@ -1376,6 +1392,7 @@ // do not convert the character. // The characters on screen are in unicode char ch = (char) b; + if (isDataEBCDIC(b)) ch = codePage.ebcdic2uni(b); @@ -1386,7 +1403,7 @@ int numFields = bk.getNextByte() << 8 & 0xff00; numFields |= bk.getNextByte() & 0xff; - Log.d(TAG,"number of fields " + numFields); + Log.d(TAG, "number of fields " + numFields); if (numFields > 0) { int x = 0; @@ -1398,41 +1415,40 @@ int fcw1 = 0; int fcw2 = 0; boolean mdt = false; - ScreenField sf = null; + while (x < numFields) { - attr = bk.getNextByte(); fPos = bk.getNextByte() << 8 & 0xff00; fPos |= bk.getNextByte() & 0xff; + if (bk.getNextByte() == 1) mdt = true; else mdt = false; + fLen = bk.getNextByte() << 8 & 0xff00; fLen |= bk.getNextByte() & 0xff; ffw1 = bk.getNextByte(); ffw2 = bk.getNextByte(); fcw1 = bk.getNextByte(); fcw2 = bk.getNextByte(); - sf = screen52.getScreenFields().setField(attr, screen52.getRow(fPos), screen52.getCol(fPos), fLen, ffw1, ffw2, fcw1, fcw2); while (fLen-- > 0) { - // now we set the field plane attributes - planes.setScreenFieldAttr(fPos++,ffw1); - + planes.setScreenFieldAttr(fPos++, ffw1); } if (mdt) { sf.setMDT(); screen52.getScreenFields().setMasterMDT(); } - Log.d(TAG,"/nRestored "); - Log.d(TAG,sf.toString()); + + Log.d(TAG, "/nRestored "); + Log.d(TAG, sf.toString()); x++; } } @@ -1442,13 +1458,12 @@ screen52.drawFields(); screen52.restoreScreen(); // display the screen - // The position was saved with currentPos which 1,1 offset of the // screen position. // The setPendingInsert is the where the cursor position will be // displayed after the restore. screen52.setPendingInsert(true, screen52.getRow(pos + cols), screen52 - .getCol(pos + cols)); + .getCol(pos + cols)); // We need to offset the pos by -1 since the position is 1,1 based // and the goto_XY is 0,0 based. screen52.goto_XY(pos - 1); @@ -1456,19 +1471,18 @@ // // Redraw the gui fields if we are in gui mode // if (screen52.isUsingGuiInterface()) // screen52.drawFields(); - } catch (Exception e) { - Log.w(TAG,"error restoring screen " + which + " with " - + e.getMessage()); + } + catch (Exception e) { + Log.w(TAG, "error restoring screen " + which + " with " + + e.getMessage()); } } public final boolean waitingForInput() { - return waitingForInput; } private void parseIncoming() { - boolean done = false; boolean error = false; @@ -1477,129 +1491,143 @@ byte b = bk.getNextByte(); switch (b) { - case 0: - case 1: - break; - case CMD_SAVE_SCREEN: // 0x02 2 Save Screen - case 3: // 0x03 3 Save Partial Screen - Log.d(TAG,"save screen partial"); - saveScreen(); - break; - - case ESC: // ESCAPE - break; - case 7: // audible bell - manager.playBeep(); - bk.getNextByte(); - bk.getNextByte(); - break; - case CMD_WRITE_TO_DISPLAY: // 0x11 17 write to display - error = writeToDisplay(true); - // WVL - LDC : TR.000300 : Callback scenario from 5250 - // Only scan when WRITE_TO_DISPLAY operation (i.e. refill - // screen buffer) - // has been issued! - if (scan) - scan(); - - break; - case CMD_RESTORE_SCREEN: // 0x12 18 Restore Screen - case 13: // 0x13 19 Restore Partial Screen - Log.d(TAG,"restore screen partial"); - restoreScreen(); - break; - - case CMD_CLEAR_UNIT_ALTERNATE: // 0x20 32 clear unit alternate - int param = bk.getNextByte(); - if (param != 0) { - Log.d(TAG," clear unit alternate error " - + Integer.toHexString(param)); - sendNegResponse(NR_REQUEST_ERROR, 03, 01, 05, - " clear unit alternate not supported"); - done = true; - } else { - if (screen52.getRows() != 27) - screen52.setRowsCols(27, 132); + case 0: + case 1: + break; + + case CMD_SAVE_SCREEN: // 0x02 2 Save Screen + case 3: // 0x03 3 Save Partial Screen + Log.d(TAG, "save screen partial"); + saveScreen(); + break; + + case ESC: // ESCAPE + break; + + case 7: // audible bell + manager.playBeep(); + bk.getNextByte(); + bk.getNextByte(); + break; + + case CMD_WRITE_TO_DISPLAY: // 0x11 17 write to display + error = writeToDisplay(true); + + // WVL - LDC : TR.000300 : Callback scenario from 5250 + // Only scan when WRITE_TO_DISPLAY operation (i.e. refill + // screen buffer) + // has been issued! + if (scan) + scan(); + + break; + + case CMD_RESTORE_SCREEN: // 0x12 18 Restore Screen + case 13: // 0x13 19 Restore Partial Screen + Log.d(TAG, "restore screen partial"); + restoreScreen(); + break; + + case CMD_CLEAR_UNIT_ALTERNATE: // 0x20 32 clear unit alternate + int param = bk.getNextByte(); + + if (param != 0) { + Log.d(TAG, " clear unit alternate error " + + Integer.toHexString(param)); + sendNegResponse(NR_REQUEST_ERROR, 03, 01, 05, + " clear unit alternate not supported"); + done = true; + } + else { + if (screen52.getRows() != 27) + screen52.setRowsCols(27, 132); + + screen52.clearAll(); + + if (sfParser != null && sfParser.isGuisExists()) + sfParser.clearGuiStructs(); + } + + break; + + case CMD_WRITE_ERROR_CODE: // 0x21 33 Write Error Code + writeErrorCode(); + error = writeToDisplay(false); + break; + + case CMD_WRITE_ERROR_CODE_TO_WINDOW: // 0x22 34 + // Write Error Code to window + writeErrorCodeToWindow(); + error = writeToDisplay(false); + break; + + case CMD_READ_SCREEN_IMMEDIATE: // 0x62 98 + case CMD_READ_SCREEN_TO_PRINT: // 0x66 102 read screen to print + readScreen(); + break; + + case CMD_CLEAR_UNIT: // 64 0x40 clear unit + if (screen52.getRows() != 24) + screen52.setRowsCols(24, 80); screen52.clearAll(); + if (sfParser != null && sfParser.isGuisExists()) sfParser.clearGuiStructs(); - - } - break; - - case CMD_WRITE_ERROR_CODE: // 0x21 33 Write Error Code - writeErrorCode(); - error = writeToDisplay(false); - break; - case CMD_WRITE_ERROR_CODE_TO_WINDOW: // 0x22 34 - // Write Error Code to window - writeErrorCodeToWindow(); - error = writeToDisplay(false); - break; - - case CMD_READ_SCREEN_IMMEDIATE: // 0x62 98 - case CMD_READ_SCREEN_TO_PRINT: // 0x66 102 read screen to print - readScreen(); - break; - - case CMD_CLEAR_UNIT: // 64 0x40 clear unit - if (screen52.getRows() != 24) - screen52.setRowsCols(24, 80); - screen52.clearAll(); - if (sfParser != null && sfParser.isGuisExists()) - sfParser.clearGuiStructs(); - - break; - - case CMD_CLEAR_FORMAT_TABLE: // 80 0x50 Clear format table - screen52.clearTable(); - break; - - case CMD_READ_INPUT_FIELDS: //0x42 66 read input fields - case CMD_READ_MDT_FIELDS: // 0x52 82 read MDT Fields - bk.getNextByte(); - bk.getNextByte(); - readType = b; - screen52.goHome(); - // do nothing with the cursor here it is taken care of - // in the main loop. - //////////////// screen52.setCursorOn(); - waitingForInput = true; - pendingUnlock = true; - // screen52.setKeyboardLocked(false); - break; - case CMD_READ_MDT_IMMEDIATE_ALT: // 0x53 83 - readType = b; - // screen52.goHome(); - // waitingForInput = true; - // screen52.setKeyboardLocked(false); - readImmediate(readType); - break; - case CMD_WRITE_STRUCTURED_FIELD: // 243 0xF3 -13 Write - // structured field - writeStructuredField(); - break; - case CMD_ROLL: // 0x23 35 Roll Not sure what it does right now - int updown = bk.getNextByte(); - int topline = bk.getNextByte(); - int bottomline = bk.getNextByte(); - screen52.rollScreen(updown, topline, bottomline); - break; - - default: - done = true; - sendNegResponse(NR_REQUEST_ERROR, 03, 01, 01, - "parseIncoming"); - break; + break; + + case CMD_CLEAR_FORMAT_TABLE: // 80 0x50 Clear format table + screen52.clearTable(); + break; + + case CMD_READ_INPUT_FIELDS: //0x42 66 read input fields + case CMD_READ_MDT_FIELDS: // 0x52 82 read MDT Fields + bk.getNextByte(); + bk.getNextByte(); + readType = b; + screen52.goHome(); + // do nothing with the cursor here it is taken care of + // in the main loop. + //////////////// screen52.setCursorOn(); + waitingForInput = true; + pendingUnlock = true; + // screen52.setKeyboardLocked(false); + break; + + case CMD_READ_MDT_IMMEDIATE_ALT: // 0x53 83 + readType = b; + // screen52.goHome(); + // waitingForInput = true; + // screen52.setKeyboardLocked(false); + readImmediate(readType); + break; + + case CMD_WRITE_STRUCTURED_FIELD: // 243 0xF3 -13 Write + // structured field + writeStructuredField(); + break; + + case CMD_ROLL: // 0x23 35 Roll Not sure what it does right now + int updown = bk.getNextByte(); + int topline = bk.getNextByte(); + int bottomline = bk.getNextByte(); + screen52.rollScreen(updown, topline, bottomline); + break; + + default: + done = true; + sendNegResponse(NR_REQUEST_ERROR, 03, 01, 01, + "parseIncoming"); + break; } if (error) done = true; } - } catch (Exception exc) { - Log.w(TAG,"incoming " + exc.getMessage()); + } + catch (Exception exc) { + Log.w(TAG, "incoming " + exc.getMessage()); } } @@ -1618,17 +1646,15 @@ * */ protected void sendNegResponse(int cat, int modifier, int uByte1, - int uByte2, String from) { - + int uByte2, String from) { try { - int os = bk.getByteOffset(-1) & 0xf0; int cp = (bk.getCurrentPos() - 1); - Log.i(TAG,"invalid " + from + " command " + os - + " at pos " + cp); - } catch (Exception e) { - - Log.w(TAG,"Send Negative Response error " + e.getMessage()); + Log.i(TAG, "invalid " + from + " command " + os + + " at pos " + cp); + } + catch (Exception e) { + Log.w(TAG, "Send Negative Response error " + e.getMessage()); } baosp.write(cat); @@ -1638,32 +1664,30 @@ try { writeGDS(128, 0, baosp.toByteArray()); - } catch (IOException ioe) { - - Log.w(TAG,ioe.getMessage()); } + catch (IOException ioe) { + Log.w(TAG, ioe.getMessage()); + } + baosp.reset(); - } public void sendNegResponse2(int ec) { - screen52.setPrehelpState(true, true, false); baosp.write(0x00); baosp.write(ec); try { writeGDS(1, 0, baosp.toByteArray()); - } catch (IOException ioe) { - - Log.w(TAG,ioe.getMessage()); + } + catch (IOException ioe) { + Log.w(TAG, ioe.getMessage()); } baosp.reset(); } private boolean writeToDisplay(boolean controlsExist) { - boolean error = false; boolean done = false; int attr; @@ -1678,303 +1702,306 @@ control1 = bk.getNextByte(); processCC0(control0); } + while (bk.hasNext() && !done) { // pos = bk.getCurrentPos(); - // int rowc = screen52.getCurrentRow(); // int colc = screen52.getCurrentCol(); - byte bytebk = bk.getNextByte(); switch (bytebk) { - - case 1: // SOH - Start of Header Order - Log.d(TAG,"SOH - Start of Header Order"); - error = processSOH(); - - break; - case 02: // RA - Repeat to address - Log.d(TAG,"RA - Repeat to address"); - int row = screen52.getCurrentRow(); - int col = screen52.getCurrentCol(); - - int toRow = bk.getNextByte(); - int toCol = bk.getNextByte() & 0xff; - if (toRow >= row) { - int repeat = bk.getNextByte(); + case 1: // SOH - Start of Header Order + Log.d(TAG, "SOH - Start of Header Order"); + error = processSOH(); + break; + + case 02: // RA - Repeat to address + Log.d(TAG, "RA - Repeat to address"); + int row = screen52.getCurrentRow(); + int col = screen52.getCurrentCol(); + int toRow = bk.getNextByte(); + int toCol = bk.getNextByte() & 0xff; + + if (toRow >= row) { + int repeat = bk.getNextByte(); + + // a little intelligence here I hope + if (row == 1 && col == 2 && toRow == screen52.getRows() + && toCol == screen52.getColumns()) + screen52.clearScreen(); + else { + if (repeat != 0) { + //LDC - 13/02/2003 - convert it to unicode + repeat = codePage.ebcdic2uni(repeat); + //repeat = getASCIIChar(repeat); + } + + int times = ((toRow * screen52.getColumns()) + toCol) + - ((row * screen52.getColumns()) + col); + + while (times-- >= 0) { + screen52.setChar(repeat); + } + } + } + else { + sendNegResponse(NR_REQUEST_ERROR, 0x05, 0x01, 0x23, + " RA invalid"); + error = true; + } + + break; + + case 03: // EA - Erase to address + Log.d(TAG, "EA - Erase to address"); + int EArow = screen52.getCurrentRow(); + int EAcol = screen52.getCurrentCol(); + int toEARow = bk.getNextByte(); + int toEACol = bk.getNextByte() & 0xff; + int EALength = bk.getNextByte() & 0xff; + + while (--EALength > 0) { + bk.getNextByte(); + } + + char EAAttr = (char) 0; // a little intelligence here I hope - if (row == 1 && col == 2 && toRow == screen52.getRows() - && toCol == screen52.getColumns()) - + if (EArow == 1 && EAcol == 2 + && toEARow == screen52.getRows() + && toEACol == screen52.getColumns()) screen52.clearScreen(); else { - if (repeat != 0) { - //LDC - 13/02/2003 - convert it to unicode - repeat = codePage.ebcdic2uni(repeat); - //repeat = getASCIIChar(repeat); + int times = ((toEARow * screen52.getColumns()) + toEACol) + - ((EArow * screen52.getColumns()) + EAcol); + + while (times-- >= 0) { + screen52.setChar(EAAttr); } - - int times = ((toRow * screen52.getColumns()) + toCol) - - ((row * screen52.getColumns()) + col); - while (times-- >= 0) { - screen52.setChar(repeat); - } - + } + + break; + + case 04: // Command - Escape + Log.d(TAG, "Command - Escape"); + done = true; + break; + + case 16: // TD - Transparent Data + Log.d(TAG, "TD - Transparent Data"); + int j = (bk.getNextByte() & 0xff) << 8 | bk.getNextByte() + & 0xff; // length + break; + + case 17: // SBA - set buffer address order (row column) + //Log.d(TAG,"SBA - set buffer address order (row column)"); + int saRow = bk.getNextByte(); + int saCol = bk.getNextByte() & 0xff; + + // make sure it is in bounds + if (saRow >= 0 && saRow <= screen52.getRows() && saCol >= 0 + && saCol <= screen52.getColumns()) { + screen52.setCursor(saRow, saCol); // now set screen + // position for output + } + else { + sendNegResponse(NR_REQUEST_ERROR, 0x05, 0x01, 0x22, + "invalid row/col order" + " saRow = " + saRow + + " saRows = " + screen52.getRows() + + " saCol = " + saCol); + error = true; } - } else { - sendNegResponse(NR_REQUEST_ERROR, 0x05, 0x01, 0x23, - " RA invalid"); - error = true; - } - break; - - case 03: // EA - Erase to address - Log.d(TAG,"EA - Erase to address"); - int EArow = screen52.getCurrentRow(); - int EAcol = screen52.getCurrentCol(); - - int toEARow = bk.getNextByte(); - int toEACol = bk.getNextByte() & 0xff; - int EALength = bk.getNextByte() & 0xff; - while (--EALength > 0) { - + + break; + + case 18: // WEA - Extended Attribute + Log.d(TAG, "WEA - Extended Attribute"); + bk.getNextByte(); bk.getNextByte(); - - } - char EAAttr = (char) 0; - - // a little intelligence here I hope - if (EArow == 1 && EAcol == 2 - && toEARow == screen52.getRows() - && toEACol == screen52.getColumns()) - - screen52.clearScreen(); - else { - int times = ((toEARow * screen52.getColumns()) + toEACol) - - ((EArow * screen52.getColumns()) + EAcol); - while (times-- >= 0) { - screen52.setChar(EAAttr); + break; + + case 19: // IC - Insert Cursor + Log.d(TAG, "IC - Insert Cursor"); + int icX = bk.getNextByte(); + int icY = bk.getNextByte() & 0xff; + + if (icX >= 0 && icX <= saRows && icY >= 0 && icY <= saCols) { + Log.d(TAG, " IC " + icX + " " + icY); + screen52.setPendingInsert(true, icX, icY); + } + else { + sendNegResponse(NR_REQUEST_ERROR, 0x05, 0x01, 0x22, + " IC/IM position invalid "); + error = true; + } + + break; + + case 20: // MC - Move Cursor + Log.d(TAG, "MC - Move Cursor"); + int imcX = bk.getNextByte(); + int imcY = bk.getNextByte() & 0xff; + + if (imcX >= 0 && imcX <= saRows && imcY >= 0 + && imcY <= saCols) { + Log.d(TAG, " MC " + imcX + " " + imcY); + screen52.setPendingInsert(false, imcX, imcY); + } + else { + sendNegResponse(NR_REQUEST_ERROR, 0x05, 0x01, 0x22, + " IC/IM position invalid "); + error = true; } - } - break; - case 04: // Command - Escape - Log.d(TAG,"Command - Escape"); - done = true; - break; - - case 16: // TD - Transparent Data - Log.d(TAG,"TD - Transparent Data"); - int j = (bk.getNextByte() & 0xff) << 8 | bk.getNextByte() - & 0xff; // length - break; - - case 17: // SBA - set buffer address order (row column) - //Log.d(TAG,"SBA - set buffer address order (row column)"); - int saRow = bk.getNextByte(); - int saCol = bk.getNextByte() & 0xff; - // make sure it is in bounds - if (saRow >= 0 && saRow <= screen52.getRows() && saCol >= 0 - && saCol <= screen52.getColumns()) { - screen52.setCursor(saRow, saCol); // now set screen - // position for output - - } else { - - sendNegResponse(NR_REQUEST_ERROR, 0x05, 0x01, 0x22, - "invalid row/col order" + " saRow = " + saRow - + " saRows = " + screen52.getRows() - + " saCol = " + saCol); - - error = true; - - } - break; - - case 18: // WEA - Extended Attribute - Log.d(TAG,"WEA - Extended Attribute"); - bk.getNextByte(); - bk.getNextByte(); - break; - - case 19: // IC - Insert Cursor - Log.d(TAG,"IC - Insert Cursor"); - int icX = bk.getNextByte(); - int icY = bk.getNextByte() & 0xff; - if (icX >= 0 && icX <= saRows && icY >= 0 && icY <= saCols) { - - Log.d(TAG," IC " + icX + " " + icY); - screen52.setPendingInsert(true, icX, icY); - } else { - sendNegResponse(NR_REQUEST_ERROR, 0x05, 0x01, 0x22, - " IC/IM position invalid "); - error = true; - } - - break; - - case 20: // MC - Move Cursor - Log.d(TAG,"MC - Move Cursor"); - int imcX = bk.getNextByte(); - int imcY = bk.getNextByte() & 0xff; - if (imcX >= 0 && imcX <= saRows && imcY >= 0 - && imcY <= saCols) { - - Log.d(TAG," MC " + imcX + " " + imcY); - screen52.setPendingInsert(false, imcX, imcY); - } else { - sendNegResponse(NR_REQUEST_ERROR, 0x05, 0x01, 0x22, - " IC/IM position invalid "); - error = true; - } - - break; - - case 21: // WTDSF - Write To Display Structured Field order - Log.d(TAG,"WTDSF - Write To Display Structured Field order"); - byte[] seg = bk.getSegment(); - error = sfParser.parseWriteToDisplayStructuredField(seg); - break; - - case 29: // SF - Start of Field - Log.d(TAG,"SF - Start of Field"); - int fcw1 = 0; - int fcw2 = 0; - int ffw1 = 0; - int ffw0 = bk.getNextByte() & 0xff; // FFW - - if ((ffw0 & 0x40) == 0x40) { - ffw1 = bk.getNextByte() & 0xff; // FFW 1 - - fcw1 = bk.getNextByte() & 0xff; // check for field - // control word - - // check if the first fcw1 is an 0x81 if it is then get - // the next pair for checking - if (fcw1 == 0x81) { - bk.getNextByte(); + + break; + + case 21: // WTDSF - Write To Display Structured Field order + Log.d(TAG, "WTDSF - Write To Display Structured Field order"); + byte[] seg = bk.getSegment(); + error = sfParser.parseWriteToDisplayStructuredField(seg); + break; + + case 29: // SF - Start of Field + Log.d(TAG, "SF - Start of Field"); + int fcw1 = 0; + int fcw2 = 0; + int ffw1 = 0; + int ffw0 = bk.getNextByte() & 0xff; // FFW + + if ((ffw0 & 0x40) == 0x40) { + ffw1 = bk.getNextByte() & 0xff; // FFW 1 fcw1 = bk.getNextByte() & 0xff; // check for field + // control word + + // check if the first fcw1 is an 0x81 if it is then get + // the next pair for checking + if (fcw1 == 0x81) { + bk.getNextByte(); + fcw1 = bk.getNextByte() & 0xff; // check for field + // control word + } + + if (!isAttribute(fcw1)) { + fcw2 = bk.getNextByte() & 0xff; // FCW 2 + attr = bk.getNextByte() & 0xff; // attribute field + + while (!isAttribute(attr)) { + Log.i(TAG, Integer.toHexString(fcw1) + " " + + Integer.toHexString(fcw2) + + " "); + Log.i(TAG, Integer.toHexString(attr) + + " " + + Integer.toHexString(bk + .getNextByte() & 0xff)); + attr = bk.getNextByte() & 0xff; // attribute field + } + } + else { + attr = fcw1; // attribute of field + fcw1 = 0; + } } - - if (!isAttribute(fcw1)) { - - fcw2 = bk.getNextByte() & 0xff; // FCW 2 - attr = bk.getNextByte() & 0xff; // attribute field - - while (!isAttribute(attr)) { - Log.i(TAG,Integer.toHexString(fcw1) + " " - + Integer.toHexString(fcw2) - + " "); - Log.i(TAG,Integer.toHexString(attr) - + " " - + Integer.toHexString(bk - .getNextByte() & 0xff)); - attr = bk.getNextByte() & 0xff; // attribute field - } - } else { - attr = fcw1; // attribute of field - fcw1 = 0; + else { + attr = ffw0; } - } else { - attr = ffw0; - } - - int fLength = (bk.getNextByte() & 0xff) << 8 - | bk.getNextByte() & 0xff; - screen52.addField(attr, fLength, ffw0, ffw1, fcw1, fcw2); - - break; + + int fLength = (bk.getNextByte() & 0xff) << 8 + | bk.getNextByte() & 0xff; + screen52.addField(attr, fLength, ffw0, ffw1, fcw1, fcw2); + break; + // WVL - LDC : 05/08/2005 : TFX.006253 - Support STRPCCMD - case -128: //STRPCCMD - // if (screen52.getCurrentPos() == 82) { - Log.d(TAG,"STRPCCMD got a -128 command at " + screen52.getCurrentPos()); - StringBuffer value = new StringBuffer(); - int b; - char c; - int[] pco = new int[9]; - int[] pcoOk = {0xfc, 0xd7, 0xc3, 0xd6, 0x40, 0x83, 0x80, 0xa1, 0x80}; - - for (int i = 0; i < 9; i++) - { - b = bk.getNextByte(); - pco[i] = ((b & 0xff)); - c = codePage.ebcdic2uni(b); - value.append(c); - } - - // Check "PCO-String" - if (Arrays.equals(pco, pcoOk)) { - strpccmd = true; - } - // we return in the stream to have all chars - // arrive at the screen for later processing - for (int i = 0; i < 9; i++) - bk.setPrevByte(); + case -128: //STRPCCMD + // if (screen52.getCurrentPos() == 82) { + Log.d(TAG, "STRPCCMD got a -128 command at " + screen52.getCurrentPos()); + StringBuffer value = new StringBuffer(); + int b; + char c; + int[] pco = new int[9]; + int[] pcoOk = {0xfc, 0xd7, 0xc3, 0xd6, 0x40, 0x83, 0x80, 0xa1, 0x80}; + + for (int i = 0; i < 9; i++) { + b = bk.getNextByte(); + pco[i] = ((b & 0xff)); + c = codePage.ebcdic2uni(b); + value.append(c); + } + + // Check "PCO-String" + if (Arrays.equals(pco, pcoOk)) { + strpccmd = true; + } + + // we return in the stream to have all chars + // arrive at the screen for later processing + for (int i = 0; i < 9; i++) + bk.setPrevByte(); + //} // no break: so every chars arrives // on the screen for later parsing //break; - default: // all others must be output to screen - //Log.d(TAG,"all others must be output to screen"); - byte byte0 = bk.getByteOffset(-1); - if (isAttribute(byte0)) { - screen52.setAttr(byte0); - } else { - if (!screen52.isStatusErrorCode()) { - if (!isDataEBCDIC(byte0)) { - // if (byte0 == 255) { - // sendNegResponse(NR_REQUEST_ERROR,0x05,0x01,0x42, - // " Attempt to send FF to screen"); - // } - // else - - screen52.setChar(byte0); - } else - //LDC - 13/02/2003 - Convert it to unicode - //screen52.setChar(getASCIIChar(byte0)); - screen52.setChar(codePage.ebcdic2uni(byte0)); - } else { - if (byte0 == 0) - screen52.setChar(byte0); - else - //LDC - 13/02/2003 - Convert it to unicode - //screen52.setChar(getASCIIChar(byte0)); - screen52.setChar(codePage.ebcdic2uni(byte0)); + default: // all others must be output to screen + //Log.d(TAG,"all others must be output to screen"); + byte byte0 = bk.getByteOffset(-1); + + if (isAttribute(byte0)) { + screen52.setAttr(byte0); } - } - - break; + else { + if (!screen52.isStatusErrorCode()) { + if (!isDataEBCDIC(byte0)) { + // if (byte0 == 255) { + // sendNegResponse(NR_REQUEST_ERROR,0x05,0x01,0x42, + // " Attempt to send FF to screen"); + // } + // else + screen52.setChar(byte0); + } + else + //LDC - 13/02/2003 - Convert it to unicode + //screen52.setChar(getASCIIChar(byte0)); + screen52.setChar(codePage.ebcdic2uni(byte0)); + } + else { + if (byte0 == 0) + screen52.setChar(byte0); + else + //LDC - 13/02/2003 - Convert it to unicode + //screen52.setChar(getASCIIChar(byte0)); + screen52.setChar(codePage.ebcdic2uni(byte0)); + } + } + + break; } if (error) done = true; } } - catch (Exception e) { - Log.w(TAG,"write to display " + e.getMessage()); + Log.w(TAG, "write to display " + e.getMessage()); e.printStackTrace(); } + ; processCC1(control1); return error; - } private boolean processSOH() throws Exception { - int l = bk.getNextByte(); // length - Log.d(TAG," byte 0 " + l); + Log.d(TAG, " byte 0 " + l); if (l > 0 && l <= 7) { bk.getNextByte(); // flag byte 2 bk.getNextByte(); // reserved bk.getNextByte(); // resequence fields - screen52.clearTable(); // well that is the first time I have seen this. This fixes a @@ -1982,8 +2009,8 @@ if (l <= 3) return false; screen52.setErrorLine(bk.getNextByte()); // error row - int byte1 = 0; + if (l >= 5) { byte1 = bk.getNextByte(); dataIncluded[23] = (byte1 & 0x80) == 0x80; @@ -2019,17 +2046,18 @@ dataIncluded[1] = (byte1 & 0x2) == 0x2; dataIncluded[0] = (byte1 & 0x1) == 0x1; } + return false; - } else { + } + else { sendNegResponse(NR_REQUEST_ERROR, 0x05, 0x01, 0x2B, - "invalid SOH length"); + "invalid SOH length"); return true; } - } private void processCC0(byte byte0) { - Log.d(TAG," Control byte0 " + Integer.toBinaryString(byte0 & 0xff)); + Log.d(TAG, " Control byte0 " + Integer.toBinaryString(byte0 & 0xff)); boolean lockKeyboard = true; boolean resetMDT = false; boolean resetMDTAll = false; @@ -2051,42 +2079,45 @@ // '11100000' = 0xE0 /224 switch (byte0 & 0xE0) { - - case 0x40: - resetMDT = true; - break; - case 0x60: - resetMDTAll = true; - break; - case 0x80: - nullMDT = true; - break; - case 0xA0: - resetMDT = true; - nullAll = true; - break; - case 0xC0: - resetMDT = true; - nullMDT = true; - break; - - case 0xE0: - resetMDTAll = true; - nullAll = true; - break; - + case 0x40: + resetMDT = true; + break; + + case 0x60: + resetMDTAll = true; + break; + + case 0x80: + nullMDT = true; + break; + + case 0xA0: + resetMDT = true; + nullAll = true; + break; + + case 0xC0: + resetMDT = true; + nullMDT = true; + break; + + case 0xE0: + resetMDTAll = true; + nullAll = true; + break; } if (lockKeyboard) { screen52.getOIA().setKeyBoardLocked(true); pendingUnlock = false; - } else + } + else pendingUnlock = false; if (resetMDT || resetMDTAll || nullMDT || nullAll) { ScreenField sf; - int f = screen52.getScreenFields().getSize(); + for (int x = 0; x < f; x++) { sf = screen52.getScreenFields().getField(x); @@ -2096,24 +2127,26 @@ screen52.drawField(sf); } } + if (resetMDTAll || (resetMDT && !sf.isBypassField())) sf.resetMDT(); - } + sf = null; } - } private void processCC1(byte byte1) { - Log.d(TAG," Control byte1 " + Integer.toBinaryString(byte1 & 0xff)); + Log.d(TAG, " Control byte1 " + Integer.toBinaryString(byte1 & 0xff)); if ((byte1 & 0x04) == 0x04) { manager.playBeep(); } + if ((byte1 & 0x02) == 0x02) { screen52.getOIA().setMessageLightOff(); } + if ((byte1 & 0x01) == 0x01) { screen52.getOIA().setMessageLightOn(); } @@ -2133,15 +2166,15 @@ // this seems to work so far if ((byte1 & 0x20) == 0x20 && (byte1 & 0x08) == 0x00) { screen52.setPendingInsert(false); - Log.d(TAG," WTD position no move"); - } else { - + Log.d(TAG, " WTD position no move"); + } + else { screen52.setPendingInsert(true); - Log.d(TAG," WTD position move to home" + screen52.homePos + " row " - + screen52.getRow(screen52.homePos) + " col " - + screen52.getCol(screen52.homePos)); - + Log.d(TAG, " WTD position move to home" + screen52.homePos + " row " + + screen52.getRow(screen52.homePos) + " col " + + screen52.getCol(screen52.homePos)); } + // in enhanced mode we sometimes only receive bit 6 turned on which // is reset blinking cursor if ((byte1 & 0x20) == 0x20 && enhanced) { @@ -2149,7 +2182,6 @@ } if (!screen52.isStatusErrorCode() && (byte1 & 0x08) == 0x08) { - // screen52.setStatus(screen52.STATUS_SYSTEM,screen52.STATUS_VALUE_OFF,null); cursorOn = true; } @@ -2157,7 +2189,6 @@ if ((byte1 & 0x20) == 0x20 && (byte1 & 0x08) == 0x00) { screen52.setPendingInsert(false, 1, 1); } - } private boolean isAttribute(int byte0) { @@ -2168,13 +2199,12 @@ //LDC - 12/02/2003 - Function name changed from isData to isDataEBCDIC private boolean isDataEBCDIC(int byte0) { int byte1 = byte0 & 0xff; + // here it should always be less than 255 if (byte1 >= 64 && byte1 < 255) - return true; else return false; - } //LDC - 12/02/2003 - Test if the unicode character is a displayable @@ -2187,45 +2217,47 @@ } private void writeStructuredField() { - boolean done = false; + try { int length = ((bk.getNextByte() & 0xff) << 8 | (bk.getNextByte() & 0xff)); + while (bk.hasNext() && !done) { switch (bk.getNextByte()) { - - case -39: // SOH - Start of Header Order - - switch (bk.getNextByte()) { - case 112: // 5250 Query - bk.getNextByte(); // get null required field - sendQueryResponse(); + case -39: // SOH - Start of Header Order + switch (bk.getNextByte()) { + case 112: // 5250 Query + bk.getNextByte(); // get null required field + sendQueryResponse(); + break; + + default: + Log.d(TAG, "invalid structured field sub command " + + bk.getByteOffset(-1)); + break; + } + break; + default: - Log.d(TAG,"invalid structured field sub command " - + bk.getByteOffset(-1)); + Log.d(TAG, "invalid structured field command " + + bk.getByteOffset(-1)); break; - } - break; - default: - Log.d(TAG,"invalid structured field command " - + bk.getByteOffset(-1)); - break; } } - } catch (Exception e) { + } + catch (Exception e) { } + ; - } private final void writeErrorCode() throws Exception { screen52.setCursor(screen52.getErrorLine(), 1); // Skip the control byte screen52.setStatus(Screen5250.STATUS_ERROR_CODE, - Screen5250.STATUS_VALUE_ON, null); + Screen5250.STATUS_VALUE_ON, null); screen52.saveErrorLine(); cursorOn = true; - } private final void writeErrorCodeToWindow() throws Exception { @@ -2234,10 +2266,9 @@ screen52.setCursor(screen52.getErrorLine(), fromCol); // Skip the control // byte screen52.setStatus(Screen5250.STATUS_ERROR_CODE, - Screen5250.STATUS_VALUE_ON, null); + Screen5250.STATUS_VALUE_ON, null); screen52.saveErrorLine(); cursorOn = true; - } /** @@ -2255,16 +2286,17 @@ * @throws IOException */ private final void sendQueryResponse() throws IOException { - - Log.i(TAG,"sending query response"); + Log.i(TAG, "sending query response"); byte abyte0[] = new byte[64]; abyte0[0] = 0; // Cursor Row/column (set to zero) abyte0[1] = 0; // "" abyte0[2] = -120; // X'88' inbound write structure Field aid + if (enhanced == true) { abyte0[3] = 0; // 0x003D (61) length of query response abyte0[4] = 64; // "" see note below ????????? - } else { + } + else { abyte0[3] = 0; // 0x003A (58) length of query response abyte0[4] = 58; // "" // the length between 58 and 64 seems to cause @@ -2273,6 +2305,7 @@ // Well the why can be found in the manual if // read a little more ;-) } + abyte0[5] = -39; // command class 0xD9 abyte0[6] = 112; // Command type query 0x70 abyte0[7] = -128; // 0x80 Flag byte @@ -2281,7 +2314,6 @@ abyte0[10] = 1; // Controller Code Level abyte0[11] = 1; // Version 1 Rel 1.0 abyte0[12] = 0; // "" - abyte0[13] = 0; // 13 - 28 are reserved so set to 0x00 abyte0[14] = 0; // "" abyte0[15] = 0; // "" @@ -2306,16 +2338,13 @@ abyte0[34] = codePage.uni2ebcdic('0'); // "" abyte0[35] = codePage.uni2ebcdic('1'); // "" abyte0[36] = codePage.uni2ebcdic('1'); // "" - abyte0[37] = 2; // Keyboard Id - 0x02 Standard Keyboard abyte0[38] = 0; // extended keyboard id abyte0[39] = 0; // reserved - abyte0[40] = 0; // 40 - 43 Display Serial Number abyte0[41] = 36; // abyte0[42] = 36; // abyte0[43] = 0; // - abyte0[44] = 1; // Maximum number of display fields - 256 abyte0[45] = 0; // 0x0100 abyte0[46] = 0; // 46 -48 Reserved set to 0x00 @@ -2335,8 +2364,9 @@ // abyte0[53] = 0x5E; // 0x5E turns on ehnhanced mode // abyte0[53] = 0x27; // 0x5E turns on ehnhanced mode abyte0[53] = 0x7; // 0x5E turns on ehnhanced mode - Log.i(TAG,"enhanced options"); - } else + Log.i(TAG, "enhanced options"); + } + else abyte0[53] = 0x0; // 0x0 is normal emulation abyte0[54] = 24; // 54 - 60 Reserved set to 0x00 @@ -2358,146 +2388,137 @@ abyte0[63] = 0; writeGDS(0, 0, abyte0); // now tell them about us abyte0 = null; - } protected final boolean negotiate(byte abyte0[]) throws IOException { int i = 0; - // from server negotiations - if(abyte0[i] == IAC) { // -1 - - while(i < abyte0.length && abyte0[i++] == -1) + if (abyte0[i] == IAC) { // -1 + while (i < abyte0.length && abyte0[i++] == -1) + // while(i < abyte0.length && (abyte0[i] == -1 || abyte0[i++] == 0x20)) - switch(abyte0[i++]) { - - // we will not worry about what it WONT do - case WONT: // -4 - default: - break; - - case DO: //-3 - - // not sure why but since moving to V5R2 we are receiving a - // DO with no option when connecting a second session with - // device name. Can not find the cause at all. If anybody - // is interested please debug this until then this works. - if (i < abyte0.length) { - switch(abyte0[i]) { - case TERMINAL_TYPE: // 24 + switch (abyte0[i++]) { + // we will not worry about what it WONT do + case WONT: // -4 + default: + break; + + case DO: //-3 + + // not sure why but since moving to V5R2 we are receiving a + // DO with no option when connecting a second session with + // device name. Can not find the cause at all. If anybody + // is interested please debug this until then this works. + if (i < abyte0.length) { + switch (abyte0[i]) { + case TERMINAL_TYPE: // 24 + baosp.write(IAC); + baosp.write(WILL); + baosp.write(TERMINAL_TYPE); + writeByte(baosp.toByteArray()); + baosp.reset(); + break; + + case OPT_END_OF_RECORD: // 25 + baosp.write(IAC); + baosp.write(WILL); + baosp.write(OPT_END_OF_RECORD); + writeByte(baosp.toByteArray()); + baosp.reset(); + break; + + case TRANSMIT_BINARY: // 0 + baosp.write(IAC); + baosp.write(WILL); + baosp.write(TRANSMIT_BINARY); + writeByte(baosp.toByteArray()); + baosp.reset(); + break; + + case TIMING_MARK: // 6 rfc860 + // System.out.println("Timing Mark Received and notifying " + + // "the server that we will not do it"); + baosp.write(IAC); + baosp.write(WONT); + baosp.write(TIMING_MARK); + writeByte(baosp.toByteArray()); + baosp.reset(); + break; + + case NEW_ENVIRONMENT: // 39 rfc1572, rfc4777 + // allways send new environment vars ... + baosp.write(IAC); + baosp.write(WILL); + baosp.write(NEW_ENVIRONMENT); + writeByte(baosp.toByteArray()); + baosp.reset(); + break; + + default: // every thing else we will not do at this time + baosp.write(IAC); + baosp.write(WONT); + baosp.write(abyte0[i]); // either + writeByte(baosp.toByteArray()); + baosp.reset(); + break; + } + } + + i++; + break; + + case WILL: + switch (abyte0[i]) { + case OPT_END_OF_RECORD: // 25 + baosp.write(IAC); + baosp.write(DO); + baosp.write(OPT_END_OF_RECORD); + writeByte(baosp.toByteArray()); + baosp.reset(); + break; + + case TRANSMIT_BINARY: // '\0' + baosp.write(IAC); + baosp.write(DO); + baosp.write(TRANSMIT_BINARY); + writeByte(baosp.toByteArray()); + baosp.reset(); + break; + } + + i++; + break; + + case SB: // -6 + if (abyte0[i] == NEW_ENVIRONMENT && abyte0[i + 1] == 1) { + negNewEnvironment(); + + while (++i < abyte0.length && abyte0[i + 1] != IAC); + } + + if (abyte0[i] == TERMINAL_TYPE && abyte0[i + 1] == 1) { baosp.write(IAC); - baosp.write(WILL); + baosp.write(SB); baosp.write(TERMINAL_TYPE); - writeByte(baosp.toByteArray()); - baosp.reset(); - - break; - - case OPT_END_OF_RECORD: // 25 + baosp.write(QUAL_IS); + + if (!support132) + baosp.write("IBM-3179-2".getBytes()); + else + baosp.write("IBM-3477-FC".getBytes()); baosp.write(IAC); - baosp.write(WILL); - baosp.write(OPT_END_OF_RECORD); - writeByte(baosp.toByteArray()); - baosp.reset(); - break; - - case TRANSMIT_BINARY: // 0 - - baosp.write(IAC); - baosp.write(WILL); - baosp.write(TRANSMIT_BINARY); - writeByte(baosp.toByteArray()); - baosp.reset(); - - break; - - case TIMING_MARK: // 6 rfc860 - // System.out.println("Timing Mark Received and notifying " + - // "the server that we will not do it"); - baosp.write(IAC); - baosp.write(WONT); - baosp.write(TIMING_MARK); - writeByte(baosp.toByteArray()); - baosp.reset(); - - break; - - case NEW_ENVIRONMENT: // 39 rfc1572, rfc4777 - // allways send new environment vars ... - baosp.write(IAC); - baosp.write(WILL); - baosp.write(NEW_ENVIRONMENT); + baosp.write(SE); writeByte(baosp.toByteArray()); baosp.reset(); - break; - - default: // every thing else we will not do at this time - baosp.write(IAC); - baosp.write(WONT); - baosp.write(abyte0[i]); // either - writeByte(baosp.toByteArray()); - baosp.reset(); - - break; + i++; } - } - - i++; - break; - - case WILL: - - switch(abyte0[i]) { - case OPT_END_OF_RECORD: // 25 - baosp.write(IAC); - baosp.write(DO); - baosp.write(OPT_END_OF_RECORD); - writeByte(baosp.toByteArray()); - baosp.reset(); - - break; - - case TRANSMIT_BINARY: // '\0' - baosp.write(IAC); - baosp.write(DO); - baosp.write(TRANSMIT_BINARY); - writeByte(baosp.toByteArray()); - baosp.reset(); - - break; - } - i++; - break; - - case SB: // -6 - - if(abyte0[i] == NEW_ENVIRONMENT && abyte0[i + 1] == 1) { - negNewEnvironment(); - - while (++i < abyte0.length && abyte0[i + 1] != IAC); - } - - if(abyte0[i] == TERMINAL_TYPE && abyte0[i + 1] == 1) { - baosp.write(IAC); - baosp.write(SB); - baosp.write(TERMINAL_TYPE); - baosp.write(QUAL_IS); - if(!support132) - baosp.write("IBM-3179-2".getBytes()); - else - baosp.write("IBM-3477-FC".getBytes()); - baosp.write(IAC); - baosp.write(SE); - writeByte(baosp.toByteArray()); - baosp.reset(); i++; - } - i++; - break; + break; } + return true; } else { @@ -2511,7 +2532,6 @@ * @throws IOException */ private void negNewEnvironment() throws IOException { - baosp.write(IAC); baosp.write(SB); baosp.write(NEW_ENVIRONMENT); @@ -2524,12 +2544,10 @@ baosp.write("KBDTYPE".getBytes()); baosp.write(VALUE); baosp.write(kbdTypesCodePage.kbdType.getBytes()); - baosp.write(USERVAR); baosp.write("CODEPAGE".getBytes()); baosp.write(VALUE); baosp.write(kbdTypesCodePage.codepage.getBytes()); - baosp.write(USERVAR); baosp.write("CHARSET".getBytes()); baosp.write(VALUE); @@ -2538,16 +2556,12 @@ if (devName != null) { baosp.write(USERVAR); - baosp.write("DEVNAME".getBytes()); - baosp.write(VALUE); - baosp.write(negDeviceName().getBytes()); } if (user != null) { - baosp.write(VAR); baosp.write("USER".getBytes()); baosp.write(VALUE); @@ -2593,12 +2607,11 @@ baosp.write(program.getBytes()); } } + baosp.write(IAC); baosp.write(SE); - writeByte(baosp.toByteArray()); baosp.reset(); - } /** @@ -2610,20 +2623,20 @@ * @return String */ private String negDeviceName() { - if (devSeq++ == -1) { devNameUsed = devName; return devName; - } else { + } + else { StringBuffer sb = new StringBuffer(devName + devSeq); int ei = 1; + while (sb.length() > 10) { - sb.setLength(0); sb.append(devName.substring(0, devName.length() - ei++)); sb.append(devSeq); - } + devNameUsed = sb.toString(); return devNameUsed; } @@ -2632,13 +2645,15 @@ public final void setCodePage(String cp) { codePage = CharMappings.getCodePage(cp); cp = cp.toLowerCase(); + for (KbdTypesCodePages kbdtyp : KbdTypesCodePages.values()) { - if (("cp"+kbdtyp.codepage).equals(cp) || kbdtyp.ccsid.equals(cp)) { + if (("cp" + kbdtyp.codepage).equals(cp) || kbdtyp.ccsid.equals(cp)) { kbdTypesCodePage = kbdtyp; break; } } - Log.i(TAG,"Chose keyboard mapping " + kbdTypesCodePage.toString() + " for code page " + cp); + + Log.i(TAG, "Chose keyboard mapping " + kbdTypesCodePage.toString() + " for code page " + cp); } public final ICodePage getCodePage() { diff -r 6a0ad4d384ea -r 77ac18bc1b2f src/org/tn5250j/framework/transport/SSL/SSLImplementation.java --- a/src/org/tn5250j/framework/transport/SSL/SSLImplementation.java Wed Jun 18 13:00:19 2014 -0700 +++ b/src/org/tn5250j/framework/transport/SSL/SSLImplementation.java Wed Jun 18 13:03:01 2014 -0700 @@ -57,149 +57,157 @@ */ public class SSLImplementation implements SSLInterface, X509TrustManager { private static final String TAG = "SSLImplementation"; - SSLContext sslContext = null; - KeyStore userks = null; - private String userKsPath; - private char[] userksPassword = "changeit".toCharArray(); + SSLContext sslContext = null; + KeyStore userks = null; + private String userKsPath; + private char[] userksPassword = "changeit".toCharArray(); TerminalBridge bridge = null; TerminalManager manager = null; String target = null; // destination:port - KeyManagerFactory userkmf = null; + KeyManagerFactory userkmf = null; - TrustManagerFactory usertmf = null; + TrustManagerFactory usertmf = null; - TrustManager[] userTrustManagers = null; + TrustManager[] userTrustManagers = null; - X509Certificate[] acceptedIssuers; + X509Certificate[] acceptedIssuers; - public SSLImplementation(TerminalBridge bridge, TerminalManager manager) { + public SSLImplementation(TerminalBridge bridge, TerminalManager manager) { this.bridge = bridge; this.manager = manager; - - } + } - public void init(String sslType, String homeDirectory) { - try { - Log.d(TAG,"Initializing User KeyStore"); - userKsPath = homeDirectory + File.separator + "keystore"; - File userKsFile = new File(userKsPath); - userks = KeyStore.getInstance(KeyStore.getDefaultType()); - userks.load(userKsFile.exists() ? new FileInputStream(userKsFile) - : null, userksPassword); - Log.d(TAG,"Initializing User Key Manager Factory"); - userkmf = KeyManagerFactory.getInstance(KeyManagerFactory - .getDefaultAlgorithm()); - userkmf.init(userks, userksPassword); - Log.d(TAG,"Initializing User Trust Manager Factory"); - usertmf = TrustManagerFactory.getInstance(TrustManagerFactory - .getDefaultAlgorithm()); - usertmf.init(userks); - userTrustManagers = usertmf.getTrustManagers(); - Log.d(TAG,"Initializing SSL Context"); - sslContext = SSLContext.getInstance(sslType); - sslContext.init(userkmf.getKeyManagers(), new TrustManager[] {this}, null); - } catch (Exception ex) { - Log.e(TAG,"Error initializing SSL [" + ex.getMessage() + "]"); - } + public void init(String sslType, String homeDirectory) { + try { + Log.d(TAG, "Initializing User KeyStore"); + userKsPath = homeDirectory + File.separator + "keystore"; + File userKsFile = new File(userKsPath); + userks = KeyStore.getInstance(KeyStore.getDefaultType()); + userks.load(userKsFile.exists() ? new FileInputStream(userKsFile) + : null, userksPassword); + Log.d(TAG, "Initializing User Key Manager Factory"); + userkmf = KeyManagerFactory.getInstance(KeyManagerFactory + .getDefaultAlgorithm()); + userkmf.init(userks, userksPassword); + Log.d(TAG, "Initializing User Trust Manager Factory"); + usertmf = TrustManagerFactory.getInstance(TrustManagerFactory + .getDefaultAlgorithm()); + usertmf.init(userks); + userTrustManagers = usertmf.getTrustManagers(); + Log.d(TAG, "Initializing SSL Context"); + sslContext = SSLContext.getInstance(sslType); + sslContext.init(userkmf.getKeyManagers(), new TrustManager[] {this}, null); + } + catch (Exception ex) { + Log.e(TAG, "Error initializing SSL [" + ex.getMessage() + "]"); + } + } - } + public Socket createSSLSocket(String destination, int port) { + if (sslContext == null) + throw new IllegalStateException("SSL Context Not Initialized"); - public Socket createSSLSocket(String destination, int port) { - if (sslContext == null) - throw new IllegalStateException("SSL Context Not Initialized"); - SSLSocket socket = null; - try { + SSLSocket socket = null; + + try { target = destination + ":" + String.valueOf(port); - socket = (SSLSocket) sslContext.getSocketFactory().createSocket( - destination, port); - } catch (Exception e) { - Log.e(TAG,"Error creating ssl socket [" + e.getMessage() + "]"); - } - return socket; - } + socket = (SSLSocket) sslContext.getSocketFactory().createSocket( + destination, port); + } + catch (Exception e) { + Log.e(TAG, "Error creating ssl socket [" + e.getMessage() + "]"); + } - // X509TrustManager Methods + return socket; + } + + // X509TrustManager Methods - /* - * (non-Javadoc) - * - * @see javax.net.ssl.X509TrustManager#getAcceptedIssuers() - */ - public X509Certificate[] getAcceptedIssuers() { - return acceptedIssuers; - } + /* + * (non-Javadoc) + * + * @see javax.net.ssl.X509TrustManager#getAcceptedIssuers() + */ + public X509Certificate[] getAcceptedIssuers() { + return acceptedIssuers; + } - /* - * (non-Javadoc) - * - * @see - * javax.net.ssl.X509TrustManager#checkClientTrusted(java.security.cert. - * X509Certificate[], java.lang.String) - */ - public void checkClientTrusted(X509Certificate[] arg0, String arg1) - throws CertificateException { - throw new SecurityException("checkClientTrusted unsupported"); - - } + /* + * (non-Javadoc) + * + * @see + * javax.net.ssl.X509TrustManager#checkClientTrusted(java.security.cert. + * X509Certificate[], java.lang.String) + */ + public void checkClientTrusted(X509Certificate[] arg0, String arg1) + throws CertificateException { + throw new SecurityException("checkClientTrusted unsupported"); + } - /* - * (non-Javadoc) - * - * @see - * javax.net.ssl.X509TrustManager#checkServerTrusted(java.security.cert. - * X509Certificate[], java.lang.String) - */ - public void checkServerTrusted(X509Certificate[] chain, String type) - throws CertificateException { - try { - for (int i = 0; i < userTrustManagers.length; i++) { - if (userTrustManagers[i] instanceof X509TrustManager) { - X509TrustManager trustManager = (X509TrustManager) userTrustManagers[i]; - X509Certificate[] calist = trustManager - .getAcceptedIssuers(); - if (calist.length > 0) { - trustManager.checkServerTrusted(chain, type); - } else { - throw new CertificateException( - "Empty list of accepted issuers (a.k.a. root CA list)."); - } - } - } - return; - } catch (CertificateException ce) { - X509Certificate cert = chain[0]; - String certInfo = manager.res.getString(R.string.host_cert_version) + cert.getVersion() + "\r\n"; - certInfo = certInfo.concat(manager.res.getString(R.string.host_cert_serial) + cert.getSerialNumber() + "\r\n"); - certInfo = certInfo.concat(manager.res.getString(R.string.host_cert_algorithm) + cert.getSigAlgName() + "\r\n"); - certInfo = certInfo.concat(manager.res.getString(R.string.host_cert_issuer) + cert.getIssuerDN().getName() + "\r\n"); - certInfo = certInfo.concat(manager.res.getString(R.string.host_cert_from) + cert.getNotBefore() + "\r\n"); - certInfo = certInfo.concat(manager.res.getString(R.string.host_cert_to) + cert.getNotAfter() + "\r\n"); - certInfo = certInfo.concat(manager.res.getString(R.string.host_cert_dn) + cert.getSubjectDN().getName() + "\r\n"); - certInfo = certInfo.concat(manager.res.getString(R.string.host_cert_publickey) + cert.getPublicKey().getFormat() + "\r\n"); + /* + * (non-Javadoc) + * + * @see + * javax.net.ssl.X509TrustManager#checkServerTrusted(java.security.cert. + * X509Certificate[], java.lang.String) + */ + public void checkServerTrusted(X509Certificate[] chain, String type) + throws CertificateException { + try { + for (int i = 0; i < userTrustManagers.length; i++) { + if (userTrustManagers[i] instanceof X509TrustManager) { + X509TrustManager trustManager = (X509TrustManager) userTrustManagers[i]; + X509Certificate[] calist = trustManager + .getAcceptedIssuers(); + if (calist.length > 0) { + trustManager.checkServerTrusted(chain, type); + } + else { + throw new CertificateException( + "Empty list of accepted issuers (a.k.a. root CA list)."); + } + } + } + + return; + } + catch (CertificateException ce) { + X509Certificate cert = chain[0]; + String certInfo = manager.res.getString(R.string.host_cert_version) + cert.getVersion() + "\r\n"; + certInfo = certInfo.concat(manager.res.getString(R.string.host_cert_serial) + cert.getSerialNumber() + "\r\n"); + certInfo = certInfo.concat(manager.res.getString(R.string.host_cert_algorithm) + cert.getSigAlgName() + "\r\n"); + certInfo = certInfo.concat(manager.res.getString(R.string.host_cert_issuer) + cert.getIssuerDN().getName() + "\r\n"); + certInfo = certInfo.concat(manager.res.getString(R.string.host_cert_from) + cert.getNotBefore() + "\r\n"); + certInfo = certInfo.concat(manager.res.getString(R.string.host_cert_to) + cert.getNotAfter() + "\r\n"); + certInfo = certInfo.concat(manager.res.getString(R.string.host_cert_dn) + cert.getSubjectDN().getName() + "\r\n"); + certInfo = certInfo.concat(manager.res.getString(R.string.host_cert_publickey) + cert.getPublicKey().getFormat() + "\r\n"); bridge.outputLine(manager.res.getString(R.string.host_authenticity_warning, target)); bridge.outputLine(manager.res.getString(R.string.host_certificate, certInfo)); Boolean result = bridge.promptHelper.requestBooleanPrompt(null, manager.res.getString(R.string.prompt_accept_certificate)); + if ((result == null) || (!result.booleanValue())) { - throw new java.security.cert.CertificateException( - "Certificate Rejected"); - } + throw new java.security.cert.CertificateException( + "Certificate Rejected"); + } result = bridge.promptHelper.requestBooleanPrompt(null, manager.res.getString(R.string.prompt_save_certificate)); + if ((result != null) && (result.booleanValue())) { - try { - userks.setCertificateEntry(cert.getSubjectDN().getName(), - cert); - userks.store(new FileOutputStream(userKsPath), - userksPassword); - } catch (Exception e) { - Log.e(TAG,"Error saving certificate [" + e.getMessage() - + "]"); - e.printStackTrace(); - } - } - } - } + try { + userks.setCertificateEntry(cert.getSubjectDN().getName(), + cert); + userks.store(new FileOutputStream(userKsPath), + userksPassword); + } + catch (Exception e) { + Log.e(TAG, "Error saving certificate [" + e.getMessage() + + "]"); + e.printStackTrace(); + } + } + } + } } \ No newline at end of file diff -r 6a0ad4d384ea -r 77ac18bc1b2f src/org/tn5250j/framework/transport/SSL/X509CertificateTrustManager.java --- a/src/org/tn5250j/framework/transport/SSL/X509CertificateTrustManager.java Wed Jun 18 13:00:19 2014 -0700 +++ b/src/org/tn5250j/framework/transport/SSL/X509CertificateTrustManager.java Wed Jun 18 13:03:01 2014 -0700 @@ -46,63 +46,67 @@ */ public class X509CertificateTrustManager implements X509TrustManager { - KeyStore ks = null; - TrustManager[] trustManagers; - TerminalBridge bridge = null; - TerminalManager manager = null; + KeyStore ks = null; + TrustManager[] trustManagers; + TerminalBridge bridge = null; + TerminalManager manager = null; - public X509CertificateTrustManager(TrustManager[] managers, KeyStore keyStore, TerminalBridge bridge, TerminalManager manager) { - this.bridge = bridge; - this.manager = manager; - trustManagers = managers; - ks = keyStore; - } + public X509CertificateTrustManager(TrustManager[] managers, KeyStore keyStore, TerminalBridge bridge, TerminalManager manager) { + this.bridge = bridge; + this.manager = manager; + trustManagers = managers; + ks = keyStore; + } - public void checkClientTrusted(X509Certificate[] chain, String type) throws CertificateException { - throw new SecurityException("checkClientTrusted unsupported"); - } + public void checkClientTrusted(X509Certificate[] chain, String type) throws CertificateException { + throw new SecurityException("checkClientTrusted unsupported"); + } - /** - * Checks the server certificate. If it isn't trusted by the trust manager - * passed to the constructor, then the user will be prompted to accept the - * certificate. - */ - public void checkServerTrusted(X509Certificate[] chain, String type) - throws CertificateException { - try { - for (int i=0; i list = new ArrayList(10); - for (int i=0; i list = new ArrayList(10); + + for (int i = 0; i < trustManagers.length; i++) { + if (trustManagers[i] instanceof X509TrustManager) + list.addAll(Arrays.asList(((X509TrustManager)trustManagers[i]).getAcceptedIssuers())); + } + + X509Certificate[] acceptedIssuers = new X509Certificate[list.size()]; + acceptedIssuers = list.toArray(acceptedIssuers); + return acceptedIssuers; + } } \ No newline at end of file diff -r 6a0ad4d384ea -r 77ac18bc1b2f src/org/tn5250j/framework/transport/SSLInterface.java --- a/src/org/tn5250j/framework/transport/SSLInterface.java Wed Jun 18 13:00:19 2014 -0700 +++ b/src/org/tn5250j/framework/transport/SSLInterface.java Wed Jun 18 13:03:01 2014 -0700 @@ -25,22 +25,22 @@ public interface SSLInterface { - /** - * Initialize the components required to create a new client socket - * when createSSLSocket is called. - * @param sslType The ssl socket type (NONE, SSLv2, SSLv3, TLS) + /** + * Initialize the components required to create a new client socket + * when createSSLSocket is called. + * @param sslType The ssl socket type (NONE, SSLv2, SSLv3, TLS) * @param homeDirectory location of the .tn5250j subdirectory containing * the keystore - * @see org.tn5250j.framework.transport.SSLConstants - */ - public abstract void init(String sslType, String homeDirectory); + * @see org.tn5250j.framework.transport.SSLConstants + */ + public abstract void init(String sslType, String homeDirectory); - /** - * Create a new socket - * @param destination - * @param port - * @return new socket, or null if none could be created. - */ - public abstract Socket createSSLSocket(String destination, int port); + /** + * Create a new socket + * @param destination + * @param port + * @return new socket, or null if none could be created. + */ + public abstract Socket createSSLSocket(String destination, int port); } \ No newline at end of file diff -r 6a0ad4d384ea -r 77ac18bc1b2f src/org/tn5250j/framework/transport/SocketConnector.java --- a/src/org/tn5250j/framework/transport/SocketConnector.java Wed Jun 18 13:00:19 2014 -0700 +++ b/src/org/tn5250j/framework/transport/SocketConnector.java Wed Jun 18 13:03:01 2014 -0700 @@ -36,61 +36,63 @@ public class SocketConnector { private static final String TAG = "SocketConnector"; - /** - * Creates a new instance that creates a plain socket by default. - */ - public SocketConnector() { - - } + /** + * Creates a new instance that creates a plain socket by default. + */ + public SocketConnector() { + } - /** - * Create a new client Socket to the given destination, port and sslType of - * encryption. - * @param destination - * @param port - * @return a new client socket, or null if - */ - public Socket createSocket(String destination, int port, String sslType, String homeDirectory, TerminalBridge bridge, TerminalManager manager) { + /** + * Create a new client Socket to the given destination, port and sslType of + * encryption. + * @param destination + * @param port + * @return a new client socket, or null if + */ + public Socket createSocket(String destination, int port, String sslType, String homeDirectory, TerminalBridge bridge, TerminalManager manager) { + Socket socket = null; + Exception ex = null; - Socket socket = null; - Exception ex = null; + if (sslType == null || sslType.trim().length() == 0 || + sslType.toUpperCase().equals(TN5250jConstants.SSL_TYPE_NONE)) { + Log.i(TAG, "Creating Plain Socket"); - if (sslType == null || sslType.trim().length() == 0 || - sslType.toUpperCase().equals(TN5250jConstants.SSL_TYPE_NONE)) { - Log.i(TAG,"Creating Plain Socket"); - try { - // Use Socket Constructor!!! SocketFactory for jdk 1.4 - socket = new Socket(destination,port); - } catch (Exception e) { - ex = e; - } - } else { //SSL SOCKET - - Log.i(TAG,"Creating SSL ["+sslType+"] Socket"); - - SSLInterface sslIf = null; + try { + // Use Socket Constructor!!! SocketFactory for jdk 1.4 + socket = new Socket(destination, port); + } + catch (Exception e) { + ex = e; + } + } + else { //SSL SOCKET + Log.i(TAG, "Creating SSL [" + sslType + "] Socket"); + SSLInterface sslIf = null; - try { - sslIf = (SSLInterface) new SSLImplementation(bridge, manager); - } catch (Exception e) { - ex = new Exception("Failed to create SSLInterface Instance. " + - "Message is ["+e.getMessage()+"]"); - } + try { + sslIf = (SSLInterface) new SSLImplementation(bridge, manager); + } + catch (Exception e) { + ex = new Exception("Failed to create SSLInterface Instance. " + + "Message is [" + e.getMessage() + "]"); + } - if (sslIf != null) { - sslIf.init(sslType, homeDirectory); - socket = sslIf.createSSLSocket(destination, port); - } - } + if (sslIf != null) { + sslIf.init(sslType, homeDirectory); + socket = sslIf.createSSLSocket(destination, port); + } + } - if (ex != null) { - Log.e(TAG, "exception", ex); - } - if (socket == null) { - Log.w(TAG, "No socket was created"); - } - return socket; - } + if (ex != null) { + Log.e(TAG, "exception", ex); + } + + if (socket == null) { + Log.w(TAG, "No socket was created"); + } + + return socket; + } } \ No newline at end of file