getAdditionalAttributes

getAdditionalAttributes メソッドは、Campaign で定義されるカスタム・オファー属性を返します。

getAdditionalAttributes()

戻り値

getAdditionalAttributes メソッドは、NameValuePair オブジェクトの配列を返します。

以下の例では、すべての追加属性間でソートし、有効日と有効期限をチェックして、その他の属性を出力します。

    for(NameValuePair offerAttribute : offer.getAdditionalAttributes())
    {                        
        // check to see if the effective date exists
        if(offerAttribute.getName().equalsIgnoreCase("effectiveDate"))
        {
            System.out.println("Found effective date");
        }
        // check to see if the expiration date exists
        else if(offerAttribute.getName().equalsIgnoreCase("expirationDate"))
        {
            System.out.println("Found expiration date");
        }
        printNameValuePair(offerAttribute);
        }
    }    
    public static void printNameValuePair(NameValuePair nvp)
    {
        // print out the name:
        System.out.println("Name:"+nvp.getName());
        
        // based on the datatype, call the appropriate method to get the value
        if(nvp.getValueDataType()==NameValuePair.DATA_TYPE_DATETIME)
            System.out.println("DateValue:"+nvp.getValueAsDate());
        else if(nvp.getValueDataType()==NameValuePair.DATA_TYPE_NUMERIC)
            System.out.println("NumericValue:"+nvp.getValueAsNumeric());
        else
            System.out.println("StringValue:"+nvp.getValueAsString());
    }