// Path: rfc3986-uri/src/main/java/org/dmfs/rfc3986/Path.java
// public interface Path extends Iterable<UriEncoded>
// {
//     /**
//      * Returns whether this path is empty, i.e. contains no path segments.
//      *
//      * @return {@code true} if this path is empty, {@code false} otherwise.
//      */
//     boolean isEmpty();
// 
//     /**
//      * Returns whether this path is absolute, i.e. starts with a "/".
//      *
//      * @return {@code true} if this path is absolute, {@code false} otherwise.
//      */
//     boolean isAbsolute();
// }
// 
// 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/utils/Parsed.java
// public interface Parsed
// {
//     /**
//      * The length of the component in the source.
//      *
//      * @return
//      */
//     int parsedLength();
// }
// 
// Path: rfc3986-uri/src/main/java/org/dmfs/rfc3986/validation/CharSets.java
// public final static CharSet PCHAR = new BitMapCharSet(0, 0x2FFF7FF2, 0x87FFFFFF, 0x47FFFFFE);


import org.dmfs.rfc3986.Path;
import org.dmfs.rfc3986.UriEncoded;
import org.dmfs.rfc3986.utils.Parsed;
import java.util.Iterator;
import static org.dmfs.rfc3986.validation.CharSets.PCHAR;
/*
 * 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.paths;





/**
 * A lazy {@link Path}. It's not parsed nor validated until it's actually needed.
 *
 * @author Marten Gajda
 */
public final class LazyPath implements Path, Parsed
{
    private final UriEncoded mUriEncoded;
    private Path mDelegate;
    private int mEnd;


    public LazyPath(UriEncoded uri)
    {
        mUriEncoded = uri;
    }


    @Override
    public boolean isEmpty()
    {
        return path().isEmpty();
    }


    @Override
    public boolean isAbsolute()
    {
        return path().isAbsolute();
    }


    @Override
    public Iterator<UriEncoded> iterator()
    {
        return path().iterator();
    }


// Path: rfc3986-uri/src/main/java/org/dmfs/rfc3986/Path.java
// public interface Path extends Iterable<UriEncoded>
// {
//     /**
//      * Returns whether this path is empty, i.e. contains no path segments.
//      *
//      * @return {@code true} if this path is empty, {@code false} otherwise.
//      */
//     boolean isEmpty();
// 
//     /**
//      * Returns whether this path is absolute, i.e. starts with a "/".
//      *
//      * @return {@code true} if this path is absolute, {@code false} otherwise.
//      */
//     boolean isAbsolute();
// }
// 
// 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/utils/Parsed.java
// public interface Parsed
// {
//     /**
//      * The length of the component in the source.
//      *
//      * @return
//      */
//     int parsedLength();
// }
// 
// Path: rfc3986-uri/src/main/java/org/dmfs/rfc3986/validation/CharSets.java
// public final static CharSet PCHAR = new BitMapCharSet(0, 0x2FFF7FF2, 0x87FFFFFF, 0x47FFFFFE);


// Path: rfc3986-uri/src/main/java/org/dmfs/rfc3986/paths/LazyPath.java
import org.dmfs.rfc3986.Path;
import org.dmfs.rfc3986.UriEncoded;
import org.dmfs.rfc3986.utils.Parsed;
import java.util.Iterator;
import static org.dmfs.rfc3986.validation.CharSets.PCHAR;

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





/**
 * A lazy {@link Path}. It's not parsed nor validated until it's actually needed.
 *
 * @author Marten Gajda
 */
public final class LazyPath implements Path, Parsed
{
    private final UriEncoded mUriEncoded;
    private Path mDelegate;
    private int mEnd;


    public LazyPath(UriEncoded uri)
    {
        mUriEncoded = uri;
    }


    @Override
    public boolean isEmpty()
    {
        return path().isEmpty();
    }


    @Override
    public boolean isAbsolute()
    {
        return path().isAbsolute();
    }


    @Override
    public Iterator<UriEncoded> iterator()
    {
        return path().iterator();
    }


    private Path path()