BrightSide Workbench Full Report + Source Code
org.turro.financials.model.AccountFormat Class Reference

Static Public Member Functions

static String simplify (String a)
 
static String expand (String a)
 
static boolean isAccount (String a)
 
static boolean isPartialAccount (String a)
 
static String trim (String a)
 

Static Public Attributes

static final int ACCOUNT_LENGTH = 10
 

Detailed Description

Author
Lluis TurrĂ³ Cutiller lluis.nosp@m.@tur.nosp@m.ro.or.nosp@m.g

Definition at line 24 of file AccountFormat.java.

Member Function Documentation

◆ expand()

static String org.turro.financials.model.AccountFormat.expand ( String  a)
static

Definition at line 42 of file AccountFormat.java.

42  {
43  if((a == null) || (a.length() == 0))
44  return a;
45  StringBuilder text = new StringBuilder(a.trim());
46  int i;
47  if((i = text.lastIndexOf(".")) > -1) {
48  text.deleteCharAt(i);
49  while(text.length() < ACCOUNT_LENGTH)
50  text.insert(i, '0');
51  }
52  while(text.length() < ACCOUNT_LENGTH)
53  text.append('0');
54  while(text.length() > ACCOUNT_LENGTH) {
55  i = text.lastIndexOf("0");
56  if(i > -1)
57  text.deleteCharAt(i);
58  else
59  break;
60  }
61  return text.toString();
62  }
Here is the caller graph for this function:

◆ isAccount()

static boolean org.turro.financials.model.AccountFormat.isAccount ( String  a)
static

Definition at line 64 of file AccountFormat.java.

64  {
65  if(a == null) return false;
66  a = expand(a);
67  if(a.length() != ACCOUNT_LENGTH) return false;
68  for(int i = 0; i < ACCOUNT_LENGTH; i++)
69  if((a.charAt(i) < '0') || (a.charAt(i) > '9'))
70  return false;
71  return true;
72  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isPartialAccount()

static boolean org.turro.financials.model.AccountFormat.isPartialAccount ( String  a)
static

Definition at line 74 of file AccountFormat.java.

74  {
75  if(a == null) return false;
76  if(a.length() >= 10) return false;
77  for(int i = 0; i < a.length(); i++)
78  if(((a.charAt(i) < '0') || (a.charAt(i) > '9')) && !(a.charAt(i) == '.'))
79  return false;
80  return true;
81  }
Here is the caller graph for this function:

◆ simplify()

static String org.turro.financials.model.AccountFormat.simplify ( String  a)
static

Definition at line 28 of file AccountFormat.java.

28  {
29  if(!isPartialAccount(a)) return a;
30  StringBuilder text = new StringBuilder(a);
31  int i = 4;
32  while(i < text.length() && text.charAt(i) == '0')
33  i++;
34  i--;
35  while(i > -1 && i < text.length() && text.charAt(i) == '0')
36  text.deleteCharAt(i--);
37  if(i < text.length())
38  text.insert(i + 1, '.');
39  return text.toString();
40  }
static boolean isPartialAccount(String a)
Here is the call graph for this function:

◆ trim()

static String org.turro.financials.model.AccountFormat.trim ( String  a)
static

Definition at line 83 of file AccountFormat.java.

83  {
84  StringBuilder text = new StringBuilder(a);
85  while((text.length() > 0) && (text.charAt(text.length() - 1) == '0'))
86  text.deleteCharAt(text.length() - 1);
87  return text.toString();
88  }

Member Data Documentation

◆ ACCOUNT_LENGTH

final int org.turro.financials.model.AccountFormat.ACCOUNT_LENGTH = 10
static

Definition at line 26 of file AccountFormat.java.


The documentation for this class was generated from the following file: