1 package org.lobobrowser.html.test; 2 3 import java.security.Policy ; 4 import java.util.logging.*; 5 6 import org.lobobrowser.html.HttpRequest; 7 import org.lobobrowser.html.UserAgentContext; 8 9 12 public class SimpleUserAgentContext implements UserAgentContext { 13 private static final Logger logger = Logger.getLogger(SimpleUserAgentContext.class.getName()); 14 15 19 public HttpRequest createHttpRequest() { 20 return new SimpleHttpRequest(this); 21 } 22 23 public void warn(String message, Throwable throwable) { 24 if(logger.isLoggable(Level.WARNING)) { 25 logger.log(Level.WARNING, message, throwable); 26 } 27 } 28 29 public void error(String message, Throwable throwable) { 30 if(logger.isLoggable(Level.SEVERE)) { 31 logger.log(Level.SEVERE, message, throwable); 32 } 33 } 34 35 public void warn(String message) { 36 if(logger.isLoggable(Level.WARNING)) { 37 logger.log(Level.WARNING, message); 38 } 39 } 40 41 public void error(String message) { 42 if(logger.isLoggable(Level.SEVERE)) { 43 logger.log(Level.SEVERE, message); 44 } 45 } 46 47 50 public String getAppCodeName() { 51 return "Cobra"; 52 } 53 54 57 public String getAppMinorVersion() { 58 return "0"; 59 } 60 61 64 public String getAppName() { 65 return "Browser"; 66 } 67 68 71 public String getAppVersion() { 72 return "1"; 73 } 74 75 78 public String getBrowserLanguage() { 79 return "EN"; 80 } 81 82 85 public String getPlatform() { 86 return System.getProperty("os.name"); 87 } 88 89 92 public String getUserAgent() { 93 return "Mozilla/4.0 (compatible; MSIE 6.0;) Cobra/Simple"; 94 } 95 96 99 public boolean isCookieEnabled() { 100 this.warn("isCookieEnabled(): Not overridden - returning false"); 101 return false; 102 } 103 104 public String getCookie(java.net.URL url) { 105 this.warn("getCookie(): Method not overridden; returning null."); 106 return ""; 107 } 108 109 113 public boolean isScriptingEnabled() { 114 return true; 115 } 116 117 public void setCookie(java.net.URL url, String cookieSpec) { 118 this.warn("setCookie(): Method not overridden."); 119 } 120 121 125 public Policy getSecurityPolicy() { 126 return null; 127 } 128 129 132 public int getScriptingOptimizationLevel() { 133 return -1; 134 } 135 } 136 | Popular Tags |