vgritsenko 2002/10/21 20:53:45 Modified: src/java/org/apache/cocoon/generation Tag: cocoon_2_0_3_branch StatusGenerator.java Log: Fix xlink attributes generation. Revision Changes Path No revision No revision 1.5.2.1 +33 -30 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.5 retrieving revision 1.5.2.1 diff -u -r1.5 -r1.5.2.1 --- StatusGenerator.java 22 Feb 2002 07:03:51 -0000 1.5 +++ StatusGenerator.java 22 Oct 2002 03:53:45 -0000 1.5.2.1 @@ -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> @@ -98,21 +99,29 @@ */ public class StatusGenerator extends ComposerGenerator { - /** The StoreJanitor used to get cache statistics + /** + * The StoreJanitor used to get cache statistics */ protected StoreJanitor storejanitor; - /** 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 @@ -135,12 +144,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(); } @@ -192,8 +201,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); @@ -221,11 +231,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 @@ -236,33 +247,27 @@ 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); // END Cache @@ -278,7 +283,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); @@ -300,7 +305,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); @@ -309,7 +314,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()); } @@ -325,7 +330,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); @@ -335,7 +340,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"); @@ -343,7 +348,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]