예제 #1
0
        /**
         * Adds an Arabic character with an attached diacritic to the table.
         *
         * @param unicodeType
         *            the type of Unicode character
         *
         * @param ch
         *            the output character
         *
         * @param characterType
         *            the type of Arabic character
         *
         * @param diacriticType
         *            the type of diacritic
         */
        protected void addItem(UnicodeType unicodeType, char ch, CharacterType characterType, DiacriticType diacriticType)
        {
            // Create the item that will be added to the table.
            EncodingTableItem item = new EncodingTableItem(characterType, diacriticType);

            // Unicode --> item
            unicodeMap[ch] = item;

            // Character type --> Unicode
            if (characterType != CharacterType.Unknown && diacriticType == DiacriticType.Unknown)
            {
                characterList[(int)characterType] = ch;
            }

            // Unicode type --> Unicode
            unicodeList[(int)unicodeType] = ch;
        }
예제 #2
0
        /**
         * Attaches a diacritic to the last character in the buffer.
         *
         * @param diacriticType
         *            the type of diacritic to attach, such as <i>Fatha</i> or
         *            <i>Shadda</i>.
         */
        public void add(DiacriticType diacriticType)
        {
            // Get offset into buffer, based on last character.
            int offset = (characterCount - 1) * ByteFormat.CHARACTER_WIDTH;

            // Set the diacritic.
            ByteFormat.setDiacritic(buffer, offset, diacriticType);
        }
예제 #3
0
 /**
  * Adds a diacritic to the table.
  *
  * @param unicodeType
  *            the type of Unicode character
  *
  * @param ch
  *            the output character
  *
  * @param diacriticType
  *            the type of diacritic
  */
 protected void addItem(UnicodeType unicodeType, char ch, DiacriticType diacriticType)
 {
     this.addItem(unicodeType, ch, CharacterType.Unknown, diacriticType);
 }
예제 #4
0
        /**
         * Sets a diacritic as present.
         *
         * @param buffer
         *            the <code>byte[]</code> buffer
         *
         * @param offset
         *            the offset of the character
         *
         * @param diacriticType
         *            the type of diacritic to set
         */
        public static void setDiacritic(byte[] buffer, int offset, DiacriticType diacriticType)
        {
            // Convert enum to integer.
            int value = (int)diacriticType;

            // Get offset into buffer, based on last character.
            int byteOffset = offset + diacriticOffsets[value];

            // Get bit mask.
            int bitMask = diacriticMasks[value];

            // Set bit.
            buffer[byteOffset] |= (byte)bitMask;
        }
예제 #5
0
        /**
         * Determines if only a single diacritic is attached.
         *
         * @param buffer
         *            the <code>byte[]</code> buffer
         *
         * @param offset
         *            the offset of the character
         *
         * @param diacriticType
         *            the single diacritic
         * @return <code>true</code> if the character has only the specified
         *         diacritic and no others; <code>false</code> otherwise.
         */
        public static bool isSingleDiacritic(byte[] buffer, int offset,
                DiacriticType diacriticType)
        {
            // Get diacritic offset and bitmask.
            int ordinal = (int)diacriticType;
            int diacriticOffset = diacriticOffsets[ordinal];
            int bitMask = diacriticMasks[ordinal];

            // Validate.
            return buffer[offset + diacriticOffset] == bitMask
                    && buffer[offset + 3 - diacriticOffset] == 0;
        }
예제 #6
0
        /**
         * Determines if a diacritic is present.
         *
         * @param buffer
         *            the <code>byte[]</code> buffer
         *
         * @param offset
         *            the offset of the character
         *
         * @param diacriticType
         *            the type of diacritic
         *
         * @return <code>true</code> if the diacritic is present; <code>false</code>
         *         otherwise
         */
        public static bool isDiacritic(byte[] buffer, int offset,
                DiacriticType diacriticType)
        {
            // Convert enum to integer.
            int value = (int)diacriticType;

            // Get offset into buffer, based on last character.
            int byteOffset = offset + diacriticOffsets[value];

            // Get bit mask.
            int bitMask = diacriticMasks[value];

            // Get bit.
            return (buffer[byteOffset] & bitMask) != 0;
        }
예제 #7
0
 public EncodingTableItem(CharacterType characterType, DiacriticType diacriticType)
 {
     this.CharacterType = characterType;
     this.DiacriticType = diacriticType;
 }