info.magnolia.imaging.util
Class PathSplitter

java.lang.Object
  extended by info.magnolia.imaging.util.PathSplitter

public class PathSplitter
extends Object

Splits a String representation path where elements are separated by defined or default ('/') separator. Leading and trailing separators are ignored. Empty elements are not ("/a//c/" as three elements, "a", "" and "c") This keeps an internal iterator, such that for an input of "/foo/bar/baz/a/b/c/d/e", following sequence of calls:

Version:
$Id$

Constructor Summary
PathSplitter(String source)
          Splits with the '/' character (NOT the system-specific file separator) and trims extensions.
PathSplitter(String source, boolean trimExtension)
          Splits with the '/' character (NOT the system-specific file separator).
PathSplitter(String source, char separator, boolean trimExtension)
           
 
Method Summary
 int count()
          Returns the number of path elements in the source string.
 String next()
          Returns the next path element from the internal iterator.
 String remaining()
          Returns all the elements lefts after the last call to at() or next(), *without* a leading separator.
 String skipTo(int index)
          Returns the element at the given 0-based index.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PathSplitter

public PathSplitter(String source)
Splits with the '/' character (NOT the system-specific file separator) and trims extensions.


PathSplitter

public PathSplitter(String source,
                    boolean trimExtension)
Splits with the '/' character (NOT the system-specific file separator).


PathSplitter

public PathSplitter(String source,
                    char separator,
                    boolean trimExtension)
Method Detail

count

public int count()
Returns the number of path elements in the source string.


next

public String next()
Returns the next path element from the internal iterator.


skipTo

public String skipTo(int index)
Returns the element at the given 0-based index.

Throws:
ArrayIndexOutOfBoundsException

remaining

public String remaining()
Returns all the elements lefts after the last call to at() or next(), *without* a leading separator. This returns an empty string if there are not remaining elements. Calls to next(), skipTo() or remaining() after a call to remaining will lead to unexpected results.



Copyright © 2013 Magnolia International Ltd.. All Rights Reserved.