// Path: rfc3986-uri/src/main/java/org/dmfs/rfc3986/Scheme.java
// public interface Scheme extends CharSequence
// {
//     @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/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 ALPHA = new BitMapCharSet(0, 0, 0x07FFFFFE, 0x07FFFFFE);
// 
// Path: rfc3986-uri/src/main/java/org/dmfs/rfc3986/validation/CharSets.java
// public final static CharSet SCHEME_CHAR = new BitMapCharSet(0, 0x03FF6800, 0x07FFFFFE, 0x07FFFFFE);


import org.dmfs.optional.Optional;
import org.dmfs.optional.Present;
import org.dmfs.rfc3986.Scheme;
import org.dmfs.rfc3986.UriEncoded;
import org.dmfs.rfc3986.utils.Parsed;
import java.util.NoSuchElementException;
import static org.dmfs.optional.Absent.absent;
import static org.dmfs.rfc3986.validation.CharSets.ALPHA;
import static org.dmfs.rfc3986.validation.CharSets.SCHEME_CHAR;
/*
 * 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.schemes;





/**
 * The {@link Optional} {@link Scheme} of a {@link UriEncoded} URI.
 * <p>
 * Note that the presence of a {@link Scheme} in the result doesn't guarantee a valid URI. It only guarantees, if the input data represents a valid URI, this is
 * the Scheme of it.
 *
 * @author Marten Gajda
 */
public final class OptionalLazyScheme implements Optional<Scheme>, Parsed
{
    private final UriEncoded mUriEncoded;
    private Optional<Scheme> mOptionalScheme;
// Path: rfc3986-uri/src/main/java/org/dmfs/rfc3986/Scheme.java
// public interface Scheme extends CharSequence
// {
//     @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/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 ALPHA = new BitMapCharSet(0, 0, 0x07FFFFFE, 0x07FFFFFE);
// 
// Path: rfc3986-uri/src/main/java/org/dmfs/rfc3986/validation/CharSets.java
// public final static CharSet SCHEME_CHAR = new BitMapCharSet(0, 0x03FF6800, 0x07FFFFFE, 0x07FFFFFE);


// Path: rfc3986-uri/src/main/java/org/dmfs/rfc3986/schemes/OptionalLazyScheme.java
import org.dmfs.optional.Optional;
import org.dmfs.optional.Present;
import org.dmfs.rfc3986.Scheme;
import org.dmfs.rfc3986.UriEncoded;
import org.dmfs.rfc3986.utils.Parsed;
import java.util.NoSuchElementException;
import static org.dmfs.optional.Absent.absent;
import static org.dmfs.rfc3986.validation.CharSets.ALPHA;
import static org.dmfs.rfc3986.validation.CharSets.SCHEME_CHAR;

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





/**
 * The {@link Optional} {@link Scheme} of a {@link UriEncoded} URI.
 * <p>
 * Note that the presence of a {@link Scheme} in the result doesn't guarantee a valid URI. It only guarantees, if the input data represents a valid URI, this is
 * the Scheme of it.
 *
 * @author Marten Gajda
 */
public final class OptionalLazyScheme implements Optional<Scheme>, Parsed
{
    private final UriEncoded mUriEncoded;
    private Optional<Scheme> mOptionalScheme;
    private int mEnd;