|
16 | 16 | * limitations under the License. |
17 | 17 | */ |
18 | 18 |
|
| 19 | +import org.codehaus.plexus.util.xml.XmlStreamReader; |
| 20 | + |
19 | 21 | import java.io.File; |
20 | 22 | import java.io.IOException; |
21 | 23 | import java.io.InputStream; |
|
29 | 31 | /** |
30 | 32 | * Utility to create Readers from streams, with explicit encoding choice: platform default, XML, or specified. |
31 | 33 | * |
| 34 | + * @deprecated This class has been deprecated. When reading XML, users are encouraged to pass the {@code InputStream} |
| 35 | + * directory to the {@link org.codehaus.plexus.util.xml.pull.MXParser#setInput(InputStream, String)}, |
| 36 | + * giving a {@code null} encoding to let the parser figure it out. For non xml usages, use the JDK |
| 37 | + * {@link Files} utility methods. |
| 38 | + * |
32 | 39 | * @author <a href="mailto:[email protected]">Herve Boutemy</a> |
33 | 40 | * @see Charset |
34 | 41 | * @see <a href="http://java.sun.com/j2se/1.4.2/docs/guide/intl/encoding.doc.html">Supported encodings</a> |
35 | 42 | * |
36 | 43 | * @since 1.4.3 |
37 | | - * @deprecated use org.codehaus.plexus.util.xml.ReaderFactory from plexus-xml 4 |
38 | 44 | */ |
| 45 | +@Deprecated |
39 | 46 | public class ReaderFactory |
40 | 47 | { |
41 | 48 | /** |
@@ -92,6 +99,48 @@ public class ReaderFactory |
92 | 99 | */ |
93 | 100 | public static final String FILE_ENCODING = System.getProperty( "file.encoding" ); |
94 | 101 |
|
| 102 | + /** |
| 103 | + * Create a new Reader with XML encoding detection rules. |
| 104 | + * |
| 105 | + * @param in not null input stream. |
| 106 | + * @return an XML reader instance for the input stream. |
| 107 | + * @throws IOException if any. |
| 108 | + * @see XmlStreamReader |
| 109 | + */ |
| 110 | + public static XmlStreamReader newXmlReader( InputStream in ) |
| 111 | + throws IOException |
| 112 | + { |
| 113 | + return new XmlStreamReader( in ); |
| 114 | + } |
| 115 | + |
| 116 | + /** |
| 117 | + * Create a new Reader with XML encoding detection rules. |
| 118 | + * |
| 119 | + * @param file not null file. |
| 120 | + * @return an XML reader instance for the input file. |
| 121 | + * @throws IOException if any. |
| 122 | + * @see XmlStreamReader |
| 123 | + */ |
| 124 | + public static XmlStreamReader newXmlReader( File file ) |
| 125 | + throws IOException |
| 126 | + { |
| 127 | + return new XmlStreamReader( file ); |
| 128 | + } |
| 129 | + |
| 130 | + /** |
| 131 | + * Create a new Reader with XML encoding detection rules. |
| 132 | + * |
| 133 | + * @param url not null url. |
| 134 | + * @return an XML reader instance for the input url. |
| 135 | + * @throws IOException if any. |
| 136 | + * @see XmlStreamReader |
| 137 | + */ |
| 138 | + public static XmlStreamReader newXmlReader( URL url ) |
| 139 | + throws IOException |
| 140 | + { |
| 141 | + return new XmlStreamReader( url ); |
| 142 | + } |
| 143 | + |
95 | 144 | /** |
96 | 145 | * Create a new Reader with default platform encoding. |
97 | 146 | * |
|
0 commit comments