Skip to content

Commit

Permalink
checkstyle fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pdowler committed Dec 6, 2021
1 parent 3025427 commit 779f71b
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 51 deletions.
67 changes: 26 additions & 41 deletions cadc-vodml/src/main/java/ca/nrc/cadc/vodml/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,10 @@
* <http://www.gnu.org/licenses/>.
*
************************************************************************
*/
*/

package ca.nrc.cadc.vodml;


import ca.nrc.cadc.util.ArgumentMap;
import ca.nrc.cadc.util.Log4jInit;
import java.io.File;
Expand All @@ -83,78 +82,64 @@
*
* @author pdowler
*/
public class Main
{
public class Main {

private static final Logger log = Logger.getLogger(Main.class);
private static final String PKG = Main.class.getPackage().getName();

private Main() { }

public static void main(String[] args)
{
try
{

private Main() {
}

public static void main(String[] args) {
try {
ArgumentMap am = new ArgumentMap(args);
if (am.isSet("h") || am.isSet("help"))
{
if (am.isSet("h") || am.isSet("help")) {
usage();
System.exit(0);
}

if (am.isSet("d") || am.isSet("debug"))
{

if (am.isSet("d") || am.isSet("debug")) {
Log4jInit.setLevel(PKG, Level.DEBUG);
}
else if (am.isSet("v") || am.isSet("verbose"))
{
} else if (am.isSet("v") || am.isSet("verbose")) {
Log4jInit.setLevel(PKG, Level.INFO);
}
else
} else {
Log4jInit.setLevel(PKG, Level.WARN);
}

List<String> pargs = am.getPositionalArgs();
if (pargs.isEmpty())
{
if (pargs.isEmpty()) {
usage();
System.exit(1);
}

boolean warn = am.isSet("warn");
VOModelReader validator = new VOModelReader(true, true, warn);
for (String fname : pargs)
{
try
{
for (String fname : pargs) {
try {
log.info("validating: " + fname + " ...");
File f = new File(fname);
Reader fr = new FileReader(f);
Document doc = validator.read(fr);
log.info("validating: " + fname + " ... [OK]");
}
catch(JDOMException ex)
{
} catch (JDOMException ex) {
log.error("failed basic XML validation", ex);
System.exit(-1);
}
catch(SchematronValidationException ex)
{
} catch (SchematronValidationException ex) {
log.error("failed Schematron validation: " + ex.getMessage());
for (String msg : ex.getFailures())
for (String msg : ex.getFailures()) {
log.error(msg);
}
System.exit(-1);
}
}
}
catch(Throwable t)
{
} catch (Throwable t) {
log.error("uncaught exception", t);
System.exit(-1);
}
System.exit(0);
}

private static void usage()
{

private static void usage() {
System.out.println("usage: cadc-vodml [-v|--verbose|-d|--debug|-h|--help] <VO-DML/XML filename> ...");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,32 +63,29 @@
* <http://www.gnu.org/licenses/>.
*
************************************************************************
*/
*/

package ca.nrc.cadc.vodml;


import java.util.List;
import org.apache.log4j.Logger;

/**
*
* @author pdowler
*/
public class SchematronValidationException extends Exception
{
public class SchematronValidationException extends Exception {

private static final Logger log = Logger.getLogger(SchematronValidationException.class);

private final List<String> msgs;

public SchematronValidationException(int numFails, List<String> msgs)
{

public SchematronValidationException(int numFails, List<String> msgs) {
super(numFails + " failed assertions");
this.msgs = msgs;
}

public List<String> getFailures()
{
public List<String> getFailures() {
return msgs;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public void write(Document doc, OutputStream out)
OutputStreamWriter osw = new OutputStreamWriter(out);
write(doc, osw);
}

public void write(Document doc, Writer out) throws IOException {
XMLOutputter outputter = new XMLOutputter();
if (prettyPrint) {
Expand Down

0 comments on commit 779f71b

Please sign in to comment.