Commit Graph

2292 Commits

Author SHA1 Message Date
ray 82bd4c7f1f More changes requested by the puzzle pirates.
- Added ArrayUtil.indexOf(int[], int).
This has never been added, in all our years, because it exists in IntListUtil.
IntLists are sort of different from int[]s, they're designed such that a 0
is an empty slot. But indexOf() works the same in either one, so let's make
ArrayUtil the definitive container of this code, and have IntListUtil use
ArrayUtil.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2344 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-07-23 23:39:45 +00:00
ray a60b9da150 Per Micah Weaver, added getWeightedIndex(int[], Random);
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2343 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-07-23 22:27:57 +00:00
ray e04f56ce4f Patch from Charlie Groves:
Convenience method to schedule a non-recurring Interval at a specific time.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2342 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-07-23 21:49:27 +00:00
ray e67458d55f Patch from Charlie Groves:
mdb's changes to GenUtil yesterday are causing it to choke when making type
  names for arrays and causing genservice to blow up in yohoho.  This checks
  for the subclass of Type for arrays and properly generates a name for it.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2341 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-07-23 18:59:11 +00:00
ray 05357b597d Genericized, from Charlie.
Also de-microsofted the line endings.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2340 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-07-23 18:13:52 +00:00
mdb b5069d97b3 Dramatically simplified name simplification and in the process fixed the
handling of generic type arguments.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2339 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-07-22 13:47:20 +00:00
zell b619e1da06 Handle SEQUENCE strategies, which are not yet implemented. This'll fix David Hoover's super-strict compilation urges, besides being a generally good idea.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2338 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-07-21 19:36:47 +00:00
ray 30ae1be3c8 Patch from Charlie Groves:
- Makes the button arg on GroupLayout.makeButtonBox a vararg so multiple
  buttons can be passed in at creation time.  It also adds a version using
  center justification as the default since that's what we do about 80%
  of the time in yohoho.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2337 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-07-18 18:30:04 +00:00
mdb 69930d1f76 Made DEFAULT_GAP public.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2336 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-07-18 17:51:04 +00:00
zell 744c4cf3d5 Always do a (potentially distributed) cache remove on invalidation, regardless of what's in the local cache. From Kyle Sampson.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2335 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-07-17 12:16:39 +00:00
ray fbce967233 git-svn-id: https://samskivert.googlecode.com/svn/trunk@2334 6335cc39-0255-0410-8fd6-9bcaacd3b74c 2008-07-15 00:03:10 +00:00
mdb e84f6ff16b Use the platforms line separator character(s).
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2333 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-07-08 10:27:55 +00:00
ray 6717fecd06 Patch from Charlie.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2332 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-07-03 18:10:55 +00:00
mdb 872cd06201 Properly case our userid query.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2331 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-07-03 07:15:49 +00:00
mjohnson e8e1e766e4 Use StringBuilder. Added a comment saying you most likely don't want to use wordWrap.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2330 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-06-25 21:27:01 +00:00
mjohnson 7ad4e741ad Added a simple wordWrap function to StringUtil
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2329 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-06-25 21:00:20 +00:00
andrzej 07e6a574db No need to obscure the fact that's a HashMap.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2328 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-06-17 00:46:02 +00:00
andrzej 7325f92676 Added an accessor for the underlying map.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2327 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-06-17 00:44:14 +00:00
ray 97ae34fcdd Name that thread.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2326 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-06-13 01:01:14 +00:00
ray 9e41658569 Formatting adjustments, courtesy of Dave Hoover.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2325 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-06-10 20:40:13 +00:00
ray 7202cbd84e There's an indexOf in ListUtil, but that cannot find a null in an array.
Here's one suggested by Dave.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2324 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-06-10 20:28:57 +00:00
mdb 4aedf764ec Let's name our factory methods along the same lines as the pattern established
by Maps and friends.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2323 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-06-07 10:24:59 +00:00
mdb f4ba889deb Added static constructor methods that make ObserverList construction
substantially less keystroke intensive.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2322 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-06-07 10:22:14 +00:00
mdb 95452a37b8 Make it possible to configure our log factory programmatically.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2321 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-06-06 21:54:38 +00:00
andrzej e0a4516eaf Accept "t" for true in parseBooleanArray, since that's what
toString(boolean[]) emits.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2320 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-06-05 02:43:33 +00:00
mdb 0769979b03 Added countEntrySet() so that you can do:
for (CountHashMap.Entry entry : cmap.countEntrySet()) {

which you can't do with the somewhat butchered current entrySet()
implementation. Indeed, I'm not sure quite how one is supposed to use that.
Perhaps in an iterator and cast the result to a CountHashMap.Entry?


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2319 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-05-30 14:03:56 +00:00
ray 4f0164737c Protection for applet mode.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2318 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-05-29 01:43:19 +00:00
mdb 1bc0fc3346 Updated Eclipse settings from Dave.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2317 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-05-29 01:05:59 +00:00
mdb b1f9ac47a3 If we tell log4j who we are, it will figure out the caller properly.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2316 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-05-28 18:33:07 +00:00
mdb 84597c3b99 Added log4j support to the log wrapper. It is enabled if the log4j
configuration system property is set (and a particular logger is not
specifically configured).


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2315 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-05-28 18:02:37 +00:00
mdb 301a695cd8 Accept our new logger as well as Java loggers.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2314 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-05-27 19:36:54 +00:00
mdb 9a5968fe08 Use new logging shim.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2313 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-05-27 18:40:39 +00:00
mdb 55dbf25930 Find java in the path.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2312 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-05-27 18:39:46 +00:00
mdb 4af8953a19 A simple log wrapper that allows samskivert itself and libraries that depend on
samskivert to use logging services without creating a dependency on a logging
implementation.

This is basically what JCL (Jakarta Commons Logging) does except they do
auto-detection based on what's in the classpath and we're only going to
auto-detect log4j and only use it if we see that a log4j configuration has been
provided via a system property (or maybe not at all, I'm not sure yet). The
point is avoid the major gripe about JCL which is that when you stick some
logging system's jar file into your classpath for some other dependency (or
it's there for unknown reasons like maybe your servlet container uses it), all
of a sudden your log output disappears or breaks.

I had an idea while doing this and couldn't resist slipping it in: all of the
logging methods take varargs additional parameters which are a set of key/value
pairs to append to the log message in our standard format with an optional
final exception to be logged as well.

So instead of:

  log.warning("Oh crap, the fibbleminscher has exploded [state=" + 15 + 
              ", monkeys=" + StringUtil.toString(_monkeys) + "].");

You do:

  log.warning("Oh crap, the fibbleminscher has exploded.", "state", 15,
              "monkeys", _monkeys);

The formatter automatically does the StringUtil.toString magic on the arguments
(and does it safely so that if toString throws an exception the log message
isn't lost). You can also throw an exception in the mix:

  log.warning("Oh crap, the fibbleminscher has exploded.", "state", 15,
              "monkeys", _monkeys, ioe);

Or supply one with no parameters:

  log.warning("Oh mammy!", ioe);

Or even just log an exception if you have nothing pithy to add:

  log.warning(ioe);

Some research shows that other people have started doing this in their logging
systems as well under the fancier name of parameterized logging. The big
benefit is that you can pass objects that are expensive to toString() and avoid
toString()ing them unless you're actually going to generate the log message.
In our case we also get the benefit of our standard formatting and less
cluttered code (begone lots of + ", ...=" + typing).

I'm going to be doing away with the old samskivert Log code and converting all
of our libraries (and projects) to use this new shim so that we can easily
switch to using log4j, which for other reasons we want to use instead of Java's
built-in logging.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2311 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-05-27 18:36:32 +00:00
mdb ec0069f802 Fixed typo.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2310 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-05-27 17:56:52 +00:00
ray 7adef99c05 Per Charlie's suggestion, throw an unchecked exception if schedule() is called
with fixedRate=false when a RunQueue has been specified.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2309 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-05-20 21:21:06 +00:00
ray 97684500b6 Added a note explaining why this may not actually work as Charlie wants it to
without some restructuring of his code.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2308 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-05-20 19:38:42 +00:00
ray c074f73bcb Patch from Charlie Groves to expose Timer's ability to schedule at a
fixed delay. We haven't needed this before now.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2307 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-05-20 19:34:23 +00:00
ray f37ba48cce git-svn-id: https://samskivert.googlecode.com/svn/trunk@2306 6335cc39-0255-0410-8fd6-9bcaacd3b74c 2008-05-19 18:32:58 +00:00
mdb c51b652abd Created a unit for when we just want to write something to the database and do
nothing with the results.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2305 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-05-18 11:11:28 +00:00
mdb 6ba1f81cbd Updated copyright year.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2304 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-05-18 11:04:35 +00:00
ray 328fae15e6 git-svn-id: https://samskivert.googlecode.com/svn/trunk@2303 6335cc39-0255-0410-8fd6-9bcaacd3b74c 2008-05-16 03:20:27 +00:00
ray fbfd736f25 We need parens so that operators are evaluated in the right order.
This adds extra params around a bunch of things. I'll let the gods of Depot
sort that out.

BTW: Arithmetic.Div is still totally broken. It somehow booches the prepared
statement. I tried changing the operator String to "//" and that sorta worked,
but then the next operator over was missing...
I'm working around this using Mul, but it'd be nice..


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2302 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-05-16 02:10:07 +00:00
mdb 8f7d134526 Don't build tests unless we have JUnit, don't build FileUtil unless we have
commons-io (I should probably move that into com.samskivert.io but there are
various dependers that I don't feel like breaking).


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2301 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-05-07 06:39:09 +00:00
ray 77378ac880 Added static compare() methods for all the primitive types,
except where Sun has already done it for us.
- We always return 1, 0, or -1.
- We guard against overflows for ints and longs.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2300 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-05-07 00:42:18 +00:00
ray 8b06f28a9e Formatting tweaks I had laying around.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2299 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-04-30 21:06:38 +00:00
ray 104d861719 Changed the TimerTask being used to be a static inner class with an
explicit reference back to the Interval so that we can clear that
reference when the Interval is cancelled. The reason for this is that
TimerTasks sit on the Timer's internal queue until their scheduled
execution time, even if they've been cancelled. We want to allow
any references that the Interval has to be gc-able after cancellation.

Note two things:
- Once an interval is cancelled, calls to getInterval() or toString()
on the RunBuddy are invalid, even if the calls are happening inside
expired(). This probably will only affect you if you cancel() the interval
in the expired() method, but maybe I should prevent badness here anyway...
- Interval has potential for a small slip that would prevent gc. If
multiple threads are scheduling and cancelling an interval simultaneously,
it's possible (since I avoid synchronizing anywhere) for a task to
be created that incorrectly thinks it should be alive. It will never
expire(), as once it tries to it will discover that it's invalid
and will cancel at that time, but in the meanwhile the task has been
holding onto a reference to the Interval. This would not be an error,
just a non-optimal memory situation, it would rarely occur, and it
probably can never occur in most of our code since we tend to use
a single thread for scheduling and cancelling Intervals.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2298 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-04-29 20:41:58 +00:00
mdb 0cf663e07b Added copyMergedOutput().
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2297 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-04-28 22:00:55 +00:00
mdb 099f6be796 git-svn-id: https://samskivert.googlecode.com/svn/trunk@2296 6335cc39-0255-0410-8fd6-9bcaacd3b74c 2008-04-25 18:32:44 +00:00
mdb 954715191a Pass -Dcom.samskivert.jdbc.depot.debug=true to have Depot log queries before
they are executed.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2295 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2008-04-23 23:29:07 +00:00