From 1e543ea07b22339f695ec0840d9527e62054a3db Mon Sep 17 00:00:00 2001 From: Nathanael Jourdane Date: Thu, 17 Mar 2016 16:09:19 +0100 Subject: [PATCH] Code clean-up --- .settings/org.eclipse.jdt.core.prefs | 8 -------- src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapMainApp.java | 8 ++++---- src/main/java/eu/omp/irap/vespa/epntapclient/controller/EpnTapController.java | 14 +++++++------- src/main/java/eu/omp/irap/vespa/epntapclient/utils/Queries.java | 9 +++++---- src/main/java/eu/omp/irap/vespa/epntapclient/view/Dim.java | 4 ++-- src/main/java/eu/omp/irap/vespa/epntapclient/view/EpnTapMainView.java | 26 +++++++++++++------------- src/main/java/eu/omp/irap/vespa/epntapclient/view/Event.java | 2 +- src/main/java/eu/omp/irap/vespa/epntapclient/view/ParamField.java | 158 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------ src/main/java/eu/omp/irap/vespa/epntapclient/view/panels/BottomBarPanel.java | 13 ++++--------- src/main/java/eu/omp/irap/vespa/epntapclient/view/panels/RequestPanel.java | 26 +++++++++++++------------- src/main/java/eu/omp/irap/vespa/epntapclient/view/panels/ResultsPanel.java | 17 +++-------------- src/main/java/eu/omp/irap/vespa/epntapclient/view/panels/ServicesPanel.java | 19 +++++++------------ src/main/java/eu/omp/irap/vespa/epntapclient/votable/VOTableApp.java | 13 +++++++------ src/main/java/eu/omp/irap/vespa/epntapclient/votable/controller/VOTableConnection.java | 15 ++++++++------- src/main/java/eu/omp/irap/vespa/epntapclient/votable/controller/VOTableController.java | 10 +++++----- src/main/java/eu/omp/irap/vespa/epntapclient/votable/controller/VOTableDataParser.java | 32 +++++++++++++++++--------------- src/main/java/eu/omp/irap/vespa/epntapclient/votable/controller/VOTableException.java | 48 +++++++++++++++++++++++++++++++++++++++++++----- src/main/java/eu/omp/irap/vespa/epntapclient/votable/controller/VOTableParser.java | 20 +++++++++++--------- src/main/java/eu/omp/irap/vespa/epntapclient/votable/utils/Const.java | 4 ++-- src/main/java/eu/omp/irap/vespa/epntapclient/votable/utils/Utils.java | 16 ++++++++-------- src/main/java/eu/omp/irap/vespa/epntapclient/votable/view/VOTableView.java | 20 +++++++++++--------- 21 files changed, 263 insertions(+), 219 deletions(-) delete mode 100644 .settings/org.eclipse.jdt.core.prefs diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 443e085..0000000 --- a/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,8 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 -org.eclipse.jdt.core.compiler.compliance=1.7 -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning -org.eclipse.jdt.core.compiler.source=1.7 diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapMainApp.java b/src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapMainApp.java index dd9707f..49f5182 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapMainApp.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapMainApp.java @@ -3,7 +3,7 @@ * This program aims to provide EPN-TAP support for software clients, like CASSIS spectrum analyzer. * See draft specifications: https://voparis-confluence.obspm.fr/pages/viewpage.action?pageId=559861 * Copyright (C) 2016 Institut de Recherche en Astrophysique et Planétologie. - * + * * This program is free software: you can * redistribute it and/or modify it under the terms of the GNU General Public License as published * by the Free Software Foundation, either version 3 of the License, or (at your option) any later @@ -25,7 +25,7 @@ import eu.omp.irap.vespa.epntapclient.controller.EpnTapController; /** * Simple class to have a main function to launch the EPNTap client. - * + * * @author N. Jourdane */ public class EpnTapMainApp { @@ -38,14 +38,14 @@ public class EpnTapMainApp { /** * Main function to start the application as standalone. - * + * * @param args The program arguments (not used). */ public static void main(final String[] args) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { - logger.info("Lauching EPN-TAP application..."); + EpnTapMainApp.logger.info("Lauching EPN-TAP application..."); EpnTapController epnTapControl = new EpnTapController(); if (args.length != 0) { System.console().writer().println("Usage: EpnTapMainApp"); diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/controller/EpnTapController.java b/src/main/java/eu/omp/irap/vespa/epntapclient/controller/EpnTapController.java index 9ae19d2..2c0dd10 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/controller/EpnTapController.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/controller/EpnTapController.java @@ -3,7 +3,7 @@ * This program aims to provide EPN-TAP support for software clients, like CASSIS spectrum analyzer. * See draft specifications: https://voparis-confluence.obspm.fr/pages/viewpage.action?pageId=559861 * Copyright (C) 2016 Institut de Recherche en Astrophysique et Planétologie. - * + * * This program is free software: you can * redistribute it and/or modify it under the terms of the GNU General Public License as published * by the Free Software Foundation, either version 3 of the License, or (at your option) any later @@ -31,7 +31,7 @@ import eu.omp.irap.vespa.epntapclient.votable.utils.Const; /** * The main controller which manage views and controllers. - * + * * @author N. Jourdane */ public class EpnTapController implements MainViewListener { @@ -94,7 +94,7 @@ public class EpnTapController implements MainViewListener { /** * Update the row selected by the user on the Services Panel. - * + * * @param row The row selected by the user on the Jtable. */ public void updateSelected(int row) { @@ -111,7 +111,7 @@ public class EpnTapController implements MainViewListener { /** * Remove a query parameter from the parameters list. - * + * * @param paramName The name of the parameter as described in REG-TAP specifications. */ public void removeParameter(String paramName) { @@ -122,7 +122,7 @@ public class EpnTapController implements MainViewListener { /** * Update a query parameter in the parameter list. - * + * * @param paramName The name of the parameter as described in REG-TAP specifications. * @param value The value of the parameter to update. */ @@ -142,7 +142,7 @@ public class EpnTapController implements MainViewListener { /** * Send a query to the selected service on the services panel. - * + * * @param query The query to send to the selected service. * @throws VOTableException Can not fill the Table */ @@ -153,7 +153,7 @@ public class EpnTapController implements MainViewListener { /** * This methods is called each time a graphical event is detected from a view. - * + * * @param event The type of the detected event. @see Event * @param args The possible arguments which comes with the event (ie. a row column). */ diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/utils/Queries.java b/src/main/java/eu/omp/irap/vespa/epntapclient/utils/Queries.java index 3b3977e..13e3115 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/utils/Queries.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/utils/Queries.java @@ -3,7 +3,7 @@ * This program aims to provide EPN-TAP support for software clients, like CASSIS spectrum analyzer. * See draft specifications: https://voparis-confluence.obspm.fr/pages/viewpage.action?pageId=559861 * Copyright (C) 2016 Institut de Recherche en Astrophysique et Planétologie. - * + * * This program is free software: you can * redistribute it and/or modify it under the terms of the GNU General Public License as published * by the Free Software Foundation, either version 3 of the License, or (at your option) any later @@ -25,7 +25,7 @@ import eu.omp.irap.vespa.epntapclient.votable.utils.Utils.StringJoiner; /** * Defines the queries and the query patterns usually used in the application. - * + * * @author N. Jourdane */ public final class Queries { @@ -54,7 +54,7 @@ public final class Queries { /** * The default query, with these parameters, respectively: max_rows, target_name, time_min, * time_max, dataproduct_type, spectral_range_min, spectral_range_max. - * + * * @param nbRow The maximum number of rows returned. * @param tableName The name of the target table for the query. * @param params A map of parameters, for the `WHERE` keywords. @@ -67,8 +67,9 @@ public final class Queries { StringJoiner orJoin = new StringJoiner(" OR "); @SuppressWarnings("unchecked") List possibleValues = (List) param.getValue(); - for (String possibleValue : possibleValues) + for (String possibleValue : possibleValues) { orJoin.add(param.getKey() + " LIKE '" + possibleValue + "'"); + } addJoin.add("(" + orJoin + ")"); } else if (param.getValue() instanceof String) { addJoin.add(param.getKey() + " LIKE '" + param.getValue() + "'"); diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/view/Dim.java b/src/main/java/eu/omp/irap/vespa/epntapclient/view/Dim.java index 2cd74c7..d540b85 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/view/Dim.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/view/Dim.java @@ -3,7 +3,7 @@ * This program aims to provide EPN-TAP support for software clients, like CASSIS spectrum analyzer. * See draft specifications: https://voparis-confluence.obspm.fr/pages/viewpage.action?pageId=559861 * Copyright (C) 2016 Institut de Recherche en Astrophysique et Planétologie. - * + * * This program is free software: you can * redistribute it and/or modify it under the terms of the GNU General Public License as published * by the Free Software Foundation, either version 3 of the License, or (at your option) any later @@ -18,7 +18,7 @@ package eu.omp.irap.vespa.epntapclient.view; /** * A simple class containing GUI panel and elements dimensions. - * + * * @author N. Jourdane */ public class Dim { diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/view/EpnTapMainView.java b/src/main/java/eu/omp/irap/vespa/epntapclient/view/EpnTapMainView.java index 6c40f02..1283a1d 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/view/EpnTapMainView.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/view/EpnTapMainView.java @@ -3,7 +3,7 @@ * This program aims to provide EPN-TAP support for software clients, like CASSIS spectrum analyzer. * See draft specifications: https://voparis-confluence.obspm.fr/pages/viewpage.action?pageId=559861 * Copyright (C) 2016 Institut de Recherche en Astrophysique et Planétologie. - * + * * This program is free software: you can * redistribute it and/or modify it under the terms of the GNU General Public License as published * by the Free Software Foundation, either version 3 of the License, or (at your option) any later @@ -31,7 +31,7 @@ import eu.omp.irap.vespa.epntapclient.votable.view.VOTableView; /** * The main view of the application, which manage all the other views. - * + * * @author N. Jourdane */ public class EpnTapMainView extends JPanel { @@ -39,8 +39,8 @@ public class EpnTapMainView extends JPanel { @SuppressWarnings("unused") private static final Logger logger = Logger.getLogger(EpnTapMainView.class.getName()); - /** The serial version UID (affected with a random number). */ - private static final long serialVersionUID = -1233290271099283814L; + /** The serial version UID. */ + private static final long serialVersionUID = 1L; /** The JPanel where the VOTable results is displayed. */ private ResultsPanel resultsPanel; @@ -59,14 +59,14 @@ public class EpnTapMainView extends JPanel { /** * The interface for the main view listener, which listen for events. - * + * * @author N. Jourdane */ public interface MainViewListener { /** * When an event is detected on the main view. - * + * * @param event The event type. @see Event * @param args The possible arguments which comes with the event (ie. a row number). */ @@ -75,22 +75,22 @@ public class EpnTapMainView extends JPanel { /** * The main view constructor, which create all the panels. - * + * * @param voTableServicesView The view to put in the services panel, built by ServicesController * @param voTableResultsView The view to put in the results panel, built by ResultsController. */ public EpnTapMainView(VOTableView voTableServicesView, VOTableView voTableResultsView) { - this.servicesPanel = new ServicesPanel(this, voTableServicesView); - this.resultsPanel = new ResultsPanel(this, voTableResultsView); - this.requestPanel = new RequestPanel(this); - this.bottomBarPanel = new BottomBarPanel(this); + servicesPanel = new ServicesPanel(this, voTableServicesView); + resultsPanel = new ResultsPanel(this, voTableResultsView); + requestPanel = new RequestPanel(this); + bottomBarPanel = new BottomBarPanel(this); buildWindow(); } /** * Add a listener for the main view. - * + * * @param listener A MainViewListener. */ public void addMainViewListener(MainViewListener listener) { @@ -152,7 +152,7 @@ public class EpnTapMainView extends JPanel { /** * Get an event and send it to the listener of the main view. - * + * * @param event The event type. @see Event * @param args The possible arguments which comes with the event (ie. a row number). */ diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/view/Event.java b/src/main/java/eu/omp/irap/vespa/epntapclient/view/Event.java index ec4bc39..e5b6054 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/view/Event.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/view/Event.java @@ -3,7 +3,7 @@ * This program aims to provide EPN-TAP support for software clients, like CASSIS spectrum analyzer. * See draft specifications: https://voparis-confluence.obspm.fr/pages/viewpage.action?pageId=559861 * Copyright (C) 2016 Institut de Recherche en Astrophysique et Planétologie. - * + * * This program is free software: you can * redistribute it and/or modify it under the terms of the GNU General Public License as published * by the Free Software Foundation, either version 3 of the License, or (at your option) any later diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/view/ParamField.java b/src/main/java/eu/omp/irap/vespa/epntapclient/view/ParamField.java index 250a929..a41a7b8 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/view/ParamField.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/view/ParamField.java @@ -3,7 +3,7 @@ * This program aims to provide EPN-TAP support for software clients, like CASSIS spectrum analyzer. * See draft specifications: https://voparis-confluence.obspm.fr/pages/viewpage.action?pageId=559861 * Copyright (C) 2016 Institut de Recherche en Astrophysique et Planétologie. - * + * * This program is free software: you can * redistribute it and/or modify it under the terms of the GNU General Public License as published * by the Free Software Foundation, either version 3 of the License, or (at your option) any later @@ -50,45 +50,53 @@ import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableException.CantSe * is an abstract method and all type of parameter field should extend it. See * https://voparis-confluence.obspm.fr/display/VES/4+-+EPN-TAP+queries to get all parameters * details. - * + * * @author N. Jourdane */ public abstract class ParamField extends JPanel { - /** The serial version UID (affected with a random number). */ - private static final long serialVersionUID = 6025994164004985362L; + /** The serial version UID. */ + private static final long serialVersionUID = 1L; /** The logger for the class ParamField. */ static final Logger logger = Logger.getLogger(ParamField.class.getName()); /** The minimum width of the field. */ private static final int MIN_FIELD_WIDTH = 30; + /** The preferred field height. */ private static final int FIELD_HEIGHT = 20; + /** The maximum width of the field. */ private static final int MAX_FIELD_WIDTH = 400; + /** The preferred label width. */ private static final int LABEL_WIDTH = 140; /** The URL of the resolver used for the `target name` field. */ private static final String RESOLVER_URL = "http://voparis-registry.obspm.fr/ssodnet/1/autocomplete"; + /** The date format used in the DateRange field */ private static final String DATE_FORMAT = "dd/MM/yyyy"; + /** The regex used to validate the Date fields */ private static final String DATE_REGEX = "(^(((0[1-9]|1[0-9]|2[0-8])[\\/](0[1-9]|1[012]))|((29|30|31)[\\/](0[13578]|1[02]))|((29|30)[\\/](0[4,6,9]|11)))[\\/](19|[2-9][0-9])\\d\\d$)|(^29[\\/]02[\\/](19|[2-9][0-9])(00|04|08|12|16|20|24|28|32|36|40|44|48|52|56|60|64|68|72|76|80|84|88|92|96)$)"; + /** The suffix used in REG-TAP parameters names, indicating that it's a beginning of a range. */ private static final String MIN_SUFFIX = "min"; + /** The suffix used in REG-TAP parameters names, indicating that it is a end of a range. */ private static final String MAX_SUFFIX = "max"; /** The main view of the application. */ protected EpnTapMainView mainView; + /** The parameter name of the field */ protected String paramName; /** * Method constructor for the parameter field abstract class, which do all common action for all * type of field, such as displaying the name of the parameter. - * + * * @param mainView The main view of the application. * @param paramName The name of the parameter. */ @@ -98,11 +106,11 @@ public abstract class ParamField extends JPanel { this.mainView = mainView; this.paramName = paramName; - this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); - this.setMaximumSize(new Dimension(MAX_FIELD_WIDTH, FIELD_HEIGHT)); + setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); + setMaximumSize(new Dimension(ParamField.MAX_FIELD_WIDTH, ParamField.FIELD_HEIGHT)); String strLabel = paramName.replaceAll("_", " ").trim(); JLabel label = new JLabel(strLabel.substring(0, 1).toUpperCase() + strLabel.substring(1)); - label.setPreferredSize(new Dimension(LABEL_WIDTH, FIELD_HEIGHT)); + label.setPreferredSize(new Dimension(ParamField.LABEL_WIDTH, ParamField.FIELD_HEIGHT)); this.add(label); // TODO: Add tooltip text based on rr.table_column.column_description } @@ -110,25 +118,26 @@ public abstract class ParamField extends JPanel { /** * The string field is used for parameter with a `String` class. It is a simple JTextField with * no verification. The parameter is sent to the controller each time it is modified. - * + * * @author N. Jourdane */ public static class StringField extends ParamField implements TextFieldListener { - /** The serial version UID (affected with a random number). */ - private static final long serialVersionUID = 24219488975302068L; + /** The serial version UID. */ + private static final long serialVersionUID = 1L; + /** The JTextField used to put the parameter value. */ JTextField field; /** * Method constructor for the string field. - * + * * @param mainView The main view of the application. * @param paramName The name of the parameter. */ public StringField(EpnTapMainView mainView, String paramName) { super(mainView, paramName); field = new JTextField(); - addChangeListener(this, field); + ParamField.addChangeListener(this, field); this.add(field); } @@ -149,25 +158,26 @@ public abstract class ParamField extends JPanel { * The float field is used for parameter with a `Float` class. It is a JTextField which checks * if the content is a valid float. If the parameter is valid or if it is empty, then the float * value is sent to the controller. - * + * * @author N. Jourdane */ public static class FloatField extends ParamField implements TextFieldListener { - /** The serial version UID (affected with a random number). */ - private static final long serialVersionUID = -1880193152285564590L; + /** The serial version UID. */ + private static final long serialVersionUID = 1L; + /** The JTextField used to put the parameter value. */ JTextField field; /** * Method constructor - * + * * @param mainView The main view of the application. * @param paramName The name of the parameter. */ public FloatField(EpnTapMainView mainView, String paramName) { super(mainView, paramName); field = new JTextField(); - addChangeListener(this, field); + ParamField.addChangeListener(this, field); this.add(field); } @@ -196,20 +206,22 @@ public abstract class ParamField extends JPanel { * `time_min` and `time_max` parameters is concerned for now). These are JTextFields which check * if the content is a valid date, according to DATE_FORMAT. If the parameter is valid or if it * is empty, then the dates value are sent to the controller, in Julian Day format. - * + * * @author N. Jourdane */ public static class DateRangeField extends ParamField implements TextFieldListener { - /** The serial version UID (affected with a random number). */ - private static final long serialVersionUID = -7781309003911514777L; + /** The serial version UID. */ + private static final long serialVersionUID = 1L; + /** The JTextField used to put the parameter minimum value of the range. */ JTextField fieldMin; + /** The JTextField used to put the parameter maximum value of the range. */ JTextField fieldMax; /** * Method constructor - * + * * @param mainView The main view of the application. * @param paramName The name of the parameter. */ @@ -217,16 +229,18 @@ public abstract class ParamField extends JPanel { super(mainView, paramName); this.add(new JLabel("min ")); fieldMin = new JTextField(); - fieldMin.setName(MIN_SUFFIX); - fieldMin.setPreferredSize(new Dimension(MIN_FIELD_WIDTH, FIELD_HEIGHT)); - addChangeListener(this, fieldMin); + fieldMin.setName(ParamField.MIN_SUFFIX); + fieldMin.setPreferredSize( + new Dimension(ParamField.MIN_FIELD_WIDTH, ParamField.FIELD_HEIGHT)); + ParamField.addChangeListener(this, fieldMin); this.add(fieldMin); this.add(new JLabel("max ")); fieldMax = new JTextField(); - fieldMax.setName(MAX_SUFFIX); - fieldMax.setPreferredSize(new Dimension(MIN_FIELD_WIDTH, FIELD_HEIGHT)); - addChangeListener(this, fieldMin); + fieldMax.setName(ParamField.MAX_SUFFIX); + fieldMax.setPreferredSize( + new Dimension(ParamField.MIN_FIELD_WIDTH, ParamField.FIELD_HEIGHT)); + ParamField.addChangeListener(this, fieldMin); this.add(fieldMax); } @@ -235,14 +249,14 @@ public abstract class ParamField extends JPanel { */ @Override public void update(JTextField field) { - DateFormat df = new SimpleDateFormat(DATE_FORMAT, Locale.ENGLISH); + DateFormat df = new SimpleDateFormat(ParamField.DATE_FORMAT, Locale.ENGLISH); if ("".equals(field.getText())) { field.setBackground(Color.WHITE); mainView.event(Event.PARAMETER_REMOVED, paramName + field.getName()); - } else if (field.getText().matches(DATE_REGEX)) { + } else if (field.getText().matches(ParamField.DATE_REGEX)) { try { long date = df.parse(field.getText()).getTime(); - date = Math.round((date / 86400000.0) + 2440587.5); // to JD + date = Math.round(date / 86400000.0 + 2440587.5); // to JD mainView.event(Event.PARAMETER_CHANGED, paramName + field.getName(), date); field.setBackground(Color.WHITE); } catch (@SuppressWarnings("unused") ParseException e) { @@ -259,33 +273,35 @@ public abstract class ParamField extends JPanel { * The float range field is used for couples of parameter with both a `Float` class. These are * JTextFields which check if the content is a valid float. If the parameter is valid or if it * is empty, then the float value are sent to the controller. - * + * * @author N. Jourdane */ public static class FloatRangeField extends ParamField implements TextFieldListener { - /** The serial version UID (affected with a random number). */ - private static final long serialVersionUID = 7923358142882329015L; + /** The serial version UID. */ + private static final long serialVersionUID = 1L; + /** The JTextField used to put the parameter minimum value of the range. */ JTextField fieldMin; + /** The JTextField used to put the parameter maximum value of the range. */ JTextField fieldMax; /** * Method constructor - * + * * @param mainView The main view of the application. * @param paramName The name of the parameter. */ public FloatRangeField(EpnTapMainView mainView, String paramName) { super(mainView, paramName); fieldMin = new JTextField(); - fieldMin.setName(MIN_SUFFIX); - addChangeListener(this, fieldMin); + fieldMin.setName(ParamField.MIN_SUFFIX); + ParamField.addChangeListener(this, fieldMin); this.add(fieldMin); fieldMax = new JTextField(); - fieldMax.setName(MAX_SUFFIX); - addChangeListener(this, fieldMax); + fieldMax.setName(ParamField.MAX_SUFFIX); + ParamField.addChangeListener(this, fieldMax); this.add(fieldMax); } @@ -314,16 +330,19 @@ public abstract class ParamField extends JPanel { * automatically filled with actual target names which begins by the entered characters, by * asking to an online resolver (RESOLVER_URL). The parameter is sent to the controller each * time it is updated, so it is possible to enter a parameter that the resolver do not know. - * + * * @author N. Jourdane */ public static class TargetNameField extends ParamField implements TextFieldListener { - /** The serial version UID (affected with a random number). */ - private static final long serialVersionUID = 5136431108894677113L; + /** The serial version UID. */ + private static final long serialVersionUID = 1L; + /** The comboBox to enter the target_name and display target name propositions. */ JComboBox comboBox; + /** The JTextField related to the ComboBox, allowing to listen for text content update. */ JTextField field; + /** * The content of the last entered value. It is used to avoid recursions, because each time * an update event is detected, the resolver is called and the ComboBox is filled with new @@ -344,11 +363,12 @@ public abstract class ParamField extends JPanel { lastContent = content; comboBox.removeAllItems(); try { - for (String s : getItems(content)) { + for (String s : TargetNameField.getItems(content)) { comboBox.addItem(s); } } catch (CantSendQueryException e) { - logger.log(Level.WARNING, "Can't get table names for the resolver", e); + ParamField.logger.log(Level.WARNING, + "Can't get table names for the resolver", e); } comboBox.getEditor().setItem(content); } @@ -363,31 +383,33 @@ public abstract class ParamField extends JPanel { /** * Method constructor - * + * * @param mainView The main view of the application. * @param paramName The name of the parameter. */ public TargetNameField(EpnTapMainView mainView, String paramName) { super(mainView, paramName); comboBox = new JComboBox<>(); - comboBox.setPreferredSize(new Dimension(MIN_FIELD_WIDTH, FIELD_HEIGHT)); + comboBox.setPreferredSize( + new Dimension(ParamField.MIN_FIELD_WIDTH, ParamField.FIELD_HEIGHT)); comboBox.setEditable(true); field = (JTextField) comboBox.getEditor().getEditorComponent(); - addChangeListener(this, field); + ParamField.addChangeListener(this, field); this.add(comboBox); } /** * The method used to get target names propositions by asking to the resolver. - * + * * @param begining The beginning of the target_name. * @return An array of Strings corresponding to the target names got. * @throws CantSendQueryException If the resolver do not work. */ static String[] getItems(String begining) throws CantSendQueryException { StringBuilder resolverResult; - resolverResult = VOTableConnection.sendGet(RESOLVER_URL, "q=\"" + begining + "\""); + resolverResult = VOTableConnection.sendGet(ParamField.RESOLVER_URL, + "q=\"" + begining + "\""); JsonObject root = new JsonParser().parse(resolverResult.toString()).getAsJsonObject(); int count = Integer.parseInt(root.get("count").toString()); String[] targetNames = new String[count]; @@ -415,12 +437,13 @@ public abstract class ParamField extends JPanel { * https://voparis-confluence.obspm.fr/display/VES/4+-+EPN-TAP+queries#id-4-EPN-TAPqueries- * __RefHeading__35_312326667_Toc3037660444.2.4DataProductType). The parameter is sent to the * controller each time it is updated. - * + * * @author N. Jourdane */ public static class DataProductTypeField extends ParamField { - /** The serial version UID (affected with a random number). */ - private static final long serialVersionUID = -6362359909898369750L; + /** The serial version UID. */ + private static final long serialVersionUID = 1L; + /** The comboBox used to select the data product type. */ JComboBox comboBox; @@ -428,7 +451,7 @@ public abstract class ParamField extends JPanel { * An enumeration of all available data product types. Each values comes with an id because * EPN-TAP table can possibly be filled with the id instead of the name, so the query have * to ask for both of them. - * + * * @author N. Jourdane */ @SuppressWarnings("javadoc") @@ -442,12 +465,13 @@ public abstract class ParamField extends JPanel { /** The full name of the data product type, such as `Dynamic spectrum`. */ private String name = ""; + /** The id of the data product type, such as `ds`. */ private String id = ""; /** * Method constructor for the enumeration. - * + * * @param name The full name of the data product type, such as `Dynamic spectrum`. * @param id The id of the data product type, such as `ds`. */ @@ -476,7 +500,7 @@ public abstract class ParamField extends JPanel { /** * Method constructor - * + * * @param mainView The main view of the application. * @param paramName The name of the parameter. */ @@ -484,7 +508,8 @@ public abstract class ParamField extends JPanel { super(mainView, paramName); comboBox = new JComboBox<>(DataProductType.values()); comboBox.setSelectedItem(DataProductType.ALL); - comboBox.setPreferredSize(new Dimension(MIN_FIELD_WIDTH, FIELD_HEIGHT)); + comboBox.setPreferredSize( + new Dimension(ParamField.MIN_FIELD_WIDTH, ParamField.FIELD_HEIGHT)); comboBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -513,19 +538,19 @@ public abstract class ParamField extends JPanel { * https://voparis-confluence.obspm.fr/display/VES/4+-+EPN-TAP+queries#id-4-EPN-TAPqueries- * __RefHeading__39_312326667_Toc3037660464.2.6TargetClass). The parameter is sent to the * controller each time it is updated. - * + * * @author N. Jourdane */ public static class TargetClassField extends ParamField { - /** The serial version UID (affected with a random number). */ - private static final long serialVersionUID = 6439475087727685080L; + /** The serial version UID. */ + private static final long serialVersionUID = 1L; /** The comboBox used to select the target class. */ JComboBox comboBox; /** * An enumeration of all available target classes. - * + * * @author N. Jourdane */ @SuppressWarnings("javadoc") @@ -541,7 +566,7 @@ public abstract class ParamField extends JPanel { /** * Method constructor for the enumeration. - * + * * @param name The name of the target class. */ TargetClass(String name) { @@ -558,14 +583,15 @@ public abstract class ParamField extends JPanel { /** * Method constructor - * + * * @param mainView The main view of the application. * @param paramName The name of the parameter. */ public TargetClassField(EpnTapMainView mainView, String paramName) { super(mainView, paramName); comboBox = new JComboBox<>(TargetClass.values()); - comboBox.setPreferredSize(new Dimension(MIN_FIELD_WIDTH, FIELD_HEIGHT)); + comboBox.setPreferredSize( + new Dimension(ParamField.MIN_FIELD_WIDTH, ParamField.FIELD_HEIGHT)); comboBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -592,13 +618,13 @@ public abstract class ParamField extends JPanel { * The listener of text field, it aims to provide a simple way to listen a text field without to * override removeUpdate(DocumentEvent de), insertUpdate(DocumentEvent de) and * changedUpdate(DocumentEvent de) on each field to listen. - * + * * @author N. Jourdane */ interface TextFieldListener { /** * When the content of the JTextField is updated. - * + * * @param field The JTextField. Is useful for classes containing several text fields, such * as DateRangeField, to know which one triggered the event. */ @@ -607,7 +633,7 @@ public abstract class ParamField extends JPanel { /** * To add the listener. @see TextFieldListener - * + * * @param changeListener The listener of text fields. * @param field The field to listen. */ diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/view/panels/BottomBarPanel.java b/src/main/java/eu/omp/irap/vespa/epntapclient/view/panels/BottomBarPanel.java index 349ef5f..bc5582c 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/view/panels/BottomBarPanel.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/view/panels/BottomBarPanel.java @@ -3,7 +3,7 @@ * This program aims to provide EPN-TAP support for software clients, like CASSIS spectrum analyzer. * See draft specifications: https://voparis-confluence.obspm.fr/pages/viewpage.action?pageId=559861 * Copyright (C) 2016 Institut de Recherche en Astrophysique et Planétologie. - * + * * This program is free software: you can * redistribute it and/or modify it under the terms of the GNU General Public License as published * by the Free Software Foundation, either version 3 of the License, or (at your option) any later @@ -29,27 +29,22 @@ import eu.omp.irap.vespa.epntapclient.view.EpnTapMainView; * @author N. Jourdane */ public class BottomBarPanel extends JPanel { - /** The serial version UID (affected with a random number). */ - private static final long serialVersionUID = 8083897308526492902L; + /** The serial version UID. */ + private static final long serialVersionUID = 1L; /** The logger for the class BottomBar. */ @SuppressWarnings("unused") private static final Logger logger = Logger.getLogger(BottomBarPanel.class.getName()); - /** The main view of the application. */ - @SuppressWarnings("unused") - private EpnTapMainView mainView; - /** A label to display several informations (aka. status bar). */ private JLabel infoLabel; /** * Method constructor for the bottom bar panel. - * + * * @param mainView The main view of the application. */ public BottomBarPanel(EpnTapMainView mainView) { - this.mainView = mainView; setLayout(new BorderLayout()); infoLabel = new JLabel(); this.add(infoLabel); diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/view/panels/RequestPanel.java b/src/main/java/eu/omp/irap/vespa/epntapclient/view/panels/RequestPanel.java index 78e9ba3..e640ce8 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/view/panels/RequestPanel.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/view/panels/RequestPanel.java @@ -3,7 +3,7 @@ * This program aims to provide EPN-TAP support for software clients, like CASSIS spectrum analyzer. * See draft specifications: https://voparis-confluence.obspm.fr/pages/viewpage.action?pageId=559861 * Copyright (C) 2016 Institut de Recherche en Astrophysique et Planétologie. - * + * * This program is free software: you can * redistribute it and/or modify it under the terms of the GNU General Public License as published * by the Free Software Foundation, either version 3 of the License, or (at your option) any later @@ -41,7 +41,7 @@ import eu.omp.irap.vespa.epntapclient.view.ParamField.TargetNameField; /** * The view of the panel where the user builds the query. - * + * * @author N. Jourdane */ public class RequestPanel extends JPanel implements ActionListener { @@ -49,8 +49,8 @@ public class RequestPanel extends JPanel implements ActionListener { @SuppressWarnings("unused") private static final Logger logger = Logger.getLogger(RequestPanel.class.getName()); - /** The serial version UID (affected with a random number). */ - private static final long serialVersionUID = 1262856496809315405L; + /** The serial version UID. */ + private static final long serialVersionUID = 1L; /** The name of the button to send the query. */ private static final String BTN_NAME = "btnSend"; @@ -71,7 +71,7 @@ public class RequestPanel extends JPanel implements ActionListener { /** * Method constructor - * + * * @param mainView The EPN-TAP main view. */ public RequestPanel(EpnTapMainView mainView) { @@ -97,7 +97,7 @@ public class RequestPanel extends JPanel implements ActionListener { /** * Build a JPanel containing graphical elements to build the query user-friendly. - * + * * @return The JPanel. */ private JPanel buildParamPanel() { @@ -123,7 +123,7 @@ public class RequestPanel extends JPanel implements ActionListener { /** * Build a JPanel containing a text-area where the query is displayed. - * + * * @return The JPanel. */ private JPanel buildQueryPanel() { @@ -140,7 +140,7 @@ public class RequestPanel extends JPanel implements ActionListener { /** * Update the query JTextArea. - * + * * @param query The string literal to put in the text-area, which will override the old content. */ public void updateQueryArea(String query) { @@ -149,16 +149,16 @@ public class RequestPanel extends JPanel implements ActionListener { /** * Build a JPanel containing the button(s), particularly the `Send` button. - * + * * @return The JPanel . */ private JPanel buildButtonPanel() { JPanel buttonPanel = new JPanel(); JButton btnSend = new JButton("Send query"); - btnSend.setName(BTN_NAME); + btnSend.setName(RequestPanel.BTN_NAME); btnSend.addActionListener(this); buttonPanel.add(btnSend); - buttonPanel.setMaximumSize(new Dimension(1000, BUTTON_PANEL_HEIGHT)); + buttonPanel.setMaximumSize(new Dimension(1000, RequestPanel.BUTTON_PANEL_HEIGHT)); return buttonPanel; } @@ -168,8 +168,8 @@ public class RequestPanel extends JPanel implements ActionListener { */ @Override public void actionPerformed(ActionEvent evt) { - if (((JButton) evt.getSource()).getName() == BTN_NAME) { - this.mainView.event(Event.SEND_BUTTON_CLICKED, queryArea.getText()); + if (((JButton) evt.getSource()).getName() == RequestPanel.BTN_NAME) { + mainView.event(Event.SEND_BUTTON_CLICKED, queryArea.getText()); } } diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/view/panels/ResultsPanel.java b/src/main/java/eu/omp/irap/vespa/epntapclient/view/panels/ResultsPanel.java index c2ab818..c3291b5 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/view/panels/ResultsPanel.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/view/panels/ResultsPanel.java @@ -3,7 +3,7 @@ * This program aims to provide EPN-TAP support for software clients, like CASSIS spectrum analyzer. * See draft specifications: https://voparis-confluence.obspm.fr/pages/viewpage.action?pageId=559861 * Copyright (C) 2016 Institut de Recherche en Astrophysique et Planétologie. - * + * * This program is free software: you can * redistribute it and/or modify it under the terms of the GNU General Public License as published * by the Free Software Foundation, either version 3 of the License, or (at your option) any later @@ -37,28 +37,17 @@ public class ResultsPanel extends JPanel { @SuppressWarnings("unused") private static final Logger logger = Logger.getLogger(ResultsPanel.class.getName()); - /** The main view of the application. */ - @SuppressWarnings("unused") - private EpnTapMainView mainView; - - /** The generic view of the VOTable panel. */ - @SuppressWarnings("unused") - private VOTableView voTableView; - /** * Method constructor which customize the result panel, but don't build it from scratch since * VOTableView is already created by ResultController. - * + * * @param mainView The main view of the application. * @param voTableView The generic view of the VOTable panel. */ public ResultsPanel(EpnTapMainView mainView, VOTableView voTableView) { super(); - this.mainView = mainView; - this.voTableView = voTableView; - - this.setLayout(new BorderLayout()); + setLayout(new BorderLayout()); this.add(voTableView); setPreferredSize(new Dimension(Dim.LEFT_PANEL_WIDTH + Dim.RIGHT_PANEL_WIDTH, diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/view/panels/ServicesPanel.java b/src/main/java/eu/omp/irap/vespa/epntapclient/view/panels/ServicesPanel.java index 41020e2..03abe3f 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/view/panels/ServicesPanel.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/view/panels/ServicesPanel.java @@ -3,7 +3,7 @@ * This program aims to provide EPN-TAP support for software clients, like CASSIS spectrum analyzer. * See draft specifications: https://voparis-confluence.obspm.fr/pages/viewpage.action?pageId=559861 * Copyright (C) 2016 Institut de Recherche en Astrophysique et Planétologie. - * + * * This program is free software: you can * redistribute it and/or modify it under the terms of the GNU General Public License as published * by the Free Software Foundation, either version 3 of the License, or (at your option) any later @@ -33,32 +33,27 @@ import eu.omp.irap.vespa.epntapclient.votable.view.VOTableView; * @author N. Jourdane */ public class ServicesPanel extends JPanel { - /** The serial version UID (affected with a random number). */ - private static final long serialVersionUID = 7850369546415832758L; + /** The serial version UID. */ + private static final long serialVersionUID = 1L; /** The logger for the class ServicesView. */ @SuppressWarnings("unused") private static final Logger logger = Logger.getLogger(ServicesPanel.class.getName()); - /** The main view of the application. */ - @SuppressWarnings("unused") - private EpnTapMainView mainView; - /** The generic view of the VOTable panel. */ private VOTableView voTableView; /** * Method constructor which customize the services panel, but don't build it from scratch since * VOTableView is already created by ServicesController. Add also the JTable listener. - * + * * @param mainView The main view of the application. * @param voTableView The generic view of the VOTable panel. */ public ServicesPanel(final EpnTapMainView mainView, final VOTableView voTableView) { super(); - this.mainView = mainView; this.voTableView = voTableView; - this.setLayout(new BorderLayout()); + setLayout(new BorderLayout()); this.add(voTableView); setPreferredSize(new Dimension(Dim.LEFT_PANEL_WIDTH, Dim.TOP_PANEL_HEIGHT)); @@ -80,7 +75,7 @@ public class ServicesPanel extends JPanel { * @return The URL of the service corresponding to the row. */ public String getServiceURL(int row) { - return (String) this.voTableView.getValueAt(5, row); + return (String) voTableView.getValueAt(5, row); } /** @@ -88,6 +83,6 @@ public class ServicesPanel extends JPanel { * @return The table name of the service corresponding to the row. */ public String getTableName(int row) { - return (String) this.voTableView.getValueAt(2, row); + return (String) voTableView.getValueAt(2, row); } } diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/votable/VOTableApp.java b/src/main/java/eu/omp/irap/vespa/epntapclient/votable/VOTableApp.java index 3e67d9a..cecdb12 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/votable/VOTableApp.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/votable/VOTableApp.java @@ -3,7 +3,7 @@ * This program aims to provide EPN-TAP support for software clients, like CASSIS spectrum analyzer. * See draft specifications: https://voparis-confluence.obspm.fr/pages/viewpage.action?pageId=559861 * Copyright (C) 2016 Institut de Recherche en Astrophysique et Planétologie. - * + * * This program is free software: you can * redistribute it and/or modify it under the terms of the GNU General Public License as published * by the Free Software Foundation, either version 3 of the License, or (at your option) any later @@ -42,19 +42,19 @@ public class VOTableApp { /** * Main function to start the application as standalone. - * + * *
 	 * **Usage 1**: `VOtableApp pathToVOTable`
 	 * Display the VOTable stored in the specified XML file.
 	 * - `pathToVOTable`: The path to an XML file representing a VOtable;
-	 * 
+	 *
 	 * **Usage 2**: `VOtableApp targetURL type language query`
 	 * Display the VOTable resulting the service or registry request.
 	 * - `targetURL`: The URL of the service or registry to ask, ie `http://cdpp-epntap.cesr.fr`;
 	 * - `language`: The language of the query, ie `ADQL`;
 	 * - `query`: The query in the specified language in double quotes, ie. `"SELECT * FROM amdadb.epn_core"`
 	 * 
- * + * * @param args The program arguments */ public static void main(final String[] args) { @@ -63,13 +63,14 @@ public class VOTableApp { public void run() { // TODO: Add option to export to CSV and HTML in CLI. VOTableController voTableControl; - logger.info("Lauching VOTable app with arguments:\n " + new Gson().toJson(args)); + VOTableApp.logger + .info("Lauching VOTable app with arguments:\n " + new Gson().toJson(args)); if (args.length == 1) { try { voTableControl = new VOTableController(args[0]); } catch (VOTableException e) { System.console().writer().println("Error: " + e.getMessage()); - logger.log(Level.WARNING, e.getMessage(), e); + VOTableApp.logger.log(Level.WARNING, e.getMessage(), e); return; } } else if (args.length == 3) { diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/votable/controller/VOTableConnection.java b/src/main/java/eu/omp/irap/vespa/epntapclient/votable/controller/VOTableConnection.java index 7a9d2e0..f156966 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/votable/controller/VOTableConnection.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/votable/controller/VOTableConnection.java @@ -3,7 +3,7 @@ * This program aims to provide EPN-TAP support for software clients, like CASSIS spectrum analyzer. * See draft specifications: https://voparis-confluence.obspm.fr/pages/viewpage.action?pageId=559861 * Copyright (C) 2016 Institut de Recherche en Astrophysique et Planétologie. - * + * * This program is free software: you can * redistribute it and/or modify it under the terms of the GNU General Public License as published * by the Free Software Foundation, either version 3 of the License, or (at your option) any later @@ -40,7 +40,7 @@ import eu.omp.irap.vespa.epntapclient.votable.utils.Const; /** * This class provide HTTP connection support to send requests through POST / GET protocols. - * + * * @author N. Jourdane */ public final class VOTableConnection { @@ -77,9 +77,10 @@ public final class VOTableConnection { throw new CantSendQueryException.MalformedURLException(uri, e); } - logger.info("request: " + uri + "?" + parameters); + VOTableConnection.logger.info("request: " + uri + "?" + parameters); try { - printRequestResult(sendGet(uri, parameters), voTablePath); + VOTableConnection.printRequestResult(VOTableConnection.sendGet(uri, parameters), + voTablePath); } catch (IOException e) { throw new CantPrintRequestResultException(voTablePath, e); } @@ -115,7 +116,7 @@ public final class VOTableConnection { throw new CantOpenConnectionException(uri, e); } - con.setRequestProperty("User-Agent", USER_AGENT); + con.setRequestProperty("User-Agent", VOTableConnection.USER_AGENT); int code = -1; try { @@ -134,7 +135,7 @@ public final class VOTableConnection { } in.close(); } catch (IOException e1) { - logger.log(Level.WARNING, "Can not get input stream", e1); + VOTableConnection.logger.log(Level.WARNING, "Can not get input stream", e1); try (BufferedReader in = new BufferedReader( new InputStreamReader(con.getErrorStream()))) { while ((inputLine = in.readLine()) != null) { @@ -151,7 +152,7 @@ public final class VOTableConnection { /** * Print result of the query in a file. - * + * * @param response The request response content. * @param resultFileName The name of the file where the request response content is writed. * @throws IOException File not found or bad encoding. diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/votable/controller/VOTableController.java b/src/main/java/eu/omp/irap/vespa/epntapclient/votable/controller/VOTableController.java index 3148d21..a3e6954 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/votable/controller/VOTableController.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/votable/controller/VOTableController.java @@ -3,7 +3,7 @@ * This program aims to provide EPN-TAP support for software clients, like CASSIS spectrum analyzer. * See draft specifications: https://voparis-confluence.obspm.fr/pages/viewpage.action?pageId=559861 * Copyright (C) 2016 Institut de Recherche en Astrophysique et Planétologie. - * + * * This program is free software: you can * redistribute it and/or modify it under the terms of the GNU General Public License as published * by the Free Software Foundation, either version 3 of the License, or (at your option) any later @@ -51,7 +51,7 @@ public class VOTableController { /** * Method constructor - * + * * @param voTablePath The path of the VOTable XML file. * @throws VOTableException If something went wrong on the VOTable view or when filling table. */ @@ -62,7 +62,7 @@ public class VOTableController { /** * Method constructor - * + * * @param targetURL The URL of the registry to communicate (ie. "http://reg.g-vo.org"). * @param queryLanguage The language used for the queries (ie. "ADQL"). * @param query The query to ask to the registry. @@ -73,7 +73,7 @@ public class VOTableController { try { fillTable(VOTableConnection.sendQuery(targetURL, queryLanguage, query)); } catch (VOTableException e) { - logger.info("VOTableController error: " + e); + VOTableController.logger.info("VOTableController error: " + e); } } @@ -114,7 +114,7 @@ public class VOTableController { throw new SeveralTablesException(voTablePath); } - Table table = (Table) (voTable.getRESOURCE().get(0).getLINKAndTABLEOrRESOURCE().get(0)); + Table table = (Table) voTable.getRESOURCE().get(0).getLINKAndTABLEOrRESOURCE().get(0); VOTableDataParser dataParser; try { diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/votable/controller/VOTableDataParser.java b/src/main/java/eu/omp/irap/vespa/epntapclient/votable/controller/VOTableDataParser.java index 139aa64..cede09e 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/votable/controller/VOTableDataParser.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/votable/controller/VOTableDataParser.java @@ -3,7 +3,7 @@ * This program aims to provide EPN-TAP support for software clients, like CASSIS spectrum analyzer. * See draft specifications: https://voparis-confluence.obspm.fr/pages/viewpage.action?pageId=559861 * Copyright (C) 2016 Institut de Recherche en Astrophysique et Planétologie. - * + * * This program is free software: you can * redistribute it and/or modify it under the terms of the GNU General Public License as published * by the Free Software Foundation, either version 3 of the License, or (at your option) any later @@ -61,7 +61,7 @@ public class VOTableDataParser { * In VOTables, data can be stored in 4 different serializations: BINARY, BINARY2, TABLEDATA and * FITS. This class aims to provide a unique way to get the data table, regardless of its * serialization type. - * + * * @param table The table on which we want get the data. * @throws IOException If the VOTable data can not be parsed. */ @@ -78,18 +78,18 @@ public class VOTableDataParser { for (int i = 0; i < fields.size(); i++) { columnsName[i] = fields.get(i).getName(); } - logger.info("Columns name: " + new Gson().toJson(columnsName)); + VOTableDataParser.logger.info("Columns name: " + new Gson().toJson(columnsName)); data = new ArrayList<>(); if (table.getDATA().getBINARY() != null) { parseBinaryStream(table.getDATA().getBINARY().getSTREAM(), fields); } else if (table.getDATA().getBINARY2() != null) { - parseBinary2Stream(table.getDATA().getBINARY2().getSTREAM(), fields); + VOTableDataParser.parseBinary2Stream(table.getDATA().getBINARY2().getSTREAM(), fields); } else if (table.getDATA().getTABLEDATA() != null) { - parseTableDataStream(table.getDATA().getTABLEDATA(), fields); + VOTableDataParser.parseTableDataStream(table.getDATA().getTABLEDATA(), fields); } else if (table.getDATA().getFITS() != null) { - parseFITSStream(table.getDATA().getFITS().getSTREAM(), fields); + VOTableDataParser.parseFITSStream(table.getDATA().getFITS().getSTREAM(), fields); } Utils.printObject("voTableData", data); @@ -118,8 +118,9 @@ public class VOTableDataParser { int i = 0; while (!column.equals(columnsName[i])) { i++; - if (i > columnsName.length) + if (i > columnsName.length) { throw new IllegalArgumentException("Column " + column + " not found in the table."); + } } return i; } @@ -166,8 +167,9 @@ public class VOTableDataParser { */ public Object[] getRowByValue(int columnIndex, Object value) { for (Object[] row : data) { - if (value.equals(row[columnIndex])) + if (value.equals(row[columnIndex])) { return row; + } } throw new IndexOutOfBoundsException( "The value " + value + " is not found on the table at the column " + columnIndex); @@ -175,13 +177,13 @@ public class VOTableDataParser { /** * get the data on its BINARY form. - * + * * @param voStream the data Stream in the VOTable Table. * @param fields The Fields corresponding to the Table. * @throws UnsupportedOperationException Data as arrays are not supported yet. */ private void parseBinaryStream(Stream voStream, List fields) { - logger.info("Parsing data in BINARY stream..."); + VOTableDataParser.logger.info("Parsing data in BINARY stream..."); String strStream = voStream.getValue().replaceAll("(\\r|\\n)", ""); stream = ByteBuffer.wrap(DatatypeConverter.parseBase64Binary(strStream)); @@ -216,7 +218,7 @@ public class VOTableDataParser { } else { arraySize = Integer.parseInt(column.getArraysize()) * blockSize; } - if ((arraySize != blockSize) && !(dataType.equals(DataType.CHAR) + if (arraySize != blockSize && !(dataType.equals(DataType.CHAR) || dataType.equals(DataType.UNICODE_CHAR))) { throw new UnsupportedOperationException("Numeric data as array are not supported."); } @@ -252,7 +254,7 @@ public class VOTableDataParser { } else if (dataType.equals(DataType.DOUBLE)) { row[nColumn] = stream.getDouble(); } else { - logger.warning("Data type " + dataType + " is not supported."); + VOTableDataParser.logger.warning("Data type " + dataType + " is not supported."); } // logger.debug(columnsName[nColumn] + ": " + row[nColumn]) @@ -271,7 +273,7 @@ public class VOTableDataParser { * @param fields The Fields corresponding to the Table. */ private static void parseBinary2Stream(Stream stream, List fields) { - logger.info("Parsing data in BINARY2 stream..."); + VOTableDataParser.logger.info("Parsing data in BINARY2 stream..."); // TODO Implement parseBinary2Stream() } @@ -280,7 +282,7 @@ public class VOTableDataParser { * @param fields The Fields corresponding to the Table. */ private static void parseTableDataStream(TableData tabledata, List fields) { - logger.info("Parsing data in TABLEDATA stream..."); + VOTableDataParser.logger.info("Parsing data in TABLEDATA stream..."); // TODO Implement parseTableDataStream() } @@ -289,7 +291,7 @@ public class VOTableDataParser { * @param fields The Fields corresponding to the Table. */ private static void parseFITSStream(Stream stream, List fields) { - logger.info("Parsing data in FITS stream..."); + VOTableDataParser.logger.info("Parsing data in FITS stream..."); // TODO Implement parseFITSStream() } } diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/votable/controller/VOTableException.java b/src/main/java/eu/omp/irap/vespa/epntapclient/votable/controller/VOTableException.java index e29fca0..f384163 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/votable/controller/VOTableException.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/votable/controller/VOTableException.java @@ -3,7 +3,7 @@ * This program aims to provide EPN-TAP support for software clients, like CASSIS spectrum analyzer. * See draft specifications: https://voparis-confluence.obspm.fr/pages/viewpage.action?pageId=559861 * Copyright (C) 2016 Institut de Recherche en Astrophysique et Planétologie. - * + * * This program is free software: you can * redistribute it and/or modify it under the terms of the GNU General Public License as published * by the Free Software Foundation, either version 3 of the License, or (at your option) any later @@ -21,13 +21,12 @@ import java.io.IOException; /** * VOTableException is the global exception for all the VOTable application. All other exceptions * should extend it. - * + * * @author N. Jourdane */ -@SuppressWarnings("serial") public abstract class VOTableException extends Exception { - /** The serial version UID (affected with a random number). */ - private static final long serialVersionUID = -5707662871529583209L; + /** The serial version UID. */ + private static final long serialVersionUID = 1L; /** * @param message The message describing the exception displayed in the error dialog. @@ -47,6 +46,9 @@ public abstract class VOTableException extends Exception { /** Abstract exception for when the application can not send the query. */ public abstract static class CantSendQueryException extends VOTableException { + /** */ + private static final long serialVersionUID = 1L; + /** * @param message The message describing the exception displayed in the error dialog. */ @@ -65,6 +67,9 @@ public abstract class VOTableException extends Exception { /** The URL is not correctly formated. */ public static class MalformedURLException extends CantSendQueryException { + /** */ + private static final long serialVersionUID = 1L; + /** * @param uri The URI sent to the server. * @param e The exception thrown. @@ -77,6 +82,9 @@ public abstract class VOTableException extends Exception { /** Can not print the result in the file. */ public static class CantPrintRequestResultException extends CantSendQueryException { + /** */ + private static final long serialVersionUID = 1L; + /** * @param resultFilePath The path of the file where the query results should be stored. * @param e The exception thrown. @@ -89,6 +97,9 @@ public abstract class VOTableException extends Exception { /** Can not open an HTTP connection to the specified URL. */ public static class CantOpenConnectionException extends CantSendQueryException { + /** */ + private static final long serialVersionUID = 1L; + /** * @param uri The URI sent to the server. * @param e The exception thrown. @@ -101,6 +112,9 @@ public abstract class VOTableException extends Exception { /** Can not get the server response code for the request. */ public static class CantGetResponseCode extends CantSendQueryException { + /** */ + private static final long serialVersionUID = 1L; + /** * @param uri The URI sent to the server. * @param e The exception thrown. @@ -113,6 +127,9 @@ public abstract class VOTableException extends Exception { /** The server returned the bad response code (but not 400). */ public static class BadResponseCodeException extends CantSendQueryException { + /** */ + private static final long serialVersionUID = 1L; + /** * @param uri The URI sent to the server. * @param responseCode The HTTP GET response code, which is bad. @@ -126,6 +143,9 @@ public abstract class VOTableException extends Exception { /** Can not get the input stream of the result, neither the error stream. */ public static class CantGetErrorStream extends CantSendQueryException { + /** */ + private static final long serialVersionUID = 1L; + /** * @param uri The URI sent to the server. * @param e The exception thrown. @@ -141,6 +161,9 @@ public abstract class VOTableException extends Exception { /** Abstract exception for when the application can not display the VOTable. */ public abstract static class CantDisplayVOTableException extends VOTableException { + /** */ + private static final long serialVersionUID = 1L; + /** * @param message The message describing the exception displayed in the error dialog. * @param e The exception thrown. @@ -159,6 +182,9 @@ public abstract class VOTableException extends Exception { /** Can not parse the VOTable because it doesn't match with the VOTable schema. */ public static class VOTableIsNotValidException extends CantDisplayVOTableException { + /** */ + private static final long serialVersionUID = 1L; + /** * @param voTablePath The path of the VOTable. * @param e The exception thrown. @@ -172,6 +198,9 @@ public abstract class VOTableException extends Exception { /** VOTable with more than one resource are not yet supported. */ public static class SeveralResourcesException extends CantDisplayVOTableException { + /** */ + private static final long serialVersionUID = 1L; + /** * @param voTablePath The path of the VOTable. */ @@ -184,6 +213,9 @@ public abstract class VOTableException extends Exception { /** VOTable with more than one resource are not yet supported. */ public static class SeveralTablesException extends CantDisplayVOTableException { + /** */ + private static final long serialVersionUID = 1L; + /** * @param voTablePath The path of the VOTable. */ @@ -195,6 +227,9 @@ public abstract class VOTableException extends Exception { /** Can not change schema location on the VOTable file. */ public static class CantModifyVOTableException extends CantDisplayVOTableException { + /** */ + private static final long serialVersionUID = 1L; + /** * @param voTablePath The path of the VOTable. * @param e The exception thrown. @@ -206,6 +241,9 @@ public abstract class VOTableException extends Exception { /** There is an error in the VOTable. */ public static class ErrorMessageInVOTableException extends CantDisplayVOTableException { + /** */ + private static final long serialVersionUID = 1L; + /** * @param errorInfo The information about the error, which comes from the VOTable itself * from the "INFO" node. diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/votable/controller/VOTableParser.java b/src/main/java/eu/omp/irap/vespa/epntapclient/votable/controller/VOTableParser.java index 3ebcd6b..8335cf2 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/votable/controller/VOTableParser.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/votable/controller/VOTableParser.java @@ -3,7 +3,7 @@ * This program aims to provide EPN-TAP support for software clients, like CASSIS spectrum analyzer. * See draft specifications: https://voparis-confluence.obspm.fr/pages/viewpage.action?pageId=559861 * Copyright (C) 2016 Institut de Recherche en Astrophysique et Planétologie. - * + * * This program is free software: you can * redistribute it and/or modify it under the terms of the GNU General Public License as published * by the Free Software Foundation, either version 3 of the License, or (at your option) any later @@ -74,12 +74,12 @@ public final class VOTableParser { VOTABLE voTable; JAXBContext jc; try { - changeVOTableSchemaLocation(voTablePath); + VOTableParser.changeVOTableSchemaLocation(voTablePath); } catch (IOException e) { throw new CantModifyVOTableException(voTablePath, e); } try { - jc = JAXBContext.newInstance(VOTABLE_MODEL_PACKAGE); + jc = JAXBContext.newInstance(VOTableParser.VOTABLE_MODEL_PACKAGE); Unmarshaller unmarshaller = jc.createUnmarshaller(); voTable = (VOTABLE) unmarshaller.unmarshal(new File(voTablePath)); } catch (JAXBException e) { @@ -94,7 +94,7 @@ public final class VOTableParser { * allows JAXB to parse the VOTable even it's not the same namespace than the XSD. Because * VOTables schemas are retro-compatibles, there is no problem to parse a VOTable with a XML * schema with a higher version. In the same way, this method check if the file is a valid XML. - * + * * @param voTablePath The path of the VOTable XML file. * @throws IOException Can not read or write the XML file. */ @@ -107,12 +107,14 @@ public final class VOTableParser { NamedNodeMap votAttrs = doc.getFirstChild().getAttributes(); String version = votAttrs.getNamedItem("version").getTextContent(); - if (version != JAXB_VOTABLE_VERSION) { - logger.info("VOTable version is " + version + ", changing VOTable svhema to " - + JAXB_VOTABLE_VERSION); - votAttrs.getNamedItem("xmlns").setTextContent(VOTABLE_SHEMA + JAXB_VOTABLE_VERSION); + if (version != VOTableParser.JAXB_VOTABLE_VERSION) { + VOTableParser.logger + .info("VOTable version is " + version + ", changing VOTable svhema to " + + VOTableParser.JAXB_VOTABLE_VERSION); + votAttrs.getNamedItem("xmlns").setTextContent( + VOTableParser.VOTABLE_SHEMA + VOTableParser.JAXB_VOTABLE_VERSION); } else { - logger.info("VOTable version is " + version + ", everything is ok."); + VOTableParser.logger.info("VOTable version is " + version + ", everything is ok."); } Transformer transformer = TransformerFactory.newInstance().newTransformer(); diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/votable/utils/Const.java b/src/main/java/eu/omp/irap/vespa/epntapclient/votable/utils/Const.java index 69af4f6..09a77cf 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/votable/utils/Const.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/votable/utils/Const.java @@ -3,7 +3,7 @@ * This program aims to provide EPN-TAP support for software clients, like CASSIS spectrum analyzer. * See draft specifications: https://voparis-confluence.obspm.fr/pages/viewpage.action?pageId=559861 * Copyright (C) 2016 Institut de Recherche en Astrophysique et Planétologie. - * + * * This program is free software: you can * redistribute it and/or modify it under the terms of the GNU General Public License as published * by the Free Software Foundation, either version 3 of the License, or (at your option) any later @@ -18,7 +18,7 @@ package eu.omp.irap.vespa.epntapclient.votable.utils; /** * This class defines widely-used constants. - * + * * @author N. Jourdane */ public class Const { diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/votable/utils/Utils.java b/src/main/java/eu/omp/irap/vespa/epntapclient/votable/utils/Utils.java index 99114b6..7318930 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/votable/utils/Utils.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/votable/utils/Utils.java @@ -3,7 +3,7 @@ * This program aims to provide EPN-TAP support for software clients, like CASSIS spectrum analyzer. * See draft specifications: https://voparis-confluence.obspm.fr/pages/viewpage.action?pageId=559861 * Copyright (C) 2016 Institut de Recherche en Astrophysique et Planétologie. - * + * * This program is free software: you can * redistribute it and/or modify it under the terms of the GNU General Public License as published * by the Free Software Foundation, either version 3 of the License, or (at your option) any later @@ -39,7 +39,7 @@ public class Utils { /** * StringJoiner has the same purpose of Java 8 StringJoiner, it has been rewritten for Java7 * compatibility. - * + * * @author N. Jourdane */ public static class StringJoiner { @@ -52,18 +52,18 @@ public class Utils { /** * Method constructor for the String joiner. - * + * * @param separator The string joiner separator to put between each word, ie. ';'. */ public StringJoiner(String separator) { this.separator = separator; - this.list = new ArrayList<>(); + list = new ArrayList<>(); string = ""; } /** * add a new word to the joiner. - * + * * @param text The word to add. */ public void add(String text) { @@ -82,7 +82,7 @@ public class Utils { /** * Print the specified object in JSON format in a file on the temporary directory. - * + * * @param title The name of the file. * @param obj the object to print in a file. * @return The path of the file. @@ -95,9 +95,9 @@ public class Utils { writer.write(json); } catch (IOException e) { - logger.warning("Can not print in the file " + path + e); + Utils.logger.warning("Can not print in the file " + path + e); } - logger.info("A json file representing " + title + " (" + obj.getClass().getName() + Utils.logger.info("A json file representing " + title + " (" + obj.getClass().getName() + ") has been created on " + path); return path; diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/votable/view/VOTableView.java b/src/main/java/eu/omp/irap/vespa/epntapclient/votable/view/VOTableView.java index bb9f856..03ace3b 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/votable/view/VOTableView.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/votable/view/VOTableView.java @@ -3,7 +3,7 @@ * This program aims to provide EPN-TAP support for software clients, like CASSIS spectrum analyzer. * See draft specifications: https://voparis-confluence.obspm.fr/pages/viewpage.action?pageId=559861 * Copyright (C) 2016 Institut de Recherche en Astrophysique et Planétologie. - * + * * This program is free software: you can * redistribute it and/or modify it under the terms of the GNU General Public License as published * by the Free Software Foundation, either version 3 of the License, or (at your option) any later @@ -32,7 +32,7 @@ import eu.omp.irap.vespa.epntapclient.votable.utils.Utils; /** * The main class of the View of the application. - * + * * @author N. Jourdane */ public class VOTableView extends JPanel implements TableModelListener { @@ -40,8 +40,8 @@ public class VOTableView extends JPanel implements TableModelListener { static final Logger logger = Logger.getLogger(VOTableView.class.getName()); // TODO: Create class VOTableCLI the view for a CLI usage - /** The serial version UID (affected with a random number). */ - private static final long serialVersionUID = -6131752938586134234L; + /** The serial version UID. */ + private static final long serialVersionUID = 1L; /** The JTable component where the data are displayed. */ JTable table; @@ -54,8 +54,8 @@ public class VOTableView extends JPanel implements TableModelListener { */ public VOTableView() { tableData = new DefaultTableModel() { - /** The serial version UID (affected with a random number). */ - private static final long serialVersionUID = 8195913508549662555L; + /** The serial version UID. */ + private static final long serialVersionUID = 1L; @Override public boolean isCellEditable(int row, int column) { @@ -75,7 +75,7 @@ public class VOTableView extends JPanel implements TableModelListener { /** * Fill the JTable. - * + * * @param columns the column names * @param data The VoTable data displayed on the JTable */ @@ -83,8 +83,9 @@ public class VOTableView extends JPanel implements TableModelListener { Object[][] values = data.toArray(new Object[data.size()][]); Utils.printObject("tableData", values); tableData.setDataVector(values, columns); - if (values.length != 0) + if (values.length != 0) { table.setRowSelectionInterval(0, 0); + } } /** @@ -106,8 +107,9 @@ public class VOTableView extends JPanel implements TableModelListener { @Override public void tableChanged(TableModelEvent e) { - if (e.getType() != TableModelEvent.UPDATE) + if (e.getType() != TableModelEvent.UPDATE) { return; + } } } -- libgit2 0.21.2