abdera-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From James M Snell <jasn...@gmail.com>
Subject API Refactoring
Date Thu, 22 Jun 2006 21:20:51 GMT
There are a number of API refactorings that I've been meaning to do for
a while to simplify the way entry content and text elements are set.
Whereas currently the API has a whole bunch of methods like
entry.setContentAsText(...), entry.setContentAsXhtml(...), etc, the
refactoring I have ready to check in changes it to just a limited
handful of setContent(...) methods with various options.  The same kind
of refactoring is applied to all of the various
setTitle/setRights/setSubtitle/setSummary methods. This refactoring also
affects content/text related methods in the Factory interface.

//<content type="text">Testing</content>
content = entry.setContent("Testing");

//<content type="html">&lt;p>Testing&lt;/p></content>
content = entry.setContent(Content.Type.HTML, "<p>Testing</p>");

//<content type="xhtml">
//  <div xmlns='http://www.w3.org/1999/xhtml'>Testing</div>
//</content>
content = entry.setContent(
  Content.Type.XHTML,
  "<div xmlns='http://www.w3.org/1999/xhtml'>Testing</div>");

//<content type="application/xml"><a><b /></a></content>
content = entry.setContent(
  new MimeType("application/xml"),
  "<a><b/></a>");

//<content type="text/plain">foo</content>
content = entry.setContent(new MimeType("text/plain"), "foo");

//<content type="image/png">{base64}</content>
content = entry.setContent(
  new MimeType("image/png"),
  new DataHandler(new ByteArrayDataSource("foo".getBytes())));

//<content type="image/png" src="http://foo" />
content = entry.setContent(
  new MimeType("image/png"), new URI("http://foo"));

Thoughts? Complaints? Concerns before I check it in?

- James


Mime
View raw message