JAXB - no problem

The transpiler is created all we need for Marshalling and Unmarshalling. The only problem is BigInteger. JAXB is using that for www3 types integer and positiveInteger.

It looks to me like Jalview is just using those to encode standard int values. So I don’t know why, but OK, that’s the way it is, so we need to implement that. I think in JavaScript we could get away with simple Integer here. It, like BigInteger, has .intValue() and .valueOf(int).

Thus, a first pass could just be setting an equivalence

java.math.BigInteger = Integer.

at least for these purposes. This is really easy – we just add that to the .j2s j2s.class.replacements list.

Then the code to actually do these tasks should be quite trivial.

Bob

···

Robert M. Hanson
Professor of Chemistry
St. Olaf College
Northfield, MN
http://www.stolaf.edu/people/hansonr

If nature does not answer first what we want,
it is better to take what answer we get.

– Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900

Hi Bob.

The transpiler is created all we need for Marshalling and Unmarshalling.

Sounds good !

The only problem is BigInteger. JAXB is using that for www3 types integer and positiveInteger.

It looks to me like Jalview is just using those to encode standard int values. So I don’t know why, but OK, that’s the way it is, so we need to implement that. I think in JavaScript we could get away with simple Integer here. It, like BigInteger, has .intValue() and .valueOf(int).

Not entirely sure where you’re seeing this, but I suspect simply using javascript Integer as a mapping may bite us at some point in the future. We should move to something like https://developers.google.com/web/updates/2018/05/bigint as soon as its widely supported.

Jim.

···

On 28/09/2018 04:45, Robert Hanson wrote:

-- 
-------------------------------------------------------------------
Dr JB Procter, Jalview Coordinator, The Barton Group
Division of Computational Biology, School of Life Sciences
University of Dundee, Dundee DD1 5EH, UK.
+44 1382 388734 | [www.jalview.org](http://www.jalview.org) | [www.compbio.dundee.ac.uk](http://www.compbio.dundee.ac.uk)

It’s not a priority for me to implement BigInteger, because it is a real edge case, and the processing is very tedious. I did a little with it, but it is very involved and uses 64-bit ints, so that all has to be changed. I found a decent JavaScript library, but I am not looking forward to plugging that in.

But, that’s a mute point. Since you have used positiveInteger and integer instead of int in your schema, and because the package you use to create the Java classes from that for whatever reason binds that to BigInteger, we have to go with BigInteger. It is only used in the marshalling to encode a simple int, so all we need is intValue and valueOf, and these are also methods of Integer. If in the JavaScript we use Integer instead of BigInteger, there will be no difference. I may just add a couple of /** @j2sNative */ blocks to hack that. BigInteger will default to Integer anyway for any integer >= Integer.MAX_VALUE. Yes, I think I will do that.

Search for BigInteger, “{http://www.w3.org/2001/XMLSchema}integer” and “{http://www.w3.org/2001/XMLSchema}positiveinteger” in the jalview package, and you will see where it is used. Let me know if something is critical there.

Bob

···

Robert M. Hanson
Professor of Chemistry
St. Olaf College
Northfield, MN
http://www.stolaf.edu/people/hansonr

If nature does not answer first what we want,
it is better to take what answer we get.

– Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900