commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oliver Heger <oliver.he...@oliver-heger.de>
Subject Re: [configuration] how to comment / uncomment particular property in Java *.properties files
Date Sat, 26 Apr 2014 19:35:25 GMT
Hello,

Am 26.04.2014 18:21, schrieb Shalfey:
> Hello,
> 
> I cannot find the functionality for commenting / uncommenting particular
> properties by their names. Let's say I have the property like this:
> 
> |app.dateFields=tranDate,expectedCloseDate,\
>   closeDate,createdDate,lastModifiedDate,startDate,endDate,\
>   salesEffectiveDate,shipDate,actualShipDate,ccExpireDate,\
>   revecStartDate,revRecEndDate,validFrom,licenseDateUps,\
>   blanketStartDateUps,blanketEndDateUps,shipDateFedEx,\
>   homeDeliveryDateFedEx,dueDate,discountDate,billedDate|
> 
> I would like to use something like
> 
> |propertiesConfigurationLayout.commentProperty("app.dateFields");|
> 
> And have the commented property as a result:
> 
> |#  app.dateFields=tranDate,expectedCloseDate,\
> #    closeDate,createdDate,lastModifiedDate,startDate,endDate,\
> #    salesEffectiveDate,shipDate,actualShipDate,ccExpireDate,\
> #    revecStartDate,revRecEndDate,validFrom,licenseDateUps,\
> #    blanketStartDateUps,blanketEndDateUps,shipDateFedEx,\
> #    homeDeliveryDateFedEx,dueDate,discountDate,billedDate|
> 
> And I would like to do the same thing to uncomment the property I need.
> 
> Is there a way to do this in Apache Commons Configuration? Or there is
> no standard way and I have to implement it on my own?

unfortunately, this feature is not supported. The
PropertiesConfigurationLayout class records comments assigned to a
property. Such comments can be added, changed, or removed. However,
there is no way to transform a property value to a comment or vice versa.

The support for comments mainly has the goal to remain the original
layout of a properties file when it is written again using Commons
Configuration. It does not go so far that comments can be added at
arbitrary positions in the file.

I think, your use case would be an interesting feature to be added to
this library. So if you implement something on your own, it would be
great if you could share your implementation afterwards.

Thanks
Oliver

> 
> Initially I have created the topic on stackoverflow
> <http://stackoverflow.com/questions/23313323/comment-uncomment-particular-properties-in-java-properties-files-using-apach>
> and only after that I've noticed the Mailing List link. Sorry for that.
> 
> Thanks in advance,
> 
> Sergey
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message