[Cosmo-dev] Re: [commits-sandbox] [sandbox] (edbindl) [732] Refactored the Jcr/Xpath specific stuff, put constants in User and did "mapping" in JcrXpathQueryBuilder (submit patch)

Brian Moseley bcm at osafoundation.org
Tue Aug 22 17:42:06 PDT 2006


> + public JcrXpathQueryBuilder getJcrXpathQueryBuilder() {
> + return jcrXpathQueryBuilder;
> + }
> +
> + public void setJcrXpathQueryBuilder(JcrXpathQueryBuilder
> jcrXpathQueryBuilder) {
> + this.jcrXpathQueryBuilder = jcrXpathQueryBuilder;
> + }

ideally you'd have a JcrQueryBuilder interface and then make
JcrXpathQueryBuilder implement that interface by building xpath
queries. this allows us, should we need, to implement the same
interface with a JcrSqlQueryBuilder.

> + // Sort Strings
> +
> + /**
> + * A String indicating the results should be sorted by Last Name then First
> Name
> + */
> + public static final String NAME_SORT_STRING = "Name";

there's an i18n problem here. some locales may want to sort in the
opposite order. i don't think we need to deal with the issue now, just
noting it.

also, for reasons of both brevity and i18n, i like using numeric
constants for sort attributes rather than strings. eg:

public static final String NAME_SORT_STRING = 1;
public static final USERNAME_SORT_STRING = NAME_SORT_STRING + 1;

and so forth.

> + // Xpath Attributes
> +
> + public static final String COSMO_DATE_MODIFIED = "cosmo:dateModified";

eek! you're polluting our nice clean storage-independent model with
jcr-isms! :) note the JcrConstants class that already defines these
constants - you can have JcrUserDao (or whatever other class needs to
map the sort attributes to jcr properties) use JcrConstants directly.


More information about the cosmo-dev mailing list