git://git.nikiroo.be
/
fanfix.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Version 2.0.0 (small API change)
[fanfix.git]
/
src
/
be
/
nikiroo
/
utils
/
serial
/
Importer.java
diff --git
a/src/be/nikiroo/utils/serial/Importer.java
b/src/be/nikiroo/utils/serial/Importer.java
index 61093f754e158642e82a63ec27da598b17a6e929..d21f1dd341c9085af11a08015a05c5fb04fc5c14 100644
(file)
--- a/
src/be/nikiroo/utils/serial/Importer.java
+++ b/
src/be/nikiroo/utils/serial/Importer.java
@@
-65,9
+65,10
@@
public class Importer {
if (line.startsWith("ZIP:")) {
line = StringUtils.unzip64(line.substring("ZIP:".length()));
if (line.startsWith("ZIP:")) {
line = StringUtils.unzip64(line.substring("ZIP:".length()));
+ read(line);
+ } else {
+ processLine(line);
}
}
- processLine(line);
-
}
scan.close();
} catch (IOException e) {
}
scan.close();
} catch (IOException e) {
@@
-118,18
+119,33
@@
public class Importer {
} else if (line.equals("}")) { // STOP: report self to parent
return true;
} else if (line.startsWith("REF ")) { // REF: create/link self
} else if (line.equals("}")) { // STOP: report self to parent
return true;
} else if (line.startsWith("REF ")) { // REF: create/link self
- String ref = line.substring(4).split("@")[1];
+ String[] tab = line.substring("REF ".length()).split("@");
+ String type = tab[0];
+ tab = tab[1].split(":");
+ String ref = tab[0];
+
link = map.containsKey(ref);
if (link) {
me = map.get(ref);
} else {
link = map.containsKey(ref);
if (link) {
me = map.get(ref);
} else {
- me = SerialUtils.createObject(line.substring(4).split("@")[0]);
+ if (line.endsWith(":")) {
+ // construct
+ me = SerialUtils.createObject(type);
+ } else {
+ // direct value
+ int pos = line.indexOf(":");
+ String encodedValue = line.substring(pos + 1);
+ me = SerialUtils.decode(encodedValue);
+ }
map.put(ref, me);
}
map.put(ref, me);
}
- } else { // FIELD: new field
+ } else { // FIELD: new field
*or* direct simple value
if (line.endsWith(":")) {
// field value is compound
currentFieldName = line.substring(0, line.length() - 1);
if (line.endsWith(":")) {
// field value is compound
currentFieldName = line.substring(0, line.length() - 1);
+ } else if (line.startsWith(":") || !line.contains(":")) {
+ // not a field value but a direct value
+ me = SerialUtils.decode(line);
} else {
// field value is direct
int pos = line.indexOf(":");
} else {
// field value is direct
int pos = line.indexOf(":");