@@ -15,18 +15,35 @@ public class Coords {
1515 public String getComment () {
1616 return commentStr ;
1717 }
18-
18+
19+ public String ltrim (String s ) {
20+ int i = 0 ;
21+ while (i < s .length () && Character .isWhitespace (s .charAt (i ))) {
22+ i ++;
23+ }
24+ return s .substring (i );
25+ }
26+
27+ public String rtrim (String s ) {
28+ int i = s .length () - 1 ;
29+ while (i > 0 && Character .isWhitespace (s .charAt (i ))) {
30+ i --;
31+ }
32+ return s .substring (0 , i + 1 );
33+ }
34+
1935 public Coords (String coordsString ) {
2036 String str = coordsString ;
2137 // Comment
2238 {
2339 Integer pos = coordsString .indexOf ("#" );
24-
40+
2541 if (pos > 0 ) {
2642 // add spaces between valuable chars and # to comment
27- commentStr = StringUtils .difference (str .substring (0 , pos ).trim (), str .substring (0 , pos )) + str .substring (pos );
28- str = str .substring (0 , pos ).trim ();
29- this .coordsStringNoComment = str ;
43+ commentStr = StringUtils .difference (str .substring (0 , pos ).trim (), ltrim (str .substring (0 , pos )))
44+ + str .substring (pos );
45+ str = rtrim (str .substring (0 , pos ));
46+ this .coordsStringNoComment = str .trim ();
3047 } else {
3148 commentStr = "" ;
3249 this .coordsStringNoComment = coordsString ;
@@ -93,25 +110,25 @@ public String toString() {
93110
94111 public String toString (String versionStr ) {
95112 String str = versionStr + classifier + extension ;
96- return getName () + (str .isEmpty () ? "" : ":" + str ) + commentStr ;
113+ return getName () + (str .isEmpty () ? "" : ":" + str ) + commentStr ;
97114 }
98-
115+
99116 public String getName () {
100117 return groupId + ":" + artifactId ;
101118 }
102-
119+
103120 public String getGroupId () {
104121 return groupId ;
105122 }
106-
123+
107124 public String getArtifactId () {
108125 return artifactId ;
109126 }
110127
111128 public String getExtension () {
112129 return extension ;
113130 }
114-
131+
115132 public String getClassifier () {
116133 return classifier ;
117134 }
0 commit comments