Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(684)

Side by Side Diff: java/org/chromium/distiller/ParsedUrl.java

Issue 1178633002: implement parser for new pagination algorithm (Closed) Base URL: https://github.com/chromium/dom-distiller.git@master
Patch Set: addr wychen's comments Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.distiller; 5 package org.chromium.distiller;
6 6
7 import com.google.gwt.core.client.JavaScriptObject; 7 import com.google.gwt.core.client.JavaScriptObject;
8 8
9 /** 9 /**
10 * Wraps a javascript URL object and its URLUtils properties, with additional me thods and instance 10 * Wraps a javascript URL object and its URLUtils properties, with additional me thods and instance
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 }-*/; 44 }-*/;
45 45
46 private final native String getUsername() /*-{ 46 private final native String getUsername() /*-{
47 return this.username; 47 return this.username;
48 }-*/; 48 }-*/;
49 49
50 private final native String getPassword() /*-{ 50 private final native String getPassword() /*-{
51 return this.password; 51 return this.password;
52 }-*/; 52 }-*/;
53 53
54 private final native String getHash() /*-{
55 return this.hash;
56 }-*/;
57
54 private final native String setUsername(String username) /*-{ 58 private final native String setUsername(String username) /*-{
55 this.username = username; 59 this.username = username;
56 }-*/; 60 }-*/;
57 61
58 private final native String setPassword(String password) /*-{ 62 private final native String setPassword(String password) /*-{
59 this.password = password; 63 this.password = password;
60 }-*/; 64 }-*/;
61 65
66 private final native String setHash(String hash) /*-{
67 this.hash = hash;
68 }-*/;
69
62 private final native String replaceQueryValue(String queryName, String c urrentQueryValue, 70 private final native String replaceQueryValue(String queryName, String c urrentQueryValue,
63 String newQueryValue) /*-{ 71 String newQueryValue) /*-{
64 return this.href.replace(queryName + "=" + currentQueryValue, 72 return this.href.replace(queryName + "=" + currentQueryValue,
65 queryName + "=" + newQueryValue); 73 queryName + "=" + newQueryValue);
66 }-*/; 74 }-*/;
67 75
68 /** 76 /**
69 * Returns pathname without leading and trailing '/'s and part after ';' . 77 * Returns pathname without leading and trailing '/'s and part after ';' .
70 * This is needed for ParsedUrl.getPathComponents(), and probably other callers. 78 * This is needed for ParsedUrl.getPathComponents(), and probably other callers.
71 */ 79 */
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 } 142 }
135 143
136 /** 144 /**
137 * Returns URLUtils.password. 145 * Returns URLUtils.password.
138 */ 146 */
139 public final String getPassword() { 147 public final String getPassword() {
140 return mUrl.getPassword(); 148 return mUrl.getPassword();
141 } 149 }
142 150
143 /** 151 /**
152 * Returns URLUtils.hash.
153 */
154 public final String getHash() {
155 return mUrl.getHash();
156 }
157
158 /**
159 /**
144 * Returns a array of components broken down from URLUtils.path without the part after ';'. 160 * Returns a array of components broken down from URLUtils.path without the part after ';'.
145 */ 161 */
146 public final String[] getPathComponents() { 162 public final String[] getPathComponents() {
147 if (mPathComponents == null) { 163 if (mPathComponents == null) {
148 String path = getTrimmedPath(); 164 String path = getTrimmedPath();
149 if (path.isEmpty()) { 165 if (path.isEmpty()) {
150 mPathComponents = new String[0]; 166 mPathComponents = new String[0];
151 } else { 167 } else {
152 mPathComponents = StringUtil.split(path, "\\/"); 168 mPathComponents = StringUtil.split(path, "\\/");
153 } 169 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 } 203 }
188 204
189 /** 205 /**
190 * Sets URLUtils.password. 206 * Sets URLUtils.password.
191 */ 207 */
192 public final String setPassword(String password) { 208 public final String setPassword(String password) {
193 return mUrl.setPassword(password); 209 return mUrl.setPassword(password);
194 } 210 }
195 211
196 /** 212 /**
213 * Sets URLUtils.hash.
214 */
215 public final String setHash(String hash) {
216 return mUrl.setHash(hash);
217 }
218
219 /**
197 * Replaces the specified name-value query parameter with the new query valu e. 220 * Replaces the specified name-value query parameter with the new query valu e.
198 * Returns the new HRef. The original HRef is not mutated. 221 * Returns the new HRef. The original HRef is not mutated.
199 */ 222 */
200 public final String replaceQueryValue(String queryName, String currentQueryV alue, 223 public final String replaceQueryValue(String queryName, String currentQueryV alue,
201 String newQueryValue) { 224 String newQueryValue) {
202 return mUrl.replaceQueryValue(queryName, currentQueryValue, newQueryValue ); 225 return mUrl.replaceQueryValue(queryName, currentQueryValue, newQueryValue );
203 } 226 }
204 227
205 @Override 228 @Override
206 public String toString() { 229 public String toString() {
207 return mUrl.toString(); 230 return mUrl.toString();
208 } 231 }
209 232
210 private ParsedUrl(Url url) { 233 private ParsedUrl(Url url) {
211 mUrl = url; 234 mUrl = url;
212 } 235 }
213 236
214 } 237 }
OLDNEW
« no previous file with comments | « java/org/chromium/distiller/PageParameterParser.java ('k') | javatests/org/chromium/distiller/PageParameterParserTest.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698