jSyncManager

org.jSyncManager.API.Tools
Class StringManipulator

java.lang.Object
  extended byorg.jSyncManager.API.Tools.StringManipulator

public final class StringManipulator
extends java.lang.Object

A class to provide string manipulation routines. This class only provides static methods, and thus cannot be initialized.

Version:
$Revision: 3.3 $
Author:
Brad BARCLAY <bbarclay@jsyncmanager.org>
Last modified by: $Author: yaztromo $ on $Date: 2004/07/14 04:31:15 $.

Field Summary
static char[] invalidFileCharactersArray
           
 
Method Summary
static java.lang.String generateValidFilename(java.lang.String in)
          Generates a valid filename from the given filename, replacing invalid characters with an underscore (_).
static java.lang.String generateValidFilename(java.lang.String in, char replacement)
          Generates a valid filename from the given filename, replacing invalid characters with the specified character.
static int getCharArrayLength(byte[] data, int i)
          Returns the length of the char array from the specified point in the specified data array.
static boolean isInvalidFileChar(char c)
          Tests to see if the specified character is an invalid filename character.
static java.lang.String strip(java.lang.String s)
          This method returns the substring from the first character to the first null, if one exists.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

invalidFileCharactersArray

public static final char[] invalidFileCharactersArray
Method Detail

strip

public static java.lang.String strip(java.lang.String s)
This method returns the substring from the first character to the first null, if one exists.

Parameters:
s - the string to strip.
Returns:
the substring of the given string up to the first null.

getCharArrayLength

public static int getCharArrayLength(byte[] data,
                                     int i)
Returns the length of the char array from the specified point in the specified data array. This method basically counts the number of bytes between the specified start point, and the first null encountered, or the end of the array.

Parameters:
data - the byte array to test.
i - the starting index to scan from.
Returns:
the number of bytes between i and the first null.

generateValidFilename

public static java.lang.String generateValidFilename(java.lang.String in,
                                                     char replacement)
Generates a valid filename from the given filename, replacing invalid characters with the specified character. If the specified replacement character is itself invalid, this method will replace invalid characters with the underscore (_) character.

Parameters:
in - the input filename.
replacement - the replacement character.
Returns:
a valid filename generated by replacing the invalid characters.

generateValidFilename

public static java.lang.String generateValidFilename(java.lang.String in)
Generates a valid filename from the given filename, replacing invalid characters with an underscore (_).

Parameters:
in - the input filename.
Returns:
a valid filename generated by replacing the invalid characters.

isInvalidFileChar

public static boolean isInvalidFileChar(char c)
Tests to see if the specified character is an invalid filename character.

Parameters:
c - the character to test.
Returns:
true if the input character is invalid in filenames, false otherwise.

jSyncManager

Copyright (c) 1999 - 2004 Brad BARCLAY and others. All Rights Reserved.