public class PageTemplateXMLReader extends Object
Modifier and Type | Field and Description |
---|---|
private static Logger |
logger |
private Map<com.yahoo.component.ComponentId,Element> |
pageElementsByPageId
XML elements by page id - available after phase 1.
|
private PageTemplateRegistry |
registry
The registry being constructed
|
Constructor and Description |
---|
PageTemplateXMLReader() |
Modifier and Type | Method and Description |
---|---|
private void |
addIfNonNull(PageElement pageElement,
List<PageElement> pageElements) |
private Map<com.yahoo.component.ComponentId,Element> |
createPages(List<com.yahoo.io.reader.NamedReader> pageReaders,
boolean validateReaderNames) |
private String |
nullIfEmpty(String s) |
PageTemplateRegistry |
read(List<com.yahoo.io.reader.NamedReader> pageReaders,
boolean validateReaderNames)
Reads all page template xml files in a given list of readers.
|
PageTemplateRegistry |
read(String directory)
Reads all page template xml files in a given directory.
|
private AbstractChoice |
readChoice(Element choiceElement) |
PageTemplate |
readFile(String fileName)
Reads a single page template file.
|
private List<PageElement> |
readInclude(Element element)
Reads the direct descendant elements of an include
|
private MapChoice |
readMapChoice(Element choiceElement,
String method) |
private Choice |
readNonMapChoice(Element choiceElement,
String method) |
private int |
readOptionalNumber(Element element,
String attributeName) |
private void |
readPageContent(Element pageElement,
PageTemplate page) |
private PageElement |
readPageElement(Element child)
Returns the page element corresponding to the given node, never null
|
private List<PageElement> |
readPageElements(Element parent)
Returns all page elements found under the given node
|
private void |
readPages() |
private Map<String,String> |
readParameters(Element containingElement) |
private Placeholder |
readPlaceholder(Element placeholderElement) |
private Renderer |
readRenderer(Element rendererElement) |
private Section |
readSection(Element sectionElement,
Section section)
Fills a section with attributes and sub-elements from a "section" or "page" element
|
private Source |
readSource(Element sourceElement) |
private List<Source> |
readSourceAttribute(Element sectionElement) |
private List<String> |
readSpaceSeparatedAttribute(String attributeName,
Element containingElement) |
private List<File> |
sortFiles(File dir) |
private String |
stripXmlEnding(String fileName) |
private void |
validateFileName(String actualName,
com.yahoo.component.ComponentId id,
String artifactName)
Throws an exception if the name is not corresponding to the id
|
private static Logger logger
private PageTemplateRegistry registry
public PageTemplateRegistry read(String directory)
RuntimeException
- if directory
is not a readable directory, or if there is some error in the XMLpublic PageTemplate readFile(String fileName)
RuntimeException
- if fileName
is not a readable file, or if there is some error in the XMLpublic PageTemplateRegistry read(List<com.yahoo.io.reader.NamedReader> pageReaders, boolean validateReaderNames)
validateReaderNames
- should be set to true if the readers were created by files, not otherwiseRuntimeException
- if directory
is not a readable directory, or if there is some error in the XMLprivate Map<com.yahoo.component.ComponentId,Element> createPages(List<com.yahoo.io.reader.NamedReader> pageReaders, boolean validateReaderNames)
private void validateFileName(String actualName, com.yahoo.component.ComponentId id, String artifactName)
private void readPages()
private void readPageContent(Element pageElement, PageTemplate page)
private Section readSection(Element sectionElement, Section section)
private List<PageElement> readPageElements(Element parent)
private void addIfNonNull(PageElement pageElement, List<PageElement> pageElements)
private List<PageElement> readInclude(Element element)
private PageElement readPageElement(Element child)
private Placeholder readPlaceholder(Element placeholderElement)
private AbstractChoice readChoice(Element choiceElement)
Copyright © 2017. All rights reserved.