001package org.unix4j.unix.from;
002
003import org.unix4j.unix.From;
004
005/**
006 * Factory for the {@link From from} command returning 
007 * a new command instance from every signature method.
008 */
009public final class FromFactory implements From.Interface<FromCommand> {
010        
011        /**
012         * The singleton instance of this factory.
013         */
014        public static final FromFactory INSTANCE = new FromFactory();
015
016        /**
017         * Private, only used to create singleton instance.
018         */
019        private FromFactory() {
020                super();
021        }
022
023        @Override
024        public FromCommand fromString(String string) {
025                final FromArguments fromArgs = new FromArguments();
026                fromArgs.setInput(new org.unix4j.io.StringInput(string));
027                return new FromCommand(fromArgs);
028        }
029
030        @Override
031        public FromCommand fromStrings(String... strings) {
032                final FromArguments fromArgs = new FromArguments();
033                fromArgs.setInput(new org.unix4j.io.StringInput(strings));
034                return new FromCommand(fromArgs);
035        }
036
037        @Override
038        public FromCommand from(Iterable<? extends String> lines) {
039                final FromArguments fromArgs = new FromArguments();
040                fromArgs.setInput(new org.unix4j.io.StringInput(lines));
041                return new FromCommand(fromArgs);
042        }
043
044        @Override
045        public FromCommand from(java.util.Iterator<? extends String> iterator) {
046                final FromArguments fromArgs = new FromArguments();
047                fromArgs.setInput(new org.unix4j.io.StringInput(iterator));
048                return new FromCommand(fromArgs);
049        }
050
051        @Override
052        public FromCommand from(java.util.stream.Stream<? extends String> stream) {
053                final FromArguments fromArgs = new FromArguments();
054                fromArgs.setInput(new org.unix4j.io.StringInput(stream));
055                return new FromCommand(fromArgs);
056        }
057
058        @Override
059        public FromCommand fromFile(String path) {
060                final FromArguments fromArgs = new FromArguments();
061                fromArgs.setPath(path);
062                return new FromCommand(fromArgs);
063        }
064
065        @Override
066        public FromCommand fromFile(java.io.File file) {
067                final FromArguments fromArgs = new FromArguments();
068                fromArgs.setInput(new org.unix4j.io.FileInput(file));
069                return new FromCommand(fromArgs);
070        }
071
072        @Override
073        public FromCommand fromResource(String resource) {
074                final FromArguments fromArgs = new FromArguments();
075                fromArgs.setResource(resource);
076                return new FromCommand(fromArgs);
077        }
078
079        @Override
080        public FromCommand fromResource(Class<?> base, String resource) {
081                final FromArguments fromArgs = new FromArguments();
082                fromArgs.setBase(base);
083                fromArgs.setResource(resource);
084                return new FromCommand(fromArgs);
085        }
086
087        @Override
088        public FromCommand from(java.io.InputStream in) {
089                final FromArguments fromArgs = new FromArguments();
090                fromArgs.setInput(new org.unix4j.io.StreamInput(in));
091                return new FromCommand(fromArgs);
092        }
093
094        @Override
095        public FromCommand from(java.io.Reader reader) {
096                final FromArguments fromArgs = new FromArguments();
097                fromArgs.setInput(new org.unix4j.io.ReaderInput(reader));
098                return new FromCommand(fromArgs);
099        }
100
101        @Override
102        public FromCommand from(java.net.URL url) {
103                final FromArguments fromArgs = new FromArguments();
104                fromArgs.setInput(new org.unix4j.io.URLInput(url));
105                return new FromCommand(fromArgs);
106        }
107
108        @Override
109        public FromCommand from(org.unix4j.io.Input input) {
110                final FromArguments fromArgs = new FromArguments();
111                fromArgs.setInput(input);
112                return new FromCommand(fromArgs);
113        }
114}