Default Value for BigDecimal fields?

1,470 views
Skip to first unread message

Marcus

unread,
Feb 4, 2009, 10:51:07 PM2/4/09
to legstar-user
Is there a way to set a default value for BigDecimal fields?

My Cobol structure has many fields that are defined as PIC S9(8)V99.
This equates to BigDecimal in the binding classes. I only want to set
one or two fields to a value, the others I would like to default to
Zero. However, if I don't explicitly call set on all BigDecimal
fields, I get a NullPointerError:

java.lang.NullPointerException
at
com.legstar.coxb.convert.simple.CobolZonedDecimalSimpleConverter.formatString
(CobolZonedDecimalSimpleConverter.java:309)
at
com.legstar.coxb.convert.simple.CobolZonedDecimalSimpleConverter.toHostSingle
(CobolZonedDecimalSimpleConverter.java:224)
at
com.legstar.coxb.convert.simple.CobolZonedDecimalSimpleConverter.toHost
(CobolZonedDecimalSimpleConverter.java:73)
at com.legstar.coxb.impl.visitor.CobolMarshalVisitor.visit
(CobolMarshalVisitor.java:241)
at com.legstar.coxb.impl.CZonedDecimalBinding.accept
(CZonedDecimalBinding.java:51)
at com.legstar.coxb.impl.visitor.CobolMarshalVisitor.visit
(CobolMarshalVisitor.java:86)
at com.legstar.coxb.common.CComplexBinding.accept
(CComplexBinding.java:74)
at com.legstar.coxb.transform.AbstractJavaToHostTransformer.transform
(AbstractJavaToHostTransformer.java:122)
at com.legstar.coxb.transform.AbstractJavaToHostTransformer.transform
(AbstractJavaToHostTransformer.java:92)
at
au.com.zurich.phoenix.polisy.legstar.phxprem.bind.IrpremRecTransformers.toHost
(IrpremRecTransformers.java:30)
at au.com.zurich.phoenix.polisy.upload.record.PremiumRecord.export
(PremiumRecord.java:47)
at
au.com.zurich.phoenix.polisy.upload.record.AbstractRecordTest.setupExportTest
(AbstractRecordTest.java:66)
at
au.com.zurich.phoenix.polisy.upload.record.PremiumRecordTest.testExport
(PremiumRecordTest.java:26)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:59)
at org.junit.internal.runners.MethodRoadie.runTestMethod
(MethodRoadie.java:98)
at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:
79)
at
org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters
(MethodRoadie.java:87)
at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:
77)
at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:42)
at org.junit.internal.runners.JUnit4ClassRunner.invokeTestMethod
(JUnit4ClassRunner.java:88)
at org.junit.internal.runners.JUnit4ClassRunner.runMethods
(JUnit4ClassRunner.java:51)
at org.junit.internal.runners.JUnit4ClassRunner$1.run
(JUnit4ClassRunner.java:44)
at org.junit.internal.runners.ClassRoadie.runUnprotected
(ClassRoadie.java:27)
at org.junit.internal.runners.ClassRoadie.runProtected
(ClassRoadie.java:37)
at org.junit.internal.runners.JUnit4ClassRunner.run
(JUnit4ClassRunner.java:42)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run
(JUnit4TestReference.java:45)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run
(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests
(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests
(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run
(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main
(RemoteTestRunner.java:196)

Is there a way to specify a default value for BigDecimal fields
(either in Java or the generated XSD), and then not set all the
BigDecimal fields explicitly.

Cheers,
Mark

Fady Moussallam

unread,
Feb 5, 2009, 12:45:39 AM2/5/09
to legsta...@googlegroups.com
Hello Marcus,

This is a bug introduced in 1.2.3. I will file a bug report for it.

I have uploaded a fix here:
http://www.legsem.com/legstar/maven/snapshots/com/legsem/legstar/legstar-coxbrt/1.2.4-SNAPSHOT/legstar-coxbrt-1.2.4-SNAPSHOT.jar.

You will need to replace your legstar-coxbrt-1.2.3.jar by this one in
your install folder.

Let me know how it goes.

Fady

Marcus

unread,
Feb 9, 2009, 8:30:41 PM2/9/09
to legstar-user
Thanks for the quick response. I've used your 1.2.4-SNAPSHOT jar and
it fixed the problem.

Is there any ETA on the release date for 1.2.4?

Thanks much!
Mark
> I have uploaded a fix here:http://www.legsem.com/legstar/maven/snapshots/com/legsem/legstar/legs....

Fady Moussallam

unread,
Feb 10, 2009, 2:28:55 AM2/10/09
to legsta...@googlegroups.com
Hello Mark

Actually, I had to re-release 1.2.3 on February 05, 2009. This bug and
an issue with XmlSchema 1.4.3 [1] could not wait for the next release.

Since you are using Maven, if you have legstar-coxbrt in your
dependencies, you should pick up a fixed jar even with version 1.2.3.

Let me know how this works for you.

Fady


[1] http://code.google.com/p/legstar/issues/detail?id=34

Marcus

unread,
Feb 17, 2009, 10:05:10 PM2/17/09
to legstar-user
All Good! Thanks
Reply all
Reply to author
Forward
0 new messages