• 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • salvin francis
  • fred rosenberger

Different implementation of method within the same service

Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've got class FileMaker. It contains several methods like open and close file, read text line from file etc. and also one method which reads Record.

class FileMaker{
Record readRecord(){
String line = readLineOfTextFromFile();
return new Record(line) // or return record.convertToRecord(line)

I would like to make FileMaker general class which could be used for different types of Records
For example it should be able to read the file which contains lines about Person (name;age;email) as well as file which contains lines about Car (brand;year)

How initiate FileMaker with different implementation of "convertToRecord" for specified services?

Here I would like to use FileMaker for PersonRecord
<bean name="personService" >
<property name="fileMaker" ref="fileMaker" />

And here for CarRecord
<bean name="carService" >
<property name="fileMaker" ref="fileMaker" />

Thanks for help in advance.

That new kid is a freak. Show him this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
    Bookmark Topic Watch Topic
  • New Topic