private PageSection findSection(String sectionName, List<PageSection> sections) { for (PageSection section : sections) { if (section.getName().equals(sectionName)) { return section; } } return null; }
private ObjectSpecs findObjectSpecsInSection(PageSection section, String objectName) { if (section.getObjects() != null) { for (ObjectSpecs objectSpecs : section.getObjects()) { if (objectSpecs.getObjectName().equals(objectName)) { return objectSpecs; } } } return null; }
private void processObject(PageSection section, StructNode objectNode) throws IOException { String name = objectNode.getName(); String objectExpression = name.substring(0, name.length() - 1).trim(); List<String> objectNames = findAllMatchingObjectNamesForExpression(objectExpression, objectNode); for (String objectName : objectNames) { if (objectNode.getChildNodes() != null && objectNode.getChildNodes().size() > 0) { ObjectSpecs objectSpecs = findObjectSpecsInSection(section, objectName); if (objectSpecs == null) { objectSpecs = new ObjectSpecs(objectName); section.addObjects(objectSpecs); } for (StructNode specNode : objectNode.getChildNodes()) { if (isRule(specNode.getName())) { processObjectLevelRule(objectSpecs, specNode); } else { processSpec(objectSpecs, specNode); } } } } }
private PageSection findSection(String sectionName) { if (parentSection != null) { return findSection(sectionName, parentSection.getSections()); } else { return findSection(sectionName, pageSpecHandler.getPageSections()); } }
public void process(StructNode sectionNode) throws IOException { if (sectionNode.getChildNodes() != null) { String sectionName = sectionNode.getName().substring(1, sectionNode.getName().length() - 1).trim(); PageSection section = findSection(sectionName); if (section == null) { section = new PageSection(sectionName); if (parentSection != null) { parentSection.addSubSection(section); } else { pageSpecHandler.addSection(section); } } processSection(section, sectionNode.getChildNodes()); } }
private void processSectionRule(PageSection section, StructNode ruleNode) throws IOException { String ruleText = ruleNode.getName().substring(1).trim(); Pair<PageRule, Map<String, String>> rule = findAndProcessRule(ruleText, ruleNode); PageSection ruleSection = new PageSection(ruleText); section.addSubSection(ruleSection); List<StructNode> resultingNodes; try { resultingNodes = rule.getKey().apply(pageSpecHandler, ruleText, NO_OBJECT_NAME, rule.getValue()); } catch (Exception ex) { throw new SyntaxException(ruleNode, "Error processing custom rule", ex); } processSection(ruleSection, resultingNodes); }