001package gudusoft.gsqlparser.dlineage.graph.utils;
002
003import java.io.IOException;
004import java.io.Writer;
005
006public class Translators extends StringTranslator {
007
008    private final StringTranslator[] translators;
009
010    public Translators(StringTranslator... translators) {
011        if (translators == null) {
012            throw new IllegalArgumentException("Translators array must not be null");
013        }
014        this.translators = translators.clone();
015    }
016
017    @Override
018    public int translate(CharSequence input, int index, Writer out) throws IOException {
019        for (StringTranslator translator : translators) {
020            int consumedChars = translator.translate(input, index, out);
021            if (consumedChars != 0) {
022                return consumedChars;
023            }
024        }
025        return 0;
026    }
027}