com.atlassian.jira.web.util
Class FileNameCharacterCheckerUtil

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

public class FileNameCharacterCheckerUtil
extends java.lang.Object

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


Field Summary
static char[] INVALID_CHARS
           
 
Constructor Summary
FileNameCharacterCheckerUtil()
           
 
Method Summary
 java.lang.String assertFileNameDoesNotContainInvalidChars(java.lang.String filename)
          This will test the given filename string for any invalid characters.
 java.lang.String getPrintableInvalidCharacters()
           
 java.lang.String replaceInvalidChars(java.lang.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 java.lang.String assertFileNameDoesNotContainInvalidChars(java.lang.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 java.lang.String replaceInvalidChars(java.lang.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:
java.lang.IllegalArgumentException - if replacementChar is an invalid character itself

getPrintableInvalidCharacters

public java.lang.String getPrintableInvalidCharacters()


Copyright © 2002-2010 Atlassian. All Rights Reserved.