propertylist/IPropertylist: removed obsolete loadTextDB_sub()
[metux-java.git] / util / Depend.java
blob2778eccea61c5546d77cec03ed4d6c9eebc52278
2 package org.de.metux.util;
4 public class Depend
6 public Version version;
7 public String version_str = "0.0.0.0";
8 public String package_name;
9 public String depend_str;
10 public String[] features;
12 public Depend (String text)
14 String[] myfeatures = new String[30];
15 int num_features = 0;
17 depend_str = text;
19 int x,y;
21 /* this is the position where the name part ends in our string */
22 int name_end = -1;
23 int parse_ptr = 0;
25 /* cut out eventual version information */
26 if ((x=text.indexOf("(>="))!=-1)
28 if (x==0)
29 throw new RuntimeException("parse error: missing name part");
31 y=text.indexOf(')', x+1);
32 if (y==-1)
33 throw new RuntimeException("parse error: missing closing bracket");
35 version_str = text.substring(x+3,y);
36 name_end = x;
37 parse_ptr = y;
40 /* cut out features */
41 while ((x=text.indexOf("[",parse_ptr))!=-1)
43 if ((y=text.indexOf("]",x+1))==-1)
44 throw new RuntimeException("parse error: missing ]");
45 myfeatures[num_features++] = text.substring(x+1,y);
46 parse_ptr = y;
47 if (name_end==-1)
48 name_end = x;
50 if (num_features>0)
52 features = new String[num_features];
53 for (int a=0; a<num_features; a++)
55 features[a] = myfeatures[a];
59 if (name_end==-1)
60 package_name = text;
61 else
62 package_name = text.substring(0,name_end);
64 version = new Version(version_str);