Ejemplo n.º 1
0
        // protected constructor -------------------------------------------

        /// <summary>
        /// Trie constructor for CharTrie use.
        /// </summary>
        ///
        /// <param name="inputStream">ICU data file input stream which contains the trie</param>
        /// <param name="dataManipulate">object containing the information to parse the trie data</param>
        /// <exception cref="IOException">thrown when input stream does not have the right header.</exception>
        /// @draft 2.1
        protected internal Trie(DataInputStream inputStream, Trie.DataManipulate dataManipulate)
        {
            DataInputStream input = inputStream; // new DataInputStream(inputStream);
            // Magic number to authenticate the data.
            int signature = input.ReadInt();

            m_options_ = input.ReadInt();

            if (!CheckHeader(signature))
            {
                throw new ArgumentException(
                          "ICU data file error: Trie header authentication failed, please check if you have the most updated ICU data file");
            }

            if (dataManipulate != null)
            {
                m_dataManipulate_ = dataManipulate;
            }
            else
            {
                m_dataManipulate_ = new Trie.DefaultGetFoldingOffset();
            }
            m_isLatin1Linear_ = (m_options_ & HEADER_OPTIONS_LATIN1_IS_LINEAR_MASK_) != 0;
            m_dataOffset_     = input.ReadInt();
            m_dataLength_     = input.ReadInt();
            Unserialize(inputStream);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Trie constructor
 /// </summary>
 ///
 /// <param name="index">array to be used for index</param>
 /// <param name="options">used by the trie</param>
 /// <param name="dataManipulate">object containing the information to parse the trie data</param>
 /// @draft 2.2
 protected internal Trie(char[] index, int options, Trie.DataManipulate dataManipulate)
 {
     m_options_ = options;
     if (dataManipulate != null)
     {
         m_dataManipulate_ = dataManipulate;
     }
     else
     {
         m_dataManipulate_ = new Trie.DefaultGetFoldingOffset();
     }
     m_isLatin1Linear_ = (m_options_ & HEADER_OPTIONS_LATIN1_IS_LINEAR_MASK_) != 0;
     m_index_          = index;
     m_dataOffset_     = m_index_.Length;
 }