Coverage report

| %line | %branch
--- | --- | ---

org.apache.commons.jelly.util.SafeContentHandler

72%

100%

1

     /*

2

      * Copyright 2002,2004 The Apache Software Foundation.

3

      *

4

      * Licensed under the Apache License, Version 2.0 (the "License");

5

      * you may not use this file except in compliance with the License.

6

      * You may obtain a copy of the License at

7

      *

8

      *      http://www.apache.org/licenses/LICENSE-2.0

9

      *

10

      * Unless required by applicable law or agreed to in writing, software

11

      * distributed under the License is distributed on an "AS IS" BASIS,

12

      * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

13

      * See the License for the specific language governing permissions and

14

      * limitations under the License.

15

      */

16

     package org.apache.commons.jelly.util;

17

18

     import org.xml.sax.Attributes;

19

     import org.xml.sax.ContentHandler;

20

     import org.xml.sax.Locator;

21

     import org.xml.sax.SAXException;

22

23

     /**

24

      * Ensures that only one start and end document event is passed onto the underlying

25

      * ContentHandler. This object can only be used once and then discarded.

26

      *

27

      * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>

28

      */

29

     public class SafeContentHandler implements ContentHandler {

30

         private ContentHandler handler;

31

         private boolean documentStarted;

32

         private boolean documentEnded;

33

34

78

         public SafeContentHandler(ContentHandler handler) {

35

78

             this.handler = handler;

36

78

         }

37

38

         /**

39

          * @throws org.xml.sax.SAXException

40

          */

41

         public void startDocument() throws SAXException {

42

78

             if (! documentStarted) {

43

78

                 handler.startDocument();

44

78

                 documentStarted = true;

45

             }

46

78

         }

47

48

         /**

49

          * @throws org.xml.sax.SAXException

50

          */

51

         public void endDocument() throws SAXException {

52

78

             if (! documentEnded) {

53

78

                 handler.endDocument();

54

78

                 documentEnded = true;

55

             }

56

78

         }

57

58

         /**

59

          * @param arg0

60

          * @param arg1

61

          * @param arg2

62

          * @throws org.xml.sax.SAXException

63

          */

64

         public void characters(char[] arg0, int arg1, <span class="keyword">int arg2)

65

             throws SAXException {

66

78

             handler.characters(arg0, arg1, arg2);

67

78

         }

68

69

         /**

70

          * @param arg0

71

          * @param arg1

72

          * @param arg2

73

          * @throws org.xml.sax.SAXException

74

          */

75

         public void endElement(String arg0, String arg1, String arg2)

76

             throws SAXException {

77

65

             handler.endElement(arg0, arg1, arg2);

78

65

         }

79

80

         /**

81

          * @param arg0

82

          * @throws org.xml.sax.SAXException

83

          */

84

         public void endPrefixMapping(String arg0) throws SAXException {

85

13

             handler.endPrefixMapping(arg0);

86

13

         }

87

88

         /**

89

          * @param arg0

90

          * @param arg1

91

          * @param arg2

92

          * @throws org.xml.sax.SAXException

93

          */

94

         public void ignorableWhitespace(char[] arg0, int arg1, <span class="keyword">int arg2)

95

             throws SAXException {

96

0

             handler.ignorableWhitespace(arg0, arg1, arg2);

97

0

         }

98

99

         /**

100

          * @param arg0

101

          * @param arg1

102

          * @throws org.xml.sax.SAXException

103

          */

104

         public void processingInstruction(String arg0, String arg1)

105

             throws SAXException {

106

0

             handler.processingInstruction(arg0, arg1);

107

0

         }

108

109

         /**

110

          * @param arg0

111

          */

112

         public void setDocumentLocator(Locator arg0) {

113

0

             handler.setDocumentLocator(arg0);

114

0

         }

115

116

         /**

117

          * @param arg0

118

          * @throws org.xml.sax.SAXException

119

          */

120

         public void skippedEntity(String arg0) throws SAXException {

121

0

             handler.skippedEntity(arg0);

122

0

         }

123

124

         /**

125

          * @param arg0

126

          * @param arg1

127

          * @param arg2

128

          * @param arg3

129

          * @throws org.xml.sax.SAXException

130

          */

131

         public void startElement(

132

             String arg0,

133

             String arg1,

134

             String arg2,

135

             Attributes arg3)

136

             throws SAXException {

137

65

             handler.startElement(arg0, arg1, arg2, arg3);

138

65

         }

139

140

         /**

141

          * @param arg0

142

          * @param arg1

143

          * @throws org.xml.sax.SAXException

144

          */

145

         public void startPrefixMapping(String arg0, String arg1)

146

             throws SAXException {

147

13

             handler.startPrefixMapping(arg0, arg1);

148

13

         }

149

     }

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.