author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Wed, 01 Feb 2012 08:54:33 +0000 | |
changeset 105 | ba761aff18ac |
parent 72 | d16c7d84d4a8 |
child 111 | 44ac233b2f83 |
permissions | -rw-r--r-- |
10 | 1 |
"{ Package: 'stx:goodies/xtreams/transforms' }" |
2 |
||
3 |
"{ NameSpace: Xtreams }" |
|
4 |
||
5 |
Encoder subclass:#ASCIIEncoder |
|
6 |
instanceVariableNames:'' |
|
7 |
classVariableNames:'' |
|
8 |
poolDictionaries:'' |
|
27
2cc5a8a3ca14
added XtreamsPool to fix DefaultBufferSize; set proper category names
mkobetic
parents:
10
diff
changeset
|
9 |
category:'Xtreams-Transforms' |
10 | 10 |
! |
11 |
||
12 |
ASCIIEncoder comment:'Implements ASCII encoding. |
|
13 |
||
14 |
' |
|
15 |
! |
|
16 |
||
17 |
||
18 |
!ASCIIEncoder class methodsFor:'class initialization'! |
|
19 |
||
20 |
initialize |
|
21 |
||
22 |
self encoders |
|
23 |
at: #ascii put: self new; |
|
24 |
at: #ASCII put: self new |
|
25 |
! ! |
|
26 |
||
27 |
!ASCIIEncoder methodsFor:'accessing'! |
|
28 |
||
29 |
decodeFrom: aReadStream |
|
30 |
||
31 |
| value | |
|
32 |
^(value := aReadStream get) < 128 |
|
33 |
ifTrue: [ Character value: value ] |
|
34 |
ifFalse: [ self error: 'Illegal value!!' ] |
|
35 |
! |
|
36 |
||
37 |
encode: aCharacter on: aWriteStream |
|
38 |
||
39 |
| value | |
|
40 |
(value := aCharacter asInteger) < 128 |
|
41 |
ifTrue: [ aWriteStream put: value ] |
|
42 |
ifFalse: [ self error: 'Illegal character!!' ] |
|
43 |
! ! |
|
44 |
||
45 |
!ASCIIEncoder class methodsFor:'documentation'! |
|
46 |
||
47 |
version_SVN |
|
48 |
^ '$Id$' |
|
49 |
! ! |
|
50 |
||
51 |
ASCIIEncoder initialize! |