001package org.unix4j.unix.grep; 002 003import org.unix4j.unix.Grep; 004 005/** 006 * Factory for the {@link Grep grep} command returning 007 * a new command instance from every signature method. 008 */ 009public final class GrepFactory implements Grep.Interface<GrepCommand> { 010 011 /** 012 * The singleton instance of this factory. 013 */ 014 public static final GrepFactory INSTANCE = new GrepFactory(); 015 016 /** 017 * Private, only used to create singleton instance. 018 */ 019 private GrepFactory() { 020 super(); 021 } 022 023 @Override 024 public GrepCommand grep(String... args) { 025 final GrepArguments grepArgs = new GrepArguments(args); 026 return new GrepCommand(grepArgs); 027 } 028 029 @Override 030 public GrepCommand grep(String regexp) { 031 final GrepArguments grepArgs = new GrepArguments(); 032 grepArgs.setRegexp(regexp); 033 return new GrepCommand(grepArgs); 034 } 035 036 @Override 037 public GrepCommand grep(String regexp, java.io.File... files) { 038 final GrepArguments grepArgs = new GrepArguments(); 039 grepArgs.setRegexp(regexp); 040 grepArgs.setFiles(files); 041 return new GrepCommand(grepArgs); 042 } 043 044 @Override 045 public GrepCommand grep(String regexp, org.unix4j.io.Input... inputs) { 046 final GrepArguments grepArgs = new GrepArguments(); 047 grepArgs.setRegexp(regexp); 048 grepArgs.setInputs(inputs); 049 return new GrepCommand(grepArgs); 050 } 051 052 @Override 053 public GrepCommand grep(java.util.regex.Pattern pattern) { 054 final GrepArguments grepArgs = new GrepArguments(); 055 grepArgs.setPattern(pattern); 056 return new GrepCommand(grepArgs); 057 } 058 059 @Override 060 public GrepCommand grep(java.util.regex.Pattern pattern, java.io.File... files) { 061 final GrepArguments grepArgs = new GrepArguments(); 062 grepArgs.setPattern(pattern); 063 grepArgs.setFiles(files); 064 return new GrepCommand(grepArgs); 065 } 066 067 @Override 068 public GrepCommand grep(java.util.regex.Pattern pattern, String... paths) { 069 final GrepArguments grepArgs = new GrepArguments(); 070 grepArgs.setPattern(pattern); 071 grepArgs.setPaths(paths); 072 return new GrepCommand(grepArgs); 073 } 074 075 @Override 076 public GrepCommand grep(java.util.regex.Pattern pattern, org.unix4j.io.Input... inputs) { 077 final GrepArguments grepArgs = new GrepArguments(); 078 grepArgs.setPattern(pattern); 079 grepArgs.setInputs(inputs); 080 return new GrepCommand(grepArgs); 081 } 082 083 @Override 084 public GrepCommand grep(GrepOptions options, String regexp) { 085 final GrepArguments grepArgs = new GrepArguments(options); 086 grepArgs.setRegexp(regexp); 087 return new GrepCommand(grepArgs); 088 } 089 090 @Override 091 public GrepCommand grep(GrepOptions options, java.util.regex.Pattern pattern) { 092 final GrepArguments grepArgs = new GrepArguments(options); 093 grepArgs.setPattern(pattern); 094 return new GrepCommand(grepArgs); 095 } 096 097 @Override 098 public GrepCommand grep(GrepOptions options, String regexp, java.io.File... files) { 099 final GrepArguments grepArgs = new GrepArguments(options); 100 grepArgs.setRegexp(regexp); 101 grepArgs.setFiles(files); 102 return new GrepCommand(grepArgs); 103 } 104 105 @Override 106 public GrepCommand grep(GrepOptions options, String regexp, String... paths) { 107 final GrepArguments grepArgs = new GrepArguments(options); 108 grepArgs.setRegexp(regexp); 109 grepArgs.setPaths(paths); 110 return new GrepCommand(grepArgs); 111 } 112 113 @Override 114 public GrepCommand grep(GrepOptions options, String regexp, org.unix4j.io.Input... inputs) { 115 final GrepArguments grepArgs = new GrepArguments(options); 116 grepArgs.setRegexp(regexp); 117 grepArgs.setInputs(inputs); 118 return new GrepCommand(grepArgs); 119 } 120 121 @Override 122 public GrepCommand grep(GrepOptions options, java.util.regex.Pattern pattern, java.io.File... files) { 123 final GrepArguments grepArgs = new GrepArguments(options); 124 grepArgs.setPattern(pattern); 125 grepArgs.setFiles(files); 126 return new GrepCommand(grepArgs); 127 } 128 129 @Override 130 public GrepCommand grep(GrepOptions options, java.util.regex.Pattern pattern, String... paths) { 131 final GrepArguments grepArgs = new GrepArguments(options); 132 grepArgs.setPattern(pattern); 133 grepArgs.setPaths(paths); 134 return new GrepCommand(grepArgs); 135 } 136 137 @Override 138 public GrepCommand grep(GrepOptions options, java.util.regex.Pattern pattern, org.unix4j.io.Input... inputs) { 139 final GrepArguments grepArgs = new GrepArguments(options); 140 grepArgs.setPattern(pattern); 141 grepArgs.setInputs(inputs); 142 return new GrepCommand(grepArgs); 143 } 144}