<commit_before>/* 
@ITMillApache2LicenseForJavaFiles@
 */

package com.vaadin.terminal.gwt.server;

import java.util.Locale;

import javax.servlet.http.HttpServletRequest;

import com.vaadin.terminal.Terminal;

@SuppressWarnings("serial")
public class WebBrowser implements Terminal {

    private int screenHeight = 0;
    private int screenWidth = 0;
    private String browserApplication = null;
    private Locale locale;
    private String address;
    private boolean secureConnection;

    /**
     * There is no default-theme for this terminal type.
     * 
     * @return Allways returns null.
     */
    public String getDefaultTheme() {
        return null;
    }

    /**
     * Get the height of the users display in pixels.
     * 
     */
    public int getScreenHeight() {
        return screenHeight;
    }

    /**
     * Get the width of the users display in pixels.
     * 
     */
    public int getScreenWidth() {
        return screenWidth;
    }

    /**
     * Get the browser user-agent string.
     * 
     * @return
     */
    public String getBrowserApplication() {
        return browserApplication;
    }

    void updateBrowserProperties(HttpServletRequest request) {
        locale = request.getLocale();
        address = request.getRemoteAddr();
        secureConnection = request.isSecure();

        final String agent = request.getHeader("user-agent");
        if (agent != null) {
            browserApplication = agent;
        }

        final String sw = request.getParameter("sw");
        if (sw != null) {
            final String sh = request.getParameter("sh");
            try {
                screenHeight = Integer.parseInt(sh);
                screenWidth = Integer.parseInt(sw);
            } catch (final NumberFormatException e) {
                screenHeight = screenWidth = 0;
            }
        }
    }

    /**
     * Get the IP-address of the web browser.
     * 
     * @return IP-address in 172.16.17.32 -format
     */
    public String getAddress() {
        return address;
    }

    /** Get the default locate of the browser. */
    public Locale getLocale() {
        return locale;
    }

    /** Is the connection made using HTTPS? */
    public boolean isSecureConnection() {
        return secureConnection;
    }

}<commit_msg>Added support for portlet requests.<commit_after>/* 
@ITMillApache2LicenseForJavaFiles@
 */

package com.vaadin.terminal.gwt.server;

import java.util.Locale;

import javax.portlet.PortletRequest;
import javax.servlet.http.HttpServletRequest;

import com.vaadin.terminal.Terminal;

@SuppressWarnings("serial")
public class WebBrowser implements Terminal {

    private int screenHeight = 0;
    private int screenWidth = 0;
    private String browserApplication = null;
    private Locale locale;
    private String address;
    private boolean secureConnection;

    /**
     * There is no default-theme for this terminal type.
     * 
     * @return Allways returns null.
     */
    public String getDefaultTheme() {
        return null;
    }

    /**
     * Get the height of the users display in pixels.
     * 
     */
    public int getScreenHeight() {
        return screenHeight;
    }

    /**
     * Get the width of the users display in pixels.
     * 
     */
    public int getScreenWidth() {
        return screenWidth;
    }

    /**
     * Get the browser user-agent string.
     * 
     * @return
     */
    public String getBrowserApplication() {
        return browserApplication;
    }

    void updateBrowserProperties(HttpServletRequest request) {
        locale = request.getLocale();
        address = request.getRemoteAddr();
        secureConnection = request.isSecure();

        final String agent = request.getHeader("user-agent");
        if (agent != null) {
            browserApplication = agent;
        }

        final String sw = request.getParameter("sw");
        if (sw != null) {
            final String sh = request.getParameter("sh");
            try {
                screenHeight = Integer.parseInt(sh);
                screenWidth = Integer.parseInt(sw);
            } catch (final NumberFormatException e) {
                screenHeight = screenWidth = 0;
            }
        }
    }

    void updateBrowserProperties(PortletRequest request) {
        locale = request.getLocale();
        address = null;
        secureConnection = request.isSecure();

        final String agent = request.getProperty("user-agent");
        if (agent != null) {
            browserApplication = agent;
        }

        final String sw = request.getParameter("sw");
        if (sw != null) {
            final String sh = request.getParameter("sh");
            try {
                screenHeight = Integer.parseInt(sh);
                screenWidth = Integer.parseInt(sw);
            } catch (final NumberFormatException e) {
                screenHeight = screenWidth = 0;
            }
        }
    }

    /**
     * Get the IP-address of the web browser. If the application is running
     * inside a portlet, this method will return null.
     * 
     * @return IP-address in 172.16.17.323 -format
     */
    public String getAddress() {
        return address;
    }

    /** Get the default locate of the browser. */
    public Locale getLocale() {
        return locale;
    }

    /** Is the connection made using HTTPS? */
    public boolean isSecureConnection() {
        return secureConnection;
    }

}
{'fraction_non_alphanumeric': 0.09373855730501647, 'fraction_numerical': 0.005126327352618088, 'mean_word_length': 2.009917355371901, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3308405', 'n_tokens_mistral': 1466, 'n_tokens_neox': 1405, 'n_words': 408}