tcurdt 2002/10/08 10:21:59
Modified: src/java/org/apache/cocoon/components/treeprocessor/variables
PreparedVariableResolver.java
Log:
added support for root path sitemap variables {/1},
fixed a disposal bug
Revision Changes Path
1.4 +34 -10
xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/variables/PreparedVariableResolver.java
Index: PreparedVariableResolver.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/variables/PreparedVariableResolver.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- PreparedVariableResolver.java 29 Sep 2002 20:24:22 -0000 1.3
+++ PreparedVariableResolver.java 8 Oct 2002 17:21:59 -0000 1.4
@@ -76,7 +76,7 @@
private List items = new ArrayList();
// Special constants used for levels
- // later : final int ROOT_VAR = 0;
+ static final int ROOT = 0;
static final int LITERAL = -1;
static final int THREADSAFE_MODULE = -2;
static final int STATEFUL_MODULE = -3;
@@ -148,15 +148,21 @@
}
private void addSitemapVariable(String variable) {
- // Find level
- int level = 1; // Start at 1 since it will be substracted from list.size()
- int pos = 0;
- while(variable.startsWith("../", pos)) {
- level++;
- pos += "../".length();
+ if (variable.startsWith("/")) {
+ this.items.add(new Integer(ROOT));
+ this.items.add(variable.substring(1));
+ }
+ else {
+ // Find level
+ int level = 1; // Start at 1 since it will be substracted from
list.size()
+ int pos = 0;
+ while (variable.startsWith("../", pos)) {
+ level++;
+ pos += "../".length();
+ }
+ this.items.add(new Integer(level));
+ this.items.add(variable.substring(pos));
}
- this.items.add(new Integer(level));
- this.items.add(variable.substring(pos));
}
private void addModuleVariable(String moduleName, String variable) throws
PatternException {
@@ -219,7 +225,17 @@
case LITERAL :
result.append(items.get(++i));
break;
-
+
+ case ROOT :
+ {
+ Object key = this.items.get(++i);
+ Object value = ((Map)mapStack.get(0)).get(key);
+ if (value != null) {
+ result.append(value);
+ }
+ }
+ break;
+
case THREADSAFE_MODULE :
{
InputModule module = (InputModule)items.get(++i);
@@ -284,6 +300,10 @@
int type = ((Integer)this.items.get(i)).intValue();
switch(type) {
+ case ROOT :
+ i++; // variable
+ break;
+
case LITERAL :
i++; // literal string
break;
@@ -297,6 +317,10 @@
case STATEFUL_MODULE :
i += 2; // module name, variable
break;
+
+ default:
+ // relative sitemap variable
+ i++; // variable
}
}
----------------------------------------------------------------------
In case of troubles, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]