• 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

Loop to read through a string of fields and database table column names

 
Ranch Hand
Posts: 226
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a string that has pairs of field names and database column names. These fields will be set to the value of the database table columns. Some fields are mapped with only one database column. Some fields are mapped with three database columns separated by slashes and some fields are mapped with two database columns separated by a colon. I have a setField() method that takes two parameters: a pdf field name and its corresponding value. I have a hash map called columnValues that has database column names paired with their corresponding values. In order to find the value of a particular database table column my application executes this line of code: columnValues.get(databaseColumn)

How would I make a loop that would do the following?

1. If a field is mapped with only one database column, then do this
pdf.setField(field, columnValues.get(databaseColumn));

2. If a field is mapped three database columns separated by slashes, then get the values of all three database columns and concatenate them with slashes separating them.

3. If a field is mapped with two database columns separated by a colon, then get the values of both database columns and concatenate them.

My application is reading through a string such as the following. It is field names with their corresponding database column names.
vehicleMake=makeColumn, dateOfCollision=monthColumn/dayColumn/yearColumn, vehicleYear=centuryColumn:yearColumn


 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic