/// <summary> /// a UnicodeSet of extra characters to quote with \\uXXXX-style escaping /// (will automatically quote pattern whitespace) /// </summary> /// /// <param name="toQuote_0"></param> public PrettyPrinter SetToQuote(UnicodeSet toQuote_0) { toQuote_0 = (UnicodeSet)toQuote_0.Clone(); toQuote_0.AddAll(patternWhitespace); this.toQuote = toQuote_0; return(this); }
/// <exclude/> /// <summary> /// <p> /// Constructs a string tokenizer for the specified string. All characters in /// the delim argument are the delimiters for separating tokens. /// </p> /// <p> /// If the returnDelims flag is false, the delimiter characters are skipped /// and only serve as separators between tokens. /// </p> /// <p> /// If the returnDelims flag is true, then the delimiter characters are also /// returned as tokens. If coalescedelims is true, one token is returned for /// each run of delimiter characters, otherwise one token is returned per /// delimiter. Since surrogate pairs can be delimiters, the returned token /// might be two chars in length. /// </p> /// </summary> /// /// <param name="str">a string to be parsed.</param> /// <param name="delim">the delimiters.</param> /// <param name="returndelims">flag indicating whether to return the delimiters as tokens.</param> /// <param name="coalescedelims">flag indicating whether to return a run of delimiters as asingle token or as one token per delimiter. This only takeseffect if returndelims is true.</param> /// <exception cref=" throws a NullPointerException if str is null"></exception> public StringTokenizer(String str, String delim, bool returndelims, bool coalescedelims) { // don't ignore whitespace m_delimiters_ = EMPTY_DELIMITER_; if (delim != null && delim.Length > 0) { m_delimiters_ = new UnicodeSet(); m_delimiters_.AddAll(delim); CheckDelimiters(); } m_coalesceDelimiters_ = coalescedelims; m_source_ = str; m_length_ = str.Length; m_returnDelimiters_ = returndelims; m_tokenOffset_ = -1; m_tokenSize_ = -1; if (m_length_ == 0) { // string length 0, no tokens m_nextOffset_ = -1; } else { m_nextOffset_ = 0; if (!returndelims) { m_nextOffset_ = GetNextNonDelimiter(0); } } }
/// <summary> /// Adds all characters in range (uses preferred naming convention). /// </summary> /// <param name="set">This set.</param> /// <param name="start">The index of where to start on adding all characters.</param> /// <param name="end">The index of where to end on adding all characters.</param> /// <returns>A reference to this object.</returns> /// <draft>ICU4N 60.1</draft> /// <provisional>This API might change or be removed in a future release.</provisional> public static UnicodeSet AddAll(this UnicodeSet set, int start, int end) { if (set == null) { throw new ArgumentNullException(nameof(set)); } return(set.AddAll(start, end)); }
/// <summary> /// Add a collection (as strings) into this <see cref="UnicodeSet"/>. /// Uses standard naming convention. /// </summary> /// <param name="set">This set.</param> /// <param name="source">Source collection to add into.</param> /// <returns>A reference to this object.</returns> /// <draft>ICU4N 60.1</draft> /// <provisional>This API might change or be removed in a future release.</provisional> // ICU4N specific overload to optimize for string public static UnicodeSet AddAll(this UnicodeSet set, IEnumerable <string> source) { if (set == null) { throw new ArgumentNullException(nameof(set)); } return(set.AddAll(source)); }
/// <seealso cref="Transliterator.AddSourceTargetSet(UnicodeSet, UnicodeSet, UnicodeSet)"/> public override void AddSourceTargetSet(UnicodeSet inputFilter, UnicodeSet sourceSet, UnicodeSet targetSet) { // intersect myFilter with the input filter UnicodeSet myFilter = GetFilterAsUnicodeSet(inputFilter); sourceSet.AddAll(myFilter); // do nothing with the target }
/// <seealso cref="Transliterator.AddSourceTargetSet(UnicodeSet, UnicodeSet, UnicodeSet)"/> #pragma warning disable 672 public override void AddSourceTargetSet(UnicodeSet inputFilter, UnicodeSet sourceSet, UnicodeSet targetSet) { #pragma warning restore 672 #pragma warning disable 612, 618 // intersect myFilter with the input filter UnicodeSet myFilter = GetFilterAsUnicodeSet(inputFilter); #pragma warning restore 612, 618 sourceSet.AddAll(myFilter); // do nothing with the target }
/// <summary> /// Returns the next token in this string tokenizer's string. First, the set /// of characters considered to be delimiters by this /// <tt>StringTokenizer</tt> object is changed to be the characters in the /// string <tt>delim</tt>. Then the next token in the string after the /// current position is returned. The current position is advanced beyond the /// recognized token. The new delimiter set remains the default after this /// call. /// </summary> /// /// <param name="delim">the new delimiters.</param> /// <returns>the next token, after switching to the new delimiter set.</returns> /// <exception cref="NoSuchElementException">if there are no more tokens in this tokenizer's string.</exception> /// @stable ICU 2.4 public String NextToken(String delim) { m_delimiters_ = EMPTY_DELIMITER_; if (delim != null && delim.Length > 0) { m_delimiters_ = new UnicodeSet(); m_delimiters_.AddAll(delim); } return(NextToken(m_delimiters_)); }
/// <exclude/> /// <summary> /// Returns the set of all characters that may be generated as replacement /// text by this transliterator. /// </summary> /// public override UnicodeSet GetTargetSet() { UnicodeSet set = new UnicodeSet(); for (int i = 0; i < trans.Length; ++i) { // This is a heuristic, and not 100% reliable. set.AddAll(trans[i].GetTargetSet()); } return(set); }
public void TestUnicodeSet() { string[] array = new string[] { "a", "b", "c", "{de}" }; List <string> list = array.ToList(); ISet <string> aset = new HashSet <string>(list); Logln(" *** The source set's size is: " + aset.Count); //The size reads 4 UnicodeSet set = new UnicodeSet(); set.Clear(); set.AddAll(aset); Logln(" *** After addAll, the UnicodeSet size is: " + set.Count); //The size should also read 4, but 0 is seen instead }
public void TestUnicodeSet() { String[] array = new String[] { "a", "b", "c", "{de}" }; IList list = ILOG.J2CsMapping.Collections.Arrays.AsList(array); ILOG.J2CsMapping.Collections.ISet aset = new HashedSet(list); Logln(" *** The source set's size is: " + aset.Count); // The size reads 4 UnicodeSet set = new UnicodeSet(); set.Clear(); set.AddAll(aset); Logln(" *** After addAll, the UnicodeSet size is: " + set.Size()); // The size should also read 4, but 0 is seen instead }
/// <exclude/> /// <summary> /// Return the set of all characters that may be modified by this /// Transliterator, ignoring the effect of our filter. /// </summary> /// protected internal override UnicodeSet HandleGetSourceSet() { UnicodeSet set = new UnicodeSet(); for (int i = 0; i < trans.Length; ++i) { set.AddAll(trans[i].GetSourceSet()); // Take the example of Hiragana-Latin. This is really // Hiragana-Katakana; Katakana-Latin. The source set of // these two is roughly [:Hiragana:] and [:Katakana:]. // But the source set for the entire transliterator is // actually [:Hiragana:] ONLY -- that is, the first // non-empty source set. // This is a heuristic, and not 100% reliable. if (!set.IsEmpty()) { break; } } return(set); }
/// <summary> /// Modifies Unicode set to flatten the strings. Eg [abc{da}] => [abcd] /// Returns the set for chaining. /// </summary> /// /// <param name="exemplar1"></param> /// <returns></returns> public static UnicodeSet Flatten(UnicodeSet exemplar1) { UnicodeSet result = new UnicodeSet(); bool gotString = false; for (UnicodeSetIterator it = new UnicodeSetIterator(exemplar1); it .NextRange();) { if (it.codepoint == IBM.ICU.Text.UnicodeSetIterator.IS_STRING) { result.AddAll(it.str0); gotString = true; } else { result.Add(it.codepoint, it.codepointEnd); } } if (gotString) { exemplar1.Set(result); } return(exemplar1); }
/// <summary> /// Union the set of all characters that may output by this object into the /// given set. /// </summary> /// /// <param name="toUnionTo">the set into which to union the output characters</param> public virtual void AddReplacementSetTo(UnicodeSet toUnionTo) { toUnionTo.AddAll(translit.GetTargetSet()); }