Some widening/vararg logging that I've had lying around for ages

git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@861 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
Dave Hoover
2009-10-29 22:28:31 +00:00
parent faa3315d7d
commit a46c4bbb00
3 changed files with 52 additions and 67 deletions
@@ -30,11 +30,9 @@ import com.samskivert.util.StringUtil;
import com.threerings.media.sprite.Sprite; import com.threerings.media.sprite.Sprite;
/** /**
* The character component represents a single component that can be * The character component represents a single component that can be composited with other
* composited with other character components to generate an image * character components to generate an image representing a complete character displayable in any
* representing a complete character displayable in any of the eight * of the eight compass directions as detailed in the {@link Sprite} class direction constants.
* compass directions as detailed in the {@link Sprite} class direction
* constants.
*/ */
public class CharacterComponent implements Serializable public class CharacterComponent implements Serializable
{ {
@@ -48,11 +46,10 @@ public class CharacterComponent implements Serializable
public ComponentClass componentClass; public ComponentClass componentClass;
/** /**
* Constructs a character component with the specified id of the * Constructs a character component with the specified id of the specified class.
* specified class.
*/ */
public CharacterComponent (int componentId, String name, public CharacterComponent (
ComponentClass compClass, FrameProvider fprov) int componentId, String name, ComponentClass compClass, FrameProvider fprov)
{ {
this.componentId = componentId; this.componentId = componentId;
this.name = name; this.name = name;
@@ -60,7 +57,6 @@ public class CharacterComponent implements Serializable
_frameProvider = fprov; _frameProvider = fprov;
} }
/** /**
* Returns the render priority appropriate for this component at the specified action and * Returns the render priority appropriate for this component at the specified action and
* orientation. * orientation.
@@ -71,11 +67,11 @@ public class CharacterComponent implements Serializable
} }
/** /**
* Returns the image frames for the specified action animation or null if * Returns the image frames for the specified action animation or null if no animation for the
* no animation for the specified action is available for this component. * specified action is available for this component.
* *
* @param type null for the normal action frames or one of the custom * @param type null for the normal action frames or one of the custom action sub-types:
* action sub-types: {@link StandardActions#SHADOW_TYPE}, etc. * {@link StandardActions#SHADOW_TYPE}, etc.
*/ */
public ActionFrames getFrames (String action, String type) public ActionFrames getFrames (String action, String type)
{ {
@@ -83,11 +79,11 @@ public class CharacterComponent implements Serializable
} }
/** /**
* Returns the path to the image frames for the specified action animation or null if * Returns the path to the image frames for the specified action animation or null if no
* no animation for the specified action is available for this component. * animation for the specified action is available for this component.
* *
* @param type null for the normal action frames or one of the custom * @param type null for the normal action frames or one of the custom action sub-types:
* action sub-types: {@link StandardActions#SHADOW_TYPE}, etc. * {@link StandardActions#SHADOW_TYPE}, etc.
* *
* @param existentPaths the set of all paths for which there are valid frames. * @param existentPaths the set of all paths for which there are valid frames.
*/ */
@@ -24,48 +24,44 @@ package com.threerings.cast;
import java.util.Iterator; import java.util.Iterator;
/** /**
* Makes available a collection of character components and associated * Makes available a collection of character components and associated metadata. Character
* metadata. Character components are animated sequences that can be * components are animated sequences that can be composited together to create a complete
* composited together to create a complete character visualization * character visualization (imagine interchanging pairs of boots, torsos, hats, etc.).
* (imagine interchanging pairs of boots, torsos, hats, etc.).
*/ */
public interface ComponentRepository public interface ComponentRepository
{ {
/** /**
* Returns the {@link CharacterComponent} object for the given * Returns the {@link CharacterComponent} object for the given component identifier.
* component identifier.
*/ */
public CharacterComponent getComponent (int componentId) public CharacterComponent getComponent (int componentId)
throws NoSuchComponentException; throws NoSuchComponentException;
/** /**
* Returns the {@link CharacterComponent} object with the given * Returns the {@link CharacterComponent} object with the given component class and name.
* component class and name.
*/ */
public CharacterComponent getComponent (String className, String compName) public CharacterComponent getComponent (String className, String compName)
throws NoSuchComponentException; throws NoSuchComponentException;
/** /**
* Returns the {@link ComponentClass} with the specified name or null * Returns the {@link ComponentClass} with the specified name or null if none exists with that
* if none exists with that name. * name.
*/ */
public ComponentClass getComponentClass (String className); public ComponentClass getComponentClass (String className);
/** /**
* Iterates over the {@link ComponentClass} instances representing all * Iterates over the {@link ComponentClass} instances representing all available character
* available character component classes. * component classes.
*/ */
public Iterator<ComponentClass> enumerateComponentClasses (); public Iterator<ComponentClass> enumerateComponentClasses ();
/** /**
* Iterates over the {@link ActionSequence} instances representing * Iterates over the {@link ActionSequence} instances representing every available action
* every available action sequence. * sequence.
*/ */
public Iterator<ActionSequence> enumerateActionSequences (); public Iterator<ActionSequence> enumerateActionSequences ();
/** /**
* Iterates over the component ids of all components in the specified * Iterates over the component ids of all components in the specified class.
* class.
*/ */
public Iterator<Integer> enumerateComponentIds (ComponentClass compClass); public Iterator<Integer> enumerateComponentIds (ComponentClass compClass);
} }
@@ -47,14 +47,14 @@ import com.threerings.resource.ResourceManager;
import static com.threerings.media.Log.log; import static com.threerings.media.Log.log;
/** /**
* A repository of image recoloration information. It was called the * A repository of image recoloration information. It was called the recolor repository but the
* recolor repository but the re-s cancelled one another out. * re-s cancelled one another out.
*/ */
public class ColorPository implements Serializable public class ColorPository implements Serializable
{ {
/** /**
* Used to store information on a class of colors. These are public to * Used to store information on a class of colors. These are public to simplify the XML
* simplify the XML parsing process, so pay them no mind. * parsing process, so pay them no mind.
*/ */
public static class ClassRecord implements Serializable public static class ClassRecord implements Serializable
{ {
@@ -87,8 +87,8 @@ public class ColorPository implements Serializable
{ {
// validate the color id // validate the color id
if (record.colorId > 255) { if (record.colorId > 255) {
log.warning("Refusing to add color record; colorId > 255 " + log.warning("Refusing to add color record; colorId > 255",
"[class=" + this + ", record=" + record + "]."); "class", this, "record", record);
} else { } else {
record.cclass = this; record.cclass = this;
colors.put(record.colorId, record); colors.put(record.colorId, record);
@@ -96,14 +96,12 @@ public class ColorPository implements Serializable
} }
/** /**
* Translants a color identified in string form into the id that * Translates a color identified in string form into the id that should be used to look up
* should be used to look up its information. Throws an * its information. Throws an exception if no color could be found that associates with
* exception if no color could be found that associates with
* that name. * that name.
* *
* FIXME: This lookup could be sped up a lot with some cached * FIXME: This lookup could be sped up a lot with some cached data tables if it looked
* data tables if it looked like this function would get called * like this function would get called in time critical situations.
* in time critical situations.
*/ */
public int getColorId (String name) public int getColorId (String name)
throws ParseException throws ParseException
@@ -129,8 +127,7 @@ public class ColorPository implements Serializable
throw new ParseException("No color named '" + name + "'", 0); throw new ParseException("No color named '" + name + "'", 0);
} }
/** Returns a random starting id from the entries in this /** Returns a random starting id from the entries in this class. */
* class. */
public ColorRecord randomStartingColor () public ColorRecord randomStartingColor ()
{ {
// figure out our starter ids if we haven't already // figure out our starter ids if we haven't already
@@ -296,9 +293,8 @@ public class ColorPository implements Serializable
} }
/** /**
* Returns true if the specified color is legal for use at character * Returns true if the specified color is legal for use at character creation time. false is
* creation time. false is always returned for non-existent colors or * always returned for non-existent colors or classes.
* classes.
*/ */
public boolean isLegalStartColor (int classId, int colorId) public boolean isLegalStartColor (int classId, int colorId)
{ {
@@ -359,7 +355,7 @@ public class ColorPository implements Serializable
try { try {
colorId = crec.getColorId(colorName); colorId = crec.getColorId(colorName);
} catch (ParseException pe) { } catch (ParseException pe) {
log.info("Error getting colorization by name. [error=" + pe + "]"); log.info("Error getting colorization by name", "error", pe);
return null; return null;
} }
@@ -372,8 +368,7 @@ public class ColorPository implements Serializable
} }
/** /**
* Loads up a colorization class by name and logs a warning if it * Loads up a colorization class by name and logs a warning if it doesn't exist.
* doesn't exist.
*/ */
public ClassRecord getClassRecord (String className) public ClassRecord getClassRecord (String className)
{ {
@@ -384,7 +379,7 @@ public class ColorPository implements Serializable
return crec; return crec;
} }
} }
log.warning("No such color class [class=" + className + "].", new Exception()); log.warning("No such color class", "class", className, new Exception());
return null; return null;
} }
@@ -398,8 +393,8 @@ public class ColorPository implements Serializable
// if they request color class zero, we assume they're just // if they request color class zero, we assume they're just
// decoding a blank colorprint, otherwise we complain // decoding a blank colorprint, otherwise we complain
if (classId != 0) { if (classId != 0) {
log.warning("Requested unknown color class [classId=" + classId + log.warning("Requested unknown color class",
", colorId=" + colorId + "].", new Exception()); "classId", classId, "colorId", colorId, new Exception());
} }
return null; return null;
} }
@@ -413,8 +408,8 @@ public class ColorPository implements Serializable
{ {
ClassRecord record = getClassRecord(className); ClassRecord record = getClassRecord(className);
if (record == null) { if (record == null) {
log.warning("Requested unknown color class [className=" + className + log.warning("Requested unknown color class",
", colorName=" + colorName + "].", new Exception()); "className", className, "colorName", colorName, new Exception());
return null; return null;
} }
@@ -422,7 +417,7 @@ public class ColorPository implements Serializable
try { try {
colorId = record.getColorId(colorName); colorId = record.getColorId(colorName);
} catch (ParseException pe) { } catch (ParseException pe) {
log.info("Error getting color record by name. [error=" + pe + "]"); log.info("Error getting color record by name", "error", pe);
return null; return null;
} }
@@ -430,8 +425,8 @@ public class ColorPository implements Serializable
} }
/** /**
* Adds a fully configured color class record to the pository. This is * Adds a fully configured color class record to the pository. This is only called by the XML
* only called by the XML parsing code, so pay it no mind. * parsing code, so pay it no mind.
*/ */
public void addClass (ClassRecord record) public void addClass (ClassRecord record)
{ {
@@ -452,8 +447,7 @@ public class ColorPository implements Serializable
try { try {
return loadColorPository(rmgr.getResource(CONFIG_PATH)); return loadColorPository(rmgr.getResource(CONFIG_PATH));
} catch (IOException ioe) { } catch (IOException ioe) {
log.warning("Failure loading color pository [path=" + CONFIG_PATH + log.warning("Failure loading color pository", "path", CONFIG_PATH, "error", ioe);
", error=" + ioe + "].");
return new ColorPository(); return new ColorPository();
} }
} }
@@ -467,7 +461,7 @@ public class ColorPository implements Serializable
try { try {
return (ColorPository)CompiledConfig.loadConfig(source); return (ColorPository)CompiledConfig.loadConfig(source);
} catch (IOException ioe) { } catch (IOException ioe) {
log.warning("Failure loading color pository: " + ioe + "."); log.warning("Failure loading color pository", "ioe", ioe);
return new ColorPository(); return new ColorPository();
} }
} }
@@ -481,8 +475,7 @@ public class ColorPository implements Serializable
try { try {
CompiledConfig.saveConfig(path, posit); CompiledConfig.saveConfig(path, posit);
} catch (IOException ioe) { } catch (IOException ioe) {
log.warning("Failure saving color pository " + log.warning("Failure saving color pository", "path", path, "error", ioe);
"[path=" + path + ", error=" + ioe + "].");
} }
} }