Switch to unified view

a/tool/src/spdxlib/Person.java b/tool/src/spdxlib/Person.java
...
...
15
15
16
16
17
public class Person {
17
public class Person {
18
18
19
    private String
19
    private String
20
            person, // mandatory field
20
            person = "", // mandatory field
21
            personEmail, // optional field
21
            personEmail = "", // optional field
22
            organization, // mandatory field
22
            organization = "", // mandatory field
23
            organizationEmail, // optional field
23
            organizationEmail = "", // optional field
24
            tool, // mandatory field
24
            tool = "", // mandatory field
25
            toolVersion // mandatory field
25
            toolVersion = "" // mandatory field
26
            ;
26
            ;
27
    
27
    
28
    
28
    public TagValue
29
    private TagValue
30
            tagOrganization,
29
            tagPerson,
31
            tagPerson,
30
            tagOrganization,
31
            tagTool;
32
            tagTool;
32
    
33
    
33
    
34
    /**
34
    /**
35
     * Provides a distinctive identifier title
35
     * Provides a distinctive identifier title
36
     * @return 
36
     * @return 
37
     */
37
     */
...
...
49
            return tagTool.toString();
49
            return tagTool.toString();
50
        }
50
        }
51
        // nothing good here, just return null..
51
        // nothing good here, just return null..
52
        return null;
52
        return null;
53
    }
53
    }
54
55
    public TagValue getTagPerson() {
56
        return tagPerson;
57
    }
58
59
    public void setTagPerson(TagValue tagPerson) {
60
        // do the basic handling
61
        person = tagPerson.toString();
62
        this.tagPerson = tagPerson;
63
        // now do the more refined processing, try to extract values
64
        String temp = tagPerson.toString();
65
        // do we have an email address like: "(nuno.brito@triplecheck.de)"?
66
         if(temp.contains(" (")&&temp.contains(")")){
67
            int start = temp.indexOf("(");
68
            int end = temp.lastIndexOf(")");
69
            //  something is wrong, just leave
70
            if(start +1 > end){
71
                return;
72
            }
73
            // get the email address
74
            String thisMail = temp.substring(start +1, end);
75
            this.personEmail = thisMail;
76
            this.person = temp.substring(0, start -1);
77
        }
78
    }
79
80
    public TagValue getTagOrganization() {
81
        return tagOrganization;
82
    }
83
84
    public void setTagOrganization(TagValue tagOrganization) {
85
        // do the basic handling
86
        organization = tagOrganization.toString();
87
        this.tagOrganization = tagOrganization;
88
        // now do the more refined processing, try to extract values
89
        String temp = tagOrganization.toString();
90
        // do we have an email address like: "(nuno.brito@triplecheck.de)"?
91
         if(temp.contains(" (")&&temp.contains(")")){
92
            int start = temp.indexOf("(");
93
            int end = temp.lastIndexOf(")");
94
            //  something is wrong, just leave
95
            if(start +1 > end){
96
                return;
97
            }
98
            // get the email address
99
            String thisMail = temp.substring(start +1, end);
100
            this.organizationEmail = thisMail;
101
            this.organization = temp.substring(0, start -1);
102
        }
103
    }
104
105
    public TagValue getTagTool() {
106
        return tagTool;
107
    }
108
109
    public void setTagTool(TagValue tagTool) {
110
        // basic handling
111
        this.tagTool = tagTool;
112
        tool = tagTool.toString();
113
        // more refined search for the version number
114
        int pos = tool.indexOf("-");
115
        if(pos < 1){
116
            return;
117
        }
118
        // hopefully we get a nicely formatted string
119
       toolVersion = tool.substring(pos+1);
120
       tool = tool.substring(0, pos);
121
    }
54
    
122
    
55
    
123
    
56
    
124
    
57
    @Override
125
    @Override
58
    public String toString(){
126
    public String toString(){
59
        return getTitle();
127
        return getTitle();
60
    }
128
    }
129
130
    public String getPerson() {
131
        return person;
132
    }
133
134
    public String getPersonEmail() {
135
        return personEmail;
136
    }
137
138
    public String getOrganization() {
139
        return organization;
140
    }
141
142
    public String getOrganizationEmail() {
143
        return organizationEmail;
144
    }
145
146
    public String getTool() {
147
        return tool;
148
    }
149
150
    public String getToolVersion() {
151
        return toolVersion;
152
    }
153
154
    /**
155
     * Calculates what is the best place to add a new tag related to a Person
156
     * @return the line number inside the SPDX document that should be used
157
     */
158
    public int getAnchor() {
159
         // if there is a name, use it
160
        if(tagPerson != null){
161
            return tagPerson.linePosition;
162
        }
163
        // or use the organization name if available
164
        if(tagOrganization != null){
165
            return tagOrganization.linePosition;
166
        }
167
        // or even use the tool name if available
168
        if(tagTool != null){
169
            return tagTool.linePosition;
170
        }
171
        // nothing good here, just return 0 but this is not a goot thing..
172
        return 0;
173
    }
174
    
175
    
61
    
176
    
62
}
177
}