comparison flys-backend/src/main/java/de/intevation/flys/importer/AnnotationsParser.java @ 765:763c4137d6e1

Added classification of annotation types. Needs testing! flys-backend/trunk@2162 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Sun, 19 Jun 2011 12:26:12 +0000
parents 8076f6a689d0
children aa9e3da95c31
comparison
equal deleted inserted replaced
764:e09f00ecb915 765:763c4137d6e1
29 }; 29 };
30 30
31 protected HashMap<String, ImportAttribute> attributes; 31 protected HashMap<String, ImportAttribute> attributes;
32 protected HashMap<String, ImportPosition> positions; 32 protected HashMap<String, ImportPosition> positions;
33 protected TreeSet<ImportAnnotation> annotations; 33 protected TreeSet<ImportAnnotation> annotations;
34 protected AnnotationClassifier classifier;
34 35
35 public AnnotationsParser() { 36 public AnnotationsParser() {
37 this(null);
38 }
39
40 public AnnotationsParser(AnnotationClassifier classifier) {
36 attributes = new HashMap<String, ImportAttribute>(); 41 attributes = new HashMap<String, ImportAttribute>();
37 positions = new HashMap<String, ImportPosition>(); 42 positions = new HashMap<String, ImportPosition>();
38 annotations = new TreeSet<ImportAnnotation>(); 43 annotations = new TreeSet<ImportAnnotation>();
44 this.classifier = classifier;
39 } 45 }
40 46
41 public void parseFile(File file) throws IOException { 47 public void parseFile(File file) throws IOException {
42 log.info("parsing km file: '" + file + "'"); 48 log.info("parsing km file: '" + file + "'");
49
50 ImportAnnotationType defaultIAT = null;
51
52 if (classifier != null) {
53 defaultIAT = classifier.classifyFile(
54 file.getName(),
55 classifier.getDefaultType());
56 }
57
43 LineNumberReader in = null; 58 LineNumberReader in = null;
44 try { 59 try {
45 in = 60 in =
46 new LineNumberReader( 61 new LineNumberReader(
47 new InputStreamReader( 62 new InputStreamReader(
122 } 137 }
123 } 138 }
124 139
125 ImportRange range = new ImportRange(from, to); 140 ImportRange range = new ImportRange(from, to);
126 141
127 ImportAnnotationType type = null; // TODO: do classification 142 ImportAnnotationType type = classifier != null
143 ? classifier.classifyDescription(line, defaultIAT)
144 : null;
128 145
129 ImportAnnotation annotation = new ImportAnnotation( 146 ImportAnnotation annotation = new ImportAnnotation(
130 attribute, position, range, edge, type); 147 attribute, position, range, edge, type);
131 148
132 if (!annotations.add(annotation)) { 149 if (!annotations.add(annotation)) {

http://dive4elements.wald.intevation.org