|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectorg.opencms.loader.CmsDefaultFileNameGenerator
public class CmsDefaultFileNameGenerator
The default class used for generating file names either for the urlName mapping
or when using a "new" operation in the context of the direct edit interface.
| Nested Class Summary | |
|---|---|
class |
CmsDefaultFileNameGenerator.CmsNumberFactory
Factory to use for resolving the %(number) macro. |
| Field Summary |
|---|
| Fields inherited from interface org.opencms.loader.I_CmsFileNameGenerator |
|---|
MACRO_NUMBER, NUMBER_FORMAT |
| Constructor Summary | |
|---|---|
CmsDefaultFileNameGenerator()
|
|
| Method Summary | |
|---|---|
String |
getNewFileName(CmsObject cms,
String namePattern,
int defaultDigits)
Returns a new resource name based on the provided OpenCms user context and name pattern. |
protected String |
getNewFileNameFromList(List<String> fileNames,
String checkPattern,
int defaultDigits)
Internal method for file name generation, decoupled for testing. |
String |
getUniqueFileName(CmsObject cms,
String parentFolder,
String baseName)
Returns a unique filename for the given base name and the parent folder. |
Iterator<String> |
getUrlNameSequence(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. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public CmsDefaultFileNameGenerator()
| Method Detail |
|---|
public String getNewFileName(CmsObject cms,
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 in interface I_CmsFileNameGeneratorcms - 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 names
CmsException - in case something goes wrong
public String getUniqueFileName(CmsObject cms,
String parentFolder,
String baseName)
I_CmsFileNameGenerator
getUniqueFileName in interface I_CmsFileNameGeneratorcms - the current OpenCms user contextparentFolder - the parent folder of the filebaseName - the proposed file name
I_CmsFileNameGenerator.getUniqueFileName(org.opencms.file.CmsObject, java.lang.String, java.lang.String)public Iterator<String> getUrlNameSequence(String baseName)
getUrlNameSequence in interface I_CmsFileNameGeneratorbaseName - the base name
I_CmsFileNameGenerator.getUrlNameSequence(java.lang.String)
protected String getNewFileNameFromList(List<String> fileNames,
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
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||