public void TestNoCoalesce()
        {
            String str    = "This is   a test\rto see if\nwhitespace is handled \n\r unusually\r\n by our tokenizer\n\n\n!!!plus some other odd ones like \ttab\ttab\ttab\nand form\ffeed\ffoo.\n";
            String delims = " \t\n\r\f\ud800\udc00";

            ILOG.J2CsMapping.Util.StringTokenizer jt = new ILOG.J2CsMapping.Util.StringTokenizer(str,
                                                                                                 delims, true);
            IBM.ICU.Util.StringTokenizer it = new IBM.ICU.Util.StringTokenizer(
                str, delims, true);
            int n = 0;

            while (jt.HasMoreTokens() && it.HasMoreTokens())
            {
                AssertEquals("[" + n++.ToString() + "]", jt.NextToken(),
                             it.NextToken());
            }
            AssertFalse("java tokenizer has no more tokens", jt.HasMoreTokens());
            AssertFalse("icu tokenizer has no more tokens", it.HasMoreTokens());

            String sur = "Even\ud800\udc00 works.\n\n";

            it = new IBM.ICU.Util.StringTokenizer(sur, delims, true); // no
            // coalesce
            AssertEquals("sur1", it.NextToken(), "Even");
            AssertEquals("sur2", it.NextToken(), "\ud800\udc00");
            AssertEquals("sur3", it.NextToken(), " ");
            AssertEquals("sur4", it.NextToken(), "works.");
            AssertEquals("sur5", it.NextToken(), "\n");
            AssertEquals("sur6", it.NextToken(), "\n");
            AssertFalse("sur7", it.HasMoreTokens());
        }
Example #2
0
        static internal Locale[] Find(String prefix)
        {
            int    last        = prefix.LastIndexOf('/');
            String thePackage  = prefix.Substring(0, (last + 1) - (0));
            int    length      = prefix.Length;
            String classPrefix = prefix.Substring(last + 1, (length) - (last + 1));

            ILOG.J2CsMapping.Collections.Generics.ISet <String> result = new HashedSet <String>();
            ILOG.J2CsMapping.Util.StringTokenizer paths = new ILOG.J2CsMapping.Util.StringTokenizer(System.Environment.GetEnvironmentVariable("org.apache.harmony.boot.class.path"), System.Environment.GetEnvironmentVariable("path.separator")); //$NON-NLS-1$//$NON-NLS-2$
            while (paths.HasMoreTokens())
            {
                String        nextToken = paths.NextToken();
                DirectoryInfo directory = new DirectoryInfo(nextToken);
                if (directory.Exists)
                {
                    if (System.IO.Directory.Exists(directory.Name))
                    {
                        String path;
                        try
                        {
                            path = directory.FullName;
                        }
                        catch (IOException e)
                        {
                            continue;
                        }
                        DirectoryInfo newDir;
                        if (path[path.Length - 1] == Path.PathSeparator)
                        {
                            newDir = new DirectoryInfo(path + thePackage);
                        }
                        else
                        {
                            newDir = new DirectoryInfo(path + Path.PathSeparator
                                                       + thePackage);
                        }
                        if (System.IO.Directory.Exists(newDir.Name))
                        {
                            FileInfo[] list = newDir.GetFiles();
                            for (int i = 0; i < list.Length; i++)
                            {
                                FileInfo file = list[i];
                                String   name = file.Name;
                                if (name.StartsWith(classPrefix) &&
                                    name.EndsWith(".class"))
                                { //$NON-NLS-1$
                                    ILOG.J2CsMapping.Collections.Generics.Collections.Add(result, name.Substring(0, (name.Length - 6) - (0)));
                                }
                            }
                        }
                    }
                    else
                    {
                        // Handle ZIP/JAR files.
                        try
                        {
                            /*ZipPackage zip = new ZipPackage(directory);
                             * IIterator<ZipPackagePart> entries = zip.Entries();
                             * while (entries.HasNext()) {
                             *  ZipPackagePart e_0 = entries.Next();
                             *  String name_1 = e_0.GetName();
                             *  if (name_1.StartsWith(prefix)
                             *          && name_1.EndsWith(".class")) {//$NON-NLS-1$
                             *      ILOG.J2CsMapping.Collections.Generics.Collections.Add(result,name_1.Substring(last + 1,(name_1.Length - 6)-(last + 1)));
                             *  }
                             * }*/
                            //zip.Close();
                        }
                        catch (IOException e_2)
                        {
                            // Empty
                        }
                    }
                }
            }
            Locale[] locales = new Locale[result.Count];
            int      i_3     = 0;

            /* foreach */
            foreach (String name_4 in result)
            {
                int index     = name_4.IndexOf('_');
                int nextIndex = name_4.IndexOf('_', index + 1);
                if (nextIndex == -1)
                {
                    locales[i_3++] = new Locale(name_4.Substring(index + 1, (name_4.Length) - (index + 1)), ""); //$NON-NLS-1$
                }
                else
                {
                    String language = name_4.Substring(index + 1, (nextIndex) - (index + 1));
                    String variant;
                    if ((index = name_4.IndexOf('_', nextIndex + 1)) == -1)
                    {
                        variant = ""; //$NON-NLS-1$
                        index   = name_4.Length;
                    }
                    else
                    {
                        variant = name_4.Substring(index + 1, (name_4.Length) - (index + 1));
                    }
                    String country = name_4.Substring(nextIndex + 1, (index) - (nextIndex + 1));
                    locales[i_3++] = new Locale(language, country, variant);
                }
            }
            return(locales);
        }