Page 1 of 1

[patch] Interface for sdt-elements

PostPosted: Wed Feb 16, 2011 9:22 pm
by Richard
Hi Jason,

I've created a patch and want to share it with you.
Because I'm new to docx4j I'm not sure if it is a pratical / neccessary one, but I know you'll tell me. ;)

I created an interface for SdtRun, SdtBlock, CTSdtCell and CTSdtRow, because I've written a utility for my application which handels all of these types. To reduce some lines of code I found it helpfull to create an interface.

All JUnit tests worked for me.

I've read the terms & conditions for providing a patch and accept them.

Richard

Re: [patch] Interface for sdt-elements

PostPosted: Mon Feb 21, 2011 11:16 pm
by jason
Hi Richard

Thank you for this.

I have applied it, except that I commented out:

void afterUnmarshal(Unmarshaller unmarshaller, Object parent);

from the interface. Is there a reason you have that there?

I've also extended your concept to include:

public SdtContent getContent();

See http://dev.plutext.org/trac/docx4j/changeset/1432 and 1433

Its getContent(), rather than getSdtContent(), because a method with that name is already part of the API.

So now you can use the interface for both the Sdt's Pr, and Content.

I haven't included a setSdtContent() method; if this was included, the implementation should probably check the arg is the correct sub-class.

Let me know what you think.

cheers .. Jason

Re: [patch] Interface for sdt-elements

PostPosted: Tue Feb 22, 2011 7:31 pm
by Richard
I'm ok with those adjustments.

I put the afterUnmarshal method in the interface, because I've seen it in every of the four classes, but I was not aware that it is not necessary.

I like the idea to have a getContent() in the interface as well. If a setContent() becomes necessary we can add it later...

Thanks for applying those changes. :)