public class NoteTemplateDefinition extends Object
Constructor and Description |
---|
NoteTemplateDefinition(String templateId,
LocalizedMessage templateName,
LocalizedMessage template)
Creates a new template definition with default expiration timeout of zero.
|
NoteTemplateDefinition(String templateId,
LocalizedMessage templateName,
LocalizedMessage template,
long expirationTimeout)
Creates a new template definition.
|
Modifier and Type | Method and Description |
---|---|
void |
addTemplate(NoteRenderMode renderMode,
LocalizedMessage template)
Allows overriding the default template for other render modes.
|
long |
getExpirationTimeout() |
LocalizedMessage |
getTemplate() |
LocalizedMessage |
getTemplate(NoteRenderMode renderMode)
Like
getTemplate() but return a template that was explicitly added via
addTemplate(NoteRenderMode, LocalizedMessage) for the given renderMode. |
String |
getTemplateId() |
LocalizedMessage |
getTemplateName() |
boolean |
hasTemplate(NoteRenderMode renderMode)
Test whether the definition has a template for the given render mode.
|
void |
removeTemplate(NoteRenderMode renderMode)
Removes a template previously added with
addTemplate(NoteRenderMode, LocalizedMessage) . |
void |
setExpirationTimeout(long timeout)
Sets the expiration timeout.
|
void |
setPropertiesValidator(NoteTemplatePropertiesValidator validator)
Sets the validator to be used for validating the template properties.
|
void |
validateProperties(Map<String,Object> templatePropertiesJSON)
Validates the template properties using the validator of this definition, in case there is
one.
|
public NoteTemplateDefinition(String templateId, LocalizedMessage templateName, LocalizedMessage template)
templateId
- an ID which uniquely identifies the templatetemplateName
- a localizable name of the templatetemplate
- the actual template. This will be the default template.public NoteTemplateDefinition(String templateId, LocalizedMessage templateName, LocalizedMessage template, long expirationTimeout)
templateId
- an ID which uniquely identifies the templatetemplateName
- a localizable name of the templatetemplate
- the actual template. This will be the default template.expirationTimeout
- a timeout in milliseconds after which a note that uses this template should expirepublic void addTemplate(NoteRenderMode renderMode, LocalizedMessage template)
renderMode
- the render mode for which the provided template should be usedtemplate
- the template to usepublic long getExpirationTimeout()
public LocalizedMessage getTemplate()
public LocalizedMessage getTemplate(NoteRenderMode renderMode)
getTemplate()
but return a template that was explicitly added via
addTemplate(NoteRenderMode, LocalizedMessage)
for the given renderMode. If there is
no template for that renderMode the default template will be returned.renderMode
- the renderMode for which the template should be retrieved, if null the default
template is returned.public String getTemplateId()
public LocalizedMessage getTemplateName()
public boolean hasTemplate(NoteRenderMode renderMode)
renderMode
- the render mode to testaddTemplate(NoteRenderMode, LocalizedMessage)
for the given render modepublic void removeTemplate(NoteRenderMode renderMode)
addTemplate(NoteRenderMode, LocalizedMessage)
. If there is no template for the
renderMode nothing will happen.renderMode
- the renderMode for which an added template should be removedpublic void setExpirationTimeout(long timeout)
timeout
- a timeout in milliseconds after which a note that uses this template should expire
(be deleted) automatically. A value of zero or less means no expiration.public void setPropertiesValidator(NoteTemplatePropertiesValidator validator)
validator
- the validatorpublic void validateProperties(Map<String,Object> templatePropertiesJSON) throws NoteTemplatePropertiesValidationException
templatePropertiesJSON
- the JSON object, as nested map, holding the properties that should be validated,
can be null. Any modifications made to the object won't be persisted.NoteTemplatePropertiesValidationException
- in case the validation failedCopyright © 2019 Communote team. All rights reserved.