Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1)

E13403-03

oracle.jdeveloper.compare
Class StreamDecoder

java.lang.Object
  extended by oracle.jdeveloper.compare.StreamDecoder

public final class StreamDecoder
extends java.lang.Object

This class handles the vagarities of decoding .xml, .html and text files using the correct encoding. A lot of this is duplicate code (from XMLNode and HTMLNode), but there's no obvious way to reuse that code :(


Constructor Summary
StreamDecoder()
           
 
Method Summary
static void deregisterDecoderHelper(StreamDecoderHelper decoderHelper)
          Deegister a decoder helper to assist with custom default encodings.
static java.lang.String getDefaultEncoding(java.net.URL url)
          Get the default encoding which will be used for the given URL, according to registered decoder helpers.
static java.io.Reader getReader(java.lang.String suffix, java.io.InputStream stream)
          Deprecated. replaced by getReader(String,InputStream,String) and getReader(String,URL).
static java.io.Reader getReader(java.lang.String suffix, java.io.InputStream stream, java.lang.String defaultEncoding)
          Get a reader for the specified URL.
static java.io.Reader getReader(java.lang.String suffix, java.net.URL url)
          Get a reader for the specified URL and file suffix.
static java.io.Reader getReader(java.net.URL url)
          Get a reader for the specified URL.
static Stream getStream(java.lang.String suffix, java.io.InputStream inputStream, java.lang.String defaultEncoding)
          Get a reader for the specified URL.
static void registerDecoderHelper(StreamDecoderHelper decoderHelper)
          Register a decoder helper to assist with custom default encodings.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StreamDecoder

public StreamDecoder()
Method Detail

registerDecoderHelper

public static final void registerDecoderHelper(StreamDecoderHelper decoderHelper)
Register a decoder helper to assist with custom default encodings.

Parameters:
decoderHelper - the decoder helper to register.

deregisterDecoderHelper

public static final void deregisterDecoderHelper(StreamDecoderHelper decoderHelper)
Deegister a decoder helper to assist with custom default encodings.

Parameters:
decoderHelper - the decoder helper to deregister.

getDefaultEncoding

public static final java.lang.String getDefaultEncoding(java.net.URL url)
Get the default encoding which will be used for the given URL, according to registered decoder helpers. If no custom default encoding is found, the value of IdeUtil.getIdeEncoding() is returned.

Parameters:
url - the URL.
Returns:
the default encoding.

getReader

public static java.io.Reader getReader(java.net.URL url)
                                throws java.io.IOException
Get a reader for the specified URL. The IDE's file type registry will be consulted to determine whether this file is an HTML file, an XML file or a text file. If the file is an .xml file, org.xml.sax.InputSource will be used to decode the file appropriately. If the file is an .html file, we scan a predefined number of bytes into the file searching for an encoding. If found, this encoding is used. If no encoding is found, the encoding set on the Environment page of preferences is used instead. If the file is neither an .html or .xml file, it is assumed to be a text file. The encoding set on the Environment page of preferences is used.

Throws:
java.io.IOException

getReader

public static java.io.Reader getReader(java.lang.String suffix,
                                       java.net.URL url)
                                throws java.io.IOException
Get a reader for the specified URL and file suffix. The IDE's file type registry will be consulted to determine whether this file is an HTML file, an XML file or a text file. If the file is an .xml file, org.xml.sax.InputSource will be used to decode the file appropriately. If the file is an .html file, we scan a predefined number of bytes into the file searching for an encoding. If found, this encoding is used. If no encoding is found, the encoding set on the Environment page of preferences is used instead. If the file is neither an .html or .xml file, it is assumed to be a text file. The encoding set on the Environment page of preferences is used.

Throws:
java.io.IOException

getReader

public static java.io.Reader getReader(java.lang.String suffix,
                                       java.io.InputStream stream)
                                throws java.io.IOException
Deprecated. replaced by getReader(String,InputStream,String) and getReader(String,URL).

Throws:
java.io.IOException

getReader

public static java.io.Reader getReader(java.lang.String suffix,
                                       java.io.InputStream stream,
                                       java.lang.String defaultEncoding)
                                throws java.io.IOException
Get a reader for the specified URL. The IDE's file type registry will be consulted to determine whether this file is an HTML file, an XML file or a text file. If the file is an .xml file, org.xml.sax.InputSource will be used to decode the file appropriately. If the file is an .html file, we scan a predefined number of bytes into the file searching for an encoding. If found, this encoding is used. If no encoding is found, the encoding set on the Environment page of preferences is used instead. If the file is neither an .html or .xml file, it is assumed to be a text file. The encoding set on the Environment page of preferences is used.

Throws:
java.io.IOException

getStream

public static Stream getStream(java.lang.String suffix,
                               java.io.InputStream inputStream,
                               java.lang.String defaultEncoding)
                        throws java.io.IOException
Get a reader for the specified URL. The IDE's file type registry will be consulted to determine whether this file is an HTML file, an XML file or a text file. If the file is an .xml file, org.xml.sax.InputSource will be used to decode the file appropriately. If the file is an .html file, we scan a predefined number of bytes into the file searching for an encoding. If found, this encoding is used. If no encoding is found, the encoding set on the Environment page of preferences is used instead. If the file is neither an .html or .xml file, it is assumed to be a text file. The encoding set on the Environment page of preferences is used.

Throws:
java.io.IOException

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1)

E13403-03

Copyright © 1997, 2009, Oracle. All rights reserved.