001: /*
002: * ====================================================================
003: * Copyright (c) 2004-2008 TMate Software Ltd. All rights reserved.
004: *
005: * This software is licensed as described in the file COPYING, which
006: * you should have received as part of this distribution. The terms
007: * are also available at http://svnkit.com/license.html
008: * If newer versions of this license are posted there, you may use a
009: * newer version instead, at your option.
010: * ====================================================================
011: */
012:
013: package org.tmatesoft.svn.cli;
014:
015: import java.util.ArrayList;
016: import java.util.Iterator;
017: import java.util.Set;
018:
019: import org.tmatesoft.svn.core.SVNException;
020:
021: /**
022: * @version 1.1.1
023: * @author TMate Software Ltd.
024: */
025: public abstract class SVNArgument {
026:
027: public static final SVNArgument PASSWORD = createStringArgument(new String[] { "--password" });
028: public static final SVNArgument USERNAME = createStringArgument(new String[] { "--username" });
029: public static final SVNArgument CONFIG_DIR = createStringArgument(new String[] { "--config-dir" });
030:
031: public static final SVNArgument NON_RECURSIVE = createUnaryArgument(new String[] {
032: "--non-recursive", "-N" });
033: public static final SVNArgument NO_AUTO_PROPS = createUnaryArgument(new String[] { "--no-auto-props" });
034: public static final SVNArgument AUTO_PROPS = createUnaryArgument(new String[] { "--auto-props" });
035: public static final SVNArgument IGNORE_ANCESTRY = createUnaryArgument(new String[] { "--ignore-ancestry" });
036: public static final SVNArgument REV_PROP = createUnaryArgument(new String[] { "--revprop" });
037: public static final SVNArgument RECURSIVE = createUnaryArgument(new String[] {
038: "--recursive", "-R" });
039: public static final SVNArgument VERBOSE = createUnaryArgument(new String[] {
040: "--verbose", "-v" });
041: public static final SVNArgument NO_DIFF_DELETED = createUnaryArgument(new String[] { "--no-diff-deleted" });
042: public static final SVNArgument NO_DIFF_ADDED = createUnaryArgument(new String[] { "--no-diff-added" });
043: public static final SVNArgument DIFF_COPY_FROM = createUnaryArgument(new String[] { "--diff-copy-from" });
044: public static final SVNArgument USE_ANCESTRY = createUnaryArgument(new String[] { "--notice-ancestry" });
045: public static final SVNArgument QUIET = createUnaryArgument(new String[] {
046: "--quiet", "-q" });
047: public static final SVNArgument SHOW_UPDATES = createUnaryArgument(new String[] {
048: "--show-updates", "-u" });
049: public static final SVNArgument NO_IGNORE = createUnaryArgument(new String[] { "--no-ignore" });
050: public static final SVNArgument MESSAGE = createStringArgument(new String[] {
051: "--message", "-m" });
052: public static final SVNArgument REVISION = createStringArgument(new String[] {
053: "--revision", "-r" });
054: public static final SVNArgument OLD = createStringArgument(new String[] { "--old" });
055: public static final SVNArgument NEW = createStringArgument(new String[] { "--new" });
056: public static final SVNArgument NO_AUTH_CACHE = createUnaryArgument(new String[] { "--no-auth-cache" });
057: public static final SVNArgument FORCE = createUnaryArgument(new String[] { "--force" });
058: public static final SVNArgument FORCE_LOG = createUnaryArgument(new String[] { "--force-log" });
059: public static final SVNArgument FILE = createStringArgument(new String[] { "-F" });
060: public static final SVNArgument EDITOR_CMD = createStringArgument(new String[] { "--editor-cmd" });
061: public static final SVNArgument STRICT = createUnaryArgument(new String[] { "--strict" });
062: public static final SVNArgument STOP_ON_COPY = createUnaryArgument(new String[] { "--stop-on-copy" });
063: public static final SVNArgument NO_UNLOCK = createUnaryArgument(new String[] { "--no-unlock" });
064: public static final SVNArgument RELOCATE = createUnaryArgument(new String[] { "--relocate" });
065: public static final SVNArgument EOL_STYLE = createStringArgument(new String[] { "--native-eol" });
066: public static final SVNArgument DRY_RUN = createUnaryArgument(new String[] { "--dry-run" });
067: public static final SVNArgument INCREMENTAL = createUnaryArgument(new String[] { "--incremental" });
068: public static final SVNArgument XML = createUnaryArgument(new String[] { "--xml" });
069: public static final SVNArgument LIMIT = createStringArgument(new String[] { "--limit" });
070: public static final SVNArgument NON_INTERACTIVE = createUnaryArgument(new String[] { "--non-interactive" });
071: public static final SVNArgument CHANGE = createStringArgument(new String[] {
072: "--change", "-c" });
073: public static final SVNArgument SUMMARIZE = createUnaryArgument(new String[] { "--summarize" });
074:
075: public static final SVNArgument EXTENSIONS = createUnaryArgument(new String[] {
076: "-x", "--extensions" });
077: public static final SVNArgument IGNORE_WS_CHANGE = createUnaryArgument(new String[] {
078: "-b", "--ignore-space-change" });
079: public static final SVNArgument IGNORE_ALL_WS = createUnaryArgument(new String[] {
080: "-w", "--ignore-all-space" });
081: public static final SVNArgument IGNORE_EOL_STYLE = createUnaryArgument(new String[] { "--ignore-eol-style" });
082:
083: public static final SVNArgument FS_TYPE = createStringArgument(new String[] { "--fs-type" });
084: public static final SVNArgument PRE_14_COMPATIBLE = createUnaryArgument(new String[] { "--pre-1.4-compatible" });
085: public static final SVNArgument BDB_TXN_NOSYNC = createUnaryArgument(new String[] { "--bdb-txn-nosync" });
086: public static final SVNArgument BDB_LOG_KEEP = createUnaryArgument(new String[] { "--bdb-log-keep" });
087: public static final SVNArgument DELTAS = createUnaryArgument(new String[] { "--deltas" });
088: public static final SVNArgument IGNORE_UUID = createUnaryArgument(new String[] { "--ignore-uuid" });
089: public static final SVNArgument FORCE_UUID = createUnaryArgument(new String[] { "--force-uuid" });
090: public static final SVNArgument USE_PRECOMMIT_HOOK = createUnaryArgument(new String[] { "--use-pre-commit-hook" });
091: public static final SVNArgument USE_POSTCOMMIT_HOOK = createUnaryArgument(new String[] { "--use-post-commit-hook" });
092: public static final SVNArgument PARENT_DIR = createStringArgument(new String[] { "--parent-dir" });
093:
094: public static final SVNArgument TRANSACTION = createStringArgument(new String[] {
095: "--transaction", "-t" });
096: public static final SVNArgument COPY_INFO = createUnaryArgument(new String[] { "--copy-info" });
097: public static final SVNArgument SHOW_IDS = createUnaryArgument(new String[] { "--show-ids" });
098: public static final SVNArgument FULL_PATHS = createUnaryArgument(new String[] { "--full-paths" });
099:
100: public static SVNArgument findArgument(String name,
101: Set validArguments) {
102: for (Iterator arguments = validArguments.iterator(); arguments
103: .hasNext();) {
104: SVNArgument argument = (SVNArgument) arguments.next();
105: for (Iterator names = argument.names(); names.hasNext();) {
106: String argumentName = (String) names.next();
107: if (argumentName.equals(name)) {
108: return argument;
109: }
110: }
111: }
112: return null;
113: }
114:
115: private static SVNArgument createStringArgument(String[] names) {
116: return new SVNStringArgument(names);
117: }
118:
119: static SVNArgument createUnaryArgument(String[] names) {
120: return new SVNUnaryArgument(names);
121: }
122:
123: private ArrayList myNames;
124:
125: private SVNArgument(String[] names) {
126: myNames = new ArrayList();
127: for (int i = 0; i < names.length; i++) {
128: myNames.add(names[i]);
129: }
130: }
131:
132: public Iterator names() {
133: return myNames.iterator();
134: }
135:
136: public abstract boolean hasValue();
137:
138: public abstract Object parseValue(String value) throws SVNException;
139:
140: private static class SVNUnaryArgument extends SVNArgument {
141: protected SVNUnaryArgument(String[] names) {
142: super (names);
143: }
144:
145: public boolean hasValue() {
146: return false;
147: }
148:
149: public Object parseValue(String value) throws SVNException {
150: return null;
151: }
152: }
153:
154: private static class SVNStringArgument extends SVNArgument {
155: protected SVNStringArgument(String[] names) {
156: super (names);
157: }
158:
159: public boolean hasValue() {
160: return true;
161: }
162:
163: public Object parseValue(String value) throws SVNException {
164: return value;
165: }
166: }
167: }
|