info.magnolia.link
Class LinkFactory

java.lang.Object
  extended by info.magnolia.link.LinkFactory

public class LinkFactory
extends Object

Factory processing various input into the Link objects and back. For parsing html and converting multiple link instances on the fly use LinkUtil.

Version:
$Id:$
Author:
had

Field Summary
static Pattern LINK_PATTERN
          Pattern to find a link.
static Pattern UUID_PATTERN
          Pattern to find a magnolia formatted uuid link.
 
Constructor Summary
LinkFactory()
           
 
Method Summary
static Link createLink(Content node)
          Creates new link from the content node.
static Link createLink(NodeData nodeData)
          Creates new link from the node data.
static Link createLink(String repository, String uuid)
          Creates link to the content denoted by repository and uuid.
static Link createLink(String repository, String path, String extension, String anchor, String parameters)
          Creates link to the content identified by the repository and path.
static Link createLink(String uuid, String repository, String fallbackHandle, String nodeDataName, String extension, String anchor, String parameters)
          Creates link based on provided parameters.
static Link parseLink(String link)
          Parses provided URI to the link.
static Link parseUUIDLink(String uuidLink)
          Parses UUID link pattern string and converts it into a Link object.
static String toPattern(Link link)
          Converts provided Link to an UUID link pattern.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UUID_PATTERN

public static Pattern UUID_PATTERN
Pattern to find a magnolia formatted uuid link.


LINK_PATTERN

public static final Pattern LINK_PATTERN
Pattern to find a link.

Constructor Detail

LinkFactory

public LinkFactory()
Method Detail

createLink

public static Link createLink(Content node)
Creates new link from the content node.

Parameters:
node - Target content for the link.
Returns:
Link pointing to the provided content.

createLink

public static Link createLink(NodeData nodeData)
                       throws LinkException
Creates new link from the node data.

Parameters:
nodeData - Target node data for the link.
Returns:
Link pointing to the provided node data.
Throws:
LinkException

createLink

public static Link createLink(String repository,
                              String uuid)
                       throws LinkException
Creates link to the content denoted by repository and uuid.

Parameters:
repository - Parent repository of the content of interest.
uuid - UUID of the content to create link to.
Returns:
link to the content with provided UUID.
Throws:
LinkException

createLink

public static Link createLink(String repository,
                              String path,
                              String extension,
                              String anchor,
                              String parameters)
                       throws LinkException
Creates link to the content identified by the repository and path. Link will use specified extension and will also contain the anchor and parameters if specified.

Parameters:
repository - Source repository for the content.
path - Path to the content of interest.
extension - Optional extension to be used in the link
anchor - Optional link anchor.
parameters - Optional link parameters.
Returns:
Link pointing to the content denoted by repository and path including extension, anchor and parameters if such were provided.
Throws:
LinkException

createLink

public static Link createLink(String uuid,
                              String repository,
                              String fallbackHandle,
                              String nodeDataName,
                              String extension,
                              String anchor,
                              String parameters)
                       throws LinkException
Creates link based on provided parameters. Should the uuid be non existent or the fallback handle invalid, creates nonetheless an "undefined" Link object, pointing to the non existing uuid so that broken link detection tools can find it.

Parameters:
uuid - UUID of the content
repository - Content repository name.
fallbackHandle - Optional fallback content handle.
nodeDataName - Content node data name for binary data.
extension - Optional link extension.
anchor - Optional link anchor.
parameters - Optional link parameters.
Returns:
Link pointing to the content denoted by uuid and repository. Link is created using all provided optional values if present.
Throws:
LinkException

parseUUIDLink

public static Link parseUUIDLink(String uuidLink)
                          throws LinkException
Parses UUID link pattern string and converts it into a Link object.

Parameters:
uuidLink - String containing reference to content as a UUID link pattern.
Returns:
Link to content referenced in the provided text.
Throws:
LinkException

parseLink

public static Link parseLink(String link)
                      throws LinkException
Parses provided URI to the link.

Parameters:
link - URI representing path to piece of content
Returns:
Link pointing to the content represented by provided URI
Throws:
LinkException

toPattern

public static String toPattern(Link link)
Converts provided Link to an UUID link pattern.

Parameters:
link - Link to convert.
Returns:
UUID link pattern representation of provided link.


Copyright © 2003–2014 Magnolia International Ltd.. All rights reserved.