comparison src/org/tn5250j/framework/tn5250/KeyStrokenizer.java @ 25:5949eb469a79 tn5250

adding tn5250 files, native android logging
author Carl Byington <carl@five-ten-sg.com>
date Tue, 03 Jun 2014 12:10:21 -0700
parents e8d2a24e85c6
children b29b39f386a4
comparison
equal deleted inserted replaced
24:d1c549560aff 25:5949eb469a79
19 * 19 *
20 */ 20 */
21 21
22 package org.tn5250j.framework.tn5250; 22 package org.tn5250j.framework.tn5250;
23 23
24 import org.tn5250j.tools.logging.TN5250jLogFactory; 24 import android.util.Log;
25 import org.tn5250j.tools.logging.TN5250jLogger; 25
26 26
27 27
28 public class KeyStrokenizer { 28 public class KeyStrokenizer {
29 29
30 private StringBuffer keyStrokes; 30 private StringBuffer keyStrokes;
31 private StringBuffer sb; 31 private StringBuffer sb;
32 private int index; 32 private int index;
33 private int length; 33 private int length;
34 34
35 private final TN5250jLogger log = TN5250jLogFactory.getLogger(this.getClass()); 35
36 36
37 public KeyStrokenizer() { 37 public KeyStrokenizer() {
38 38
39 sb = new StringBuffer(); 39 sb = new StringBuffer();
40 setKeyStrokes(null); 40 setKeyStrokes(null);
42 42
43 public void setKeyStrokes (String strokes) { 43 public void setKeyStrokes (String strokes) {
44 44
45 if (strokes != null) { 45 if (strokes != null) {
46 keyStrokes.setLength(0); 46 keyStrokes.setLength(0);
47 log.debug("set "+ keyStrokes); 47 Log.d(TAG,"set "+ keyStrokes);
48 length = strokes.length(); 48 length = strokes.length();
49 } 49 }
50 else { 50 else {
51 51
52 keyStrokes = new StringBuffer(); 52 keyStrokes = new StringBuffer();
75 sb.append(c); 75 sb.append(c);
76 index++; 76 index++;
77 77
78 // we need to throw an error here 78 // we need to throw an error here
79 if(index >= length) { 79 if(index >= length) {
80 log.warn(" mnemonic key was incomplete :1 " + 80 Log.w(TAG," mnemonic key was incomplete :1 " +
81 "at position " + index + " len " + length ); 81 "at position " + index + " len " + length );
82 } 82 }
83 else { 83 else {
84 c = keyStrokes.charAt(index); 84 c = keyStrokes.charAt(index);
85 85
97 sb.append(c); 97 sb.append(c);
98 index++; 98 index++;
99 // we need to throw an error here because we did not 99 // we need to throw an error here because we did not
100 // find an ending for the potential mnemonic 100 // find an ending for the potential mnemonic
101 if(index >= length) { 101 if(index >= length) {
102 log.warn( 102 Log.w(TAG,
103 " mnemonic key was incomplete ending not found :2 " + 103 " mnemonic key was incomplete ending not found :2 " +
104 "at position " + index); 104 "at position " + index);
105 } 105 }
106 c = keyStrokes.charAt(index); 106 c = keyStrokes.charAt(index);
107 } 107 }
111 break; 111 break;
112 112
113 case ']': 113 case ']':
114 index++; 114 index++;
115 if(index >= length) { 115 if(index >= length) {
116 log.warn( 116 Log.w(TAG,
117 " mnemonic key was incomplete ending not found :3 " + 117 " mnemonic key was incomplete ending not found :3 " +
118 "at position " + index); 118 "at position " + index);
119 sb.append(c); 119 sb.append(c);
120 index++; 120 index++;
121 121
125 if(c == ']') { 125 if(c == ']') {
126 sb.append(c); 126 sb.append(c);
127 index++; 127 index++;
128 } 128 }
129 else { 129 else {
130 log.warn( 130 Log.w(TAG,
131 " mnemonic key was incomplete beginning not found :4 " + 131 " mnemonic key was incomplete beginning not found :4 " +
132 "at position " + index); 132 "at position " + index);
133 } 133 }
134 } 134 }
135 break; 135 break;
141 if(sb != null) { 141 if(sb != null) {
142 s = new String(sb); 142 s = new String(sb);
143 } 143 }
144 144
145 } 145 }
146 log.debug("next "+ keyStrokes); 146 Log.d(TAG,"next "+ keyStrokes);
147 147
148 return s; 148 return s;
149 } 149 }
150 150
151 public String getUnprocessedKeyStroked() { 151 public String getUnprocessedKeyStroked() {