|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
XmlReaderException | Line # 20 | 14 | 8 | 100% |
1.0
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||
(3) | |||
Result | |||
0.54545456
|
com.sun.syndication.io.XmlReaderExceptionTest.testGetter2 com.sun.syndication.io.XmlReaderExceptionTest.testGetter2 | 1 PASS | |
0.54545456
|
com.sun.syndication.io.XmlReaderExceptionTest.testGetter com.sun.syndication.io.XmlReaderExceptionTest.testGetter | 1 PASS | |
0.45454547
|
com.sun.syndication.io.XmlReaderExceptionTest.testCreator com.sun.syndication.io.XmlReaderExceptionTest.testCreator | 1 PASS | |
1 | package com.sun.syndication.io; | |
2 | ||
3 | ||
4 | import java.io.InputStream; | |
5 | import java.io.IOException; | |
6 | ||
7 | /** | |
8 | * The XmlReaderException is thrown by the XmlReader constructors if the charset encoding can not be | |
9 | * determined according to the XML 1.0 specification and RFC 3023. | |
10 | * <p> | |
11 | * The exception returns the unconsumed InputStream to allow the application to do an alternate | |
12 | * processing with the stream. Note that the original InputStream given to the XmlReader cannot be | |
13 | * used as that one has been already read. | |
14 | * <p> | |
15 | * | |
16 | * @author Alejandro Abdelnur | |
17 | * @version revision 1.8 taken on 2008-03-06 from Rome (see | |
18 | * https://rome.dev.java.net/source/browse/rome/src/java/com/sun/syndication/io/XmlReaderException.java) | |
19 | */ | |
20 | public class XmlReaderException extends IOException { | |
21 | private String _bomEncoding; | |
22 | private String _xmlGuessEncoding; | |
23 | private String _xmlEncoding; | |
24 | private String _contentTypeMime; | |
25 | private String _contentTypeEncoding; | |
26 | private InputStream _is; | |
27 | ||
28 | /** | |
29 | * Creates an exception instance if the charset encoding could not be determined. | |
30 | * <p> | |
31 | * Instances of this exception are thrown by the XmlReader. | |
32 | * <p> | |
33 | * | |
34 | * @param msg message describing the reason for the exception. | |
35 | * @param bomEnc BOM encoding. | |
36 | * @param xmlGuessEnc XML guess encoding. | |
37 | * @param xmlEnc XML prolog encoding. | |
38 | * @param is the unconsumed InputStream. | |
39 | */ | |
40 | 4 | public XmlReaderException(String msg,String bomEnc,String xmlGuessEnc,String xmlEnc,InputStream is) { |
41 | 4 | this(msg,null,null,bomEnc,xmlGuessEnc,xmlEnc,is); |
42 | } | |
43 | ||
44 | /** | |
45 | * Creates an exception instance if the charset encoding could not be determined. | |
46 | * <p> | |
47 | * Instances of this exception are thrown by the XmlReader. | |
48 | * <p> | |
49 | * | |
50 | * @param msg message describing the reason for the exception. | |
51 | * @param ctMime MIME type in the content-type. | |
52 | * @param ctEnc encoding in the content-type. | |
53 | * @param bomEnc BOM encoding. | |
54 | * @param xmlGuessEnc XML guess encoding. | |
55 | * @param xmlEnc XML prolog encoding. | |
56 | * @param is the unconsumed InputStream. | |
57 | */ | |
58 | 7 | public XmlReaderException(String msg,String ctMime,String ctEnc, |
59 | String bomEnc,String xmlGuessEnc,String xmlEnc,InputStream is) { | |
60 | 7 | super(msg); |
61 | 7 | _contentTypeMime = ctMime; |
62 | 7 | _contentTypeEncoding = ctEnc; |
63 | 7 | _bomEncoding = bomEnc; |
64 | 7 | _xmlGuessEncoding = xmlGuessEnc; |
65 | 7 | _xmlEncoding = xmlEnc; |
66 | 7 | _is = is; |
67 | } | |
68 | ||
69 | /** | |
70 | * Returns the BOM encoding found in the InputStream. | |
71 | * <p> | |
72 | * | |
73 | * @return the BOM encoding, null if none. | |
74 | */ | |
75 | 2 | public String getBomEncoding() { |
76 | 2 | return _bomEncoding; |
77 | } | |
78 | ||
79 | /** | |
80 | * Returns the encoding guess based on the first bytes of the InputStream. | |
81 | * <p> | |
82 | * | |
83 | * @return the encoding guess, null if it couldn't be guessed. | |
84 | */ | |
85 | 2 | public String getXmlGuessEncoding() { |
86 | 2 | return _xmlGuessEncoding; |
87 | } | |
88 | ||
89 | /** | |
90 | * Returns the encoding found in the XML prolog of the InputStream. | |
91 | * <p> | |
92 | * | |
93 | * @return the encoding of the XML prolog, null if none. | |
94 | */ | |
95 | 2 | public String getXmlEncoding() { |
96 | 2 | return _xmlEncoding; |
97 | } | |
98 | ||
99 | /** | |
100 | * Returns the MIME type in the content-type used to attempt determining the encoding. | |
101 | * <p> | |
102 | * | |
103 | * @return the MIME type in the content-type, null if there was not content-type or the encoding | |
104 | * detection did not involve HTTP. | |
105 | */ | |
106 | 2 | public String getContentTypeMime() { |
107 | 2 | return _contentTypeMime; |
108 | } | |
109 | ||
110 | /** | |
111 | * Returns the encoding in the content-type used to attempt determining the encoding. | |
112 | * <p> | |
113 | * | |
114 | * @return the encoding in the content-type, null if there was not content-type, no encoding in | |
115 | * it or the encoding detection did not involve HTTP. | |
116 | */ | |
117 | 2 | public String getContentTypeEncoding() { |
118 | 2 | return _contentTypeEncoding; |
119 | } | |
120 | ||
121 | /** | |
122 | * Returns the unconsumed InputStream to allow the application to do an alternate encoding | |
123 | * detection on the InputStream. | |
124 | * <p> | |
125 | * | |
126 | * @return the unconsumed InputStream. | |
127 | */ | |
128 | 2 | public InputStream getInputStream() { |
129 | 2 | return _is; |
130 | } | |
131 | } |
|