// Path: rfc3986-uri/src/main/java/org/dmfs/rfc3986/validation/CharSet.java
// public interface CharSet
// {
//     /**
//      * Returns whether this CharSet contains the given character.
//      *
//      * @param c
//      *         The character to test.
//      *
//      * @return {@code true} if the given character is contained in the set, {@code false} otherwise.
//      */
//     boolean contains(char c);
// }


import org.dmfs.rfc3986.validation.CharSet;
import java.io.IOException;
import java.io.OutputStream;
/*
 * Copyright 2017 dmfs GmbH
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.dmfs.rfc3986.encoding.utils;




/**
 * An {@link OutputStream} that percent-encodes characters transparently. Calling {@link #toString()} returns the result.
 *
 * @author Marten Gajda
 */
public final class FormPercentEncodingOutputStream extends OutputStream
{
    private final static char[] HEXDIGITS = new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };

    private final StringBuilder mStringBuilder;
    private final CharSet mNoEncodeMap;


// Path: rfc3986-uri/src/main/java/org/dmfs/rfc3986/validation/CharSet.java
// public interface CharSet
// {
//     /**
//      * Returns whether this CharSet contains the given character.
//      *
//      * @param c
//      *         The character to test.
//      *
//      * @return {@code true} if the given character is contained in the set, {@code false} otherwise.
//      */
//     boolean contains(char c);
// }


// Path: rfc3986-uri/src/main/java/org/dmfs/rfc3986/encoding/utils/FormPercentEncodingOutputStream.java
import org.dmfs.rfc3986.validation.CharSet;
import java.io.IOException;
import java.io.OutputStream;

/*
 * Copyright 2017 dmfs GmbH
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.dmfs.rfc3986.encoding.utils;




/**
 * An {@link OutputStream} that percent-encodes characters transparently. Calling {@link #toString()} returns the result.
 *
 * @author Marten Gajda
 */
public final class FormPercentEncodingOutputStream extends OutputStream
{
    private final static char[] HEXDIGITS = new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };

    private final StringBuilder mStringBuilder;
    private final CharSet mNoEncodeMap;


    public FormPercentEncodingOutputStream(int initialCapacity, CharSet noEncodeMap)