source: other-projects/the-macronizer/trunk/src/java/monogram/model/ListModel.java@ 30062

Last change on this file since 30062 was 30062, checked in by davidb, 9 years ago

Removal/Tidy-up of debug statements

File size: 2.0 KB
Line 
1/*
2 * To change this license header, choose License Headers in Project Properties.
3 * To change this template file, choose Tools | Templates
4 * and open the template in the editor.
5 */
6package monogram.model;
7
8import java.io.BufferedReader;
9import java.io.IOException;
10import java.io.InputStreamReader;
11import java.io.Reader;
12import java.util.HashSet;
13import java.util.Set;
14import util.Pool;
15
16
17/**
18 *
19 * @author tl113
20 */
21public class ListModel {
22
23 private Set<String> specialConditionsList;
24 private final String CHARSET_ENCODING = "utf-8";
25 private final String DELIMITER = "\t";
26
27 private Pool<String> pool;
28 private final String path;
29
30 public ListModel(String path, Pool<String> pool){
31 this.path = path;
32 this.pool = pool;
33 specialConditionsList = new HashSet();
34 init();
35
36 }
37
38 private void init() {
39 BufferedReader reader = null;
40 try {
41 final String filepath = path;
42 reader = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(filepath), CHARSET_ENCODING));
43 String line;
44 while ((line = reader.readLine()) != null) {
45 // final String elements = line.split(DELIMITER);
46 specialConditionsList.add(line);
47 }
48 } catch (IOException e) {
49 e.printStackTrace();
50 } finally {
51 close(reader);
52 }
53
54 }
55
56 private void close(Reader reader) {
57 if (reader != null) {
58 try {
59 reader.close();
60 } catch (IOException e) {
61 e.printStackTrace();
62 }
63 }
64 }
65
66 public Set<String> getMonogramProbabilities() {
67 return specialConditionsList;
68 }
69
70 public boolean contains(String s){
71
72 if(specialConditionsList.contains(s)){
73
74 return true;
75 }
76
77 return false;
78 }
79
80
81}
Note: See TracBrowser for help on using the repository browser.