Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2007

Tip: Looking for answers? Try searching our database.

ANT condition is(not)set

Thread view: 
nuthinking@googlemail.com - 28 Nov 2007 15:09 GMT
Hi guys, it is a while I'm trying to look a way to have an optional
property in a property file that if set will override a property in
another property file (that will act thus as default value). With the
little knowledge my logic would have been: if the optional parameter
is missing I will create it assigning it the default value. I'm stuck
because as condition I can use "isset" but in this case I reckon I
should use something like "isnotset" that doesn't seem to exist. Am I
clear?

Any hint? Thanks a lot,

chr
Lew - 28 Nov 2007 19:52 GMT
> Hi guys, it is a while I'm trying to look a way to have an optional
> property in a property file that if set will override a property in
[quoted text clipped - 6 lines]
>
> Any hint? Thanks a lot,

The java.util.Properties class itself has a default property mechanism.
<http://java.sun.com/javase/6/docs/api/java/util/Properties.html>
> A property list can contain another property list as its "defaults";
> this second property list is searched if the property key is not found
> in the original property list.

Javadocs is grand, ain't they?

Signature

Lew

Owen Jacobson - 28 Nov 2007 20:46 GMT
On Nov 28, 7:09 am, "nuthink...@googlemail.com"
<nuthink...@googlemail.com> wrote:
> Hi guys, it is a while I'm trying to look a way to have an optional
> property in a property file that if set will override a property in
[quoted text clipped - 8 lines]
>
> chr

In Ant, properties can be set at most once during any build cycle.
The first attempt to set a property sets it; the remainder are
ignored.  So, load your properties file first using <property
file="..." />, then set the property explicitly using <property
name="foo.bar" value="x" />.  If the file includes foo.bar, the
default will be suppressed.
nuthinking@googlemail.com - 29 Nov 2007 09:33 GMT
> On Nov 28, 7:09 am, "nuthink...@googlemail.com"
>
[quoted text clipped - 18 lines]
> name="foo.bar" value="x" />.  If the file includes foo.bar, the
> default will be suppressed.

Hi Owen, how stupid was I, your solution is definitely the one I
needed, I just had to change the order the property files are loaded.

Best, chr


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.