Project

General

Profile

« Previous | Next » 

Revision 56504

- Made Serializers methods non static to improve readability and maintenability.
- Code cleanup

View differences:

FundingParser.java
10 10

  
11 11
public class FundingParser {
12 12

  
13
	private String DELIM;
14
	private String ENCLOSING;
13 15

  
14
	public static String getFundingLevel(String funding_level, int level, String DELIM, String ENCLOSING) {
16
	public FundingParser(String DELIM, String ENCLOSING) {
17
		this.DELIM = DELIM;
18
		this.ENCLOSING = ENCLOSING;
19
	}
15 20

  
21
	public String getFundingLevel(String funding_level, int level) {
22

  
16 23
		if (funding_level.isEmpty()) {
17 24
			return ENCLOSING + " " + ENCLOSING + DELIM;
18 25
		}
......
40 47
			} else if (funding_level.equalsIgnoreCase("SP2")) {
41 48
				funding_level = "SP2-Ideas";
42 49
			}
50

  
43 51
			if (funding_level.equalsIgnoreCase("SP3")) {
44 52
				funding_level = "SP3-People";
45 53
			} else if (funding_level.equalsIgnoreCase("SP4")) {
46 54
				funding_level = "SP4-Capacities";
47

  
48 55
			} else if (funding_level.equalsIgnoreCase("SP5")) {
49 56
				funding_level = "SP5-Euratom";
50 57
			}
51 58
		}
52 59

  
53

  
54 60
		funding_level = funding_level.replaceAll(">", "");
55

  
56 61
		funding_level = funding_level.replaceAll("</", "");
57 62
		funding_level = funding_level.replace(DELIM, " ");
58 63
		funding_level = funding_level.replace(ENCLOSING, " ");
......
60 65
		return ENCLOSING + funding_level + ENCLOSING + DELIM;
61 66
	}
62 67

  
63
	public static String getFundingInfo(String buff, String DELIM, String ENCLOSING) {
64
		return getFunder(buff, DELIM, ENCLOSING) +
65
				getFundingLevel(buff, 0, DELIM, ENCLOSING) + (getFundingLevel(buff, 1, DELIM, ENCLOSING) + getFundingLevel(buff, 2, DELIM, ENCLOSING)
66
				+ getFundingLevel(buff, 3, DELIM, ENCLOSING));
68
	public String getFundingInfo(String buff) {
69
		return getFunder(buff) + getFundingLevel(buff, 0) + (getFundingLevel(buff, 1) + getFundingLevel(buff, 2)
70
				+ getFundingLevel(buff, 3));
67 71
	}
68 72

  
69
	public static String getFunder(String buff, String DELIM, String ENCLOSING) {
73
	public String getFunder(String buff) {
70 74

  
71 75
		if (buff.isEmpty()) {
72 76
			return ENCLOSING + " " + ENCLOSING + DELIM;
......
81 85
		split = funder.split("<name>");
82 86

  
83 87
		funder = split[1];
84

  
85 88
		funder = funder.substring(0, funder.indexOf("</name>"));
86

  
87 89
		funder = funder.replaceAll(">", "");
88

  
89 90
		funder = funder.replaceAll("</", "");
90

  
91 91
		funder = funder.replaceAll("\"", "");
92 92
		funder = funder.replaceAll("&amp;", "");
93 93
		funder = funder.replace(ENCLOSING, " ");
94 94

  
95 95
		return ENCLOSING + funder + ENCLOSING + DELIM;
96 96
	}
97

  
98 97
}
99 98

  

Also available in: Unified diff