001: /*
002: * Copyright 2006-2007 The Kuali Foundation.
003: *
004: * Licensed under the Educational Community License, Version 1.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/ecl1.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:
017: package org.kuali.module.gl.bo;
018:
019: import java.util.LinkedHashMap;
020:
021: import org.kuali.core.bo.PersistableBusinessObjectBase;
022: import org.kuali.module.chart.bo.Chart;
023:
024: /**
025: * This class represents a sufficient fund rebuild
026: */
027: public class SufficientFundRebuild extends
028: PersistableBusinessObjectBase {
029:
030: public static final String REBUILD_ACCOUNT = "A";
031: public static final String REBUILD_OBJECT = "O";
032:
033: private String chartOfAccountsCode;
034: private String accountFinancialObjectTypeCode;
035: private String accountNumberFinancialObjectCode;
036: private Chart chart;
037:
038: /**
039: * Default constructor.
040: */
041: public SufficientFundRebuild() {
042:
043: }
044:
045: public SufficientFundRebuild(String line) {
046: setFromTextFile(line);
047: }
048:
049: /**
050: * This method sets this object's attributes from a line
051: *
052: * @param line with object's attributes
053: */
054: public void setFromTextFile(String line) {
055:
056: // Just in case
057: line = line + " ";
058:
059: setChartOfAccountsCode(line.substring(0, 2).trim());
060: setAccountFinancialObjectTypeCode(line.substring(2, 3));
061: setAccountNumberFinancialObjectCode(line.substring(3, 10)
062: .trim());
063: }
064:
065: /**
066: * This method returns a String representation of this object
067: * @return String representation of this object
068: */
069: public String getLine() {
070: StringBuffer sb = new StringBuffer();
071: sb.append(getField(2, chartOfAccountsCode));
072: sb.append(getField(1, accountFinancialObjectTypeCode));
073: sb.append(getField(7, accountNumberFinancialObjectCode));
074: return sb.toString();
075: }
076:
077: private static String SPACES = " ";
078:
079: /**
080: * This method returns the value passed in with additional spaces if need be.
081: *
082: * @param size
083: * @param value
084: * @return
085: */
086: private String getField(int size, String value) {
087: if (value == null) {
088: return SPACES.substring(0, size);
089: } else {
090: if (value.length() < size) {
091: return value
092: + SPACES.substring(0, size - value.length());
093: } else {
094: return value;
095: }
096: }
097: }
098:
099: /**
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: * Gets the accountFinancialObjectTypeCode attribute.
119: *
120: * @return Returns the accountFinancialObjectTypeCode
121: */
122: public String getAccountFinancialObjectTypeCode() {
123: return accountFinancialObjectTypeCode;
124: }
125:
126: /**
127: * Sets the accountFinancialObjectTypeCode attribute.
128: *
129: * @param accountFinancialObjectTypeCode The accountFinancialObjectTypeCode to set.
130: */
131: public void setAccountFinancialObjectTypeCode(
132: String accountFinancialObjectTypeCode) {
133: this .accountFinancialObjectTypeCode = accountFinancialObjectTypeCode;
134: }
135:
136: /**
137: * Gets the accountNumberFinancialObjectCode attribute.
138: *
139: * @return Returns the accountNumberFinancialObjectCode
140: */
141: public String getAccountNumberFinancialObjectCode() {
142: return accountNumberFinancialObjectCode;
143: }
144:
145: /**
146: * Sets the accountNumberFinancialObjectCode attribute.
147: *
148: * @param accountNumberFinancialObjectCode The accountNumberFinancialObjectCode to set.
149: */
150: public void setAccountNumberFinancialObjectCode(
151: String accountNumberFinancialObjectCode) {
152: this .accountNumberFinancialObjectCode = accountNumberFinancialObjectCode;
153: }
154:
155: /**
156: * Gets the chart attribute.
157: *
158: * @return Returns the chart
159: */
160: public Chart getChart() {
161: return chart;
162: }
163:
164: /**
165: * Sets the chart attribute.
166: *
167: * @param chart The chart to set.
168: * @deprecated
169: */
170: public void setChart(Chart chart) {
171: this .chart = chart;
172: }
173:
174: /**
175: * @see org.kuali.core.bo.BusinessObjectBase#toStringMapper()
176: */
177: protected LinkedHashMap toStringMapper() {
178: LinkedHashMap m = new LinkedHashMap();
179: m.put("chartOfAccountsCode", this .chartOfAccountsCode);
180: m.put("accountFinancialObjectTypeCode",
181: this .accountFinancialObjectTypeCode);
182: m.put("accountNumberFinancialObjectCode",
183: this.accountNumberFinancialObjectCode);
184: return m;
185: }
186: }
|