Menu

#17 Parsing packages with comma in version spec. fails

open
Framework (7)
5
2008-01-21
2008-01-11
Paul Neyens
No

When Import/Eport-Pacakges contains an entry like this:

some.package;version="[2.0.0, 3.0.0)", other.package

the method readProperty in BundleClassLoader finds three packages instead of two:

some.package;version="[2.0.0
3.0.0)
other.package

Possible solution:

private static String[] readProperty(final Attributes attrs,
final String property) throws BundleException {
final String values = attrs.getValue(property);
if (values == null) {
return new String[0];
}
if (values.equals("")) {
throw new BundleException("Broken manifest, " + property + " is empty.");
}

if (values.indexOf(",") == -1) {
return new String[] { values };
}
//REPLACED CODE START
return parseProperty(values);
//REPLACED CODE END

}

private static String[] parseProperty(String value) {
char c;
List result = new ArrayList(); //or new Vector()
int index = 0;
int off = 0;
final int len = value.length();
while (index < len) {
c = value.charAt(index++);
switch (c) {
case ',':
result.add(value.substring(off, index - 1));
off = index;
break;
case '"':
index = value.indexOf('"', index) + 1;
if (index == 0) throw new IllegalArgumentException("Unmatched quote in " + value);
}
}
if (off < len) result.add(value.substring(off));
return (String[]) result.toArray(new String[result.size()]);
}

Discussion

  • Jan S. Rellermeyer

    Logged In: YES
    user_id=1368628
    Originator: NO

    Isn't the notation of package versions that you describe an R4 feature? Concierge currently does not support the R4 manifest format.

     
  • Jan S. Rellermeyer

    • assigned_to: nobody --> rjan
     
  • Paul Neyens

    Paul Neyens - 2008-01-22

    Logged In: YES
    user_id=329187
    Originator: YES

    You're right, it's indeed an R4 feature. Apologies.

     
  • Nobody/Anonymous

    Logged In: NO

    There might be the chance that later versions of Concierge will support certain features of R4 to make it more compatible with the newer generation bundles, or that it will even implement R4.x. I am currently in the progress of evaluating certain ideas...

    Cheers,

    Jan.

     

Log in to post a comment.