XmlMetaのパース処理を修正

This commit is contained in:
r-ca 2024-01-21 18:44:26 +09:00
parent c1151b778c
commit 8c71dedd85
No known key found for this signature in database
GPG Key ID: 6A72911AC73464A9

View File

@ -17,6 +17,8 @@ import one.nem.lacerta.utils.LacertaLogger;
public class XmlMetaParserImpl implements XmlMetaParser{ public class XmlMetaParserImpl implements XmlMetaParser{
String TAG = getClass().getSimpleName();
@Inject @Inject
LacertaLogger logger; LacertaLogger logger;
@ -35,13 +37,18 @@ public class XmlMetaParserImpl implements XmlMetaParser{
meta.setRevisionId(rootElement.getElementsByTagName("revisionId").item(0).getTextContent()); meta.setRevisionId(rootElement.getElementsByTagName("revisionId").item(0).getTextContent());
ArrayList<XmlMetaPageModel> pages = new ArrayList<>(); ArrayList<XmlMetaPageModel> pages = new ArrayList<>();
for(int i = 0; i < rootElement.getElementsByTagName("pages").getLength(); i++) { for (int i = 0; i < rootElement.getElementsByTagName("page").getLength(); i++) {
Element pageElement = (Element) rootElement.getElementsByTagName("page").item(i); Element pageElement = (Element) rootElement.getElementsByTagName("page").item(i);
XmlMetaPageModel page = new XmlMetaPageModel(); XmlMetaPageModel page = new XmlMetaPageModel();
page.setFilename(pageElement.getElementsByTagName("filename").item(0).getTextContent()); page.setFilename(pageElement.getElementsByTagName("filename").item(0).getTextContent());
pages.add(page); pages.add(page);
} }
logger.debug(TAG, "Parsed Meta: " + meta.getRevisionId() + " " + pages.size() + " pages.");
for (XmlMetaPageModel page : pages) {
logger.debug(TAG, "\tPage: " + page.getFilename());
}
meta.setPages(pages); meta.setPages(pages);
return meta; return meta;