Parcourir la source

Add a basic model class for aliases.

Change-Id: I2df03b35733bd60af99f9502166d4e96b02bb300
Reviewed-on: http://gerrit.dmdirc.com/3514
Reviewed-by: Greg Holmes <greg@dmdirc.com>
Automatic-Compile: DMDirc Build Manager
pull/1/head
Chris Smith il y a 10 ans
Parent
révision
85e2c8591e
1 fichiers modifiés avec 76 ajouts et 0 suppressions
  1. 76
    0
      src/com/dmdirc/commandparser/aliases/Alias.java

+ 76
- 0
src/com/dmdirc/commandparser/aliases/Alias.java Voir le fichier

@@ -0,0 +1,76 @@
1
+/*
2
+ * Copyright (c) 2006-2014 DMDirc Developers
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.commandparser.aliases;
24
+
25
+import com.dmdirc.commandparser.CommandInfo;
26
+import com.dmdirc.commandparser.CommandType;
27
+
28
+/**
29
+ * Describes a user-defined command alias.
30
+ */
31
+public class Alias implements CommandInfo {
32
+
33
+    /** The type of this alias. */
34
+    private final CommandType type;
35
+    /** The name of the alias. */
36
+    private final String name;
37
+    /** The minimum number of arguments this alias requires. */
38
+    private final int minArguments;
39
+    /** The command string to substitute arguments into. */
40
+    private final String substitution;
41
+
42
+    public Alias(
43
+            final CommandType type,
44
+            final String name,
45
+            final int minArguments,
46
+            final String substitution) {
47
+        this.type = type;
48
+        this.name = name;
49
+        this.minArguments = minArguments;
50
+        this.substitution = substitution;
51
+    }
52
+
53
+    @Override
54
+    public String getName() {
55
+        return name;
56
+    }
57
+
58
+    @Override
59
+    public String getHelp() {
60
+        return name + " - alias for " + substitution.split(" ", 2)[0];
61
+    }
62
+
63
+    public int getMinArguments() {
64
+        return minArguments;
65
+    }
66
+
67
+    public String getSubstitution() {
68
+        return substitution;
69
+    }
70
+
71
+    @Override
72
+    public CommandType getType() {
73
+        return type;
74
+    }
75
+
76
+}

Chargement…
Annuler
Enregistrer