/** * Sets the current value for the restriction tag. If {@code value} is null or an empty string, * the restriction tag is removed. * * @param value the value of the restriction tag */ public void setRestrictionTagValue(String value) { if (value == null || value.trim().equals("")) { tagEditorModel.delete("restriction"); } else { TagModel tm = tagEditorModel.get("restriction"); if (tm != null) { tm.setValue(value); } else { tagEditorModel.prepend(new TagModel("restriction", value.trim().toLowerCase())); } } setChanged(); notifyObservers(); }
/** * Sets the current value of the tag "except". Removes the tag is {@code value} is null or * consists of white space only. * * @param value the new value for 'except' */ public void setExcept(ExceptValueModel value) { if (value == null || value.getValue().equals("")) { if (tagEditorModel.get("except") != null) { tagEditorModel.delete("except"); setChanged(); notifyObservers(); } return; } TagModel tag = tagEditorModel.get("except"); if (tag == null) { tagEditorModel.prepend(new TagModel("except", value.getValue())); setChanged(); notifyObservers(); } else { if (!tag.getValue().equals(value.getValue())) { tag.setValue(value.getValue().trim()); setChanged(); notifyObservers(); } } }
/** * Replies the current value of the tag "except", or the empty string if the tag doesn't exist. */ public ExceptValueModel getExcept() { TagModel tag = tagEditorModel.get("except"); if (tag == null) return new ExceptValueModel(""); return new ExceptValueModel(tag.getValue()); }