* format.
*
* @return String representation of the value stored in the Property
- * @deprecated use the property value directly, or {@link #getStringValue()}
- * during migration period
+ * @deprecated use {@link #getValue()} instead and possibly toString on that
*/
@Deprecated
@Override
+ ".toString()");
}
- /**
- * Returns the value of the <code>Property</code> in human readable textual
- * format.
- *
- * @return String representation of the value stored in the Property
- * @since 7.0
- */
- public String getStringValue() {
- final Object value = getValue();
- if (value == null) {
- return null;
- }
- return value.toString();
- }
-
/* Events */
/**
*
* @return <code>String</code> representation of the value stored in the
* Property
- * @deprecated use the property value directly, or
- * {@link #getStringValue()} during migration period
+ * @deprecated use {@link #getValue()} instead and possibly toString on
+ * that
*/
@Deprecated
@Override
"Use Property.getValue() instead of IndexedContainerProperty.toString()");
}
- /**
- * Returns the value of the <code>Property</code> in human readable
- * textual format.
- *
- * @return String representation of the value stored in the Property
- * @since 7.0
- */
- public String getStringValue() {
- final Object value = getValue();
- if (value == null) {
- return null;
- }
- return value.toString();
- }
-
/**
* Calculates a integer hash-code for the Property that's unique inside
* the Item containing the Property. Two different Properties inside the
.removeListener(this);
}
readOnly = isReadOnly();
- prevValue = getStringValue();
+ prevValue = getValue();
}
dataSource = newDataSource;
if (isReadOnly() != readOnly) {
fireReadOnlyStatusChange();
}
- String newVal = getStringValue();
+ String newVal = getValue();
if ((prevValue == null && newVal != null)
|| (prevValue != null && !prevValue.equals(newVal))) {
fireValueChange();
* String given by format().
*/
public String getValue() {
- return getStringValue();
- }
-
- /**
- * Get the formatted value. For PropertyFormatter, this is identical with
- * {@link #getValue()}.
- *
- * @return If the datasource returns null, this is null. Otherwise this is
- * String given by format().
- */
- @Override
- public String getStringValue() {
T value = dataSource == null ? null : dataSource.getValue();
if (value == null) {
return null;
} else {
try {
dataSource.setValue(parse(newValue.toString()));
- if (!newValue.equals(getStringValue())) {
+ if (!newValue.equals(getValue())) {
fireValueChange();
}
} catch (Exception e) {
* Returns the value of the Property in human readable textual format.
*
* @see java.lang.Object#toString()
- * @deprecated get the string representation from the value, or use
- * getStringValue() during migration
+ * @deprecated get the string representation from the value
*/
@Deprecated
@Override
"Use ColumnProperty.getValue() instead of ColumnProperty.toString()");
}
- /**
- * Returns the (UI type) value of the field converted to a String using
- * toString().
- *
- * This method exists to help migration from the use of Property.toString()
- * to get the field value - for new applications, access getValue()
- * directly. This method may disappear in future Vaadin versions.
- *
- * @return string representation of the field value or null if the value is
- * null
- * @since 7.0
- */
- public String getStringValue() {
- final Object value = getValue();
- if (value == null) {
- return null;
- }
- return value.toString();
- }
-
public void setOwner(RowItem owner) {
if (owner == null) {
throw new IllegalArgumentException("Owner can not be set to null.");
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import java.util.logging.Logger;
import com.vaadin.Application;
import com.vaadin.data.Buffered;
/* Private members */
+ private static final Logger logger = Logger.getLogger(AbstractField.class
+ .getName());
+
/**
* Value of the abstract field.
*/
}
}
+ /**
+ * Gets the value from the data source. This is only here because of clarity
+ * in the code that handles both the data model value and the field value.
+ *
+ * @return The value of the property data source
+ */
private Object getDataSourceValue() {
return dataSource.getValue();
}
/**
- * Returns the value that is or should be displayed in the field. This is
- * always of type T.
- *
- * This method should return the converter data source value if there are no
- * buffered changes in the field.
+ * Returns the field value. This is always identical to {@link #getValue()}
+ * and only here because of clarity in the code that handles both the data
+ * model value and the field value.
*
* @return The value of the field
*/
/* Property interface implementation */
/**
- * Returns the value of the Property in human readable textual format.
+ * Returns the (field) value converted to a String using toString().
*
* @see java.lang.Object#toString()
- * @deprecated get the string representation from the data source, or use
- * getStringValue() during migration
+ * @deprecated Instead use {@link #getValue()} to get the value of the
+ * field, {@link #getConvertedValue()} to get the field value
+ * converted to the data model type or
+ * {@link #getPropertyDataSource()} .getValue() to get the value
+ * of the data source.
*/
@Deprecated
@Override
public String toString() {
- throw new UnsupportedOperationException(
- "Use Property.getValue() instead of " + getClass()
- + ".toString()");
- }
-
- /**
- * Returns the (UI type) value of the field converted to a String.
- *
- * This method exists to help migration from the use of Property.toString()
- * to get the field value. For new applications, it is often better to
- * access getValue() directly.
- *
- * @return string representation of the field value or null if the value is
- * null
- * @since 7.0
- */
- public String getStringValue() {
+ logger.warning("You are using AbstractField.toString() to get the value for a "
+ + getClass().getSimpleName()
+ + ". This is not recommended and will not be supported in future versions.");
final Object value = getFieldValue();
if (value == null) {
return null;
@Override
protected boolean isEmpty() {
- return super.isEmpty() || getStringValue().length() == 0;
+ return super.isEmpty() || getValue().length() == 0;
}
/**
dataSource.setValue(newValue);
}
- /**
- * @see com.vaadin.ui.AbstractField#toString()
- * @deprecated use the data source value instead of toString()
- */
- @Deprecated
- @Override
- public String toString() {
- throw new UnsupportedOperationException(
- "Use Property.getValue() instead of ProgressIndicator.toString()");
- }
-
/**
* @see com.vaadin.ui.AbstractField#getType()
*/
@Override
protected boolean isEmpty() {
- return super.isEmpty() || getStringValue().length() == 0;
+ return super.isEmpty() || getValue().length() == 0;
}
}
filterButton.addListener(new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
ic.removeAllContainerFilters();
- if (fooFilter.getStringValue().length() > 0) {
- ic.addContainerFilter("foo", fooFilter.getStringValue(), false,
+ if (fooFilter.getValue().length() > 0) {
+ ic.addContainerFilter("foo", fooFilter.getValue(), false,
false);
}
- if (barFilter.getStringValue().length() > 0) {
- ic.addContainerFilter("bar", barFilter.getStringValue(), true,
+ if (barFilter.getValue().length() > 0) {
+ ic.addContainerFilter("bar", barFilter.getValue(), true,
true);
}
count.setValue("Rows in table: " + ic.size());
date.addListener(new Property.ValueChangeListener() {
public void valueChange(ValueChangeEvent event) {
if (date.isValid()) {
- getMainWindow().showNotification(date.getStringValue());
+ getMainWindow()
+ .showNotification(date.getValue().toString());
}
}
tf.addListener(new Property.ValueChangeListener() {
public void valueChange(ValueChangeEvent event) {
main.addComponent(new Label(name + " send text:"
- + tf.getStringValue()));
+ + tf.getValue()));
}
});
for (int i = 0; i < 3; i++) {
height.addListener(new Property.ValueChangeListener() {
public void valueChange(ValueChangeEvent event) {
try {
- target.setHeight(height.getStringValue());
+ target.setHeight(height.getValue());
height.setComponentError(null);
updateLabel();
} catch (Exception e) {
width.addListener(new Property.ValueChangeListener() {
public void valueChange(ValueChangeEvent event) {
try {
- target.setWidth(width.getStringValue());
+ target.setWidth(width.getValue());
width.setComponentError(null);
updateLabel();
} catch (Exception e) {