org.xwiki.model.internal.scripting
Class ModelScriptService

java.lang.Object
  extended by org.xwiki.model.internal.scripting.ModelScriptService
All Implemented Interfaces:
org.xwiki.script.service.ScriptService

@Component
@Named(value="model")
@Singleton
public class ModelScriptService
extends java.lang.Object
implements org.xwiki.script.service.ScriptService

Provides Model-specific Scripting APIs.

Since:
2.3M1
Version:
$Id$

Constructor Summary
ModelScriptService()
           
 
Method Summary
 AttachmentReference createAttachmentReference(DocumentReference documentReference, java.lang.String fileName)
          Creates an AttachmentReference from a file name and a reference to the document holding that file.
 DocumentReference createDocumentReference(java.lang.String wiki, java.lang.String space, java.lang.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 a "currentmixed/reference" resolver.
 DocumentReference createDocumentReference(java.lang.String wiki, java.lang.String space, java.lang.String page, java.lang.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.
 AttachmentReference resolveAttachment(java.lang.String stringRepresentation)
           
 AttachmentReference resolveAttachment(java.lang.String stringRepresentation, java.lang.String hint, java.lang.Object... parameters)
           
 DocumentReference resolveDocument(java.lang.String stringRepresentation)
           
 DocumentReference resolveDocument(java.lang.String stringRepresentation, java.lang.String hint, java.lang.Object... parameters)
           
 java.lang.String serialize(EntityReference reference)
           
 java.lang.String serialize(EntityReference reference, java.lang.String hint)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ModelScriptService

public ModelScriptService()
Method Detail

createDocumentReference

public DocumentReference createDocumentReference(java.lang.String wiki,
                                                 java.lang.String space,
                                                 java.lang.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 a "currentmixed/reference" resolver.

Parameters:
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)
Returns:
the typed Document Reference object or null if no Resolver with the passed hint could be found
Since:
2.3M2

createDocumentReference

public DocumentReference createDocumentReference(java.lang.String wiki,
                                                 java.lang.String space,
                                                 java.lang.String page,
                                                 java.lang.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. Valid hints are for example "default/reference", "current/reference", "currentmixed/reference".

Parameters:
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 null
Returns:
the typed Document Reference object or null if no Resolver with the passed hint could be found

createAttachmentReference

public AttachmentReference createAttachmentReference(DocumentReference documentReference,
                                                     java.lang.String fileName)
Creates an AttachmentReference from a file name and a reference to the document holding that file.

Parameters:
documentReference - a reference to the document the file is attached to
fileName - the name of a file attached to a document
Returns:
a reference to the specified attachment
Since:
2.5M2

resolveDocument

public DocumentReference resolveDocument(java.lang.String stringRepresentation)
Parameters:
stringRepresentation - the document reference specified as a String (using the "wiki:space.page" format and with special characters escaped where required)
Returns:
the typed Document Reference object (resolved using the resolver)
Since:
2.3M2

resolveDocument

public DocumentReference resolveDocument(java.lang.String stringRepresentation,
                                         java.lang.String hint,
                                         java.lang.Object... parameters)
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 reference
Returns:
the typed Document Reference object or null if no Resolver with the passed hint could be found

resolveAttachment

public AttachmentReference resolveAttachment(java.lang.String stringRepresentation)
Parameters:
stringRepresentation - an attachment reference specified as String (using the "wiki:space.page@file" format and with special characters escaped where required)
Returns:
the corresponding typed AttachmentReference object (resolved using the resolver)
Since:
2.5M2

resolveAttachment

public AttachmentReference resolveAttachment(java.lang.String stringRepresentation,
                                             java.lang.String hint,
                                             java.lang.Object... parameters)
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 reference
Returns:
the corresponding typed AttachmentReference object
Since:
2.5M2

serialize

public java.lang.String serialize(EntityReference reference)
Parameters:
reference - the entity reference to transform into a String representation
Returns:
the string representation of the passed entity reference (using the "compact" serializer)
Since:
2.3M2

serialize

public java.lang.String serialize(EntityReference reference,
                                  java.lang.String hint)
Parameters:
reference - the entity reference to transform into a String representation
hint - the hint of the Serializer to use (valid hints are for example "default", "compact", "local")
Returns:
the string representation of the passed entity reference


Copyright © 2004-2011 XWiki. All Rights Reserved.