cziegeler 2004/05/03 04:36:07
Modified: tools/src/anttasks SitemapTask.java
src/documentation/templates sitemap-component.xml
Log:
Use dynamic table; output mime-type
Revision Changes Path
1.8 +76 -30 cocoon-2.1/tools/src/anttasks/SitemapTask.java
Index: SitemapTask.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/tools/src/anttasks/SitemapTask.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- SitemapTask.java 3 May 2004 09:14:01 -0000 1.7
+++ SitemapTask.java 3 May 2004 11:36:06 -0000 1.8
@@ -311,7 +311,7 @@
// test for logger
// TODO Default logger?
- if (
this.javaClass.isA("org.apache.avalon.framework.logger.LogEnabled") ) {
+ if ( this.javaClass.isA(LOG_ENABLED) ) {
this.addAttribute(node, LOGGER_TAG, "logger", null);
}
@@ -319,7 +319,7 @@
this.addAttribute(node, LABEL_TAG, "label", null);
// pooling?
- if (
this.javaClass.isA("org.apache.avalon.excalibur.pool.Poolable") ) {
+ if ( this.javaClass.isA(POOLABLE) ) {
// TODO - Think about default values
this.addAttribute(node, POOL_MIN_TAG, "pool-min", null);
this.addAttribute(node, POOL_MAX_TAG, "pool-max", null);
@@ -327,7 +327,7 @@
}
// mime-type
- if (
this.javaClass.isA("org.apache.cocoon.sitemap.SitemapOutputComponent") ) {
+ if ( this.javaClass.isA(OUTPUT_COMPONENT) ) {
this.addAttribute(node, MIMETYPE_TAG, "mime-type", null);
}
@@ -413,30 +413,47 @@
}
}
+ // Info Table
+ final Node tableNode = XPathAPI.selectSingleNode(body, "[EMAIL
PROTECTED]'Info']/table");
+
// Info - Name
- setValue(body, "[EMAIL PROTECTED]'Info']/table/tr[1]/td[2]",
this.name);
+ this.addRow(tableNode, "Name", this.name);
+
// Info - Class
- setValue(body, "[EMAIL PROTECTED]'Info']/table/tr[2]/td[2]",
this.javaClass.getFullyQualifiedName());
+ this.addRow(tableNode, "Class",
this.javaClass.getFullyQualifiedName());
+
// Info - Cacheable
- String cacheInfo;
- if (
this.javaClass.isA("org.apache.cocoon.caching.CacheableProcessingComponent") ) {
- cacheInfo = this.getTagValue(CACHING_INFO_TAG, null);
- if ( cacheInfo != null ) {
- cacheInfo = "Yes - " + cacheInfo;
- } else {
- cacheInfo = "Yes";
- }
- } else if (
this.javaClass.isA("org.apache.cocoon.caching.Cacheable") ) {
- cacheInfo = this.getTagValue(CACHING_INFO_TAG, null);
- if ( cacheInfo != null ) {
- cacheInfo = "Yes (2.0 Caching) - " + cacheInfo;
+ if ( this.javaClass.isA(GENERATOR)
+ || this.javaClass.isA(TRANSFORMER)
+ || this.javaClass.isA(SERIALIZER)
+ || this.javaClass.isA(READER)) {
+
+ String cacheInfo;
+ if ( this.javaClass.isA(CACHEABLE) ) {
+ cacheInfo = this.getTagValue(CACHING_INFO_TAG, null);
+ if ( cacheInfo != null ) {
+ cacheInfo = "Yes - " + cacheInfo;
+ } else {
+ cacheInfo = "Yes";
+ }
+ } else if ( this.javaClass.isA(DEPRECATED_CACHEABLE) ) {
+ cacheInfo = this.getTagValue(CACHING_INFO_TAG, null);
+ if ( cacheInfo != null ) {
+ cacheInfo = "Yes (2.0 Caching) - " + cacheInfo;
+ } else {
+ cacheInfo = "Yes (2.0 Caching)";
+ }
} else {
- cacheInfo = "Yes (2.0 Caching)";
+ cacheInfo = "No";
}
- } else {
- cacheInfo = "No";
+ this.addRow(tableNode, "Cacheable", cacheInfo);
+ }
+
+ // Info - mime-type
+ if ( this.javaClass.isA(OUTPUT_COMPONENT) ) {
+ final String value = this.getTagValue(MIMETYPE_TAG, "-");
+ this.addRow(tableNode, "Mime-Type", value);
}
- setValue(body, "[EMAIL PROTECTED]'Info']/table/tr[3]/td[2]",
cacheInfo);
// merge with old doc
this.merge(body, docFile);
@@ -490,22 +507,33 @@
return defaultValue;
}
+ private void addRow(Node table, String title, String value) {
+ final Element row = table.getOwnerDocument().createElement("tr");
+ final Element firstColumn =
table.getOwnerDocument().createElement("td");
+
firstColumn.appendChild(table.getOwnerDocument().createTextNode(title));
+ final Element secondColumn =
table.getOwnerDocument().createElement("td");
+
secondColumn.appendChild(table.getOwnerDocument().createTextNode(value));
+ row.appendChild(firstColumn);
+ row.appendChild(secondColumn);
+ table.appendChild(row);
+ }
+
private static String getType(JavaClass clazz) {
- if ( clazz.isA("org.apache.cocoon.generation.Generator") ) {
+ if ( clazz.isA(GENERATOR) ) {
return "generator";
- } else if (
clazz.isA("org.apache.cocoon.transformation.Transformer") ) {
+ } else if ( clazz.isA(TRANSFORMER) ) {
return "transformer";
- } else if ( clazz.isA("org.apache.cocoon.reading.Reader") ) {
+ } else if ( clazz.isA(READER) ) {
return "reader";
- } else if (
clazz.isA("org.apache.cocoon.serialization.Serializer") ) {
+ } else if ( clazz.isA(SERIALIZER) ) {
return "serializer";
- } else if ( clazz.isA("org.apache.cocoon.acting.Action") ) {
+ } else if ( clazz.isA(ACTION) ) {
return "action";
- } else if ( clazz.isA("org.apache.cocoon.matching.Matcher") ) {
+ } else if ( clazz.isA(MATCHER) ) {
return "matcher";
- } else if ( clazz.isA("org.apache.cocoon.selection.Selector") ) {
+ } else if ( clazz.isA(SELECTOR) ) {
return "selector";
- } else if (
clazz.isA("org.apache.cocoon.components.pipeline.ProcessingPipeline") ) {
+ } else if ( clazz.isA(PIPELINE) ) {
return "pipe";
} else {
throw new BuildException("Sitemap component " +
clazz.getName() + " does not implement a sitemap component interface.");
@@ -546,4 +574,22 @@
}
}
}
+
+ // Class Constants
+ private static final String LOG_ENABLED =
"org.apache.avalon.framework.logger.LogEnabled";
+ private static final String POOLABLE =
"org.apache.avalon.excalibur.pool.Poolable";
+
+ private static final String CACHEABLE =
"org.apache.cocoon.caching.CacheableProcessingComponent";
+ private static final String DEPRECATED_CACHEABLE =
"org.apache.cocoon.caching.Cacheable";
+
+ private static final String OUTPUT_COMPONENT =
"org.apache.cocoon.sitemap.SitemapOutputComponent";
+
+ private static final String GENERATOR =
"org.apache.cocoon.generation.Generator";
+ private static final String TRANSFORMER =
"org.apache.cocoon.transformation.Transformer";
+ private static final String SERIALIZER =
"org.apache.cocoon.serialization.Serializer";
+ private static final String READER = "org.apache.cocoon.reading.Reader";
+ private static final String MATCHER =
"org.apache.cocoon.matching.Matcher";
+ private static final String SELECTOR =
"org.apache.cocoon.selection.Selector";
+ private static final String ACTION = "org.apache.cocoon.acting.Action";
+ private static final String PIPELINE =
"org.apache.cocoon.components.pipeline.ProcessingPipeline";
}
1.3 +0 -12
cocoon-2.1/src/documentation/templates/sitemap-component.xml
Index: sitemap-component.xml
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/documentation/templates/sitemap-component.xml,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- sitemap-component.xml 3 May 2004 09:00:29 -0000 1.2
+++ sitemap-component.xml 3 May 2004 11:36:07 -0000 1.3
@@ -29,18 +29,6 @@
</s1>
<s1 title="Info">
<table>
- <tr>
- <td>Name</td>
- <td/>
- </tr>
- <tr>
- <td>Class</td>
- <td/>
- </tr>
- <tr>
- <td>Cacheable</td>
- <td/>
- </tr>
</table>
</s1>
</body>