/** * Creates a new StringFieldValue with the given value. * * @param value the value to wrap. * @throws IllegalArgumentException if the string contains non-text characters as defined by * {@link Text#isTextCharacter(int)} */ public StringFieldValue(String value) { if (value == null) throw new IllegalArgumentException("Value cannot be null"); setValue(value); }
/** * Sets a new value for this StringFieldValue. NOTE that doing so will clear all span trees from this value, * since they most certainly will not make sense for a new string value. * * @param o the new String to assign to this. An argument of null is equal to calling clear(). * @throws IllegalArgumentException if the given argument is a string containing non-text characters as defined by * {@link Text#isTextCharacter(int)} */ @Override public void assign(Object o) { if (spanTrees != null) { spanTrees.clear(); spanTrees = null; } if (!checkAssign(o)) { return; } if (o instanceof StringFieldValue) { spanTrees=((StringFieldValue)o).spanTrees; } if (o instanceof String) { setValue((String) o); } else if (o instanceof StringFieldValue || o instanceof NumericFieldValue) { setValue(o.toString()); } else { throw new IllegalArgumentException("Class " + o.getClass() + " not applicable to an " + this.getClass() + " instance."); } }