use of android.net.ParseException in project platform_frameworks_base by android.
the class URLUtil method guessUrl.
/**
* Cleans up (if possible) user-entered web addresses
*/
public static String guessUrl(String inUrl) {
String retVal = inUrl;
WebAddress webAddress;
if (TRACE)
Log.v(LOGTAG, "guessURL before queueRequest: " + inUrl);
if (inUrl.length() == 0)
return inUrl;
if (inUrl.startsWith("about:"))
return inUrl;
// Do not try to interpret data scheme URLs
if (inUrl.startsWith("data:"))
return inUrl;
// Do not try to interpret file scheme URLs
if (inUrl.startsWith("file:"))
return inUrl;
// Do not try to interpret javascript scheme URLs
if (inUrl.startsWith("javascript:"))
return inUrl;
// bug 762454: strip period off end of url
if (inUrl.endsWith(".") == true) {
inUrl = inUrl.substring(0, inUrl.length() - 1);
}
try {
webAddress = new WebAddress(inUrl);
} catch (ParseException ex) {
if (TRACE) {
Log.v(LOGTAG, "smartUrlFilter: failed to parse url = " + inUrl);
}
return retVal;
}
// Check host
if (webAddress.getHost().indexOf('.') == -1) {
// no dot: user probably entered a bare domain. try .com
webAddress.setHost("www." + webAddress.getHost() + ".com");
}
return webAddress.toString();
}
use of android.net.ParseException in project android_frameworks_base by AOSPA.
the class URLUtil method guessUrl.
/**
* Cleans up (if possible) user-entered web addresses
*/
public static String guessUrl(String inUrl) {
String retVal = inUrl;
WebAddress webAddress;
if (TRACE)
Log.v(LOGTAG, "guessURL before queueRequest: " + inUrl);
if (inUrl.length() == 0)
return inUrl;
if (inUrl.startsWith("about:"))
return inUrl;
// Do not try to interpret data scheme URLs
if (inUrl.startsWith("data:"))
return inUrl;
// Do not try to interpret file scheme URLs
if (inUrl.startsWith("file:"))
return inUrl;
// Do not try to interpret javascript scheme URLs
if (inUrl.startsWith("javascript:"))
return inUrl;
// bug 762454: strip period off end of url
if (inUrl.endsWith(".") == true) {
inUrl = inUrl.substring(0, inUrl.length() - 1);
}
try {
webAddress = new WebAddress(inUrl);
} catch (ParseException ex) {
if (TRACE) {
Log.v(LOGTAG, "smartUrlFilter: failed to parse url = " + inUrl);
}
return retVal;
}
// Check host
if (webAddress.getHost().indexOf('.') == -1) {
// no dot: user probably entered a bare domain. try .com
webAddress.setHost("www." + webAddress.getHost() + ".com");
}
return webAddress.toString();
}
use of android.net.ParseException in project XobotOS by xamarin.
the class BrowserFrame method maybeSavePassword.
/**
* If this looks like a POST request (form submission) containing a username
* and password, give the user the option of saving them. Will either do
* nothing, or block until the UI interaction is complete.
*
* Called by startLoadingResource when using the Apache HTTP stack.
* Called directly by WebKit when using the Chrome HTTP stack.
*
* @param postData The data about to be sent as the body of a POST request.
* @param username The username entered by the user (sniffed from the DOM).
* @param password The password entered by the user (sniffed from the DOM).
*/
private void maybeSavePassword(byte[] postData, String username, String password) {
if (postData == null || username == null || username.isEmpty() || password == null || password.isEmpty()) {
// No password to save.
return;
}
if (!mSettings.getSavePassword()) {
// User doesn't want to save passwords.
return;
}
try {
if (DebugFlags.BROWSER_FRAME) {
Assert.assertNotNull(mCallbackProxy.getBackForwardList().getCurrentItem());
}
WebAddress uri = new WebAddress(mCallbackProxy.getBackForwardList().getCurrentItem().getUrl());
String schemePlusHost = uri.getScheme() + uri.getHost();
// Check to see if the username & password appear in
// the post data (there could be another form on the
// page and that was posted instead.
String postString = new String(postData);
if (postString.contains(URLEncoder.encode(username)) && postString.contains(URLEncoder.encode(password))) {
String[] saved = mDatabase.getUsernamePassword(schemePlusHost);
if (saved != null) {
// save password
if (saved[0] != null) {
// non-null username implies that user has
// chosen to save password, so update the
// recorded password
mDatabase.setUsernamePassword(schemePlusHost, username, password);
}
} else {
// CallbackProxy will handle creating the resume
// message
mCallbackProxy.onSavePassword(schemePlusHost, username, password, null);
}
}
} catch (ParseException ex) {
// if it is bad uri, don't save its password
}
}
use of android.net.ParseException in project android_frameworks_base by ResurrectionRemix.
the class URLUtil method guessUrl.
/**
* Cleans up (if possible) user-entered web addresses
*/
public static String guessUrl(String inUrl) {
String retVal = inUrl;
WebAddress webAddress;
if (TRACE)
Log.v(LOGTAG, "guessURL before queueRequest: " + inUrl);
if (inUrl.length() == 0)
return inUrl;
if (inUrl.startsWith("about:"))
return inUrl;
// Do not try to interpret data scheme URLs
if (inUrl.startsWith("data:"))
return inUrl;
// Do not try to interpret file scheme URLs
if (inUrl.startsWith("file:"))
return inUrl;
// Do not try to interpret javascript scheme URLs
if (inUrl.startsWith("javascript:"))
return inUrl;
// bug 762454: strip period off end of url
if (inUrl.endsWith(".") == true) {
inUrl = inUrl.substring(0, inUrl.length() - 1);
}
try {
webAddress = new WebAddress(inUrl);
} catch (ParseException ex) {
if (TRACE) {
Log.v(LOGTAG, "smartUrlFilter: failed to parse url = " + inUrl);
}
return retVal;
}
// Check host
if (webAddress.getHost().indexOf('.') == -1) {
// no dot: user probably entered a bare domain. try .com
webAddress.setHost("www." + webAddress.getHost() + ".com");
}
return webAddress.toString();
}
use of android.net.ParseException in project smartmodule by carozhu.
the class DateUtil method compareTime.
/**
* 比较时间
*
* @return true courseTime 大于当前时间
*/
public boolean compareTime(String curTime, String courseTime) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.CHINA);
boolean boo = true;
try {
try {
boo = sdf.parse(courseTime).getTime() - sdf.parse(curTime).getTime() > 0;
} catch (java.text.ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return boo;
}
Aggregations