|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.hd.d.pg2k.svrCore.props.PropertiesBundleDiff
public class PropertiesBundleDiff
A diff/patch mechanism for a bundle of well-behaved simple String-->String Properties. These diffs can be used to send just changes/deltas over the wire for well-behaved bundles of closely-related pure-String Properties, eg of the form of i18n ResourceBundle inputs.
This class itself is immutable and Serialisable, and designed to be efficient on the wire.
This uses PropertiesDiff to hold each Properties instance immutably/efficiently.
| Field Summary | |
|---|---|
private int |
_hash
Cached hash value; initially zero. |
private java.util.SortedSet<java.lang.String> |
deletedNames
The immutable in-order set of Properties sets entirely removed; never null. |
private static java.util.Map<java.lang.String,java.util.Properties> |
EMPTY_BUNDLE
Private empty Properties map; never changed, never null. |
static PropertiesBundleDiff |
EMPTY_DIFF
Immutable empty diff. |
private static java.util.Properties |
EMPTY_PROPERTIES
Private empty Properties map; never changed, never null. |
private java.util.SortedMap<java.lang.String,PropertiesDiff> |
newValues
The immutable in-order map from items/names to the new/changed Properties sets; never null. |
private static long |
serialVersionUID
Serial UID. |
int |
sizeAfter
The output bundle count as a sanity-check; guaranteed non-negative. |
int |
sizeBefore
The input bundle count as a sanity-check; guaranteed non-negative. |
| Constructor Summary | |
|---|---|
PropertiesBundleDiff()
Make new empty diff instance. |
|
PropertiesBundleDiff(int sizeBefore,
int sizeAfter,
java.util.Set<java.lang.String> deleted,
java.util.Map<java.lang.String,PropertiesDiff> added)
Create diff instance. |
|
| Method Summary | |
|---|---|
private static java.util.Set<Tuple.Pair<java.lang.String,java.util.Properties>> |
_computeChangeValues(java.util.Map<java.lang.String,java.util.Properties> pb)
Create "change" values from a Properties bundle; never null. |
static java.util.Map<java.lang.String,java.util.Properties> |
applyDiff(java.util.Map<java.lang.String,java.util.Properties> bp1,
PropertiesBundleDiff diff)
Applies diff to an extant Properties instance to generate a new AEP instance; never null. |
static PropertiesBundleDiff |
createAsStandAloneDiff(java.util.Map<java.lang.String,java.util.Properties> p1)
Create diff against empty Properties. |
static PropertiesBundleDiff |
createDiff(java.util.Map<java.lang.String,java.util.Properties> p1,
java.util.Map<java.lang.String,java.util.Properties> p2,
boolean force,
boolean intern)
Create diff between two Properties instances. |
static java.util.Map<java.lang.String,java.util.Properties> |
createFromStandAloneDiff(PropertiesBundleDiff pd)
Create from diff against empty Properties. |
boolean |
equals(java.lang.Object obj)
Equal iff all fields are identical. |
java.util.SortedMap<java.lang.String,PropertiesDiff> |
getNewValues()
Get newValues; never null. |
int |
hashCode()
Hash code depends on all deleted/changed elements; guaranteed zero for an empty diff, non-zero otherwise. |
boolean |
isEmpty()
Returns true iff the diff is "empty", ie no deletions nor additions/changes. |
static Tuple.Pair<java.util.Map<java.lang.String,java.util.Properties>,java.lang.Long> |
loadBundle(java.io.File dir,
java.lang.String basename)
Load a complete bundle of properties files with timestamp in one go; never null. |
private void |
readObject(java.io.ObjectInputStream ois)
Deserialise. |
protected java.lang.Object |
readResolve()
Deserialise: discard duplicate empty values. |
java.lang.String |
toString()
Human-readable summary of state. |
void |
validateObject()
Checks that the object is internally consistent. |
private void |
writeObject(java.io.ObjectOutputStream oos)
Write out a less-redundant form of our internal information. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
private transient java.util.SortedSet<java.lang.String> deletedNames
private transient java.util.SortedMap<java.lang.String,PropertiesDiff> newValues
This field is NOT serialised directly.
public final int sizeBefore
public final int sizeAfter
public static final PropertiesBundleDiff EMPTY_DIFF
private static final java.util.Map<java.lang.String,java.util.Properties> EMPTY_BUNDLE
private static final java.util.Properties EMPTY_PROPERTIES
private transient int _hash
Since access is atomic, this need not be marked volatile.
Never set to zero once non-zero.
private static final long serialVersionUID
| Constructor Detail |
|---|
public PropertiesBundleDiff()
public PropertiesBundleDiff(int sizeBefore,
int sizeAfter,
java.util.Set<java.lang.String> deleted,
java.util.Map<java.lang.String,PropertiesDiff> added)
sizeBefore - size of input Properties; non-negativesizeAfter - size of output Properties; non-negativedeleted - named Properties sets present in input and not present in output; non-nulladded - new/changed named Properties sets in output; non-null| Method Detail |
|---|
public java.util.SortedMap<java.lang.String,PropertiesDiff> getNewValues()
private static java.util.Set<Tuple.Pair<java.lang.String,java.util.Properties>> _computeChangeValues(java.util.Map<java.lang.String,java.util.Properties> pb)
The first element in each Pair is the (non-null) Properties set name; the second element is the (non-null) Properties set.
pb - non-null pure String-->String properties setpublic static PropertiesBundleDiff createAsStandAloneDiff(java.util.Map<java.lang.String,java.util.Properties> p1)
Forces intern()ing of the keys and values.
public static java.util.Map<java.lang.String,java.util.Properties> createFromStandAloneDiff(PropertiesBundleDiff pd)
throws AllExhibitPropertiesDelta.DiffException
AllExhibitPropertiesDelta.DiffException
public static PropertiesBundleDiff createDiff(java.util.Map<java.lang.String,java.util.Properties> p1,
java.util.Map<java.lang.String,java.util.Properties> p2,
boolean force,
boolean intern)
throws AllExhibitPropertiesDelta.DiffException
This will refuse to create a diff if it seems that the diff is unlikely to be useful, for example:
force - if true then force a diff to be produced
even if this routine would normally refuse to do so on efficiency groundsintern - if true than force intern()ing of all String values
AllExhibitPropertiesDelta.DiffException - if no diff can be generated
or is unlikely to be worthwhile to use
(eg would be more than a fraction of the size of the second AEP)
public static java.util.Map<java.lang.String,java.util.Properties> applyDiff(java.util.Map<java.lang.String,java.util.Properties> bp1,
PropertiesBundleDiff diff)
throws AllExhibitPropertiesDelta.DiffException
We do very basic/quick sanity checks on the before/after sizes to catch misapplication of a diff to a clearly-inappropriate Properties set.
AllExhibitPropertiesDelta.DiffException - if the diff cannot be appliedpublic boolean isEmpty()
public boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Object
private void writeObject(java.io.ObjectOutputStream oos)
throws java.io.IOException
java.io.IOException
private void readObject(java.io.ObjectInputStream ois)
throws java.io.IOException,
java.lang.ClassNotFoundException
java.io.IOException
java.lang.ClassNotFoundException
protected java.lang.Object readResolve()
throws java.io.ObjectStreamException
java.io.ObjectStreamException
public void validateObject()
throws java.io.InvalidObjectException
validateObject in interface java.io.ObjectInputValidationjava.io.InvalidObjectException
public static Tuple.Pair<java.util.Map<java.lang.String,java.util.Properties>,java.lang.Long> loadBundle(java.io.File dir,
java.lang.String basename)
throws java.io.IOException
We load all files of form basename*.properties
in the given directory.
dir - directory in which properties files are to be found; non-nullbasename - base name of properties files; non-null
java.io.FileNotFoundException - if directoiry not found or no bundle files found
java.io.IOException - in case of difficulty loading bundle files
|
DHD Multimedia Gallery V1.57.21 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||