com.endeca.portal.format
Class FormattingUtils

java.lang.Object
  extended by com.endeca.portal.format.FormattingUtils

public class FormattingUtils
extends java.lang.Object


Constructor Summary
FormattingUtils()
           
 
Method Summary
static Formatter createDefaultFormatter(MDEXAttribute.PropertyType attributeType)
          Return the default formatter for the specified attribute type
static FormatSettings createFormatSettings(MDEXAttribute.PropertyType attributeType, java.lang.String jsonSettings)
          Create a FormatSettings instance from a json string or, if failed, return null.
static Formatter createFormatter(javax.portlet.PortletRequest request, DataSource dataSource, java.lang.String viewKey, java.lang.String attributeKey)
          Create formatter from the settings in the specified view of the given data source.
static Formatter createFormatter(javax.portlet.PortletRequest request, DataSource dataSource, java.lang.String viewKey, java.lang.String attributeKey, java.lang.String jsonSettings)
          Creates a formatter with the json string given, if it fails then try to create one from the settings in the view.
static Formatter createFormatter(javax.portlet.PortletRequest request, MDEXAttribute.PropertyType attributeType, java.util.Map<java.lang.String,java.lang.Object> settings)
          Create a formatter instance from a map of settings, if failed, return the cached default formatter for the attribute type.
static Formatter createFormatter(javax.portlet.PortletRequest request, MDEXAttribute.PropertyType attributeType, java.lang.String jsonSettings)
          Create a formatter instance from a json string or, if failed, return the cached default formatter for the attribute type.
static Formatter createFormatter(javax.portlet.PortletRequest request, SemanticView semanticView, java.lang.String attributeKey)
          Create formatter from the settings in the specified view.
static Formatter createFormatter(javax.portlet.PortletRequest request, SemanticView semanticView, java.lang.String attributeKey, java.util.Map<java.lang.String,java.lang.Object> settings)
          Creates a formatter with the json string given, if it fails then try to create one from the settings in the view.
static Formatter createFormatter(javax.portlet.PortletRequest request, SemanticView semanticView, java.lang.String attributeKey, java.lang.String jsonSettings)
          Creates a formatter with the json string given, if it fails then try to create one from the settings in the view.
static Formatter createFormatter(javax.portlet.PortletRequest request, java.lang.String attributeKey)
          Create formatter for the attribute specified.
static Formatter createFormatter(javax.portlet.PortletRequest request, java.lang.String attributeKey, java.lang.String jsonSettings)
          Creates a formatter for the specified attribute with the specified settings.
static java.lang.String formatterPanelResources(javax.portlet.PortletRequest request)
          Return the extra resources required by the panel in the page.
static java.lang.String formatValue(Formatter formatter, java.lang.String text)
          return formatted value as a String.
static Formatter getCachedDefaultFormatter(javax.portlet.PortletRequest request, MDEXAttribute.PropertyType attributeType)
          Get the cached default formatter for the attribute type from the request.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FormattingUtils

public FormattingUtils()
Method Detail

createFormatter

public static Formatter createFormatter(javax.portlet.PortletRequest request,
                                        MDEXAttribute.PropertyType attributeType,
                                        java.lang.String jsonSettings)
Create a formatter instance from a json string or, if failed, return the cached default formatter for the attribute type. The returned formatter should NOT be changed or persisted to a portlet's preference because it may be cached and shared in a request. To customize a formatter, please use the constructor of Formatter (or its subclasses) to create an instance.

Parameters:
request -
attributeType -
jsonSettings -
Returns:
A Formatter instance

createFormatSettings

public static FormatSettings createFormatSettings(MDEXAttribute.PropertyType attributeType,
                                                  java.lang.String jsonSettings)
Create a FormatSettings instance from a json string or, if failed, return null. The purpose of this method is to allow some portlet to read some specific field(s) in the json settings. DO NOT try to convert the returned settings into Formatter!

Parameters:
attributeType -
jsonSettings -
Returns:
A FormatSettings instance

createFormatter

public static Formatter createFormatter(javax.portlet.PortletRequest request,
                                        MDEXAttribute.PropertyType attributeType,
                                        java.util.Map<java.lang.String,java.lang.Object> settings)
Create a formatter instance from a map of settings, if failed, return the cached default formatter for the attribute type. The returned formatter should NOT be changed or persisted to a portlet's preference because it may be cached and shared in a request. To customize a formatter, please use the constructor of Formatter (or its subclasses) to create an instance.

Parameters:
request -
settings -
attributeType -
Returns:

createFormatter

public static Formatter createFormatter(javax.portlet.PortletRequest request,
                                        DataSource dataSource,
                                        java.lang.String viewKey,
                                        java.lang.String attributeKey,
                                        java.lang.String jsonSettings)
Creates a formatter with the json string given, if it fails then try to create one from the settings in the view. If it fails again, just simply create a default formatter for the specified data type.

Parameters:
request -
dataSource -
viewKey -
attributeKey -
jsonSettings -
Returns:

createFormatter

public static Formatter createFormatter(javax.portlet.PortletRequest request,
                                        SemanticView semanticView,
                                        java.lang.String attributeKey,
                                        java.util.Map<java.lang.String,java.lang.Object> settings)
Creates a formatter with the json string given, if it fails then try to create one from the settings in the view. If it fails again, just simply create a default formatter for the specified data type.

Parameters:
request -
semanticView -
attributeKey -
dataType -
settings -
Returns:

createFormatter

public static Formatter createFormatter(javax.portlet.PortletRequest request,
                                        SemanticView semanticView,
                                        java.lang.String attributeKey,
                                        java.lang.String jsonSettings)
Creates a formatter with the json string given, if it fails then try to create one from the settings in the view. If it fails again, just simply create a default formatter for the specified data type.

Parameters:
request -
semanticView -
attributeKey -
jsonSettings -
Returns:

createFormatter

public static Formatter createFormatter(javax.portlet.PortletRequest request,
                                        DataSource dataSource,
                                        java.lang.String viewKey,
                                        java.lang.String attributeKey)
Create formatter from the settings in the specified view of the given data source. If it fails, create a default formatter based on the property type. This method is for the portlets that don't have formatter panel available.

Parameters:
request -
dataSource -
viewKey -
attributeKey -
Returns:

createFormatter

public static Formatter createFormatter(javax.portlet.PortletRequest request,
                                        SemanticView semanticView,
                                        java.lang.String attributeKey)
Create formatter from the settings in the specified view. If it fails, create a default formatter based on the given property type This method is for the portlets that don't have formatter panel available.

Parameters:
request -
semanticView -
attributeKey -
dataType -
Returns:

createFormatter

public static Formatter createFormatter(javax.portlet.PortletRequest request,
                                        java.lang.String attributeKey)
Create formatter for the attribute specified. It creates the data source in the request and gets the base view for the data source. Then it gets the settings of the specified attribute in view manager and creates the formatter with the settings. If no settings is found, returns the formatter of the attribute type. If it fails to do so, it returns a default formatter.

Parameters:
request -
attributeKey -
Returns:

createFormatter

public static Formatter createFormatter(javax.portlet.PortletRequest request,
                                        java.lang.String attributeKey,
                                        java.lang.String jsonSettings)
Creates a formatter for the specified attribute with the specified settings. Sets up the appropriate formatter hierarchy. This is essentially the same as createFormatter(PortletRequest,SemanticView,String,String), but it first looks up the default view in the DataSource.

Parameters:
request -
attributeKey -
jsonSettings -
Returns:

formatValue

public static java.lang.String formatValue(Formatter formatter,
                                           java.lang.String text)
return formatted value as a String. If any exception happens, the original value will be returned.

Parameters:
formatter -
text -
Returns:

formatterPanelResources

public static java.lang.String formatterPanelResources(javax.portlet.PortletRequest request)
Return the extra resources required by the panel in the page.

Returns:

getCachedDefaultFormatter

public static Formatter getCachedDefaultFormatter(javax.portlet.PortletRequest request,
                                                  MDEXAttribute.PropertyType attributeType)
Get the cached default formatter for the attribute type from the request. Create one and cache it if not exist.

Parameters:
request -
locale -
Returns:

createDefaultFormatter

public static Formatter createDefaultFormatter(MDEXAttribute.PropertyType attributeType)
Return the default formatter for the specified attribute type

Parameters:
attributeType -
Returns: