public class TLcdXMLPeeker extends Object implements ILcdInputStreamFactoryCapable
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.
Constructor and Description |
---|
TLcdXMLPeeker()
Creates a new peeker.
|
TLcdXMLPeeker(ILcdInputStreamFactory aFactory)
Creates a new peeker that uses the given input stream factory.
|
Modifier and Type | Method and Description |
---|---|
static QName |
decodeRootElementName(InputStream aInputStream)
Decodes the name of the root element in the given input stream.
|
QName |
decodeRootElementName(String aSource)
Decodes the name of the root element in the given source.
|
ILcdInputStreamFactory |
getInputStreamFactory()
Returns the input stream factory that is used.
|
void |
setInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory)
Sets the input stream factory to be used.
|
public TLcdXMLPeeker()
public TLcdXMLPeeker(ILcdInputStreamFactory aFactory)
aFactory
- the factory to use when decoding a sourcepublic QName decodeRootElementName(String aSource) throws IOException
aSource
- the source file to peek intoIOException
public static QName decodeRootElementName(InputStream aInputStream) throws IOException
aInputStream
- the stream to peek into. The stream must support marking
.IllegalArgumentException
- if the input stream does not support markingIOException
public void setInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory)
marking
(most buffered input
streams do).setInputStreamFactory
in interface ILcdInputStreamFactoryCapable
aInputStreamFactory
- the input stream factory to be used.public ILcdInputStreamFactory getInputStreamFactory()
ILcdInputStreamFactoryCapable
getInputStreamFactory
in interface ILcdInputStreamFactoryCapable