Home | History | Annotate | Download | only in base

Lines Matching full:code

104 An object that divides strings (or other instances of <code>CharSequence</code>)
107 expression, <code>CharMatcher</code>, or by using a fixed substring length. This
108 class provides the complementary functionality to <A HREF="../../../../com/google/common/base/Joiner.html" title="class in com.google.common.base"><CODE>Joiner</CODE></A>.
110 <p>Here is the most basic example of <code>Splitter</code> usage: <pre> <code>Splitter.on(',').split("foo,bar")</code></pre>
112 This invocation returns an <code>Iterable&lt;String&gt;</code> containing <code>"foo"</code>
113 and <code>"bar"</code>, in that order.
115 <p>By default <code>Splitter</code>'s behavior is very simplistic: <pre> <code>Splitter.on(',').split("foo,,bar, quux")</code></pre>
117 This returns an iterable containing <code>["foo", "", "bar", " quux"]</code>.
120 ask for them: <pre> <code>private static final Splitter MY_SPLITTER = Splitter.on(',')
122 .omitEmptyStrings();</code></pre>
124 Now <code>MY_SPLITTER.split("foo, ,bar, quux,")</code> returns an iterable
125 containing just <code>["foo", "bar", "quux"]</code>. Note that the order in which
128 regardless of the order in which the <A HREF="../../../../com/google/common/base/Splitter.html#trimResults()"><CODE>trimResults()</CODE></A> and
129 <A HREF="../../../../com/google/common/base/Splitter.html#omitEmptyStrings()"><CODE>omitEmptyStrings()</CODE></A> methods were invoked.
132 method such as <code>omitEmptyStrings</code> has no effect on the instance it
134 the method. This makes splitters thread-safe, and safe to store as <code>static final</code> constants (as illustrated above). <pre> <code>// Bad! Do not do this!
137 return splitter.split("wrong / wrong / wrong");</code></pre>
140 literal character as in the examples above. See the methods <A HREF="../../../../com/google/common/base/Splitter.html#on(java.lang.String)"><CODE>on(String)</CODE></A>, <A HREF="../../../../com/google/common/base/Splitter.html#on(java.util.regex.Pattern)"><CODE>on(Pattern)</CODE></A> and <A HREF="../../../../com/google/common/base/Splitter.html#on(com.google.common.base.CharMatcher)"><CODE>on(CharMatcher)</CODE></A> for examples
145 separators, as does <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/String.html?is-external=true#split(java.lang.String)" title="class or interface in java.lang"><CODE>String.split(String)</CODE></A>, nor does it have a default
147 <A HREF="http://java.sun.com/javase/6/docs/api/java/util/StringTokenizer.html?is-external=true" title="class or interface in java.util"><CODE>StringTokenizer</CODE></A>.
171 <CODE>static&nbsp;<A HREF="../../../../com/google/common/base/Splitter.html" title="class in com.google.common.base">Splitter</A></CODE></FONT></TD>
172 <TD><CODE><B><A HREF="../../../../com/google/common/base/Splitter.html#fixedLength(int)">fixedLength</A></B>(int&nbsp;length)</CODE>
179 <CODE>&nbsp;<A HREF="../../../../com/google/common/base/Splitter.html" title="class in com.google.common.base">Splitter</A></CODE></FONT></TD>
180 <TD><CODE><B><A HREF="../../../../com/google/common/base/Splitter.html#omitEmptyStrings()">omitEmptyStrings</A></B>()</CODE>
183 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns a splitter that behaves equivalently to <code>this</code> splitter, but
188 <CODE>static&nbsp;<A HREF="../../../../com/google/common/base/Splitter.html" title="class in com.google.common.base">Splitter</A></CODE></FONT></TD>
189 <TD><CODE><B><A HREF="../../../../com/google/common/base/Splitter.html#on(char)">on</A></B>(char&nbsp;separator)</CODE>
196 <CODE>static&nbsp;<A HREF="../../../../com/google/common/base/Splitter.html" title="class in com.google.common.base">Splitter</A></CODE></FONT></TD>
197 <TD><CODE><B><A HREF="../../../../com/google/common/base/Splitter.html#on(com.google.common.base.CharMatcher)">on</A></B>(<A HREF="../../../../com/google/common/base/CharMatcher.html" title="class in com.google.common.base">CharMatcher</A>&nbsp;separatorMatcher)</CODE>
201 given <code>CharMatcher</code> to be a separator.</TD>
205 <CODE>static&nbsp;<A HREF="../../../../com/google/common/base/Splitter.html" title="class in com.google.common.base">Splitter</A></CODE></FONT></TD>
206 <TD><CODE><B><A HREF="../../../../com/google/common/base/Splitter.html#on(java.util.regex.Pattern)">on</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/util/regex/Pattern.html?is-external=true" title="class or interface in java.util.regex">Pattern</A>&nbsp;separatorPattern)</CODE>
209 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns a splitter that considers any subsequence matching <code>pattern</code> to be a separator.</TD>
213 <CODE>static&nbsp;<A HREF="../../../../com/google/common/base/Splitter.html" title="class in com.google.common.base">Splitter</A></CODE></FONT></TD>
214 <TD><CODE><B><A HREF="../../../../com/google/common/base/Splitter.html#on(java.lang.String)">on</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</A>&nbsp;separator)</CODE>
221 <CODE>static&nbsp;<A HREF="../../../../com/google/common/base/Splitter.html" title="class in com.google.common.base">Splitter</A></CODE></FONT></TD>
222 <TD><CODE><B><A HREF="../../../../com/google/common/base/Splitter.html#onPattern(java.lang.String)">onPattern</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</A>&nbsp;separatorPattern)</CODE>
230 <CODE>&nbsp;<A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Iterable.html?is-external=true" title="class or interface in java.lang">Iterable</A>&lt;<A HREF="http://java.sun.com/javase/6/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</A>&gt;</CODE></FONT></TD>
231 <TD><CODE><B><A HREF="../../../../com/google/common/base/Splitter.html#split(java.lang.CharSequence)">split</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/lang/CharSequence.html?is-external=true" title="class or interface in java.lang">CharSequence</A>&nbsp;sequence)</CODE>
234 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Splits the <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/CharSequence.html?is-external=true" title="class or interface in java.lang"><CODE>CharSequence</CODE></A> passed in parameter.</TD>
238 <CODE>&nbsp;<A HREF="../../../../com/google/common/base/Splitter.html" title="class in com.google.common.base">Splitter</A></CODE></FONT></TD>
239 <TD><CODE><B><A HREF="../../../../com/google/common/base/Splitter.html#trimResults()">trimResults</A></B>()</CODE>
242 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns a splitter that behaves equivalently to <code>this</code> splitter, but
244 to <code>trimResults(CharMatcher.WHITESPACE)</code>.</TD>
248 <CODE>&nbsp;<A HREF="../../../../com/google/common/base/Splitter.html" title="class in com.google.common.base">Splitter</A></CODE></FONT></TD>
249 <TD><CODE><B><A HREF="../../../../com/google/common/base/Splitter.html#trimResults(com.google.common.base.CharMatcher)">trimResults</A></B>(<A HREF="../../../../com/google/common/base/CharMatcher.html" title="class in com.google.common.base">CharMatcher</A>&nbsp;trimmer)</CODE>
252 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns a splitter that behaves equivalently to <code>this</code> splitter, but
253 removes all leading or trailing characters matching the given <code>CharMatcher</code> from each returned substring.</TD>
262 <TD><CODECODE></TD>
284 example, <code>Splitter.on(',').split("foo,,bar")</code> returns an iterable
285 containing <code>["foo", "", "bar"]</code>.
288 <DT><B>Parameters:</B><DD><CODE>separator</CODE> - the character to recognize as a separator
300 given <code>CharMatcher</code> to be a separator. For example, <code>Splitter.on(CharMatcher.anyOf(";,")).split("foo,;bar,quux")</code> returns an
301 iterable containing <code>["foo", "", "bar", "quux"]</code>.
304 <DT><B>Parameters:</B><DD><CODE>separatorMatcher</CODE> - a <A HREF="../../../../com/google/common/base/CharMatcher.html" title="class in com.google.common.base"><CODE>CharMatcher</CODE></A> that determines whether a
317 example, <code>Splitter.on(", ").split("foo, bar, baz,qux")</code> returns an
318 iterable containing <code>["foo", "bar", "baz,qux"]</code>.
321 <DT><B>Parameters:</B><DD><CODE>separator</CODE> - the literal, nonempty string to recognize as a separator
332 <DD>Returns a splitter that considers any subsequence matching <code>pattern</code> to be a separator. For example, <code>Splitter.on(Pattern.compile("\r?\n")).split(entireFile)</code> splits a string
336 <DT><B>Parameters:</B><DD><CODE>separatorPattern</CODE> - the pattern that determines whether a subsequence
340 <DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</A></CODE> - if <code>separatorPattern</code> matches the
352 pattern (regular expression) to be a separator. For example, <code>Splitter.onPattern("\r?\n").split(entireFile)</code> splits a string into lines
354 equivalent to <code>Splitter.on(Pattern.compile(pattern))</code>.
357 <DT><B>Parameters:</B><DD><CODE>separatorPattern</CODE> - the pattern that determines whether a subsequence
361 <DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/util/regex/PatternSyntaxException.html?is-external=true" title="class or interface in java.util.regex">PatternSyntaxException</A></CODE> - if <code>separatorPattern</code> is a malformed
363 <DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</A></CODE> - if <code>separatorPattern</code> matches the
375 For example, <code>Splitter.atEach(2).split("abcde")</code> returns an
376 iterable containing <code>["ab", "cd", "e"]</code>. The last piece can be
377 smaller than <code>length</code> but will never be empty.
380 <DT><B>Parameters:</B><DD><CODE>length</CODE> - the desired length of pieces after splitting
392 <DD>Returns a splitter that behaves equivalently to <code>this</code> splitter, but
393 automatically omits empty strings from the results. For example, <code>Splitter.on(',').omitEmptyStrings().split(",a,,,b,c,,")</code> returns an
394 iterable containing only <code>["a", "b", "c"]</code>.
396 <p>If either <code>trimResults</code> option is also specified when creating a
398 emptiness. So, for example, <code>Splitter.on(':').omitEmptyStrings().trimResults().split(": : : ")</code> returns
401 <p>Note that it is ordinarily not possible for <A HREF="../../../../com/google/common/base/Splitter.html#split(java.lang.CharSequence)"><CODE>split(CharSequence)</CODE></A>
417 <DD>Returns a splitter that behaves equivalently to <code>this</code> splitter, but
419 to <code>trimResults(CharMatcher.WHITESPACE)</code>. For example, <code>Splitter.on(',').trimResults().split(" a, b ,c ")</code> returns an iterable
420 containing <code>["a", "b", "c"]</code>.
434 <DD>Returns a splitter that behaves equivalently to <code>this</code> splitter, but
435 removes all leading or trailing characters matching the given <code>CharMatcher</code> from each returned substring. For example, <code>Splitter.on(',').trimResults(CharMatcher.is('_')).split("_a ,_b_ ,c__")</code>
436 returns an iterable containing <code>["a ", "b_ ", "c"]</code>.
439 <DT><B>Parameters:</B><DD><CODE>trimmer</CODE> - a <A HREF="../../../../com/google/common/base/CharMatcher.html" title="class in com.google.common.base"><CODE>CharMatcher</CODE></A> that determines whether a character
451 <DD>Splits the <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/CharSequence.html?is-external=true" title="class or interface in java.lang"><CODE>CharSequence</CODE></A> passed in parameter.
454 <DT><B>Parameters:</B><DD><CODE>sequence</CODE> - the sequence of characters to split