My new DOM api: jquery-alike or with getters/setters?
<p>I have built an event-base java html parser: <a href="http://jodd.org/doc/lagarto/index.html" rel="nofollow" title="Lagarto">Lagarto</a>. Now I am working on DOM builder, that creates a DOM tree using the parser. In the same time, I have developed CSS3 selectors node filter java library that works nice with this DOM tree.</p>

<p>My initial idea was to design DOM classes with API similar to <strong>JQuery</strong>. For example, to read an attribute user would call:</p>

<pre><code>element.attr("name");
</code></pre>

<p>Similarly, to set an attribute user would call:</p>

<pre><code>element.attr("name", "value");
</code></pre>

<p>However, this approach breaks the usual way how things are get and set in Java. Now I can't decide should I:</p>

<ul>
<li>build the jquery-alike API for my DOM classes. Together with CSS3 selectors library this would make everything very similar to <strong>jquery</strong></li>
<li>build the DOM classes using getters and setters. I am not sure if they would be ever used by some beanutil library, for example; and, for this purpose, it does not look so nice and fluent to me.</li>
</ul>

<p><em>Question</em>: what would you choose from above if you if you had to build your own DOM library?</p>

<p>Of course, there is no correct answer on this one:) Therefore I would accept the answer that matches my final decision - but that doesn't mean that the other solution is not correct!</p>
