com.bemoko.live.platform.mwc.sites
Class LiveResourceUri

java.lang.Object
  extended by com.bemoko.live.platform.mwc.sites.LiveResourceUri
All Implemented Interfaces:
com.bemoko.live.platform.mwc.cache.SiteScopedCacheEntry, Serializable, Cloneable

public class LiveResourceUri
extends Object
implements Cloneable, com.bemoko.live.platform.mwc.cache.SiteScopedCacheEntry, Serializable

See Also:
Serialized Form

Nested Class Summary
protected  class LiveResourceUri.RemovalResult
           
 
Constructor Summary
LiveResourceUri(String uri)
           
LiveResourceUri(String siteName, String resourceType, String resourcePath)
          Create a LiveResourceURI from the constitute parts
LiveResourceUri(String siteName, String resourceType, String contextName, String contextResourcePath)
          Create a LiveResourceURI from the constitute parts
 
Method Summary
 void addSelector(String selectorFunctionAsString)
           
 void appendToResourcePath(String extraPath)
           
 void appendToResourcePath(String extraPath, boolean addLeadingSlash)
          Add the given relative path to the current resource path
 Object clone()
          Make a clone of a LiveResourceURI
 String getContextName()
          Return the context name e.g.
 List<String> getContextNameParts()
          Get a list of the context name parts
 String getContextResourcePath()
          Return the resource name relative to a context directory, e.g.
 String getContextResourcePathOrResourcePathIfContextNameIsNull()
           
 String getExtension()
           
 String getFallbackContext()
          Create a fallback context, i.e.
 String getFallbackContext(String newFirstContextName)
          Create a fallback context by replacing the first context name
 String getFallbackSiteName()
          Create a fallback site name, i.e.
 String getFallbackSiteName(String newFirstSiteName)
          Create a fallback site name by replacing the first site name
 String getFirstContextName()
          Return the first context name in the list of context name parts where each part is separated by a ":"
 String getFirstPath()
          Return the physical path of the first uri relative to the site location on which this site is mounted.
 String getFirstSiteContextEndPoint(LiveSite site, String resourceTypeDirectory)
           
 String getFirstSiteContextEndPoint(String resourceTypeDirectory)
           
 String getFirstSiteName()
          Return the first site name in the list of site name parts where each part is separated by a ":"
 String getFirstSitePath()
          Return the physical path of the first site name relative to the site location on which this site is mounted, e.g.
 String getFirstSiteRelativeUri()
          Get the URI relative to the site using the first context name in the list of context name parts
 String getFirstUri()
          Get the URI using the first context name in the list of context name parts and the first site name in the list of site name parts
 String getFirstUri(LiveSite site)
          Get the URI using the first context name in the list of context name parts and the site passed in as an argument
 String getLocalisation()
           
 String getName()
           
 String getResourcePath()
          Return the resource name, e.g.
 List<String> getResourcePathVariations()
           
 String getResourceType()
          Get the resource type, e.g.
 String getSecondContextName()
           
 String getSecondSiteName()
           
 List<Selector> getSelectors()
          The selector is a function that can be applied to a uri, e.g.
 String getSiteName()
           
 List<String> getSiteNameParts()
          Get a list of the site name parts
 String getSiteRelativeUri()
           
 String getUri()
           
 String getURI()
          Deprecated. since v1.3 - please use getUri()
 String getUriWithoutSelectors()
          Get the URI without any selector parts.
protected  LiveResourceUri.RemovalResult removeAndSetSelectors(String path)
           
 void setContextName(String contextName)
           
 void setContextResourcePath(String contextResourcePath)
           
 void setExtension(String extension)
           
 void setLocalisation(String localisation)
           
 void setResourceType(String resourceType)
           
 void setSiteName(String siteName)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LiveResourceUri

public LiveResourceUri(String uri)
                throws LiveException
Throws:
LiveException

LiveResourceUri

public LiveResourceUri(String siteName,
                       String resourceType,
                       String resourcePath)
Create a LiveResourceURI from the constitute parts

Parameters:
siteName - the site name
resourceType - the resource type
resourcePath - the resource path

LiveResourceUri

public LiveResourceUri(String siteName,
                       String resourceType,
                       String contextName,
                       String contextResourcePath)
Create a LiveResourceURI from the constitute parts

Parameters:
siteName -
resourceType -
contextName -
contextResourcePath - context resource path relative to the context directory and starting with a "/"
Method Detail

addSelector

public void addSelector(String selectorFunctionAsString)
Parameters:
selectorFunctionAsString - the selector function

appendToResourcePath

public void appendToResourcePath(String extraPath)

appendToResourcePath

public void appendToResourcePath(String extraPath,
                                 boolean addLeadingSlash)
Add the given relative path to the current resource path


clone

public Object clone()
Make a clone of a LiveResourceURI

Overrides:
clone in class Object

getContextName

public String getContextName()
Return the context name e.g. "mobile" when the resource name is "mobile/index.html".

Returns:
context name

getContextNameParts

public List<String> getContextNameParts()
Get a list of the context name parts

Returns:
context name parts as List

getContextResourcePath

public String getContextResourcePath()
Return the resource name relative to a context directory, e.g. "index.html" when the resource name is "mobile/index.html".

Returns:
cotext resource path

getContextResourcePathOrResourcePathIfContextNameIsNull

public String getContextResourcePathOrResourcePathIfContextNameIsNull()

getResourcePathVariations

public List<String> getResourcePathVariations()

getExtension

public String getExtension()

getFallbackContext

public String getFallbackContext()
Create a fallback context, i.e. the context path minus the first one

Returns:
fallback context

getFallbackContext

public String getFallbackContext(String newFirstContextName)
Create a fallback context by replacing the first context name


getFallbackSiteName

public String getFallbackSiteName()
Create a fallback site name, i.e. the site path minus the first one

Returns:
fallback site name

getFallbackSiteName

public String getFallbackSiteName(String newFirstSiteName)
Create a fallback site name by replacing the first site name


getFirstContextName

public String getFirstContextName()
Return the first context name in the list of context name parts where each part is separated by a ":"

Returns:
first context name

getFirstSiteContextEndPoint

public String getFirstSiteContextEndPoint(String resourceTypeDirectory)

getFirstSiteContextEndPoint

public String getFirstSiteContextEndPoint(LiveSite site,
                                          String resourceTypeDirectory)

getFirstSiteName

public String getFirstSiteName()
Return the first site name in the list of site name parts where each part is separated by a ":"

Returns:
first site name

getFirstSitePath

public String getFirstSitePath()
Return the physical path of the first site name relative to the site location on which this site is mounted, e.g. for site name "=site" return "/site" ; for site name "site~subsite" return "/site/subsite" and for site name "site$addon" return "/site/addons/addon" Starts with a '/' SiteUtils.getPathWithoutLeadingSlash(String)

Returns:
the physical path of the first site name

getFirstPath

public String getFirstPath()
Return the physical path of the first uri relative to the site location on which this site is mounted. Starts with a '/' SiteUtils.getPathWithoutLeadingSlash(String)

Returns:
the physical path of the first site name

getFirstSiteRelativeUri

public String getFirstSiteRelativeUri()
Get the URI relative to the site using the first context name in the list of context name parts

Returns:
reslative URI for first site

getFirstUri

public String getFirstUri()
Get the URI using the first context name in the list of context name parts and the first site name in the list of site name parts

Returns:
first URI

getFirstUri

public String getFirstUri(LiveSite site)
Get the URI using the first context name in the list of context name parts and the site passed in as an argument

Returns:
first URI for site

getLocalisation

public String getLocalisation()
Returns:
the localisation part of the URI

getResourcePath

public String getResourcePath()
Return the resource name, e.g. "mobile/index.html"

Returns:
resource path

getName

public String getName()

getResourceType

public String getResourceType()
Get the resource type, e.g. ui or plugins

Returns:
resource type

getSecondContextName

public String getSecondContextName()

getSecondSiteName

public String getSecondSiteName()

getSelectors

public List<Selector> getSelectors()
The selector is a function that can be applied to a uri, e.g. ":parent" to get the parent resource

Returns:
the selector

getSiteName

public String getSiteName()
Specified by:
getSiteName in interface com.bemoko.live.platform.mwc.cache.SiteScopedCacheEntry

getSiteNameParts

public List<String> getSiteNameParts()
Get a list of the site name parts

Returns:
site name parts

getSiteRelativeUri

public String getSiteRelativeUri()

getURI

@Deprecated
public String getURI()
Deprecated. since v1.3 - please use getUri()

Returns:
URI

getUri

public String getUri()

removeAndSetSelectors

protected LiveResourceUri.RemovalResult removeAndSetSelectors(String path)

setContextName

public void setContextName(String contextName)

setContextResourcePath

public void setContextResourcePath(String contextResourcePath)

setExtension

public void setExtension(String extension)

setLocalisation

public void setLocalisation(String localisation)
Parameters:
localisation - the localisation to set

setResourceType

public void setResourceType(String resourceType)

setSiteName

public void setSiteName(String siteName)

toString

public String toString()
Overrides:
toString in class Object

getUriWithoutSelectors

public String getUriWithoutSelectors()
Get the URI without any selector parts. If there are no selector parts then this is exactly the same as the URI.

Returns:
the uriWithoutSelectors