Updated line-endings
diff --git a/core/src/main/java/org/apache/metamodel/schema/naming/AlphabeticColumnNamingStrategy.java b/core/src/main/java/org/apache/metamodel/schema/naming/AlphabeticColumnNamingStrategy.java
index f6575c7..34498de 100644
--- a/core/src/main/java/org/apache/metamodel/schema/naming/AlphabeticColumnNamingStrategy.java
+++ b/core/src/main/java/org/apache/metamodel/schema/naming/AlphabeticColumnNamingStrategy.java
@@ -1,43 +1,43 @@
-/**

- * Licensed to the Apache Software Foundation (ASF) under one

- * or more contributor license agreements.  See the NOTICE file

- * distributed with this work for additional information

- * regarding copyright ownership.  The ASF licenses this file

- * to you 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 org.apache.metamodel.schema.naming;

-

-import org.apache.metamodel.util.AlphabeticSequence;

-

-public class AlphabeticColumnNamingStrategy implements ColumnNamingStrategy {

-

-    private static final long serialVersionUID = 1L;

-

-    @Override

-    public ColumnNamingSession startColumnNamingSession() {

-        return new ColumnNamingSession() {

-            private final AlphabeticSequence seq = new AlphabeticSequence();

-

-            @Override

-            public String getNextColumnName(ColumnNamingContext ctx) {

-                return seq.next();

-            }

-

-            @Override

-            public void close() {

-            }

-        };

-    }

-

-}

+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.metamodel.schema.naming;
+
+import org.apache.metamodel.util.AlphabeticSequence;
+
+public class AlphabeticColumnNamingStrategy implements ColumnNamingStrategy {
+
+    private static final long serialVersionUID = 1L;
+
+    @Override
+    public ColumnNamingSession startColumnNamingSession() {
+        return new ColumnNamingSession() {
+            private final AlphabeticSequence seq = new AlphabeticSequence();
+
+            @Override
+            public String getNextColumnName(ColumnNamingContext ctx) {
+                return seq.next();
+            }
+
+            @Override
+            public void close() {
+            }
+        };
+    }
+
+}
diff --git a/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingContext.java b/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingContext.java
index b613913..b43ad87 100644
--- a/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingContext.java
+++ b/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingContext.java
@@ -1,52 +1,52 @@
-/**

- * Licensed to the Apache Software Foundation (ASF) under one

- * or more contributor license agreements.  See the NOTICE file

- * distributed with this work for additional information

- * regarding copyright ownership.  The ASF licenses this file

- * to you 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 org.apache.metamodel.schema.naming;

-

-import org.apache.metamodel.schema.Table;

-

-/**

- * Defines the context for naming a single column in a

- * {@link ColumnNamingStrategy} session.

- */

-public interface ColumnNamingContext {

-

-    /**

-     * Gets the index of the column being named.

-     * 

-     * @return

-     */

-    public int getColumnIndex();

-

-    /**

-     * Gets the {@link Table} that the column is to pertain to. If the table is

-     * not yet available then this may return null.

-     * 

-     * @return

-     */

-    public Table getTable();

-

-    /**

-     * Gets the intrinsic column name, if this is defined in the datastore

-     * itself. This may be in the form of a header or such. Sometimes intrinsic

-     * column names exist only for some columns and sometimes there may be

-     * duplicate names or other anomalies which are often discouraged.

-     * 

-     * @return

-     */

-    public String getIntrinsicColumnName();

-}

+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.metamodel.schema.naming;
+
+import org.apache.metamodel.schema.Table;
+
+/**
+ * Defines the context for naming a single column in a
+ * {@link ColumnNamingStrategy} session.
+ */
+public interface ColumnNamingContext {
+
+    /**
+     * Gets the index of the column being named.
+     * 
+     * @return
+     */
+    public int getColumnIndex();
+
+    /**
+     * Gets the {@link Table} that the column is to pertain to. If the table is
+     * not yet available then this may return null.
+     * 
+     * @return
+     */
+    public Table getTable();
+
+    /**
+     * Gets the intrinsic column name, if this is defined in the datastore
+     * itself. This may be in the form of a header or such. Sometimes intrinsic
+     * column names exist only for some columns and sometimes there may be
+     * duplicate names or other anomalies which are often discouraged.
+     * 
+     * @return
+     */
+    public String getIntrinsicColumnName();
+}
diff --git a/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingContextImpl.java b/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingContextImpl.java
index cc7a24e..ec77440 100644
--- a/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingContextImpl.java
+++ b/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingContextImpl.java
@@ -1,64 +1,64 @@
-/**

- * Licensed to the Apache Software Foundation (ASF) under one

- * or more contributor license agreements.  See the NOTICE file

- * distributed with this work for additional information

- * regarding copyright ownership.  The ASF licenses this file

- * to you 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 org.apache.metamodel.schema.naming;

-

-import org.apache.metamodel.schema.Table;

-

-public class ColumnNamingContextImpl implements ColumnNamingContext {

-

-    private final int columnIndex;

-    private final Table table;

-    private final String intrinsicColumnName;

-

-    /**

-     * 

-     * @param table

-     * @param intrinsicColumnName

-     * @param columnIndex

-     */

-    public ColumnNamingContextImpl(Table table, String intrinsicColumnName, int columnIndex) {

-        this.table = table;

-        this.intrinsicColumnName = intrinsicColumnName;

-        this.columnIndex = columnIndex;

-    }

-

-    /**

-     * 

-     * @param columnIndex

-     */

-    public ColumnNamingContextImpl(int columnIndex) {

-        this(null, null, columnIndex);

-    }

-

-    @Override

-    public int getColumnIndex() {

-        return columnIndex;

-    }

-

-    @Override

-    public Table getTable() {

-        return table;

-    }

-

-    @Override

-    public String getIntrinsicColumnName() {

-        return intrinsicColumnName;

-    }

-

-}

+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.metamodel.schema.naming;
+
+import org.apache.metamodel.schema.Table;
+
+public class ColumnNamingContextImpl implements ColumnNamingContext {
+
+    private final int columnIndex;
+    private final Table table;
+    private final String intrinsicColumnName;
+
+    /**
+     * 
+     * @param table
+     * @param intrinsicColumnName
+     * @param columnIndex
+     */
+    public ColumnNamingContextImpl(Table table, String intrinsicColumnName, int columnIndex) {
+        this.table = table;
+        this.intrinsicColumnName = intrinsicColumnName;
+        this.columnIndex = columnIndex;
+    }
+
+    /**
+     * 
+     * @param columnIndex
+     */
+    public ColumnNamingContextImpl(int columnIndex) {
+        this(null, null, columnIndex);
+    }
+
+    @Override
+    public int getColumnIndex() {
+        return columnIndex;
+    }
+
+    @Override
+    public Table getTable() {
+        return table;
+    }
+
+    @Override
+    public String getIntrinsicColumnName() {
+        return intrinsicColumnName;
+    }
+
+}
diff --git a/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingStrategies.java b/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingStrategies.java
index 0696376..f0da83a 100644
--- a/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingStrategies.java
+++ b/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingStrategies.java
@@ -1,45 +1,45 @@
-/**

- * Licensed to the Apache Software Foundation (ASF) under one

- * or more contributor license agreements.  See the NOTICE file

- * distributed with this work for additional information

- * regarding copyright ownership.  The ASF licenses this file

- * to you 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 org.apache.metamodel.schema.naming;

-

-import java.util.List;

-

-/**

- * Constructors and common utilities for {@link ColumnNamingStrategy} objects.

- */

-public class ColumnNamingStrategies {

-

-    private static final DelegatingIntrinsicSwitchColumnNamingStrategy DEFAULT_STRATEGY = new DelegatingIntrinsicSwitchColumnNamingStrategy(

-            new UniqueColumnNamingStrategy(), new AlphabeticColumnNamingStrategy());

-

-    private ColumnNamingStrategies() {

-    }

-

-    public static ColumnNamingStrategy defaultStrategy() {

-        return DEFAULT_STRATEGY;

-    }

-

-    public static ColumnNamingStrategy customNames(List<String> columnNames) {

-        return new CustomColumnNamingStrategy(columnNames);

-    }

-

-    public static ColumnNamingStrategy customNames(String ... columnNames) {

-        return new CustomColumnNamingStrategy(columnNames);

-    }

-}

+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.metamodel.schema.naming;
+
+import java.util.List;
+
+/**
+ * Constructors and common utilities for {@link ColumnNamingStrategy} objects.
+ */
+public class ColumnNamingStrategies {
+
+    private static final DelegatingIntrinsicSwitchColumnNamingStrategy DEFAULT_STRATEGY = new DelegatingIntrinsicSwitchColumnNamingStrategy(
+            new UniqueColumnNamingStrategy(), new AlphabeticColumnNamingStrategy());
+
+    private ColumnNamingStrategies() {
+    }
+
+    public static ColumnNamingStrategy defaultStrategy() {
+        return DEFAULT_STRATEGY;
+    }
+
+    public static ColumnNamingStrategy customNames(List<String> columnNames) {
+        return new CustomColumnNamingStrategy(columnNames);
+    }
+
+    public static ColumnNamingStrategy customNames(String ... columnNames) {
+        return new CustomColumnNamingStrategy(columnNames);
+    }
+}
diff --git a/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingStrategy.java b/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingStrategy.java
index 6ccccbf..27e85ea 100644
--- a/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingStrategy.java
+++ b/core/src/main/java/org/apache/metamodel/schema/naming/ColumnNamingStrategy.java
@@ -1,31 +1,31 @@
-/**

- * Licensed to the Apache Software Foundation (ASF) under one

- * or more contributor license agreements.  See the NOTICE file

- * distributed with this work for additional information

- * regarding copyright ownership.  The ASF licenses this file

- * to you 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 org.apache.metamodel.schema.naming;

-

-import java.io.Serializable;

-

-/**

- * A strategy that defines how columns are logically named. Such strategies are

- * mostly used when a particular datastore is not itself intrinsically

- * specifying the column name.

- */

-public interface ColumnNamingStrategy extends Serializable {

-    

-    public ColumnNamingSession startColumnNamingSession();

-}

+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.metamodel.schema.naming;
+
+import java.io.Serializable;
+
+/**
+ * A strategy that defines how columns are logically named. Such strategies are
+ * mostly used when a particular datastore is not itself intrinsically
+ * specifying the column name.
+ */
+public interface ColumnNamingStrategy extends Serializable {
+    
+    public ColumnNamingSession startColumnNamingSession();
+}
diff --git a/core/src/main/java/org/apache/metamodel/schema/naming/CustomColumnNamingStrategy.java b/core/src/main/java/org/apache/metamodel/schema/naming/CustomColumnNamingStrategy.java
index e6cc706..39397d7 100644
--- a/core/src/main/java/org/apache/metamodel/schema/naming/CustomColumnNamingStrategy.java
+++ b/core/src/main/java/org/apache/metamodel/schema/naming/CustomColumnNamingStrategy.java
@@ -1,62 +1,62 @@
-/**

- * Licensed to the Apache Software Foundation (ASF) under one

- * or more contributor license agreements.  See the NOTICE file

- * distributed with this work for additional information

- * regarding copyright ownership.  The ASF licenses this file

- * to you 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 org.apache.metamodel.schema.naming;

-

-import java.util.Arrays;

-import java.util.Iterator;

-import java.util.List;

-

-/**

- * A {@link ColumnNamingStrategy} that allows the user to supply his own list of

- * custom column names.

- */

-public class CustomColumnNamingStrategy implements ColumnNamingStrategy {

-

-    private static final long serialVersionUID = 1L;

-

-    private final List<String> columnNames;

-

-    public CustomColumnNamingStrategy(List<String> columnNames) {

-        this.columnNames = columnNames;

-    }

-

-    public CustomColumnNamingStrategy(String... columnNames) {

-        this(Arrays.asList(columnNames));

-    }

-

-    @Override

-    public ColumnNamingSession startColumnNamingSession() {

-        final Iterator<String> iterator = columnNames.iterator();

-        return new ColumnNamingSession() {

-

-            @Override

-            public String getNextColumnName(ColumnNamingContext ctx) {

-                if (iterator.hasNext()) {

-                    return iterator.next();

-                }

-                return null;

-            }

-

-            @Override

-            public void close() {

-            }

-        };

-    }

-

-}

+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.metamodel.schema.naming;
+
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * A {@link ColumnNamingStrategy} that allows the user to supply his own list of
+ * custom column names.
+ */
+public class CustomColumnNamingStrategy implements ColumnNamingStrategy {
+
+    private static final long serialVersionUID = 1L;
+
+    private final List<String> columnNames;
+
+    public CustomColumnNamingStrategy(List<String> columnNames) {
+        this.columnNames = columnNames;
+    }
+
+    public CustomColumnNamingStrategy(String... columnNames) {
+        this(Arrays.asList(columnNames));
+    }
+
+    @Override
+    public ColumnNamingSession startColumnNamingSession() {
+        final Iterator<String> iterator = columnNames.iterator();
+        return new ColumnNamingSession() {
+
+            @Override
+            public String getNextColumnName(ColumnNamingContext ctx) {
+                if (iterator.hasNext()) {
+                    return iterator.next();
+                }
+                return null;
+            }
+
+            @Override
+            public void close() {
+            }
+        };
+    }
+
+}
diff --git a/core/src/main/java/org/apache/metamodel/schema/naming/DelegatingIntrinsicSwitchColumnNamingStrategy.java b/core/src/main/java/org/apache/metamodel/schema/naming/DelegatingIntrinsicSwitchColumnNamingStrategy.java
index e18cb3a..35a0f39 100644
--- a/core/src/main/java/org/apache/metamodel/schema/naming/DelegatingIntrinsicSwitchColumnNamingStrategy.java
+++ b/core/src/main/java/org/apache/metamodel/schema/naming/DelegatingIntrinsicSwitchColumnNamingStrategy.java
@@ -1,60 +1,60 @@
-/**

- * Licensed to the Apache Software Foundation (ASF) under one

- * or more contributor license agreements.  See the NOTICE file

- * distributed with this work for additional information

- * regarding copyright ownership.  The ASF licenses this file

- * to you 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 org.apache.metamodel.schema.naming;

-

-/**

- * A {@link ColumnNamingStrategy} that switches between two other

- * {@link ColumnNamingStrategy} delegates depending on the availability of a

- * intrinsic column name.

- */

-public class DelegatingIntrinsicSwitchColumnNamingStrategy implements ColumnNamingStrategy {

-

-    private static final long serialVersionUID = 1L;

-    private final ColumnNamingStrategy intrinsicStrategy;

-    private final ColumnNamingStrategy nonIntrinsicStrategy;

-

-    public DelegatingIntrinsicSwitchColumnNamingStrategy(ColumnNamingStrategy intrinsicStrategy,

-            ColumnNamingStrategy nonIntrinsicStrategy) {

-        this.intrinsicStrategy = intrinsicStrategy;

-        this.nonIntrinsicStrategy = nonIntrinsicStrategy;

-    }

-

-    @Override

-    public ColumnNamingSession startColumnNamingSession() {

-        final ColumnNamingSession intrinsicSession = intrinsicStrategy.startColumnNamingSession();

-        final ColumnNamingSession nonIntrinsicSession = nonIntrinsicStrategy.startColumnNamingSession();

-        return new ColumnNamingSession() {

-

-            @Override

-            public String getNextColumnName(ColumnNamingContext ctx) {

-                final String intrinsicColumnName = ctx.getIntrinsicColumnName();

-                if (intrinsicColumnName == null || intrinsicColumnName.isEmpty()) {

-                    return nonIntrinsicSession.getNextColumnName(ctx);

-                }

-                return intrinsicSession.getNextColumnName(ctx);

-            }

-

-            @Override

-            public void close() {

-                intrinsicSession.close();

-                nonIntrinsicSession.close();

-            }

-        };

-    }

-}

+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.metamodel.schema.naming;
+
+/**
+ * A {@link ColumnNamingStrategy} that switches between two other
+ * {@link ColumnNamingStrategy} delegates depending on the availability of a
+ * intrinsic column name.
+ */
+public class DelegatingIntrinsicSwitchColumnNamingStrategy implements ColumnNamingStrategy {
+
+    private static final long serialVersionUID = 1L;
+    private final ColumnNamingStrategy intrinsicStrategy;
+    private final ColumnNamingStrategy nonIntrinsicStrategy;
+
+    public DelegatingIntrinsicSwitchColumnNamingStrategy(ColumnNamingStrategy intrinsicStrategy,
+            ColumnNamingStrategy nonIntrinsicStrategy) {
+        this.intrinsicStrategy = intrinsicStrategy;
+        this.nonIntrinsicStrategy = nonIntrinsicStrategy;
+    }
+
+    @Override
+    public ColumnNamingSession startColumnNamingSession() {
+        final ColumnNamingSession intrinsicSession = intrinsicStrategy.startColumnNamingSession();
+        final ColumnNamingSession nonIntrinsicSession = nonIntrinsicStrategy.startColumnNamingSession();
+        return new ColumnNamingSession() {
+
+            @Override
+            public String getNextColumnName(ColumnNamingContext ctx) {
+                final String intrinsicColumnName = ctx.getIntrinsicColumnName();
+                if (intrinsicColumnName == null || intrinsicColumnName.isEmpty()) {
+                    return nonIntrinsicSession.getNextColumnName(ctx);
+                }
+                return intrinsicSession.getNextColumnName(ctx);
+            }
+
+            @Override
+            public void close() {
+                intrinsicSession.close();
+                nonIntrinsicSession.close();
+            }
+        };
+    }
+}
diff --git a/core/src/main/java/org/apache/metamodel/schema/naming/UniqueColumnNamingStrategy.java b/core/src/main/java/org/apache/metamodel/schema/naming/UniqueColumnNamingStrategy.java
index d4d21dd..9321998 100644
--- a/core/src/main/java/org/apache/metamodel/schema/naming/UniqueColumnNamingStrategy.java
+++ b/core/src/main/java/org/apache/metamodel/schema/naming/UniqueColumnNamingStrategy.java
@@ -1,62 +1,62 @@
-/**

- * Licensed to the Apache Software Foundation (ASF) under one

- * or more contributor license agreements.  See the NOTICE file

- * distributed with this work for additional information

- * regarding copyright ownership.  The ASF licenses this file

- * to you 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 org.apache.metamodel.schema.naming;

-

-import java.util.HashSet;

-import java.util.Set;

-

-/**

- * A {@link ColumnNamingStrategy} that uses the intrinsic column names, but

- * ensures that all column names are unique. When duplicate names are

- * encountered a number will be appended yielding column names like "name",

- * "name_2", "name_3" etc.

- */

-public class UniqueColumnNamingStrategy implements ColumnNamingStrategy {

-

-    private static final long serialVersionUID = 1L;

-

-    @Override

-    public ColumnNamingSession startColumnNamingSession() {

-        return new ColumnNamingSession() {

-

-            private final Set<String> names = new HashSet<>();

-

-            @Override

-            public String getNextColumnName(ColumnNamingContext ctx) {

-                final String intrinsicName = ctx.getIntrinsicColumnName();

-                boolean unique = names.add(intrinsicName);

-                if (unique) {

-                    return intrinsicName;

-                }

-

-                String newName = null;

-                for (int i = 2; !unique; i++) {

-                    newName = intrinsicName + '_' + i;

-                    unique = names.add(newName);

-                }

-                return newName;

-            }

-

-            @Override

-            public void close() {

-            }

-        };

-    }

-

-}

+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.metamodel.schema.naming;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * A {@link ColumnNamingStrategy} that uses the intrinsic column names, but
+ * ensures that all column names are unique. When duplicate names are
+ * encountered a number will be appended yielding column names like "name",
+ * "name_2", "name_3" etc.
+ */
+public class UniqueColumnNamingStrategy implements ColumnNamingStrategy {
+
+    private static final long serialVersionUID = 1L;
+
+    @Override
+    public ColumnNamingSession startColumnNamingSession() {
+        return new ColumnNamingSession() {
+
+            private final Set<String> names = new HashSet<>();
+
+            @Override
+            public String getNextColumnName(ColumnNamingContext ctx) {
+                final String intrinsicName = ctx.getIntrinsicColumnName();
+                boolean unique = names.add(intrinsicName);
+                if (unique) {
+                    return intrinsicName;
+                }
+
+                String newName = null;
+                for (int i = 2; !unique; i++) {
+                    newName = intrinsicName + '_' + i;
+                    unique = names.add(newName);
+                }
+                return newName;
+            }
+
+            @Override
+            public void close() {
+            }
+        };
+    }
+
+}
diff --git a/core/src/test/java/org/apache/metamodel/insert/AbstractRowInsertionBuilderTest.java b/core/src/test/java/org/apache/metamodel/insert/AbstractRowInsertionBuilderTest.java
index fc9f6bd..1b8ea7c 100644
--- a/core/src/test/java/org/apache/metamodel/insert/AbstractRowInsertionBuilderTest.java
+++ b/core/src/test/java/org/apache/metamodel/insert/AbstractRowInsertionBuilderTest.java
@@ -1,49 +1,49 @@
-/**

- * Licensed to the Apache Software Foundation (ASF) under one

- * or more contributor license agreements.  See the NOTICE file

- * distributed with this work for additional information

- * regarding copyright ownership.  The ASF licenses this file

- * to you 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 org.apache.metamodel.insert;

-

-import static org.junit.Assert.assertEquals;

-

-import org.apache.metamodel.MetaModelException;

-import org.apache.metamodel.UpdateCallback;

-import org.apache.metamodel.schema.MutableColumn;

-import org.apache.metamodel.schema.MutableTable;

-import org.junit.Test;

-

-public class AbstractRowInsertionBuilderTest {

-

-    @Test

-    public void testToString() {

-        final MutableTable table = new MutableTable("tbl");

-        final MutableColumn col1 = new MutableColumn("col1").setTable(table);

-        final MutableColumn col2 = new MutableColumn("col2").setTable(table);

-        table.addColumn(col1).addColumn(col2);

-

-        final AbstractRowInsertionBuilder<UpdateCallback> builder = new AbstractRowInsertionBuilder<UpdateCallback>(

-                null, table) {

-            @Override

-            public void execute() throws MetaModelException {

-                throw new UnsupportedOperationException();

-            }

-        };

-

-        builder.value(col1, "value1").value(col2, "value2");

-        assertEquals("INSERT INTO tbl(col1,col2) VALUES (\"value1\",\"value2\")", builder.toString());

-    }

-}

+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.metamodel.insert;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.metamodel.MetaModelException;
+import org.apache.metamodel.UpdateCallback;
+import org.apache.metamodel.schema.MutableColumn;
+import org.apache.metamodel.schema.MutableTable;
+import org.junit.Test;
+
+public class AbstractRowInsertionBuilderTest {
+
+    @Test
+    public void testToString() {
+        final MutableTable table = new MutableTable("tbl");
+        final MutableColumn col1 = new MutableColumn("col1").setTable(table);
+        final MutableColumn col2 = new MutableColumn("col2").setTable(table);
+        table.addColumn(col1).addColumn(col2);
+
+        final AbstractRowInsertionBuilder<UpdateCallback> builder = new AbstractRowInsertionBuilder<UpdateCallback>(
+                null, table) {
+            @Override
+            public void execute() throws MetaModelException {
+                throw new UnsupportedOperationException();
+            }
+        };
+
+        builder.value(col1, "value1").value(col2, "value2");
+        assertEquals("INSERT INTO tbl(col1,col2) VALUES (\"value1\",\"value2\")", builder.toString());
+    }
+}
diff --git a/elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/JestElasticSearchUpdateCallback.java b/elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/JestElasticSearchUpdateCallback.java
index 521955d..94e557c 100644
--- a/elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/JestElasticSearchUpdateCallback.java
+++ b/elasticsearch/rest/src/main/java/org/apache/metamodel/elasticsearch/rest/JestElasticSearchUpdateCallback.java
@@ -1,165 +1,165 @@
-/**

- * Licensed to the Apache Software Foundation (ASF) under one

- * or more contributor license agreements.  See the NOTICE file

- * distributed with this work for additional information

- * regarding copyright ownership.  The ASF licenses this file

- * to you 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 org.apache.metamodel.elasticsearch.rest;

-

-import java.util.List;

-

-import org.apache.metamodel.AbstractUpdateCallback;

-import org.apache.metamodel.MetaModelException;

-import org.apache.metamodel.UpdateCallback;

-import org.apache.metamodel.create.TableCreationBuilder;

-import org.apache.metamodel.delete.RowDeletionBuilder;

-import org.apache.metamodel.drop.TableDropBuilder;

-import org.apache.metamodel.insert.RowInsertionBuilder;

-import org.apache.metamodel.schema.Schema;

-import org.apache.metamodel.schema.Table;

-import org.elasticsearch.action.bulk.BulkRequest;

-import org.slf4j.Logger;

-import org.slf4j.LoggerFactory;

-

-import io.searchbox.action.Action;

-import io.searchbox.action.BulkableAction;

-import io.searchbox.client.JestResult;

-import io.searchbox.core.Bulk;

-import io.searchbox.core.Bulk.Builder;

-import io.searchbox.core.BulkResult;

-import io.searchbox.core.BulkResult.BulkResultItem;

-import io.searchbox.indices.Refresh;

-

-/**

- * {@link UpdateCallback} implementation for

- * {@link ElasticSearchRestDataContext}.

- */

-final class JestElasticSearchUpdateCallback extends AbstractUpdateCallback {

-

-    private static final Logger logger = LoggerFactory.getLogger(JestElasticSearchUpdateCallback.class);

-

-    private static final int BULK_BUFFER_SIZE = 1000;

-

-    private Bulk.Builder bulkBuilder;

-    private int bulkActionCount = 0;

-    private final boolean isBatch;

-

-    public JestElasticSearchUpdateCallback(ElasticSearchRestDataContext dataContext, boolean isBatch) {

-        super(dataContext);

-        this.isBatch = isBatch;

-    }

-

-    private boolean isBatch() {

-        return isBatch;

-    }

-

-    @Override

-    public ElasticSearchRestDataContext getDataContext() {

-        return (ElasticSearchRestDataContext) super.getDataContext();

-    }

-

-    @Override

-    public TableCreationBuilder createTable(Schema schema, String name) throws IllegalArgumentException,

-            IllegalStateException {

-        return new JestElasticSearchCreateTableBuilder(this, schema, name);

-    }

-

-    @Override

-    public boolean isDropTableSupported() {

-        return true;

-    }

-

-    @Override

-    public TableDropBuilder dropTable(Table table) throws IllegalArgumentException, IllegalStateException,

-            UnsupportedOperationException {

-        return new JestElasticSearchDropTableBuilder(this, table);

-    }

-

-    @Override

-    public RowInsertionBuilder insertInto(Table table) throws IllegalArgumentException, IllegalStateException,

-            UnsupportedOperationException {

-        return new JestElasticSearchInsertBuilder(this, table);

-    }

-

-    @Override

-    public boolean isDeleteSupported() {

-        return true;

-    }

-

-    @Override

-    public RowDeletionBuilder deleteFrom(Table table) throws IllegalArgumentException, IllegalStateException,

-            UnsupportedOperationException {

-        return new JestElasticSearchDeleteBuilder(this, table);

-    }

-

-    public void onExecuteUpdateFinished() {

-        if (isBatch()) {

-            flushBulkActions();

-        }

-

-        final String indexName = getDataContext().getIndexName();

-        final Refresh refresh = new Refresh.Builder().addIndex(indexName).build();

-

-        JestClientExecutor.execute(getDataContext().getElasticSearchClient(), refresh, false);

-    }

-

-    private void flushBulkActions() {

-        if (bulkBuilder == null || bulkActionCount == 0) {

-            // nothing to flush

-            return;

-        }

-        final Bulk bulk = getBulkBuilder().build();

-        logger.info("Flushing {} actions to ElasticSearch index {}", bulkActionCount, getDataContext().getIndexName());

-        executeBlocking(bulk);

-

-        bulkActionCount = 0;

-        bulkBuilder = null;

-    }

-

-    public void execute(Action<?> action) {

-        if (isBatch() && action instanceof BulkableAction) {

-            final Bulk.Builder bulkBuilder = getBulkBuilder();

-            bulkBuilder.addAction((BulkableAction<?>) action);

-            bulkActionCount++;

-            if (bulkActionCount == BULK_BUFFER_SIZE) {

-                flushBulkActions();

-            }

-        } else {

-            executeBlocking(action);

-        }

-    }

-

-    private void executeBlocking(Action<?> action) {

-        final JestResult result = JestClientExecutor.execute(getDataContext().getElasticSearchClient(), action);

-        if (!result.isSucceeded()) {

-            if (result instanceof BulkResult) {

-                final List<BulkResultItem> failedItems = ((BulkResult) result).getFailedItems();

-                for (int i = 0; i < failedItems.size(); i++) {

-                    final BulkResultItem failedItem = failedItems.get(i);

-                    logger.error("Bulk failed with item no. {} of {}: id={} op={} status={} error={}", i+1, failedItems.size(), failedItem.id, failedItem.operation, failedItem.status, failedItem.error);

-                }

-            }

-            throw new MetaModelException(result.getResponseCode() + " - " + result.getErrorMessage());

-        }

-    }

-

-    private Builder getBulkBuilder() {

-        if (bulkBuilder == null) {

-            bulkBuilder = new Bulk.Builder();

-            bulkBuilder.defaultIndex(getDataContext().getIndexName());

-        }

-        return bulkBuilder;

-    }

-}

+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.metamodel.elasticsearch.rest;
+
+import java.util.List;
+
+import org.apache.metamodel.AbstractUpdateCallback;
+import org.apache.metamodel.MetaModelException;
+import org.apache.metamodel.UpdateCallback;
+import org.apache.metamodel.create.TableCreationBuilder;
+import org.apache.metamodel.delete.RowDeletionBuilder;
+import org.apache.metamodel.drop.TableDropBuilder;
+import org.apache.metamodel.insert.RowInsertionBuilder;
+import org.apache.metamodel.schema.Schema;
+import org.apache.metamodel.schema.Table;
+import org.elasticsearch.action.bulk.BulkRequest;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import io.searchbox.action.Action;
+import io.searchbox.action.BulkableAction;
+import io.searchbox.client.JestResult;
+import io.searchbox.core.Bulk;
+import io.searchbox.core.Bulk.Builder;
+import io.searchbox.core.BulkResult;
+import io.searchbox.core.BulkResult.BulkResultItem;
+import io.searchbox.indices.Refresh;
+
+/**
+ * {@link UpdateCallback} implementation for
+ * {@link ElasticSearchRestDataContext}.
+ */
+final class JestElasticSearchUpdateCallback extends AbstractUpdateCallback {
+
+    private static final Logger logger = LoggerFactory.getLogger(JestElasticSearchUpdateCallback.class);
+
+    private static final int BULK_BUFFER_SIZE = 1000;
+
+    private Bulk.Builder bulkBuilder;
+    private int bulkActionCount = 0;
+    private final boolean isBatch;
+
+    public JestElasticSearchUpdateCallback(ElasticSearchRestDataContext dataContext, boolean isBatch) {
+        super(dataContext);
+        this.isBatch = isBatch;
+    }
+
+    private boolean isBatch() {
+        return isBatch;
+    }
+
+    @Override
+    public ElasticSearchRestDataContext getDataContext() {
+        return (ElasticSearchRestDataContext) super.getDataContext();
+    }
+
+    @Override
+    public TableCreationBuilder createTable(Schema schema, String name) throws IllegalArgumentException,
+            IllegalStateException {
+        return new JestElasticSearchCreateTableBuilder(this, schema, name);
+    }
+
+    @Override
+    public boolean isDropTableSupported() {
+        return true;
+    }
+
+    @Override
+    public TableDropBuilder dropTable(Table table) throws IllegalArgumentException, IllegalStateException,
+            UnsupportedOperationException {
+        return new JestElasticSearchDropTableBuilder(this, table);
+    }
+
+    @Override
+    public RowInsertionBuilder insertInto(Table table) throws IllegalArgumentException, IllegalStateException,
+            UnsupportedOperationException {
+        return new JestElasticSearchInsertBuilder(this, table);
+    }
+
+    @Override
+    public boolean isDeleteSupported() {
+        return true;
+    }
+
+    @Override
+    public RowDeletionBuilder deleteFrom(Table table) throws IllegalArgumentException, IllegalStateException,
+            UnsupportedOperationException {
+        return new JestElasticSearchDeleteBuilder(this, table);
+    }
+
+    public void onExecuteUpdateFinished() {
+        if (isBatch()) {
+            flushBulkActions();
+        }
+
+        final String indexName = getDataContext().getIndexName();
+        final Refresh refresh = new Refresh.Builder().addIndex(indexName).build();
+
+        JestClientExecutor.execute(getDataContext().getElasticSearchClient(), refresh, false);
+    }
+
+    private void flushBulkActions() {
+        if (bulkBuilder == null || bulkActionCount == 0) {
+            // nothing to flush
+            return;
+        }
+        final Bulk bulk = getBulkBuilder().build();
+        logger.info("Flushing {} actions to ElasticSearch index {}", bulkActionCount, getDataContext().getIndexName());
+        executeBlocking(bulk);
+
+        bulkActionCount = 0;
+        bulkBuilder = null;
+    }
+
+    public void execute(Action<?> action) {
+        if (isBatch() && action instanceof BulkableAction) {
+            final Bulk.Builder bulkBuilder = getBulkBuilder();
+            bulkBuilder.addAction((BulkableAction<?>) action);
+            bulkActionCount++;
+            if (bulkActionCount == BULK_BUFFER_SIZE) {
+                flushBulkActions();
+            }
+        } else {
+            executeBlocking(action);
+        }
+    }
+
+    private void executeBlocking(Action<?> action) {
+        final JestResult result = JestClientExecutor.execute(getDataContext().getElasticSearchClient(), action);
+        if (!result.isSucceeded()) {
+            if (result instanceof BulkResult) {
+                final List<BulkResultItem> failedItems = ((BulkResult) result).getFailedItems();
+                for (int i = 0; i < failedItems.size(); i++) {
+                    final BulkResultItem failedItem = failedItems.get(i);
+                    logger.error("Bulk failed with item no. {} of {}: id={} op={} status={} error={}", i+1, failedItems.size(), failedItem.id, failedItem.operation, failedItem.status, failedItem.error);
+                }
+            }
+            throw new MetaModelException(result.getResponseCode() + " - " + result.getErrorMessage());
+        }
+    }
+
+    private Builder getBulkBuilder() {
+        if (bulkBuilder == null) {
+            bulkBuilder = new Bulk.Builder();
+            bulkBuilder.defaultIndex(getDataContext().getIndexName());
+        }
+        return bulkBuilder;
+    }
+}
diff --git a/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthColumnSpec.java b/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthColumnSpec.java
index dedfbcd..5f53ff5 100644
--- a/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthColumnSpec.java
+++ b/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthColumnSpec.java
@@ -1,45 +1,45 @@
-/**

- * Licensed to the Apache Software Foundation (ASF) under one

- * or more contributor license agreements.  See the NOTICE file

- * distributed with this work for additional information

- * regarding copyright ownership.  The ASF licenses this file

- * to you 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 org.apache.metamodel.fixedwidth;

-

-import org.apache.metamodel.util.HasName;

-

-/**

- * Represents the specification of a single column for a

- * {@link FixedWidthDataContext}.

- */

-final class FixedWidthColumnSpec implements HasName {

-

-    private final String name;

-    private final int width;

-

-    public FixedWidthColumnSpec(String name, int width) {

-        this.name = name;

-        this.width = width;

-    }

-

-    @Override

-    public String getName() {

-        return name;

-    }

-

-    public int getWidth() {

-        return width;

-    }

-}

+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.metamodel.fixedwidth;
+
+import org.apache.metamodel.util.HasName;
+
+/**
+ * Represents the specification of a single column for a
+ * {@link FixedWidthDataContext}.
+ */
+final class FixedWidthColumnSpec implements HasName {
+
+    private final String name;
+    private final int width;
+
+    public FixedWidthColumnSpec(String name, int width) {
+        this.name = name;
+        this.width = width;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    public int getWidth() {
+        return width;
+    }
+}
diff --git a/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthConfiguration.java b/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthConfiguration.java
index c53ff16..79aac36 100644
--- a/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthConfiguration.java
+++ b/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthConfiguration.java
@@ -1,186 +1,186 @@
-/**

- * Licensed to the Apache Software Foundation (ASF) under one

- * or more contributor license agreements.  See the NOTICE file

- * distributed with this work for additional information

- * regarding copyright ownership.  The ASF licenses this file

- * to you 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 org.apache.metamodel.fixedwidth;

-

-import java.io.Serializable;

-import java.util.Arrays;

-import java.util.List;

-

-import org.apache.metamodel.data.DataSet;

-import org.apache.metamodel.schema.naming.ColumnNamingStrategies;

-import org.apache.metamodel.schema.naming.ColumnNamingStrategy;

-import org.apache.metamodel.util.BaseObject;

-import org.apache.metamodel.util.CollectionUtils;

-import org.apache.metamodel.util.FileHelper;

-import org.apache.metamodel.util.HasNameMapper;

-

-/**

- * Configuration of metadata about a fixed width values data context.

- */

-public class FixedWidthConfiguration extends BaseObject implements Serializable {

-

-    private static final long serialVersionUID = 1L;

-

-    public static final int NO_COLUMN_NAME_LINE = 0;

-    public static final int DEFAULT_COLUMN_NAME_LINE = 1;

-

-    private final String encoding;

-    private final int fixedValueWidth;

-    private final int[] valueWidths;

-    private final int columnNameLineNumber;

-    private final boolean failOnInconsistentLineWidth;

-    private final ColumnNamingStrategy columnNamingStrategy;

-

-    public FixedWidthConfiguration(int fixedValueWidth) {

-        this(DEFAULT_COLUMN_NAME_LINE, FileHelper.DEFAULT_ENCODING, fixedValueWidth);

-    }

-

-    public FixedWidthConfiguration(int[] valueWidth) {

-        this(DEFAULT_COLUMN_NAME_LINE, FileHelper.DEFAULT_ENCODING, valueWidth, false);

-    }

-

-    public FixedWidthConfiguration(int columnNameLineNumber, String encoding, int fixedValueWidth) {

-        this(columnNameLineNumber, encoding, fixedValueWidth, false);

-    }

-

-    public FixedWidthConfiguration(int columnNameLineNumber, String encoding, int fixedValueWidth,

-            boolean failOnInconsistentLineWidth) {

-        this.encoding = encoding;

-        this.fixedValueWidth = fixedValueWidth;

-        this.columnNameLineNumber = columnNameLineNumber;

-        this.failOnInconsistentLineWidth = failOnInconsistentLineWidth;

-        this.columnNamingStrategy = null;

-        this.valueWidths = new int[0];

-    }

-

-    public FixedWidthConfiguration(int columnNameLineNumber, String encoding, int[] valueWidths, 

-            boolean failOnInconsistentLineWidth) {

-        this(columnNameLineNumber, null, encoding, valueWidths, failOnInconsistentLineWidth);

-    }

-

-    public FixedWidthConfiguration(int columnNameLineNumber, ColumnNamingStrategy columnNamingStrategy, String encoding,

-            int[] valueWidths, boolean failOnInconsistentLineWidth) {

-        this.encoding = encoding;

-        this.fixedValueWidth = -1;

-        this.columnNameLineNumber = columnNameLineNumber;

-        this.failOnInconsistentLineWidth = failOnInconsistentLineWidth;

-        this.columnNamingStrategy = columnNamingStrategy;

-        this.valueWidths = valueWidths;

-    }

-

-    public FixedWidthConfiguration(String encoding, List<FixedWidthColumnSpec> columnSpecs) {

-        this(encoding, columnSpecs, false);

-    }

-

-    public FixedWidthConfiguration(String encoding, List<FixedWidthColumnSpec> columnSpecs,

-            boolean failOnInconsistentLineWidth) {

-        this.encoding = encoding;

-        this.fixedValueWidth = -1;

-        this.columnNameLineNumber = NO_COLUMN_NAME_LINE;

-        this.columnNamingStrategy = ColumnNamingStrategies.customNames(CollectionUtils.map(columnSpecs,

-                new HasNameMapper()));

-        this.valueWidths = new int[columnSpecs.size()];

-        for (int i = 0; i < valueWidths.length; i++) {

-            valueWidths[i] = columnSpecs.get(i).getWidth();

-        }

-        this.failOnInconsistentLineWidth = failOnInconsistentLineWidth;

-    }

-

-    /**

-     * The line number (1 based) from which to get the names of the columns.

-     *

-     * @return an int representing the line number of the column headers/names.

-     */

-    public int getColumnNameLineNumber() {

-        return columnNameLineNumber;

-    }

-

-    /**

-     * Gets a {@link ColumnNamingStrategy} to use if needed.

-     * @return column naming strategy

-     */

-    public ColumnNamingStrategy getColumnNamingStrategy() {

-        if (columnNamingStrategy == null) {

-            return ColumnNamingStrategies.defaultStrategy();

-        }

-        return columnNamingStrategy;

-    }

-

-    /**

-     * Gets the file encoding to use for reading the file.

-     *

-     * @return the text encoding to use for reading the file.

-     */

-    public String getEncoding() {

-        return encoding;

-    }

-

-    /**

-     * Gets the width of each value within the fixed width value file.

-     *

-     * @return the fixed width to use when parsing the file.

-     */

-    public int getFixedValueWidth() {

-        return fixedValueWidth;

-    }

-

-    public int[] getValueWidths() {

-        return valueWidths;

-    }

-

-    /**

-     * Determines if the {@link DataSet#next()} should throw an exception in

-     * case of inconsistent line width in the fixed width value file.

-     *

-     * @return a boolean indicating whether or not to fail on inconsistent line

-     *         widths.

-     */

-    public boolean isFailOnInconsistentLineWidth() {

-        return failOnInconsistentLineWidth;

-    }

-

-    @Override

-    protected void decorateIdentity(List<Object> identifiers) {

-        identifiers.add(columnNameLineNumber);

-        identifiers.add(encoding);

-        identifiers.add(fixedValueWidth);

-        identifiers.add(valueWidths);

-        identifiers.add(failOnInconsistentLineWidth);

-    }

-

-    @Override

-    public String toString() {

-        return "FixedWidthConfiguration[encoding=" + encoding

-                + ", fixedValueWidth=" + fixedValueWidth + ", valueWidths="

-                + Arrays.toString(valueWidths) + ", columnNameLineNumber="

-                + columnNameLineNumber + ", failOnInconsistentLineWidth="

-                + failOnInconsistentLineWidth + "]";

-    }

-

-    public boolean isConstantValueWidth() {

-        return fixedValueWidth != -1;

-    }

-

-    public int getValueWidth(int columnIndex) {

-        if (isConstantValueWidth()) {

-            return fixedValueWidth;

-        }

-        return valueWidths[columnIndex];

-    }

-}

+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.metamodel.fixedwidth;
+
+import java.io.Serializable;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.metamodel.data.DataSet;
+import org.apache.metamodel.schema.naming.ColumnNamingStrategies;
+import org.apache.metamodel.schema.naming.ColumnNamingStrategy;
+import org.apache.metamodel.util.BaseObject;
+import org.apache.metamodel.util.CollectionUtils;
+import org.apache.metamodel.util.FileHelper;
+import org.apache.metamodel.util.HasNameMapper;
+
+/**
+ * Configuration of metadata about a fixed width values data context.
+ */
+public class FixedWidthConfiguration extends BaseObject implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    public static final int NO_COLUMN_NAME_LINE = 0;
+    public static final int DEFAULT_COLUMN_NAME_LINE = 1;
+
+    private final String encoding;
+    private final int fixedValueWidth;
+    private final int[] valueWidths;
+    private final int columnNameLineNumber;
+    private final boolean failOnInconsistentLineWidth;
+    private final ColumnNamingStrategy columnNamingStrategy;
+
+    public FixedWidthConfiguration(int fixedValueWidth) {
+        this(DEFAULT_COLUMN_NAME_LINE, FileHelper.DEFAULT_ENCODING, fixedValueWidth);
+    }
+
+    public FixedWidthConfiguration(int[] valueWidth) {
+        this(DEFAULT_COLUMN_NAME_LINE, FileHelper.DEFAULT_ENCODING, valueWidth, false);
+    }
+
+    public FixedWidthConfiguration(int columnNameLineNumber, String encoding, int fixedValueWidth) {
+        this(columnNameLineNumber, encoding, fixedValueWidth, false);
+    }
+
+    public FixedWidthConfiguration(int columnNameLineNumber, String encoding, int fixedValueWidth,
+            boolean failOnInconsistentLineWidth) {
+        this.encoding = encoding;
+        this.fixedValueWidth = fixedValueWidth;
+        this.columnNameLineNumber = columnNameLineNumber;
+        this.failOnInconsistentLineWidth = failOnInconsistentLineWidth;
+        this.columnNamingStrategy = null;
+        this.valueWidths = new int[0];
+    }
+
+    public FixedWidthConfiguration(int columnNameLineNumber, String encoding, int[] valueWidths, 
+            boolean failOnInconsistentLineWidth) {
+        this(columnNameLineNumber, null, encoding, valueWidths, failOnInconsistentLineWidth);
+    }
+
+    public FixedWidthConfiguration(int columnNameLineNumber, ColumnNamingStrategy columnNamingStrategy, String encoding,
+            int[] valueWidths, boolean failOnInconsistentLineWidth) {
+        this.encoding = encoding;
+        this.fixedValueWidth = -1;
+        this.columnNameLineNumber = columnNameLineNumber;
+        this.failOnInconsistentLineWidth = failOnInconsistentLineWidth;
+        this.columnNamingStrategy = columnNamingStrategy;
+        this.valueWidths = valueWidths;
+    }
+
+    public FixedWidthConfiguration(String encoding, List<FixedWidthColumnSpec> columnSpecs) {
+        this(encoding, columnSpecs, false);
+    }
+
+    public FixedWidthConfiguration(String encoding, List<FixedWidthColumnSpec> columnSpecs,
+            boolean failOnInconsistentLineWidth) {
+        this.encoding = encoding;
+        this.fixedValueWidth = -1;
+        this.columnNameLineNumber = NO_COLUMN_NAME_LINE;
+        this.columnNamingStrategy = ColumnNamingStrategies.customNames(CollectionUtils.map(columnSpecs,
+                new HasNameMapper()));
+        this.valueWidths = new int[columnSpecs.size()];
+        for (int i = 0; i < valueWidths.length; i++) {
+            valueWidths[i] = columnSpecs.get(i).getWidth();
+        }
+        this.failOnInconsistentLineWidth = failOnInconsistentLineWidth;
+    }
+
+    /**
+     * The line number (1 based) from which to get the names of the columns.
+     *
+     * @return an int representing the line number of the column headers/names.
+     */
+    public int getColumnNameLineNumber() {
+        return columnNameLineNumber;
+    }
+
+    /**
+     * Gets a {@link ColumnNamingStrategy} to use if needed.
+     * @return column naming strategy
+     */
+    public ColumnNamingStrategy getColumnNamingStrategy() {
+        if (columnNamingStrategy == null) {
+            return ColumnNamingStrategies.defaultStrategy();
+        }
+        return columnNamingStrategy;
+    }
+
+    /**
+     * Gets the file encoding to use for reading the file.
+     *
+     * @return the text encoding to use for reading the file.
+     */
+    public String getEncoding() {
+        return encoding;
+    }
+
+    /**
+     * Gets the width of each value within the fixed width value file.
+     *
+     * @return the fixed width to use when parsing the file.
+     */
+    public int getFixedValueWidth() {
+        return fixedValueWidth;
+    }
+
+    public int[] getValueWidths() {
+        return valueWidths;
+    }
+
+    /**
+     * Determines if the {@link DataSet#next()} should throw an exception in
+     * case of inconsistent line width in the fixed width value file.
+     *
+     * @return a boolean indicating whether or not to fail on inconsistent line
+     *         widths.
+     */
+    public boolean isFailOnInconsistentLineWidth() {
+        return failOnInconsistentLineWidth;
+    }
+
+    @Override
+    protected void decorateIdentity(List<Object> identifiers) {
+        identifiers.add(columnNameLineNumber);
+        identifiers.add(encoding);
+        identifiers.add(fixedValueWidth);
+        identifiers.add(valueWidths);
+        identifiers.add(failOnInconsistentLineWidth);
+    }
+
+    @Override
+    public String toString() {
+        return "FixedWidthConfiguration[encoding=" + encoding
+                + ", fixedValueWidth=" + fixedValueWidth + ", valueWidths="
+                + Arrays.toString(valueWidths) + ", columnNameLineNumber="
+                + columnNameLineNumber + ", failOnInconsistentLineWidth="
+                + failOnInconsistentLineWidth + "]";
+    }
+
+    public boolean isConstantValueWidth() {
+        return fixedValueWidth != -1;
+    }
+
+    public int getValueWidth(int columnIndex) {
+        if (isConstantValueWidth()) {
+            return fixedValueWidth;
+        }
+        return valueWidths[columnIndex];
+    }
+}
diff --git a/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthConfigurationReader.java b/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthConfigurationReader.java
index 264287f..71a2640 100644
--- a/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthConfigurationReader.java
+++ b/fixedwidth/src/main/java/org/apache/metamodel/fixedwidth/FixedWidthConfigurationReader.java
@@ -1,176 +1,176 @@
-/**

- * Licensed to the Apache Software Foundation (ASF) under one

- * or more contributor license agreements.  See the NOTICE file

- * distributed with this work for additional information

- * regarding copyright ownership.  The ASF licenses this file

- * to you 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 org.apache.metamodel.fixedwidth;

-

-import java.io.BufferedReader;

-import java.io.InputStream;

-import java.io.InputStreamReader;

-import java.util.ArrayList;

-import java.util.HashMap;

-import java.util.LinkedHashMap;

-import java.util.List;

-import java.util.Map;

-import java.util.Map.Entry;

-import java.util.regex.Matcher;

-import java.util.regex.Pattern;

-

-import org.apache.metamodel.csv.CsvConfiguration;

-import org.apache.metamodel.csv.CsvDataContext;

-import org.apache.metamodel.data.DataSet;

-import org.apache.metamodel.schema.Table;

-import org.apache.metamodel.util.Action;

-import org.apache.metamodel.util.Resource;

-import org.slf4j.Logger;

-import org.slf4j.LoggerFactory;

-

-/**

- * Object capable of reading fixed width metadata from external sources and

- * thereby producing an appropriate {@link FixedWidthConfiguration} to use with

- * a {@link FixedWidthDataContext}.

- */

-public class FixedWidthConfigurationReader {

-

-    private static final Logger logger = LoggerFactory.getLogger(FixedWidthConfigurationReader.class);

-

-    // example: @1 COL1 $char1.

-    private final Pattern PATTERN_SAS_INPUT_LINE = Pattern.compile("\\@(\\d+) (.+) .*?(\\d+)\\.");

-

-    // example: COL1 "Record type"

-    private final Pattern PATTERN_SAS_LABEL_LINE = Pattern.compile("(.+) \\\"(.+)\\\"");

-

-    /**

-     * Reads a {@link FixedWidthConfiguration} based on a SAS 'format file',

-     * <a href=

-     * "http://support.sas.com/documentation/cdl/en/etlug/67323/HTML/default/viewer.htm#p0h03yig7fp1qan1arghp3lwjqi6.htm">

-     * described here</a>.

-     * 

-     * @param encoding the format file encoding

-     * @param resource the format file resource 

-     * @param failOnInconsistentLineWidth flag specifying whether inconsistent line should stop processing or not

-     * @return a {@link FixedWidthConfiguration} object to use

-     */

-    public FixedWidthConfiguration readFromSasFormatFile(String encoding, Resource resource,

-            boolean failOnInconsistentLineWidth) {

-        final List<FixedWidthColumnSpec> columnSpecs = new ArrayList<>();

-

-        final CsvDataContext dataContext = new CsvDataContext(resource, new CsvConfiguration());

-        final Table table = dataContext.getDefaultSchema().getTable(0);

-        try (final DataSet dataSet = dataContext.query().from(table).select("Name", "BeginPosition", "EndPosition")

-                .execute()) {

-            while (dataSet.next()) {

-                final String name = (String) dataSet.getRow().getValue(0);

-                final int beginPosition = Integer.parseInt((String) dataSet.getRow().getValue(1));

-                final int endPosition = Integer.parseInt((String) dataSet.getRow().getValue(2));

-                final int width = 1 + endPosition - beginPosition;

-                columnSpecs.add(new FixedWidthColumnSpec(name, width));

-            }

-        }

-

-        return new FixedWidthConfiguration(encoding, columnSpecs, failOnInconsistentLineWidth);

-    }

-

-    /**

-     * Reads a {@link FixedWidthConfiguration} based on a SAS INPUT declaration.

-     * The reader method also optionally will look for a LABEL definition for column naming.

-     * 

-     * @param encoding the format file encoding

-     * @param resource the format file resource

-     * @param failOnInconsistentLineWidth flag specifying whether inconsistent line should stop processing or not

-     * @return a {@link FixedWidthConfiguration} object to use

-     */

-    public FixedWidthConfiguration readFromSasInputDefinition(String encoding, Resource resource,

-            boolean failOnInconsistentLineWidth) {

-

-        final Map<String, Integer> inputWidthDeclarations = new LinkedHashMap<>();

-        final Map<String, String> labelDeclarations = new HashMap<>();

-

-        resource.read(new Action<InputStream>() {

-

-            private boolean inInputSection = false;

-            private boolean inLabelSection = false;

-

-            @Override

-            public void run(InputStream in) throws Exception {

-                try (final BufferedReader reader = new BufferedReader(new InputStreamReader(in))) {

-                    for (String line = reader.readLine(); line != null; line = reader.readLine()) {

-                        processLine(line);

-                    }

-                }

-            }

-

-            private void processLine(String line) {

-                line = line.trim();

-                if (line.isEmpty()) {

-                    return;

-                }

-                if (";".equals(line)) {

-                    inInputSection = false;

-                    inLabelSection = false;

-                    return;

-                } else if ("INPUT".equals(line)) {

-                    inInputSection = true;

-                    return;

-                } else if ("LABEL".equals(line)) {

-                    inLabelSection = true;

-                    return;

-                }

-

-                if (inInputSection) {

-                    final Matcher matcher = PATTERN_SAS_INPUT_LINE.matcher(line);

-                    if (matcher.matches()) {

-                        final String positionSpec = matcher.group(1);

-                        final String nameSpec = matcher.group(2);

-                        final int width = Integer.parseInt(matcher.group(3));

-                        logger.debug("Parsed INPUT line \"{}\": position={}, name={}, width={}", line, positionSpec,

-                                nameSpec, width);

-                        inputWidthDeclarations.put(nameSpec, width);

-                    } else {

-                        logger.debug("Failed to parse/recognize INPUT line \"{}\"", line);

-                    }

-                } else if (inLabelSection) {

-                    final Matcher matcher = PATTERN_SAS_LABEL_LINE.matcher(line);

-                    if (matcher.matches()) {

-                        final String nameSpec = matcher.group(1);

-                        final String labelSpec = matcher.group(2);

-                        logger.debug("Parsed LABEL line \"{}\": name={}, label={}", line, nameSpec, labelSpec);

-                        labelDeclarations.put(nameSpec, labelSpec);

-                    } else {

-                        logger.debug("Failed to parse/recognize LABEL line \"{}\"", line);

-                    }

-                }

-

-                if (line.endsWith(";")) {

-                    inInputSection = false;

-                    inLabelSection = false;

-                }

-            }

-        });

-

-        final List<FixedWidthColumnSpec> columnSpecs = new ArrayList<>();

-        for (Entry<String, Integer> entry : inputWidthDeclarations.entrySet()) {

-            final String columnKey = entry.getKey();

-            final Integer columnWidth = entry.getValue();

-            final String columnLabel = labelDeclarations.get(columnKey);

-            final String columnName = columnLabel == null ? columnKey : columnLabel;

-            columnSpecs.add(new FixedWidthColumnSpec(columnName, columnWidth));

-        }

-

-        return new FixedWidthConfiguration(encoding, columnSpecs, failOnInconsistentLineWidth);

-    }

-}

+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.metamodel.fixedwidth;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.metamodel.csv.CsvConfiguration;
+import org.apache.metamodel.csv.CsvDataContext;
+import org.apache.metamodel.data.DataSet;
+import org.apache.metamodel.schema.Table;
+import org.apache.metamodel.util.Action;
+import org.apache.metamodel.util.Resource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Object capable of reading fixed width metadata from external sources and
+ * thereby producing an appropriate {@link FixedWidthConfiguration} to use with
+ * a {@link FixedWidthDataContext}.
+ */
+public class FixedWidthConfigurationReader {
+
+    private static final Logger logger = LoggerFactory.getLogger(FixedWidthConfigurationReader.class);
+
+    // example: @1 COL1 $char1.
+    private final Pattern PATTERN_SAS_INPUT_LINE = Pattern.compile("\\@(\\d+) (.+) .*?(\\d+)\\.");
+
+    // example: COL1 "Record type"
+    private final Pattern PATTERN_SAS_LABEL_LINE = Pattern.compile("(.+) \\\"(.+)\\\"");
+
+    /**
+     * Reads a {@link FixedWidthConfiguration} based on a SAS 'format file',
+     * <a href=
+     * "http://support.sas.com/documentation/cdl/en/etlug/67323/HTML/default/viewer.htm#p0h03yig7fp1qan1arghp3lwjqi6.htm">
+     * described here</a>.
+     * 
+     * @param encoding the format file encoding
+     * @param resource the format file resource 
+     * @param failOnInconsistentLineWidth flag specifying whether inconsistent line should stop processing or not
+     * @return a {@link FixedWidthConfiguration} object to use
+     */
+    public FixedWidthConfiguration readFromSasFormatFile(String encoding, Resource resource,
+            boolean failOnInconsistentLineWidth) {
+        final List<FixedWidthColumnSpec> columnSpecs = new ArrayList<>();
+
+        final CsvDataContext dataContext = new CsvDataContext(resource, new CsvConfiguration());
+        final Table table = dataContext.getDefaultSchema().getTable(0);
+        try (final DataSet dataSet = dataContext.query().from(table).select("Name", "BeginPosition", "EndPosition")
+                .execute()) {
+            while (dataSet.next()) {
+                final String name = (String) dataSet.getRow().getValue(0);
+                final int beginPosition = Integer.parseInt((String) dataSet.getRow().getValue(1));
+                final int endPosition = Integer.parseInt((String) dataSet.getRow().getValue(2));
+                final int width = 1 + endPosition - beginPosition;
+                columnSpecs.add(new FixedWidthColumnSpec(name, width));
+            }
+        }
+
+        return new FixedWidthConfiguration(encoding, columnSpecs, failOnInconsistentLineWidth);
+    }
+
+    /**
+     * Reads a {@link FixedWidthConfiguration} based on a SAS INPUT declaration.
+     * The reader method also optionally will look for a LABEL definition for column naming.
+     * 
+     * @param encoding the format file encoding
+     * @param resource the format file resource
+     * @param failOnInconsistentLineWidth flag specifying whether inconsistent line should stop processing or not
+     * @return a {@link FixedWidthConfiguration} object to use
+     */
+    public FixedWidthConfiguration readFromSasInputDefinition(String encoding, Resource resource,
+            boolean failOnInconsistentLineWidth) {
+
+        final Map<String, Integer> inputWidthDeclarations = new LinkedHashMap<>();
+        final Map<String, String> labelDeclarations = new HashMap<>();
+
+        resource.read(new Action<InputStream>() {
+
+            private boolean inInputSection = false;
+            private boolean inLabelSection = false;
+
+            @Override
+            public void run(InputStream in) throws Exception {
+                try (final BufferedReader reader = new BufferedReader(new InputStreamReader(in))) {
+                    for (String line = reader.readLine(); line != null; line = reader.readLine()) {
+                        processLine(line);
+                    }
+                }
+            }
+
+            private void processLine(String line) {
+                line = line.trim();
+                if (line.isEmpty()) {
+                    return;
+                }
+                if (";".equals(line)) {
+                    inInputSection = false;
+                    inLabelSection = false;
+                    return;
+                } else if ("INPUT".equals(line)) {
+                    inInputSection = true;
+                    return;
+                } else if ("LABEL".equals(line)) {
+                    inLabelSection = true;
+                    return;
+                }
+
+                if (inInputSection) {
+                    final Matcher matcher = PATTERN_SAS_INPUT_LINE.matcher(line);
+                    if (matcher.matches()) {
+                        final String positionSpec = matcher.group(1);
+                        final String nameSpec = matcher.group(2);
+                        final int width = Integer.parseInt(matcher.group(3));
+                        logger.debug("Parsed INPUT line \"{}\": position={}, name={}, width={}", line, positionSpec,
+                                nameSpec, width);
+                        inputWidthDeclarations.put(nameSpec, width);
+                    } else {
+                        logger.debug("Failed to parse/recognize INPUT line \"{}\"", line);
+                    }
+                } else if (inLabelSection) {
+                    final Matcher matcher = PATTERN_SAS_LABEL_LINE.matcher(line);
+                    if (matcher.matches()) {
+                        final String nameSpec = matcher.group(1);
+                        final String labelSpec = matcher.group(2);
+                        logger.debug("Parsed LABEL line \"{}\": name={}, label={}", line, nameSpec, labelSpec);
+                        labelDeclarations.put(nameSpec, labelSpec);
+                    } else {
+                        logger.debug("Failed to parse/recognize LABEL line \"{}\"", line);
+                    }
+                }
+
+                if (line.endsWith(";")) {
+                    inInputSection = false;
+                    inLabelSection = false;
+                }
+            }
+        });
+
+        final List<FixedWidthColumnSpec> columnSpecs = new ArrayList<>();
+        for (Entry<String, Integer> entry : inputWidthDeclarations.entrySet()) {
+            final String columnKey = entry.getKey();
+            final Integer columnWidth = entry.getValue();
+            final String columnLabel = labelDeclarations.get(columnKey);
+            final String columnName = columnLabel == null ? columnKey : columnLabel;
+            columnSpecs.add(new FixedWidthColumnSpec(columnName, columnWidth));
+        }
+
+        return new FixedWidthConfiguration(encoding, columnSpecs, failOnInconsistentLineWidth);
+    }
+}
diff --git a/fixedwidth/src/test/java/org/apache/metamodel/fixedwidth/FixedWidthConfigurationReaderTest.java b/fixedwidth/src/test/java/org/apache/metamodel/fixedwidth/FixedWidthConfigurationReaderTest.java
index eb57233..c34b294 100644
--- a/fixedwidth/src/test/java/org/apache/metamodel/fixedwidth/FixedWidthConfigurationReaderTest.java
+++ b/fixedwidth/src/test/java/org/apache/metamodel/fixedwidth/FixedWidthConfigurationReaderTest.java
@@ -1,89 +1,89 @@
-/**

- * Licensed to the Apache Software Foundation (ASF) under one

- * or more contributor license agreements.  See the NOTICE file

- * distributed with this work for additional information

- * regarding copyright ownership.  The ASF licenses this file

- * to you 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 org.apache.metamodel.fixedwidth;

-

-import static org.junit.Assert.*;

-

-import java.util.Arrays;

-

-import org.apache.metamodel.DataContext;

-import org.apache.metamodel.data.DataSet;

-import org.apache.metamodel.schema.Table;

-import org.apache.metamodel.util.FileResource;

-import org.apache.metamodel.util.Resource;

-import org.junit.Test;

-

-public class FixedWidthConfigurationReaderTest {

-

-    private final FileResource dataResource = new FileResource("src/test/resources/metadata_spec1/data.txt");

-

-    @Test

-    public void testReadConfigurationFromSasFormatFile() throws Exception {

-        final FixedWidthConfigurationReader reader = new FixedWidthConfigurationReader();

-        final Resource resource = new FileResource("src/test/resources/metadata_spec1/sas-formatfile-metadata.txt");

-        assertTrue(resource.isExists());

-

-        final FixedWidthConfiguration configuration = reader.readFromSasFormatFile("UTF8", resource, false);

-        assertEquals("[1, 20, 2]", Arrays.toString(configuration.getValueWidths()));

-

-        final FixedWidthDataContext dataContext = new FixedWidthDataContext(dataResource, configuration);

-

-        performAssertionsOnSpec1(dataContext);

-    }

-    

-    @Test

-    public void testReadConfigurationFromSasInputMetadata() throws Exception {

-        final FixedWidthConfigurationReader reader = new FixedWidthConfigurationReader();

-        final Resource resource = new FileResource("src/test/resources/metadata_spec1/sas-input-metadata.txt");

-        assertTrue(resource.isExists());

-

-        final FixedWidthConfiguration configuration = reader.readFromSasInputDefinition("UTF8", resource, false);

-        assertEquals("[1, 20, 2]", Arrays.toString(configuration.getValueWidths()));

-

-        final FixedWidthDataContext dataContext = new FixedWidthDataContext(dataResource, configuration);

-

-        performAssertionsOnSpec1(dataContext);

-    }

-

-    /**

-     * Shared assertions section once the 'metadata_spec1' {@link DataContext}

-     * has been loaded.

-     * 

-     * @param dataContext

-     */

-    private void performAssertionsOnSpec1(FixedWidthDataContext dataContext) {

-        final Table table = dataContext.getDefaultSchema().getTable(0);

-        final String[] columnNames = table.getColumnNames();

-        assertEquals("[Record type, Description, Initials]", Arrays.toString(columnNames));

-

-        try (final DataSet dataSet = dataContext.query().from(table).selectAll().execute()) {

-            assertTrue(dataSet.next());

-            assertEquals("Row[values=[P, Kasper Sorensen, KS]]", dataSet.getRow().toString());

-            assertTrue(dataSet.next());

-            assertEquals("Row[values=[C, Human Inference, HI]]", dataSet.getRow().toString());

-            assertTrue(dataSet.next());

-            assertEquals("Row[values=[P, Ankit Kumar, AK]]", dataSet.getRow().toString());

-            assertTrue(dataSet.next());

-            assertEquals("Row[values=[C, Stratio, S]]", dataSet.getRow().toString());

-            assertTrue(dataSet.next());

-            assertEquals("Row[values=[U, Unknown, ]]", dataSet.getRow().toString());

-            assertFalse(dataSet.next());

-        }

-    }

-}

+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.metamodel.fixedwidth;
+
+import static org.junit.Assert.*;
+
+import java.util.Arrays;
+
+import org.apache.metamodel.DataContext;
+import org.apache.metamodel.data.DataSet;
+import org.apache.metamodel.schema.Table;
+import org.apache.metamodel.util.FileResource;
+import org.apache.metamodel.util.Resource;
+import org.junit.Test;
+
+public class FixedWidthConfigurationReaderTest {
+
+    private final FileResource dataResource = new FileResource("src/test/resources/metadata_spec1/data.txt");
+
+    @Test
+    public void testReadConfigurationFromSasFormatFile() throws Exception {
+        final FixedWidthConfigurationReader reader = new FixedWidthConfigurationReader();
+        final Resource resource = new FileResource("src/test/resources/metadata_spec1/sas-formatfile-metadata.txt");
+        assertTrue(resource.isExists());
+
+        final FixedWidthConfiguration configuration = reader.readFromSasFormatFile("UTF8", resource, false);
+        assertEquals("[1, 20, 2]", Arrays.toString(configuration.getValueWidths()));
+
+        final FixedWidthDataContext dataContext = new FixedWidthDataContext(dataResource, configuration);
+
+        performAssertionsOnSpec1(dataContext);
+    }
+    
+    @Test
+    public void testReadConfigurationFromSasInputMetadata() throws Exception {
+        final FixedWidthConfigurationReader reader = new FixedWidthConfigurationReader();
+        final Resource resource = new FileResource("src/test/resources/metadata_spec1/sas-input-metadata.txt");
+        assertTrue(resource.isExists());
+
+        final FixedWidthConfiguration configuration = reader.readFromSasInputDefinition("UTF8", resource, false);
+        assertEquals("[1, 20, 2]", Arrays.toString(configuration.getValueWidths()));
+
+        final FixedWidthDataContext dataContext = new FixedWidthDataContext(dataResource, configuration);
+
+        performAssertionsOnSpec1(dataContext);
+    }
+
+    /**
+     * Shared assertions section once the 'metadata_spec1' {@link DataContext}
+     * has been loaded.
+     * 
+     * @param dataContext
+     */
+    private void performAssertionsOnSpec1(FixedWidthDataContext dataContext) {
+        final Table table = dataContext.getDefaultSchema().getTable(0);
+        final String[] columnNames = table.getColumnNames();
+        assertEquals("[Record type, Description, Initials]", Arrays.toString(columnNames));
+
+        try (final DataSet dataSet = dataContext.query().from(table).selectAll().execute()) {
+            assertTrue(dataSet.next());
+            assertEquals("Row[values=[P, Kasper Sorensen, KS]]", dataSet.getRow().toString());
+            assertTrue(dataSet.next());
+            assertEquals("Row[values=[C, Human Inference, HI]]", dataSet.getRow().toString());
+            assertTrue(dataSet.next());
+            assertEquals("Row[values=[P, Ankit Kumar, AK]]", dataSet.getRow().toString());
+            assertTrue(dataSet.next());
+            assertEquals("Row[values=[C, Stratio, S]]", dataSet.getRow().toString());
+            assertTrue(dataSet.next());
+            assertEquals("Row[values=[U, Unknown, ]]", dataSet.getRow().toString());
+            assertFalse(dataSet.next());
+        }
+    }
+}
diff --git a/fixedwidth/src/test/resources/metadata_spec1/data.txt b/fixedwidth/src/test/resources/metadata_spec1/data.txt
index 785a539..ac055c9 100644
--- a/fixedwidth/src/test/resources/metadata_spec1/data.txt
+++ b/fixedwidth/src/test/resources/metadata_spec1/data.txt
@@ -1,5 +1,5 @@
-PKasper Sorensen     KS

-CHuman Inference     HI

-PAnkit Kumar         AK

-CStratio             S 

-UUnknown               

+PKasper Sorensen     KS
+CHuman Inference     HI
+PAnkit Kumar         AK
+CStratio             S 
+UUnknown               
diff --git a/fixedwidth/src/test/resources/metadata_spec1/sas-formatfile-metadata.txt b/fixedwidth/src/test/resources/metadata_spec1/sas-formatfile-metadata.txt
index 9bbe411..38b0e04 100644
--- a/fixedwidth/src/test/resources/metadata_spec1/sas-formatfile-metadata.txt
+++ b/fixedwidth/src/test/resources/metadata_spec1/sas-formatfile-metadata.txt
@@ -1,4 +1,4 @@
-Name,SASColumnType,BeginPosition,EndPosition,ReadFlag,Desc,SASFormat,SASInformat

-Record type,C,1,1,y,Record Type,$char.,$char.

-Description,C,2,21,y,Description of record,$char.,$char.

-Initials,C,22,23,y,Initials of record,,

+Name,SASColumnType,BeginPosition,EndPosition,ReadFlag,Desc,SASFormat,SASInformat
+Record type,C,1,1,y,Record Type,$char.,$char.
+Description,C,2,21,y,Description of record,$char.,$char.
+Initials,C,22,23,y,Initials of record,,
diff --git a/fixedwidth/src/test/resources/metadata_spec1/sas-input-metadata.txt b/fixedwidth/src/test/resources/metadata_spec1/sas-input-metadata.txt
index f12e418..6839a9b 100644
--- a/fixedwidth/src/test/resources/metadata_spec1/sas-input-metadata.txt
+++ b/fixedwidth/src/test/resources/metadata_spec1/sas-input-metadata.txt
@@ -1,19 +1,19 @@
-INPUT

-

-   @1 COL1 $char1.

-

-   @2 COL2 $char20.

-

-   @22 COL3 $char2.

-   

-;

-

-LABEL

-

-   COL1 "Record type"

-

-   COL2 "Description"

-

-   COL3 "Initials"

-

-;

+INPUT
+
+   @1 COL1 $char1.
+
+   @2 COL2 $char20.
+
+   @22 COL3 $char2.
+   
+;
+
+LABEL
+
+   COL1 "Record type"
+
+   COL2 "Description"
+
+   COL3 "Initials"
+
+;