Internal method to perform the normalization.

@param filename
the filename
@param keepSeparator
true to keep the final separator
@return the normalized filename
675
private static String doNormalizeIgnoreOtherSeparator(String filename, boolean keepSeparator) {
		if (filename == null) {
			return null;
		}
		int size = filename.length();
		if (size == 0) {
			return filename;
		}
		int prefix = 0;
		// int prefix = getPrefixLength(filename);
		// if (prefix < 0) {
		// return null;
		// }

		char[] array = new char[size + 2]; // +1 for possible extra slash, +2
											// for arraycopy
		filename.getChars(0, filename.length(), array, 0);

		// add extra separator on the end to simplify code below
		boolean lastIsDirectory = true;
		if (array[size - 1] != JawrConstant.URL_SEPARATOR_CHAR) {
			array[size++] = JawrConstant.URL_SEPARATOR_CHAR;
			lastIsDirectory = false;
		}

		// adjoining slashes
		for (int i = prefix + 1; i < size; i++) {
			if (array[i] == JawrConstant.URL_SEPARATOR_CHAR && array[i - 1] == JawrConstant.URL_SEPARATOR_CHAR) {
				System.arraycopy(array, i, array, i - 1, size - i);
				size--;
				i--;
			}
		}

		// dot slash
		for (int i = prefix + 1; i < size; i++) {
			if (array[i] == JawrConstant.URL_SEPARATOR_CHAR && array[i - 1] == '.'
					&& (i == prefix + 1 || array[i - 2] == JawrConstant.URL_SEPARATOR_CHAR)) {
				if (i == size - 1) {
					lastIsDirectory = true;
				}
				System.arraycopy(array, i + 1, array, i - 1, size - i);
				size -= 2;
				i--;
			}
		}

		// double dot slash
		outer: for (int i = prefix + 2; i < size; i++) {
			if (array[i] == JawrConstant.URL_SEPARATOR_CHAR && array[i - 1] == '.' && array[i - 2] == '.'
					&& (i == prefix + 2 || array[i - 3] == JawrConstant.URL_SEPARATOR_CHAR)) {
				if (i == prefix + 2) {
					return null;
				}
				if (i == size - 1) {
					lastIsDirectory = true;
				}
				int j;
				for (j = i - 4; j >= prefix; j--) {
					if (array[j] == JawrConstant.URL_SEPARATOR_CHAR) {
						// remove b/../ from a/b/../c
						System.arraycopy(array, i + 1, array, j + 1, size - i);
						size -= (i - j);
						i = j + 1;
						continue outer;
					}
				}
				// remove a/../ from a/../c
				System.arraycopy(array, i + 1, array, prefix, size - i);
				size -= (i + 1 - prefix);
				i = prefix + 1;
			}
		}

		if (size <= 0) { // should never be less than 0
			return "";
		}
		if (size <= prefix) { // should never be less than prefix
			return new String(array, 0, size);
		}
		if (lastIsDirectory && keepSeparator) {
			return new String(array, 0, size); // keep trailing separator
		}
		return new String(array, 0, size - 1); // lose trailing separator
	}
971603
static protected String normalizePath(String oldPath,
                                        String newPath,
                                        int offset,
                                        char separatorChar)
  {
    CharBuffer cb = new CharBuffer();
    normalizePath(cb, oldPath, newPath, offset, separatorChar);
    return cb.toString();
  }
295589
public static String extName(String fileName) {
		if (fileName == null) {
			return null;
		}
		int index = fileName.lastIndexOf(StrUtil.DOT);
		if (index == -1) {
			return StrUtil.EMPTY;
		} else {
			String ext = fileName.substring(index + 1);
			// 扩展名中不能包含路径相关的符号
			return StrUtil.containsAny(ext, UNIX_SEPARATOR, WINDOWS_SEPARATOR) ? StrUtil.EMPTY : ext;
		}
	}
975398
public static String cleanNameWithAccents( String name ) {

		String temp = Normalizer.normalize( name, Normalizer.Form.NFD );
		Pattern pattern = Pattern.compile( "\\p{InCombiningDiacriticalMarks}+" );
		return pattern.matcher( temp ).replaceAll( "" ).trim();
	}
1077612
public static String parseNonceFromDigestFilename(String filename) {
        if (filename == null || !filename.endsWith(".digest")) {
            throw new IllegalArgumentException("Bad digest filename: " + filename);
        }

        return parseNonceFromSnapshotFilename(filename);
    }
980519
private static String escapeFileSeparatorChar(String fname)
  {
    if (File.separatorChar == '\\')
    {
      return fname.replaceAll(File.separator + File.separator, "_");
    }
    else
    {
      return fname.replaceAll(File.separator, "_");
    }
  }
229823
protected static String toInternalName(String name, boolean keepCase)
    {
        return keepCase ? name : name.toLowerCase(Locale.US);
    }
380409
public Response filenameHeader(String filename) {
        if (filename != null && !filename.isEmpty()) {
            header(HttpConstants.Header.CONTENT_DISPOSITION, "attachment; filename=\"" + filename + "\"");
        } else {
            header(HttpConstants.Header.CONTENT_DISPOSITION, "attachment; filename=\"\"");
        }

        return this;
    }
459007
public static String removeExtension(String fileName) {
		final String separator = FILE_SEPARATOR;
		String filename;
		// Remove the path upto the filename.
		final int lastSeparatorIndex = fileName.lastIndexOf(separator);
		if (lastSeparatorIndex == -1) {
			filename = fileName;
		} else {
			filename = fileName.substring(lastSeparatorIndex + 1);
		}

		// Remove the extension.
		final int extensionIndex = filename.lastIndexOf(".");
		if (extensionIndex == -1) {
			return filename;
		}
		fileName = fileName.substring(0, lastSeparatorIndex);
		return fileName + File.separator + filename.substring(0, extensionIndex);
	}
348304
private int retrieveIndexValueFromFileName(String fileName) {
        int index = 0;
        if (fileName != null && !fileName.trim().isEmpty()) {
            index = Integer.parseInt(fileName.substring(fileName.lastIndexOf('-') + 1,
                    fileName.length() - EXTENSION.length()));
        }
        return index;
    }
453574
public static String toValidFileName(String fileName) {
        // adds MAX_VALUE to eliminate minus character which might be returned by hashCode()
        return Long.toString((long) fileName.hashCode() + Integer.MAX_VALUE);
    }
1050241
public static List<String> parseName(String sourceName, char separator) {
		List<String> result = new ArrayList<String>();
		if (sourceName != null) {
			StringBuilder currentWord = new StringBuilder();
			boolean lastIsLower = false;
			for (int index = 0, length = sourceName.length(); index < length; ++index) {
				char curChar = sourceName.charAt(index);
				if (Character.isUpperCase(curChar) || (!lastIsLower && Character.isDigit(curChar)) || curChar == separator) {
					if (lastIsLower && currentWord.length() > 1 || curChar == separator && currentWord.length() > 0) {
						result.add(currentWord.toString());
						currentWord = new StringBuilder();
					}
					lastIsLower = false;
				} else {
					if (!lastIsLower) {
						int currentWordLength = currentWord.length();
						if (currentWordLength > 1) {
							char lastChar = currentWord.charAt(--currentWordLength);
							currentWord.setLength(currentWordLength);
							result.add(currentWord.toString());
							currentWord = new StringBuilder();
							currentWord.append(lastChar);
						}
					}
					lastIsLower = true;
				}

				if (curChar != separator) {
					currentWord.append(curChar);
				}
			}

			result.add(currentWord.toString());
		}
		return result;
	}
120794
private String convertFileNameToBaseClassName(String filename) {
        if (filename.endsWith("_.java")) {
            return substringBeforeLast(filename, "_.java") + BASE_SUFFIX_;
        } else {
            return substringBeforeLast(filename, ".java") + BASE_SUFFIX;
        }
    }
401061
private String encodeFileName(String fileName) {

		String result = Normalizer.normalize(fileName, Normalizer.Form.NFD).replaceAll("\\s+", "-")
				.replaceAll("[^A-Za-z0-9_\\-\\.]", "");
		if (result.isEmpty()) {
			result = "report";
		}
		return result;
	}
239143
public static String getName(String fileName){
        int dot = fileName.lastIndexOf('.');
        return dot==-1 ? fileName : fileName.substring(0, dot);
    }
119921
public static String[] splitFileName(String fileName) {
	int pos = fileName.lastIndexOf('.');
	if (pos == -1) {
	    return new String[] { fileName };
	}
	return new String[] { fileName.substring(0, pos), fileName.substring(pos + 1) };
    }
623148
private String determineFileName(final Matcher matcher) {
        String fileName;
        if (StringUtils.isNotBlank(matcher.group(3))) {
            fileName = matcher.group(3);
        }
        else if (StringUtils.isNotBlank(matcher.group(7))) {
            fileName = matcher.group(7);
        }
        else {
            fileName = matcher.group(1);
        }
        if (StringUtils.isBlank(fileName)) {
            fileName = StringUtils.substringBetween(matcher.group(6), "'");
        }
        if (StringUtils.isBlank(fileName)) {
            fileName = "unknown.file";
        }
        return fileName;
    }