Commit Graph

2840 Commits

Author SHA1 Message Date
ray.j.greenwell 485e5e160d getNormal() from Mark Johnson.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2913 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2010-10-12 01:20:26 +00:00
ray.j.greenwell 4ac0865946 Some javadoc cleanup.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2912 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2010-10-06 16:32:02 +00:00
ray.j.greenwell 068aac8e27 A more localized application of @SuppressWarnings is desireable.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2911 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2010-10-04 17:13:31 +00:00
ray.j.greenwell 0f7fd4a914 Revert the meat of r2908.
Maybe mdb is using a newer compiler that is behaving correctly,
but my 1.6 freaks out without these.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2910 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2010-10-01 23:15:03 +00:00
ray.j.greenwell f49e205f68 Make this inner class protected, as we're fans of that access level.
Use at your own risk!


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2909 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2010-10-01 23:08:03 +00:00
karma@deadmoose.com 12906728e5 That's already a T, so we don't need to cast it.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2908 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2010-10-01 22:44:46 +00:00
karma@deadmoose.com bf9fd231e0 Flag @Overrides & suppress warnings about those pad members.
I know it's changing code copy & pasted from elsewhere, but 
warnings aren't fun.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2907 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2010-10-01 22:43:46 +00:00
samskivert 808f05322f Actually, let's just pass the level index down to the logger implementation (as
Ray suggested). It's less code and skips the casts entirely.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2906 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2010-10-01 22:13:48 +00:00
samskivert b33c3fcbba We don't want to expose the type parameter just used to pass log level
constants up from the logger impl and back down, so we'll just use Object and
do the casting manually.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2905 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2010-10-01 22:10:14 +00:00
ray.j.greenwell 45b4cb516f Added @ReplaceBy annotation. (The wimpy man's @Deprecated)
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2904 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2010-10-01 00:23:51 +00:00
ray.j.greenwell c917825410 Provide access to Randoms that use a faster thread-local Random.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2903 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2010-10-01 00:14:39 +00:00
ray.j.greenwell e398039478 Javadoc and header.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2902 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2010-09-30 23:15:59 +00:00
ray.j.greenwell cfa7c9c79b A new replacement for RandomUtil.
- Instead of duplicating every method twice, once allowing you to specify
  your own Random object, there is a static thread-safe sharable instance
  that anyone can use, and a factory method to create your own instance
  with a supplied Random.

- The goofy methods for picking an element from a collection but skipping
  a particular value, or picking from an iterator but providing a count,
  are gone.

- Instead there are two methods: pick and pluck, for picking an element
  or picking and removing an element. For Iterator, only pick is available.
  Optimized code paths are provided for Lists and Collections, but the API
  is kept simple.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2901 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2010-09-30 22:12:56 +00:00
samskivert e88c687229 Import pruning.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2900 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2010-09-30 21:39:56 +00:00
samskivert 1f2a1396ee Ray points out that addAll() and putAll() were already added to CollectionUtil.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2899 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2010-09-30 21:39:31 +00:00
samskivert e8b633abaf Some tests, just for kicks.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2898 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2010-09-30 21:35:55 +00:00
samskivert 8f781ea4cf Oops, missed a spot.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2897 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2010-09-30 21:26:52 +00:00
samskivert 510d31b138 Let's go ahead and add general fold and reduce even though I've held off on
adding a function type to samskivert because everyone and their mother has a
function type. This is hopefully innocuous enough and allows you to obtain
generality at the expense of verbosity:

  Folds.foldLeft(new Folds.R<Integer>() {
    public Integer apply (Integer zero, Integer elem) {
      return Math.max(zero, elem);
    }
  }, 0, values);

  Folds.foldLeft(new Folds.R<String>() {
    public String apply (String zero, String elem) {
      return zero + elem;
    }
  }, "", strings);

Maybe by Java 8 or 9 we'll have closures and this can become:

  Folds.foldLeft((Integer b, Integer a) => Math.max(b, a))
  Folds.foldLeft((String b, String a) => b + a)

or maybe:

  Folds.foldLeft(#(Integer b, Integer a) { return Math.max(b, a); })
  Folds.foldLeft(#(String b, String a) { return b + a; })

who knows where the syntax bike shed arguments will end up. Of course, that'll
probably hit the shelves around 2015 or so at the rate Oracle seems to be
proceeding.

If you really want to get jiggy with the functional programming, you can check
out Functional Java, which goes the whole nine yards, but sort of ignores Java's
standard collections in the process which kind of sucks:

  http://functionaljava.org/


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2896 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2010-09-30 21:26:26 +00:00
samskivert eeed7f2d2e More functional utilities from Mr Greenwell (with some name tweaks by MDB). He
so wants to be using Scala. For example, in Java:

 Folds.sum(0, values)

where values must implement Iterable and all you get is sum. In Scala:

 scala> Array(1, 2, 3).getClass // a real array
 res1: java.lang.Class[_] = class [I

 scala> Array(1, 2, 3).sum     
 res2: Int = 6

 scala> Vector(1, 2, 3).sum // more like ArrayList
 res3: Int = 6

 scala> Map(1 -> 2, 3 -> 4).keysIterator.sum // even works on Iterator
 res4: Int = 4

and you can do arbitrary folds just as easily:

 scala> Array(1, 2, 3).reduceLeft(math.max)
 res5: Int = 3

 scala> Array(2, 3, 4).reduceLeft(_*_)                 
 res6: Int = 24

Want to specify the type of the result? Can do:

 scala> Array(1, 2, 3).foldLeft(0L)(_+_)
 res7: Long = 6

Have a list of maps you need to merge? No problem:

 scala> List(Map(1 -> 2), Map(2 -> 3), Map(3 -> 4)).reduceLeft(_++_)
 res8: scala.collection.immutable.Map[Int,Int] = Map((1,2), (2,3), (3,4))

Functional programming truly does start with fun!


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2895 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2010-09-30 21:02:37 +00:00
samskivert 4c622ea5c8 (From Mr Greenwell) Reduction in size of Logger implementations via some
abstraction, and inlining of LogBuilder code into doLog() so that odd trailing
log arguments can be included without borking our ability to also include a
Throwable as the final argument.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2894 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2010-09-30 20:31:41 +00:00
ray.j.greenwell f12cf8a04e - Append chars when possible, and avoid any String concatination.
- Made arrayStr static, soften the Exception thrown.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2893 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2010-09-21 23:00:07 +00:00
ray.j.greenwell 48951845b3 Oh crap.
The Loggers don't strip out the Exception if it's the last
element, so they actually *depend* on this ignoring the last odd element.
Revert my last change until I figure some reasonable compromise out.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2892 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2010-09-21 20:25:35 +00:00
ray.j.greenwell 5cbde1b456 Created an addAll() that folds a supplied Iterable of Collections
into the starter collection using addAll. Certain Collections, like
guava's Multiset have optimized addAll() methods that recognize
other Multisets.
There is also a putAll() equivalent for Maps.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2891 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2010-09-21 02:11:03 +00:00
samskivert ace6b104e2 Utilities!
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2890 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2010-09-20 22:31:02 +00:00
karma@deadmoose.com 8c9adfd8f8 Ray rolled back the bit that needed this one.
And SVN is being super pokey so I'm swimming against molasses and
that wasn't showing yet. Argh.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2889 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2010-09-17 20:54:40 +00:00
ray.j.greenwell 590be465d7 Why are we silently ignoring the last argument if someone passes in an odd number?
Instead, let's log:
  message [name1=value1, name2=<toString failure: ArrayIndexOutOfBoundsException>]


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2888 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2010-09-17 20:53:00 +00:00
karma@deadmoose.com ef34b921b2 Need to import those to use them.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2887 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2010-09-17 20:47:54 +00:00
ray.j.greenwell 42e4c4138d Reverted r2884.
If someone wants to use StringUtil.toString(), let them get
the openBox/closeBox/separators they were expected.

Gee, I hope r2885 didn't beak any Log parsing code...


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2886 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2010-09-17 20:45:56 +00:00
ray.j.greenwell 0dc4418fd2 Do not use StringUtil.toString() to log any arguments.
As detailed in my last checkin.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2885 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2010-09-17 20:44:22 +00:00
ray.j.greenwell 7dba599509 Just call toString() on a Collection rather than iterating over it ourselves.
This is an incomplete fix and brings up a larger issue that I'll explain
below. Also, this breaks the customization of openBox/closeBox/separator
Strings.

First off, I know of no Collection that doesn't have a decent toString()
implementation. The java.util.Abstract* classes all do something
reasonable and most Collections are built from those.

Guava's Multiset has a defined way of representing itself as a String.
An example would be "[value1, value2 x 100]". This fix is mainly
addressed at fixing that, as this class would do the very dumb thing
if provided with a Multiset.

Do we really customize the openBox/closeBox/separator values? Should we?


The second issue comes from the way Log uses StringUtil to evaluate
the var-args it is passed. Check out the following code.

Iterator<Thing> it = Iterables.concat(_staticThings, newThings).iterator();
log.debug("About to iterate", "user", user, "request", req, "iterator", it);
while (it.hasNext()) {
    ...


If the logging level is above debug, this works fine. However if one day
you lower your logging level, the message will be logged and the Iterator
will be passed to String.toString(), which will suck all the elements out of it.

That's a problem.

Actually, perhaps the right thing to do is simply to change the Log class
to avoid using this, and instead just call String.valueOf() on all objects
except arrays, which can instead be String'd with the methods added to
java.util.Arrays in 1.5.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2884 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2010-09-17 20:23:41 +00:00
ray.j.greenwell 8e33cc2cd7 Shareable references to common 0-length arrays.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2883 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2010-09-14 00:40:05 +00:00
ray.j.greenwell 62c86b38f7 Append the final "]" using the StringBuilder.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2882 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2010-09-13 19:50:22 +00:00
samskivert 5f5a261e0d Go ahead and build and ship the Velocity and Digester stuff. Most of the
Velocity stuff actually works with a non-hacked Velocity implementation, and
specifically VelocityUtil and ClasspathResourceLoader are used all over the
place for great justice, so we want to support that.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2881 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2010-09-11 04:28:04 +00:00
samskivert 58f0b9a067 A test of some basic HsqldbLiaison behavior, which I added to test other
things, which ended up being infeasible. But I'll leave this test machinery
here as it may be useful in the future if we want to add more
com.samskivert.jdcb unit tests.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2880 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2010-09-10 23:48:48 +00:00
samskivert 87731adf48 [maven-release-plugin] prepare for next development iteration
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2879 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2010-09-10 16:15:13 +00:00
samskivert 71f1a59668 [maven-release-plugin] prepare release samskivert-1.0
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2877 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2010-09-10 16:15:04 +00:00
samskivert 6c97376395 This only works when we fork the compiler. Also managed to bork my dash.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2876 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2010-09-10 16:09:49 +00:00
samskivert 6d2269e465 OMFG. The inmates are running the asylum.
Instead of fixing this utterly ridiculous problem, some guy submitted a patch
to detect when someone was using spaces in the text of <compilerArgument> and
spit out a warning, directing them to a new FAQ entry explaining the
limitation, and telling them this retarded workaround:
http://jira.codehaus.org/browse/MCOMPILER-130

He then included a bunch of code to allow this warning to be turned off.
WTFFFFFFFFFFFFFFFFFFFFF!?


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2875 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2010-09-10 16:02:38 +00:00
samskivert 9b55d58add We apparently need the current version to be a -SNAPSHOT version to perform a
release.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2874 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2010-09-10 15:12:54 +00:00
samskivert 8c54d3689c Link to the project page from the Javadocs.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2872 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2010-09-09 20:24:42 +00:00
samskivert c201ac6d9f Add plugin declarations for these plugins so that we get the latest versions.
Sigh.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2870 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2010-09-09 20:17:26 +00:00
samskivert d1c37e5b36 Omit Javadocs for protected members. They clutter up the documentation of the
public interfaces and if you are making use of protected members, you should be
looking at the source.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2869 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2010-09-09 20:10:42 +00:00
samskivert d159774dff Minor edit.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2865 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2010-09-09 18:22:21 +00:00
samskivert eb85d7d40b Bye bye Ivy. Even though I like you better, building with Maven makes
publishing to the public Maven repositories much simpler. Being published to
the public Maven repositories makes life easier for everyone who wants to
depend on samskivert.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2864 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2010-09-09 18:21:54 +00:00
samskivert db601ce31f Include our GWT source bits directly in the main jar.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2863 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2010-09-09 17:44:44 +00:00
samskivert eb4b4b90dd Not specifying a plugin version number is interpreted by Maven as "use whatever
fucking arbitrary version you like". Fortunately, it is possible to instruct
Maven to do what would be the sensible default: use the latest release version
of the plugin.

Now that I have done so, the magical insertion of a -link argument for the Java
API is working. Much to my chagrin, the associated <detectLinks> option of the
javadoc plugin is a cruel joke.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2862 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2010-09-09 04:44:52 +00:00
samskivert 155c8bada1 This is in the resources directory now, sadly.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2861 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2010-09-08 22:57:12 +00:00
samskivert 5cae01afd6 Second entry into "Why Maven sucks" journal:
Sun "enhanced" the jar file specification to allow dependencies to be expressed
inside jar files, which cause the JVM to try to magically add dependent jar
files to the classpath. This is half-assed and wrong in too many ways to
enumerate here.

They then helpfully added activation.jar to mail.jar under the multiple
misguided assumptions that no one would ever possibly need to use mail.jar
without also having activation.jar in their classpath, with that exact name,
and located precisely in the same directory. I can't possibly imagine devating
from those implicit requirements.

Maven then upped the ante on this little fiasco by deciding that any time the
Java compiler generates a warning that they can't parse, they should fail the
build. Clearly it's critical that your build system be conversant in every
possible warning that might be emitted by your compiler. As a result, when I
fix their boneheaded default of suppressing warnings by default, the build now
fails with this demonstration of awesomeness:

  could not parse error message: warning: [path] bad path element
  "/home/mdb/.m2/repository/javax/mail/mail/1.4.1/activation.jar": no such file
  or directory

Thank you Sun, and thank you Maven.

Fortunately, I can tell javac to not emit warnings for these bogus jar
dependencies, which I have done.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2860 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2010-09-08 22:56:00 +00:00
samskivert 9699eceea7 First entry into "Why Maven sucks" journal:
1. Warnings and deprecations are not shown by default.

2. Documentation shows use of <compilerArgument> with mulitple arguments in a
single element:

  <compilerArgument>-foo -bar</compilerArgument>

which is a bald-faced lie. Only a single argument is allowed inside a
<compilerArgument> element. Web search turns up "helpful" advice to use
multiple elements:

  <compilerArgument>-foo</compilerArgument>
  <compilerArgument>-bar</compilerArgument>

Fair enough, and also a bald-faced lie. After spending a bunch of time
debugging why my compiler arguments were not working, I discovered that Maven
was just (silently) using the last one and ignoring/overwriting all of the
previous arguments.

I had noticed while poring over the documentation that it was also possible to
use the so-called "Map version" (whatever that means), which uses this
completely fucking stupid syntax:

  <compilerArguments>
    <foo/>
    <bar/>
  </compilerArguments>

Why is that syntax completely fucking stupid, you might ask? Well, dear reader,
because the arguments that I'm actually passing end up looking like this:

  <compilerArguments>
    <Xlint/>
    <Xlint:-serial/>
  </compilerArguments>

which is a case study in how not to represent information in XML. I didn't even
try that originally because I was sure that it would not work, given the wacky
non-[a-zA-z]+ nature of the argument I needed to supply. The fact that it does
work gives me the fear.

You might wonder if the following form would provide satisfaction:

  <compilerArguments>
    <compilerArgument>-Xlint</compilerArgument>
    <compilerArgument>-Xlint:-serial</compilerArgument>
  </compilerArguments>

Other than being absurdly verbose, it seems right in line with The Maven Way
(tm). However, that results in -compilerArgument=-Xlint and
-compilerArgument=-Xlint:-serial being passed to the compiler. Hilarity
naturally ensues.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2859 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2010-09-08 21:28:27 +00:00
samskivert 312d38c6b7 GPG plugin configuration, as Sonatype requires published artifacts to be GPG
signed.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2858 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2010-09-08 19:50:26 +00:00