author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Wed, 01 Feb 2012 08:54:33 +0000 | |
changeset 105 | ba761aff18ac |
parent 89 | 208ac7c53cfb |
child 109 | 9587e2df7029 |
permissions | -rw-r--r-- |
6 | 1 |
"{ Package: 'stx:goodies/xtreams/support' }" |
2 |
||
3 |
"{ NameSpace: Xtreams }" |
|
4 |
||
5 |
Object subclass:#Encoder |
|
6 |
instanceVariableNames:'' |
|
7 |
classVariableNames:'DialectEncoder Encoders' |
|
8 |
poolDictionaries:'' |
|
24
f906c95ca2ed
added XtreamsPool to fix DefaultBufferSize; set proper category names
mkobetic
parents:
6
diff
changeset
|
9 |
category:'Xtreams-Support' |
6 | 10 |
! |
11 |
||
12 |
Encoder comment:'Abstract character encoder class defines the API and maintains a registry of known encoders (Encoders). Also provides a hook to allow plugging in dialect specific encoders (DialectEncoder) as a secondary encoder resource. |
|
13 |
||
14 |
Shared Variables |
|
15 |
DialectEncoder <Class> optional dialect specific encoder class providing support for additional encodings |
|
16 |
Encoders <Dictionary key: Symbol value: Class> maps encoding names to encoders |
|
17 |
||
18 |
' |
|
19 |
! |
|
20 |
||
21 |
||
22 |
!Encoder class methodsFor:'instance creation'! |
|
23 |
||
24 |
for: anEncoding |
|
25 |
||
41 | 26 |
anEncoding isSymbol ifFalse: [ ^anEncoding streamingAsEncoder ]. |
27 |
^Encoders at: anEncoding ifAbsent: [ |
|
28 |
DialectEncoder |
|
29 |
ifNil: [ self error: 'Unknown encoding!!' ] |
|
30 |
ifNotNil: [ DialectEncoder for: anEncoding ] ] |
|
6 | 31 |
! |
32 |
||
33 |
streamingAsEncoder |
|
34 |
||
35 |
^self new |
|
36 |
! ! |
|
37 |
||
38 |
!Encoder class methodsFor:'accessing'! |
|
39 |
||
40 |
encoders |
|
41 |
||
42 |
^Encoders ifNil: [ Encoders := IdentityDictionary new ] |
|
43 |
! ! |
|
44 |
||
45 |
!Encoder methodsFor:'accessing'! |
|
46 |
||
47 |
backupState |
|
48 |
! |
|
49 |
||
89 | 50 |
contentsSpecies |
51 |
||
52 |
^String |
|
53 |
! |
|
54 |
||
6 | 55 |
decodeFrom: aReadStream |
56 |
||
57 |
^self subclassResponsibility |
|
58 |
! |
|
59 |
||
60 |
encode: aCharacter on: aWriteStream |
|
61 |
||
62 |
^self subclassResponsibility |
|
63 |
! |
|
64 |
||
65 |
restoreState |
|
66 |
! |
|
67 |
||
68 |
streamingAsEncoder |
|
69 |
||
70 |
^self |
|
71 |
! ! |
|
72 |
||
73 |
!Encoder class methodsFor:'documentation'! |
|
74 |
||
75 |
version_SVN |
|
76 |
^ '$Id$' |
|
77 |
! ! |