annotate src/org/tn5250j/framework/tn5250/Stream5250.java @ 62:aac8e0496ef9 tn5250

add 5250 config entries
author Carl Byington <carl@five-ten-sg.com>
date Fri, 13 Jun 2014 15:33:16 -0700
parents e8d2a24e85c6
children 77ac18bc1b2f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1 /**
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2 * Title: tn5250J
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
3 * Copyright: Copyright (c) 2001
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
4 * Company:
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
5 * @author Kenneth J. Pouncey
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
6 * @version 0.4
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
7 *
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
8 * Description:
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
9 *
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
10 * This program is free software; you can redistribute it and/or modify
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
11 * it under the terms of the GNU General Public License as published by
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
12 * the Free Software Foundation; either version 2, or (at your option)
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
13 * any later version.
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
14 *
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
15 * This program is distributed in the hope that it will be useful,
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
18 * GNU General Public License for more details.
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
19 *
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
20 * You should have received a copy of the GNU General Public License
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
21 * along with this software; see the file COPYING. If not, write to
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
22 * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
23 * Boston, MA 02111-1307 USA
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
24 *
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
25 */
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
26 package org.tn5250j.framework.tn5250;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
27
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
28 public class Stream5250 {
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
29
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
30 public int streamSize;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
31 public int opCode;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
32 public int dataStart;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
33 public int pos;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
34 public byte buffer[];
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
35
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
36 public Stream5250(byte abyte0[]) {
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
37 buffer = abyte0;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
38 // size without end of record 0xFF 0xEF
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
39 streamSize = (abyte0[0] & 0xff) << 8 | abyte0[1] & 0xff;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
40 opCode = abyte0[9];
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
41 dataStart = 6 + abyte0[6];
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
42 pos = dataStart;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
43 }
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
44
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
45 public Stream5250() {
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
46 buffer = null;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
47 streamSize = 0;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
48 opCode = 0;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
49 dataStart = 0;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
50 pos = dataStart;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
51 }
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
52
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
53 /**
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
54 * This method takes a byte array and initializes the object information
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
55 * to be used.
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
56 *
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
57 * @param abyte0
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
58 */
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
59 public void initialize(byte abyte0[]) {
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
60
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
61 buffer = abyte0;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
62 // size without end of record 0xFF 0xEF
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
63 streamSize = (abyte0[0] & 0xff) << 8 | abyte0[1] & 0xff;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
64 opCode = abyte0[9];
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
65 dataStart = 6 + abyte0[6];
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
66 pos = dataStart;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
67
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
68 }
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
69
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
70 public final int getOpCode() {
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
71 return opCode;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
72 }
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
73
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
74 public final byte getNextByte()
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
75 throws Exception {
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
76 if(buffer == null || pos > buffer.length)
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
77 throw new Exception("Buffer length exceeded: " + pos);
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
78 else
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
79 return buffer[pos++];
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
80 }
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
81
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
82 public final void setPrevByte()
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
83 throws Exception {
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
84 if(pos == 0) {
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
85 throw new Exception("Index equals zero.");
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
86 }
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
87 else {
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
88 pos--;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
89 return;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
90 }
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
91 }
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
92
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
93 /**
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
94 * Returns where we are in the buffer
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
95 * @return position in the buffer
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
96 */
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
97 public final int getCurrentPos() {
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
98 return pos;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
99 }
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
100
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
101 public final byte getByteOffset(int off)
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
102 throws Exception {
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
103
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
104 if(buffer == null || (pos + off ) > buffer.length)
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
105 throw new Exception("Buffer length exceeded: " + pos);
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
106 else
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
107 return buffer[pos + off];
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
108
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
109 }
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
110
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
111 public final boolean size() {
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
112 return pos >= streamSize;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
113 }
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
114
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
115
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
116 /**
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
117 * Determines if any more bytes are available in the buffer to be processed.
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
118 * @return yes or no
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
119 */
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
120 public final boolean hasNext() {
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
121
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
122 // return pos >= buffer.length;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
123 return pos < streamSize;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
124 }
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
125
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
126 /**
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
127 * This routine will retrieve a segment based on the first two bytes being
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
128 * the length of the segment.
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
129 *
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
130 * @return a new byte array containing the bytes of the segment.
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
131 * @throws Exception
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
132 */
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
133 public final byte[] getSegment() throws Exception {
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
134
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
135 // The first two bytes contain the length of the segment.
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
136 int length = ((buffer[pos] & 0xff )<< 8 | (buffer[pos+1] & 0xff));
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
137 // allocate space for it.
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
138 byte[] segment = new byte[length];
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
139
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
140 getSegment(segment,length,true);
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
141
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
142 return segment;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
143 }
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
144
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
145
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
146 /**
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
147 * This routine will retrieve a byte array based on the first two bytes being
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
148 * the length of the segment.
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
149 *
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
150 * @param segment - byte array
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
151 * @param length - length of segment to return
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
152 * @param adjustPos - adjust the position of the buffer to the end of the seg
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
153 * ment
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
154 * @throws Exception
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
155 */
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
156 public final void getSegment(byte[] segment, int length, boolean adjustPos)
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
157 throws Exception {
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
158
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
159 // If the length is larger than what is available throw an exception
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
160 if((pos + length ) > buffer.length)
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
161 throw new Exception("Buffer length exceeded: start " + pos
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
162 + " length " + length);
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
163 // use the system array copy to move the bytes from the buffer
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
164 // to the allocated byte array
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
165 System.arraycopy(buffer,pos,segment,0,length);
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
166
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
167 // update the offset to be after the segment so the next byte can be read
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
168 if (adjustPos)
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
169 pos +=length;
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
170
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
171 }
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
172
e8d2a24e85c6 adding tn5250 files
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
173 }