Skip to content

Commit

Permalink
'#2351 Propagates path correctly to name date values metadata.
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickdalla committed Oct 28, 2024
1 parent ee770c4 commit 1c2b28d
Showing 1 changed file with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public boolean isKAArray(NSObject obj) {
return ((obj instanceof NSDictionary) && ((NSDictionary) obj).containsKey("$class") && !((NSDictionary) obj).containsKey("NS.keys") && (((NSDictionary) obj).containsKey("NS.objects")));
}

private void parseObject(String name, NSObject object, NSArray objects, Set<NSObject> alreadyVisitedObjects, XHTMLContentHandler xhtml, Metadata metadata, String bplistMetadataSuffix,
private void parseObject(String name, NSObject object, NSArray objects, Set<NSObject> alreadyVisitedObjects, XHTMLContentHandler xhtml, Metadata metadata, String path,
EmbeddedDocumentExtractor extractor,
ParseContext context) throws SAXException {
try {
Expand All @@ -118,7 +118,7 @@ private void parseObject(String name, NSObject object, NSArray objects, Set<NSOb
}

if (isPrimitive(obj)) {
parseNSPrimitiveObject(obj, xhtml, metadata, bplistMetadataSuffix, extractor, context);
parseNSPrimitiveObject(obj, xhtml, metadata, path, extractor, context);
} else {
// checks if object was already written to avoid infinite loops
if (alreadyVisitedObjects.contains(obj)) {
Expand All @@ -140,7 +140,7 @@ private void parseObject(String name, NSObject object, NSArray objects, Set<NSOb
}

if (isNSTime(obj)) {
parseNSTime(((NSDictionary) obj).get("NS.time"), xhtml, metadata, bplistMetadataSuffix, extractor, context);
parseNSTime(((NSDictionary) obj).get("NS.time"), xhtml, metadata, path, extractor, context);
} else if (isKAArray(obj)) {
NSObject[] arrayObjects = getNSObjects(obj, objects);
if (arrayObjects.length > 0) {
Expand All @@ -151,7 +151,7 @@ private void parseObject(String name, NSObject object, NSArray objects, Set<NSOb
xhtml.endElement("summary");
String classname = getNSClassName(obj, objects);
for (NSObject member : arrayObjects) {
parseObject(classname, member, objects, alreadyVisitedObjects, xhtml, metadata, bplistMetadataSuffix, extractor, context);
parseObject(classname, member, objects, alreadyVisitedObjects, xhtml, metadata, path, extractor, context);
}
xhtml.endElement("details");
}
Expand All @@ -162,7 +162,7 @@ private void parseObject(String name, NSObject object, NSArray objects, Set<NSOb
xhtml.characters(name);
xhtml.endElement("summary");
for (NSObject member : ((NSArray) obj).getArray()) {
parseObject(name, member, objects, alreadyVisitedObjects, xhtml, metadata, bplistMetadataSuffix, extractor, context);
parseObject(name, member, objects, alreadyVisitedObjects, xhtml, metadata, path, extractor, context);
}
xhtml.endElement("details");
} else if (isNSDictionary(obj)) {
Expand All @@ -179,15 +179,15 @@ private void parseObject(String name, NSObject object, NSArray objects, Set<NSOb
xhtml.startElement("summary", "class", "is-expandable");
xhtml.characters(d.getKey());
xhtml.endElement("summary");
parseObject(d.getKey(), d.getValue(), objects, alreadyVisitedObjects, xhtml, metadata, bplistMetadataSuffix, extractor,
parseObject(d.getKey(), d.getValue(), objects, alreadyVisitedObjects, xhtml, metadata, path + ":" + className + ":" + d.getKey(), extractor,
context);
xhtml.endElement("details");
}
}
xhtml.endElement("details");
}
} else if (isKADictionary(obj)) {
parseKADictionary(name, uid, obj, objects, alreadyVisitedObjects, xhtml, metadata, bplistMetadataSuffix, extractor, context);
parseKADictionary(name, uid, obj, objects, alreadyVisitedObjects, xhtml, metadata, path, extractor, context);
} else {
xhtml.startElement("details", attr);
xhtml.startElement("summary", "class", "is-expandable");
Expand All @@ -200,7 +200,7 @@ private void parseObject(String name, NSObject object, NSArray objects, Set<NSOb
xhtml.startElement("summary", "class", "is-expandable");
xhtml.characters(e.getKey());
xhtml.endElement("summary");
parseObject(e.getKey(), e.getValue(), objects, alreadyVisitedObjects, xhtml, metadata, bplistMetadataSuffix, extractor, context);
parseObject(e.getKey(), e.getValue(), objects, alreadyVisitedObjects, xhtml, metadata, path + ":" + classname + ":" + e.getKey(), extractor, context);
xhtml.endElement("details");
}
}
Expand All @@ -223,7 +223,7 @@ private void parseNSTime(NSObject nso, XHTMLContentHandler xhtml, Metadata metad
metadata.add(path, dateStr);
}

public void parseKADictionary(String name, UID uid, NSObject obj, NSArray objects, Set<NSObject> alreadyVisitedObjects, XHTMLContentHandler xhtml, Metadata metadata, String bplistMetadataSuffix,
public void parseKADictionary(String name, UID uid, NSObject obj, NSArray objects, Set<NSObject> alreadyVisitedObjects, XHTMLContentHandler xhtml, Metadata metadata, String path,
EmbeddedDocumentExtractor extractor,
ParseContext context) throws SAXException {

Expand All @@ -247,7 +247,7 @@ public void parseKADictionary(String name, UID uid, NSObject obj, NSArray object
NSArray keys = (NSArray) ((NSDictionary) obj).get("NS.keys");
int classIndex = -1;
for (NSObject member : keys.getArray()) {
parseObject(name, member, objects, alreadyVisitedObjects, xhtml, metadata, bplistMetadataSuffix, extractor, context);
parseObject(name, member, objects, alreadyVisitedObjects, xhtml, metadata, path, extractor, context);
}
xhtml.endElement("details");

Expand All @@ -256,8 +256,10 @@ public void parseKADictionary(String name, UID uid, NSObject obj, NSArray object
xhtml.characters("NS.objects");
xhtml.endElement("summary");
NSArray objectsArray = (NSArray) ((NSDictionary) obj).get("NS.objects");
int i=0;
for (NSObject member : objectsArray.getArray()) {
parseObject(name, member, objects, alreadyVisitedObjects, xhtml, metadata, bplistMetadataSuffix, extractor, context);
parseObject(name, member, objects, alreadyVisitedObjects, xhtml, metadata, path + ":" + classname, extractor, context);
i++;
}
xhtml.endElement("details");
xhtml.endElement("details");
Expand Down

0 comments on commit 1c2b28d

Please sign in to comment.