I'm just starting out to learn Java programming, starting with this basic piece of code:
public class MyApplication {public static void main(String[] args) {MainFrame frame = new MainFrame(); if (args.length > 0) /* Need to parse the argument list intelligently, not */ /* just assume that only fileNames are present. */ for (int A = 0; A < args.length; A++) frame.addDocument(new File(args[A])); else frame.insertNewDocument(); frame.setVisible(true); } }
As the comment says, I need to parse the command line text. Since there are only a handful of options to detect, using something like the Apache parser is rather like killing flies with a sledgehammer. :-) Looking at the various String methods, i see some deficiencies from what I have found useful, so I'd like to create some convenience methods to avoid making my mainline code too complicated.
The String class apparently cannot be extended or subclassed, but it occurred to me that methods owned by class MyApplication can perfectly well perform string manipulations; the only question is what attributes such methods need to have. These methods should be accessible globally, so I think that something along the lines of
where <returnType> might be String, int or bool and the number and type of arguments would vary depending on the method's purpose. Might these be the right sort of attributes for such methods?