/** * Add a new filter. * * @param filter the filter to be added. */ public synchronized void addFilter(Filter filter) { if (isReference()) { throw noChildrenAllowed(); } filters.addElement(filter); filterHash = null; }
/** * Set the string used to id the end of a token. * * @param endOfToken The new Endtoken value. */ public void setEndToken(String endOfToken) { if (isReference()) { throw tooManyAttributes(); } if (endOfToken == null || endOfToken.isEmpty()) { throw new BuildException("endToken must not be empty"); } this.endOfToken = endOfToken; }
/** * Set the file containing the filters for this filterset. * * @param filtersFile sets the filter file from which to read filters * for this filter set. * @throws BuildException if there is an error. */ public void setFiltersfile(File filtersFile) throws BuildException { if (isReference()) { throw tooManyAttributes(); } filtersFiles.add(filtersFile); }
/** * Set the string used to id the beginning of a token. * * @param startOfToken The new Begintoken value. */ public void setBeginToken(String startOfToken) { if (isReference()) { throw tooManyAttributes(); } if (startOfToken == null || startOfToken.isEmpty()) { throw new BuildException("beginToken must not be empty"); } this.startOfToken = startOfToken; }
/** * Create a new FiltersFile. * * @return The filtersfile that was created. */ public FiltersFile createFiltersfile() { if (isReference()) { throw noChildrenAllowed(); } return new FiltersFile(); }
/** * Get the end token for this filterset. * * @return the filter set's end token for replacement delimiting. */ public String getEndToken() { if (isReference()) { return getRef().getEndToken(); } return endOfToken; }
/** * Adds the properties provided by the specified PropertySet to this filterset. * * @param propertySet the propertyset to be added to this propertyset */ public synchronized void addConfiguredPropertySet(PropertySet propertySet) { if (isReference()) { throw noChildrenAllowed(); } Properties p = propertySet.getProperties(); Set<Map.Entry<Object, Object>> entries = p.entrySet(); for (Map.Entry<Object, Object> entry : entries) { addFilter(new Filter(String.valueOf(entry.getKey()), String.valueOf(entry.getValue()))); } }
/** * Get the begin token for this filterset. * * @return the filter set's begin token for filtering. */ public String getBeginToken() { if (isReference()) { return getRef().getBeginToken(); } return startOfToken; }
/** * Add a Filterset to this filter set. * * @param filterSet the filterset to be added to this filterset */ public synchronized void addConfiguredFilterSet(FilterSet filterSet) { if (isReference()) { throw noChildrenAllowed(); } for (Filter filter : filterSet.getFilters()) { addFilter(filter); } }
/** * Add a new filter made from the given token and value. * * @param token The token for the new filter. * @param value The value for the new filter. */ public synchronized void addFilter(String token, String value) { if (isReference()) { throw noChildrenAllowed(); } addFilter(new Filter(token, value)); }
if (isReference()) { throw tooManyAttributes();
/** * Get the filters in the filter set. * * @return a Vector of Filter instances. */ protected synchronized Vector<Filter> getFilters() { if (isReference()) { return getRef().getFilters(); } dieOnCircularReference(); // silly hack to avoid stack overflow... if (!readingFiles) { readingFiles = true; for (File filtersFile : filtersFiles) { readFiltersFromFile(filtersFile); } filtersFiles.clear(); readingFiles = false; } return filters; }
/** * Clone the filterset. * * @return a deep clone of this filterset. * * @throws BuildException if the clone cannot be performed. */ @Override public synchronized Object clone() throws BuildException { if (isReference()) { return getRef().clone(); } try { FilterSet fs = (FilterSet) super.clone(); @SuppressWarnings("unchecked") Vector<Filter> clonedFilters = (Vector<Filter>) getFilters().clone(); fs.filters = clonedFilters; fs.setProject(getProject()); return fs; } catch (CloneNotSupportedException e) { throw new BuildException(e); } }
/** * Gets the filter hash of the FilterSet. * * @return The hash of the tokens and values for quick lookup. */ public synchronized Hashtable<String, String> getFilterHash() { if (isReference()) { return getRef().getFilterHash(); } dieOnCircularReference(); if (filterHash == null) { filterHash = new Hashtable<>(getFilters().size()); getFilters().forEach(filter -> filterHash.put(filter.getToken(), filter.getValue())); } return filterHash; }