com.endeca.infront.cartridge.model
Class LinkBuilder

java.lang.Object
  extended by com.endeca.infront.cartridge.model.LinkBuilder

public class LinkBuilder
extends Object

A class that represents links as created by the LinkBuilder editor in Experience Manager and transforms them into Action objects.

Usage Example

Here's a sample handler that uses the LinkBuilder class to transform a link.

 FILE: MyHandler.java
  public ContentItem process(SampleConfig config)
          throws CartridgeHandlerException {
      LinkBuilder link = config.getLink();
      Action linkAction = null;
      try {
          linkAction= link.createAction(
              navigationStateBuilder, mdexResource));
      } catch (ContentException e) {
          throw new CartridgeHandlerException(e);
      }
      config.setAction(linkAction);
      return config;
  }
 


Nested Class Summary
static class LinkBuilder.LinkType
          The types of links that the LinkBuilder supports.
 
Constructor Summary
LinkBuilder()
          Default constructor.
LinkBuilder(String path)
          Constructs a LinkBuilder model with the specified path.
LinkBuilder(String path, LinkBuilder.LinkType linkType)
          Constructs a LinkBuilder model with the specified path and link type.
LinkBuilder(String path, LinkBuilder.LinkType linkType, String queryString)
          Constructs a LinkBuilder model with the specified path, link type and queryString.
 
Method Summary
 Action createAction(NavigationStateBuilder navigationStateBuilder, ContentSource source, ActionPathProvider pathProvider)
          Returns an action created from the path, link type and query string of this LinkBuilder.
 LinkBuilder.LinkType getLinkType()
           
 String getPath()
           
 String getQueryString()
           
 void setLinkType(LinkBuilder.LinkType linkType)
          Sets the type of this link.
 void setPath(String path)
          Sets the path of this Link.
 void setQueryString(String query)
          Sets the query string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LinkBuilder

public LinkBuilder()
Default constructor.


LinkBuilder

public LinkBuilder(String path)
Constructs a LinkBuilder model with the specified path.


LinkBuilder

public LinkBuilder(String path,
                   LinkBuilder.LinkType linkType)
Constructs a LinkBuilder model with the specified path and link type.


LinkBuilder

public LinkBuilder(String path,
                   LinkBuilder.LinkType linkType,
                   String queryString)
Constructs a LinkBuilder model with the specified path, link type and queryString.

Method Detail

getPath

public String getPath()
Returns:
The path of the URL. If it is an external link, the path must be an absolute URL.

setPath

public void setPath(String path)
Sets the path of this Link.

Parameters:
path - the path of the URL

getLinkType

public LinkBuilder.LinkType getLinkType()
Returns:
The link type.

setLinkType

public void setLinkType(LinkBuilder.LinkType linkType)
Sets the type of this link.

Parameters:
linkType - a link type
See Also:
LinkBuilder.LinkType

getQueryString

public String getQueryString()
Returns:
The query string of the URL.

setQueryString

public void setQueryString(String query)
Sets the query string.

Parameters:
query - a query string

createAction

public Action createAction(NavigationStateBuilder navigationStateBuilder,
                           ContentSource source,
                           ActionPathProvider pathProvider)
                    throws ContentException
Returns an action created from the path, link type and query string of this LinkBuilder.

Parameters:
navigationStateBuilder - used to create the navigation state for the action
source - the content source to use for resolving content URIs
pathProvider - if specified, will be used to fill in the action path components for links that have no path configured
Returns:
The action represented by this LinkBuilder.
Throws:
ContentException - If the path was not specified and the dimensions or record IDs are not valid.


Copyright © 2012. All Rights Reserved.