01: /*
02: * Copyright 2004-2006 Fouad HAMDI.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.csvbeans.builders;
17:
18: import java.util.List;
19: import java.util.Map;
20:
21: import org.csvbeans.specs.SpecificationsFile;
22:
23: /**
24: * Define the specifications of CSV building strategy.
25: *
26: * Implement this interface to create your own CSV builder.
27: *
28: * @author Fouad Hamdi
29: * @since 0.5
30: */
31: public interface BuildingStrategy {
32: /**
33: * Define the CSV file header.
34: *
35: * @param header
36: * the header object.
37: */
38: void setHeader(Object header);
39:
40: /**
41: * Define a list of beans associated with a tag. During the generation, the
42: * beans will be added to the CSV file below the specified tag. The tag and
43: * beans must be defined in the XML specification file or there will be an
44: * error during the generation.
45: *
46: * @param tag
47: * the tag after which the beans will be added.
48: * @param beans
49: * the objects associated with the tag.
50: */
51: void addBeans(String tag, List beans);
52:
53: /**
54: * Build the CSV file according to the builder specifications.
55: *
56: * @param output
57: * the writer where the lines will be written.
58: * @throws GenerationException
59: * when there is a problem to build the CSV file.
60: */
61: void build(LinesWriter output) throws GenerationException;
62:
63: /**
64: * Define the CSV specifications.
65: *
66: * @param specifications
67: * The CSV specifications.
68: */
69: void setSpecifications(SpecificationsFile specifications);
70:
71: /**
72: * Add a property to the building strategy. It is used to set some
73: * properties to specific builders.
74: *
75: * @param name
76: * @param value
77: */
78: void addProperty(String name, String value);
79:
80: /**
81: * Define the builder properties.
82: *
83: * @param properties
84: * the builder properties.
85: */
86: void setProperties(Map properties);
87:
88: /**
89: * Return the value of the specified property.
90: *
91: * @param name
92: * the property name
93: * @return the property value
94: */
95: String getPropertyValue(String name);
96: }
|