1 package org.apidesign.javamonitorflaws;
3 import org.apidesign.javamonitorflaws.Cache;
4 import java.beans.PropertyChangeListener;
5 import java.beans.PropertyChangeSupport;
9 * @author Jaroslav Tulach <jtulach@netbeans.org>
11 public class MultiplyCache extends Cache<String,Integer> {
12 private PropertyChangeSupport pcs;
14 public static final String PROP_MULTIPLY = "multiply";
16 public synchronized int getMultiply() {
19 public synchronized void setMultiply(int multiply) {
20 int oldMultiply = this.multiply;
21 this.multiply = multiply;
22 pcs.firePropertyChange(PROP_MULTIPLY, oldMultiply, multiply);
25 public synchronized void addPropertyChangeListener(PropertyChangeListener listener) {
27 pcs = new PropertyChangeSupport(this);
29 pcs.addPropertyChangeListener(listener);
31 public void removePropertyChangeListener(PropertyChangeListener listener) {
33 pcs.removePropertyChangeListener(listener);
38 protected Integer createItem(String f) {
39 return f.length() * getMultiply();