All Downloads are FREE. Search and download functionalities are using the official Maven repository.

uk.co.real_logic.artio.util.float_parsing.CharSequenceCharReader Maven / Gradle / Ivy

There is a newer version: 0.160
Show newest version
package uk.co.real_logic.artio.util.float_parsing;

public final class CharSequenceCharReader implements CharReader
{

    private static final char ZERO = '0';

    public static final CharSequenceCharReader INSTANCE = new CharSequenceCharReader();

    private CharSequenceCharReader()
    {

    }

    @Override
    public boolean isSpace(final CharSequence data, final int index)
    {
        return Character.isSpaceChar(data.charAt(index));
    }

    @Override
    public char charAt(final CharSequence data, final int index)
    {
        return data.charAt(index);
    }

    @Override
    public CharSequence asString(final CharSequence data, final int offset, final int length)
    {
        return data.subSequence(offset, offset + length);
    }

    @Override
    public boolean isZero(final CharSequence data, final int index)
    {
        return data.charAt(index) == ZERO;
    }

    @Override
    public int getDigit(final CharSequence data, final int index, final char charValue)
    {
        if (charValue < '0' || charValue > '9')
        {
            throw new NumberFormatException("'" + charValue + "' isn't a valid digit @ " + index);
        }

        return charValue - '0';
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy