Commit Graph

604 Commits

Author SHA1 Message Date
Ray Greenwell 92c201575d Update the tests.
One test no longer works, because the StringArray transformer now inherits
the fromPersistent method from StringBase, and has a generic return type.
Perhaps we can update FieldMarshaller to deal with Types instead of classes
when validating... But for now I did what all bad programmers do when a test
fails: comment it out.
2010-10-12 20:39:07 +00:00
Ray Greenwell dcd4046c60 Transformer rejigger.
Transformer is now an abstract class with a default init() method.
The Type parameter has been removed from fromPersistent().
The Transformer annotation now has some new attributes that
can be used to hint whether you want a result that is immutable or interned,
the meaning and support of both is completely up to the Transformer.
Brought back my uber Iterable<String> transformers, with immutable/intern
support in a single Transformer.
 - interning will intern the strings
 - immutable will wrap the collections in Collections.unmodifiable*
   (using a guava Immutable collection ends up creating a temporary
    builder collection and then copying the elements)
 - if immutable AND interning then the collection itself is
   "interned".
At some point I'll add support for nearly any Iterable
of an otherwise supported type, so that our Records can have
List<Integer> and other such fields.
2010-10-12 19:35:07 +00:00
Ray Greenwell 2ff3bac12d Look for any worthy method, even in superclasses. 2010-10-01 01:29:46 +00:00
Ray Greenwell c7eb6f56ef Roll this back until I do some more testing.. :( 2010-09-30 22:25:16 +00:00
Ray Greenwell 89bec13aa2 Added Transformers that will always return immutable collections,
interned Strings, or both.
I may rework this into attributes that can be specified for any
@Transformer annotation, and leave it up to each Transformer
whether they are honored (and how).
2010-09-30 21:30:59 +00:00
Ray Greenwell 9fafebd487 Support creating arrays of java.sql.Date. 2010-09-29 18:31:31 +00:00
Ray Greenwell 020d33c8aa Was looking at how some things work and made a few drive-by optimizations
to FindAllQuery.
- We don't need to destructively modify the Set of keys to fetch if we hold
  on to one iterator.
- We can create an ArrayList that won't need to grow if our keys Iterable
  happens to be a Collection.
- And, just generally prefer Lists factories to specific constructors.
2010-09-20 23:21:06 +00:00
Andrzej Kapolka 8c5f333f73 Is there a reason why this didn't return TIME? It seems to work. 2010-09-17 02:46:17 +00:00
Michael Bayne 07e4bdec4a Move overview.html to a place where Maven's javadoc plugin will find it. 2010-09-09 20:31:51 +00:00
Michael Bayne 33f6351af5 Add link to project website to docs. 2010-09-09 20:28:34 +00:00
Michael Bayne 0fea1dfb07 Nix link since we're not including protected bits in the docs. 2010-09-09 20:27:18 +00:00
Michael Bayne 5fe094a804 Import needed for Javadoc comment. 2010-09-09 05:26:16 +00:00
Michael Bayne 3f7a7be9da Some Javadoc fixing. Though it's very annoying that I have to use &#064;
instead of @. Thanks for making things totally unreadable in the source file
javadoc. How about \@ instead?
2010-08-27 18:11:22 +00:00
Michael Bayne 28f9439b5f More layout standardizing. 2010-08-27 17:49:18 +00:00
Michael Bayne 6778ada227 Moving toward more standard project layout. 2010-08-27 17:47:07 +00:00
Michael Bayne 5a97565eaa New HSQLDB requires length for VARBINARY. 2010-08-27 17:41:11 +00:00
Andrzej Kapolka 2471487d2f Oops, that will never be null. 2010-08-18 22:43:33 +00:00
Andrzej Kapolka af0c636517 More fixes for named columns. DepotMarshaller expects the names of the
columns in the results to match the FieldMarshaller column names, so we have
to use those rather than the field names.  Also, shadowed fields need to use
the column names of the fields that they're shadowing.
2010-08-18 22:40:03 +00:00
Andrzej Kapolka 061219bc57 Postgres returns a timestamp from date_trunc, whereas MySQL returns a
date from date().  We should probably just modify DateFuncs.date to
return a date in both cases (perhaps with a separate DateFun.DateCast
class), but for now it's easier to have MySQL return a timestamp as
well.
2010-07-22 21:37:11 +00:00
Andrzej Kapolka 27ff0f6f55 And this should be getting the column name, too (though it doesn't
actually do anything yet except log a message).
2010-07-15 00:50:59 +00:00
Andrzej Kapolka cd94a13551 While I'm in there, this also looks wrong. 2010-07-15 00:30:40 +00:00
Andrzej Kapolka 5dd3ae92a5 Looks like this should be the column name, not the field name. 2010-07-15 00:22:28 +00:00
Ray Greenwell c7ce640a78 Prefer Guava to Samskivert. 2010-07-14 18:51:40 +00:00
Ray Greenwell 9d83cc96a5 For the String[] transformer, encode null elements as "\" followed by
the terminator (we encode the terminator as a different character).
This is somewhat nicer when inspecting an encoded String, and allows
for a future in which the decoder easily counts the number of terminator
characters and pre-allocates the storage, if we so desired.
2010-07-06 20:54:48 +00:00
Ray Greenwell 95f2fc6938 A Transformer from a Set<ByteEnum> -> Integer, plus some new tests. 2010-07-06 18:30:32 +00:00
Michael Bayne 5ec15839d3 Factored shared code into a base class. Restructured to avoid double checking
for null.
2010-07-06 18:22:09 +00:00
Michael Bayne 0b84e08917 Nixed deprecated transformer. 2010-07-06 18:15:37 +00:00
Ray Greenwell 20e06e9789 Ready my Transformer for prime time.
There are some optimizations that could probably be made, but
for now I defer to the new One Rule of Optimization:
"Do not optimize for performance unless it does not weird the code or
it Really Matters".
2010-07-05 22:43:13 +00:00
Ray Greenwell 2b71609148 I should change the name of this test... 2010-07-05 22:36:18 +00:00
Ray Greenwell 48279471e1 Updated tests. 2010-07-05 22:34:15 +00:00
Ray Greenwell eef66bcaee Changed my String[] Transformer:
- continue to terminate Strings with a newline
- turn newlines inside a String into "\n"
- turn null elements into "\0".

This is one additional character when encoding nulls, but
I think it may improve readability..
2010-07-05 22:10:56 +00:00
Michael Bayne 0e82904696 Provide the Transformer with the field's Type rather than it's Class. The Type
contains generic type information which would allow a transformer to do the
right thing with a field of, say, type Set<Integer>.

If we had unit tests for StringIterable, I'd know that I didn't just break it.
I'd also know that it worked in the first place. :)
2010-07-05 21:43:10 +00:00
Ray Greenwell a5fee01354 Maybe I can generalize this into a rule: if either of operands 2 or 3
to the ternary operator are boolean constants, don't use the ternary operator.

a ? true : x   ==  a || x
a ? x : true   ==  !a || x
a ? false : x  ==  !a && x
a ? x : false  ==  a && x
2010-07-05 21:32:28 +00:00
Ray Greenwell f2f995766b A demonstration of the failing of the current String[] transformer.
I'll do some more tests and nix this one today.
2010-07-05 14:16:00 +00:00
Ray Greenwell ce1d06e82b I was trying to be clever with newline and save a character,
but I forgot about that cleverness in fromPersistent, so skip it for now.
2010-07-02 03:56:26 +00:00
Ray Greenwell f4c7b7fef4 Better String[] Transformer, RFC. 2010-07-02 03:49:43 +00:00
Par Winzell 846ea920b6 Make the adapter configurable, as was always the intention. 2010-07-01 17:15:32 +00:00
Par Winzell a0e8c602ed Maintain correct record counts for cacheless finds. 2010-06-24 18:15:40 +00:00
Michael Bayne 75a22f5584 Nix joiner. 2010-06-19 18:05:46 +00:00
Michael Bayne 728159dc48 Replace the CommaSeparatedString transformer with an escaping
TabSeparatedString transformer. Maybe I should just use StringUtil methods...
2010-06-19 18:05:23 +00:00
Michael Bayne f4cc4f2bee Move the repository south to match AllTypesTest. 2010-06-19 17:52:52 +00:00
Michael Bayne 978bf81acb Added support for boxed booleans. I have to admit that adding it to the test
case, seeing it fail, then adding the code to handle it was rather satisfying.

I'm not jumping on the TDD bandwagon or anything, but libraries like Depot are
clear cases where vigorous unit testing is a big win.
2010-06-19 17:48:51 +00:00
Michael Bayne 9d9ba71c97 Import tidying. 2010-06-19 17:45:28 +00:00
Michael Bayne d0dd828925 Comment our workarounds. 2010-06-19 17:44:55 +00:00
Michael Bayne 45ec7cf77c Implemented the ColumnTyper interface for our various builders. 2010-06-19 17:41:10 +00:00
Michael Bayne 5587d134bd Request the appropriate length for int arrays. 2010-06-19 17:40:03 +00:00
Michael Bayne ff53b67e3d Test that @Transform works in its various supported use cases, and fails as
early as possible in situations where the developer is fucking up.
2010-06-19 17:36:04 +00:00
Michael Bayne 7f9bf7b589 Determined that we need to pass the field type into the fromPersistent() to
support use cases like ByteEnum. (Even though I'm leaving ByteEnum support
hard-coded for the time being.)
2010-06-19 17:35:05 +00:00
Michael Bayne 1d9a19e502 Unit tests for all supported field types (including null versions). 2010-06-19 17:34:21 +00:00
Michael Bayne 06c36fbed2 - Added support for @Transform annotation.
- Revamped column type determination to use a mechanism that supports
  delegation and does not rely on a heap of instanceof calls (which results in
  runtime failure rather than compile time failure when a new column type is
  added)
- Discovered that HSQLDB (at least) does not handle Byte, Short and Float
  correctly. It returns them as Integer, Integer and Double respectively, which
  then causes failure when trying to write those values back to the fields. We
  work around this by converting non-null results to the correct type after we
  get them back from the JDBC driver.
2010-06-19 17:33:55 +00:00