public class CmsDefaultFileNameGenerator extends java.lang.Object implements I_CmsFileNameGenerator
urlName
mapping
or when using a "new" operation in the context of the direct edit interface.限定符和类型 | 类和说明 |
---|---|
class |
CmsDefaultFileNameGenerator.CmsNumberFactory
Factory to use for resolving the %(number) macro.
|
MACRO_NUMBER, NUMBER_FORMAT
构造器和说明 |
---|
CmsDefaultFileNameGenerator() |
限定符和类型 | 方法和说明 |
---|---|
java.lang.String |
getNewFileName(CmsObject cms,
java.lang.String namePattern,
int defaultDigits)
Returns a new resource name based on the provided OpenCms user context and name pattern.
|
protected java.lang.String |
getNewFileNameFromList(java.util.List<java.lang.String> fileNames,
java.lang.String checkPattern,
int defaultDigits)
Internal method for file name generation, decoupled for testing.
|
java.lang.String |
getUniqueFileName(CmsObject cms,
java.lang.String parentFolder,
java.lang.String baseName)
Returns a unique filename for the given base name and the parent folder.
|
java.util.Iterator<java.lang.String> |
getUrlNameSequence(java.lang.String baseName)
This default implementation will just generate a 5 digit sequence that is appended to the resource name in case
of a collision of names.
|
static java.lang.String |
removeExtension(java.lang.String path)
Removes the file extension if it only consists of letters.
|
public static java.lang.String removeExtension(java.lang.String path)
path
- the path from which to remove the file extensionpublic java.lang.String getNewFileName(CmsObject cms, java.lang.String namePattern, int defaultDigits) throws CmsException
The pattern in this default implementation must be a path which may contain the macro %(number)
.
This will be replaced by the first "n" digit sequence for which the resulting file name is not already
used. For example the pattern "/file_%(number).xml"
would result in something like "/file_00003.xml"
.
Alternatively, the macro can have the form %(number:n)
with n = {1...9}
, for example %(number:6)
.
In this case the default digits will be ignored and instead the digits provided as "n" will be used.
getNewFileName
在接口中 I_CmsFileNameGenerator
cms
- the current OpenCms user contextnamePattern
- the pattern to be used when generating the new resource namedefaultDigits
- the default number of digits to use for numbering the created file namesCmsException
- in case something goes wrongpublic java.lang.String getUniqueFileName(CmsObject cms, java.lang.String parentFolder, java.lang.String baseName)
I_CmsFileNameGenerator
getUniqueFileName
在接口中 I_CmsFileNameGenerator
cms
- the current OpenCms user contextparentFolder
- the parent folder of the filebaseName
- the proposed file nameI_CmsFileNameGenerator.getUniqueFileName(org.opencms.file.CmsObject, java.lang.String, java.lang.String)
public java.util.Iterator<java.lang.String> getUrlNameSequence(java.lang.String baseName)
getUrlNameSequence
在接口中 I_CmsFileNameGenerator
baseName
- the base nameI_CmsFileNameGenerator.getUrlNameSequence(java.lang.String)
protected java.lang.String getNewFileNameFromList(java.util.List<java.lang.String> fileNames, java.lang.String checkPattern, int defaultDigits)
fileNames
- the list of file names already existing in the foldercheckPattern
- the pattern to be used when generating the new resource namedefaultDigits
- the default number of digits to use for numbering the created file names