Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NX: contractor data file.

 
Yuan Ye
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi. all. I have two questions about reading the data file.
1. After I get the head infomation of each records (name & length of each field), the length is used to read the data, what's the usage of name? Since I may already defined a similar name in the Contractor class.
2. How to use ByteBuffer to get a string value of n bytes. Should I use the getChar() method?
Thanks in advance
 
Tony Collins
Ranch Hand
Posts: 435
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1) I used the names as the column headings of my JTable.
2) I assume you've read the data into a byte buffer with a file channel. Use .array() and construct a string as below, remember to specify how the bytes are encoded.

Tony
 
Yuan Ye
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can use the field name as table header, do we also must construct our data class using the field names? To have property names exactly match the name defined by the db file. Thanks
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12014
220
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Peter,
Time for you to make a design decision: Do you
  • Use the descriptive names from the instructions file
  • or use the names that are inside the physical data file
  • or some combination (e.g. use descriptive names whenever a recognised real name is found, otherwise use the real name).


  • If the first option, do you do some translation from the descriptive to the stored names?
    Also, do you verify that the field names in the physical file do match the expected values?
    Some positive aspects of either option:
    Using the names from the physical file means that you are less likely to be affected if a column changes position, or a new column is added.
    Using the descriptive names may be more user friendly.
    Regards, Andrew
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic