/** ******************************************************************************* * Copyright (C) 1996-2001, International Business Machines Corporation and * * others. All Rights Reserved. * ******************************************************************************* * * $Source: /xsrl/Nsvn/icu/unicodetools/com/ibm/text/UCD/UData.java,v $ * $Date: 2002/06/15 02:47:12 $ * $Revision: 1.5 $ * ******************************************************************************* */ package com.ibm.text.UCD; import java.io.*; import com.ibm.text.utility.*; class UData implements UCD_Types { String name; String shortName; // cache String decompositionMapping; String simpleUppercase; String simpleLowercase; String simpleTitlecase; String simpleCaseFolding; String fullUppercase; String fullLowercase; String fullTitlecase; String fullCaseFolding; String specialCasing = ""; String bidiMirror; int codePoint = -1; float numericValue = Float.NaN; int binaryProperties; // bidiMirroring, compositionExclusions, PropList byte generalCategory = Cn; byte combiningClass = 0; byte bidiClass = BIDI_ON; byte decompositionType = NONE; byte numericType = NUMERIC_NONE; byte eastAsianWidth = EAN; byte lineBreak = LBXX; byte joiningType = JT_U; byte joiningGroup = NO_SHAPING; byte script = COMMON_SCRIPT; byte age = 0; static final UData UNASSIGNED = new UData(); //static final UData NONCHARACTER = new UData(); static { UNASSIGNED.name = ""; UNASSIGNED.decompositionMapping = UNASSIGNED.bidiMirror = UNASSIGNED.simpleUppercase = UNASSIGNED.simpleLowercase = UNASSIGNED.simpleTitlecase = ""; UNASSIGNED.fleshOut(); /*NONCHARACTER.name = ""; NONCHARACTER.decompositionMapping = NONCHARACTER.bidiMirror = NONCHARACTER.simpleUppercase = NONCHARACTER.simpleLowercase = NONCHARACTER.simpleTitlecase = ""; NONCHARACTER.binaryProperties = Noncharacter_Code_PointMask; NONCHARACTER.fleshOut(); */ } public UData (int codePoint) { this.codePoint = codePoint; } public UData () { } public boolean equals(Object that) { UData other = (UData) that; if (!name.equals(other.name)) return false; if (!decompositionMapping.equals(other.decompositionMapping)) return false; if (!simpleUppercase.equals(other.simpleUppercase)) return false; if (!simpleLowercase.equals(other.simpleLowercase)) return false; if (!simpleTitlecase.equals(other.simpleTitlecase)) return false; if (!simpleCaseFolding.equals(other.simpleCaseFolding)) return false; if (!fullUppercase.equals(other.fullUppercase)) return false; if (!fullLowercase.equals(other.fullLowercase)) return false; if (!fullTitlecase.equals(other.fullTitlecase)) return false; if (!fullCaseFolding.equals(other.fullCaseFolding)) return false; if (!specialCasing.equals(other.specialCasing)) return false; if (!bidiMirror.equals(other.bidiMirror)) return false; if (codePoint != other.codePoint) return false; if (numericValue != other.numericValue) return false; if (binaryProperties != other.binaryProperties) return false; if (generalCategory != other.generalCategory) return false; if (combiningClass != other.combiningClass) return false; if (bidiClass != other.bidiClass) return false; if (decompositionType != other.decompositionType) return false; if (numericType != other.numericType) return false; if (eastAsianWidth != other.eastAsianWidth) return false; if (lineBreak != other.lineBreak) return false; if (joiningType != other.joiningType) return false; if (joiningGroup != other.joiningGroup) return false; if (script != other.script) return false; if (age != other.age) return false; return true; } public void fleshOut() { String codeValue = UTF32.valueOf32(codePoint); if (decompositionMapping == null) decompositionMapping = codeValue; if (bidiMirror == null) bidiMirror = codeValue; if (simpleLowercase == null) simpleLowercase = codeValue; if (simpleCaseFolding == null) simpleCaseFolding = simpleLowercase; if (fullLowercase == null) fullLowercase = simpleLowercase; if (fullCaseFolding == null) fullCaseFolding = fullLowercase; if (simpleUppercase == null) simpleUppercase = codeValue; if (simpleTitlecase == null) simpleTitlecase = codeValue; if (fullUppercase == null) fullUppercase = simpleUppercase; if (fullTitlecase == null) fullTitlecase = simpleTitlecase; } public void compact() { fleshOut(); String codeValue = UTF32.valueOf32(codePoint); if (fullTitlecase.equals(simpleTitlecase)) fullTitlecase = null; if (fullUppercase.equals(simpleUppercase)) fullUppercase = null; if (simpleTitlecase.equals(codeValue)) simpleTitlecase = null; if (simpleUppercase.equals(codeValue)) simpleUppercase = null; if (fullCaseFolding.equals(fullLowercase)) fullCaseFolding = null; if (fullLowercase.equals(simpleLowercase)) fullLowercase = null; if (simpleCaseFolding.equals(simpleLowercase)) simpleCaseFolding = null; if (simpleLowercase.equals(codeValue)) simpleLowercase = null; if (decompositionMapping.equals(codeValue)) decompositionMapping = null; if (bidiMirror.equals(codeValue)) bidiMirror = null; } public void setBinaryProperties(int binaryProperties) { this.binaryProperties = binaryProperties; } public boolean isLetter() { return ((1<"); return result.toString(); } public void writeBytes(DataOutputStream os) throws IOException { compact(); os.writeInt(codePoint); writeString(os, name); writeString(os, decompositionMapping); writeString(os, simpleUppercase); writeString(os, simpleLowercase); writeString(os, simpleTitlecase); writeString(os, simpleCaseFolding); writeString(os, fullUppercase); writeString(os, fullLowercase); writeString(os, fullTitlecase); writeString(os, fullCaseFolding); writeString(os, specialCasing); writeString(os, bidiMirror); os.writeFloat(numericValue); os.writeInt(binaryProperties); os.writeByte(generalCategory); os.writeByte(combiningClass); os.writeByte(bidiClass); os.writeByte(decompositionType); os.writeByte(numericType); os.writeByte(eastAsianWidth); os.writeByte(lineBreak); os.writeByte(joiningType); os.writeByte(joiningGroup); os.writeByte(script); os.writeByte(age); } public void readBytes(DataInputStream is) throws IOException { codePoint = is.readInt(); name = readString(is); decompositionMapping = readString(is); simpleUppercase = readString(is); simpleLowercase = readString(is); simpleTitlecase = readString(is); simpleCaseFolding = readString(is); fullUppercase = readString(is); fullLowercase = readString(is); fullTitlecase = readString(is); fullCaseFolding = readString(is); specialCasing = readString(is); bidiMirror = readString(is); numericValue = is.readFloat(); binaryProperties = is.readInt(); generalCategory = is.readByte(); combiningClass = is.readByte(); bidiClass = is.readByte(); decompositionType = is.readByte(); numericType = is.readByte(); eastAsianWidth = is.readByte(); lineBreak = is.readByte(); joiningType = is.readByte(); joiningGroup = is.readByte(); script = is.readByte(); age = is.readByte(); fleshOut(); // HACK /* int bp = binaryProperties; bp &= ~(1 << CaseFoldTurkishI); // clear bit if (codePoint == 'i' || codePoint == 'I') { bp |= (1 << CaseFoldTurkishI); } if (bp != binaryProperties) { if (!HACK) { System.out.println("\tHACK Resetting CaseFoldTurkishI on U+" + Utility.hex(codePoint) + " " + name + " and others..."); HACK = true; } binaryProperties = bp; } */ /* if (generalCategory == Sm) { if ((binaryProperties & Math_PropertyMask) != 0) { if (!HACK) { System.out.println("Stripping " + Utility.hex(codePoint) + " " + name + " and others..."); HACK = true; } binaryProperties &= ~Math_PropertyMask; } } */ } static boolean HACK = false; }