View Javadoc
1   /*
2    * Copyright 2006 The Kuali Foundation
3    * 
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    * http://www.opensource.org/licenses/ecl2.php
9    * 
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  
17  package org.kuali.ole.gl.businessobject;
18  
19  import java.util.LinkedHashMap;
20  
21  import org.kuali.ole.coa.businessobject.Chart;
22  import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
23  
24  
25  /**
26   * This class represents a sufficient fund rebuild
27   */
28  public class SufficientFundRebuild extends PersistableBusinessObjectBase {
29  
30      public static final String REBUILD_ACCOUNT = "A";
31      public static final String REBUILD_OBJECT = "O";
32  
33      private String chartOfAccountsCode;
34      private String accountFinancialObjectTypeCode;
35      private String accountNumberFinancialObjectCode;
36      private Chart chart;
37  
38      /**
39       * Default constructor.
40       */
41      public SufficientFundRebuild() {
42  
43      }
44  
45      public SufficientFundRebuild(String line) {
46          setFromTextFile(line);
47      }
48  
49      /**
50       * This method sets this object's attributes from a line
51       * 
52       * @param line with object's attributes
53       */
54      public void setFromTextFile(String line) {
55  
56          // Just in case
57          line = line + "                   ";
58  
59          setChartOfAccountsCode(line.substring(0, 2).trim());
60          setAccountFinancialObjectTypeCode(line.substring(2, 3));
61          setAccountNumberFinancialObjectCode(line.substring(3, 10).trim());
62      }
63  
64      /**
65       * This method returns a String representation of this object
66       * @return String representation of this object
67       */
68      public String getLine() {
69          StringBuffer sb = new StringBuffer();
70          sb.append(getField(2, chartOfAccountsCode));
71          sb.append(getField(1, accountFinancialObjectTypeCode));
72          sb.append(getField(7, accountNumberFinancialObjectCode));
73          return sb.toString();
74      }
75  
76      private static String SPACES = "          ";
77  
78      /**
79       * This method returns the value passed in with additional spaces if need be.
80       * 
81       * @param size
82       * @param value
83       * @return
84       */
85      private String getField(int size, String value) {
86          if (value == null) {
87              return SPACES.substring(0, size);
88          }
89          else {
90              if (value.length() < size) {
91                  return value + SPACES.substring(0, size - value.length());
92              }
93              else {
94                  return value;
95              }
96          }
97      }
98  
99      /**
100      * Gets the chartOfAccountsCode attribute.
101      * 
102      * @return Returns the chartOfAccountsCode
103      */
104     public String getChartOfAccountsCode() {
105         return chartOfAccountsCode;
106     }
107 
108     /**
109      * Sets the chartOfAccountsCode attribute.
110      * 
111      * @param chartOfAccountsCode The chartOfAccountsCode to set.
112      */
113     public void setChartOfAccountsCode(String chartOfAccountsCode) {
114         this.chartOfAccountsCode = chartOfAccountsCode;
115     }
116 
117 
118     /**
119      * Gets the accountFinancialObjectTypeCode attribute.
120      * 
121      * @return Returns the accountFinancialObjectTypeCode
122      */
123     public String getAccountFinancialObjectTypeCode() {
124         return accountFinancialObjectTypeCode;
125     }
126 
127     /**
128      * Sets the accountFinancialObjectTypeCode attribute.
129      * 
130      * @param accountFinancialObjectTypeCode The accountFinancialObjectTypeCode to set.
131      */
132     public void setAccountFinancialObjectTypeCode(String accountFinancialObjectTypeCode) {
133         this.accountFinancialObjectTypeCode = accountFinancialObjectTypeCode;
134     }
135 
136 
137     /**
138      * Gets the accountNumberFinancialObjectCode attribute.
139      * 
140      * @return Returns the accountNumberFinancialObjectCode
141      */
142     public String getAccountNumberFinancialObjectCode() {
143         return accountNumberFinancialObjectCode;
144     }
145 
146     /**
147      * Sets the accountNumberFinancialObjectCode attribute.
148      * 
149      * @param accountNumberFinancialObjectCode The accountNumberFinancialObjectCode to set.
150      */
151     public void setAccountNumberFinancialObjectCode(String accountNumberFinancialObjectCode) {
152         this.accountNumberFinancialObjectCode = accountNumberFinancialObjectCode;
153     }
154 
155 
156     /**
157      * Gets the chart attribute.
158      * 
159      * @return Returns the chart
160      */
161     public Chart getChart() {
162         return chart;
163     }
164 
165     /**
166      * Sets the chart attribute.
167      * 
168      * @param chart The chart to set.
169      * @deprecated
170      */
171     public void setChart(Chart chart) {
172         this.chart = chart;
173     }
174 
175     /**
176      * @see org.kuali.rice.krad.bo.BusinessObjectBase#toStringMapper()
177      */
178     protected LinkedHashMap toStringMapper_RICE20_REFACTORME() {
179         LinkedHashMap m = new LinkedHashMap();
180         m.put("chartOfAccountsCode", this.chartOfAccountsCode);
181         m.put("accountFinancialObjectTypeCode", this.accountFinancialObjectTypeCode);
182         m.put("accountNumberFinancialObjectCode", this.accountNumberFinancialObjectCode);
183         return m;
184     }
185 }