@Component @Named(value="model") @Singleton public class ModelScriptService extends Object implements org.xwiki.script.service.ScriptService
Constructor and Description |
---|
ModelScriptService() |
Modifier and Type | Method and Description |
---|---|
AttachmentReference |
createAttachmentReference(DocumentReference documentReference,
String fileName)
Creates an
AttachmentReference from a file name and a reference to the document holding that file. |
DocumentReference |
createDocumentReference(DocumentReference reference,
Locale locale)
Create a new reference with the passed
Locale . |
DocumentReference |
createDocumentReference(String wiki,
List<String> spaces,
String page)
Create a Document Reference from a passed wiki, list of spaces and page names, which can be empty strings or
null in which case they are resolved using the resolver. |
DocumentReference |
createDocumentReference(String wiki,
List<String> spaces,
String page,
String hint)
Create a Document Reference from a passed wiki, list of spaces and page names, which can be empty strings or null
in which case they are resolved against the Resolver having the hint passed as parameter.
|
DocumentReference |
createDocumentReference(String pageName,
SpaceReference parent)
Creates a new
DocumentReference from a given page name and the reference of the parent space. |
DocumentReference |
createDocumentReference(String wiki,
String space,
String page)
Create a Document Reference from a passed wiki, space and page names, which can be empty strings or
null
in which case they are resolved using the resolver. |
DocumentReference |
createDocumentReference(String wiki,
String space,
String page,
String hint)
Create a Document Reference from a passed wiki, space and page names, which can be empty strings or null in which
case they are resolved against the Resolver having the hint passed as parameter.
|
EntityReference |
createEntityReference(String name,
EntityType type)
Creates any
EntityReference from a string. |
EntityReference |
createEntityReference(String name,
EntityType type,
EntityReference parent)
Creates any
EntityReference from a string. |
PageAttachmentReference |
createPageAttachmentReference(PageReference pageReference,
String fileName)
Creates a
PageAttachmentReference from a file name and a reference to the page holding that file. |
PageReference |
createPageReference(String wiki,
List<String> pages,
Locale locale)
Create a Page Reference from a passed wiki, list of page names, which can be empty strings or
null in
which case they are resolved using the resolver. |
PageReference |
createPageReference(String wiki,
List<String> pages,
Locale locale,
String hint)
Create a Page Reference from a passed wiki, list of pages names, which can be empty strings or null in which case
they are resolved against the Resolver having the hint passed as parameter.
|
PageReference |
createPageReference(String wiki,
String... pages)
Create a Page Reference from a passed wiki and pages names, which can be empty strings or
null in which
case they are resolved using the resolver. |
SpaceReference |
createSpaceReference(List<String> spaces,
WikiReference parent)
Creates a
SpaceReference from a list of string representing the space name and the name of its parents. |
SpaceReference |
createSpaceReference(String spaceName,
SpaceReference parent)
Creates a
SpaceReference from a string representing the space name and the reference of the parent space. |
SpaceReference |
createSpaceReference(String spaceName,
WikiReference parent)
Creates a
SpaceReference from a string representing the space name. |
WikiReference |
createWikiReference(String wikiName)
Creates a
WikiReference from a string representing the wiki name. |
String |
escape(String name,
EntityType type)
Escape the passed entity name according to reference syntax.
|
EntityReference |
getEntityReference(EntityType type)
Get the current reference configured for a specific entity type, like the space reference or wiki reference.
|
EntityReference |
getEntityReference(EntityType type,
String hint)
Get the reference configured for a specific entity type, like the space reference or wiki reference.
|
String |
getEntityReferenceValue(EntityType type)
Deprecated.
since 7.4.1/8.0M1, use
getEntityReference(EntityType) |
String |
getEntityReferenceValue(EntityType type,
String hint)
Deprecated.
since 7.2M1, use
getEntityReference(EntityType, String) |
AttachmentReference |
resolveAttachment(String stringRepresentation,
Object... parameters) |
AttachmentReference |
resolveAttachment(String stringRepresentation,
String hint,
Object... parameters) |
ClassPropertyReference |
resolveClassProperty(String stringRepresentation,
Object... parameters) |
ClassPropertyReference |
resolveClassProperty(String stringRepresentation,
String hint,
Object... parameters) |
DocumentReference |
resolveDocument(String stringRepresentation,
Object... parameters) |
DocumentReference |
resolveDocument(String stringRepresentation,
String hint,
Object... parameters) |
ObjectReference |
resolveObject(String stringRepresentation,
Object... parameters) |
ObjectReference |
resolveObject(String stringRepresentation,
String hint,
Object... parameters) |
ObjectPropertyReference |
resolveObjectProperty(String stringRepresentation,
Object... parameters) |
ObjectPropertyReference |
resolveObjectProperty(String stringRepresentation,
String hint,
Object... parameters) |
PageReference |
resolvePage(String stringRepresentation,
Object... parameters) |
PageReference |
resolvePage(String stringRepresentation,
String hint,
Object... parameters) |
PageAttachmentReference |
resolvePageAttachment(String stringRepresentation,
Object... parameters) |
PageAttachmentReference |
resolvePageAttachment(String stringRepresentation,
String hint,
Object... parameters) |
PageClassPropertyReference |
resolvePageClassProperty(String stringRepresentation,
Object... parameters) |
PageClassPropertyReference |
resolvePageClassProperty(String stringRepresentation,
String hint,
Object... parameters) |
PageObjectReference |
resolvePageObject(String stringRepresentation,
Object... parameters) |
PageObjectReference |
resolvePageObject(String stringRepresentation,
String hint,
Object... parameters) |
PageObjectPropertyReference |
resolvePageObjectProperty(String stringRepresentation,
Object... parameters) |
PageObjectPropertyReference |
resolvePageObjectProperty(String stringRepresentation,
String hint,
Object... parameters) |
SpaceReference |
resolveSpace(String stringRepresentation,
Object... parameters) |
SpaceReference |
resolveSpace(String stringRepresentation,
String hint,
Object... parameters) |
String |
serialize(EntityReference reference,
Object... parameters) |
String |
serialize(EntityReference reference,
String hint,
Object... parameters) |
EntityReferenceTree |
toTree(EntityReference... references)
Convert passed references to a tree of references.
|
EntityReferenceTree |
toTree(Iterable<? extends EntityReference> references)
Convert passed references to a tree of references.
|
public DocumentReference createDocumentReference(String wiki, String space, String page)
null
in which case they are resolved using the resolver.wiki
- the wiki reference name to use (can be empty or null)space
- the space reference name to use (can be empty or null)page
- the page reference name to use (can be empty or null)public DocumentReference createDocumentReference(String wiki, List<String> spaces, String page)
null
in which case they are resolved using the resolver.wiki
- the wiki reference name to use (can be empty or null)spaces
- the list of spaces name to use (can be empty or null)page
- the page reference name to use (can be empty or null)public DocumentReference createDocumentReference(DocumentReference reference, Locale locale)
Locale
.reference
- the reference (with or without locale)locale
- the locale of the new referencepublic DocumentReference createDocumentReference(String pageName, SpaceReference parent)
DocumentReference
from a given page name and the reference of the parent space.pageName
- the page nameparent
- the parent space referenceDocumentReference
objectpublic DocumentReference createDocumentReference(String wiki, String space, String page, String hint)
wiki
- the wiki reference name to use (can be empty or null)space
- the space reference name to use (can be empty or null)page
- the page reference name to use (can be empty or null)hint
- the hint of the Resolver to use in case any parameter is empty or nullpublic DocumentReference createDocumentReference(String wiki, List<String> spaces, String page, String hint)
wiki
- the wiki reference name to use (can be empty or null)spaces
- the spaces list to use (can be empty or null)page
- the page reference name to use (can be empty or null)hint
- the hint of the Resolver to use in case any parameter is empty or nullpublic PageReference createPageReference(String wiki, String... pages)
null
in which
case they are resolved using the resolver.wiki
- the wiki reference name to use (can be empty or null)pages
- the page reference names to use (can be empty or null)public PageReference createPageReference(String wiki, List<String> pages, Locale locale)
null
in
which case they are resolved using the resolver.wiki
- the wiki reference name to use (can be empty or null)pages
- the list of pages name to use (can be empty or null)locale
- the locale of the pagepublic PageReference createPageReference(String wiki, List<String> pages, Locale locale, String hint)
wiki
- the wiki reference name to use (can be empty or null)pages
- the pages list to use (can be empty or null)locale
- the locale of the pagehint
- the hint of the Resolver to use in case any parameter is empty or nullpublic AttachmentReference createAttachmentReference(DocumentReference documentReference, String fileName)
AttachmentReference
from a file name and a reference to the document holding that file.documentReference
- a reference to the document the file is attached tofileName
- the name of a file attached to a documentpublic PageAttachmentReference createPageAttachmentReference(PageReference pageReference, String fileName)
PageAttachmentReference
from a file name and a reference to the page holding that file.pageReference
- a reference to the page the file is attached tofileName
- the name of a file attached to a pagepublic WikiReference createWikiReference(String wikiName)
WikiReference
from a string representing the wiki name.wikiName
- the wiki name (eg "xwiki")public SpaceReference createSpaceReference(String spaceName, WikiReference parent)
SpaceReference
from a string representing the space name.spaceName
- the space name (eg "Main")parent
- the wiki reference in which the space is locatedpublic SpaceReference createSpaceReference(String spaceName, SpaceReference parent)
SpaceReference
from a string representing the space name and the reference of the parent space.spaceName
- the space name (e.g. "Main")parent
- the reference of the parent spacepublic SpaceReference createSpaceReference(List<String> spaces, WikiReference parent)
SpaceReference
from a list of string representing the space name and the name of its parents.spaces
- the list of the spaces name (eg ["A", "B", "C"])parent
- the wiki reference in which the space is locatedpublic EntityReference createEntityReference(String name, EntityType type)
EntityReference
from a string.name
- the entity reference name (eg "page")type
- the entity type (eg "wiki", "space", "document", etc)public EntityReference createEntityReference(String name, EntityType type, EntityReference parent)
EntityReference
from a string.name
- the entity reference name (eg "page")type
- the entity type (eg "wiki", "space", "document", etc)parent
- the entity parentpublic SpaceReference resolveSpace(String stringRepresentation, Object... parameters)
stringRepresentation
- the space reference specified as a String (using the "wiki:space" format and with
special characters escaped where required)parameters
- extra parameters to pass to the resolver; you can use these parameters to resolve a space
reference relative to another entity referencepublic SpaceReference resolveSpace(String stringRepresentation, String hint, Object... parameters)
stringRepresentation
- the space reference specified as a String (using the "wiki:space" format and with
special characters escaped where required)hint
- the hint of the Resolver to use in case any part of the reference is missing (no wiki or no space
specified)parameters
- extra parameters to pass to the resolver; you can use these parameters to resolve a space
reference relative to another entity referencepublic DocumentReference resolveDocument(String stringRepresentation, Object... parameters)
stringRepresentation
- the document reference specified as a String (using the "wiki:space.page" format and
with special characters escaped where required)parameters
- extra parameters to pass to the resolver; you can use these parameters to resolve a document
reference relative to another entity referencepublic DocumentReference resolveDocument(String stringRepresentation, String hint, Object... parameters)
stringRepresentation
- the document reference specified as a String (using the "wiki:space.page" format and
with special characters escaped where required)hint
- the hint of the Resolver to use in case any part of the reference is missing (no wiki specified, no
space or no page)parameters
- extra parameters to pass to the resolver; you can use these parameters to resolve a document
reference relative to another entity referencepublic PageReference resolvePage(String stringRepresentation, Object... parameters)
stringRepresentation
- the document reference specified as a String (using the "wiki:space/page" format and
with special characters escaped where required)parameters
- extra parameters to pass to the resolver; you can use these parameters to resolve a document
reference relative to another entity referencepublic PageReference resolvePage(String stringRepresentation, String hint, Object... parameters)
stringRepresentation
- the document reference specified as a String (using the "wiki:space/page" format and
with special characters escaped where required)hint
- the hint of the Resolver to use in case any part of the reference is missing (no wiki specified, no
space or no page)parameters
- extra parameters to pass to the resolver; you can use these parameters to resolve a document
reference relative to another entity referencepublic AttachmentReference resolveAttachment(String stringRepresentation, Object... parameters)
stringRepresentation
- an attachment reference specified as String
(using the "wiki:space.page@file"
format and with special characters escaped where required)parameters
- extra parameters to pass to the resolver; you can use these parameters to resolve an attachment
reference relative to another entity referenceAttachmentReference
object (resolved using the
resolver)public AttachmentReference resolveAttachment(String stringRepresentation, String hint, Object... parameters)
stringRepresentation
- an attachment reference specified as String
(using the "wiki:space.page@file"
format and with special characters escaped where required)hint
- the hint of the resolver to use in case any part of the reference is missing (no wiki specified, no
space or no page)parameters
- extra parameters to pass to the resolver; you can use these parameters to resolve an attachment
reference relative to another entity referenceAttachmentReference
objectpublic PageAttachmentReference resolvePageAttachment(String stringRepresentation, Object... parameters)
stringRepresentation
- an attachment reference specified as String
(using the "wiki:space/page/file"
format and with special characters escaped where required)parameters
- extra parameters to pass to the resolver; you can use these parameters to resolve an attachment
reference relative to another entity referencePageAttachmentReference
object (resolved using the
resolver)public PageAttachmentReference resolvePageAttachment(String stringRepresentation, String hint, Object... parameters)
stringRepresentation
- an attachment reference specified as String
(using the "wiki:space/page/file"
format and with special characters escaped where required)hint
- the hint of the resolver to use in case any part of the reference is missing (no wiki specified, no
space or no page)parameters
- extra parameters to pass to the resolver; you can use these parameters to resolve an attachment
reference relative to another entity referencePageAttachmentReference
objectpublic ObjectReference resolveObject(String stringRepresentation, Object... parameters)
stringRepresentation
- an object reference specified as String
(using the "wiki:space.page^object"
format and with special characters escaped where required)parameters
- extra parameters to pass to the resolver; you can use these parameters to resolve an object
reference relative to another entity referenceObjectReference
object (resolved using the
resolver)public ObjectReference resolveObject(String stringRepresentation, String hint, Object... parameters)
stringRepresentation
- an object reference specified as String
(using the "wiki:space.page^object"
format and with special characters escaped where required)hint
- the hint of the resolver to use in case any part of the reference is missing (no wiki specified, no
space or no page)parameters
- extra parameters to pass to the resolver; you can use these parameters to resolve an object
reference relative to another entity referenceObjectReference
objectpublic PageObjectReference resolvePageObject(String stringRepresentation, Object... parameters)
stringRepresentation
- an object reference specified as String
(using the "wiki:space/page/object"
format and with special characters escaped where required)parameters
- extra parameters to pass to the resolver; you can use these parameters to resolve an object
reference relative to another entity referencePageObjectReference
object (resolved using the
resolver)public PageObjectReference resolvePageObject(String stringRepresentation, String hint, Object... parameters)
stringRepresentation
- an object reference specified as String
(using the "wiki:space/page/object"
format and with special characters escaped where required)hint
- the hint of the resolver to use in case any part of the reference is missing (no wiki specified, no
space or no page)parameters
- extra parameters to pass to the resolver; you can use these parameters to resolve an object
reference relative to another entity referencePageObjectReference
objectpublic ObjectPropertyReference resolveObjectProperty(String stringRepresentation, Object... parameters)
stringRepresentation
- an object property reference specified as String
(using the
"wiki:space.page^object.property" format and with special characters escaped where required)parameters
- extra parameters to pass to the resolver; you can use these parameters to resolve an object
property reference relative to another entity referenceObjectPropertyReference
object (resolved using the
resolver)public ObjectPropertyReference resolveObjectProperty(String stringRepresentation, String hint, Object... parameters)
stringRepresentation
- an object property reference specified as String
(using the
"wiki:space.page^object.property" format and with special characters escaped where required)hint
- the hint of the resolver to use in case any part of the reference is missing (no wiki specified, no
space or no page)parameters
- extra parameters to pass to the resolver; you can use these parameters to resolve an object
property reference relative to another entity referenceObjectPropertyReference
objectpublic PageObjectPropertyReference resolvePageObjectProperty(String stringRepresentation, Object... parameters)
stringRepresentation
- an object property reference specified as String
(using the
"wiki:space/page/object/property" format and with special characters escaped where required)parameters
- extra parameters to pass to the resolver; you can use these parameters to resolve an object
property reference relative to another entity referenceObjectPropertyReference
object (resolved using the
resolver)public PageObjectPropertyReference resolvePageObjectProperty(String stringRepresentation, String hint, Object... parameters)
stringRepresentation
- an object property reference specified as String
(using the
"wiki:space/page/object/property" format and with special characters escaped where required)hint
- the hint of the resolver to use in case any part of the reference is missing (no wiki specified, no
space or no page)parameters
- extra parameters to pass to the resolver; you can use these parameters to resolve an object
property reference relative to another entity referenceObjectPropertyReference
objectpublic ClassPropertyReference resolveClassProperty(String stringRepresentation, Object... parameters)
stringRepresentation
- a class property reference specified as String
(using the
"wiki:Space.Class^property" format and with special characters escaped where required)parameters
- extra parameters to pass to the resolver; you can use these parameters to resolve a class
property reference relative to another entity referenceClassPropertyReference
object (resolved using the
resolver)public ClassPropertyReference resolveClassProperty(String stringRepresentation, String hint, Object... parameters)
stringRepresentation
- a class property reference specified as String
(using the
"wiki:Space.Class^property" format and with special characters escaped where required)hint
- the hint of the resolver to use in case any part of the reference is missing (no wiki specified, no
space or no page)parameters
- extra parameters to pass to the resolver; you can use these parameters to resolve a class
property reference relative to another entity referenceClassPropertyReference
objectpublic PageClassPropertyReference resolvePageClassProperty(String stringRepresentation, Object... parameters)
stringRepresentation
- a class property reference specified as String
(using the
"wiki:Space/Class/property" format and with special characters escaped where required)parameters
- extra parameters to pass to the resolver; you can use these parameters to resolve a class
property reference relative to another entity referenceClassPropertyReference
object (resolved using the
resolver)public PageClassPropertyReference resolvePageClassProperty(String stringRepresentation, String hint, Object... parameters)
stringRepresentation
- a class property reference specified as String
(using the
"wiki:Space/Class/property" format and with special characters escaped where required)hint
- the hint of the resolver to use in case any part of the reference is missing (no wiki specified, no
space or no page)parameters
- extra parameters to pass to the resolver; you can use these parameters to resolve a class
property reference relative to another entity referenceClassPropertyReference
objectpublic String serialize(EntityReference reference, Object... parameters)
reference
- the entity reference to transform into a String representationparameters
- the optional extra parameters to pass to the Serializer; they are passed directly to
EntityReferenceSerializer.serialize(org.xwiki.model.reference.EntityReference, Object...)
public String serialize(EntityReference reference, String hint, Object... parameters)
reference
- the entity reference to transform into a String representationhint
- the hint of the Serializer to use (valid hints are for example "default", "compact", "local")parameters
- the optional extra parameters to pass to the Serializer; they are passed directly to
EntityReferenceSerializer.serialize(org.xwiki.model.reference.EntityReference, Object...)
@Deprecated public String getEntityReferenceValue(EntityType type)
getEntityReference(EntityType)
type
- the target entity type; from Velocity it's enough to use a string with the uppercase name of the
entity, like 'SPACE'
@Deprecated public String getEntityReferenceValue(EntityType type, String hint)
getEntityReference(EntityType, String)
type
- the target entity type; from Velocity it's enough to use a string with the uppercase name of the
entity, like 'SPACE'
hint
- the hint of the value provider to use (valid hints are for example "default", "current" and
"currentmixed")public EntityReference getEntityReference(EntityType type)
type
- the target entity type; from Velocity it's enough to use a string with the uppercase name of the
entity, like 'SPACE'
public EntityReference getEntityReference(EntityType type, String hint)
type
- the target entity type; from Velocity it's enough to use a string with the uppercase name of the
entity, like 'SPACE'
hint
- the hint of the EntityReferenceProvider
to use (valid hints are for example "default",
"current" and "currentmixed")public EntityReferenceTree toTree(Iterable<? extends EntityReference> references)
references
- the referencespublic EntityReferenceTree toTree(EntityReference... references)
references
- the referencespublic String escape(String name, EntityType type)
name
- the name of the entitytype
- the type of the entityCopyright © 2004–2021 XWiki. All rights reserved.