reformat code using felix eclipse template. FELIX-1953.
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@892583 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Activator.java b/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Activator.java
index 0fae433..be9b12e 100644
--- a/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Activator.java
+++ b/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Activator.java
@@ -63,7 +63,8 @@
shell.setThreadio(threadio);
shell.setConverter(new Support());
shell.start();
- converterTracker = new ServiceTracker(context, Converter.class.getName(), null) {
+ converterTracker = new ServiceTracker(context, Converter.class.getName(), null)
+ {
@Override
public Object addingService(ServiceReference reference)
{
@@ -80,28 +81,33 @@
}
};
converterTracker.open();
-
- commandTracker = new ServiceTracker(context, context.createFilter("(&(osgi.command.scope=*)(osgi.command.function=*))"), null) {
+
+ commandTracker = new ServiceTracker(context,
+ context.createFilter("(&(osgi.command.scope=*)(osgi.command.function=*))"),
+ null)
+ {
@Override
public Object addingService(ServiceReference reference)
{
Object scope = reference.getProperty("osgi.command.scope");
Object function = reference.getProperty("osgi.command.function");
List<Object> commands = new ArrayList<Object>();
- if(scope != null && function != null)
+ if (scope != null && function != null)
{
if (function.getClass().isArray())
{
for (Object f : ((Object[]) function))
{
- Function target = new CommandProxy(context, reference, f.toString());
+ Function target = new CommandProxy(context, reference,
+ f.toString());
shell.addCommand(scope.toString(), target, f.toString());
commands.add(target);
}
}
else
{
- Function target = new CommandProxy(context, reference, function.toString());
+ Function target = new CommandProxy(context, reference,
+ function.toString());
shell.addCommand(scope.toString(), target, function.toString());
commands.add(target);
}
@@ -114,31 +120,40 @@
public void removedService(ServiceReference reference, Object service)
{
List<Object> commands = (List<Object>) service;
- for (Object cmd : commands) {
+ for (Object cmd : commands)
+ {
shell.removeCommand(cmd);
}
super.removedService(reference, service);
}
};
commandTracker.open();
-
- felixTracker = new ServiceTracker(context, FelixCommandAdaptor.FELIX_COMMAND, null) {
+
+ felixTracker = new ServiceTracker(context, FelixCommandAdaptor.FELIX_COMMAND,
+ null)
+ {
@Override
- public Object addingService(ServiceReference ref) {
+ public Object addingService(ServiceReference ref)
+ {
Object felixCommand = super.addingService(ref);
- try {
+ try
+ {
FelixCommandAdaptor adaptor = new FelixCommandAdaptor(felixCommand);
- regs.put(ref, context.registerService(FelixCommandAdaptor.class.getName(), adaptor,
- adaptor.getAttributes()));
+ regs.put(ref, context.registerService(
+ FelixCommandAdaptor.class.getName(), adaptor,
+ adaptor.getAttributes()));
return felixCommand;
- } catch (Exception e) {
+ }
+ catch (Exception e)
+ {
System.err.println("felixcmd: " + e);
return null;
}
}
@Override
- public void removedService(ServiceReference reference, Object service) {
+ public void removedService(ServiceReference reference, Object service)
+ {
ServiceRegistration reg = regs.remove(reference);
if (reg != null)
reg.unregister();
@@ -146,14 +161,18 @@
}
};
felixTracker.open();
-
- threadioRegistration = context.registerService(ThreadIO.class.getName(), threadio, new Hashtable());
- shellRegistration = context.registerService(CommandProcessor.class.getName(), shell, new Hashtable());
+
+ threadioRegistration = context.registerService(ThreadIO.class.getName(),
+ threadio, new Hashtable());
+ shellRegistration = context.registerService(CommandProcessor.class.getName(),
+ shell, new Hashtable());
}
- private String getProperty(BundleContext context, String name, String def) {
+ private String getProperty(BundleContext context, String name, String def)
+ {
String v = context.getProperty(name);
- if (v == null) {
+ if (v == null)
+ {
v = def;
}
return v;
diff --git a/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/FelixCommandAdaptor.java b/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/FelixCommandAdaptor.java
index 174e7dd..b9e8ff3 100644
--- a/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/FelixCommandAdaptor.java
+++ b/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/FelixCommandAdaptor.java
@@ -8,7 +8,8 @@
import org.osgi.service.command.CommandProcessor;
-public class FelixCommandAdaptor {
+public class FelixCommandAdaptor
+{
public static final String FELIX_COMMAND = "org.apache.felix.shell.Command";
private final Object felixCommand;
private Method execute;
@@ -16,10 +17,11 @@
private String name;
private String usage;
- public FelixCommandAdaptor(Object felixCommand) throws Exception {
+ public FelixCommandAdaptor(Object felixCommand) throws Exception
+ {
this.felixCommand = felixCommand;
Class<?> c = felixCommand.getClass();
- Class<?>[] parms = { String.class, PrintStream.class, PrintStream.class};
+ Class<?>[] parms = { String.class, PrintStream.class, PrintStream.class };
execute = c.getMethod("execute", parms);
Method name = c.getMethod("getName", (Class[]) null);
@@ -32,18 +34,23 @@
this.usage = (String) usage.invoke(felixCommand, (Object[]) null);
}
- public void _main(String[] argv) throws Exception {
+ public void _main(String[] argv) throws Exception
+ {
StringBuilder buf = new StringBuilder();
- for (String arg : argv) {
+ for (String arg : argv)
+ {
if (buf.length() > 0)
buf.append(' ');
buf.append(arg);
}
-
- try {
- Object[] args = { buf.toString(), System.out, System.err};
+
+ try
+ {
+ Object[] args = { buf.toString(), System.out, System.err };
execute.invoke(felixCommand, args);
- } catch (InvocationTargetException e) {
+ }
+ catch (InvocationTargetException e)
+ {
Throwable cause = e.getCause();
if (cause instanceof Exception)
throw (Exception) cause;
@@ -51,7 +58,8 @@
}
}
- public Dictionary<String, Object> getAttributes() {
+ public Dictionary<String, Object> getAttributes()
+ {
Dictionary<String, Object> dict = new Hashtable<String, Object>();
dict.put(CommandProcessor.COMMAND_SCOPE, "felix");
dict.put(CommandProcessor.COMMAND_FUNCTION, name);
diff --git a/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/cpeg/Procedural.java b/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/cpeg/Procedural.java
index a9ea63b..e297c08 100644
--- a/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/cpeg/Procedural.java
+++ b/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/cpeg/Procedural.java
@@ -18,16 +18,15 @@
*/
package org.apache.felix.gogo.runtime.cpeg;
-
import org.osgi.framework.Bundle;
import org.osgi.service.command.CommandSession;
import org.osgi.service.command.Function;
-
public class Procedural
{
- public Object _if(CommandSession session, Function condition, Function ifTrue, Function ifFalse) throws Exception
+ public Object _if(CommandSession session, Function condition, Function ifTrue,
+ Function ifFalse) throws Exception
{
Object result = condition.execute(session, null);
if (isTrue(result))
diff --git a/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/lang/Support.java b/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/lang/Support.java
index 2ab6bbe..7a19eef 100644
--- a/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/lang/Support.java
+++ b/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/lang/Support.java
@@ -26,29 +26,32 @@
import java.lang.reflect.Proxy;
import java.util.Arrays;
-
public class Support implements Converter
{
public Object convert(Class<?> desiredType, final Object in) throws Exception
{
- if (in instanceof Function && desiredType.isInterface() && desiredType.getDeclaredMethods().length == 1)
+ if (in instanceof Function && desiredType.isInterface()
+ && desiredType.getDeclaredMethods().length == 1)
{
- return Proxy.newProxyInstance(desiredType.getClassLoader(), new Class[]{desiredType}, new InvocationHandler()
- {
- Function command = ((Function) in);
-
- public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
+ return Proxy.newProxyInstance(desiredType.getClassLoader(),
+ new Class[] { desiredType }, new InvocationHandler()
{
- return command.execute(null, Arrays.asList(args));
- }
+ Function command = ((Function) in);
- });
+ public Object invoke(Object proxy, Method method, Object[] args)
+ throws Throwable
+ {
+ return command.execute(null, Arrays.asList(args));
+ }
+
+ });
}
return null;
}
- public CharSequence format(Object target, int level, Converter escape) throws Exception
+ public CharSequence format(Object target, int level, Converter escape)
+ throws Exception
{
return null;
}
diff --git a/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/osgi/OSGiCommands.java b/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/osgi/OSGiCommands.java
index 3bfca82..459e504 100644
--- a/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/osgi/OSGiCommands.java
+++ b/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/osgi/OSGiCommands.java
@@ -42,14 +42,14 @@
this.bundle = bundle;
}
-// Bundle[] getBundles() {
-// return getContext().getBundles();
-// }
+ // Bundle[] getBundles() {
+ // return getContext().getBundles();
+ // }
public BundleContext getContext()
{
if (bundle.getState() != Bundle.ACTIVE && bundle.getState() != Bundle.STARTING
- && bundle.getState() != Bundle.STOPPING)
+ && bundle.getState() != Bundle.STOPPING)
{
throw new IllegalStateException("Framework is not started yet");
}
@@ -63,7 +63,8 @@
{
version = "0.0.0";
}
- return String.format("%06d %s %s-%s", bundle.getBundleId(), getState(bundle), bundle.getSymbolicName(), version);
+ return String.format("%06d %s %s-%s", bundle.getBundleId(), getState(bundle),
+ bundle.getSymbolicName(), version);
}
CharSequence print(ServiceReference ref)
@@ -78,7 +79,9 @@
spid = pid.toString();
}
- f.format("%06d %3s %-40s %s", ref.getProperty("service.id"), ref.getBundle().getBundleId(), getShortNames((String[]) ref.getProperty("objectclass")), spid);
+ f.format("%06d %3s %-40s %s", ref.getProperty("service.id"),
+ ref.getBundle().getBundleId(),
+ getShortNames((String[]) ref.getProperty("objectclass")), spid);
return sb;
}
@@ -177,7 +180,8 @@
return sb;
}
- public void each(CommandSession session, Collection<Object> list, Function closure) throws Exception
+ public void each(CommandSession session, Collection<Object> list, Function closure)
+ throws Exception
{
List<Object> args = new ArrayList<Object>();
args.add(null);
@@ -282,7 +286,8 @@
}
else
{
- if (desiredType.isAssignableFrom(String.class) && in instanceof InputStream)
+ if (desiredType.isAssignableFrom(String.class)
+ && in instanceof InputStream)
{
return read(((InputStream) in));
}
@@ -298,14 +303,16 @@
String s = in.toString();
if (s.startsWith("(") && s.endsWith(")"))
{
- ServiceReference refs[] = getContext().getServiceReferences(null, String.format("(|(service.id=%s)(service.pid=%s))", in, in));
+ ServiceReference refs[] = getContext().getServiceReferences(null,
+ String.format("(|(service.id=%s)(service.pid=%s))", in, in));
if (refs != null && refs.length > 0)
{
return refs[0];
}
}
- ServiceReference refs[] = getContext().getServiceReferences(null, String.format("(|(service.id=%s)(service.pid=%s))", in, in));
+ ServiceReference refs[] = getContext().getServiceReferences(null,
+ String.format("(|(service.id=%s)(service.pid=%s))", in, in));
if (refs != null && refs.length > 0)
{
return refs[0];
@@ -343,7 +350,8 @@
return null;
}
- public CharSequence format(Object target, int level, Converter converter) throws IOException
+ public CharSequence format(Object target, int level, Converter converter)
+ throws IOException
{
if (level == INSPECT && target instanceof InputStream)
{
diff --git a/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/osgi/OSGiShell.java b/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/osgi/OSGiShell.java
index 7c8bb37..17556b1 100644
--- a/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/osgi/OSGiShell.java
+++ b/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/osgi/OSGiShell.java
@@ -42,7 +42,8 @@
setConverter(commands);
if (bundle.getState() == Bundle.ACTIVE || bundle.getState() == Bundle.STARTING)
{
- addCommand("osgi", commands.service(PackageAdmin.class.getName(), null), PackageAdmin.class);
+ addCommand("osgi", commands.service(PackageAdmin.class.getName(), null),
+ PackageAdmin.class);
addCommand("osgi", commands.getContext(), BundleContext.class);
try
@@ -101,7 +102,9 @@
return null;
}
- String filter = String.format("(&(osgi.command.scope=%s)(osgi.command.function=%s))", service, function);
+ String filter = String.format(
+ "(&(osgi.command.scope=%s)(osgi.command.function=%s))", service,
+ function);
ServiceReference refs[] = context.getServiceReferences(null, filter);
if (refs == null || refs.length == 0)
{
@@ -110,7 +113,9 @@
if (refs.length > 1)
{
- throw new IllegalArgumentException("Command name is not unambiguous: " + name + ", found multiple impls");
+ throw new IllegalArgumentException(
+ "Command name is not unambiguous: " + name
+ + ", found multiple impls");
}
return new ServiceCommand(this, refs[0], function);
diff --git a/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/osgi/ServiceCommand.java b/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/osgi/ServiceCommand.java
index 5970424..0e8a617 100644
--- a/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/osgi/ServiceCommand.java
+++ b/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/osgi/ServiceCommand.java
@@ -39,7 +39,8 @@
this.name = name;
}
- public Object execute(CommandSession session, List<Object> arguments) throws Exception
+ public Object execute(CommandSession session, List<Object> arguments)
+ throws Exception
{
try
{
@@ -55,7 +56,8 @@
{
return result;
}
- throw new IllegalArgumentException("Service does not implement promised command " + ref + " " + name);
+ throw new IllegalArgumentException(
+ "Service does not implement promised command " + ref + " " + name);
}
}
finally
diff --git a/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/shell/Closure.java b/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/shell/Closure.java
index 8ab4dc1..d54272f 100644
--- a/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/shell/Closure.java
+++ b/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/shell/Closure.java
@@ -53,68 +53,68 @@
{
ArrayList<Pipe> pipes = new ArrayList<Pipe>();
- for (List<CharSequence> statement : pipeline)
- {
- Pipe current = new Pipe(this, statement);
+ for (List<CharSequence> statement : pipeline)
+ {
+ Pipe current = new Pipe(this, statement);
- if (pipes.isEmpty())
- {
- if (current.out == null)
- {
- current.setIn(session.in);
- current.setOut(session.out);
- current.setErr(session.err);
- }
- }
- else
- {
- Pipe previous = pipes.get(pipes.size() - 1);
- previous.connect(current);
- }
- pipes.add(current);
- }
+ if (pipes.isEmpty())
+ {
+ if (current.out == null)
+ {
+ current.setIn(session.in);
+ current.setOut(session.out);
+ current.setErr(session.err);
+ }
+ }
+ else
+ {
+ Pipe previous = pipes.get(pipes.size() - 1);
+ previous.connect(current);
+ }
+ pipes.add(current);
+ }
- if (pipes.size() == 1)
- {
- pipes.get(0).run();
- }
- else if (pipes.size() > 1)
- {
- for (Pipe pipe : pipes)
- {
- pipe.start();
- }
- for (Pipe pipe : pipes)
- {
- pipe.join();
- }
- }
+ if (pipes.size() == 1)
+ {
+ pipes.get(0).run();
+ }
+ else if (pipes.size() > 1)
+ {
+ for (Pipe pipe : pipes)
+ {
+ pipe.start();
+ }
+ for (Pipe pipe : pipes)
+ {
+ pipe.join();
+ }
+ }
- last = pipes.remove(pipes.size() - 1);
+ last = pipes.remove(pipes.size() - 1);
- for (Pipe pipe : pipes)
- {
- if (pipe.exception != null)
- {
- // can't throw exception, as result is defined by last pipe
- session.err.println("pipe: " + pipe.exception);
- session.put("pipe-exception", pipe.exception);
- }
- }
+ for (Pipe pipe : pipes)
+ {
+ if (pipe.exception != null)
+ {
+ // can't throw exception, as result is defined by last pipe
+ session.err.println("pipe: " + pipe.exception);
+ session.put("pipe-exception", pipe.exception);
+ }
+ }
- if (last.exception != null)
- {
- Pipe.reset();
- throw last.exception;
- }
- }
+ if (last.exception != null)
+ {
+ Pipe.reset();
+ throw last.exception;
+ }
+ }
- Pipe.reset(); // reset IO in case sshd uses same thread for new client
+ Pipe.reset(); // reset IO in case sshd uses same thread for new client
- if (last == null)
- {
- return null;
- }
+ if (last == null)
+ {
+ return null;
+ }
if (last.result instanceof Object[])
{
@@ -126,11 +126,12 @@
Object executeStatement(List<CharSequence> statement) throws Exception
{
// add set -x facility if echo is set
- if (Boolean.TRUE.equals(session.get("echo"))) {
+ if (Boolean.TRUE.equals(session.get("echo")))
+ {
StringBuilder buf = new StringBuilder("+");
for (CharSequence token : statement)
{
- buf.append(' ');
+ buf.append(' ');
buf.append(token);
}
session.err.println(buf);
@@ -153,7 +154,8 @@
values.add(p);
}
}
- else {
+ else
+ {
values.add(v);
}
}
@@ -202,7 +204,8 @@
}
else
{
- Object value = execute(values.get(1), values.subList(2, values.size()));
+ Object value = execute(values.get(1),
+ values.subList(2, values.size()));
return assignment(scmd, value);
}
}
@@ -219,7 +222,8 @@
x = get(scopedFunction);
if (x == null || !(x instanceof Function))
{
- throw new IllegalArgumentException("Command not found: " + scopedFunction);
+ throw new IllegalArgumentException("Command not found: "
+ + scopedFunction);
}
}
return ((Function) x).execute(session, values);
@@ -310,13 +314,15 @@
continue;
case '(':
p.next();
- Closure cl = new Closure(session, this, p.text.subSequence(start + 1, p.find(')', '(') - 1));
+ Closure cl = new Closure(session, this, p.text.subSequence(
+ start + 1, p.find(')', '(') - 1));
res = cl.execute(session, parms);
start = p.current;
continue;
case '{':
p.next();
- res = new Closure(session, this, p.text.subSequence(start + 1, p.find('}', '{') - 1));
+ res = new Closure(session, this, p.text.subSequence(
+ start + 1, p.find('}', '{') - 1));
start = p.current;
continue;
case '$':
@@ -435,7 +441,8 @@
if (map.size() != 0 && list.size() != 0)
{
- throw new IllegalArgumentException("You can not mix maps and arrays: " + array);
+ throw new IllegalArgumentException("You can not mix maps and arrays: "
+ + array);
}
if (map.size() > 0)
diff --git a/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/shell/Command.java b/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/shell/Command.java
index 9d48c1a..cf75e2d 100644
--- a/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/shell/Command.java
+++ b/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/shell/Command.java
@@ -35,7 +35,8 @@
this.target = target;
}
- public Object execute(CommandSession session, List<Object> arguments) throws Exception
+ public Object execute(CommandSession session, List<Object> arguments)
+ throws Exception
{
return method(session, target, function, arguments);
}
diff --git a/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/shell/CommandProxy.java b/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/shell/CommandProxy.java
index 448be1a..3a5ba99 100644
--- a/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/shell/CommandProxy.java
+++ b/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/shell/CommandProxy.java
@@ -25,21 +25,26 @@
import org.osgi.framework.ServiceReference;
import org.osgi.framework.BundleContext;
-public class CommandProxy extends Reflective implements Function {
+public class CommandProxy extends Reflective implements Function
+{
BundleContext context;
ServiceReference reference;
String function;
- public CommandProxy(BundleContext context, ServiceReference reference, String function) {
+ public CommandProxy(BundleContext context, ServiceReference reference, String function)
+ {
this.context = context;
this.reference = reference;
this.function = function;
}
- public Object execute(CommandSession session, List<Object> arguments) throws Exception {
+ public Object execute(CommandSession session, List<Object> arguments)
+ throws Exception
+ {
Object target = context.getService(reference);
- try {
+ try
+ {
if (target instanceof Function)
{
return ((Function) target).execute(session, arguments);
diff --git a/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/shell/CommandSessionImpl.java b/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/shell/CommandSessionImpl.java
index ab8888f..54878cd 100644
--- a/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/shell/CommandSessionImpl.java
+++ b/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/shell/CommandSessionImpl.java
@@ -42,7 +42,7 @@
PrintStream err;
CommandShellImpl service;
final Map<Object, Object> variables = new HashMap<Object, Object>();
- private boolean closed; // derek
+ private boolean closed; // derek
CommandSessionImpl(CommandShellImpl service, InputStream in, PrintStream out, PrintStream err)
{
@@ -54,7 +54,7 @@
public void close()
{
- this.closed = true; // derek
+ this.closed = true; // derek
}
public Object execute(CharSequence commandline) throws Exception
@@ -64,7 +64,7 @@
if (closed)
{
- throw new IllegalStateException("session is closed"); // derek
+ throw new IllegalStateException("session is closed"); // derek
}
Closure impl = new Closure(this, null, commandline);
@@ -98,7 +98,8 @@
// XXX: derek: add SCOPE support
if (name.startsWith("*:"))
{
- String path = variables.containsKey("SCOPE") ? variables.get("SCOPE").toString() : "osgi:*";
+ String path = variables.containsKey("SCOPE") ? variables.get("SCOPE").toString()
+ : "osgi:*";
String func = name.substring(2);
for (String scope : path.split(":"))
{
@@ -124,7 +125,8 @@
}
@SuppressWarnings("unchecked")
- public CharSequence format(Object target, int level, Converter escape) throws Exception
+ public CharSequence format(Object target, int level, Converter escape)
+ throws Exception
{
if (target == null)
{
@@ -303,7 +305,9 @@
try
{
String name = m.getName();
- if (m.getName().startsWith("get") && !m.getName().equals("getClass") && m.getParameterTypes().length == 0 && Modifier.isPublic(m.getModifiers()))
+ if (m.getName().startsWith("get") && !m.getName().equals("getClass")
+ && m.getParameterTypes().length == 0
+ && Modifier.isPublic(m.getModifiers()))
{
found = true;
name = name.substring(3);
diff --git a/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/shell/CommandShellImpl.java b/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/shell/CommandShellImpl.java
index 492e114..efd6471 100644
--- a/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/shell/CommandShellImpl.java
+++ b/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/shell/CommandShellImpl.java
@@ -42,7 +42,7 @@
public CommandShellImpl()
{
addCommand("shell", this, "addCommand");
- addCommand("shell", this, "removeCommand"); // derek
+ addCommand("shell", this, "removeCommand"); // derek
}
public CommandSession createSession(InputStream in, PrintStream out, PrintStream err)
@@ -177,7 +177,7 @@
Method methods[] = target.getMethods();
for (Method m : methods)
{
- if (m.getDeclaringClass().equals(Object.class)) // derek
+ if (m.getDeclaringClass().equals(Object.class)) // derek
{
continue;
}
diff --git a/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/shell/Parser.java b/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/shell/Parser.java
index 930a3ab..4ac1921 100644
--- a/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/shell/Parser.java
+++ b/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/shell/Parser.java
@@ -45,7 +45,8 @@
{
current++;
}
- if (peek() == '/' && current < text.length() - 2 && text.charAt(current + 1) == '/')
+ if (peek() == '/' && current < text.length() - 2
+ && text.charAt(current + 1) == '/')
{
comment();
}
@@ -125,7 +126,8 @@
// but have the escaped flag set, important for {},[] etc
}
}
- if (!increment) {
+ if (!increment)
+ {
current = last;
}
return c;
@@ -158,7 +160,8 @@
CharSequence context(int around)
{
- return text.subSequence(Math.max(0, current - 20), Math.min(text.length(), current + 4));
+ return text.subSequence(Math.max(0, current - 20), Math.min(text.length(),
+ current + 4));
}
public List<List<CharSequence>> pipeline()
@@ -230,7 +233,8 @@
int start = current;
char c = next();
- if (!escaped) {
+ if (!escaped)
+ {
switch (c)
{
case '{':
@@ -245,7 +249,8 @@
return text.subSequence(start, current);
case '"':
case '\'':
- quote(c); break;
+ quote(c);
+ break;
}
}
@@ -255,22 +260,43 @@
c = peek();
if (!escaped)
{
- if (Character.isWhitespace(c) || c == ';' || c =='|' || c == '=') {
+ if (Character.isWhitespace(c) || c == ';' || c == '|' || c == '=')
+ {
break;
- } else if (c == '{') {
- next(); find('}', '{');
- } else if (c == '(') {
- next(); find(')', '(');
- } else if (c == '<') {
- next(); find('>', '<');
- } else if (c == '[') {
- next(); find(']', '[');
- } else if (c == '\'' || c == '"') {
- next(); quote(c); next();
- } else {
+ }
+ else if (c == '{')
+ {
+ next();
+ find('}', '{');
+ }
+ else if (c == '(')
+ {
+ next();
+ find(')', '(');
+ }
+ else if (c == '<')
+ {
+ next();
+ find('>', '<');
+ }
+ else if (c == '[')
+ {
+ next();
+ find(']', '[');
+ }
+ else if (c == '\'' || c == '"')
+ {
+ next();
+ quote(c);
next();
}
- } else {
+ else
+ {
+ next();
+ }
+ }
+ else
+ {
next();
}
}
@@ -291,7 +317,8 @@
{
if (current + 4 > text.length())
{
- throw new IllegalArgumentException("Unicode \\u escape at eof at pos ..." + context(current) + "...");
+ throw new IllegalArgumentException("Unicode \\u escape at eof at pos ..."
+ + context(current) + "...");
}
String s = text.subSequence(current, current + 4).toString();
@@ -308,7 +335,8 @@
{
if (eof())
{
- throw new RuntimeException("Eof found in the middle of a compound for '" + target + deeper + "', begins at " + context(start));
+ throw new RuntimeException("Eof found in the middle of a compound for '"
+ + target + deeper + "', begins at " + context(start));
}
char c = next();
@@ -381,7 +409,8 @@
if (Character.isJavaIdentifierPart(c))
{
- while (c == '$') {
+ while (c == '$')
+ {
c = next();
}
while (!eof() && (Character.isJavaIdentifierPart(c) || c == '.') && c != '$')
@@ -391,7 +420,9 @@
}
return text.subSequence(start, current);
}
- throw new IllegalArgumentException("Reference to variable does not match syntax of a variable: " + context(start));
+ throw new IllegalArgumentException(
+ "Reference to variable does not match syntax of a variable: "
+ + context(start));
}
public String toString()
diff --git a/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/shell/Pipe.java b/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/shell/Pipe.java
index f3608cf..f0ec922 100644
--- a/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/shell/Pipe.java
+++ b/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/shell/Pipe.java
@@ -40,7 +40,7 @@
Exception exception;
Object result;
List<CharSequence> statement;
-
+
public static void reset()
{
tIn.set(null);
@@ -58,8 +58,9 @@
out = tOut.get();
err = tErr.get();
}
-
- public String toString() {
+
+ public String toString()
+ {
return "pipe<" + statement + "> out=" + out;
}
diff --git a/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/shell/Reflective.java b/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/shell/Reflective.java
index f1399c0..901e45e 100644
--- a/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/shell/Reflective.java
+++ b/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/shell/Reflective.java
@@ -32,10 +32,20 @@
public class Reflective
{
public final static Object NO_MATCH = new Object();
- public final static Set<String> KEYWORDS = new HashSet<String>(Arrays.asList(new String[]{"abstract", "continue", "for", "new", "switch", "assert", "default", "goto", "package", "synchronized", "boolean", "do", "if", "private", "this", "break", "double", "implements", "protected", "throw", "byte", "else", "import", "public", "throws", "case", "enum", "instanceof", "return", "transient", "catch", "extends", "int", "short", "try", "char", "final", "interface", "static", "void", "class", "finally", "long", "strictfp", "volatile", "const", "float", "native", "super", "while"}));
+ public final static Set<String> KEYWORDS = new HashSet<String>(
+ Arrays.asList(new String[] { "abstract", "continue", "for", "new", "switch",
+ "assert", "default", "goto", "package", "synchronized", "boolean", "do",
+ "if", "private", "this", "break", "double", "implements", "protected",
+ "throw", "byte", "else", "import", "public", "throws", "case", "enum",
+ "instanceof", "return", "transient", "catch", "extends", "int", "short",
+ "try", "char", "final", "interface", "static", "void", "class",
+ "finally", "long", "strictfp", "volatile", "const", "float", "native",
+ "super", "while" }));
public final static String MAIN = "_main";
-
- public Object method(CommandSession session, Object target, String name, List<Object> args) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException, Exception
+
+ public Object method(CommandSession session, Object target, String name,
+ List<Object> args) throws IllegalArgumentException, IllegalAccessException,
+ InvocationTargetException, Exception
{
Method[] methods = target.getClass().getMethods();
name = name.toLowerCase();
@@ -48,14 +58,15 @@
{
name = "_" + name;
}
-
+
if (target instanceof Class)
{
- Method[] staticMethods = ((Class<?>)target).getMethods();
+ Method[] staticMethods = ((Class<?>) target).getMethods();
for (Method m : staticMethods)
{
String mname = m.getName().toLowerCase();
- if (mname.equals(name) || mname.equals(get) || mname.equals(set) || mname.equals(is) || mname.equals(MAIN))
+ if (mname.equals(name) || mname.equals(get) || mname.equals(set)
+ || mname.equals(is) || mname.equals(MAIN))
{
methods = staticMethods;
break;
@@ -71,7 +82,8 @@
for (Method m : methods)
{
String mname = m.getName().toLowerCase();
- if (mname.equals(name) || mname.equals(get) || mname.equals(set) || mname.equals(is) || mname.equals(MAIN))
+ if (mname.equals(name) || mname.equals(get) || mname.equals(set)
+ || mname.equals(is) || mname.equals(MAIN))
{
Class<?>[] types = m.getParameterTypes();
ArrayList<Object> xargs = new ArrayList<Object>(args);
@@ -92,7 +104,7 @@
// if (types.length >= args.size() ) {
int local = coerce(session, target, types, parms, xargs);
if ((local >= xargs.size()) && (local >= types.length))
- { // derek - stop no-args
+ { // derek - stop no-args
boolean exact = (local == xargs.size() && local == types.length);
if (exact || local > match)
{
@@ -159,7 +171,8 @@
list.add(buf.toString());
}
- throw new IllegalArgumentException(String.format("Cannot coerce %s%s to any of %s", name, args, list));
+ throw new IllegalArgumentException(String.format(
+ "Cannot coerce %s%s to any of %s", name, args, list));
// } derek
}
}
@@ -179,7 +192,8 @@
* @throws Exception
*/
@SuppressWarnings("unchecked")
- private int coerce(CommandSession session, Object target, Class<?> types[], Object out[], List<Object> in) throws Exception
+ private int coerce(CommandSession session, Object target, Class<?> types[],
+ Object out[], List<Object> in) throws Exception
{
int i = 0;
while (i < out.length)
@@ -226,7 +240,7 @@
{
++i;
}
- return i; // derek - return number of args converted
+ return i; // derek - return number of args converted
}
return -1;
}
@@ -246,7 +260,8 @@
return i;
}
- Object coerce(CommandSession session, Object target, Class<?> type, Object arg) throws Exception
+ Object coerce(CommandSession session, Object target, Class<?> type, Object arg)
+ throws Exception
{
if (arg == null)
{
diff --git a/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/threadio/ThreadIOImpl.java b/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/threadio/ThreadIOImpl.java
index 282d7d5..c3bcd60 100644
--- a/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/threadio/ThreadIOImpl.java
+++ b/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/threadio/ThreadIOImpl.java
@@ -52,7 +52,7 @@
}
private void checkIO()
- { // derek
+ { // derek
if (System.in != in)
{
log.fine("ThreadIO: eek! who's set System.in=" + System.in);
diff --git a/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/threadio/ThreadPrintStream.java b/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/threadio/ThreadPrintStream.java
index d9c700e..e8893f6 100644
--- a/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/threadio/ThreadPrintStream.java
+++ b/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/threadio/ThreadPrintStream.java
@@ -92,12 +92,12 @@
public void setError()
{
-// getCurrent().setError();
+ // getCurrent().setError();
}
public void clearError()
{
-// getCurrent().clearError();
+ // getCurrent().clearError();
}
public void write(int b)
diff --git a/gogo/runtime/src/main/java/org/osgi/service/command/CommandProcessor.java b/gogo/runtime/src/main/java/org/osgi/service/command/CommandProcessor.java
index b997845..64d8549 100644
--- a/gogo/runtime/src/main/java/org/osgi/service/command/CommandProcessor.java
+++ b/gogo/runtime/src/main/java/org/osgi/service/command/CommandProcessor.java
@@ -59,6 +59,5 @@
* @param err The stream used for System.err
* @return A new session.
*/
- CommandSession createSession(InputStream in, PrintStream out,
- PrintStream err);
+ CommandSession createSession(InputStream in, PrintStream out, PrintStream err);
}
diff --git a/gogo/runtime/src/main/java/org/osgi/service/command/CommandSession.java b/gogo/runtime/src/main/java/org/osgi/service/command/CommandSession.java
index 293c612..4413008 100644
--- a/gogo/runtime/src/main/java/org/osgi/service/command/CommandSession.java
+++ b/gogo/runtime/src/main/java/org/osgi/service/command/CommandSession.java
@@ -88,9 +88,9 @@
*/
CharSequence format(Object target, int level);
- /**
- * Convert an object to another type.
- */
-
- Object convert(Class<?> type, Object instance);
+ /**
+ * Convert an object to another type.
+ */
+
+ Object convert(Class<?> type, Object instance);
}
diff --git a/gogo/runtime/src/main/java/org/osgi/service/command/Converter.java b/gogo/runtime/src/main/java/org/osgi/service/command/Converter.java
index 7ca29d4..14c5341 100644
--- a/gogo/runtime/src/main/java/org/osgi/service/command/Converter.java
+++ b/gogo/runtime/src/main/java/org/osgi/service/command/Converter.java
@@ -18,7 +18,6 @@
*/
package org.osgi.service.command;
-
/**
* A converter is a service that can help create specific object types from a
* string, and vice versa.
diff --git a/gogo/runtime/src/main/java/org/osgi/service/threadio/ThreadIO.java b/gogo/runtime/src/main/java/org/osgi/service/threadio/ThreadIO.java
index 682e833..483e198 100644
--- a/gogo/runtime/src/main/java/org/osgi/service/threadio/ThreadIO.java
+++ b/gogo/runtime/src/main/java/org/osgi/service/threadio/ThreadIO.java
@@ -53,5 +53,5 @@
* <p/>
* This method will not do anything when no streams are associated.
*/
- void close();
+ void close();
}
diff --git a/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/shell/Context.java b/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/shell/Context.java
index a2c397c..afb8284 100644
--- a/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/shell/Context.java
+++ b/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/shell/Context.java
@@ -23,7 +23,8 @@
public class Context extends CommandShellImpl
{
public static final String EMPTY = "";
- CommandSessionImpl session = (CommandSessionImpl) createSession(System.in, System.out, System.err);
+ CommandSessionImpl session = (CommandSessionImpl) createSession(System.in,
+ System.out, System.err);
static ThreadIOImpl threadio;
static
@@ -53,5 +54,4 @@
session.put(name, value);
}
-
}
diff --git a/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/shell/TestParser.java b/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/shell/TestParser.java
index 18aa183..b75ec82 100644
--- a/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/shell/TestParser.java
+++ b/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/shell/TestParser.java
@@ -113,10 +113,12 @@
assertEquals("def", c.execute("echo def|grep d.*|capture"));
assertEquals("def", c.execute("echoout def|grep d.*|capture"));
assertEquals("def", c.execute("myecho def|grep d.*|capture"));
- assertEquals("def", c.execute("(echoout abc; echoout def; echoout ghi)|grep d.*|capture"));
+ assertEquals("def",
+ c.execute("(echoout abc; echoout def; echoout ghi)|grep d.*|capture"));
assertEquals("", c.execute("echoout def; echoout ghi | grep d.* | capture"));
assertEquals("hello world", c.execute("echo hello world|capture"));
- assertEquals("defghi", c.execute("(echoout abc; echoout def; echoout ghi)|grep 'def|ghi'|capture"));
+ assertEquals("defghi",
+ c.execute("(echoout abc; echoout def; echoout ghi)|grep 'def|ghi'|capture"));
}
public void testAssignment() throws Exception
@@ -147,7 +149,8 @@
c.addCommand("echo", this);
c.addCommand("capture", this);
- assertEquals("http://www.aqute.biz?com=2&biz=1", c.execute("['http://www.aqute.biz?com=2&biz=1'] get 0"));
+ assertEquals("http://www.aqute.biz?com=2&biz=1",
+ c.execute("['http://www.aqute.biz?com=2&biz=1'] get 0"));
assertEquals("{a=2, b=3}", c.execute("[a=2 b=3]").toString());
assertEquals("3", c.execute("[a=2 b=3] get b"));
assertEquals("[3, 4]", c.execute("[1 2 [3 4] 5 6] get 2").toString());
@@ -163,7 +166,8 @@
public void testArray() throws Exception
{
Context c = new Context();
- assertEquals("http://www.aqute.biz?com=2&biz=1", c.execute("['http://www.aqute.biz?com=2&biz=1'] get 0"));
+ assertEquals("http://www.aqute.biz?com=2&biz=1",
+ c.execute("['http://www.aqute.biz?com=2&biz=1'] get 0"));
assertEquals("{a=2, b=3}", c.execute("[a=2 b=3]").toString());
assertEquals("3", c.execute("[a=2 b=3] get b"));
assertEquals("[3, 4]", c.execute("[1 2 [3 4] 5 6] get 2").toString());
@@ -257,8 +261,8 @@
{
if (arg != null)
{
- if (sb.length() > 0)
- sb.append(' ');
+ if (sb.length() > 0)
+ sb.append(' ');
sb.append(arg);
}
}
@@ -342,7 +346,8 @@
public void testSimpleValue()
{
- List<CharSequence> x = new Parser("abc def.ghi http://www.osgi.org?abc=&x=1 [1,2,3] {{{{{{{xyz}}}}}}} (immediate) {'{{{{{'} {\\}} 'abc{}'").statement();
+ List<CharSequence> x = new Parser(
+ "abc def.ghi http://www.osgi.org?abc=&x=1 [1,2,3] {{{{{{{xyz}}}}}}} (immediate) {'{{{{{'} {\\}} 'abc{}'").statement();
assertEquals("abc", x.get(0));
assertEquals("def.ghi", x.get(1));
assertEquals("http://www.osgi.org?abc=&x=1", x.get(2));
@@ -354,7 +359,8 @@
assertEquals("'abc{}'", x.get(8));
}
- void each(CommandSession session, Collection<Object> list, Function closure) throws Exception
+ void each(CommandSession session, Collection<Object> list, Function closure)
+ throws Exception
{
List<Object> args = new ArrayList<Object>();
args.add(null);