Skip to content
Snippets Groups Projects
Commit c017fa97 authored by Hallvard Trætteberg's avatar Hallvard Trætteberg
Browse files

Added doc strings and dependency on corresponding annotations.

parent 898ded0a
Branches
No related tags found
No related merge requests found
...@@ -3,7 +3,8 @@ ...@@ -3,7 +3,8 @@
osgi.core;version=7.0.0,\ osgi.core;version=7.0.0,\
osgi.cmpn;version=7.0.0,\ osgi.cmpn;version=7.0.0,\
tdt4250.dict3.util;version=latest,\ tdt4250.dict3.util;version=latest,\
tdt4250.dict3.api;version=latest tdt4250.dict3.api;version=latest,\
org.apache.felix.gogo.runtime
-testpath: \ -testpath: \
${junit},\ ${junit},\
......
...@@ -4,6 +4,7 @@ import java.io.IOException; ...@@ -4,6 +4,7 @@ import java.io.IOException;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import org.apache.felix.service.command.Descriptor;
import org.osgi.framework.BundleContext; import org.osgi.framework.BundleContext;
import org.osgi.framework.FrameworkUtil; import org.osgi.framework.FrameworkUtil;
import org.osgi.framework.InvalidSyntaxException; import org.osgi.framework.InvalidSyntaxException;
...@@ -30,6 +31,7 @@ import tdt4250.dict3.util.SortedSetWords; ...@@ -30,6 +31,7 @@ import tdt4250.dict3.util.SortedSetWords;
) )
public class DictCommands { public class DictCommands {
@Descriptor("list available dictionaries")
public void list() { public void list() {
Activator activator = Activator.getActivator(); Activator activator = Activator.getActivator();
System.out.print("Dictionaries: "); System.out.print("Dictionaries: ");
...@@ -43,7 +45,11 @@ public class DictCommands { ...@@ -43,7 +45,11 @@ public class DictCommands {
System.out.println(); System.out.println();
} }
public void lookup(String s) { @Descriptor("look up a word in each available dictionary")
public void lookup(
@Descriptor("the word to look up")
String s
) {
BundleContext bc = FrameworkUtil.getBundle(this.getClass()).getBundleContext(); BundleContext bc = FrameworkUtil.getBundle(this.getClass()).getBundleContext();
try { try {
// iterate through all Dict service objects // iterate through all Dict service objects
...@@ -60,7 +66,15 @@ public class DictCommands { ...@@ -60,7 +66,15 @@ public class DictCommands {
} }
} }
public void add(String name, String urlStringOrWord, String... ss) { @Descriptor("add a dictionary, with content from a URL and/or specific words")
public void add(
@Descriptor("the name of the new dictionary")
String name,
@Descriptor("the URL of file with the words, or a simple word to add to the dictionary")
String urlStringOrWord,
@Descriptor("additional words to add to the dictionary")
String... ss
) {
MutableWords words = null; MutableWords words = null;
try { try {
URL url = new URL(urlStringOrWord); URL url = new URL(urlStringOrWord);
...@@ -81,7 +95,11 @@ public class DictCommands { ...@@ -81,7 +95,11 @@ public class DictCommands {
System.out.println("\"" + name + "\" dictionary " + (existed ? "replaced" : "added")); System.out.println("\"" + name + "\" dictionary " + (existed ? "replaced" : "added"));
} }
public void remove(String name) { @Descriptor("remove a (manually added) dictionary")
public void remove(
@Descriptor("the name of the (manually added) dictionary to remove")
String name
) {
boolean removed = Activator.getActivator().removeDict(name); boolean removed = Activator.getActivator().removeDict(name);
System.out.println("\"" + name + "\" dictionary " + (removed ? "removed" : "was not added manually")); System.out.println("\"" + name + "\" dictionary " + (removed ? "removed" : "was not added manually"));
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment