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
    • fromPath

      @NotNull public static @NotNull XmlParser fromPath(@NotNull @NotNull Path path)
      Parameters:
      path - the file path
      Returns:
      XmlParser loaded from the specified file path
    • 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)
    • readString

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

      public String readString(String name)
    • readInt

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

      public int readInt(String name)
    • readIntHex

      public int readIntHex(String name)
    • readLong

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

      public long readLong(String name)
    • readFloat

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

      public float readFloat(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)
    • readStringList

      public List<String> readStringList(String name, String splitter)
    • close

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