Class XmlParser

java.lang.Object
host.anzo.commons.xml.XmlParser
All Implemented Interfaces:
AutoCloseable

public class XmlParser extends Object implements AutoCloseable
  • Method Details

    • fromFile

      @NotNull public static @NotNull XmlParser fromFile(@NotNull @NotNull String fileName)
      Parameters:
      fileName - file name
      Returns:
      XmlParser loaded from specified file
    • fromZip

      @NotNull public static @NotNull List<XmlParser> fromZip(String @NotNull ... fileNames)
      Parameters:
      fileNames - zip file names
      Returns:
      list of XmlParsers loaded from specified zip files
    • fromResource

      @NotNull public static @NotNull XmlParser fromResource(String fileName, @NotNull @NotNull ClassLoader classLoader) throws IOException
      Parameters:
      fileName - resource file name
      classLoader - class loader
      Returns:
      XmlParser loaded from specified resource
      Throws:
      IOException - when resource can't be read
    • fromInputStream

      @NotNull public static @NotNull XmlParser fromInputStream(Path filePath, InputStream inputStream) throws IOException
      Parameters:
      filePath - file path
      inputStream - input stream to read
      Returns:
      XmlParser loaded from specified input stream
      Throws:
      IOException - when input stream can't be read
    • getFileName

      public String getFileName()
    • getDirectoryName

      public String getDirectoryName()
    • name

      public String name()
    • content

      public String content()
    • child

      public XmlParser child(String name)
    • optChild

      public XmlParser optChild(String name)
    • children

      public List<XmlParser> children()
    • children

      public List<XmlParser> children(@NotNull @NotNull String name)
    • attributeNames

      public Set<String> attributeNames()
    • hasAttribute

      public boolean hasAttribute(@NotNull @NotNull String attributeName)
    • readS

      public String readS(@NotNull @NotNull String name, String defaultValue)
    • readS

      public String readS(String name)
    • readD

      public int readD(String name, int defaultValue)
    • readD

      public int readD(String name)
    • readDx

      public int readDx(String name)
    • readQ

      public long readQ(String name, long defaultValue)
    • readQ

      public long readQ(String name)
    • readF

      public float readF(String name, float defaultValue)
    • readF

      public float readF(String name)
    • readBoolean

      public boolean readBoolean(String name, boolean defaultValue)
    • readBoolean

      public boolean readBoolean(String name)
    • readEnum

      public final <T extends Enum<T>> T readEnum(String name, Class<T> enumClass, T defaultValue)
    • close

      public void close() throws Exception
      Specified by:
      close in interface AutoCloseable
      Throws:
      Exception