コード例 #1
0
	public static java.lang.String test() {
		java.lang.StringBuilder sb = new java.lang.StringBuilder();
		sb.append('a');
		sb.append('\u0062');
		sb.append('\x63');
		return sb.toString();
	}
コード例 #2
0
        /** Splits a backslash escaped string on the separator.
         * <p>
         * Current backslash escaping supported:
         * <br> \n \t \r \b \f are escaped the same as a Java String
         * <br> Other characters following a backslash are produced verbatim (\c => c)
         *
         * @param s  the string to split
         * @param separator the separator to split on
         * @param decode decode backslash escaping
         */
        public static List /*<String>*/ splitSmart(string s, string separator, bool decode)
        {
            ArrayList /*<String>*/ lst = new ArrayList/*<String>*/ (2);

            java.lang.StringBuilder sb = new java.lang.StringBuilder();
            int pos = 0, end = s.Length;

            while (pos < end)
            {
                if (java.lang.String.instancehelper_startsWith(s, separator, pos))
                {
                    if (sb.length() > 0)
                    {
                        lst.add(sb.toString());
                        sb = new java.lang.StringBuilder();
                    }
                    pos += separator.Length;
                    continue;
                }

                char ch = s[pos++];
                if (ch == '\\')
                {
                    if (!decode)
                    {
                        sb.append(ch);
                    }
                    if (pos >= end)
                    {
                        break;  // ERROR, or let it go?
                    }
                    ch = s[pos++];
                    if (decode)
                    {
                        switch (ch)
                        {
                        case 'n': ch = '\n'; break;

                        case 't': ch = '\t'; break;

                        case 'r': ch = '\r'; break;

                        case 'b': ch = '\b'; break;

                        case 'f': ch = '\f'; break;
                        }
                    }
                }

                sb.append(ch);
            }

            if (sb.length() > 0)
            {
                lst.add(sb.toString());
            }

            return(lst);
        }
コード例 #3
0
 public static java.lang.String test()
 {
     java.lang.StringBuilder sb = new java.lang.StringBuilder();
     sb.append('a');
     sb.append('\u0062');
     sb.append('\x63');
     return(sb.toString());
 }
コード例 #4
0
        public static List /*<String>*/ splitWS(string s, bool decode)
        {
            ArrayList /*<String>*/ lst = new ArrayList/*<String>*/ (2);

            java.lang.StringBuilder sb = new java.lang.StringBuilder();
            int pos = 0, end = s.Length;

            while (pos < end)
            {
                char ch = s[pos++];
                if (java.lang.Character.isWhitespace(ch))
                {
                    if (sb.length() > 0)
                    {
                        lst.add(sb.toString());
                        sb = new java.lang.StringBuilder();
                    }
                    continue;
                }

                if (ch == '\\')
                {
                    if (!decode)
                    {
                        sb.append(ch);
                    }
                    if (pos >= end)
                    {
                        break;  // ERROR, or let it go?
                    }
                    ch = s[pos++];
                    if (decode)
                    {
                        switch (ch)
                        {
                        case 'n': ch = '\n'; break;

                        case 't': ch = '\t'; break;

                        case 'r': ch = '\r'; break;

                        case 'b': ch = '\b'; break;

                        case 'f': ch = '\f'; break;
                        }
                    }
                }

                sb.append(ch);
            }

            if (sb.length() > 0)
            {
                lst.add(sb.toString());
            }

            return(lst);
        }
コード例 #5
0
        /** Construct a compound token. */
        private Token gramToken(Token first, Token second)
        {
            buffer.setLength(0);
#pragma warning disable 612
            buffer.append(first.termText());
#pragma warning restore 612
            buffer.append(SEPARATOR);
#pragma warning disable 612
            buffer.append(second.termText());
#pragma warning restore 612
            Token result = new Token(buffer.toString(), first.startOffset(), second
                                     .endOffset(), "gram");
            result.setPositionIncrement(0);
            return(result);
        }
コード例 #6
0
        static SpellingQueryConverter()
        {
            java.lang.StringBuilder sb = new java.lang.StringBuilder();
            foreach (string part in NAMESTARTCHAR_PARTS)
            {
                sb.append(part);
            }
            foreach (string part in ADDITIONAL_NAMECHAR_PARTS)
            {
                sb.append(part);
            }
            string NMTOKEN = "([" + sb.toString() + "]|" + SURROGATE_PAIR + ")+";
            string PATTERN = "(?:(?!(" + NMTOKEN + ":|\\d+)))[\\p{L}_\\-0-9]+";

            QUERY_REGEX = Pattern.compile(PATTERN);
        }
コード例 #7
0
 public override string toString()
 {
     java.lang.StringBuilder sb = new java.lang.StringBuilder("TokenizerChain(");
     foreach (CharFilterFactory filter in charFilters)
     {
         sb.append(filter);
         sb.append(", ");
     }
     sb.append(tokenizer);
     foreach (TokenFilterFactory filter in filters)
     {
         sb.append(", ");
         sb.append(filter);
     }
     sb.append(')');
     return(sb.toString());
 }
コード例 #8
0
ファイル: BaseTokenTestCase.cs プロジェクト: formist/LinkMe
        public static string tsToString(TokenStream input)
        {
            java.lang.StringBuilder output = new java.lang.StringBuilder();
#pragma warning disable 612
            Token t = input.next();
#pragma warning restore 612
            if (null != t)
            {
                output.append(new string(t.termBuffer(), 0, t.termLength()));
            }

#pragma warning disable 612
            for (t = input.next(); null != t; t = input.next())
            {
#pragma warning restore 612
                output.append(" ").append(new string(t.termBuffer(), 0, t.termLength()));
            }
            input.close();
            return(output.toString());
        }
コード例 #9
0
        private static string GetCollationQuery(String origQuery,
                                                java.util.List /*<SpellCheckCorrection>*/ corrections)
        {
            var collation = new java.lang.StringBuilder(origQuery);
            int offset    = 0;

            for (var iter = corrections.iterator(); iter.hasNext();)
            {
                SpellCheckCorrection correction = (SpellCheckCorrection)iter.next();
                Token tok = correction.getOriginal();
                // we are replacing the query in order, but injected terms might cause
                // illegal offsets due to previous replacements.
                if (tok.getPositionIncrement() == 0)
                {
                    continue;
                }
                collation.replace(tok.startOffset() + offset, tok.endOffset() + offset,
                                  correction.getCorrection());
                offset += correction.getCorrection().Length
                          - (tok.endOffset() - tok.startOffset());
            }
            return(collation.toString());
        }
コード例 #10
0
 public new string ToString()
 {
     return(_builder.toString());
 }