1 19 20 package org.netbeans.modules.versioning.system.cvss.util; 21 22 import org.netbeans.lib.cvsclient.command.Command; 23 import org.netbeans.lib.cvsclient.command.log.RlogCommand; 24 import org.netbeans.lib.cvsclient.command.tag.RtagCommand; 25 import org.netbeans.lib.cvsclient.command.tag.TagCommand; 26 import org.netbeans.lib.cvsclient.command.remove.RemoveCommand; 27 import org.netbeans.lib.cvsclient.command.commit.CommitCommand; 28 import org.netbeans.lib.cvsclient.command.update.UpdateCommand; 29 30 35 public abstract class CommandDuplicator { 36 37 public static CommandDuplicator getDuplicator(Command src) { 38 if (src instanceof CommitCommand) return new CommitCloner((CommitCommand) src); 39 if (src instanceof UpdateCommand) return new UpdateCloner((UpdateCommand) src); 40 if (src instanceof RemoveCommand) return new RemoveCloner((RemoveCommand) src); 41 if (src instanceof RtagCommand) return new RtagCloner((RtagCommand) src); 42 if (src instanceof RlogCommand) return new RlogCloner((RlogCommand) src); 43 if (src instanceof TagCommand) return new TagCloner((TagCommand) src); 44 throw new IllegalArgumentException ("Clone not supported for command type: " + src.getClass().getName()); } 46 47 public abstract Command duplicate(); 48 49 private static class CommitCloner extends CommandDuplicator { 50 private final CommitCommand sample; 51 52 public CommitCloner(CommitCommand sample) { 53 this.sample = sample; 54 } 55 56 public Command duplicate() { 57 CommitCommand c = new CommitCommand(); 58 c.setForceCommit(sample.isForceCommit()); 59 c.setLogMessageFromFile(sample.getLogMessageFromFile()); 60 c.setMessage(sample.getMessage()); 61 c.setNoModuleProgram(sample.isNoModuleProgram()); 62 c.setRecursive(sample.isRecursive()); 63 c.setToRevisionOrBranch(sample.getToRevisionOrBranch()); 64 return c; 65 } 66 } 67 68 private static class UpdateCloner extends CommandDuplicator { 69 private final UpdateCommand sample; 70 71 public UpdateCloner(UpdateCommand sample) { 72 this.sample = sample; 73 } 74 75 public Command duplicate() { 76 UpdateCommand c = new UpdateCommand(); 77 c.setBuildDirectories(sample.isBuildDirectories()); 78 c.setCleanCopy(sample.isCleanCopy()); 79 c.setKeywordSubst(sample.getKeywordSubst()); 80 c.setMergeRevision1(sample.getMergeRevision1()); 81 c.setMergeRevision2(sample.getMergeRevision2()); 82 c.setPipeToOutput(sample.isPipeToOutput()); 83 c.setPruneDirectories(sample.isPruneDirectories()); 84 c.setResetStickyOnes(sample.isResetStickyOnes()); 85 c.setUpdateByDate(sample.getUpdateByDate()); 86 c.setUpdateByRevision(sample.getUpdateByRevision()); 87 c.setUseHeadIfNotFound(sample.isUseHeadIfNotFound()); 88 c.setRecursive(sample.isRecursive()); 89 return c; 90 } 91 } 92 93 94 private static class RemoveCloner extends CommandDuplicator { 95 private final RemoveCommand sample; 96 97 public RemoveCloner(RemoveCommand sample) { 98 this.sample = sample; 99 } 100 101 public Command duplicate() { 102 RemoveCommand c = new RemoveCommand(); 103 c.setDeleteBeforeRemove(sample.isDeleteBeforeRemove()); 104 c.setIgnoreLocallyExistingFiles(sample.isIgnoreLocallyExistingFiles()); 105 c.setRecursive(sample.isRecursive()); 106 return c; 107 } 108 } 109 110 private static class RtagCloner extends CommandDuplicator { 111 private final RtagCommand sample; 112 113 public RtagCloner(RtagCommand sample) { 114 this.sample = sample; 115 } 116 117 public Command duplicate() { 118 RtagCommand c = new RtagCommand(); 119 c.setClearFromRemoved(sample.isClearFromRemoved()); 120 c.setDeleteTag(sample.isDeleteTag()); 121 c.setMakeBranchTag(sample.isMakeBranchTag()); 122 c.setMatchHeadIfRevisionNotFound(sample.isMatchHeadIfRevisionNotFound()); 123 c.setModules(sample.getModules()); 124 c.setNoExecTagProgram(sample.isNoExecTagProgram()); 125 c.setOverrideExistingTag(sample.isOverrideExistingTag()); 126 c.setTag(sample.getTag()); 127 c.setTagByDate(sample.getTagByDate()); 128 c.setTagByRevision(sample.getTagByRevision()); 129 c.setRecursive(sample.isRecursive()); 130 return c; 131 } 132 } 133 134 private static class TagCloner extends CommandDuplicator { 135 private final TagCommand sample; 136 137 public TagCloner(TagCommand sample) { 138 this.sample = sample; 139 } 140 141 public Command duplicate() { 142 TagCommand c = new TagCommand(); 143 c.setDeleteTag(sample.isDeleteTag()); 144 c.setMakeBranchTag(sample.isMakeBranchTag()); 145 c.setMatchHeadIfRevisionNotFound(sample.isMatchHeadIfRevisionNotFound()); 146 c.setOverrideExistingTag(sample.isOverrideExistingTag()); 147 c.setTag(sample.getTag()); 148 c.setTagByDate(sample.getTagByDate()); 149 c.setTagByRevision(sample.getTagByRevision()); 150 c.setRecursive(sample.isRecursive()); 151 c.setCheckThatUnmodified(sample.isCheckThatUnmodified()); 152 return c; 153 } 154 } 155 156 private static class RlogCloner extends CommandDuplicator { 157 private final RlogCommand sample; 158 159 public RlogCloner(RlogCommand sample) { 160 this.sample = sample; 161 } 162 163 public Command duplicate() { 164 RlogCommand c = new RlogCommand(); 165 c.setDateFilter(sample.getDateFilter()); 166 c.setDefaultBranch(sample.isDefaultBranch()); 167 c.setHeaderAndDescOnly(sample.isHeaderAndDescOnly()); 168 c.setHeaderOnly(sample.isHeaderOnly()); 169 c.setNoTags(sample.isNoTags()); 170 c.setRevisionFilter(sample.getRevisionFilter()); 171 c.setStateFilter(sample.getStateFilter()); 172 c.setSuppressHeader(sample.isSuppressHeader()); 173 c.setUserFilter(sample.getUserFilter()); 174 c.setModules(sample.getModules()); 175 c.setRecursive(sample.isRecursive()); 176 return c; 177 } 178 } 179 } 180 | Popular Tags |