internal static void AppendQuoted(String chars, StringBuffer toAddTo) { bool inQuote = false; char ch = chars.CharAt(0); if (Character.IsSpaceChar(ch)) { inQuote = true; toAddTo.Append('\''); } else { if (PatternEntry.IsSpecialChar(ch)) { inQuote = true; toAddTo.Append('\''); } else { switch (ch) { case 0x0010: case '\f': case '\r': case '\t': case '\n': case '@': inQuote = true; toAddTo.Append('\''); break; case '\'': inQuote = true; toAddTo.Append('\''); break; default: if (inQuote) { inQuote = false; toAddTo.Append('\''); } break; } } } toAddTo.Append(chars); if (inQuote) { toAddTo.Append('\''); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public PatternEntry next() throws ParseException public virtual PatternEntry Next() { int newStrength = UNSET; NewChars.Length = 0; NewExtension.Length = 0; bool inChars = true; bool inQuote = false; while (i < Pattern.Length()) { char ch = Pattern.CharAt(i); if (inQuote) { if (ch == '\'') { inQuote = false; } else { if (NewChars.Length() == 0) { NewChars.Append(ch); } else if (inChars) { NewChars.Append(ch); } else { NewExtension.Append(ch); } } } else { switch (ch) { case '=': if (newStrength != UNSET) { goto mainLoopBreak; } newStrength = Collator.IDENTICAL; break; case ',': if (newStrength != UNSET) { goto mainLoopBreak; } newStrength = Collator.TERTIARY; break; case ';': if (newStrength != UNSET) { goto mainLoopBreak; } newStrength = Collator.SECONDARY; break; case '<': if (newStrength != UNSET) { goto mainLoopBreak; } newStrength = Collator.PRIMARY; break; case '&': if (newStrength != UNSET) { goto mainLoopBreak; } newStrength = RESET; break; case '\t': case '\n': case '\f': case '\r': case ' ': // skip whitespace TODO use Character break; case '/': inChars = false; break; case '\'': inQuote = true; ch = Pattern.CharAt(++i); if (NewChars.Length() == 0) { NewChars.Append(ch); } else if (inChars) { NewChars.Append(ch); } else { NewExtension.Append(ch); } break; default: if (newStrength == UNSET) { throw new ParseException("missing char (=,;<&) : " + Pattern.Substring(i, (10 < Pattern.Length()) ? i + 10 : Pattern.Length()), i); } if (PatternEntry.IsSpecialChar(ch) && (inQuote == false)) { throw new ParseException("Unquoted punctuation character : " + Convert.ToString(ch, 16), i); } if (inChars) { NewChars.Append(ch); } else { NewExtension.Append(ch); } break; } } i++; mainLoopContinue :; } mainLoopBreak : if (newStrength == UNSET) { return(null); } if (NewChars.Length() == 0) { throw new ParseException("missing chars (=,;<&): " + Pattern.Substring(i, (10 < Pattern.Length()) ? i + 10 : Pattern.Length()), i); } return(new PatternEntry(newStrength, NewChars, NewExtension)); }