为文本文件构建API

时间:2014-07-16 17:28:00

标签: java text-files java-api

我是初级软件开发人员,负责构建API。这是我第一次做这样的高级任务。

我的api将管理包含付款的文本文件。我的问题是我不知道从哪里开始或做什么。

我的任务是构建一个API来处理文本文件。我的软件将加载文件并对其进行处理。我的解决方案包括文件格式的处理程序。处理程序应该调用附加的Java接口Payment Receiver中的方法

我的界面,方法签名

import java.math.BigDecimal;
import java.util.Date;

public interface PaymentReceiver {
/**
 * Called to mark the start of a new payment bundle.
 * @param accountNumber The account number where funds are deposited.
 * @param paymentDate The date at which the funds were/will be deposited on the specified account.
 * @param currency The currency of the payments in the bundle.
 */
public void startPaymentBundle(String accountNumber, Date paymentDate, String currency);

/**
 * Called to notify the receiver of a single payment within a bundle.
 * @param amount The payment amount.
 * @param reference The payment reference.
 */
public void payment(BigDecimal amount, String reference);

/**
 * Called to mark the end of a payment bundle. This means that there will be no more calls      to payment() 
 * for this bundle, and that the receiver can process the bundle.
 */
public void endPaymentBundle();
}

1 个答案:

答案 0 :(得分:1)

您显示的界面是一个侦听器类型的界面。您的处理程序需要做的是:

  • 配置数据源(文件)和接收器实例
  • 解析给定的数据源
  • 在解析数据源时,在读取数据时将数据传递给给定的接收器实例