com.atlassian.jira.web.util
Class FileNameCharacterCheckerUtil

java.lang.Object
  extended by com.atlassian.jira.web.util.FileNameCharacterCheckerUtil

public class FileNameCharacterCheckerUtil
extends Object

This is a centralized object for checking illegal characters in attachment file names. This is used by the AttachmentManager, the Screenshot Applet and the Abstract Message Handler


Field Summary
static char[] INVALID_CHARS
           
 
Constructor Summary
FileNameCharacterCheckerUtil()
           
 
Method Summary
 String assertFileNameDoesNotContainInvalidChars(String filename)
          This will test the given filename string for any invalid characters.
 String getPrintableInvalidCharacters()
           
 String replaceInvalidChars(String filename, char replacementChar)
          Replaces each invalid character of the given filename with the replacementChar.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INVALID_CHARS

public static final char[] INVALID_CHARS
Constructor Detail

FileNameCharacterCheckerUtil

public FileNameCharacterCheckerUtil()
Method Detail

assertFileNameDoesNotContainInvalidChars

public String assertFileNameDoesNotContainInvalidChars(String filename)
This will test the given filename string for any invalid characters. If it contains an invalid character then the string returned will be the character. A return value of null means that the string is a valid filename. if the filename is null it will return null for the caller to handle the null filename.

Parameters:
filename - the filename to be checked.
Returns:
null if the filename is valid, else the character that is invalid.

replaceInvalidChars

public String replaceInvalidChars(String filename,
                                  char replacementChar)
Replaces each invalid character of the given filename with the replacementChar. If the filename is null, returns null so that the caller can handle the null filename

Parameters:
filename - file name to replace invalid characters from
replacementChar - character to replace invalid characters
Returns:
new filename with valid characters
Throws:
IllegalArgumentException - if replacementChar is an invalid character itself

getPrintableInvalidCharacters

public String getPrintableInvalidCharacters()


Copyright © 2002-2007 Atlassian. All Rights Reserved.