Last change
on this file since 2 was 2, checked in by bart, 5 years ago |
Added new parties : linear, hardliner, conceder, boulware
|
File size:
965 bytes
|
Line | |
---|
1 | package geniusweb.profileconnection;
|
---|
2 |
|
---|
3 | import java.io.File;
|
---|
4 | import java.io.IOException;
|
---|
5 | import java.nio.charset.StandardCharsets;
|
---|
6 | import java.nio.file.Files;
|
---|
7 | import java.nio.file.Path;
|
---|
8 |
|
---|
9 | import com.fasterxml.jackson.databind.ObjectMapper;
|
---|
10 |
|
---|
11 | import geniusweb.profile.Profile;
|
---|
12 |
|
---|
13 | /**
|
---|
14 | * ProfileInterface based on a plain filesystem UTF8 file.
|
---|
15 | */
|
---|
16 | public class FileProfileConnector implements ProfileInterface {
|
---|
17 | private final static ObjectMapper jackson = new ObjectMapper();
|
---|
18 | private final Profile profile;
|
---|
19 |
|
---|
20 | /**
|
---|
21 | *
|
---|
22 | * @param filename the filename of the file containing the profile
|
---|
23 | * @throws IOException if the profile is not proper json
|
---|
24 | */
|
---|
25 | public FileProfileConnector(String filename) throws IOException {
|
---|
26 | Path path = new File(filename).toPath();
|
---|
27 | String serialized = new String(Files.readAllBytes(path), StandardCharsets.UTF_8);
|
---|
28 | profile = jackson.readValue(serialized, Profile.class);
|
---|
29 | }
|
---|
30 |
|
---|
31 | @Override
|
---|
32 | public Profile getProfile() {
|
---|
33 | return profile;
|
---|
34 | }
|
---|
35 |
|
---|
36 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.