• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Design issue

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
We want to convert an HashMap to a byte array . i.e say employee feild has feild will occupy first 8 bytes then next 4 byte is area code etc. to talk to a legacy system. Byte array is passed to leagacy system

I think we should be doing this conversion via xml.are there any alternative approaches?
Is there anything existing which we can reuse?

Thanks
 
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are no direct way to get a Map implementation converted to a stream of bytes.As you said legacy application then you should first be knowing as how the legacy system is excepting data.

If you legacy system is excepting properly formatted bytes and sending an xml would not help.Your legacy system will tell you as how its expecting the data.
 
Amit A. Patil
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We will not be sending xml. Basically legacy had native methods that accept only byte array.
Java has objects. Java nees to pull psecific values and put it at well defined places in byte array.

[First 8 bytes employeeId][4 bytes Area Code][7 bytes Salary].....

I dont want to hard code the positioning and width while populating this byte array
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Amit A. Patil:


[First 8 bytes employeeId][4 bytes Area Code][7 bytes Salary].....



I also guessed that this would be the case.

But bytes will not be sufficient , even you need to know the encoding.Considering ASCII or LATIN1 codepage that takes one byte per user character.It should be quite simple and remaining places you can pad using spaces.

I dont want to hard code the positioning and width while populating this byte array



There should be some metadata for this which would define as how the fields should lay in the request.
 
Amit A. Patil
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Rahul Bhattacharjee:


There should be some metadata for this which would define as how the fields should lay in the request.



Are there any existing frameworks for this?
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't know if your legacy side is COBOL, but the problem description sounds just like what I've run into with COBOL. A quick Google for "java cobol library" found a few hits. Maybe JRecord wold do the job?
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Amit A. Patil:


Are there any existing frameworks for this?



I am sure that your legacy application has something similar.I worked on a similar application where the legacy application provides me with java based metadata for invoking services in the application.
 
They worship nothing. They say it's because nothing lasts forever. Like this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic