reports/Builder__ReportFormat.st
author Claus Gittinger <cg@exept.de>
Thu, 28 Mar 2019 13:54:38 +0100
changeset 542 aa25a71be62a
parent 202 730a466fbe35
permissions -rw-r--r--
#DOCUMENTATION by cg class: stx_goodies_builder_quickSelfTest class definition class: stx_goodies_builder_quickSelfTest class added:18 methods
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
73
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     1
"{ Package: 'stx:goodies/builder/reports' }"
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     2
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     3
"{ NameSpace: Builder }"
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     4
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     5
Object subclass:#ReportFormat
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     6
	instanceVariableNames:'report stream'
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     7
	classVariableNames:''
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     8
	poolDictionaries:''
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     9
	category:'Builder-Reports-Formats'
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    10
!
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    11
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    12
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    13
!ReportFormat class methodsFor:'instance creation'!
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    14
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    15
named:aString 
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    16
    "Return new format with given name. Name may be
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    17
     either class or symbolic name"
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    18
    
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    19
    self allSubclassesDo:
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    20
            [:cls |             
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    21
            (cls isAbstract not and:[cls name = aString or:[ cls symbolicNames includes:aString ]]) 
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    22
                ifTrue:[ ^ cls new ] ].
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    23
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    24
    self error:'No format named ' , aString.
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    25
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    26
    "
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    27
        ReportFormat named: 'tap'
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    28
        ReportFormat named: 'JUnitFormat'
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    29
        ReportFormat named: 'NONEX'
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    30
    "
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    31
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    32
    "Created: / 04-08-2011 / 11:47:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    33
!
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    34
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    35
new
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    36
    "return an initialized instance"
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    37
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    38
    ^ self basicNew initialize.
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    39
! !
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    40
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    41
!ReportFormat class methodsFor:'accessing'!
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    42
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    43
symbolicNames
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    44
    "Returns a collection of symbolic names for this format"
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    45
    
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    46
    ^ self subclassResponsibility
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    47
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    48
    "Modified (comment): / 04-08-2011 / 11:46:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    49
! !
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    50
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    51
!ReportFormat class methodsFor:'testing'!
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    52
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    53
isAbstract
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    54
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    55
    ^self == HDReportFormat
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    56
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    57
    "Created: / 04-08-2011 / 11:44:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    58
! !
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    59
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    60
!ReportFormat methodsFor:'accessing - defaults'!
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    61
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    62
defaultFileSuffix
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    63
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    64
    ^self subclassResponsibility
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    65
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    66
    "Created: / 04-08-2011 / 12:47:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    67
! !
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    68
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    69
!ReportFormat methodsFor:'initialization'!
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    70
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    71
initialize
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    72
    "Invoked when a new instance is created."
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    73
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    74
    "/ please change as required (and remove this comment)
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    75
    "/ stream := nil.
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    76
    "/ suite := nil.
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    77
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    78
    "/ super initialize.   -- commented since inherited method does nothing
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    79
!
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    80
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    81
report: aReport stream: aStream
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    82
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    83
    report := aReport.
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    84
    (aStream isKindOf: EncodedStream) ifTrue:[
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    85
        stream := aStream.
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    86
    ] ifFalse:[
89
b21b16d6c4f8 changed: #report:stream: - use XMLUTF8 encoder, if possible
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 73
diff changeset
    87
        | encoder |
b21b16d6c4f8 changed: #report:stream: - use XMLUTF8 encoder, if possible
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 73
diff changeset
    88
        "Kludge since ISO10646_to_XMLUTF8 encoder may not be present"
b21b16d6c4f8 changed: #report:stream: - use XMLUTF8 encoder, if possible
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 73
diff changeset
    89
b21b16d6c4f8 changed: #report:stream: - use XMLUTF8 encoder, if possible
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 73
diff changeset
    90
        CharacterEncoderImplementations::ISO10646_to_XMLUTF8 notNil ifTrue:[
b21b16d6c4f8 changed: #report:stream: - use XMLUTF8 encoder, if possible
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 73
diff changeset
    91
            CharacterEncoderImplementations::ISO10646_to_XMLUTF8 autoload.
b21b16d6c4f8 changed: #report:stream: - use XMLUTF8 encoder, if possible
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 73
diff changeset
    92
            encoder := CharacterEncoderImplementations::ISO10646_to_XMLUTF8 new.
b21b16d6c4f8 changed: #report:stream: - use XMLUTF8 encoder, if possible
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 73
diff changeset
    93
        ] ifFalse:[
b21b16d6c4f8 changed: #report:stream: - use XMLUTF8 encoder, if possible
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 73
diff changeset
    94
            encoder := CharacterEncoder encoderForUTF8.
b21b16d6c4f8 changed: #report:stream: - use XMLUTF8 encoder, if possible
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 73
diff changeset
    95
        ].
b21b16d6c4f8 changed: #report:stream: - use XMLUTF8 encoder, if possible
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 73
diff changeset
    96
        stream := EncodedStream stream: aStream encoder: encoder
73
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    97
    ]
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    98
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    99
    "Created: / 03-08-2011 / 18:54:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   100
! !
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   101
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   102
!ReportFormat methodsFor:'stream - utilities'!
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   103
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   104
stream 
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   105
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   106
    ^ stream
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   107
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   108
!
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   109
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   110
streamClose
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   111
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   112
    "Temporarily closes the stream"
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   113
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   114
    "stream is EncodedStream..."             
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   115
    stream stream close.
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   116
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   117
    "Created: / 12-08-2011 / 09:30:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   118
!
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   119
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   120
streamFlush
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   121
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   122
    "Temporarily closes the stream"
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   123
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   124
    "stream is EncodedStream..."             
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   125
    stream stream flush.
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   126
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   127
    "Created: / 12-08-2011 / 09:35:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   128
!
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   129
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   130
streamOpenForAppend
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   131
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   132
    "Open previously closes stream"
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   133
    
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   134
    | s |
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   135
    "stream is EncodedStream..."             
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   136
    s := stream stream.
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   137
    s isExternalStream ifTrue:[
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   138
        s isOpen ifTrue:[s close].
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   139
        s openForWriting.
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   140
	s setToEnd.
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   141
    ].
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   142
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   143
    "Created: / 12-08-2011 / 09:31:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   144
! !
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   145
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   146
!ReportFormat methodsFor:'writing'!
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   147
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   148
writeFooter
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   149
    "raise an error: must be redefined in concrete subclass(es)"
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   150
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   151
    ^ self subclassResponsibility
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   152
!
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   153
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   154
writeHeader
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   155
    "raise an error: must be redefined in concrete subclass(es)"
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   156
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   157
    ^ self subclassResponsibility
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   158
! !
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   159
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   160
!ReportFormat methodsFor:'writing - utilities'!
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   161
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   162
encode: aString
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   163
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   164
    ^Report encode: aString
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   165
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   166
    "Created: / 03-08-2011 / 14:37:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
202
730a466fbe35 Temporary commit - improved line coverage reporting.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 89
diff changeset
   167
!
730a466fbe35 Temporary commit - improved line coverage reporting.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 89
diff changeset
   168
730a466fbe35 Temporary commit - improved line coverage reporting.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 89
diff changeset
   169
writeCDATA: string
730a466fbe35 Temporary commit - improved line coverage reporting.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 89
diff changeset
   170
    | start stop |
730a466fbe35 Temporary commit - improved line coverage reporting.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 89
diff changeset
   171
730a466fbe35 Temporary commit - improved line coverage reporting.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 89
diff changeset
   172
    start := 1. 
730a466fbe35 Temporary commit - improved line coverage reporting.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 89
diff changeset
   173
    stop := start.
730a466fbe35 Temporary commit - improved line coverage reporting.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 89
diff changeset
   174
    [ (stop := (string indexOf: $] startingAt: stop)) ~~ 0 ] whileTrue:[
730a466fbe35 Temporary commit - improved line coverage reporting.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 89
diff changeset
   175
        ((stop < (string size - 1)) 
730a466fbe35 Temporary commit - improved line coverage reporting.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 89
diff changeset
   176
            and:[(string at: stop + 1) == $]
730a466fbe35 Temporary commit - improved line coverage reporting.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 89
diff changeset
   177
                and:[(string at: stop + 2) == $>]]) ifTrue:[
730a466fbe35 Temporary commit - improved line coverage reporting.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 89
diff changeset
   178
                    " Okay, found CDATA end token "
730a466fbe35 Temporary commit - improved line coverage reporting.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 89
diff changeset
   179
                    stream nextPutAll: string startingAt: start to: stop + 1.
730a466fbe35 Temporary commit - improved line coverage reporting.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 89
diff changeset
   180
                    stream nextPutAll: ']]><!![CDATA[>'.
730a466fbe35 Temporary commit - improved line coverage reporting.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 89
diff changeset
   181
                    start := stop := stop + 3.
730a466fbe35 Temporary commit - improved line coverage reporting.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 89
diff changeset
   182
                ] ifFalse:[
730a466fbe35 Temporary commit - improved line coverage reporting.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 89
diff changeset
   183
                    stop := stop + 1.
730a466fbe35 Temporary commit - improved line coverage reporting.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 89
diff changeset
   184
                ].
730a466fbe35 Temporary commit - improved line coverage reporting.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 89
diff changeset
   185
    ].
730a466fbe35 Temporary commit - improved line coverage reporting.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 89
diff changeset
   186
    start < string size ifTrue:[
730a466fbe35 Temporary commit - improved line coverage reporting.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 89
diff changeset
   187
        stream nextPutAll: string startingAt: start to: string size.        
730a466fbe35 Temporary commit - improved line coverage reporting.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 89
diff changeset
   188
    ].
730a466fbe35 Temporary commit - improved line coverage reporting.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 89
diff changeset
   189
730a466fbe35 Temporary commit - improved line coverage reporting.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 89
diff changeset
   190
    "
730a466fbe35 Temporary commit - improved line coverage reporting.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 89
diff changeset
   191
    String streamContents:[:s | Builder::TestReportFormat::JUnit new report: nil stream: s; writeCDATA:'ABCD']
730a466fbe35 Temporary commit - improved line coverage reporting.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 89
diff changeset
   192
    String streamContents:[:s | Builder::TestReportFormat::JUnit new report: nil stream: s; writeCDATA:']]]]']         
730a466fbe35 Temporary commit - improved line coverage reporting.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 89
diff changeset
   193
    String streamContents:[:s | Builder::TestReportFormat::JUnit new report: nil stream: s; writeCDATA:'Some <[CDATA[ CDATA ]]> Some Text and stray terminator ]]> here']
730a466fbe35 Temporary commit - improved line coverage reporting.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 89
diff changeset
   194
    "
730a466fbe35 Temporary commit - improved line coverage reporting.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 89
diff changeset
   195
730a466fbe35 Temporary commit - improved line coverage reporting.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 89
diff changeset
   196
    "Created: / 05-07-2013 / 16:54:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
73
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   197
! !
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   198
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   199
!ReportFormat class methodsFor:'documentation'!
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   200
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   201
version
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   202
    ^ '$Header$'
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   203
!
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   204
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   205
version_CVS
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   206
    ^ '$Header$'
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   207
!
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   208
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   209
version_SVN
202
730a466fbe35 Temporary commit - improved line coverage reporting.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 89
diff changeset
   210
    ^ '$Id$'
73
86ad0c9b27de initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   211
! !
202
730a466fbe35 Temporary commit - improved line coverage reporting.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 89
diff changeset
   212