34
|
1 |
"{ Package: 'stx:goodies/monticello' }"
|
|
2 |
|
|
3 |
Object subclass:#MCReader
|
|
4 |
instanceVariableNames:'stream'
|
|
5 |
classVariableNames:''
|
|
6 |
poolDictionaries:''
|
|
7 |
category:'Monticello-Storing'
|
|
8 |
!
|
|
9 |
|
|
10 |
|
|
11 |
!MCReader class methodsFor:'instance creation'!
|
|
12 |
|
|
13 |
new
|
|
14 |
^ self basicNew initialize
|
|
15 |
!
|
|
16 |
|
|
17 |
on: aStream
|
|
18 |
^ self new stream: aStream
|
|
19 |
!
|
|
20 |
|
|
21 |
on: aStream name: aFileName
|
|
22 |
| class |
|
|
23 |
class _ self readerClassForFileNamed: aFileName.
|
|
24 |
^ class
|
|
25 |
ifNil: [self error: 'Unsupported format: ', aFileName]
|
|
26 |
ifNotNil: [class on: aStream]
|
|
27 |
! !
|
|
28 |
|
|
29 |
!MCReader class methodsFor:'testing'!
|
|
30 |
|
|
31 |
canReadFileNamed: fileName
|
|
32 |
^ (fileName endsWith: self extension)
|
|
33 |
!
|
|
34 |
|
|
35 |
concreteSubclasses
|
|
36 |
^ self allSubclasses reject: [:c | c isAbstract]
|
|
37 |
!
|
|
38 |
|
|
39 |
isAbstract
|
|
40 |
^ (self respondsTo: #extension) not
|
|
41 |
!
|
|
42 |
|
|
43 |
readerClassForFileNamed: fileName
|
|
44 |
^ self concreteSubclasses
|
|
45 |
detect: [:c | c canReadFileNamed: fileName]
|
|
46 |
ifNone: [nil]
|
|
47 |
! !
|
|
48 |
|
|
49 |
!MCReader methodsFor:'accessing'!
|
|
50 |
|
|
51 |
stream: aStream
|
|
52 |
stream _ aStream
|
|
53 |
! !
|
|
54 |
|
|
55 |
!MCReader methodsFor:'lifecycle'!
|
|
56 |
|
|
57 |
initialize
|
|
58 |
! !
|
|
59 |
|
|
60 |
!MCReader class methodsFor:'documentation'!
|
|
61 |
|
|
62 |
version
|
|
63 |
^ '$Header: /cvs/stx/stx/goodies/monticello/MCReader.st,v 1.1 2006-11-22 13:05:12 cg Exp $'
|
|
64 |
! !
|