001    /*
002     * Copyright 2011 The Kuali Foundation.
003     * 
004     * Licensed under the Educational Community 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.opensource.org/licenses/ecl2.php
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.kuali.kfs.sys.businessobject;
017    
018    import java.io.InputStream;
019    import java.util.List;
020    
021    import org.kuali.kfs.sys.document.AccountingDocument;
022    
023    /**
024     * Defines an abstraction for parsing serialized <code>AccountingLines</code>
025     */
026    public interface AccountingLineParser {
027        /**
028         * @return <code>SourceAccountingLine</code> attribute format
029         */
030        public String[] getSourceAccountingLineFormat();
031    
032        /**
033         * @return <code>TargetAccountingLine</code> attribute format
034         */
035        public String[] getTargetAccountingLineFormat();
036    
037        /**
038         * @param accountingLineClass
039         * @return String representation of the <code>String[]</code> attribute format with each attribute seperated by a comma.
040         */
041        public String getExpectedAccountingLineFormatAsString(Class<? extends AccountingLine> accountingLineClass);
042    
043        /**
044         * parses a comma deliminated string into an <code>SourceAccountingLine</code> by populating the attributes found in the
045         * getSourceAccountingLineFormat()
046         * 
047         * @param transactionalDocument
048         * @param sourceAccountingLineString
049         * @return SourceAccountingLine
050         */
051        public SourceAccountingLine parseSourceAccountingLine(AccountingDocument transactionalDocument, String sourceAccountingLineString);
052    
053        /**
054         * parses a comma deliminated string into an <code>TargetAccountingLine</code> by populating the attributes found in the
055         * getTargetAccountingLineFormat()
056         * 
057         * @param transactionalDocument
058         * @param targetAccountingLineString
059         * @return TargetAccountingLine
060         */
061        public TargetAccountingLine parseTargetAccountingLine(AccountingDocument transactionalDocument, String targetAccountingLineString);
062    
063        /**
064         * generates a list of <code>SourceAccountingLine</code> from the inputStream
065         * 
066         * @param stream
067         * @param document
068         * @return List containing <code>SourceAccountingLine</code>s
069         */
070        public List importSourceAccountingLines(String fileName, InputStream stream, AccountingDocument document);
071    
072        /**
073         * generates a list of <code>TargetAccountingLine</code> from the inputStream
074         * 
075         * @param stream
076         * @param document
077         * @return List containing <code>SourceAccountingLine</code>s
078         */
079        public List importTargetAccountingLines(String fileName, InputStream stream, AccountingDocument document);
080    
081    }