// Path: rfc3986-uri/src/main/java/org/dmfs/rfc3986/Fragment.java
// public interface Fragment extends UriEncoded
// {
// 
//     /**
//      * Returns the encoded String representation of the fragment.
//      *
//      * @return A {@link String} representing the encoded fragment.
//      */
//     @Override
//     String toString();
// }
// 
// Path: rfc3986-uri/src/main/java/org/dmfs/rfc3986/UriEncoded.java
// public interface UriEncoded extends CharSequence
// {
//     /**
//      * Returns a normalized version of this {@link UriEncoded}. In particular that means any percent-encoded unreserved characters are decoded and
//      * percent-encoding sequences are converted to uppercase.
//      *
//      * @return The normalized version of this {@link UriEncoded}.
//      */
//     UriEncoded normalized();
// 
//     /**
//      * Returns the decoded text, using the given charset to decode the non-ASCII characters.
//      *
//      * @param charset
//      *         The name of the charset.
//      *
//      * @return
//      */
//     CharSequence decoded(String charset) throws UnsupportedEncodingException;
// 
//     /**
//      * Returns the decoded text assuming UTF-8 encoding.
//      *
//      * @return
//      */
//     CharSequence decoded();
// 
//     @Override
//     UriEncoded subSequence(int startIndex, int endIndex);
// 
//     @Override
//     String toString();
// }
// 
// Path: rfc3986-uri/src/main/java/org/dmfs/rfc3986/encoding/XWwwFormUrlEncoded.java
// public final class XWwwFormUrlEncoded implements UriEncoded
// {
//     private final ParameterList mParams;
//     private final String mCharSet;
//     private String mText;
// 
// 
//     public XWwwFormUrlEncoded(ParameterList params)
//     {
//         this(params, "UTF-8");
//     }
// 
// 
//     public XWwwFormUrlEncoded(ParameterList params, String charset)
//     {
//         mParams = params;
//         mCharSet = charset;
//     }
// 
// 
//     @Override
//     public UriEncoded normalized()
//     {
//         // this will be rendered in normalized form
//         return this;
//     }
// 
// 
//     @Override
//     public CharSequence decoded(String charset) throws UnsupportedEncodingException
//     {
//         throw new UnsupportedOperationException("x-www-form-urlencoded can't be decoded as a whole");
//     }
// 
// 
//     @Override
//     public CharSequence decoded()
//     {
//         throw new UnsupportedOperationException("x-www-form-urlencoded can't be decoded as a whole");
//     }
// 
// 
//     @Override
//     public int length()
//     {
//         return toString().length();
//     }
// 
// 
//     @Override
//     public char charAt(int i)
//     {
//         return toString().charAt(i);
//     }
// 
// 
//     @Override
//     public UriEncoded subSequence(int startIndex, int endIndex)
//     {
//         if (startIndex == 0 && endIndex == toString().length())
//         {
//             return this;
//         }
//         return new Precoded(toString().subSequence(startIndex, endIndex));
//     }
// 
// 
//     @Override
//     public String toString()
//     {
//         if (mText == null)
//         {
//             StringBuilder sb = new StringBuilder(256);
//             boolean first = true;
//             for (Parameter parameter : mParams)
//             {
//                 if (first)
//                 {
//                     first = false;
//                 }
//                 else
//                 {
//                     sb.append('&');
//                 }
//                 sb.append(new FormEncoded(parameter.name(), mCharSet));
//                 sb.append('=');
//                 sb.append(new FormEncoded(parameter.textValue(), mCharSet));
//             }
//             mText = sb.toString();
//         }
//         return mText;
//     }
// }
// 
// Path: rfc3986-uri/src/main/java/org/dmfs/rfc3986/parameters/ParameterList.java
// public interface ParameterList extends Iterable<Parameter>
// {
// }


import org.dmfs.rfc3986.Fragment;
import org.dmfs.rfc3986.UriEncoded;
import org.dmfs.rfc3986.encoding.XWwwFormUrlEncoded;
import org.dmfs.rfc3986.parameters.ParameterList;
import java.io.UnsupportedEncodingException;
/*
 * 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.fragments;




/**
 * A {@link Fragment} derived from a {@link UriEncoded} {@link CharSequence}.
 *
 * @author Marten Gajda
 */
public final class SimpleFragment implements Fragment
{
    private final UriEncoded mDelegate;


    public SimpleFragment(ParameterList parameters)
    {
        this(new XWwwFormUrlEncoded(parameters));
    }


    public SimpleFragment(UriEncoded fragment)
    {
        mDelegate = fragment;
    }


    @Override
    public UriEncoded normalized()
    {
        return mDelegate.normalized();
    }


    @Override
    public CharSequence decoded(String charset) throws UnsupportedEncodingException
    {
        return mDelegate.decoded(charset);
    }


    @Override
    public CharSequence decoded()
    {
        return mDelegate.decoded();
    }


// Path: rfc3986-uri/src/main/java/org/dmfs/rfc3986/Fragment.java
// public interface Fragment extends UriEncoded
// {
// 
//     /**
//      * Returns the encoded String representation of the fragment.
//      *
//      * @return A {@link String} representing the encoded fragment.
//      */
//     @Override
//     String toString();
// }
// 
// Path: rfc3986-uri/src/main/java/org/dmfs/rfc3986/UriEncoded.java
// public interface UriEncoded extends CharSequence
// {
//     /**
//      * Returns a normalized version of this {@link UriEncoded}. In particular that means any percent-encoded unreserved characters are decoded and
//      * percent-encoding sequences are converted to uppercase.
//      *
//      * @return The normalized version of this {@link UriEncoded}.
//      */
//     UriEncoded normalized();
// 
//     /**
//      * Returns the decoded text, using the given charset to decode the non-ASCII characters.
//      *
//      * @param charset
//      *         The name of the charset.
//      *
//      * @return
//      */
//     CharSequence decoded(String charset) throws UnsupportedEncodingException;
// 
//     /**
//      * Returns the decoded text assuming UTF-8 encoding.
//      *
//      * @return
//      */
//     CharSequence decoded();
// 
//     @Override
//     UriEncoded subSequence(int startIndex, int endIndex);
// 
//     @Override
//     String toString();
// }
// 
// Path: rfc3986-uri/src/main/java/org/dmfs/rfc3986/encoding/XWwwFormUrlEncoded.java
// public final class XWwwFormUrlEncoded implements UriEncoded
// {
//     private final ParameterList mParams;
//     private final String mCharSet;
//     private String mText;
// 
// 
//     public XWwwFormUrlEncoded(ParameterList params)
//     {
//         this(params, "UTF-8");
//     }
// 
// 
//     public XWwwFormUrlEncoded(ParameterList params, String charset)
//     {
//         mParams = params;
//         mCharSet = charset;
//     }
// 
// 
//     @Override
//     public UriEncoded normalized()
//     {
//         // this will be rendered in normalized form
//         return this;
//     }
// 
// 
//     @Override
//     public CharSequence decoded(String charset) throws UnsupportedEncodingException
//     {
//         throw new UnsupportedOperationException("x-www-form-urlencoded can't be decoded as a whole");
//     }
// 
// 
//     @Override
//     public CharSequence decoded()
//     {
//         throw new UnsupportedOperationException("x-www-form-urlencoded can't be decoded as a whole");
//     }
// 
// 
//     @Override
//     public int length()
//     {
//         return toString().length();
//     }
// 
// 
//     @Override
//     public char charAt(int i)
//     {
//         return toString().charAt(i);
//     }
// 
// 
//     @Override
//     public UriEncoded subSequence(int startIndex, int endIndex)
//     {
//         if (startIndex == 0 && endIndex == toString().length())
//         {
//             return this;
//         }
//         return new Precoded(toString().subSequence(startIndex, endIndex));
//     }
// 
// 
//     @Override
//     public String toString()
//     {
//         if (mText == null)
//         {
//             StringBuilder sb = new StringBuilder(256);
//             boolean first = true;
//             for (Parameter parameter : mParams)
//             {
//                 if (first)
//                 {
//                     first = false;
//                 }
//                 else
//                 {
//                     sb.append('&');
//                 }
//                 sb.append(new FormEncoded(parameter.name(), mCharSet));
//                 sb.append('=');
//                 sb.append(new FormEncoded(parameter.textValue(), mCharSet));
//             }
//             mText = sb.toString();
//         }
//         return mText;
//     }
// }
// 
// Path: rfc3986-uri/src/main/java/org/dmfs/rfc3986/parameters/ParameterList.java
// public interface ParameterList extends Iterable<Parameter>
// {
// }


// Path: rfc3986-uri/src/main/java/org/dmfs/rfc3986/fragments/SimpleFragment.java
import org.dmfs.rfc3986.Fragment;
import org.dmfs.rfc3986.UriEncoded;
import org.dmfs.rfc3986.encoding.XWwwFormUrlEncoded;
import org.dmfs.rfc3986.parameters.ParameterList;
import java.io.UnsupportedEncodingException;

/*
 * 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.fragments;




/**
 * A {@link Fragment} derived from a {@link UriEncoded} {@link CharSequence}.
 *
 * @author Marten Gajda
 */
public final class SimpleFragment implements Fragment
{
    private final UriEncoded mDelegate;


    public SimpleFragment(ParameterList parameters)
    {
        this(new XWwwFormUrlEncoded(parameters));
    }


    public SimpleFragment(UriEncoded fragment)
    {
        mDelegate = fragment;
    }


    @Override
    public UriEncoded normalized()
    {
        return mDelegate.normalized();
    }


    @Override
    public CharSequence decoded(String charset) throws UnsupportedEncodingException
    {
        return mDelegate.decoded(charset);
    }


    @Override
    public CharSequence decoded()
    {
        return mDelegate.decoded();
    }


    @Override