stephan 2002/08/20 09:25:34 Modified: src/scratchpad/src/org/apache/cocoon/generation SourceDescriptionGenerator.java Log: Increase speed by build prebuild qnames. Make revision information optional. Revision Changes Path 1.12 +31 -38 xml-cocoon2/src/scratchpad/src/org/apache/cocoon/generation/SourceDescriptionGenerator.java Index: SourceDescriptionGenerator.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/scratchpad/src/org/apache/cocoon/generation/SourceDescriptionGenerator.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- SourceDescriptionGenerator.java 19 Aug 2002 17:32:15 -0000 1.11 +++ SourceDescriptionGenerator.java 20 Aug 2002 16:25:34 -0000 1.12 @@ -110,6 +110,7 @@ private static final String SOURCE_PREFIX = "source"; private static final String SOURCE_NODE_NAME = "source"; + private static final String SOURCE_NODE_QNAME = SOURCE_PREFIX+":"+SOURCE_NODE_NAME; private static final String NAME_ATTR_NAME = "name"; private static final String SYSTEMID_ATTR_NAME = "systemid"; @@ -122,15 +123,21 @@ private static final String REVISIONBRANCH_ATTR_NAME = "branch"; private static final String PROPERTIES_NODE_NAME = "properties"; + private static final String PROPERTIES_NODE_QNAME = SOURCE_PREFIX+":"+PROPERTIES_NODE_NAME; private static final String PROPERTY_TYPE_ATTR_NAME = "type"; private static final String PERMISSIONS_NODE_NAME = "permissions"; + private static final String PERMISSIONS_NODE_QNAME = SOURCE_PREFIX+":"+PERMISSIONS_NODE_NAME; private static final String PERMISSION_NODE_NAME = "permission"; + private static final String PERMISSION_NODE_QNAME = SOURCE_PREFIX+":"+PERMISSION_NODE_NAME; private static final String LOCKS_NODE_NAME = "locks"; + private static final String LOCKS_NODE_QNAME = SOURCE_PREFIX+":"+LOCKS_NODE_NAME; private static final String LOCK_NODE_NAME = "lock"; + private static final String LOCK_NODE_QNAME = SOURCE_PREFIX+":"+LOCK_NODE_NAME; private static final String CHILDREN_NODE_NAME = "children"; + private static final String CHILDREN_NODE_QNAME = SOURCE_PREFIX+":"+CHILDREN_NODE_NAME; private static final String PRINCIPAL_ATTR_NAME = "principal"; private static final String GROUP_ATTR_NAME = "group"; @@ -151,6 +158,9 @@ /** Include locks into the description */ private boolean locks = true; + /** Include version into the description */ + private boolean version = true; + /** How deep the generator traverse the source */ private int deep = 1; @@ -165,8 +175,7 @@ this.properties = parameters.getParameterAsBoolean("properties", true); this.permissions = parameters.getParameterAsBoolean("permissions", true); this.locks = parameters.getParameterAsBoolean("locks", true); - - this.deep = parameters.getParameterAsInteger("deep", 1); + this.version = parameters.getParameterAsBoolean("version", true); } /** @@ -296,7 +305,7 @@ attributes.addAttribute(SOURCE_NS, LASTMODIFIED_ATTR_NAME, LASTMODIFIED_ATTR_NAME, "CDATA", String.valueOf(source.getLastModified())); - if (source instanceof VersionableSource) { + if (this.version && (source instanceof VersionableSource)) { VersionableSource versionablesource = (VersionableSource)source; if (versionablesource.isVersioned()) { if ((versionablesource.getSourceRevision()!=null) && @@ -327,10 +336,9 @@ parent); } - this.contentHandler.startElement(SOURCE_NS, SOURCE_NODE_NAME, - SOURCE_PREFIX+":"+SOURCE_NODE_NAME, attributes); + this.contentHandler.startElement(SOURCE_NS, SOURCE_NODE_NAME, SOURCE_NODE_QNAME, attributes); - if ((source instanceof InspectableSource) && this.properties) + if (this.properties && (source instanceof InspectableSource)) pushLiveSourceProperties((InspectableSource)source); if (this.properties) @@ -346,12 +354,11 @@ } } - if ((source instanceof LockableSource) && this.locks) + if (this.locks && (source instanceof LockableSource)) pushSourceLocks((LockableSource)source); if ((isCollection) && (deep>0)) { - this.contentHandler.startElement(SOURCE_NS, CHILDREN_NODE_NAME, - SOURCE_PREFIX+":"+CHILDREN_NODE_NAME, new AttributesImpl()); + this.contentHandler.startElement(SOURCE_NS, CHILDREN_NODE_NAME, CHILDREN_NODE_QNAME, new AttributesImpl()); for(int i=0; i<traversablesource.getChildSourceCount(); i++) { try { pushSourceDescription(traversablesource.getChildSource(i), deep-1); @@ -360,12 +367,10 @@ getLogger().debug("Could not retrieve source", se); } } - this.contentHandler.endElement(SOURCE_NS, SOURCE_NODE_NAME, - SOURCE_PREFIX+":"+SOURCE_NODE_NAME); + this.contentHandler.endElement(SOURCE_NS, SOURCE_NODE_NAME, SOURCE_NODE_QNAME); } - this.contentHandler.endElement(SOURCE_NS, SOURCE_NODE_NAME, - SOURCE_PREFIX+":"+SOURCE_NODE_NAME); + this.contentHandler.endElement(SOURCE_NS, SOURCE_NODE_NAME, SOURCE_NODE_QNAME); } catch (SAXException saxe) { throw saxe; @@ -381,8 +386,7 @@ AttributesImpl attributes = new AttributesImpl(); attributes.addAttribute(SOURCE_NS, PROPERTY_TYPE_ATTR_NAME, PROPERTY_TYPE_ATTR_NAME, "CDATA", "live"); - this.contentHandler.startElement(SOURCE_NS, PROPERTIES_NODE_NAME, - SOURCE_PREFIX+":"+PROPERTIES_NODE_NAME, attributes); + this.contentHandler.startElement(SOURCE_NS, PROPERTIES_NODE_NAME, PROPERTIES_NODE_QNAME, attributes); IncludeXMLConsumer consumer = new IncludeXMLConsumer(this.contentHandler); for (int i=0; i<properties.length; i++) { @@ -393,16 +397,14 @@ this.contentHandler.endPrefixMapping(""); } - this.contentHandler.endElement(SOURCE_NS, PROPERTIES_NODE_NAME, - SOURCE_PREFIX+":"+PROPERTIES_NODE_NAME); + this.contentHandler.endElement(SOURCE_NS, PROPERTIES_NODE_NAME, PROPERTIES_NODE_QNAME); } private void pushComputedSourceProperties(Source source) throws SAXException, SourceException { AttributesImpl attributes = new AttributesImpl(); attributes.addAttribute(SOURCE_NS, PROPERTY_TYPE_ATTR_NAME, PROPERTY_TYPE_ATTR_NAME, "CDATA", "computed"); - this.contentHandler.startElement(SOURCE_NS, PROPERTIES_NODE_NAME, - SOURCE_PREFIX+":"+PROPERTIES_NODE_NAME, attributes); + this.contentHandler.startElement(SOURCE_NS, PROPERTIES_NODE_NAME, PROPERTIES_NODE_QNAME, attributes); SourceInspector inspector = null; try { @@ -419,8 +421,7 @@ this.manager.release(inspector); } - this.contentHandler.endElement(SOURCE_NS, PROPERTIES_NODE_NAME, - SOURCE_PREFIX+":"+PROPERTIES_NODE_NAME); + this.contentHandler.endElement(SOURCE_NS, PROPERTIES_NODE_NAME, PROPERTIES_NODE_QNAME); } private void pushSourcePermissions(RestrictableSource source) throws SAXException, SourceException { @@ -428,8 +429,7 @@ if ((permissions!=null) && (permissions.length>0)) { - this.contentHandler.startElement(SOURCE_NS, PERMISSIONS_NODE_NAME, - SOURCE_PREFIX+':'+PERMISSIONS_NODE_NAME, new AttributesImpl()); + this.contentHandler.startElement(SOURCE_NS, PERMISSIONS_NODE_NAME, PERMISSIONS_NODE_QNAME, new AttributesImpl()); for(int i=0; i<permissions.length; i++) { @@ -449,14 +449,11 @@ attributes.addAttribute("", NEGATIVE_ATTR_NAME, NEGATIVE_ATTR_NAME, "CDATA", String.valueOf(permissions[i].isNegative())); - this.contentHandler.startElement(SOURCE_NS, PERMISSION_NODE_NAME, - SOURCE_PREFIX+':'+PERMISSION_NODE_NAME, attributes); - this.contentHandler.endElement(SOURCE_NS, PERMISSION_NODE_NAME, - SOURCE_PREFIX+':'+PERMISSION_NODE_NAME); + this.contentHandler.startElement(SOURCE_NS, PERMISSION_NODE_NAME, PERMISSION_NODE_QNAME, attributes); + this.contentHandler.endElement(SOURCE_NS, PERMISSION_NODE_NAME, PERMISSION_NODE_QNAME); } - this.contentHandler.endElement(SOURCE_NS, PERMISSIONS_NODE_NAME, - SOURCE_PREFIX+':'+PERMISSIONS_NODE_NAME); + this.contentHandler.endElement(SOURCE_NS, PERMISSIONS_NODE_NAME, PERMISSIONS_NODE_QNAME); } } @@ -466,8 +463,7 @@ if (locks.hasMoreElements()) { - this.contentHandler.startElement(SOURCE_NS, LOCKS_NODE_NAME, - SOURCE_PREFIX+':'+LOCKS_NODE_NAME, new AttributesImpl()); + this.contentHandler.startElement(SOURCE_NS, LOCKS_NODE_NAME, LOCKS_NODE_QNAME, new AttributesImpl()); while (locks.hasMoreElements()) { @@ -486,15 +482,12 @@ attributes.addAttribute("", EXCLUSIVE_ATTR_NAME, EXCLUSIVE_ATTR_NAME, "CDATA", String.valueOf(lock.isExclusive())); - this.contentHandler.startElement(SOURCE_NS, LOCK_NODE_NAME, - SOURCE_PREFIX+':'+LOCK_NODE_NAME, attributes); - this.contentHandler.endElement(SOURCE_NS, LOCK_NODE_NAME, - SOURCE_PREFIX+':'+LOCK_NODE_NAME); + this.contentHandler.startElement(SOURCE_NS, LOCK_NODE_NAME, LOCK_NODE_QNAME, attributes); + this.contentHandler.endElement(SOURCE_NS, LOCK_NODE_NAME, LOCK_NODE_QNAME); } - this.contentHandler.endElement(SOURCE_NS, LOCKS_NODE_NAME, - SOURCE_PREFIX+':'+LOCKS_NODE_NAME); + this.contentHandler.endElement(SOURCE_NS, LOCKS_NODE_NAME, LOCKS_NODE_QNAME); } } }
---------------------------------------------------------------------- In case of troubles, e-mail: [EMAIL PROTECTED] To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]