Skip to content

Commit

Permalink
Minor refactorying of writer API
Browse files Browse the repository at this point in the history
  • Loading branch information
JanBliznicenko committed Jul 25, 2022
1 parent fea8009 commit 86209c7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
4 changes: 2 additions & 2 deletions repository/OP-XMI/OPXMITest.class.st
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Class {
#name : #OPXMITest,
#superclass : #TestCase,
#category : 'OP-XMI-Tests'
#category : #'OP-XMI-Tests'
}

{ #category : #tests }
Expand All @@ -26,6 +26,6 @@ OPXMITest >> testReadWrite [
</container>
</xmi:XMI>'.
root := OPXMIReader readFrom: in readStream.
out := OPXMIWriter writeToString: root.
out := OPXMIWriter toString: root.
self assert: (self normalized: in) equals: (self normalized: out)
]
21 changes: 9 additions & 12 deletions repository/OP-XMI/OPXMIWriter.class.st
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
Class {
#name : #OPXMIWriter,
#superclass : #Object,
#category : 'OP-XMI-Writer'
#category : #'OP-XMI-Writer'
}

{ #category : #writing }
OPXMIWriter class >> write: anXMI to: aStream [
^ self new write: anXMI to: aStream
]
OPXMIWriter class >> toString: anXMI [

{ #category : #writing }
OPXMIWriter class >> writeToString: anXMI [
^ String streamContents: [ :stream | self write: anXMI to: stream ]
]

{ #category : #writing }
OPXMIWriter >> write: anXMI to: aStream [
| visitor |
visitor := OPXMIWriterVisitor new.
visitor visit: anXMI.
aStream << visitor contents
^ visitor contents
]

{ #category : #writing }
OPXMIWriter class >> write: anXMI toStream: aStream [

aStream << (self toString: anXMI)
]

0 comments on commit 86209c7

Please sign in to comment.