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

com.github.robtimus.io.stream.Messages Maven / Gradle / Ivy

Go to download

A collection of InputStream, OutputStream, Reader and Writer implementations

The newest version!
/*
 * Messages.java
 * Copyright 2020 Rob Spoor
 *
 * 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.
 */

// This file has been generated by i18n-maven-plugin
// (https://robtimus.github.io/i18n-maven-plugin/)

package com.github.robtimus.io.stream;

import java.util.Locale;
import java.util.Map;
import java.util.ResourceBundle;
import java.util.concurrent.ConcurrentHashMap;

@SuppressWarnings("nls")
final class Messages {

    private static final Map BUNDLES = new ConcurrentHashMap<>();

    private Messages() {
        throw new IllegalStateException("cannot create instances of " + getClass().getName());
    }

    private static ResourceBundle getResourceBundle(Locale locale) {
        Locale l = nonNull(locale);
        return BUNDLES.computeIfAbsent(l, k -> ResourceBundle.getBundle("com.github.robtimus.io.stream.io-streams", l));
    }

    private static String getString(Locale locale, String key) {
        ResourceBundle bundle = getResourceBundle(locale);
        return bundle.getString(key);
    }

    private static Locale nonNull(Locale locale) {
        return locale != null ? locale : Locale.getDefault(Locale.Category.FORMAT);
    }

    static final Array_ array = new Array_();

    static final class Array_ {

        private Array_() {
            super();
        }

        String invalidOffsetOrLength(
            Object arg1,
            Object arg2,
            Object arg3) {

            return invalidOffsetOrLength(null,
                    arg1,
                    arg2,
                    arg3
            );
        }

        String invalidOffsetOrLength(Locale locale,
                Object arg1,
                Object arg2,
                Object arg3) {

            Locale l = nonNull(locale);
            String s = getString(l, "array.invalidOffsetOrLength");
            return String.format(l, s,
                    arg1,
                    arg2,
                    arg3
            );
        }

        String invalidStartOrEnd(
            Object arg1,
            Object arg2,
            Object arg3) {

            return invalidStartOrEnd(null,
                    arg1,
                    arg2,
                    arg3
            );
        }

        String invalidStartOrEnd(Locale locale,
                Object arg1,
                Object arg2,
                Object arg3) {

            Locale l = nonNull(locale);
            String s = getString(l, "array.invalidStartOrEnd");
            return String.format(l, s,
                    arg1,
                    arg2,
                    arg3
            );
        }
    }

    static final CharSequence_ charSequence = new CharSequence_();

    static final class CharSequence_ {

        private CharSequence_() {
            super();
        }

        String invalidIndex(
            Object arg1,
            Object arg2) {

            return invalidIndex(null,
                    arg1,
                    arg2
            );
        }

        String invalidIndex(Locale locale,
                Object arg1,
                Object arg2) {

            Locale l = nonNull(locale);
            String s = getString(l, "charSequence.invalidIndex");
            return String.format(l, s,
                    arg1,
                    arg2
            );
        }

        String invalidOffsetOrLength(
            Object arg1,
            Object arg2,
            Object arg3) {

            return invalidOffsetOrLength(null,
                    arg1,
                    arg2,
                    arg3
            );
        }

        String invalidOffsetOrLength(Locale locale,
                Object arg1,
                Object arg2,
                Object arg3) {

            Locale l = nonNull(locale);
            String s = getString(l, "charSequence.invalidOffsetOrLength");
            return String.format(l, s,
                    arg1,
                    arg2,
                    arg3
            );
        }

        String invalidStartOrEnd(
            Object arg1,
            Object arg2,
            Object arg3) {

            return invalidStartOrEnd(null,
                    arg1,
                    arg2,
                    arg3
            );
        }

        String invalidStartOrEnd(Locale locale,
                Object arg1,
                Object arg2,
                Object arg3) {

            Locale l = nonNull(locale);
            String s = getString(l, "charSequence.invalidStartOrEnd");
            return String.format(l, s,
                    arg1,
                    arg2,
                    arg3
            );
        }
    }

    static final Stream_ stream = new Stream_();

    static final class Stream_ {

        private Stream_() {
            super();
        }

        String closed() {
            return closed(null);
        }

        String closed(Locale locale) {
            Locale l = nonNull(locale);
            return getString(l, "stream.closed");
        }
    }

    static final Pipe_ pipe = new Pipe_();

    static final class Pipe_ {

        private Pipe_() {
            super();
        }

        String readerDied() {
            return readerDied(null);
        }

        String readerDied(Locale locale) {
            Locale l = nonNull(locale);
            return getString(l, "pipe.readerDied");
        }

        String writerDied() {
            return writerDied(null);
        }

        String writerDied(Locale locale) {
            Locale l = nonNull(locale);
            return getString(l, "pipe.writerDied");
        }
    }

    static final Ascii_ ascii = new Ascii_();

    static final class Ascii_ {

        private Ascii_() {
            super();
        }

        String invalidByte(Object arg) {
            return invalidByte(null, arg);
        }

        String invalidByte(Locale locale, Object arg) {
            Locale l = nonNull(locale);
            String s = getString(l, "ascii.invalidByte");
            return String.format(l, s, arg);
        }

        String invalidChar(Object arg) {
            return invalidChar(null, arg);
        }

        String invalidChar(Locale locale, Object arg) {
            Locale l = nonNull(locale);
            String s = getString(l, "ascii.invalidChar");
            return String.format(l, s, arg);
        }
    }

    static final Hex_ hex = new Hex_();

    static final class Hex_ {

        private Hex_() {
            super();
        }

        String eof() {
            return eof(null);
        }

        String eof(Locale locale) {
            Locale l = nonNull(locale);
            return getString(l, "hex.eof");
        }

        String invalidChar(Object arg) {
            return invalidChar(null, arg);
        }

        String invalidChar(Locale locale, Object arg) {
            Locale l = nonNull(locale);
            String s = getString(l, "hex.invalidChar");
            return String.format(l, s, arg);
        }
    }

    static final LimitExceededException_ LimitExceededException = new LimitExceededException_();

    static final class LimitExceededException_ {

        private LimitExceededException_() {
            super();
        }

        String init(Object arg) {
            return init(null, arg);
        }

        String init(Locale locale, Object arg) {
            Locale l = nonNull(locale);
            String s = getString(l, "LimitExceededException.init");
            return String.format(l, s, arg);
        }
    }

    static final MultiLineReader_ MultiLineReader = new MultiLineReader_();

    static final class MultiLineReader_ {

        private MultiLineReader_() {
            super();
        }

        String iteratorAlreadyReturned() {
            return iteratorAlreadyReturned(null);
        }

        String iteratorAlreadyReturned(Locale locale) {
            Locale l = nonNull(locale);
            return getString(l, "MultiLineReader.iteratorAlreadyReturned");
        }
    }

    static final RandomReader_ RandomReader = new RandomReader_();

    static final class RandomReader_ {

        private RandomReader_() {
            super();
        }

        String emptyAlphabet() {
            return emptyAlphabet(null);
        }

        String emptyAlphabet(Locale locale) {
            Locale l = nonNull(locale);
            return getString(l, "RandomReader.emptyAlphabet");
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy