com.fatwire.gst.foundation.facade.assetapi
Class AttributeDataUtils

java.lang.Object
  extended by com.fatwire.gst.foundation.facade.assetapi.AttributeDataUtils

public final class AttributeDataUtils
extends Object

Utility class for processing attribute data. Some of the data conversion methods have not been thoroughly tested and may therefore require some bug fixes.

Since:
Nov 17, 2009
Author:
Tony Field, Dolf Dijkstra

Method Summary
static com.fatwire.assetapi.data.AssetId asAssetId(com.fatwire.assetapi.data.AttributeData attr)
           
static List<com.fatwire.assetapi.data.AssetId> asAssetIdList(com.fatwire.assetapi.data.AttributeData attr)
           
static com.fatwire.assetapi.data.BlobObject asBlob(com.fatwire.assetapi.data.AttributeData attr)
           
static List<com.fatwire.assetapi.data.BlobObject> asBlobList(com.fatwire.assetapi.data.AttributeData attr)
           
static Date asDate(com.fatwire.assetapi.data.AttributeData attr)
           
static List<Date> asDateList(com.fatwire.assetapi.data.AttributeData attr)
           
static com.fatwire.mda.Dimension asDimension(com.fatwire.assetapi.data.AttributeData attr)
          Returns the Dimension for the attribute.
static Double asDouble(com.fatwire.assetapi.data.AttributeData attr)
           
static List<Double> asDoubleList(com.fatwire.assetapi.data.AttributeData attr)
           
static Float asFloat(com.fatwire.assetapi.data.AttributeData attr)
           
static List<Float> asFloatList(com.fatwire.assetapi.data.AttributeData attr)
           
static Integer asInt(com.fatwire.assetapi.data.AttributeData attr)
           
static List<Integer> asIntList(com.fatwire.assetapi.data.AttributeData attr)
           
static List<?> asList(com.fatwire.assetapi.data.AttributeData attr)
           
static Long asLong(com.fatwire.assetapi.data.AttributeData attr)
           
static List<Long> asLongList(com.fatwire.assetapi.data.AttributeData attr)
           
static String asString(com.fatwire.assetapi.data.AttributeData attr)
           
static List<String> asStringList(com.fatwire.assetapi.data.AttributeData attr)
           
static Collection<String> getAndSplitString(com.fatwire.assetapi.data.AttributeData attributeData, String delimRegex)
          Get an attribute that is a comma-separated string and split it into a collection.
static String getMultivaluedAsCommaSepString(com.fatwire.assetapi.data.AttributeData attributeData)
          Get the specified attribute data, converting each of the values into a string and separating them with a comma (no space).
static String getWithFallback(com.fatwire.assetapi.data.AssetData assetData, String... orderedAttributeNames)
          Get the specified attribute field from the AssetData object.
static boolean isSingleValued(com.fatwire.assetapi.data.AttributeData attr)
           
static boolean isSingleValued(com.fatwire.assetapi.def.AttributeDef ad)
          Returns true if the attribute definition is defined as single valued.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getWithFallback

public static String getWithFallback(com.fatwire.assetapi.data.AssetData assetData,
                                     String... orderedAttributeNames)
Get the specified attribute field from the AssetData object. If it is not found, get the next field listed. Continue until the end of the list. Safe to use with a single value. If no data is found for any attribute, an exception is thrown.

Parameters:
assetData - populated AssetData object
orderedAttributeNames - vararg array of attribute names that are expected to be found and populated in the assetData object
Returns:
the value, never null

getMultivaluedAsCommaSepString

public static String getMultivaluedAsCommaSepString(com.fatwire.assetapi.data.AttributeData attributeData)
Get the specified attribute data, converting each of the values into a string and separating them with a comma (no space).

Parameters:
attributeData - multi-valued attribute data
Returns:
attribute data converted to a string, comma-separated.

getAndSplitString

public static Collection<String> getAndSplitString(com.fatwire.assetapi.data.AttributeData attributeData,
                                                   String delimRegex)
Get an attribute that is a comma-separated string and split it into a collection. If the attribute has no values, an empty list is returned. All attribute values or substring values of zero length are dropped.

Parameters:
attributeData -
delimRegex - regex for splitting
Returns:
Collection of attribute data, never null (though an empty list may be returned

isSingleValued

public static boolean isSingleValued(com.fatwire.assetapi.data.AttributeData attr)
Parameters:
attr - the attribute data
Returns:
true if valueCount == ValueCount.SINGLE

isSingleValued

public static boolean isSingleValued(com.fatwire.assetapi.def.AttributeDef ad)
Returns true if the attribute definition is defined as single valued.

Parameters:
ad - attribute definition
Returns:
true if valueCount == ValueCount.SINGLE

asList

public static List<?> asList(com.fatwire.assetapi.data.AttributeData attr)
Parameters:
attr - the attribute data
Returns:
the attribute value as a List. If attribute isSingleValued than return getData() and cast to List.

asInt

public static Integer asInt(com.fatwire.assetapi.data.AttributeData attr)
Parameters:
attr - the attribute data
Returns:
attribute value as a Integer if the attribute type is a INT.

asDate

public static Date asDate(com.fatwire.assetapi.data.AttributeData attr)
Parameters:
attr - the attribute data
Returns:
attribute value as a Date if the attribute type is a DATE

asBlob

public static com.fatwire.assetapi.data.BlobObject asBlob(com.fatwire.assetapi.data.AttributeData attr)
Parameters:
attr - the attribute data
Returns:
attribute value as a BlobObject if the attribute type is a URL or BLOB

asFloat

public static Float asFloat(com.fatwire.assetapi.data.AttributeData attr)
Parameters:
attr - the attribute data.
Returns:
attribute value as a Float if the attribute type is a FLOAT or INT.

asDouble

public static Double asDouble(com.fatwire.assetapi.data.AttributeData attr)
Parameters:
attr - the attribute data
Returns:
attribute value as a Double if the attribute type is a FLOAT,INT,LONG or MONEY.

asLong

public static Long asLong(com.fatwire.assetapi.data.AttributeData attr)
Parameters:
attr - the attribute data
Returns:
attribute value as a Long if the attribute type is a INT or LONG.

asAssetId

public static com.fatwire.assetapi.data.AssetId asAssetId(com.fatwire.assetapi.data.AttributeData attr)
Parameters:
attr - the attribute data
Returns:
attribute value as a AssetId if the attribute type is a ASSET.

asString

public static String asString(com.fatwire.assetapi.data.AttributeData attr)
Parameters:
attr - the attribute data
Returns:
attribute value as a String if the attribute type is a INT,FLOAT,LONG,MONEY,DATE,STRING or LARGE_TEXT.

asIntList

public static List<Integer> asIntList(com.fatwire.assetapi.data.AttributeData attr)
Parameters:
attr - the attribute data
Returns:
attribute value as a Integer if the attribute type is a INT.

asDateList

public static List<Date> asDateList(com.fatwire.assetapi.data.AttributeData attr)
Parameters:
attr - the attribute data
Returns:
attribute value as a Date if the attribute type is a DATE

asBlobList

public static List<com.fatwire.assetapi.data.BlobObject> asBlobList(com.fatwire.assetapi.data.AttributeData attr)
Parameters:
attr - the attribute data
Returns:
attribute value as a BlobObject if the attribute type is a URL or BLOB

asFloatList

public static List<Float> asFloatList(com.fatwire.assetapi.data.AttributeData attr)
Parameters:
attr - the attribute data.
Returns:
attribute value as a Float if the attribute type is a FLOAT or INT.

asDoubleList

public static List<Double> asDoubleList(com.fatwire.assetapi.data.AttributeData attr)
Parameters:
attr - the attribute data
Returns:
attribute value as a Double if the attribute type is a FLOAT,INT,LONG or MONEY.

asLongList

public static List<Long> asLongList(com.fatwire.assetapi.data.AttributeData attr)
Parameters:
attr - the attribute data
Returns:
attribute value as a Long if the attribute type is a INT or LONG.

asAssetIdList

public static List<com.fatwire.assetapi.data.AssetId> asAssetIdList(com.fatwire.assetapi.data.AttributeData attr)
Parameters:
attr - the attribute data
Returns:
attribute value as a AssetId if the attribute type is a ASSET.

asStringList

public static List<String> asStringList(com.fatwire.assetapi.data.AttributeData attr)
Parameters:
attr - the attribute data
Returns:
attribute value as a String if the attribute type is a INT,FLOAT,LONG,MONEY,DATE,STRING or LARGE_TEXT.

asDimension

public static com.fatwire.mda.Dimension asDimension(com.fatwire.assetapi.data.AttributeData attr)
Returns the Dimension for the attribute.

Parameters:
attr - the attribute data for the 'Dimension' attribute.
Returns:
the Dimension if found.


Copyright © 2010-2013 Oracle Corporation. All Rights Reserved.