org.jboss.virtual.plugins.vfs.helpers
Class PathTokenizer

java.lang.Object
  extended by org.jboss.virtual.plugins.vfs.helpers.PathTokenizer

public class PathTokenizer
extends java.lang.Object

PathTokenizer.

Version:
$Revision: 1.1 $
Author:
Adrian Brock, Ales Justin, David M. Lloyd

Method Summary
static java.lang.String applySpecialPaths(java.lang.String path)
          Apply any .
static java.util.List<java.lang.String> applySpecialPathsToTokens(java.lang.String path)
          Apply any .
protected static int applySpecialTokens(java.util.List<java.lang.String> tokens, java.lang.String path)
          Handle special tokens.
static java.lang.String getRemainingPath(java.util.List<java.lang.String> tokens, int i)
          Get the remaining path from some tokens
protected static java.lang.String getRemainingPath(java.util.List<java.lang.String> tokens, int i, int end)
          Get the remaining path from some tokens
static java.util.List<java.lang.String> getTokens(java.lang.String path)
          Get the tokens that comprise this path.
static boolean isCurrentToken(java.lang.String token)
          Is current token.
static boolean isReverseToken(java.lang.String token)
          Is reverse token.
static void setErrorOnSuspiciousTokens(boolean errorOnSuspiciousTokens)
          Set errorOnSuspiciousTokens flag.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getRemainingPath

protected static java.lang.String getRemainingPath(java.util.List<java.lang.String> tokens,
                                                   int i,
                                                   int end)
Get the remaining path from some tokens

Parameters:
tokens - the tokens
i - the current location
end - the end index
Returns:
the remaining path
Throws:
java.lang.IllegalArgumentException - for null tokens or i is out of range

getTokens

public static java.util.List<java.lang.String> getTokens(java.lang.String path)
Get the tokens that comprise this path.

Parameters:
path - the path
Returns:
the tokens or null if the path is empty
Throws:
java.lang.IllegalArgumentException - if the path is null, or if this class is configured to reject so-called "suspicious" tokens (files that start with "." which are not one of the two special directories "." or "..")

getRemainingPath

public static java.lang.String getRemainingPath(java.util.List<java.lang.String> tokens,
                                                int i)
Get the remaining path from some tokens

Parameters:
tokens - the tokens
i - the current location
Returns:
the remaining path
Throws:
java.lang.IllegalArgumentException - for null tokens or i is out of range

applySpecialTokens

protected static int applySpecialTokens(java.util.List<java.lang.String> tokens,
                                        java.lang.String path)
                                 throws java.io.IOException
Handle special tokens.

Parameters:
tokens - the tokens
path - the path
Returns:
index of last token
Throws:
java.io.IOException - for any error

applySpecialPathsToTokens

public static java.util.List<java.lang.String> applySpecialPathsToTokens(java.lang.String path)
                                                                  throws java.io.IOException
Apply any . or .. paths in the path param.

Parameters:
path - the path
Returns:
simple path, containing no . or .. paths
Throws:
java.io.IOException - if reverse path goes over the top path

applySpecialPaths

public static java.lang.String applySpecialPaths(java.lang.String path)
                                          throws java.io.IOException
Apply any . or .. paths in the path param.

Parameters:
path - the path
Returns:
simple path, containing no . or .. paths
Throws:
java.io.IOException - if reverse path goes over the top path

isCurrentToken

public static boolean isCurrentToken(java.lang.String token)
Is current token.

Parameters:
token - the token to check
Returns:
true if token matches current path token

isReverseToken

public static boolean isReverseToken(java.lang.String token)
Is reverse token.

Parameters:
token - the token to check
Returns:
true if token matches reverse path token

setErrorOnSuspiciousTokens

public static void setErrorOnSuspiciousTokens(boolean errorOnSuspiciousTokens)
Set errorOnSuspiciousTokens flag.

Parameters:
errorOnSuspiciousTokens - the errorOnSuspiciousTokens flag