Class JSamp


  • public class JSamp
    extends java.lang.Object
    Convenience class for invoking JSAMP command-line applications.
    Since:
    23 Jul 2008
    Author:
    Mark Taylor
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) static java.lang.String[] COMMAND_CLASSES
      Known command class names.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private JSamp()
      Private sole constructor prevents instantiation.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      private static java.lang.String abbrev​(java.lang.String className)
      Returns the abbreviated form of a given class name.
      private static java.lang.String formatImpls​(java.lang.Object[] options, java.lang.Class clazz)  
      (package private) static java.lang.reflect.Method getMainMethod​(java.lang.Class clazz)
      Returns the main(String[]) method for a given class.
      private static java.lang.String getVersionText()
      Returns a string giving version details for this package.
      static void main​(java.lang.String[] args)
      Main method.
      private static int runCommand​(java.lang.String className, java.lang.String[] args)
      Runs a command.
      static int runMain​(java.lang.String[] args)
      Does the work for the main method.
      private static void setDefaultProperty​(java.lang.String key, java.lang.String value)
      Sets a system property to a given value unless it has already been set.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • COMMAND_CLASSES

        static final java.lang.String[] COMMAND_CLASSES
        Known command class names.
    • Constructor Detail

      • JSamp

        private JSamp()
        Private sole constructor prevents instantiation.
    • Method Detail

      • runMain

        public static int runMain​(java.lang.String[] args)
        Does the work for the main method.
      • runCommand

        private static int runCommand​(java.lang.String className,
                                      java.lang.String[] args)
        Runs a command.
        Parameters:
        className - name of a class with a main(String[]) method
        args - arguments as if passed from the command line
      • getMainMethod

        static java.lang.reflect.Method getMainMethod​(java.lang.Class clazz)
        Returns the main(String[]) method for a given class.
      • abbrev

        private static java.lang.String abbrev​(java.lang.String className)
        Returns the abbreviated form of a given class name.
        Parameters:
        className - class name
        Returns:
        abbreviation
      • formatImpls

        private static java.lang.String formatImpls​(java.lang.Object[] options,
                                                    java.lang.Class clazz)
      • getVersionText

        private static java.lang.String getVersionText()
        Returns a string giving version details for this package.
        Returns:
        version string
      • setDefaultProperty

        private static void setDefaultProperty​(java.lang.String key,
                                               java.lang.String value)
        Sets a system property to a given value unless it has already been set. If it has a prior value, that is undisturbed. Potential security exceptions are caught and dealt with.
        Parameters:
        key - property name
        value - suggested property value
      • main

        public static void main​(java.lang.String[] args)
        Main method. Use -help flag for documentation.