/** * You should pass in a string, or a java.util.List of strings to set the value. * * @param value The value that should populate when imported. * * @throws IOException If there is an error setting the value. */ public void setValue(Object value) throws IOException { COSBase cos = null; if (value instanceof List) { cos = COSArrayList.convertStringListToCOSStringCOSArray((List<String>) value); } else if (value instanceof String) { cos = new COSString((String) value); } else if (value instanceof COSObjectable) { cos = ((COSObjectable) value).getCOSObject(); } else if (value != null) { throw new IOException("Error:Unknown type for field import" + value); } field.setItem(COSName.V, cos); }
/** * This will set the export values. * * @see #getExportValues() * @param values List containing all possible export values. Supplying null or an empty list will remove the Opt entry. */ public void setExportValues(List<String> values) { COSArray cosValues; if (values != null && !values.isEmpty()) { cosValues = COSArrayList.convertStringListToCOSStringCOSArray(values); getCOSObject().setItem(COSName.OPT, cosValues); } else { getCOSObject().removeItem(COSName.OPT); } }
/** * This will set the display values - the 'Opt' key. * * <p> * The Opt array specifies the list of options in the choice field either * as an array of text strings representing the display value * or as an array of a two-element array where the * first element is the export value and the second the display value. * </p> * <p> * To set both the export and the display value use {@link #setOptions(List, List)} * </p> * * @param displayValues List containing all possible options. */ public void setOptions(List<String> displayValues) { if (displayValues != null && !displayValues.isEmpty()) { if (isSort()) { Collections.sort(displayValues); } getCOSObject().setItem(COSName.OPT, COSArrayList.convertStringListToCOSStringCOSArray(displayValues)); } else { getCOSObject().removeItem(COSName.OPT); } }
/** * Sets the entry "V" to the given values. Requires {@link #isMultiSelect()} to be true. * * @param values the list of values * @throws IOException if the appearance couldn't be generated. */ public void setValue(List<String> values) throws IOException { if (values != null && !values.isEmpty()) { if (!isMultiSelect()) { throw new IllegalArgumentException("The list box does not allow multiple selections."); } if (!getOptions().containsAll(values)) { throw new IllegalArgumentException("The values are not contained in the selectable options."); } getCOSObject().setItem(COSName.V, COSArrayList.convertStringListToCOSStringCOSArray(values)); updateSelectedOptionsIndex(values); } else { getCOSObject().removeItem(COSName.V); getCOSObject().removeItem(COSName.I); } applyChange(); }
/** * You should pass in a string, or a java.util.List of strings to set the value. * * @param value The value that should populate when imported. * * @throws IOException If there is an error setting the value. */ public void setValue(Object value) throws IOException { COSBase cos = null; if (value instanceof List) { cos = COSArrayList.convertStringListToCOSStringCOSArray((List<String>) value); } else if (value instanceof String) { cos = new COSString((String) value); } else if (value instanceof COSObjectable) { cos = ((COSObjectable) value).getCOSObject(); } else if (value != null) { throw new IOException("Error:Unknown type for field import" + value); } field.setItem(COSName.V, cos); }
/** * This will set the export values. * * @see #getExportValues() * @param values List containing all possible export values. Supplying null or an empty list will remove the Opt entry. */ public void setExportValues(List<String> values) { COSArray cosValues; if (values != null && !values.isEmpty()) { cosValues = COSArrayList.convertStringListToCOSStringCOSArray(values); getCOSObject().setItem(COSName.OPT, cosValues); } else { getCOSObject().removeItem(COSName.OPT); } }
/** * You should pass in a string, or a java.util.List of strings to set the value. * * @param value The value that should populate when imported. * * @throws IOException If there is an error setting the value. */ public void setValue(Object value) throws IOException { COSBase cos = null; if (value instanceof List) { cos = COSArrayList.convertStringListToCOSStringCOSArray((List<String>) value); } else if (value instanceof String) { cos = new COSString((String) value); } else if (value instanceof COSObjectable) { cos = ((COSObjectable) value).getCOSObject(); } else if (value != null) { throw new IOException("Error:Unknown type for field import" + value); } field.setItem(COSName.V, cos); }
/** * This will set the export values. * * @see #getExportValues() * @param values List containing all possible export values. Supplying null or an empty list will remove the Opt entry. */ public void setExportValues(List<String> values) { COSArray cosValues; if (values != null && !values.isEmpty()) { cosValues = COSArrayList.convertStringListToCOSStringCOSArray(values); getCOSObject().setItem(COSName.OPT, cosValues); } else { getCOSObject().removeItem(COSName.OPT); } }
/** * This will set the display values - the 'Opt' key. * * <p> * The Opt array specifies the list of options in the choice field either * as an array of text strings representing the display value * or as an array of a two-element array where the * first element is the export value and the second the display value. * </p> * <p> * To set both the export and the display value use {@link #setOptions(List, List)} * </p> * * @param displayValues List containing all possible options. */ public void setOptions(List<String> displayValues) { if (displayValues != null && !displayValues.isEmpty()) { if (isSort()) { Collections.sort(displayValues); } getCOSObject().setItem(COSName.OPT, COSArrayList.convertStringListToCOSStringCOSArray(displayValues)); } else { getCOSObject().removeItem(COSName.OPT); } }
/** * This will set the display values - the 'Opt' key. * * <p> * The Opt array specifies the list of options in the choice field either * as an array of text strings representing the display value * or as an array of a two-element array where the * first element is the export value and the second the display value. * </p> * <p> * To set both the export and the display value use {@link #setOptions(List, List)} * </p> * * @param displayValues List containing all possible options. */ public void setOptions(List<String> displayValues) { if (displayValues != null && !displayValues.isEmpty()) { if (isSort()) { Collections.sort(displayValues); } getCOSObject().setItem(COSName.OPT, COSArrayList.convertStringListToCOSStringCOSArray(displayValues)); } else { getCOSObject().removeItem(COSName.OPT); } }
/** * Sets the entry "V" to the given values. Requires {@link #isMultiSelect()} to be true. * * @param values the list of values * @throws IOException if the appearance couldn't be generated. */ public void setValue(List<String> values) throws IOException { if (values != null && !values.isEmpty()) { if (!isMultiSelect()) { throw new IllegalArgumentException("The list box does not allow multiple selections."); } if (!getOptions().containsAll(values)) { throw new IllegalArgumentException("The values are not contained in the selectable options."); } getCOSObject().setItem(COSName.V, COSArrayList.convertStringListToCOSStringCOSArray(values)); updateSelectedOptionsIndex(values); } else { getCOSObject().removeItem(COSName.V); getCOSObject().removeItem(COSName.I); } applyChange(); }
/** * Sets the entry "V" to the given values. Requires {@link #isMultiSelect()} to be true. * * @param values the list of values * @throws IOException if the appearance couldn't be generated. */ public void setValue(List<String> values) throws IOException { if (values != null && !values.isEmpty()) { if (!isMultiSelect()) { throw new IllegalArgumentException("The list box does not allow multiple selections."); } if (!getOptions().containsAll(values)) { throw new IllegalArgumentException("The values are not contained in the selectable options."); } getCOSObject().setItem(COSName.V, COSArrayList.convertStringListToCOSStringCOSArray(values)); updateSelectedOptionsIndex(values); } else { getCOSObject().removeItem(COSName.V); getCOSObject().removeItem(COSName.I); } applyChange(); }