vgritsenko 2002/10/21 20:54:09
Modified: src/java/org/apache/cocoon/generation StatusGenerator.java
Log:
Fix xlink attribute generation
Revision Changes Path
1.8 +39 -38
xml-cocoon2/src/java/org/apache/cocoon/generation/StatusGenerator.java
Index: StatusGenerator.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/generation/StatusGenerator.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- StatusGenerator.java 20 Sep 2002 18:15:31 -0000 1.7
+++ StatusGenerator.java 22 Oct 2002 03:54:09 -0000 1.8
@@ -67,7 +67,8 @@
import java.text.DateFormat;
import java.util.*;
-/** Generates an XML representation of the current status of Cocoon.
+/**
+ * Generates an XML representation of the current status of Cocoon.
* Potted DTD:
*
* <code>
@@ -99,23 +100,31 @@
*/
public class StatusGenerator extends ComposerGenerator {
- /** The StoreJanitor used to get cache statistics
+ /**
+ * The StoreJanitor used to get cache statistics
*/
protected StoreJanitor storejanitor;
protected Store store_persistent;
- /** The XML namespace for the output document.
+ /**
+ * The XML namespace for the output document.
*/
protected static final String namespace =
"http://apache.org/cocoon/status/2.0";
- /** The XML namespace for xlink
+ /**
+ * The XML namespace for xlink
*/
protected static final String xlinkNamespace =
"http://www.w3.org/1999/xlink";
/**
+ * The namespace prefix for xlink namespace
+ */
+ protected static final String xlinkPrefix = "xlink";
+
+ /**
* Set the current <code>ComponentManager</code> instance used by this
* <code>Composable</code>.
* Need to get statistics about cache hits
@@ -139,12 +148,12 @@
// Start the document and set the namespace.
this.contentHandler.startDocument();
this.contentHandler.startPrefixMapping("", namespace);
- this.contentHandler.startPrefixMapping("xlink", xlinkNamespace);
+ this.contentHandler.startPrefixMapping(xlinkPrefix, xlinkNamespace);
genStatus(this.contentHandler);
// End the document.
- this.contentHandler.endPrefixMapping("xlink");
+ this.contentHandler.endPrefixMapping(xlinkPrefix);
this.contentHandler.endPrefixMapping("");
this.contentHandler.endDocument();
}
@@ -196,8 +205,9 @@
startGroup(ch, "jre");
addValue(ch, "version", System.getProperty("java.version"));
atts.clear();
- atts.addAttribute(xlinkNamespace, "type", "type", "CDATA", "simple");
- atts.addAttribute(xlinkNamespace, "href", "href", "CDATA",
+ // qName = prefix + ':' + localName
+ atts.addAttribute(xlinkNamespace, "type", xlinkPrefix + ":type", "CDATA",
"simple");
+ atts.addAttribute(xlinkNamespace, "href", xlinkPrefix + ":href", "CDATA",
System.getProperty("java.vendor.url") );
addValue(ch, "java-vendor", System.getProperty("java.vendor"), atts);
endGroup(ch);
@@ -225,11 +235,12 @@
// For each element in StoreJanitor
Iterator i = this.storejanitor.iterator();
- while( i.hasNext() ) {
+ while (i.hasNext()) {
Store store = (Store) i.next();
startGroup(ch, store.getClass().getName()+" (hash =
0x"+Integer.toHexString(store.hashCode())+")" );
int size = 0;
int empty = 0;
+ atts.clear();
atts.addAttribute(namespace, "name", "name", "CDATA", "cached");
ch.startElement(namespace, "value", "value", atts);
// For each element in Store
@@ -240,51 +251,46 @@
Object key = e.nextElement();
Object val = store.get( key );
String line = null;
- if( val == null ) {
+ if (val == null) {
empty++;
- } else {
- line = key.toString() + " (class: " +
- val.getClass().getName() +
- ")" ;
+ } else {
+ line = key + " (class: " + val.getClass().getName() + ")";
ch.startElement(namespace, "line", "line", atts);
ch.characters(line.toCharArray(), 0, line.length());
- ch.endElement(namespace, "line", "line");
- };
-
-
- };
+ ch.endElement(namespace, "line", "line");
+ }
+ }
if (size == 0) {
- atts.clear();
ch.startElement(namespace, "line", "line", atts);
String value = "[empty]";
ch.characters(value.toCharArray(), 0, value.length());
ch.endElement(namespace, "line", "line");
}
-
ch.endElement(namespace, "value", "value");
addValue(ch, "size", String.valueOf(size) + " items in cache (" + empty
+ " are empty)");
endGroup(ch);
- };
+ }
endGroup(ch);
- startGroup(ch, store_persistent.getClass().getName()+" (hash =
0x"+Integer.toHexString(store_persistent.hashCode())+")" );
+ startGroup(ch, store_persistent.getClass().getName()+" (hash =
0x"+Integer.toHexString(store_persistent.hashCode())+")");
int size = 0;
int empty = 0;
+ atts.clear();
atts.addAttribute(namespace, "name", "name", "CDATA", "cached");
ch.startElement(namespace, "value", "value", atts);
Enumeration enum = this.store_persistent.keys();
- while( enum.hasMoreElements() ) {
+ while (enum.hasMoreElements()) {
size++;
Object key = enum.nextElement();
- Object val = store_persistent.get( key );
+ Object val = store_persistent.get (key);
String line = null;
- if( val == null ) {
+ if (val == null) {
empty++;
} else {
- line = key.toString() + " (class: " + val.getClass().getName() +
")" ;
+ line = key + " (class: " + val.getClass().getName() + ")";
ch.startElement(namespace, "line", "line", atts);
ch.characters(line.toCharArray(), 0, line.length());
ch.endElement(namespace, "line", "line");
@@ -292,18 +298,15 @@
}
if (size == 0) {
- atts.clear();
ch.startElement(namespace, "line", "line", atts);
String value = "[empty]";
ch.characters(value.toCharArray(), 0, value.length());
ch.endElement(namespace, "line", "line");
}
-
ch.endElement(namespace, "value", "value");
addValue(ch, "size", String.valueOf(size) + " items in cache (" + empty + "
are empty)");
endGroup(ch);
-
// END Cache
// BEGIN OS info
@@ -318,7 +321,7 @@
/** Utility function to begin a <code>group</code> tag pair with added
attributes. */
private void startGroup(ContentHandler ch, String name, Attributes atts) throws
SAXException {
AttributesImpl ai;
- if ( atts == null ) {
+ if (atts == null) {
ai = new AttributesImpl();
} else {
ai = new AttributesImpl(atts);
@@ -340,7 +343,7 @@
/** Utility function to begin and end a <code>value</code> tag pair with added
attributes. */
private void addValue(ContentHandler ch, String name, String value, Attributes
atts) throws SAXException {
AttributesImpl ai;
- if ( atts == null ) {
+ if (atts == null) {
ai = new AttributesImpl();
} else {
ai = new AttributesImpl(atts);
@@ -349,7 +352,7 @@
ch.startElement(namespace, "value", "value", ai);
ch.startElement(namespace, "line", "line", new AttributesImpl());
- if ( value != null ) {
+ if (value != null) {
ch.characters(value.toCharArray(), 0, value.length());
}
@@ -365,7 +368,7 @@
/** Utility function to begin and end a <code>value</code> tag pair with added
attributes. */
private void addMultilineValue(ContentHandler ch, String name, List values,
Attributes atts) throws SAXException {
AttributesImpl ai;
- if ( atts == null ) {
+ if (atts == null) {
ai = new AttributesImpl();
} else {
ai = new AttributesImpl(atts);
@@ -375,7 +378,7 @@
for (int i = 0; i < values.size(); i++) {
String value = (String) values.get(i);
- if ( value != null ) {
+ if (value != null) {
ch.startElement(namespace, "line", "line", new AttributesImpl());
ch.characters(value.toCharArray(), 0, value.length());
ch.endElement(namespace, "line", "line");
@@ -383,7 +386,5 @@
}
ch.endElement(namespace, "value", "value");
-
}
}
-
----------------------------------------------------------------------
In case of troubles, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]