[daisy] Programmatically create a link (VariantKey)

Marc Portier mpo at outerthought.org
Wed Dec 6 05:25:03 CST 2006



Bruno Dumon wrote:
> On Tue, 2006-12-05 at 09:31 -0500, Robert Cecil wrote:
>> Awesome help guys. I had stumbled onto the bare constructor, and
>> frankly, I was unsure of myself.
> 
> As long as you stick to the APIs, you can do anything you want. The API
> contains mostly interfaces, but if there are any concrete classes in
> there, you're free to use them.
> 
>>  I was unsure because my previous experience with the API seemed to
>> follow more of factory-method approach for lifecycle
>> (createDocument(), etc, etc.)
> 
> Yep, but that's because the implementation of those objects is hidden.
> 
> The VariantKey is as simple value object (like a string), so can be
> instantiated as is.
> 
>> Have you thought about making a factory method on VariantManager or
>> DocumentManager called 
>>
>>
>> createDefaultVariant(Document doc)
> 
> Might make sense indeed, though I'd rather add it as a static method on
> the VariantKey object. Or we could at least define the -1 as a constant
> somewhere.
> 

the constants already exist :-)

I currently have this on an own daisy-helper-class:

    public static VariantKey defaultVariant(long id)
    {
        return new VariantKey(id, Branch.MAIN_BRANCH_ID,
Language.DEFAULT_LANGUAGE_ID);
    }

but I agree:
1/ it makes more sense that this would just live on the VariantKey class
  (having a separate factory-class for this sounds like an overkill)

2/ and an overloaded version taking a Document as argument seems useful
in this linking context


regards,
-marc=
-- 
Marc Portier                            http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
Read my weblog at                http://blogs.cocoondev.org/mpo/
mpo at outerthought.org                              mpo at apache.org


More information about the daisy mailing list