1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package com.github.maven_nar;
21
22
23
24
25
26 public class AOL {
27
28 private String architecture;
29
30 private String os;
31
32 private String linkerName;
33
34
35 public AOL(final String aol) {
36 final int linkerIndex = 2;
37 final int osIndex = 1;
38 final int architectureIndex = 0;
39
40 final String[] aolString = aol.split("-", linkerIndex + 1);
41 switch (aolString.length) {
42 case linkerIndex + 1:
43 this.linkerName = aolString[linkerIndex];
44 case osIndex + 1:
45 this.os = aolString[osIndex];
46 case architectureIndex + 1:
47 this.architecture = aolString[architectureIndex];
48 break;
49
50 default:
51 throw new IllegalArgumentException("AOL '" + aol + "' cannot be parsed.");
52 }
53 }
54
55 public AOL(final String architecture, final String os, final String linkerName) {
56 this.architecture = architecture;
57 this.os = os;
58 this.linkerName = linkerName;
59 }
60
61
62
63
64
65
66 public final String getKey() {
67 String tempLinkerName = null;
68 if (this.linkerName == null) {
69 tempLinkerName = "";
70 } else if (this.linkerName.equals("g++")) {
71 tempLinkerName = ".gpp";
72 } else {
73 tempLinkerName = "." + this.linkerName;
74 }
75
76 return this.architecture + (this.os == null ? "" : "." + this.os + tempLinkerName);
77 }
78
79 final String getOS() {
80 return this.os;
81 }
82
83
84 public final boolean hasLinker(final String linker) {
85 return this.linkerName.equals(linker);
86 }
87
88
89
90
91
92
93 @Override
94 public final String toString() {
95 String tempLinkerName = null;
96 if (this.linkerName == null) {
97 tempLinkerName = "";
98 } else if (this.linkerName.equals("g++")) {
99 tempLinkerName = "-gpp";
100 } else {
101 tempLinkerName = "-" + this.linkerName;
102 }
103
104 return this.architecture + (this.os == null ? "" : "-" + this.os + tempLinkerName);
105 }
106 }