Skip to content

Commit 66a5c79

Browse files
committed
Minor cleanup
1 parent c2da9a5 commit 66a5c79

2 files changed

Lines changed: 42 additions & 22 deletions

File tree

framework/src/main/java/org/apache/felix/framework/URLHandlersStreamHandlerProxy.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ public class URLHandlersStreamHandlerProxy extends URLStreamHandler
6969
private static final Method SAME_FILE;
7070
private static final Method TO_EXTERNAL_FORM;
7171

72-
static {
72+
static
73+
{
7374
SecureAction action = new SecureAction();
7475

7576
EQUALS = reflect(action, "equals",

framework/src/main/java/org/apache/felix/framework/VersionConverter.java

Lines changed: 40 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19-
2019
package org.apache.felix.framework;
2120

2221
import java.util.regex.Matcher;
@@ -26,15 +25,13 @@
2625

2726
/**
2827
* Converts generic version identifiers to the {@link Version} instances.
29-
*
30-
* @author David Matejcek
3128
*/
32-
public class VersionConverter {
29+
public class VersionConverter
30+
{
3331

3432
private static final Pattern FUZZY_VERSION = Pattern.compile("(\\d+)(\\.(\\d+)(\\.(\\d+))?)?([^a-zA-Z0-9](.*))?",
3533
Pattern.DOTALL);
3634

37-
3835
/**
3936
* Converts generic version id to the {@link Version} instance. Examples:
4037
*
@@ -50,58 +47,80 @@ public class VersionConverter {
5047
* @throws IllegalArgumentException If the numerical components are negative
5148
* or the qualifier string is invalid.
5249
*/
53-
public static Version toOsgiVersion(String value) throws IllegalArgumentException {
50+
public static Version toOsgiVersion(String value) throws IllegalArgumentException
51+
{
5452
return new Version(cleanupVersion(value));
5553
}
5654

57-
private static String cleanupVersion(String version) {
55+
private static String cleanupVersion(String version)
56+
{
5857
StringBuilder result = new StringBuilder();
5958
Matcher m = FUZZY_VERSION.matcher(version);
60-
if (m.matches()) {
59+
if (m.matches())
60+
{
6161
String major = m.group(1);
6262
String minor = m.group(3);
6363
String micro = m.group(5);
6464
String qualifier = m.group(7);
6565

66-
if (major != null) {
66+
if (major != null)
67+
{
6768
result.append(major);
68-
if (minor != null) {
69+
if (minor != null)
70+
{
6971
result.append(".");
7072
result.append(minor);
71-
if (micro != null) {
73+
if (micro != null)
74+
{
7275
result.append(".");
7376
result.append(micro);
74-
if (qualifier != null && !qualifier.isEmpty()) {
77+
if (qualifier != null && !qualifier.isEmpty())
78+
{
7579
result.append(".");
7680
cleanupModifier(result, qualifier);
7781
}
78-
} else if (qualifier != null && !qualifier.isEmpty()) {
82+
}
83+
else if (qualifier != null && !qualifier.isEmpty())
84+
{
7985
result.append(".0.");
8086
cleanupModifier(result, qualifier);
81-
} else {
87+
}
88+
else
89+
{
8290
result.append(".0");
8391
}
84-
} else if (qualifier != null && !qualifier.isEmpty()) {
92+
}
93+
else if (qualifier != null && !qualifier.isEmpty())
94+
{
8595
result.append(".0.0.");
8696
cleanupModifier(result, qualifier);
87-
} else {
97+
}
98+
else
99+
{
88100
result.append(".0.0");
89101
}
90102
}
91-
} else {
103+
}
104+
else
105+
{
92106
result.append("0.0.0.");
93107
cleanupModifier(result, version);
94108
}
95109
return result.toString();
96110
}
97111

98112

99-
private static void cleanupModifier(StringBuilder result, String modifier) {
100-
for (int i = 0; i < modifier.length(); i++) {
113+
private static void cleanupModifier(StringBuilder result, String modifier)
114+
{
115+
for (int i = 0; i < modifier.length(); i++)
116+
{
101117
char c = modifier.charAt(i);
102-
if ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_' || c == '-') {
118+
if ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_' || c == '-')
119+
{
103120
result.append(c);
104-
} else {
121+
}
122+
else
123+
{
105124
result.append('_');
106125
}
107126
}

0 commit comments

Comments
 (0)