1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.xnap.pkg;
21
22 import java.io.BufferedReader;
23 import java.io.IOException;
24 import java.util.Properties;
25
26 /***
27 *
28 */
29 public class PackageInfoReader
30 {
31
32
33
34
35
36
37
38
39
40 public static Properties readNext(BufferedReader in) throws IOException
41 {
42 Properties p = new Properties();
43 String key = null;
44 String value = null;
45
46 String s;
47 while ((s = in.readLine()) != null) {
48 if (s.startsWith("#")) {
49 continue;
50 }
51 else if (s.length() == 0 || s.startsWith(" ")) {
52 s = s.trim();
53 if (s.length() == 0) {
54 if (p.size() > 0) {
55
56 break;
57 }
58 }
59 else if (s.equals(".")) {
60 value += "\n";
61 }
62 else {
63 value += " " + s;
64 }
65 }
66 else {
67 if (key != null && value != null) {
68
69 p.setProperty(key, value);
70 }
71
72
73 key = value = null;
74 int i = s.indexOf(':');
75 if (i > 0) {
76 key = s.substring(0, i);
77 value = s.substring(i + 1).trim();
78 }
79 else {
80
81 }
82 }
83 }
84
85 if (key != null && value != null) {
86
87 p.setProperty(key, value);
88 }
89
90 return (p.size() > 0) ? p : null;
91 }
92
93 }
94