<commit_before>package org.archive.url;

import java.net.MalformedURLException;
import java.net.URL;

public class HandyURL {
	public final static int DEFAULT_PORT = -1;
	
	private String scheme;
	private String authUser;
	private String authPass;
	private String host;
	private int port;
	private String path;
	private String query;
	private String hash;
	private String opaque;
	
	// cached values:
	private String cachedPubSuffix;
	private String cachedPubPrefix;
	
	public HandyURL() {
		this.scheme = null;
		this.authUser = null;
		this.authPass = null;
		this.host = null;
		this.port = DEFAULT_PORT;
		this.path = null;
		this.query = null;
		this.hash = null;
		this.opaque = null;
	}
	
	public HandyURL(String scheme,
			String authUser,
			String authPass,
			String host,
			int port,
			String path,
			String query,
			String hash) {
		this.scheme = scheme;
		this.authUser = authUser;
		this.authPass = <PASSWORD>;
		this.host = host;
		this.port = port;
		this.path = path;
		this.query = query;
		this.hash = hash;
	}
	
	public String getURLString(boolean surt, boolean appendScheme, boolean publicSuffix) {
		if(opaque != null) {
			return opaque;
		}
		StringBuilder sb = new StringBuilder();

		if(appendScheme) {
			sb.append(scheme).append("://");
		}
		
		if(surt) {
			sb.append("(");
		}
		if(authUser != null) {
			sb.append(authUser);
			if(authPass != null) {
				sb.append(":").append(authPass);
			}
			sb.append("@");<commit_msg>getURLString(boolean,boolean,boolean) - omit opening paren when includeScheme is false(); new convenience method getSURTString(boolean includeScheme)<commit_after>package org.archive.url;

import java.net.MalformedURLException;
import java.net.URL;

public class HandyURL {
	public final static int DEFAULT_PORT = -1;
	
	private String scheme;
	private String authUser;
	private String authPass;
	private String host;
	private int port;
	private String path;
	private String query;
	private String hash;
	private String opaque;
	
	// cached values:
	private String cachedPubSuffix;
	private String cachedPubPrefix;
	
	public HandyURL() {
		this.scheme = null;
		this.authUser = null;
		this.authPass = null;
		this.host = null;
		this.port = DEFAULT_PORT;
		this.path = null;
		this.query = null;
		this.hash = null;
		this.opaque = null;
	}
	
	public HandyURL(String scheme,
			String authUser,
			String authPass,
			String host,
			int port,
			String path,
			String query,
			String hash) {
		this.scheme = scheme;
		this.authUser = authUser;
		this.authPass = authPass;
		this.host = host;
		this.port = port;
		this.path = path;
		this.query = query;
		this.hash = hash;
	}

	public String getSURTString(boolean includeScheme) {
		return getURLString(true, includeScheme, false);
	}
	
	public String getURLString(boolean surt, boolean includeScheme, boolean publicSuffix) {
		if(opaque != null) {
			return opaque;
		}
		StringBuilder sb = new StringBuilder();

		if(includeScheme) {
			sb.append(scheme).append("://");
			if (surt) {
				sb.append("(");
			}
		}
		if(authUser != null) {
			sb.append(authUser);
			if(authPass != null) {
				sb.append(":").append(authPass);
			}
			sb.append("@");
{'fraction_non_alphanumeric': 0.11465571699305117, 'fraction_numerical': 0.0006317119393556538, 'mean_word_length': 3.5568345323741006, 'pattern_counts': {'":': 4, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, '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': '4151533', 'n_tokens_mistral': 1186, 'n_tokens_neox': 1037, 'n_words': 280}