Class TLcdXMLPeeker

java.lang.Object
com.luciad.format.xml.util.TLcdXMLPeeker
All Implemented Interfaces:
ILcdInputStreamFactoryCapable

public class TLcdXMLPeeker extends Object implements ILcdInputStreamFactoryCapable
Allows to quickly determine the type of an XML file without consuming the input stream. This can be used, for example, to choose a XML decoder for a data source or to implement a canDecode method. Example usage:

   String namespaceURI = TLcdXMLPeeker.decodeRootElementName(inputStream).getNamespaceURI();
   if (myNamespaceV1.equals(namespaceURI)) {
     return myDecoderV1.decode(inputStream);
   } else if (myNamespaceV2.equals(namespaceURI)) {
     return myDecoderV2.decode(inputStream);
   } else {
     ...
   }
 

The used ILcdInputStreamFactory must create streams that support marking (most buffered input streams do). If not, an exception is thrown.

Since:
2017.1
  • Constructor Details

    • TLcdXMLPeeker

      public TLcdXMLPeeker()
      Creates a new peeker.
    • TLcdXMLPeeker

      public TLcdXMLPeeker(ILcdInputStreamFactory aFactory)
      Creates a new peeker that uses the given input stream factory.
      Parameters:
      aFactory - the factory to use when decoding a source
  • Method Details