Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Handle line endings automatically for files detected as text
# and leave all files detected as binary untouched.
* text=auto

#
# The above will handle all files NOT found below
#
# These files are text and should be normalized (Convert crlf => lf)
*.css text
*.df text
*.java text
*.js text
*.json text
*.jsp text
*.properties text
*.sql text
*.svg text
*.tld text
*.txt text
*.xml text

# These files are binary and should be left untouched
# (binary is a macro for -text -diff)
*.dll binary
*.gif binary
*.ico binary
*.jar binary
*.png binary
*.so binary

25 changes: 25 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/target/
/tiles-api/target/
/tiles-core/target/
/tiles-template/target/
/tiles-servlet/target/
/tiles-jsp/target/
/tiles-freemarker/target/
/tiles-velocity/target/
/tiles-el/target/
/tiles-ognl/target/
/tiles-mvel/target/
/tiles-compat/target/
/tiles-extras/target/
/tiles-test-pom/tiles-test-db/target/
/tiles-test-pom/tiles-test-alt/target/
/tiles-test-pom/target/
/tiles-test-pom/tiles-test-common/target/
/tiles-test-pom/tiles-test/target/
/assembly/target/
*~
*.bak
*.swp
*.log
.DS_Store
pom.xml.versionsBackup
2 changes: 1 addition & 1 deletion tiles-api/src/main/java/org/apache/tiles/Attribute.java
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ public String toString() {
if (value != null) {
return value.toString();
}
return null;
return "null";
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public void testToString() {
roles.add("role2");
assertEquals("my.value", attribute.toString());
attribute.setValue(null);
assertNull(attribute.toString());
assertEquals(attribute.toString(), "null");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,18 @@
* specific language governing permissions and limitations
* under the License.
*/

package org.apache.tiles.evaluator;

import java.util.ArrayList;
import java.util.List;
import org.apache.tiles.Attribute;
import org.apache.tiles.Expression;
import org.apache.tiles.ListAttribute;
import org.apache.tiles.request.Request;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


/**
* Abstract class to link a correct evaluation of an attribute, by evaluating
Expand All @@ -33,7 +40,10 @@
*/
public abstract class AbstractAttributeEvaluator implements AttributeEvaluator {

private static final Logger log = LoggerFactory.getLogger(AbstractAttributeEvaluator.class);

/** {@inheritDoc} */
@Override
public Object evaluate(Attribute attribute, Request request) {
if (attribute == null) {
throw new IllegalArgumentException("The attribute cannot be null");
Expand All @@ -44,11 +54,49 @@ public Object evaluate(Attribute attribute, Request request) {
if (retValue == null) {
Expression expression = attribute.getExpressionObject();
if (expression != null) {
log.debug("Evaluating expression: [attribute={},expression={}]", attribute, expression);
retValue = evaluate(attribute.getExpressionObject()
.getExpression(), request);
}
} else if (retValue instanceof List) {
log.debug("Evaluating list for expressions: {}", retValue);
retValue = evaluateList((List) retValue, request);
}

log.debug("Returning result: {}", retValue);
return retValue;
}

private List evaluateList(List src, Request request) {
List res = new ArrayList();
for (Object val : src) {
if (val instanceof ListAttribute) {
log.debug("Evaluating list entry (ListAttribute): {}", val);
res.add(evaluateList(((ListAttribute) val).getValue(), request));
} else if (val instanceof Attribute) {
log.debug("Evaluating list entry (Attribute): {}", val);
Attribute att = (Attribute) val;
if (att.getValue() != null) {
res.add(att.getValue() instanceof List
? evaluateList((List) att.getValue(), request)
: att);
} else {
Expression expression = att.getExpressionObject();
if (expression != null) {
log.debug("Evaluating list entry expression: {}", expression);
att = att.clone();
att.setValue(evaluate(expression.getExpression(), request));
res.add(att);
} else {
res.add(att);
}
}
} else {
log.debug("Evaluating list entry ({}): {}", val.getClass(), val);
res.add(val);
}
}
return res;
}

}