[jsword-devel] Adding a transient property to SwordBookMetaData

DM Smith dmsmith at crosswire.org
Fri Nov 6 17:43:54 MST 2015


I'll have to check this weekend.

Cent from my fone so theer mite be tipos. ;)

> On Nov 6, 2015, at 5:57 PM, Martin Denham <mjdenham at gmail.com> wrote:
> 
> Do the JSword junits currently run?
> 
> I was trying to do a simple fix by adding another putProperty method to swordBookMetaData and also adding a new SwordMetaDataLocator.TRANSIENT :
>     public void putProperty(String key, String value, SwordMetaDataLocator metaDataLocator) 
> which would allow me to set a property without persisting it.
> 
> But I don't think that SwordBookMetaDataTest is currently working - at least it is one of the few tests that fails on my pc.
> The first problem I had was that SwordBookMetaData.KEY_DATA_PATH was not set causing an NPE in SwordBookMetaData.setLibrary, so I fixed that by adding this to the junit setUp()
>         table.add(SwordBookMetaData.KEY_DATA_PATH, "./modules/texts/ztext/kjv/");
> 
> Then I got
> java.lang.StringIndexOutOfBoundsException: String index out of range: -1
> 	at org.crosswire.common.util.NetUtil.lengthenURI(NetUtil.java:391)
> 	at org.crosswire.jsword.book.sword.SwordBookMetaData.setLibrary(SwordBookMetaData.java:366)
> because the test URI is an empty string and 0-1 is out of bounds in NetUtil:
> char lastChar = path.charAt(path.length() - 1);
> 
> So is the SwordBookMetaDataTest broken or am I doing something silly?
> 
> Thanks
> Martin
> 
> 
>> On 2 November 2015 at 21:44, Martin Denham <mjdenham at gmail.com> wrote:
>> And Bible adds a temporary property to SwordBookMetaData to identify which repository a downloadable book came from.  This sort of property is transient and does not need to be stored.  However, to prevent this throwing an exception after upgrade to the recent JSword I needed to specify this as a ui property which is persisted in the jsword-mods.d folder.  
>> 
>> Currently BookMetadata.putproperty takes a boolean property which determines where the property is persisted.
>> void putProperty(String key, String value, boolean forFrontend);
>> Would it be a good idea to make it possible to add transient properties that are not persisted?  This might be done by using an enum instead of a boolean for the third property.
>> 
>> Martin
> 
> _______________________________________________
> jsword-devel mailing list
> jsword-devel at crosswire.org
> http://www.crosswire.org/mailman/listinfo/jsword-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.crosswire.org/pipermail/jsword-devel/attachments/20151106/8bb5a13c/attachment.html>


More information about the jsword-devel mailing list