Implementing path.contains(obj)

This commit is contained in:
hns 2004-02-27 13:24:03 +00:00
parent e6da507d85
commit 5c8d774f47
2 changed files with 24 additions and 1 deletions

View file

@ -131,5 +131,15 @@ public class RequestPath {
return buffer.toString();
}
/**
* Checks if the given object is contained in the request path
*
* @param obj the element to check
* @return the index of the element, or -1 if it isn't contained
*/
public int contains(Object obj) {
return objects.indexOf(obj);
}
}

View file

@ -43,7 +43,8 @@ public class PathWrapper extends ScriptableObject {
setParentScope(core.getScope());
setPrototype(null);
defineProperty("length", PathWrapper.class, attributes);
defineFunctionProperties(new String[] {"href"}, PathWrapper.class, attributes);
defineFunctionProperties(new String[] {"href", "contains"},
PathWrapper.class, attributes);
}
/**
@ -125,6 +126,18 @@ public class PathWrapper extends ScriptableObject {
return path.href(null);
}
/**
* Checks if the given object is contained in the request path
*
* @param obj the element to check
* @return the index of the element, or -1 if it isn't contained
*/
public int contains(Object obj) {
if (obj instanceof Wrapper)
obj = ((Wrapper) obj).unwrap();
return path.contains(obj);
}
public String getClassName() {
return "[PathWrapper]";