org.rhq.core.pluginapi.util
Class JavaCommandLine

java.lang.Object
  extended by org.rhq.core.pluginapi.util.JavaCommandLine

public class JavaCommandLine
extends Object

Parses a java command line and provides easy access to its parts.

A Java command line looks like this:


   Usage: java [-options] class [args...]
         (to execute a class)
      or  java [-options] -jar jarfile [args...]
         (to execute a jar file)
 


Nested Class Summary
static class JavaCommandLine.OptionValueDelimiter
          When parsing command line options, specifies the valid option value delimiter(s).
 
Constructor Summary
JavaCommandLine(String... args)
          Same as JavaCommandLine(args, false, OptionFormat.POSIX, OptionFormat.POSIX)
JavaCommandLine(String[] args, boolean includeSystemPropertiesFromClassArguments)
          Same as JavaCommandLine(args, includeSystemPropertiesFromClassArguments, OptionFormat.POSIX, OptionFormat.POSIX)
JavaCommandLine(String[] args, boolean includeSystemPropertiesFromClassArguments, Set<JavaCommandLine.OptionValueDelimiter> shortClassOptionValueDelims, Set<JavaCommandLine.OptionValueDelimiter> longClassOptionValueDelims)
           
 
Method Summary
 List<String> getArguments()
           
 List<String> getClassArguments()
           
 String getClassOption(CommandLineOption option)
           
 String getClassOption(CommandLineOption option, String defaultValue)
           
 List<String> getClassPath()
           
 File getExecutableJarFile()
           
 File getJavaExecutable()
           
 List<String> getJavaOptions()
           
 String getMainClassName()
           
 Map<String,String> getSystemProperties()
           
 boolean isClassOptionPresent(CommandLineOption option)
           
protected  void processClassArgument(String classArg, String nextArg)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JavaCommandLine

public JavaCommandLine(String... args)
Same as JavaCommandLine(args, false, OptionFormat.POSIX, OptionFormat.POSIX)


JavaCommandLine

public JavaCommandLine(String[] args,
                       boolean includeSystemPropertiesFromClassArguments)
Same as JavaCommandLine(args, includeSystemPropertiesFromClassArguments, OptionFormat.POSIX, OptionFormat.POSIX)


JavaCommandLine

public JavaCommandLine(String[] args,
                       boolean includeSystemPropertiesFromClassArguments,
                       Set<JavaCommandLine.OptionValueDelimiter> shortClassOptionValueDelims,
                       Set<JavaCommandLine.OptionValueDelimiter> longClassOptionValueDelims)
Method Detail

processClassArgument

protected void processClassArgument(String classArg,
                                    String nextArg)

getArguments

@NotNull
public List<String> getArguments()

getJavaExecutable

@NotNull
public File getJavaExecutable()

getClassPath

@NotNull
public List<String> getClassPath()

getSystemProperties

@NotNull
public Map<String,String> getSystemProperties()

getJavaOptions

@NotNull
public List<String> getJavaOptions()

getMainClassName

@Nullable
public String getMainClassName()

getExecutableJarFile

@Nullable
public File getExecutableJarFile()

getClassArguments

@NotNull
public List<String> getClassArguments()

getClassOption

@Nullable
public String getClassOption(CommandLineOption option)
Parameters:
option - the class option to look for
Returns:
null if the class option is not on the command line, "" if it is on the command line and either has no value or expects no value, and otherwise the non-empty value.

getClassOption

@Nullable
public String getClassOption(CommandLineOption option,
                                      String defaultValue)
Parameters:
option - the class option to look for
defaultValue - the value to return if the specified class option is not on the command line
Returns:
null if the class option is not on the command line, "" if it is on the command line and either has no value or expects no value, and otherwise the non-empty value.

isClassOptionPresent

public boolean isClassOptionPresent(CommandLineOption option)

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2008-2012 Red Hat, Inc.. All Rights Reserved.