Class XMLUtils

java.lang.Object
org.apache.drill.exec.store.xml.XMLUtils

public class XMLUtils extends Object
  • Constructor Details

    • XMLUtils

      public XMLUtils()
  • Method Details

    • isEmptyWhiteSpace

      public static boolean isEmptyWhiteSpace(XMLEvent event)
      Empty events are not helpful so this method checks to see if the event consists solely of whitespace or newline characters. Unfortunately, newlines and other extraneous characters are treated as new elements, so this function wraps a lot of those checks in one function.
      Parameters:
      event - The input XMLEvent
      Returns:
      True if the XMLEvent is only whitespace, false if not.
    • isNotCruft

      public static boolean isNotCruft(XMLEvent event)
      Identifies XML events that may be populated but are not useful for extracting data.
      Parameters:
      event - The XMLEvent in question
      Returns:
      True if the event is useful, false if not
    • addField

      public static String addField(String prefix, String field)
      Generates a nested field name by combining a field prefix to the current field name.
      Parameters:
      prefix - The prefix to be added to the field name.
      field - The field name
      Returns:
      the prefix, followed by an underscore and the fieldname.
    • removeField

      public static String removeField(String prefix, String fieldName)
      Returns the field name from nested field names.
      Parameters:
      fieldName - The nested field name
      Returns:
      The field name
    • hasAttributes

      public static boolean hasAttributes(XMLEvent event)
      Returns true if a given XMLEvent has attributes, false if not. Since only start elements can by definition have attributes, returns false if the event is not a start element.
      Parameters:
      event - The XMLEvent in question
      Returns:
      True if the XMLEvent has attributes, false if not.