1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.vfs; |
21 |
|
|
22 |
|
import java.net.URI; |
23 |
|
import java.util.ArrayList; |
24 |
|
import java.util.Arrays; |
25 |
|
import java.util.List; |
26 |
|
|
27 |
|
import org.apache.commons.lang3.StringUtils; |
28 |
|
import org.apache.commons.lang3.builder.EqualsBuilder; |
29 |
|
import org.apache.commons.lang3.builder.HashCodeBuilder; |
30 |
|
import org.apache.commons.lang3.builder.ToStringBuilder; |
31 |
|
import org.xwiki.resource.AbstractResourceReference; |
32 |
|
import org.xwiki.resource.ResourceType; |
33 |
|
import org.xwiki.text.XWikiToStringBuilder; |
34 |
|
|
35 |
|
|
36 |
|
|
37 |
|
|
38 |
|
@version |
39 |
|
@since |
40 |
|
|
|
|
| 84.6% |
Uncovered Elements: 6 (39) |
Complexity: 13 |
Complexity Density: 0.57 |
|
41 |
|
public class VfsResourceReference extends AbstractResourceReference |
42 |
|
{ |
43 |
|
|
44 |
|
|
45 |
|
|
46 |
|
public static final ResourceType TYPE = new ResourceType("vfs"); |
47 |
|
|
48 |
|
private static final String RESOURCE_PATH_SEPARATOR = "/"; |
49 |
|
|
50 |
|
private URI uri; |
51 |
|
|
52 |
|
private List<String> pathSegments; |
53 |
|
|
54 |
|
|
55 |
|
@param |
56 |
|
|
57 |
|
@param@link |
58 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
59 |
37 |
public VfsResourceReference(URI uri, List<String> pathSegments)... |
60 |
|
{ |
61 |
37 |
setType(TYPE); |
62 |
37 |
this.uri = uri; |
63 |
37 |
this.pathSegments = new ArrayList<>(pathSegments); |
64 |
|
} |
65 |
|
|
66 |
|
|
67 |
|
@param |
68 |
|
|
69 |
|
@param@link |
70 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
71 |
33 |
public VfsResourceReference(URI uri, String pathSegments)... |
72 |
|
{ |
73 |
33 |
this(uri, Arrays.asList(StringUtils.split(pathSegments, RESOURCE_PATH_SEPARATOR))); |
74 |
|
} |
75 |
|
|
76 |
|
|
77 |
|
@param |
78 |
|
|
79 |
|
|
80 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
81 |
12 |
public VfsResourceReference(URI fullURI)... |
82 |
|
{ |
83 |
|
|
84 |
12 |
this(URI.create(StringUtils.substringBefore(fullURI.toString(), RESOURCE_PATH_SEPARATOR)), |
85 |
|
StringUtils.substringAfter(fullURI.toString(), RESOURCE_PATH_SEPARATOR)); |
86 |
|
} |
87 |
|
|
88 |
|
|
89 |
|
@return |
90 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
91 |
62 |
public URI getURI()... |
92 |
|
{ |
93 |
62 |
return this.uri; |
94 |
|
} |
95 |
|
|
96 |
|
|
97 |
|
@return |
98 |
|
|
99 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
100 |
34 |
public List<String> getPathSegments()... |
101 |
|
{ |
102 |
34 |
return this.pathSegments; |
103 |
|
} |
104 |
|
|
105 |
|
|
106 |
|
@return |
107 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
108 |
10 |
public String getPath()... |
109 |
|
{ |
110 |
10 |
return StringUtils.join(getPathSegments(), RESOURCE_PATH_SEPARATOR); |
111 |
|
} |
112 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
113 |
2 |
@Override... |
114 |
|
public int hashCode() |
115 |
|
{ |
116 |
2 |
return new HashCodeBuilder(7, 7) |
117 |
|
.append(getURI()) |
118 |
|
.append(getPathSegments()) |
119 |
|
.append(getType()) |
120 |
|
.append(getParameters()) |
121 |
|
.toHashCode(); |
122 |
|
} |
123 |
|
|
|
|
| 57.1% |
Uncovered Elements: 6 (14) |
Complexity: 4 |
Complexity Density: 0.5 |
|
124 |
8 |
@Override... |
125 |
|
public boolean equals(Object object) |
126 |
|
{ |
127 |
8 |
if (object == null) { |
128 |
0 |
return false; |
129 |
|
} |
130 |
8 |
if (object == this) { |
131 |
0 |
return true; |
132 |
|
} |
133 |
8 |
if (object.getClass() != getClass()) { |
134 |
0 |
return false; |
135 |
|
} |
136 |
8 |
VfsResourceReference rhs = (VfsResourceReference) object; |
137 |
8 |
return new EqualsBuilder() |
138 |
|
.append(getURI(), rhs.getURI()) |
139 |
|
.append(getPathSegments(), rhs.getPathSegments()) |
140 |
|
.append(getType(), rhs.getType()) |
141 |
|
.append(getParameters(), rhs.getParameters()) |
142 |
|
.isEquals(); |
143 |
|
} |
144 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
145 |
3 |
@Override... |
146 |
|
public String toString() |
147 |
|
{ |
148 |
3 |
ToStringBuilder builder = new XWikiToStringBuilder(this); |
149 |
3 |
builder.append("uri", getURI()); |
150 |
3 |
builder.append("path", getPath()); |
151 |
3 |
builder.append("parameters", getParameters()); |
152 |
3 |
return builder.toString(); |
153 |
|
} |
154 |
|
|
155 |
|
|
156 |
|
@return |
157 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
158 |
1 |
public URI toURI()... |
159 |
|
{ |
160 |
1 |
return URI.create(String.format("%s/%s", getURI().toString(), getPath())); |
161 |
|
} |
162 |
|
} |