org.apache.cocoon.bean
Class Target

java.lang.Object
  extended by org.apache.cocoon.bean.Target

public class Target
extends Object

A Target is a single page for generation. It encapsulates the URI arithmetic required to transform the URI of the page to be generated (the source URI) into the URI to which the resulting page should be written (the destination URI).

Version:
CVS $Id: Target.html 1304258 2012-03-23 10:09:27Z ilgrosso $
Author:
Upayavira

Constructor Summary
Target(String sourceURI, String destURI)
           
Target(String type, String sourceURI, String destURI)
           
Target(String type, String root, String sourceURI, String destURI)
           
 
Method Summary
 boolean confirmExtensions()
           
 boolean equals(Object o)
           
 boolean followLinks()
           
 String getAuthlessDestURI()
           
 String getDeparameterizedSourceURI()
          Gets the source URI for this target, with parameters removed.
 Target getDerivedTarget(String originalLinkURI)
           
 String getDestinationURI()
          Calculates the destination URI - the URI to which the generated page should be written.
 String getExtension()
          Gets the file extension for the source URI
 String getLogger()
           
 String getOriginalSourceURI()
          Gets the original URI used to create this Target.
 String getPageURI()
          Gets the filename from the source URI, without the path.
 TreeMap getParameters()
          Gets the parameters that have been removed from the URI.
 String getParentURI()
          Gets the parent URI (the URI of the page that contained a link to this URI). null is returned if this page was not referred to in a link.
 String getPath()
          Gets the path from the source URI, without the filename.
 String getSourceURI()
          Gets the source URI for this target, after the URI has been 'prepared' by normalisation, absolutization and deparameterization followed by reparameterization.
 String getTranslatedURI(String path)
          Gets a translated version of a link, ready for insertion into another page as a link.
 int hashCode()
           
 void setConfirmExtension(boolean b)
           
 void setDefaultFilename(String filename)
          Sets the default filename.
 void setExtraExtension(String extension)
          Sets a file extension to be appended to the end of the destination URI.
 void setFollowLinks(boolean b)
           
 void setLogger(String string)
           
 void setMimeType(String mimeType)
          Sets the mime type for the resource referenced by this target.
 void setOriginalURI(String uri)
          Sets the original URI.
 void setParentURI(String uri)
          Sets the URI of the page that contained the link to this URI.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Target

public Target(String type,
              String root,
              String sourceURI,
              String destURI)
       throws IllegalArgumentException
Throws:
IllegalArgumentException

Target

public Target(String type,
              String sourceURI,
              String destURI)
       throws IllegalArgumentException
Throws:
IllegalArgumentException

Target

public Target(String sourceURI,
              String destURI)
       throws IllegalArgumentException
Throws:
IllegalArgumentException
Method Detail

getDerivedTarget

public Target getDerivedTarget(String originalLinkURI)
                        throws IllegalArgumentException
Throws:
IllegalArgumentException

setOriginalURI

public void setOriginalURI(String uri)
Sets the original URI. This is used to record the URI that caused the creation of this Target, for example as a link in another page. It is needed for doing link translation, as this is the URI that must be replaced by the translated one.


setParentURI

public void setParentURI(String uri)
Sets the URI of the page that contained the link to this URI. Used for reporting purposes.


setMimeType

public void setMimeType(String mimeType)
Sets the mime type for the resource referenced by this target. If a mime type is specified, the file extension of the destination URI will be checked to see that it matches the default extension for the specified mime type. If it doesn't, the default extension will be appended to the destination URI. This URI change will be taken into account in pages that link to the current page. If the mime type is not specified (and thus null), no extension checking will take place.


setExtraExtension

public void setExtraExtension(String extension)
Sets a file extension to be appended to the end of the destination URI. The main use of this is to create broken link error files that stand out, within the file structure of the generated site, by, for example, adding '.error' to the end of the filename.


setDefaultFilename

public void setDefaultFilename(String filename)
Sets the default filename. This filename is appended to URIs that refer to a directory, i.e. end with a slash, as resources referred to by such a URI cannot be written to a file system without a filename. This URI change will be taken into account in pages that link to the current page. If no default is specified, the Cocoon constants value will be used.


getPageURI

public String getPageURI()
Gets the filename from the source URI, without the path. This is used to fill out relative URIs that have parameters but no filename such as ?page=123


getPath

public String getPath()
Gets the path from the source URI, without the filename. This is used when absolutizing/relativizing link URIs.


getExtension

public String getExtension()
Gets the file extension for the source URI


getParentURI

public String getParentURI()
Gets the parent URI (the URI of the page that contained a link to this URI). null is returned if this page was not referred to in a link.


getDestinationURI

public String getDestinationURI()
                         throws ProcessingException
Calculates the destination URI - the URI to which the generated page should be written. This will be a URI that, when resolved by a SourceResolver, will return a modifiableSource. This calculation is only done once per target. It is therefore necessary to ensure that the mime type has been set (if required) before this method is called.

Throws:
ProcessingException

getTranslatedURI

public String getTranslatedURI(String path)
                        throws ProcessingException
Gets a translated version of a link, ready for insertion into another page as a link. This link needs to be relative to the original page.

Throws:
ProcessingException

getAuthlessDestURI

public String getAuthlessDestURI()
                          throws ProcessingException
Returns:
destination URI after all authentication details have been removed
Throws:
ProcessingException

getOriginalSourceURI

public String getOriginalSourceURI()
Gets the original URI used to create this Target. This URI is completely unprocessed.


getSourceURI

public String getSourceURI()
Gets the source URI for this target, after the URI has been 'prepared' by normalisation, absolutization and deparameterization followed by reparameterization. This final step is to ensure that all parameters appear in a consistent order. For example page?a=1&b=2 and page?b=2&a=1 should be considered the same resource, and thus have the same sourceURI.


getDeparameterizedSourceURI

public String getDeparameterizedSourceURI()
Gets the source URI for this target, with parameters removed. This is the URI that is to be passed to Cocoon in order to generate the page.


getParameters

public TreeMap getParameters()
Gets the parameters that have been removed from the URI. These need to be passed to Cocoon when generating a page.


equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object

confirmExtensions

public boolean confirmExtensions()
Returns:
boolean

followLinks

public boolean followLinks()

getLogger

public String getLogger()

setConfirmExtension

public void setConfirmExtension(boolean b)

setFollowLinks

public void setFollowLinks(boolean b)

setLogger

public void setLogger(String string)


Copyright © 1999-2010 The Apache Software Foundation. All Rights Reserved.