antonio 2004/04/02 16:46:33
Modified: src/java/org/apache/cocoon/components/pipeline/impl AbstractCachingProcessingPipeline.java src/blocks/qdox/java/org/apache/cocoon/components/source/impl QDoxSourceFactory.java QDoxSource.java src/blocks/chaperon/java/org/apache/cocoon/generation TextGenerator.java Log: using o.a.commons.lang
Index: QDoxSourceFactory.java
===================================================================
- String className = location.substring(location.indexOf(':') + 1);
+ String className = StringUtils.substringAfter(location, ":");
Index: QDoxSource.java
===================================================================
private String resolveMemberNameFromLink(String ref) {
- int hashIndex = ref.indexOf('#');
- if (hashIndex < 0) {
- return "";
- } else {
- return ref.substring(hashIndex + 1);
- }
+ return StringUtils.substringAfter(ref, "#");
Still no sleep, Antonio?
One of the above must obviously be wrong IMO as it changes the behaviour in comparison to the original code. From commons lang JavaDoc I guess it's the QDoxSourceFactory change:
http://jakarta.apache.org/commons/lang/api/org/apache/commons/lang/StringUtils.html#substringAfter(java.lang.String,%20java.lang.String)
If the second argument of substringAfter() is not found in the first argument, the function returns an empty string. This is why you can replace 6 lines in QDoxSource with one line.
But for the original code of QDoxSourceFactory this did not happen. If there is no ':' in location, className would be location (location.indexOf(':') = -1), now it is empty string. And there it also makes not much sense to introduce dependency on another library as it saves only 3 chars.
Joerg
