vgritsenko 02/04/19 16:54:21 Modified: src/java/org/apache/cocoon/environment AbstractEnvironment.java Log: remove extra toString() Revision Changes Path 1.14 +18 -17 xml-cocoon2/src/java/org/apache/cocoon/environment/AbstractEnvironment.java Index: AbstractEnvironment.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/environment/AbstractEnvironment.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- AbstractEnvironment.java 19 Apr 2002 11:02:57 -0000 1.13 +++ AbstractEnvironment.java 19 Apr 2002 23:54:21 -0000 1.14 @@ -70,7 +70,7 @@ * * @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a> * @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a> - * @version CVS $Id: AbstractEnvironment.java,v 1.13 2002/04/19 11:02:57 cziegeler Exp $ + * @version CVS $Id: AbstractEnvironment.java,v 1.14 2002/04/19 23:54:21 vgritsenko Exp $ */ public abstract class AbstractEnvironment extends AbstractLoggable implements Environment { @@ -241,15 +241,16 @@ getLogger().debug(" to context(" + newContext + ") and prefix(" + prefix + ")"); getLogger().debug(" at URI " + this.uris); } - if (prefix.length() >= 1 && !this.uris.startsWith(prefix)) { - String message = "The current URI (" + this.uris + - ") doesn't start with given prefix (" + prefix + ")"; - getLogger().error(message); - throw new RuntimeException(message); - } - if (prefix.length() >= 1) { + int l = prefix.length(); + if (l >= 1) { + if (!this.uris.startsWith(prefix)) { + String message = "The current URI (" + this.uris + + ") doesn't start with given prefix (" + prefix + ")"; + getLogger().error(message); + throw new RuntimeException(message); + } this.prefix.append(prefix); - this.uris = this.uris.substring(prefix.length()); + this.uris = this.uris.substring(l); // check for a slash at the beginning to avoid problems with subsitemaps if (this.uris.startsWith("/")) { @@ -264,25 +265,25 @@ getLogger().debug("Base context is zip: " + this.context); this.context = new URL(this.context.toString() + newContext); } else { + String sContext; // if we got a absolute context or one with a protocol resolve it if (newContext.charAt(0) == '/') { // context starts with the '/' - absolute file URL - this.context = new URL("file:" + newContext); + sContext = "file:" + newContext; } else if (newContext.indexOf(':') > 1) { // context have ':' - absolute URL - this.context = new URL(newContext); + sContext = newContext; } else { // context is relative to old one - this.context = new URL(this.context, newContext); + sContext = new URL(this.context, newContext).toString(); } // Cut the file name part from context (if present) - String s = this.context.toString(); - int i = s.lastIndexOf('/'); - if (i != -1 && i + 1 < s.length()) { - s = s.substring(0, i + 1); + int i = sContext.lastIndexOf('/'); + if (i != -1 && i + 1 < sContext.length()) { + sContext = sContext.substring(0, i + 1); } - this.context = new URL(s); + this.context = new URL(sContext); } if (getLogger().isDebugEnabled()) {
---------------------------------------------------------------------- In case of troubles, e-mail: [EMAIL PROTECTED] To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]