예제 #1
0
        public static HyphenationTree getFopHyphenationTree(string key)
        {
            HyphenationTree hTree = null;
            Stream          istr  = null;

            try {
                istr = getResourceStream(key);
                if (istr == null)
                {
                    if (key.Length == 5)
                    {
                        istr = getResourceStream(key.Substring(0, 2));
                        if (istr != null)
                        {
                            Console.Error.WriteLine("Couldn't find hyphenation pattern  "
                                                    + key
                                                    + "\nusing general language pattern "
                                                    + key.Substring(0, 2)
                                                    + " instead.");
                        }
                        else
                        {
                            if (errorDump)
                            {
                                Console.Error.WriteLine("Couldn't find precompiled "
                                                        + "hyphenation pattern "
                                                        + key + ".hyp");
                            }
                            return(null);
                        }
                    }
                    else
                    {
                        if (errorDump)
                        {
                            Console.Error.WriteLine("Couldn't find precompiled "
                                                    + "hyphenation pattern "
                                                    + key + ".hyp");
                        }
                        return(null);
                    }
                }
                hTree = new HyphenationTree();
                hTree.loadInternalPatterns(istr);
            } catch (Exception e) {
                Console.Error.WriteLine(e.StackTrace);
            }
            finally {
                if (istr != null)
                {
                    try {
                        istr.Close();
                    } catch (IOException e) {
                        e.GetType();
                        Console.Error.WriteLine("can't close hyphenation stream");
                    }
                }
            }
            return(hTree);
        }