commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrew Conrad" <andrewcon...@attbi.com>
Subject RE: [lang] System properties
Date Fri, 23 Aug 2002 04:31:07 GMT
I just joined the Commons-Dev, so don't shoot me for my comments but
here goes:

I was looking at your SystemUtils class, and I was thinking that using
it would be a little clumsy.


Instead of using boolean types for IS_WINDOWS and IS_UNIX, do you think
it would be more friendly if you used int types such as 

OS_TYPE_WINDOWS, OS_TYPE_UNIX and a static method getOSType() .


I was thinking of an execution that might want to branch, you could use
a switch instead of a lot of if/else's

		switch( SystemUtils.getOSType() ) {
			case SystemUtils.OS_TYPE_WINDOWS:
				break;
			case SystemUtils.OS_TYPE_WINDOWS:
				break;
		}

I guess it's probably just a preference of coding style....

Also, a different naming convention could be   OS_FAMILIY_   and
getOSFamily()

Just thinking out loud.   If you guys like this idea, I'm offering to
rewrite the class.


- Andrew



> -----Original Message-----
> From: Stephen Colebourne [mailto:scolebourne@btopenworld.com] 
> Sent: Thursday, August 22, 2002 3:59 PM
> To: Jakarta Commons Developers List
> Subject: [lang] System properties
> 
> 
> One part I find inconvenient about Java is the system 
> properties. These are looked up by a string name, and I can 
> never remember what the name is, so I have to go and look it 
> up the javadoc - a great waste of time.
> 
> The following code, is the solution in my library. Although 
> seemingly trivial, it means that any IDE can use code 
> completion to pick the value without needing to remember the 
> string name.
> 
>     public static final String LINE_SEPARATOR = 
> System.getProperty("line.separator");
>     public static final String PATH_SEPARATOR = 
> System.getProperty("path.separator");
>     public static final String FILE_SEPARATOR = 
> System.getProperty("file.separator");
>     public static final String WORKING_DIRECTORY = 
> System.getProperty("user.dir");
>     public static final String OS_NAME = 
> System.getProperty("os.name");
>     public static final String OS_ARCH = 
> System.getProperty("os.arch");
>     public static final String OS_VERSION = 
> System.getProperty("os.version");
>     public static final String JAVA_VERSION = 
> System.getProperty("java.version");
> 
> How about a SystemUtils for [lang] ?
> 
> Stephen
> 
> 
> --
> To unsubscribe, e-mail:   
> <mailto:commons-dev-> unsubscribe@jakarta.apache.org>
> For 
> additional commands, 
> e-mail: <mailto:commons-dev-help@jakarta.apache.org>
> 


--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message