getAdditionalAttributes
getAdditionalAttributes()
La méthode
getAdditionalAttributes
renvoie les attributs d'offre personnalisés définis dans
Campaign
.
Valeur de retour
La méthode
getAdditionalAttributes
renvoie un tableau d'objets NameValuePair.
Exemple
L'exemple suivant effectue un tri en fonction de tous les attributs supplémentaires, vérifie la date d'effet et la date d'expiration, et imprime les autres attributs.
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());
}
Copyright IBM Corporation 2012. All Rights Reserved.