An annotated Java bean able to map a CSV file
- or -
Post a project like this2629
€15(approx. $16)
- Posted:
- Proposals: 4
- Remote
- #1420538
- Completed
Description
Experience Level: Expert
Estimated project duration: 1 day or less
CSV file (3 lines csv as an example):
John,Doe
Jane,Doe
Peter,Parker
Should be mapped to our Person model class as shown in a java meta code sample:
@FileMetaData(separator = ",")
Public class Person {
@CSVColumn(indx = 1)
private String firstName;
@CSVColumn(indx = 2)
private String lastName;
public String getFirstName() {
return this.firstName();
}
public void setFirstName(String firstName) { this.firstName = firstName;
}
public String getLastName() {
return this.lastName ();
}
public void setLastName (String lastName) { this.lastName = lastName;
} }
The goal is to implement 2 custom annotations and the CSV reading façade:
@FileMetaData(separator = ",") -> sets the separator used in CSV file
@CSVColumn(indx = 1) -> maps the value in the first column position of CSV file to an model instance property.
CSV reader is described in a following meta code and it is used only for reading the Person objects: SomeCoolCsvReader csvReader = new SomeCoolCsvReader(File csvFile, Person.class); csvReader.getPersons(); //should return the list of mapped Person instances.
E.g:
List persons = csvReader.getPersons();
The objects in persons list represent the rows in CSV files and the properties of objects contain the values of the columns of CSV line.
John,Doe
Jane,Doe
Peter,Parker
Should be mapped to our Person model class as shown in a java meta code sample:
@FileMetaData(separator = ",")
Public class Person {
@CSVColumn(indx = 1)
private String firstName;
@CSVColumn(indx = 2)
private String lastName;
public String getFirstName() {
return this.firstName();
}
public void setFirstName(String firstName) { this.firstName = firstName;
}
public String getLastName() {
return this.lastName ();
}
public void setLastName (String lastName) { this.lastName = lastName;
} }
The goal is to implement 2 custom annotations and the CSV reading façade:
@FileMetaData(separator = ",") -> sets the separator used in CSV file
@CSVColumn(indx = 1) -> maps the value in the first column position of CSV file to an model instance property.
CSV reader is described in a following meta code and it is used only for reading the Person objects: SomeCoolCsvReader csvReader = new SomeCoolCsvReader(File csvFile, Person.class); csvReader.getPersons(); //should return the list of mapped Person instances.
E.g:
List persons = csvReader.getPersons();
The objects in persons list represent the rows in CSV files and the properties of objects contain the values of the columns of CSV line.
Thodoris B.
100% (2)Projects Completed
3
Freelancers worked with
3
Projects awarded
40%
Last project
13 Mar 2019
Greece
New Proposal
Login to your account and send a proposal now to get this project.
Log inClarification Board Ask a Question
-
I am java developer let me know how soon you need it?
-
HI,
I'm having good experience in this, I can help you, Lets connectThodoris B.14 Jan 2017Hi, pm me please!
Abhishek G.14 Jan 2017Lets connect over skype - indianmesh
289990289924
We collect cookies to enable the proper functioning and security of our website, and to enhance your experience. By clicking on 'Accept All Cookies', you consent to the use of these cookies. You can change your 'Cookies Settings' at any time. For more information, please read ourCookie Policy
Cookie Settings
Accept All Cookies