diff --git a/src/main/java/org/exist/console/xquery/ConsoleModule.java b/src/main/java/org/exist/console/xquery/ConsoleModule.java index fb99a0e..d0746e2 100644 --- a/src/main/java/org/exist/console/xquery/ConsoleModule.java +++ b/src/main/java/org/exist/console/xquery/ConsoleModule.java @@ -46,27 +46,27 @@ public class ConsoleModule extends AbstractInternalModule { private static ConsoleAdapter adapter = null; - public static void log(String channel, String message) { + public static void log(final String channel, final String message) { log(channel, false, message); } - public static void log(String channel, boolean json, String message) { + public static void log(final String channel, final boolean json, final String message) { if (adapter != null) { adapter.log(channel, json, message); } } - public static void log(String channel, String source, int line, int column, String message) { + public static void log(final String channel, final String source, final int line, final int column, final String message) { log(channel, source, line, column, false, message); } - public static void log(String channel, String source, int line, int column, boolean json, String message) { + public static void log(final String channel, final String source, final int line, final int column, final boolean json, final String message) { if (adapter != null) { adapter.log(channel, source, line, column, json, message); } } - public static void send(String channel, String json) { + public static void send(final String channel, final String json) { if (adapter != null) { adapter.send(channel, json); } @@ -80,7 +80,7 @@ public static void setAdapter(final ConsoleAdapter consoleAdapter) { adapter = consoleAdapter; } - public ConsoleModule(Map> parameters) { + public ConsoleModule(final Map> parameters) { super(functions, parameters, false); } diff --git a/src/main/java/org/exist/console/xquery/JMXToken.java b/src/main/java/org/exist/console/xquery/JMXToken.java index 33c1584..a37ec07 100644 --- a/src/main/java/org/exist/console/xquery/JMXToken.java +++ b/src/main/java/org/exist/console/xquery/JMXToken.java @@ -45,12 +45,12 @@ public class JMXToken extends BasicFunction { new FunctionReturnSequenceType(Type.STRING, Cardinality.ZERO_OR_ONE, "The authentication token") ); - public JMXToken(XQueryContext context) { + public JMXToken(final XQueryContext context) { super(context, signature); } @Override - public Sequence eval(Sequence[] sequences, Sequence sequence) throws XPathException { + public Sequence eval(final Sequence[] sequences, final Sequence sequence) throws XPathException { if (!context.getEffectiveUser().hasDbaRole()) { throw new XPathException(this, "Only a dba user is allowed to retrieve the JMX access token."); } @@ -74,7 +74,7 @@ public Sequence eval(Sequence[] sequences, Sequence sequence) throws XPathExcept if (key != null) { return new StringValue(key); } - } catch (IOException ex) { + } catch (final IOException ex) { throw new XPathException(this, "Exception while reading token file: " + ex.getMessage(), ex); } } diff --git a/src/main/java/org/exist/console/xquery/Log.java b/src/main/java/org/exist/console/xquery/Log.java index 4ed1975..b173690 100644 --- a/src/main/java/org/exist/console/xquery/Log.java +++ b/src/main/java/org/exist/console/xquery/Log.java @@ -40,7 +40,7 @@ */ public class Log extends BasicFunction { - public final static FunctionSignature signatures[] = { + public final static FunctionSignature[] signatures = { new FunctionSignature( new QName("log", ConsoleModule.NAMESPACE_URI, ConsoleModule.PREFIX), "Logs a message to the logger using the template given in the first parameter and " + @@ -119,40 +119,40 @@ public class Log extends BasicFunction { private Expression parent = null; - public Log(XQueryContext context, FunctionSignature signature) { + public Log(final XQueryContext context, final FunctionSignature signature) { super(context, signature); } @Override - public void analyze(AnalyzeContextInfo contextInfo) throws XPathException { + public void analyze(final AnalyzeContextInfo contextInfo) throws XPathException { super.analyze(contextInfo); parent = contextInfo.getParent(); } @Override - public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException { + public Sequence eval(final Sequence[] args, final Sequence contextSequence) throws XPathException { final Properties outputProperties = new Properties(SERIALIZATION_PROPERTIES); if (isCalledAs("dump")) { final String channel = getArgumentCount() == 0 ? "default" : args[0].getStringValue(); Set varsToPrint = null; if (getArgumentCount() == 2) { - varsToPrint = new HashSet(); - for (SequenceIterator i = args[1].iterate(); i.hasNext(); ) { + varsToPrint = new HashSet<>(); + for (final SequenceIterator i = args[1].iterate(); i.hasNext(); ) { varsToPrint.add(i.nextItem().getStringValue()); } } - StringWriter writer = new StringWriter(); - JSONWriter jsonWriter = new JSONWriter(writer); + final StringWriter writer = new StringWriter(); + final JSONWriter jsonWriter = new JSONWriter(writer); try { jsonWriter.startDocument(); jsonWriter.startElement("", "result", "result"); - Map vars = context.getLocalVariables(); - for (Map.Entry var: vars.entrySet()) { - String name = var.getKey().toString(); + final Map vars = context.getLocalVariables(); + for (final Map.Entry var: vars.entrySet()) { + final String name = var.getKey().toString(); if (varsToPrint == null || varsToPrint.contains(name)) { jsonWriter.startElement("", name, name); - StringBuilder value = new StringBuilder(); + final StringBuilder value = new StringBuilder(); printItems(value, outputProperties, false, var.getValue().getValue()); jsonWriter.characters(value); jsonWriter.endElement("", name, name); @@ -167,7 +167,7 @@ public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathExce } else { ConsoleModule.log(channel, parent.getSource().pathOrContentOrShortIdentifier(), parent.getLine(), parent.getColumn(), true, msg); } - } catch (TransformerException e) { + } catch (final TransformerException e) { e.printStackTrace(); } @@ -194,8 +194,8 @@ public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathExce return Sequence.EMPTY_SEQUENCE; } - private void printItems(StringBuilder out, Properties outputProperties, boolean jsonFormat, Sequence sequence) throws XPathException { - for (SequenceIterator i = sequence.iterate(); i.hasNext(); ) { + private void printItems(final StringBuilder out, final Properties outputProperties, final boolean jsonFormat, final Sequence sequence) throws XPathException { + for (final SequenceIterator i = sequence.iterate(); i.hasNext(); ) { final Item item = i.nextItem(); if (Type.subTypeOf(item.getType(), Type.NODE)) { final Serializer serializer = context.getBroker().getSerializer(); @@ -203,7 +203,7 @@ private void printItems(StringBuilder out, Properties outputProperties, boolean try { serializer.setProperties(outputProperties); out.append(serializer.serialize((NodeValue) item)); - } catch (SAXException e) { + } catch (final SAXException e) { out.append(e.getMessage()); } } else if (item.getType() == Type.MAP_ITEM || item.getType() == Type.ARRAY_ITEM) { @@ -211,8 +211,8 @@ private void printItems(StringBuilder out, Properties outputProperties, boolean final XQuerySerializer xqSerializer = new XQuerySerializer(context.getBroker(), JSON_SERIALIZATION_PROPERTIES, writer); try { xqSerializer.serialize(item.toSequence()); - out.append(writer.toString()); - } catch (SAXException e) { + out.append(writer); + } catch (final SAXException e) { throw new XPathException(this, e.getMessage()); } } else if (jsonFormat) { diff --git a/src/main/java/org/exist/remoteconsole/RemoteConsoleAdapter.java b/src/main/java/org/exist/remoteconsole/RemoteConsoleAdapter.java index 492e96f..e96a308 100644 --- a/src/main/java/org/exist/remoteconsole/RemoteConsoleAdapter.java +++ b/src/main/java/org/exist/remoteconsole/RemoteConsoleAdapter.java @@ -54,7 +54,7 @@ public void log(final String channel, final boolean json, final String message) } @Override - public void log(String channel, String source, int line, int column, String message) { + public void log(final String channel, final String source, final int line, final int column, final String message) { log(channel, source, line, column, false, message); } @@ -80,7 +80,7 @@ public void send(final String channel, final String jsonString) { private String getTimestamp() { try { return new DateTimeValue().getStringValue(); - } catch (XPathException e) { + } catch (final XPathException e) { return null; } }