001: /*
002: * Copyright 2004-2006 Fouad HAMDI.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package org.csvbeans.specs;
017:
018: import org.csvbeans.builders.BuildingStrategy;
019: import org.csvbeans.builders.LineBuilder;
020: import org.csvbeans.converters.Converter;
021: import org.csvbeans.parsers.LineParser;
022: import org.csvbeans.parsers.ParsingStrategy;
023:
024: /**
025: * Define the specifications of the specification file.
026: *
027: * @author Fouad Hamdi
028: * @since 0.5
029: */
030: public interface SpecificationsFile {
031: /**
032: * Return the specifications associated with the specified tag.
033: *
034: * @param tag
035: * the tag
036: * @return The record specifications associated with the specified tag.
037: */
038: RecordSpecification getRecord(String tag);
039:
040: /**
041: * Allow to know if there is a record with the specified tag.
042: *
043: * @param tag
044: * the tag to verify.
045: */
046: boolean isRecordExisting(String tag);
047:
048: /**
049: * Allow to know if a header is defined for these specifications.
050: */
051: boolean hasHeader();
052:
053: /**
054: * Return the header description of the specifications.
055: */
056: BeanSpecification getHeader();
057:
058: /**
059: * Allow to know if a separator ends each CSV line.
060: */
061: boolean isEndingSeparatorEnabled();
062:
063: /**
064: * Returns the parsing strategy defined in the specifications file.
065: */
066: ParsingStrategy getParsingStrategy()
067: throws SpecificationsFileException;
068:
069: /**
070: * Returns the building strategy defined in the specifications file.
071: */
072: BuildingStrategy getBuildingStrategy()
073: throws SpecificationsFileException;
074:
075: /**
076: * Return the separator between the fields of a CSV line.
077: *
078: * @return the separator.
079: */
080: String getFieldSeparator();
081:
082: /**
083: * Return a CSV line parser initialized with the provided specifications.
084: */
085: LineParser getLineParser(BeanSpecification spec)
086: throws SpecificationsFileException;
087:
088: /**
089: * Return a CSV line builder initialized with the provided specifications.
090: */
091: LineBuilder getLineBuilder(BeanSpecification spec)
092: throws SpecificationsFileException;
093:
094: /**
095: * Return the converter associated with the specified id.
096: */
097: Converter getConverterById(String id);
098:
099: /**
100: * Clear the session context.
101: */
102: void clearSessionContext();
103:
104: /**
105: * Clear the record context.
106: */
107: void clearRecordContext();
108:
109: /**
110: * Allow to know if the same record must be used for all the data.
111: */
112: boolean useSameRecord();
113: }
|