< prev index next >

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

Print this page
rev 57619 : imported patch 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 
  48 import java.io.IOException;
  49 import java.nio.ByteBuffer;
  50 import java.util.MissingResourceException;
  51 
  52 public final class UBiDiProps {
  53     // constructors etc. --------------------------------------------------- ***
  54 
  55     // port of ubidi_openProps()
  56     private UBiDiProps() throws IOException{
  57         ByteBuffer bytes=ICUBinary.getRequiredData(DATA_FILE_NAME);
  58         readData(bytes);
  59     }
  60 
  61     private void readData(ByteBuffer bytes) throws IOException {
  62         // read the header
  63         ICUBinary.readHeader(bytes, FMT, new IsAcceptable());
  64 
  65         // read indexes[]
  66         int i, count;


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


< prev index next >