< prev index next >

src/java.base/share/classes/jdk/internal/icu/impl/UBiDiProps.java

Print this page
rev 57619 : [mq]: 8174270
   1 /*
   2  * Copyright (c) 2005, 2015, 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


  24  */
  25 /*
  26  *******************************************************************************
  27  *
  28  *   Copyright (C) 2004-2014, International Business Machines
  29  *   Corporation and others.  All Rights Reserved.
  30  *
  31  *******************************************************************************
  32  *   file name:  UBiDiProps.java
  33  *   encoding:   US-ASCII
  34  *   tab size:   8 (not used)
  35  *   indentation:4
  36  *
  37  *   created on: 2005jan16
  38  *   created by: Markus W. Scherer
  39  *
  40  *   Low-level Unicode bidi/shaping properties access.
  41  *   Java port of ubidi_props.h/.c.
  42  */
  43 
  44 package sun.text.normalizer;



  45 
  46 import java.io.IOException;
  47 import java.nio.ByteBuffer;
  48 import java.util.MissingResourceException;
  49 
  50 public final class UBiDiProps {
  51     // constructors etc. --------------------------------------------------- ***
  52 
  53     // port of ubidi_openProps()
  54     private UBiDiProps() throws IOException{
  55         ByteBuffer bytes=ICUBinary.getRequiredData(DATA_FILE_NAME);
  56         readData(bytes);
  57     }
  58 
  59     private void readData(ByteBuffer bytes) throws IOException {
  60         // read the header
  61         ICUBinary.readHeader(bytes, FMT, new IsAcceptable());
  62 
  63         // read indexes[]
  64         int i, count;


 179     }
 180 
 181     public final int getPairedBracket(int c) {
 182         int props=trie.get(c);
 183         if((props&BPT_MASK)==0) {
 184             return c;
 185         } else {
 186             return getMirror(c, props);
 187         }
 188     }
 189 
 190     // data members -------------------------------------------------------- ***
 191     private int indexes[];
 192     private int mirrors[];
 193     private byte jgArray[];
 194     private byte jgArray2[];
 195 
 196     private Trie2_16 trie;
 197 
 198     // data format constants ----------------------------------------------- ***
 199     private static final String DATA_FILE_NAME = "/sun/text/resources/ubidi.icu";




 200 
 201     /* format "BiDi" */
 202     private static final int FMT=0x42694469;
 203 
 204     /* indexes into indexes[] */
 205     private static final int IX_TRIE_SIZE=2;
 206     private static final int IX_MIRROR_LENGTH=3;
 207 
 208     private static final int IX_JG_START=4;
 209     private static final int IX_JG_LIMIT=5;
 210     private static final int IX_JG_START2=6;  /* new in format version 2.2, ICU 54 */
 211     private static final int IX_JG_LIMIT2=7;
 212 
 213     private static final int IX_TOP=16;
 214 
 215     // definitions for 16-bit bidi/shaping properties word ----------------- ***
 216 
 217                           /* CLASS_SHIFT=0, */     /* bidi class: 5 bits (4..0) */
 218     private static final int JT_SHIFT=5;           /* joining type: 3 bits (7..5) */
 219 


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


  24  */
  25 /*
  26  *******************************************************************************
  27  *
  28  *   Copyright (C) 2004-2014, International Business Machines
  29  *   Corporation and others.  All Rights Reserved.
  30  *
  31  *******************************************************************************
  32  *   file name:  UBiDiProps.java
  33  *   encoding:   US-ASCII
  34  *   tab size:   8 (not used)
  35  *   indentation:4
  36  *
  37  *   created on: 2005jan16
  38  *   created by: Markus W. Scherer
  39  *
  40  *   Low-level Unicode bidi/shaping properties access.
  41  *   Java port of ubidi_props.h/.c.
  42  */
  43 
  44 package jdk.internal.icu.impl;
  45 
  46 import jdk.internal.icu.lang.UCharacter;
  47 import jdk.internal.icu.util.VersionInfo;
  48 
  49 import java.io.IOException;
  50 import java.nio.ByteBuffer;
  51 import java.util.MissingResourceException;
  52 
  53 public final class UBiDiProps {
  54     // constructors etc. --------------------------------------------------- ***
  55 
  56     // port of ubidi_openProps()
  57     private UBiDiProps() throws IOException{
  58         ByteBuffer bytes=ICUBinary.getRequiredData(DATA_FILE_NAME);
  59         readData(bytes);
  60     }
  61 
  62     private void readData(ByteBuffer bytes) throws IOException {
  63         // read the header
  64         ICUBinary.readHeader(bytes, FMT, new IsAcceptable());
  65 
  66         // read indexes[]
  67         int i, count;


 182     }
 183 
 184     public final int getPairedBracket(int c) {
 185         int props=trie.get(c);
 186         if((props&BPT_MASK)==0) {
 187             return c;
 188         } else {
 189             return getMirror(c, props);
 190         }
 191     }
 192 
 193     // data members -------------------------------------------------------- ***
 194     private int indexes[];
 195     private int mirrors[];
 196     private byte jgArray[];
 197     private byte jgArray2[];
 198 
 199     private Trie2_16 trie;
 200 
 201     // data format constants ----------------------------------------------- ***
 202     @SuppressWarnings("deprecation")
 203     private static final String DATA_FILE_NAME =
 204             "/jdk/internal/icu/impl/data/icudt" +
 205             VersionInfo.ICU_DATA_VERSION_PATH +
 206             "/ubidi.icu";
 207 
 208     /* format "BiDi" */
 209     private static final int FMT=0x42694469;
 210 
 211     /* indexes into indexes[] */
 212     private static final int IX_TRIE_SIZE=2;
 213     private static final int IX_MIRROR_LENGTH=3;
 214 
 215     private static final int IX_JG_START=4;
 216     private static final int IX_JG_LIMIT=5;
 217     private static final int IX_JG_START2=6;  /* new in format version 2.2, ICU 54 */
 218     private static final int IX_JG_LIMIT2=7;
 219 
 220     private static final int IX_TOP=16;
 221 
 222     // definitions for 16-bit bidi/shaping properties word ----------------- ***
 223 
 224                           /* CLASS_SHIFT=0, */     /* bidi class: 5 bits (4..0) */
 225     private static final int JT_SHIFT=5;           /* joining type: 3 bits (7..5) */
 226 


< prev index next >