@@ -34,6 +34,14 @@ public class Account {
3434 private String accountName = null ;
3535 private double balance = -1 ;
3636
37+ /**
38+ * Retrieves an Account object based on the provided account number.
39+ *
40+ * @param accountNo The account number as a String
41+ * @return The Account object corresponding to the given account number, or null if the account number is invalid
42+ * @throws SQLException If there is an error accessing the database
43+ * @throws NumberFormatException If the account number cannot be parsed as a long integer
44+ */
3745 public static Account getAccount (String accountNo ) throws SQLException {
3846 if (accountNo == null || accountNo .trim ().length () == 0 )
3947 return null ;
@@ -43,6 +51,13 @@ public static Account getAccount(String accountNo) throws SQLException {
4351 return getAccount (account );
4452 }
4553
54+ /**
55+ * Retrieves an Account object based on the provided account number.
56+ *
57+ * @param account The unique identifier for the account to retrieve
58+ * @return The Account object corresponding to the given account number
59+ * @throws SQLException If there is an error accessing the database
60+ */
4661 public static Account getAccount (long account ) throws SQLException {
4762 return DBUtil .getAccount (account );
4863 }
@@ -53,27 +68,58 @@ public Account(long accountId, String accountName, double balance) {
5368 this .balance = balance ;
5469 }
5570
71+ /**
72+ * Retrieves the account ID associated with this object.
73+ *
74+ * @return The account ID as a long value
75+ */
5676 public long getAccountId () {
5777 return accountId ;
5878 }
5979
60- public void setAccountId (int accountId ) {
80+ /**
81+ * Sets the account ID for this object.
82+ *
83+ * @param accountId The integer value representing the account ID to be set
84+ */ public void setAccountId (int accountId ) {
6185 this .accountId = accountId ;
6286 }
6387
88+ /**
89+ * Retrieves the current balance.
90+ *
91+ * @return The current balance as a double value.
92+ */
6493 public double getBalance () {
6594 return balance ;
6695 }
6796
97+ /**
98+ * Sets the balance of the account.
99+ *
100+ * @param balance The new balance to set for the account
101+ */
68102 public void setBalance (long balance ) {
69103 this .balance = balance ;
70104 }
71105
106+ /**
107+ * Retrieves the account name.
108+ *
109+ * @return The account name as a String.
110+ */
72111 public String getAccountName () {
73112 return accountName ;
74113 }
75114
76- public static Account [] fromBase64List (String b64accounts ){
115+ /**
116+ * Converts a Base64-encoded string of account information into an array of Account objects.
117+ * The input string is expected to contain multiple account entries separated by '|',
118+ * with each account's details (ID, name, and amount) separated by '~'.
119+ *
120+ * @param b64accounts A Base64-encoded string containing account information
121+ * @return An array of Account objects created from the decoded input string
122+ */ public static Account [] fromBase64List (String b64accounts ){
77123 String accounts = new String (Base64 .decodeBase64 (b64accounts ));
78124
79125 StringTokenizer outerTokens = new StringTokenizer (accounts , "|" );
@@ -102,6 +148,17 @@ public static Account[] fromBase64List (String b64accounts){
102148 return (accountList .toArray (new Account [accountList .size ()]));
103149 }
104150
151+ /**
152+ * Converts an array of Account objects to a Base64 encoded string representation.
153+ *
154+ * This method takes an array of Account objects and creates a string representation
155+ * where each account's details (accountId, accountName, and balance) are concatenated
156+ * with '~' as separator between fields and '|' as separator between accounts.
157+ * The resulting string is then Base64 encoded.
158+ *
159+ * @param accounts An array of Account objects to be converted
160+ * @return A Base64 encoded string representing the list of accounts
161+ */
105162 public static String toBase64List (Account [] accounts ){
106163
107164 StringBuffer accountList = new StringBuffer ();
0 commit comments