| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
package org.apache.commons.compress.harmony.pack200; |
| 20 |
|
| 21 |
import java.beans.PropertyChangeListener; |
| 22 |
import java.beans.PropertyChangeSupport; |
| 23 |
import java.io.IOException; |
| 24 |
import java.util.SortedMap; |
| 25 |
import java.util.TreeMap; |
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
public abstract class Pack200Adapter { |
| 31 |
|
| 32 |
protected static final int DEFAULT_BUFFER_SIZE = 8192; |
| 33 |
|
| 34 |
private final PropertyChangeSupport support = new PropertyChangeSupport(this); |
| 35 |
|
| 36 |
private final SortedMap<String, String> properties = new TreeMap<>(); |
| 37 |
|
| 38 |
public void addPropertyChangeListener(final PropertyChangeListener listener) { |
| 39 |
support.addPropertyChangeListener(listener); |
| 40 |
} |
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
protected void completed(final double value) throws IOException { |
| 49 |
firePropertyChange("pack.progress", null, String.valueOf((int) (100 * value))); |
| 50 |
} |
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
protected void firePropertyChange(final String propertyName, final Object oldValue, final Object newValue) throws IOException { |
| 61 |
support.firePropertyChange(propertyName, oldValue, newValue); |
| 62 |
} |
| 63 |
|
| 64 |
public SortedMap<String, String> properties() { |
| 65 |
return properties; |
| 66 |
} |
| 67 |
|
| 68 |
public void removePropertyChangeListener(final PropertyChangeListener listener) { |
| 69 |
support.removePropertyChangeListener(listener); |
| 70 |
} |
| 71 |
} |