1 /*
2 * Copyright (c) 2000, 2007, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
959 * <code>UnsupportedOperationException</code> if not. Otherwise,
960 * it returns a clone of the <code>compressionTypes</code>
961 * instance variable if it is non-<code>null</code>, or else
962 * returns <code>null</code>.
963 *
964 * @return an array of <code>String</code>s containing the
965 * (non-localized) names of available compression types, or
966 * <code>null</code>.
967 *
968 * @exception UnsupportedOperationException if the writer does not
969 * support compression.
970 */
971 public String[] getCompressionTypes() {
972 if (!canWriteCompressed()) {
973 throw new UnsupportedOperationException(
974 "Compression not supported");
975 }
976 if (compressionTypes == null) {
977 return null;
978 }
979 return (String[])compressionTypes.clone();
980 }
981
982 /**
983 * Sets the compression type to one of the values indicated by
984 * <code>getCompressionTypes</code>. If a value of
985 * <code>null</code> is passed in, any previous setting is
986 * removed.
987 *
988 * <p> The default implementation checks whether compression is
989 * supported and the compression mode is
990 * <code>MODE_EXPLICIT</code>. If so, it calls
991 * <code>getCompressionTypes</code> and checks if
992 * <code>compressionType</code> is one of the legal values. If it
993 * is, the <code>compressionType</code> instance variable is set.
994 * If <code>compressionType</code> is <code>null</code>, the
995 * instance variable is set without performing any checking.
996 *
997 * @param compressionType one of the <code>String</code>s returned
998 * by <code>getCompressionTypes</code>, or <code>null</code> to
999 * remove any previous setting.
|
1 /*
2 * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
959 * <code>UnsupportedOperationException</code> if not. Otherwise,
960 * it returns a clone of the <code>compressionTypes</code>
961 * instance variable if it is non-<code>null</code>, or else
962 * returns <code>null</code>.
963 *
964 * @return an array of <code>String</code>s containing the
965 * (non-localized) names of available compression types, or
966 * <code>null</code>.
967 *
968 * @exception UnsupportedOperationException if the writer does not
969 * support compression.
970 */
971 public String[] getCompressionTypes() {
972 if (!canWriteCompressed()) {
973 throw new UnsupportedOperationException(
974 "Compression not supported");
975 }
976 if (compressionTypes == null) {
977 return null;
978 }
979 return compressionTypes.clone();
980 }
981
982 /**
983 * Sets the compression type to one of the values indicated by
984 * <code>getCompressionTypes</code>. If a value of
985 * <code>null</code> is passed in, any previous setting is
986 * removed.
987 *
988 * <p> The default implementation checks whether compression is
989 * supported and the compression mode is
990 * <code>MODE_EXPLICIT</code>. If so, it calls
991 * <code>getCompressionTypes</code> and checks if
992 * <code>compressionType</code> is one of the legal values. If it
993 * is, the <code>compressionType</code> instance variable is set.
994 * If <code>compressionType</code> is <code>null</code>, the
995 * instance variable is set without performing any checking.
996 *
997 * @param compressionType one of the <code>String</code>s returned
998 * by <code>getCompressionTypes</code>, or <code>null</code> to
999 * remove any previous setting.
|