PathMapping.java
1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* javax.jcr.Item
* javax.jcr.Node
* javax.jcr.Property
* javax.jcr.RepositoryException
*/
package com.day.crx.explorer.impl.j2ee.mapping;
import com.day.crx.explorer.impl.j2ee.mapping.AbstractMapping;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.jcr.Item;
import javax.jcr.Node;
import javax.jcr.Property;
import javax.jcr.RepositoryException;
public class PathMapping
extends AbstractMapping {
public static final String CRX_PATH_REQUEST_MAPPING = "crx:PathRequestMapping";
public static final String CRX_PATTERN = "crx:pattern";
private final Pattern pattern;
public PathMapping(Node def) throws RepositoryException {
super(def);
assert (def.isNodeType("crx:PathRequestMapping"));
String p = def.getProperty("crx:pattern").getString();
if (p.endsWith("//")) {
p = p.substring(0, p.length() - 2) + "(/.*)?";
}
this.pattern = Pattern.compile(p);
}
public String toString() {
return this.pattern + super.toString();
}
public boolean contains(Item i) throws RepositoryException {
if (!i.isNode() && !this.isIncludeProps()) {
return false;
}
return this.pattern.matcher(i.getPath()).matches();
}
}