Class XmlHelper
- java.lang.Object
-
- com.yahoo.config.model.builder.xml.XmlHelper
-
public final class XmlHelper extends java.lang.Object
Static methods for helping dom building- Author:
- bratseth
-
-
Field Summary
Fields Modifier and Type Field Description static javax.xml.parsers.DocumentBuilderFactory
factory
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static org.w3c.dom.Document
getDocument(java.io.Reader reader)
static javax.xml.parsers.DocumentBuilder
getDocumentBuilder()
Creates a new XML document builder.static com.yahoo.component.ComponentId
getId(org.w3c.dom.Element element)
static com.yahoo.component.ComponentSpecification
getIdRef(org.w3c.dom.Element element)
static java.lang.String
getIdString(org.w3c.dom.Element element)
For searchers inside search chains, the id may be both a reference and an id at once, or just a reference.static java.util.Optional<java.lang.String>
getOptionalAttribute(org.w3c.dom.Element element, java.lang.String name)
static java.util.Optional<org.w3c.dom.Element>
getOptionalChild(org.w3c.dom.Element parent, java.lang.String childName)
static java.util.Optional<java.lang.String>
getOptionalChildValue(org.w3c.dom.Element parent, java.lang.String childName)
static boolean
isReference(org.w3c.dom.Element element)
static java.lang.String
nullIfEmpty(java.lang.String attribute)
static java.util.List<java.lang.String>
spaceSeparatedSymbols(java.lang.String field)
static java.util.Collection<java.lang.String>
spaceSeparatedSymbolsFromAttribute(org.w3c.dom.Element spec, java.lang.String name)
static java.util.List<java.lang.String>
splitAndDiscardEmpty(java.lang.String field, java.lang.String regex)
static java.util.Collection<java.lang.String>
valuesFromElements(org.w3c.dom.Element parent, java.lang.String elementName)
-
-
-
Method Detail
-
nullIfEmpty
public static java.lang.String nullIfEmpty(java.lang.String attribute)
-
getIdString
public static java.lang.String getIdString(org.w3c.dom.Element element)
For searchers inside search chains, the id may be both a reference and an id at once, or just a reference. In other cases, it is clear which one it is from context, so I think the difference is not worth bothering users with, unless they are XML purists in which case they will have the option of writing this correctly. - Jon
-
getId
public static com.yahoo.component.ComponentId getId(org.w3c.dom.Element element)
-
getIdRef
public static com.yahoo.component.ComponentSpecification getIdRef(org.w3c.dom.Element element)
-
getDocument
public static org.w3c.dom.Document getDocument(java.io.Reader reader)
-
splitAndDiscardEmpty
public static java.util.List<java.lang.String> splitAndDiscardEmpty(java.lang.String field, java.lang.String regex)
-
spaceSeparatedSymbols
public static java.util.List<java.lang.String> spaceSeparatedSymbols(java.lang.String field)
-
spaceSeparatedSymbolsFromAttribute
public static java.util.Collection<java.lang.String> spaceSeparatedSymbolsFromAttribute(org.w3c.dom.Element spec, java.lang.String name)
-
valuesFromElements
public static java.util.Collection<java.lang.String> valuesFromElements(org.w3c.dom.Element parent, java.lang.String elementName)
-
isReference
public static boolean isReference(org.w3c.dom.Element element)
-
getDocumentBuilder
public static javax.xml.parsers.DocumentBuilder getDocumentBuilder()
Creates a new XML document builder.- Returns:
- A new DocumentBuilder instance, or null if we fail to get one.
-
getOptionalAttribute
public static java.util.Optional<java.lang.String> getOptionalAttribute(org.w3c.dom.Element element, java.lang.String name)
-
getOptionalChild
public static java.util.Optional<org.w3c.dom.Element> getOptionalChild(org.w3c.dom.Element parent, java.lang.String childName)
-
getOptionalChildValue
public static java.util.Optional<java.lang.String> getOptionalChildValue(org.w3c.dom.Element parent, java.lang.String childName)
-
-