~ubuntu-branches/ubuntu/utopic/libcommons-compress-java/utopic

« back to all changes in this revision

Viewing changes to src/main/java/org/apache/commons/compress/utils/Charsets.java

  • Committer: Package Import Robot
  • Author(s): tony mancill
  • Date: 2013-05-17 07:53:06 UTC
  • mfrom: (7.1.1 experimental)
  • Revision ID: package-import@ubuntu.com-20130517075306-4yt0jyr782vasejl
Tags: 1.5-1
* Team upload.
* Upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
14
 * See the License for the specific language governing permissions and
15
15
 * limitations under the License.
16
 
 * 
 
16
 *
17
17
 */
18
18
 
19
19
package org.apache.commons.compress.utils;
20
20
 
21
21
import java.nio.charset.Charset;
22
 
import java.nio.charset.UnsupportedCharsetException;
23
22
 
24
23
/**
25
24
 * Charsets required of every implementation of the Java platform.
26
 
 * 
 
25
 *
27
26
 * From the Java documentation <a href="http://docs.oracle.com/javase/6/docs/api/java/nio/charset/Charset.html">Standard
28
27
 * charsets</a>:
29
28
 * <p>
31
30
 * release documentation for your implementation to see if any other encodings are supported. Consult the release
32
31
 * documentation for your implementation to see if any other encodings are supported. </cite>
33
32
 * </p>
34
 
 * 
 
33
 *
35
34
 * <ul>
36
35
 * <li><code>US-ASCII</code><br/>
37
36
 * Seven-bit ASCII, a.k.a. ISO646-US, a.k.a. the Basic Latin block of the Unicode character set.</li>
47
46
 * Sixteen-bit Unicode Transformation Format, byte order specified by a mandatory initial byte-order mark (either order
48
47
 * accepted on input, big-endian used on output.)</li>
49
48
 * </ul>
50
 
 * 
 
49
 *
51
50
 * This class best belongs in the Commons Lang or IO project. Even if a similar class is defined in another Commons component, it is
52
51
 * not foreseen that Commons Compress would be made to depend on another Commons component.
53
 
 * 
 
52
 *
54
53
 * @see <a href="http://docs.oracle.com/javase/6/docs/api/java/nio/charset/Charset.html">Standard charsets</a>
55
54
 * @since 1.4
56
 
 * @version $Id: Charsets.java 1309643 2012-04-05 04:01:32Z ggregory $
 
55
 * @version $Id: Charsets.java 1437047 2013-01-22 17:00:33Z sebb $
57
56
 */
58
57
public class Charsets {
59
 
    
 
58
 
60
59
    //
61
60
    // This class should only contain Charset instances for required encodings. This guarantees that it will load correctly and
62
61
    // without delay on all Java platforms.
63
62
    //
64
 
    
 
63
 
65
64
    /**
66
 
     * Returns the given Charset or the default Charset if the given Charset is null. 
67
 
     * 
 
65
     * Returns the given Charset or the default Charset if the given Charset is null.
 
66
     *
68
67
     * @param charset
69
68
     *            A charset or null.
70
69
     * @return the given Charset or the default Charset if the given Charset is null
75
74
 
76
75
    /**
77
76
     * Returns a Charset for the named charset. If the name is null, return the default Charset.
78
 
     * 
 
77
     *
79
78
     * @param charset
80
79
     *            The name of the requested charset, may be null.
81
80
     * @return a Charset for the named charset
82
 
     * @throws UnsupportedCharsetException
 
81
     * @throws java.nio.charset.UnsupportedCharsetException
83
82
     *             If the named charset is unavailable
 
83
     * @throws java.nio.charset.IllegalCharsetNameException
 
84
     *             If the given charset name is illegal
84
85
     */
85
86
    public static Charset toCharset(String charset) {
86
87
        return charset == null ? Charset.defaultCharset() : Charset.forName(charset);
91
92
     * <p>
92
93
     * Every implementation of the Java platform is required to support this character encoding.
93
94
     * </p>
94
 
     * 
 
95
     *
95
96
     * @see <a href="http://docs.oracle.com/javase/6/docs/api/java/nio/charset/Charset.html">Standard charsets</a>
96
97
     */
97
98
    public static final Charset ISO_8859_1 = Charset.forName(CharsetNames.ISO_8859_1);
103
104
     * <p>
104
105
     * Every implementation of the Java platform is required to support this character encoding.
105
106
     * </p>
106
 
     * 
 
107
     *
107
108
     * @see <a href="http://docs.oracle.com/javase/6/docs/api/java/nio/charset/Charset.html">Standard charsets</a>
108
109
     */
109
110
    public static final Charset US_ASCII = Charset.forName(CharsetNames.US_ASCII);
116
117
     * <p>
117
118
     * Every implementation of the Java platform is required to support this character encoding.
118
119
     * </p>
119
 
     * 
 
120
     *
120
121
     * @see <a href="http://docs.oracle.com/javase/6/docs/api/java/nio/charset/Charset.html">Standard charsets</a>
121
122
     */
122
123
    public static final Charset UTF_16 = Charset.forName(CharsetNames.UTF_16);
128
129
     * <p>
129
130
     * Every implementation of the Java platform is required to support this character encoding.
130
131
     * </p>
131
 
     * 
 
132
     *
132
133
     * @see <a href="http://docs.oracle.com/javase/6/docs/api/java/nio/charset/Charset.html">Standard charsets</a>
133
134
     */
134
135
    public static final Charset UTF_16BE = Charset.forName(CharsetNames.UTF_16BE);
140
141
     * <p>
141
142
     * Every implementation of the Java platform is required to support this character encoding.
142
143
     * </p>
143
 
     * 
 
144
     *
144
145
     * @see <a href="http://docs.oracle.com/javase/6/docs/api/java/nio/charset/Charset.html">Standard charsets</a>
145
146
     */
146
147
    public static final Charset UTF_16LE = Charset.forName(CharsetNames.UTF_16LE);
152
153
     * <p>
153
154
     * Every implementation of the Java platform is required to support this character encoding.
154
155
     * </p>
155
 
     * 
 
156
     *
156
157
     * @see <a href="http://docs.oracle.com/javase/6/docs/api/java/nio/charset/Charset.html">Standard charsets</a>
157
158
     */
158
159
    public static final Charset UTF_8 = Charset.forName(CharsetNames.UTF_8);