示例#1
0
 protected SplittingEnumerable(Splitter splitter, string toSplit)
 {
     this.trimmer          = splitter.trimmer;
     this.omitEmptyStrings = splitter.omitEmptyStrings;
     this.spitterLimit     = splitter.limit;
     this.ToSplit          = toSplit;
 }
示例#2
0
 private Splitter(SplittingEnumerableProducer enumerableProducer, bool omitEmptyStrings,
                  CharMatcher trimmer, int limit)
 {
     this.enumerableProducer = enumerableProducer;
     this.omitEmptyStrings   = omitEmptyStrings;
     this.trimmer            = trimmer;
     this.limit = limit;
 }
示例#3
0
 /// <summary>
 /// Returns a matcher that matches any character matched by either this matcher or <c>other</c>.
 /// </summary>
 public virtual CharMatcher Or(CharMatcher other)
 {
     return(new OrMatcher(this, other));
 }
示例#4
0
 /// <summary>
 /// Returns a matcher that matches any character matched by both this matcher and <c>other</c>.
 /// </summary>
 public virtual CharMatcher And(CharMatcher other)
 {
     return(new AndMatcher(this, other));
 }
示例#5
0
 internal OrMatcher(CharMatcher a, CharMatcher b)
 {
     first  = CheckNotNull(a);
     second = CheckNotNull(b);
 }
示例#6
0
 public override CharMatcher Or(CharMatcher other)
 {
     CheckNotNull(other);
     return(this);
 }
示例#7
0
 public override CharMatcher And(CharMatcher other)
 {
     return(CheckNotNull(other));
 }
示例#8
0
 /// <summary>
 /// Returns a splitter that considers any single character matched by the
 /// given <c>CharMatcher</c> to be a separator.For example,
 /// <code>Splitter.On(CharMatcher.anyOf(";,")).split("foo,;bar,quux")</code>
 ///returns an iterable containing <c>["foo", "", "bar", "quux"]</c>.
 /// </summary>
 /// <param name="separatorMatcher">a <see cref="CharMatcher"/> that determines
 /// whether a character is a separator</param>
 /// <returns>a splitter, with default settings, that uses this matcher</returns>
 public static Splitter On(CharMatcher separatorMatcher)
 {
     CheckNotNull(separatorMatcher);
     return(new Splitter(ByCharMatcherSplitterStrategy(separatorMatcher)));
 }
示例#9
0
 /// <summary>
 /// Returns a splitter that uses the given single-character separator. For example,
 /// <code>Splitter.On(',').split("foo,,bar")</code> returns an iterable containing
 /// <c>["foo", "", "bar"]</c>
 /// </summary>
 /// <param name="separator">the character to recognize as a separator</param>
 /// <returns>a splitter, with default settings, that recognizes that separator</returns>
 public static Splitter On(char separator)
 {
     return(On(CharMatcher.isChar(separator)));
 }
示例#10
0
 public ByCharMatcherSplittingEnumerable(Splitter splitter,
                                         string toSplit,
                                         CharMatcher separatorMatcher) : base(splitter, toSplit)
 {
     this.separatorMatcher = separatorMatcher;
 }
示例#11
0
 private static SplittingEnumerableProducer ByCharMatcherSplitterStrategy(CharMatcher separatorMatcher)
 {
     return((splitter, toSplit) => new ByCharMatcherSplittingEnumerable(splitter, toSplit, separatorMatcher));
 }
示例#12
0
 public Splitter TrimResults(CharMatcher trimmer)
 {
     CheckNotNull(trimmer);
     return(new Splitter(enumerableProducer, omitEmptyStrings, trimmer, limit));
 }