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 09:11:44 GMT
I was kind of wondering about Linux == Unix, but just recoded it as I
saw it.

So your saying that potentially there could be a Solaris family
encompassing all Solaris versions, Windows NT family encompassing NT,
2000, XP?

Without thinking too hard about it, the only thing I can think of is to
use a byte as the enumeration type then AND them together and compare.
That will allow a boolean method  isOSFamilyLinux and isOSFamilyUnix to
both return true  (and other possible options:  I think I heard OSX ).  

But that doesn't solve the getOSFamily() method frum returning a
OS_FAMILY_LINUX value which only equals itself.  

I'll think some more about it.




What's the reasoning behind wanting to differentiate between Linux and
Unix, but not SunOS and AIX?


- Andrew


> -----Original Message-----
> From: Stephen Colebourne [mailto:scolebourne@btopenworld.com] 
> Sent: Friday, August 23, 2002 4:28 AM
> To: Jakarta Commons Developers List
> Subject: Re: [lang] System properties
> 
> 
> Andrew,
> My original class returned an enumerated type, in a similar 
> way to the int that you are proposing.
> 
> On coding the [lang] version, I used static booleans for two reasons:
> 1) Lucene and Avalon Excalibur do it that way
> 2) An OS can be under multiple headings (Linux is both UNIX and LINUX)
> 
> I am open on this one, if you can meet (2) above.
> 
> Stephen
> 
> PS. Welcome to commons
> 
> ----- Original Message -----
> From: "Andrew Conrad" <andrewconrad@attbi.com>
> To: "'Jakarta Commons Developers List'" 
> <commons-dev@jakarta.apache.org>
> Sent: Friday, August 23, 2002 5:31 AM
> Subject: RE: [lang] System properties
> 
> 
> > 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>
> >
> 
> 
> --
> 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