diff --git a/common/source/java/ch/systemsx/cisd/common/parser/DefaultPropertyMapper.java b/common/source/java/ch/systemsx/cisd/common/parser/DefaultPropertyMapper.java deleted file mode 100644 index 1203bf2e66868ce2faf60556c2f3775670cb12d6..0000000000000000000000000000000000000000 --- a/common/source/java/ch/systemsx/cisd/common/parser/DefaultPropertyMapper.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2007 ETH Zuerich, CISD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ch.systemsx.cisd.common.parser; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * - * - * @author Christian Ribeaud - */ -public class DefaultPropertyMapper implements IPropertyMapper -{ - private final Map<String, Property> properties; - - DefaultPropertyMapper(List<Property> properties) { - this.properties = listToMap(properties); - } - - private final static Map<String, Property> listToMap(List<Property> properties) - { - Map<String, Property> map = new HashMap<String, Property>(properties.size()); - for (Property property : properties) - { - map.put(property.name, property); - } - return map; - } - - /////////////////////////////////////////////////////// - // IPropertyMapper - /////////////////////////////////////////////////////// - - public Property getProperty(String name) - { - return properties.get(name); - } - -} diff --git a/common/source/java/ch/systemsx/cisd/common/parser/DefaultReaderParser.java b/common/source/java/ch/systemsx/cisd/common/parser/DefaultReaderParser.java index 0ed2a9677a8f149ae78b79ebb8ef9098f323cdbf..6e0d184ba265d21a2fa4dd03e5dacdce504e6f20 100644 --- a/common/source/java/ch/systemsx/cisd/common/parser/DefaultReaderParser.java +++ b/common/source/java/ch/systemsx/cisd/common/parser/DefaultReaderParser.java @@ -57,6 +57,9 @@ public class DefaultReaderParser<E> implements IReaderParser<E> private IPropertyMapperFactory mapperFactory; + // TODO Christian: refactor this!!! + private boolean propertyMapperSet = false; + public DefaultReaderParser() { this(new DefaultLineTokenizer()); @@ -111,10 +114,11 @@ public class DefaultReaderParser<E> implements IReaderParser<E> { for (int lineNumber = 0; (line = bufferedReader.readLine()) != null; lineNumber++) { - if (mapperFactory != null && mapperFactory.getHeaderLine() > -1) + if (mapperFactory != null && mapperFactory.getHeaderLine() > -1 && propertyMapperSet == false) { String[] tokens = parseLine(lineNumber, line); factory.setPropertyMapper(mapperFactory.createPropertyMapper(tokens)); + propertyMapperSet = true; continue; } if (lineFilter.acceptLine(line)) diff --git a/common/source/java/ch/systemsx/cisd/common/parser/HeaderFilePropertyMapper.java b/common/source/java/ch/systemsx/cisd/common/parser/HeaderFilePropertyMapper.java index 579c5d6adb42f4e1c69c4656d8f7a89540969fda..4703d0b4750f0ffd500764569bf2d6ec79086ef4 100644 --- a/common/source/java/ch/systemsx/cisd/common/parser/HeaderFilePropertyMapper.java +++ b/common/source/java/ch/systemsx/cisd/common/parser/HeaderFilePropertyMapper.java @@ -19,8 +19,6 @@ package ch.systemsx.cisd.common.parser; import java.util.HashMap; import java.util.Map; -import org.apache.commons.lang.StringUtils; - /** * * @@ -28,11 +26,9 @@ import org.apache.commons.lang.StringUtils; */ public class HeaderFilePropertyMapper implements IPropertyMapper { - public final static char NAME_FORMAT_SEPARATOR = ','; - private final Map<String, Property> properties; - HeaderFilePropertyMapper(String[] headerTokens) { + public HeaderFilePropertyMapper(String[] headerTokens) { this.properties = tokensToMap(headerTokens); } @@ -42,13 +38,7 @@ public class HeaderFilePropertyMapper implements IPropertyMapper for (int i = 0; i < tokens.length; i++) { String token = tokens[i]; - String[] split = StringUtils.split(token, NAME_FORMAT_SEPARATOR); - String format = null; - if (split.length > 1) - { - format = split[1]; - } - map.put(token, new Property(i, split[0], format)); + map.put(token, new Property(i, token)); } return map; } diff --git a/common/source/java/ch/systemsx/cisd/common/parser/IPropertyMapper.java b/common/source/java/ch/systemsx/cisd/common/parser/IPropertyMapper.java index 0c202ac7eca0116bb37d348edeec07df721ca1b0..62dac4f5f662b5c812550e0046c839424627128f 100644 --- a/common/source/java/ch/systemsx/cisd/common/parser/IPropertyMapper.java +++ b/common/source/java/ch/systemsx/cisd/common/parser/IPropertyMapper.java @@ -37,20 +37,16 @@ public interface IPropertyMapper * * @author Christian Ribeaud */ - // TODO Christian: we should maybe add a type... public final static class Property { public final int column; public final String name; - public final String format; - - protected Property(final int column, final String name, final String format) + protected Property(final int column, final String name) { this.column = column; this.name = name; - this.format = format; } ///////////////////////////////////////////////////////