package org.geometrycommands;

import com.vividsolutions.jts.geom.Geometry;

/**
 * A Command that determines if the input Geometry is valid or not.
 * @author Jared Erickson
 */
public class IsValidCommand extends GeometryCommand<GeometryOptions> {

    /**
     * Get the name of the command
     * @return The name of the command
     */
    @Override
    public String getName() {
        return "isvalid";
    }

    /**
     * Get a new GeometryOptions
     * @return A new GeometryOptions
     */
    @Override
    public GeometryOptions getOptions() {
        return new GeometryOptions();
    }

    /**
     * Determine if the input Geometry is valid or not.
     * @param geometry The input Geometry
     * @param other The other Geometry
     * @param options The GeometryOptions
     * @throws Exception if an error occurs
     */
    @Override
    public void processGeometry(Geometry geometry, GeometryOptions options) throws Exception {
        boolean valid = geometry.isValid();
        System.out.println(valid);
    }
}

@@ -68,16 +68,166 @@
 eometry;
+%0Aimport com.vividsolutions.jts.operation.valid.IsValidOp;%0Aimport org.geometrycommands.IsValidCommand.IsValidOptions;%0Aimport org.kohsuke.args4j.Option;
 %0A%0A/**%0A *
@@ -374,24 +374,23 @@
 Command%3C
-Geometry
+IsValid
 Options%3E
@@ -581,32 +581,31 @@
 * Get a new 
-Geometry
+IsValid
 Options%0A    
@@ -617,32 +617,31 @@
 eturn A new 
-Geometry
+IsValid
 Options%0A    
@@ -669,24 +669,23 @@
  public 
-Geometry
+IsValid
 Options 
@@ -718,24 +718,23 @@
 urn new 
-Geometry
+IsValid
 Options(
@@ -914,24 +914,23 @@
 ons The 
-Geometry
+IsValid
 Options%0A
@@ -1046,24 +1046,23 @@
 ometry, 
-Geometry
+IsValid
 Options 
@@ -1101,78 +1101,1119 @@
     
-boolean valid = geometry.isValid();%0A        System.out.println(valid);
+IsValidOp op = new IsValidOp(geometry);%0A        boolean valid = op.isValid();%0A        System.out.println(valid);%0A        if (options.isShowingMessage()) %7B%0A            System.out.println(op.getValidationError().getMessage());%0A        %7D%0A    %7D%0A%0A    /**%0A     * The IsValidOptions%0A     */%0A    public static class IsValidOptions extends GeometryOptions %7B%0A%0A        /**%0A         * The flag to show the validation error message.%0A         */%0A        @Option(name = %22-msg%22, usage = %22The flag to show the validation error message.%22, required = false)%0A        private boolean showingMessage;%0A%0A        /**%0A         * Get the flag to show the validation error message.%0A         * @return The flag to show the validation error message.%0A         */%0A        public boolean isShowingMessage() %7B%0A            return showingMessage;%0A        %7D%0A%0A        /**%0A         * Set the flag to show the validation error message.%0A         * @param showingMessage The flag to show the validation error message.%0A         */%0A        public void setShowingMessage(boolean showingMessage) %7B%0A            this.showingMessage = showingMessage;%0A        %7D
 %0A   

Add an option for showing the validation error message.