All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.cobraparser.ua.UserAgentContext Maven / Gradle / Ivy

There is a newer version: 1.0.2
Show newest version
package org.cobraparser.ua;

import java.net.URL;

/**
 * Provides information about the user agent (browser) driving the parser and/or
 * renderer.
 * 

* A simple implementation of this interface is provided in * {@link org.cobraparser.html.test.SimpleUserAgentContext}. * * @see org.cobraparser.html.HtmlRendererContext#getUserAgentContext() * @see org.cobraparser.html.parser.DocumentBuilderImpl#DocumentBuilderImpl(UserAgentContext) */ public interface UserAgentContext { public enum RequestKind { Image("Img"), CSS("CSS"), Cookie("Cookie"), JavaScript("JS"), Frame("Frame"), XHR("XHR"), Referrer("Referrer"); public final String shortName; RequestKind(final String shortName) { this.shortName = shortName; } private static final RequestKind[] VALUES = RequestKind.values(); public static RequestKind forOrdinal(final int o) { return VALUES[o]; } public static int numKinds() { return values().length; } } static public class Request { final public RequestKind kind; final public URL url; public Request(final URL url, final RequestKind kind) { this.kind = kind; this.url = url; } @Override public String toString() { return kind.toString() + ": " + url; } } public boolean isRequestPermitted(final Request request); /** * Creates an instance of {@link org.cobraparser.html.HttpRequest} which can * be used by the renderer to load images, scripts, external style sheets, and * implement the Javascript XMLHttpRequest class (AJAX). */ public NetworkRequest createHttpRequest(); /** * Gets browser "code" name. */ public String getAppCodeName(); /** * Gets browser application name. */ public String getAppName(); /** * Gets browser application version. */ public String getAppVersion(); /** * Gets browser application minor version. */ public String getAppMinorVersion(); /** * Gets browser language code. See ISO 639-1 * codes. */ public String getBrowserLanguage(); /** * Returns a boolean value indicating whether cookies are enabled in the user * agent. This value is used for reporting purposes only. TODO: Remove */ public boolean isCookieEnabled(); /** * Returns a boolean value indicating whether scripting is enabled in the user * agent. If this value is false, the parser will not process * scripts and Javascript element attributes will have no effect. TODO: Remove */ public boolean isScriptingEnabled(); /** * Returns a boolean value indicating whether remote (non-inline) CSS * documents should be loaded. TODO: Remove */ public boolean isExternalCSSEnabled(); /** * Returns a boolean value indicating whether STYLE tags should be processed. * TODO: Remove */ public boolean isInternalCSSEnabled(); /** * Gets the name of the user's operating system. */ public String getPlatform(); /** * Should return the string used in the User-Agent header. */ public String getUserAgent(); /** * Method used to implement Javascript document.cookie property. */ public String getCookie(URL url); /** * Method used to implement document.cookie property. * * @param cookieSpec * Specification of cookies, as they would appear in the Set-Cookie * header value of HTTP. */ public void setCookie(URL url, String cookieSpec); /** * Gets the security policy for scripting. Return null if * JavaScript code is trusted. */ public java.security.Policy getSecurityPolicy(); /** * Gets the scripting optimization level, which is a value equivalent to * Rhino's optimization level. */ public int getScriptingOptimizationLevel(); /** * Returns true if the current media matches the name provided. * * @param mediaName * Media name, which may be screen, tty, * etc. (See HTML Specification). */ public boolean isMedia(String mediaName); public String getVendor(); public String getProduct(); }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy