Styley stylopolis.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5252 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2008-07-22 14:01:51 +00:00
parent 706b85a0e4
commit 5c4ab96880
26 changed files with 139 additions and 77 deletions
@@ -913,7 +913,7 @@ public class DObject
protected transient boolean _deathWish = false;
/** Maintains a mapping of sorted field arrays for each distributed object class. */
protected static HashMap<Class,Field[]> _ftable = new HashMap<Class,Field[]>();
protected static HashMap<Class, Field[]> _ftable = new HashMap<Class, Field[]>();
/** Used to sort and search {@link #_fields}. */
protected static final Comparator<Field> FIELD_COMP = new Comparator<Field>() {
@@ -28,7 +28,6 @@ import java.util.ConcurrentModificationException;
import java.util.Iterator;
import com.samskivert.util.ArrayUtil;
import com.samskivert.util.StringUtil;
import com.threerings.io.ObjectInputStream;
import com.threerings.io.ObjectOutputStream;
@@ -49,6 +48,8 @@ import static com.threerings.presents.Log.log;
* case of entry removal, only the key for the entry to be removed will be transmitted with the
* removal event to save network bandwidth. Lastly, the object returned by {@link Entry#getKey}
* must be a {@link Streamable} type.
*
* @param <E> the type of entry stored in this set.
*/
public class DSet<E extends DSet.Entry>
implements Iterable<E>, Streamable, Cloneable
@@ -197,10 +198,8 @@ public class DSet<E extends DSet.Entry>
public Iterator<E> iterator ()
{
// the crazy sanity checks
if (_size < 0 ||_size > _entries.length ||
(_size > 0 && _entries[_size-1] == null)) {
log.warning("DSet in a bad way [size=" + _size +
", entries=" + StringUtil.toString(_entries) + "].");
if (_size < 0 || _size > _entries.length || (_size > 0 && _entries[_size-1] == null)) {
log.warning("DSet in a bad way", "size", _size, "entries", _entries);
Thread.dumpStack();
}
@@ -221,9 +220,8 @@ public class DSet<E extends DSet.Entry>
throw new ConcurrentModificationException();
}
if (_ssize != _size) {
log.warning("Size changed during iteration [ssize=" + _ssize +
", nsize=" + _size +
", entsries=" + StringUtil.toString(_entries) + "].");
log.warning("Size changed during iteration", "ssize", _ssize, "nsize", _size,
"entries", _entries);
Thread.dumpStack();
}
}
@@ -460,6 +458,7 @@ public class DSet<E extends DSet.Entry>
}
}
/** Used to search for keys. */
protected static class KeyWrapper implements DSet.Entry
{
public KeyWrapper (Comparable key) {
@@ -44,7 +44,7 @@ public class DynamicListener
{
this(target, new MethodFinder(target.getClass()));
}
/**
* Creates a listener that dynamically dispatches events on the supplied
* target using the methods in finder.
@@ -140,5 +140,5 @@ public class DynamicListener
protected MethodFinder _finder;
/** A cache of already resolved methods. */
protected HashMap<String,Method> _mcache = new HashMap<String,Method>();
protected HashMap<String, Method> _mcache = new HashMap<String, Method>();
}
@@ -29,6 +29,9 @@ import com.samskivert.util.StringUtil;
* posted to the dobjmgr.
*
* @see DObjectManager#postEvent
*
* @param <T> the type of entry being handled by this event. This must match the type on the set
* that generated this event.
*/
public class EntryAddedEvent<T extends DSet.Entry> extends NamedEvent
{
@@ -29,6 +29,9 @@ import static com.threerings.presents.Log.log;
* posted to the dobjmgr.
*
* @see DObjectManager#postEvent
*
* @param <T> the type of entry being handled by this event. This must match the type on the set
* that generated this event.
*/
public class EntryRemovedEvent<T extends DSet.Entry> extends NamedEvent
{
@@ -32,6 +32,9 @@ import static com.threerings.presents.Log.log;
* constructed to request the update of an entry and posted to the dobjmgr.
*
* @see DObjectManager#postEvent
*
* @param <T> the type of entry being handled by this event. This must match the type on the set
* that generated this event.
*/
public class EntryUpdatedEvent<T extends DSet.Entry> extends NamedEvent
{
@@ -24,10 +24,13 @@ package com.threerings.presents.dobj;
/**
* Implements the methods in SetListener so that you don't have to implement the ones you don't
* want to.
*
*
* <p> <b>NOTE:</b> This adapter will receive <em>all</em> Entry events from a DObject it's
* listening to, so it should check that the event's name matches the field it's interested in
* before acting on the event.
*
* @param <T> the type of entry being handled by this listener. This must match the type on the set
* that generates the events.
*/
public class SetAdapter<T extends DSet.Entry> implements SetListener<T>
{
@@ -24,12 +24,15 @@ package com.threerings.presents.dobj;
/**
* Implemented by entities which wish to hear about changes that occur to set attributes of a
* particular distributed object.
*
*
* <p> <b>NOTE:</b> This listener will receive <em>all</em> Entry events from a DObject it's
* listening to, so it should check that the event's name matches the field it's interested in
* before acting on the event.
*
*
* @see DObject#addListener
*
* @param <T> the type of entry being handled by this listener. This must match the type on the set
* that generates the events.
*/
public interface SetListener<T extends DSet.Entry> extends ChangeListener
{
@@ -37,6 +37,8 @@ package com.threerings.presents.dobj;
* @see AttributeChangeListener
* @see SetListener
* @see OidListListener
*
* @param <T> the type object being subscribed to.
*/
public interface Subscriber<T extends DObject>
{