Class ValidatorCLI
- java.lang.Object
- 
- org.openstreetmap.josm.data.validation.ValidatorCLI
 
- 
- All Implemented Interfaces:
- CLIModule
 
 public class ValidatorCLI extends java.lang.Object implements CLIModule Add a validate command to the JOSM command line interface.- Since:
- 18365
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description private static classValidatorCLI.Option
 - 
Field SummaryFields Modifier and Type Field Description private java.util.Map<java.lang.String,java.util.List<java.lang.String>>changeFilesThe change files.private java.util.List<java.lang.String>inputThe input file(s)static ValidatorCLIINSTANCEThe unique instance.private java.util.logging.LevellogLevelThe log levelprivate java.util.Map<java.lang.String,java.lang.String>outputThe output file(s).private static java.util.function.Supplier<ProgressMonitor>progressMonitorFactory
 - 
Constructor SummaryConstructors Constructor Description ValidatorCLI()
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetActionKeyword()Get the action keyword that the user needs to provide as first command line argument to invoke this module.private static java.lang.StringgetDefaultOutputName(java.lang.String inputString)Get the default output nameprivate static java.lang.String[]getFileParts(java.lang.String inputString)Split a string into a filename + extension.private static java.lang.StringgetHelp()private java.util.Optional<java.lang.String>handleOption(java.lang.String currentInput, ValidatorCLI.Option option, java.lang.String argument)Handle an optionprivate voidhandleOption(ValidatorCLI.Option option)(package private) voidinitialize()Initialize everything that might be needed Arguments may need to be parsed first.(package private) voidparseArguments(java.lang.String[] argArray)Parse command line arguments and do some low-level error checking.voidprocessArguments(java.lang.String[] argArray)Process the remaining command line arguments and run any of the requested actions.private voidprocessFile(java.lang.String inputFile)Process an OSM fileprivate static voidprocessMapcssFile(java.lang.String inputFile)Process a standard mapcss fileprivate static voidprocessValidatorFile(java.lang.String inputFile)Process a validator fileprivate static voidshowHelp()private voidwriteErrors(GeoJSONMapRouletteWriter geoJSONMapRouletteWriter, java.io.OutputStream fileOutputStream, java.util.Collection<TestError> errors)private voidwriteToFile(java.io.OutputStream fileOutputStream, byte[] bytes)Write to a file.
 
- 
- 
- 
Field Detail- 
INSTANCEpublic static final ValidatorCLI INSTANCE The unique instance.
 - 
inputprivate final java.util.List<java.lang.String> input The input file(s)
 - 
changeFilesprivate final java.util.Map<java.lang.String,java.util.List<java.lang.String>> changeFiles The change files. input file → list of change files
 - 
outputprivate final java.util.Map<java.lang.String,java.lang.String> output The output file(s). Ifnull, use input filename as base (replace extension with geojson). input → output
 - 
progressMonitorFactoryprivate static final java.util.function.Supplier<ProgressMonitor> progressMonitorFactory 
 - 
logLevelprivate java.util.logging.Level logLevel The log level
 
- 
 - 
Constructor Detail- 
ValidatorCLIpublic ValidatorCLI() 
 
- 
 - 
Method Detail- 
getActionKeywordpublic java.lang.String getActionKeyword() Description copied from interface:CLIModuleGet the action keyword that the user needs to provide as first command line argument to invoke this module.- Specified by:
- getActionKeywordin interface- CLIModule
- Returns:
- the action keyword of this module
 
 - 
processArgumentspublic void processArguments(java.lang.String[] argArray) Description copied from interface:CLIModuleProcess the remaining command line arguments and run any of the requested actions.- Specified by:
- processArgumentsin interface- CLIModule
- Parameters:
- argArray- command line arguments without the initial action keyword
 
 - 
processMapcssFileprivate static void processMapcssFile(java.lang.String inputFile) throws ParseException Process a standard mapcss file- Parameters:
- inputFile- The mapcss file to validate
- Throws:
- ParseException- if the file does not match the mapcss syntax
 
 - 
processValidatorFileprivate static void processValidatorFile(java.lang.String inputFile) throws ParseException, java.io.IOException Process a validator file- Parameters:
- inputFile- The file to check
- Throws:
- java.io.IOException- if there is a problem reading the file
- ParseException- if the file does not match the validator mapcss syntax
 
 - 
processFileprivate void processFile(java.lang.String inputFile) throws IllegalDataException, java.io.IOException Process an OSM file- Parameters:
- inputFile- The input filename
- Throws:
- java.lang.IllegalArgumentException- If an argument is not valid
- IllegalDataException- If there is bad data
- java.io.IOException- If a file could not be read or written
 
 - 
writeErrorsprivate void writeErrors(GeoJSONMapRouletteWriter geoJSONMapRouletteWriter, java.io.OutputStream fileOutputStream, java.util.Collection<TestError> errors) 
 - 
getDefaultOutputNameprivate static java.lang.String getDefaultOutputName(java.lang.String inputString) Get the default output name- Parameters:
- inputString- The input file
- Returns:
- The default output name for the input file (extension stripped, ".geojson" added)
 
 - 
getFilePartsprivate static java.lang.String[] getFileParts(java.lang.String inputString) Split a string into a filename + extension. Example: "foo.bar.txt" → ["foo.bar", "txt"]Please note that future versions of Java may make this method redundant. It is not as of Java 21 (look for something like Path#getExtension, see JDK-8298318. That may be in Java 22.- Parameters:
- inputString- The string to get the filename and extension from
- Returns:
- The filename and the (optional) extension
 
 - 
writeToFileprivate void writeToFile(java.io.OutputStream fileOutputStream, byte[] bytes) throws java.io.IOException Write to a file. Synchronized to avoid writing to the same file in different threads.- Parameters:
- fileOutputStream- The file output stream to read
- bytes- The bytes to write (surrounded by RS and LF)
- Throws:
- java.io.IOException- If we couldn't write to file
 
 - 
initializevoid initialize() Initialize everything that might be needed Arguments may need to be parsed first.
 - 
parseArgumentsvoid parseArguments(java.lang.String[] argArray) Parse command line arguments and do some low-level error checking.- Parameters:
- argArray- the arguments array
 
 - 
handleOptionprivate void handleOption(ValidatorCLI.Option option) 
 - 
handleOptionprivate java.util.Optional<java.lang.String> handleOption(java.lang.String currentInput, ValidatorCLI.Option option, java.lang.String argument) Handle an option- Parameters:
- currentInput- The current input file, if any. May be- null.
- option- The option to parse
- argument- The argument for the option
- Returns:
- The new input file, if any.
 
 - 
showHelpprivate static void showHelp() 
 - 
getHelpprivate static java.lang.String getHelp() 
 
- 
 
-