MCPcopy Create free account
hub / github.com/apache/nutch / unreverseUrl

Method unreverseUrl

src/java/org/apache/nutch/util/TableUtil.java:87–108  ·  view source on GitHub ↗
(String reversedUrl)

Source from the content-addressed store, hash-verified

85 }
86
87 public static String unreverseUrl(String reversedUrl) {
88 StringBuilder buf = new StringBuilder(reversedUrl.length() + 2);
89
90 int pathBegin = reversedUrl.indexOf('/');
91 if (pathBegin == -1)
92 pathBegin = reversedUrl.length();
93 String sub = reversedUrl.substring(0, pathBegin);
94
95 // {<reversed host>, <port>, <protocol>}
96 String[] splits = StringUtils.splitPreserveAllTokens(sub, ':');
97
98 buf.append(splits[1]); // add protocol
99 buf.append("://");
100 reverseAppendSplits(splits[0], buf); // splits[0] is reversed
101 // host
102 if (splits.length == 3) { // has a port
103 buf.append(':');
104 buf.append(splits[2]);
105 }
106 buf.append(reversedUrl.substring(pathBegin));
107 return buf.toString();
108 }
109
110 /**
111 * Given a reversed url, returns the reversed host E.g

Callers 15

setUpMethod · 0.95
readContentsMethod · 0.95
assertUnreverseMethod · 0.95
mapMethod · 0.95
runMethod · 0.95
readMethod · 0.95
mapMethod · 0.95
indexMethod · 0.95
mapMethod · 0.95
pageAsMapMethod · 0.95
mapMethod · 0.95
mapMethod · 0.95

Calls 3

reverseAppendSplitsMethod · 0.95
appendMethod · 0.45
toStringMethod · 0.45

Tested by 3

setUpMethod · 0.76
readContentsMethod · 0.76
assertUnreverseMethod · 0.76