[picocontainer-scm] [5598] java/2.x/trunk/pico/distribution/src/site/content: some words on converters

paul-yCVjj/[email protected]
Newsgroups gmane.comp.java.picocontainer.cvs
Message-ID <[email protected]>
Revision 5598
Author paul
Date 2010-02-09 06:57:02 -0600 (Tue, 09 Feb 2010)

Log Message

some words on converters

Modified Paths

- java/2.x/trunk/pico/distribution/src/site/content/news.html

- java/2.x/trunk/pico/distribution/src/site/content/sitemap.xml

- java/2.x/trunk/pico/distribution/src/site/templates/skin.html

Added Paths

- java/2.x/trunk/pico/distribution/src/site/content/converters.html

Diff

Added: java/2.x/trunk/pico/distribution/src/site/content/converters.html (0 => 5598)

--- java/2.x/trunk/pico/distribution/src/site/content/converters.html (rev 0)
+++ java/2.x/trunk/pico/distribution/src/site/content/converters.html 2010-02-09 12:57:02 UTC (rev 5598)
@@ -0,0 +1,81 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+<head>
+
+<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
+ <title>Converters</title>
+</head>
+<body>
+<h2>Overview<br>
+</h2>
+<p><span style="font-weight: normal;">Converters
+are take string instances in PicoContainer and convert the type that a
+particular component requires for injection.</span>&nbsp;
+DefaultPicoContainer has built in converter<span
+ style="font-weight: normal;"> for primitives:</span></p>
+<ul>
+ <li>Integer</li>
+ <li>Double</li>
+ <li>Boolean</li>
+ <li>Long</li>
+ <li>Float</li>
+ <li>Character</li>
+ <li>Byte</li>
+ <li>Short</li>
+ <li>File</li>
+</ul>
+<h2>Custom Converters</h2>
+You can extend BuiltInConverter, or implement the Converter interface
+directly.&nbsp; BuiltInConverter has a method addConverter(..) which
+you may find convenient:<br>
+<br>
+<div class="source"><pre>BuiltInConverter bic = new
+BuiltInConverter();
+bic.addConverter(SomeCustomThing.class, new SomeCustomThingConverter());
+</pre></div>s
+<br>
+Alternatively, you can subclass BuildInConverter:<br>
+<br>
+<div class="source"><pre>BuiltInConverter bic = new BuiltInConverter() {
+ @Override
+ protected void addBuiltInConverters() {
+ super.addBuiltInConverters();
+ super.addConverter(SomeCustomThing.class, new SomeCustomThingConverter());
+ }
+ };
+</pre></div>
+<br>
+or:<br>
+<br>
+<div class="source"><pre>BuiltInConverter bic = new BuiltInConverter() {
+ public BuiltInConverter() {
+ super.addConverter(SomeCustomThing.class, new SomeCustomThingConverter());
+ }
+};
+</pre></div>
+Converters themselves are easy to write.&nbsp; Here's the built in one
+for boolean:<br>
+<br>
+<div class="source"><pre>class BooleanConverter implements Converting.Converter {
+ public boolean canConvert(Type type) {
+ return Boolean.class == type;
+ }
+ public Object convert(String paramValue, Type type) {
+ return Boolean.valueOf(paramValue);
+ }
+}
+</pre></div>
+<br>
+Setup a container to use your converter:<br>
+<br>
+<div class="source"><pre>MutableContainer pico = new DefaultPicoContainer() {
+ @Override
+ public Converting.Converter getConverter() {
+ return new YourCustomConverter();
+ }
+};
+</pre></div>
+<br>
+<br>
+</body>
+</html>
Property changes on: java/2.x/trunk/pico/distribution/src/site/content/converters.html
___________________________________________________________________
Name: svn:executable
+ *

Modified: java/2.x/trunk/pico/distribution/src/site/content/news.html (5597 => 5598)

--- java/2.x/trunk/pico/distribution/src/site/content/news.html 2010-02-08 23:01:25 UTC (rev 5597)
+++ java/2.x/trunk/pico/distribution/src/site/content/news.html 2010-02-09 12:57:02 UTC (rev 5598)
@@ -6,11 +6,11 @@
</head>
<body>

- <p><strong>Feb 8, 2010 - PicoContainer 2.10 released (311K jar)</strong></p>
+ <p><strong>Feb 9, 2010 - PicoContainer 2.10 released (311K jar)</strong></p>

<p>New (since 2.9):</p>
<ul>
- <li>String Converters are now overridable and can be leveraged from parent containers if not specified in a child</li>
+ <li>String <a href="converters.html">Converters</a> are now overridable and can be leveraged from parent containers if not specified in a child</li>
<li>@Named from JSR 330 (@Inject) now supported.</li>
</ul>
<p>Changes (versus 2.9):</p>

Modified: java/2.x/trunk/pico/distribution/src/site/content/sitemap.xml (5597 => 5598)

--- java/2.x/trunk/pico/distribution/src/site/content/sitemap.xml 2010-02-08 23:01:25 UTC (rev 5597)
+++ java/2.x/trunk/pico/distribution/src/site/content/sitemap.xml 2010-02-09 12:57:02 UTC (rev 5598)
@@ -51,6 +51,7 @@
<page>parameter-names.html</page>
<page>builder.html</page>
<page>properties.html</page>
+ <page>converters.html</page>
<page>component-configuration.html</page>
<page>monitors.html</page>
<page>regex.html</page>

Modified: java/2.x/trunk/pico/distribution/src/site/templates/skin.html (5597 => 5598)

--- java/2.x/trunk/pico/distribution/src/site/templates/skin.html 2010-02-08 23:01:25 UTC (rev 5597)
+++ java/2.x/trunk/pico/distribution/src/site/templates/skin.html 2010-02-09 12:57:02 UTC (rev 5598)
@@ -30,7 +30,7 @@
<div class="clear"></div>
</div>
<div id="breadcrumbs">
-<div class="left">Latest Released Version: 2.9</div>
+<div class="left">Latest Released Version: 2.10</div>
<div class="clear"></div>
</div>

----------

To unsubscribe from this list please visit:

http://xircles.codehaus.org/manage_email
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.