001package org.unix4j.unix.cut; 002 003import org.unix4j.unix.Cut; 004 005/** 006 * Factory for the {@link Cut cut} command returning 007 * a new command instance from every signature method. 008 */ 009public final class CutFactory implements Cut.Interface<CutCommand> { 010 011 /** 012 * The singleton instance of this factory. 013 */ 014 public static final CutFactory INSTANCE = new CutFactory(); 015 016 /** 017 * Private, only used to create singleton instance. 018 */ 019 private CutFactory() { 020 super(); 021 } 022 023 @Override 024 public CutCommand cut(String... args) { 025 final CutArguments cutArgs = new CutArguments(args); 026 return new CutCommand(cutArgs); 027 } 028 029 @Override 030 public CutCommand cut(CutOptions options, org.unix4j.util.Range range) { 031 final CutArguments cutArgs = new CutArguments(options); 032 cutArgs.setRange(range); 033 return new CutCommand(cutArgs); 034 } 035 036 @Override 037 public CutCommand cut(CutOptions options, int... indexes) { 038 final CutArguments cutArgs = new CutArguments(options); 039 cutArgs.setIndexes(indexes); 040 return new CutCommand(cutArgs); 041 } 042 043 @Override 044 public CutCommand cut(CutOptions options, String delimiter, org.unix4j.util.Range range) { 045 final CutArguments cutArgs = new CutArguments(options); 046 cutArgs.setDelimiter(delimiter); 047 cutArgs.setRange(range); 048 return new CutCommand(cutArgs); 049 } 050 051 @Override 052 public CutCommand cut(CutOptions options, String delimiter, int... indexes) { 053 final CutArguments cutArgs = new CutArguments(options); 054 cutArgs.setDelimiter(delimiter); 055 cutArgs.setIndexes(indexes); 056 return new CutCommand(cutArgs); 057 } 058 059 @Override 060 public CutCommand cut(CutOptions options, String delimiter, char outputDelimiter, org.unix4j.util.Range range) { 061 final CutArguments cutArgs = new CutArguments(options); 062 cutArgs.setDelimiter(delimiter); 063 cutArgs.setOutputDelimiter(outputDelimiter); 064 cutArgs.setRange(range); 065 return new CutCommand(cutArgs); 066 } 067 068 @Override 069 public CutCommand cut(CutOptions options, String delimiter, char outputDelimiter, int... indexes) { 070 final CutArguments cutArgs = new CutArguments(options); 071 cutArgs.setDelimiter(delimiter); 072 cutArgs.setOutputDelimiter(outputDelimiter); 073 cutArgs.setIndexes(indexes); 074 return new CutCommand(cutArgs); 075 } 076}