public class RatingFieldValue extends java.lang.Object implements FieldValue
Item.getRatingValue(com.canto.cumulus.GUID)
to get this wrapper class object. You can then use Item.setRatingValue(com.canto.cumulus.GUID, RatingFieldValue)
to set the field value back into the item.Constructor and Description |
---|
RatingFieldValue(FieldDefinition fieldDefinition)
Creates a new instance for the given rating field.
|
Modifier and Type | Method and Description |
---|---|
void |
clearValue()
Clear the field's value.
|
int |
getCoreValue()
Get the enum ID for the configured number of stars.
|
java.lang.String |
getDisplayString()
Return the field's value as a string that can be displayed to the user.
|
java.lang.String |
getDisplayString(java.util.Locale locale)
Return the field's value as a string that can be displayed to the user.
|
int |
getRating()
Get the number of stars as the rating value.
|
boolean |
hasValue()
Return whether this field has a value.
|
void |
setFromDisplayString(java.util.Locale locale,
java.lang.String value)
Set the field value from a display string.
|
void |
setFromDisplayString(java.lang.String value)
Set the field value from a display string.
|
void |
setRating(int stars)
Set the field value using a number of stars representing a rating.
|
java.lang.String |
toString()
Same as
getDisplayString() . |
public RatingFieldValue(FieldDefinition fieldDefinition)
fieldDefinition
- rating fieldpublic boolean hasValue()
hasValue
in interface FieldValue
true
if the field has a value, false
otherwise.public void clearValue()
Item.save()
to
save this change back to the catalog.clearValue
in interface FieldValue
public java.lang.String getDisplayString()
*
characters corresponding to
the rating value.getDisplayString
in interface FieldValue
public java.lang.String getDisplayString(java.util.Locale locale)
*
characters corresponding to
the rating value.getDisplayString
in interface FieldValue
locale
- This parameter is not used.public void setFromDisplayString(java.lang.String value) throws InvalidArgumentException
Item.save()
to save this change back to the catalog.setFromDisplayString
in interface FieldValue
value
- The display string to set the value from. The string consists of a number of *
characters corresponding to the rating value.InvalidArgumentException
- if the display string is not of the right format.public void setFromDisplayString(java.util.Locale locale, java.lang.String value) throws InvalidArgumentException
Item.save()
to save this change back to the catalog.setFromDisplayString
in interface FieldValue
locale
- This parameter is not used.value
- The display string to set the value from. The string consists of a number of *
characters corresponding to the rating value.InvalidArgumentException
- if the display string is not of the right format.public int getRating()
public int getCoreValue()
public void setRating(int stars) throws InvalidArgumentException
stars
- The number of stars (1..5) as the new rating value.InvalidArgumentException
- if the number is not allowed by the definition of the field.public java.lang.String toString()
getDisplayString()
.toString
in class java.lang.Object
www.canto.com
Canto, the Canto logo, the Cumulus logo, and Cumulus are registered trademarks of Canto GmbH, registered in the U.S. and other countries.