1 /**
2  *  ServingXML
3  *
4  *  Copyright (C) 2006  Daniel Parker
5  *    daniel.parker@servingxml.com
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  **/
20 
21 package com.servingxml.components.flatfile.options;
22 
23 import com.servingxml.app.ServiceContext;
24 import com.servingxml.app.Flow;
25 import com.servingxml.components.flatfile.options.Delimiter;
26 
27 public class SegmentDelimiterFactory implements DelimiterFactory {
28 
29   public static final SegmentDelimiterFactory[] EMPTY_ARRAY = new SegmentDelimiterFactory[0];
30 
31   private final SeparatorFactory separatorFactory;
32 
SegmentDelimiterFactory(SeparatorFactory separatorFactory)33   public SegmentDelimiterFactory(SeparatorFactory separatorFactory) {
34     this.separatorFactory = separatorFactory;
35   }
36 
SegmentDelimiterFactory(String separator)37   public SegmentDelimiterFactory(String separator) {
38     this.separatorFactory = new DefaultSeparatorFactory(separator);
39   }
40 
createDelimiter(ServiceContext context, Flow flow)41   public Delimiter createDelimiter(ServiceContext context, Flow flow) {
42     Separator separator = separatorFactory.createSeparator(context, flow);
43 
44     return new SegmentDelimiter(separator);
45   }
46 }
47