< prev index next >

src/java.base/share/classes/java/nio/charset/Charset-X-Coder.java.template

Print this page


   1 /*
   2  * Copyright (c) 2000, 2013, 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


 178      *         The initial replacement; must not be {@code null}, must have
 179      *         non-zero length, must not be longer than max$ItypesPerOtype$,
 180      *         and must be {@linkplain #isLegalReplacement legal}
 181      *
 182      * @throws  IllegalArgumentException
 183      *          If the preconditions on the parameters do not hold
 184      */
 185     {#if[encoder]?protected:private}
 186     Charset$Coder$(Charset cs,
 187                    float average$ItypesPerOtype$,
 188                    float max$ItypesPerOtype$,
 189                    $replType$ replacement)
 190     {
 191         this.charset = cs;
 192         if (average$ItypesPerOtype$ <= 0.0f)
 193             throw new IllegalArgumentException("Non-positive "
 194                                                + "average$ItypesPerOtype$");
 195         if (max$ItypesPerOtype$ <= 0.0f)
 196             throw new IllegalArgumentException("Non-positive "
 197                                                + "max$ItypesPerOtype$");
 198         if (!Charset.atBugLevel("1.4")) {
 199             if (average$ItypesPerOtype$ > max$ItypesPerOtype$)
 200                 throw new IllegalArgumentException("average$ItypesPerOtype$"
 201                                                    + " exceeds "
 202                                                    + "max$ItypesPerOtype$");
 203         }
 204         this.replacement = replacement;
 205         this.average$ItypesPerOtype$ = average$ItypesPerOtype$;
 206         this.max$ItypesPerOtype$ = max$ItypesPerOtype$;
 207         replaceWith(replacement);
 208     }
 209 
 210     /**
 211      * Initializes a new $coder$.  The new $coder$ will have the given
 212      * $otypes-per-itype$ values and its replacement will be the
 213      * $replTypeName$ $defaultReplName$.
 214      *
 215      * @param  cs
 216      *         The charset that created this $coder$
 217      *
 218      * @param  average$ItypesPerOtype$
 219      *         A positive float value indicating the expected number of
 220      *         $otype$s that will be produced for each input $itype$
 221      *
 222      * @param  max$ItypesPerOtype$
 223      *         A positive float value indicating the maximum number of


   1 /*
   2  * Copyright (c) 2000, 2017, 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


 178      *         The initial replacement; must not be {@code null}, must have
 179      *         non-zero length, must not be longer than max$ItypesPerOtype$,
 180      *         and must be {@linkplain #isLegalReplacement legal}
 181      *
 182      * @throws  IllegalArgumentException
 183      *          If the preconditions on the parameters do not hold
 184      */
 185     {#if[encoder]?protected:private}
 186     Charset$Coder$(Charset cs,
 187                    float average$ItypesPerOtype$,
 188                    float max$ItypesPerOtype$,
 189                    $replType$ replacement)
 190     {
 191         this.charset = cs;
 192         if (average$ItypesPerOtype$ <= 0.0f)
 193             throw new IllegalArgumentException("Non-positive "
 194                                                + "average$ItypesPerOtype$");
 195         if (max$ItypesPerOtype$ <= 0.0f)
 196             throw new IllegalArgumentException("Non-positive "
 197                                                + "max$ItypesPerOtype$");

 198         if (average$ItypesPerOtype$ > max$ItypesPerOtype$)
 199             throw new IllegalArgumentException("average$ItypesPerOtype$"
 200                                                + " exceeds "
 201                                                + "max$ItypesPerOtype$");

 202         this.replacement = replacement;
 203         this.average$ItypesPerOtype$ = average$ItypesPerOtype$;
 204         this.max$ItypesPerOtype$ = max$ItypesPerOtype$;
 205         replaceWith(replacement);
 206     }
 207 
 208     /**
 209      * Initializes a new $coder$.  The new $coder$ will have the given
 210      * $otypes-per-itype$ values and its replacement will be the
 211      * $replTypeName$ $defaultReplName$.
 212      *
 213      * @param  cs
 214      *         The charset that created this $coder$
 215      *
 216      * @param  average$ItypesPerOtype$
 217      *         A positive float value indicating the expected number of
 218      *         $otype$s that will be produced for each input $itype$
 219      *
 220      * @param  max$ItypesPerOtype$
 221      *         A positive float value indicating the maximum number of


< prev index next >