|
||||||||
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 | |
---|---|
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.util.Iterator<java.lang.String> |
getUrlNameSequence(CmsObject cms,
CmsXmlContent content,
I_CmsXmlContentValue value,
CmsResource sibling)
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 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
in interface 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 names
CmsException
- in case something goes wrongpublic java.util.Iterator<java.lang.String> getUrlNameSequence(CmsObject cms, CmsXmlContent content, I_CmsXmlContentValue value, CmsResource sibling)
getUrlNameSequence
in interface I_CmsFileNameGenerator
cms
- the CMS contextcontent
- the XML contentvalue
- the content value from which the URL name should be generatedsibling
- the sibling to which the URL name should be mapped
I_CmsFileNameGenerator.getUrlNameSequence(org.opencms.file.CmsObject, org.opencms.xml.content.CmsXmlContent, org.opencms.xml.types.I_CmsXmlContentValue, org.opencms.file.CmsResource)
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
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |