<commit_before>Java URL builder
================

[![Build Status](https://travis-ci.org/mikaelhg/urlbuilder.png?branch=master)](https://travis-ci.org/mikaelhg/urlbuilder)
[![Coverage Status](https://coveralls.io/repos/mikaelhg/urlbuilder/badge.svg?branch=master)](https://coveralls.io/r/mikaelhg/urlbuilder?branch=master)

Create and modify URLs and URL parameters easily, with a builder class.

```java
UrlBuilder.fromString("http://www.google.com/")
    .addParameter("q", "charlie brown")
    .toString() == "http://www.google.com/?q=charlie+brown"

UrlBuilder.fromString("http://foo/h%F6pl%E4", "ISO-8859-1")
    .encodeAs("UTF-8")
    .toString() == "http://foo/h%C3%B6pl%C3%A4"

final UrlBuilder ub1 = UrlBuilder.fromEmpty()
    .withScheme("http")
    .withHost("www.example.com")
    .withPath("/")
    .addParameter("foo", "bar");

final java.net.URI uri1 = ub1.toUri();

try {
    final java.net.URI uri2 = ub1.toUriWithException();
} catch (java.net.URISyntaxException ex) {
    // handle the exception
}

final java.net.URL url1 = ub1.toUrl();

try {
    final java.net.URL url2 = ub1.toUrlWithException();
} catch (java.net.MalformedURLException ex) {
    // handle the exception
}
```

Todo:
-----

* More unit tests for corner cases (your help is needed!)

Use with Maven:
-----------------------

For 2.0.7 and newer:


```xml
<dependencies>
    <dependency>
        <groupId>io.mikael</groupId>
        <artifactId>urlbuilder</artifactId>
        <version>2.0.7</version>
    </dependency>
</dependencies>
```

For 1.3.2 and older:

```xml
<repositories>
    <repository>
        <id>maven2.gueck.com-releases</id>
        <url>http://maven2.gueck.com/releases</url><commit_msg>Document instance immutability.<commit_after>Java URL builder
================

[![Build Status](https://travis-ci.org/mikaelhg/urlbuilder.png?branch=master)](https://travis-ci.org/mikaelhg/urlbuilder)
[![Coverage Status](https://coveralls.io/repos/mikaelhg/urlbuilder/badge.svg?branch=master)](https://coveralls.io/r/mikaelhg/urlbuilder?branch=master)

Create and modify URLs and URL parameters easily, with a builder class.

```java
UrlBuilder.fromString("http://www.google.com/")
    .addParameter("q", "charlie brown")
    .toString() === "http://www.google.com/?q=charlie+brown"

UrlBuilder.fromString("http://foo/h%F6pl%E4", "ISO-8859-1")
    .encodeAs("UTF-8")
    .toString() == "http://foo/h%C3%B6pl%C3%A4"

final UrlBuilder ub1 = UrlBuilder.fromEmpty()
    .withScheme("http")
    .withHost("www.example.com")
    .withPath("/")
    .addParameter("foo", "bar");

final java.net.URI uri1 = ub1.toUri();

try {
    final java.net.URI uri2 = ub1.toUriWithException();
} catch (java.net.URISyntaxException ex) {
    // handle the exception
}

final java.net.URL url1 = ub1.toUrl();

try {
    final java.net.URL url2 = ub1.toUrlWithException();
} catch (java.net.MalformedURLException ex) {
    // handle the exception
}
```

Builder instances are immutable, thread-safe and reusable. Every change creates a new instance.

Todo:
-----

* More unit tests for corner cases. Please send in pull requests, your help is needed.

Use with Maven:
-----------------------

For 2.0.7 and newer:


```xml
<dependencies>
    <dependency>
        <groupId>io.mikael</groupId>
        <artifactId>urlbuilder</artifactId>
        <version>2.0.7</version>
    </dependency>
</dependencies>
```

For 1.3.2 and older:

```xml
<repositories>
    <repository>
        <id>maven2.gueck.com-releases</id>
        <url>http://maven2.gueck.com/releases</url>
{'fraction_non_alphanumeric': 0.18999151823579305, 'fraction_numerical': 0.018094430308170765, 'mean_word_length': 3.5475578406169666, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 35, 'https://': 8, 'lorem ipsum': 0, 'www.': 6, 'xml': 4}, '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': '3968060', 'n_tokens_mistral': 1305, 'n_tokens_neox': 1225, 'n_words': 229}