Remote System Explorer DataStore
Release 1.0

org.eclipse.dstore.core.util
Class XMLparser

java.lang.Object
  extended byorg.eclipse.dstore.core.util.XMLparser

public class XMLparser
extends Object

This class is used to deserialize data received from a file or a socket.

When tags indicate that data is being received, the byte stream is deserialized as a DataStore tree. When deserialized data maps to existing DataElements in the DataStore, those elements are updated directly. Any deserialized data that maps to within an existing DataElement, that does not already exist, gets created under the existing DataElement. When parsing DataElement XML, there is no intermediate DOM - rather the DOM is the DataStore itself.

When tags indicate that a byte stream or file is being received, bytes are sent the the current DataStore ByteStreamHandler to be saved on disk.


Nested Class Summary
 class XMLparser.KeepAliveRequestThread
           
 
Field Summary
static int IO_SOCKET_READ_TIMEOUT
           
static long KEEPALIVE_RESPONSE_TIMEOUT
           
static String STR_AMP
           
static String STR_APOS
           
static String STR_BUFFER
           
static String STR_BUFFER_END
           
static String STR_BUFFER_START
           
static String STR_CLASS
           
static String STR_DATAELEMENT
           
static String STR_FILE
           
static String STR_GT
           
static String STR_LT
           
static String STR_QUOTE
           
static String STR_REQUEST_CLASS
           
static String STR_SEMI
           
static String STR_SERIALIZED
           
static String STR_STATUS
           
static String STR_STATUS_ALMOST_DONE
           
static String STR_STATUS_DONE
           
static boolean VERBOSE_KEEPALIVE
           
 
Constructor Summary
XMLparser(DataStore dataStore)
          Constructor
 
Method Summary
static String convertStringFromXML(String input)
          Converts XML special character representations to the appropriate characters
 Throwable getPanicException()
          Returns the communications exception if one occurred
 DataElement parseDocument(BufferedInputStream reader, Socket socket)
          This method gets called to receive data from the pipe.
protected  DataElement parseTag(String fullTag, DataElement parent)
          Deserializes a single DataElement from the XML stream.
 boolean readClass(BufferedInputStream reader, int size, String className, String classbyteStreamHandlerId)
          Read a class file from the pipe
 void readFile(BufferedInputStream reader, int size, String path, String byteStreamHandlerId)
          Read a file from the pipe
 boolean readInstance(BufferedInputStream reader, int size, String classbyteStreamHandlerId)
           
 String readLine(BufferedInputStream reader, Socket socket)
          Reads a line from the pipe
static String replaceSpecial(String input)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

IO_SOCKET_READ_TIMEOUT

public static final int IO_SOCKET_READ_TIMEOUT
See Also:
Constant Field Values

KEEPALIVE_RESPONSE_TIMEOUT

public static final long KEEPALIVE_RESPONSE_TIMEOUT
See Also:
Constant Field Values

VERBOSE_KEEPALIVE

public static final boolean VERBOSE_KEEPALIVE
See Also:
Constant Field Values

STR_DATAELEMENT

public static String STR_DATAELEMENT

STR_BUFFER_START

public static String STR_BUFFER_START

STR_BUFFER_END

public static String STR_BUFFER_END

STR_BUFFER

public static String STR_BUFFER

STR_STATUS

public static String STR_STATUS

STR_STATUS_DONE

public static String STR_STATUS_DONE

STR_STATUS_ALMOST_DONE

public static String STR_STATUS_ALMOST_DONE

STR_FILE

public static String STR_FILE

STR_CLASS

public static String STR_CLASS

STR_REQUEST_CLASS

public static String STR_REQUEST_CLASS

STR_SERIALIZED

public static String STR_SERIALIZED

STR_AMP

public static String STR_AMP

STR_QUOTE

public static String STR_QUOTE

STR_APOS

public static String STR_APOS

STR_LT

public static String STR_LT

STR_GT

public static String STR_GT

STR_SEMI

public static String STR_SEMI
Constructor Detail

XMLparser

public XMLparser(DataStore dataStore)
Constructor

Parameters:
dataStore - the associated DataStore
Method Detail

readFile

public void readFile(BufferedInputStream reader,
                     int size,
                     String path,
                     String byteStreamHandlerId)
Read a file from the pipe

Parameters:
reader - the pipe reader
size - the number of bytes to read
path - the path of the file where the received bytes should be inserted

readInstance

public boolean readInstance(BufferedInputStream reader,
                            int size,
                            String classbyteStreamHandlerId)

readClass

public boolean readClass(BufferedInputStream reader,
                         int size,
                         String className,
                         String classbyteStreamHandlerId)
Read a class file from the pipe

Parameters:
reader - the pipe reader
size - the number of bytes to read
className - the name of the class defined by the byte array.
classbyteStreamHandlerId - the name of the classByteStreamHandler that will receive the bytes of the file.
Returns:
whether the operation is successful

readLine

public String readLine(BufferedInputStream reader,
                       Socket socket)
Reads a line from the pipe

Parameters:
reader - the pipe reader
Returns:
the line received

getPanicException

public Throwable getPanicException()
Returns the communications exception if one occurred

Returns:
a exception

parseDocument

public DataElement parseDocument(BufferedInputStream reader,
                                 Socket socket)
                          throws IOException
This method gets called to receive data from the pipe. It deserializes DataStore XML documents, creating the appropriate DataElements in appropriate places in the DataStore tree. If files are being transmitted it creates the appropriate files using the DataStore ByteStreamHandler.

Parameters:
reader - the pipe reader
Returns:
the root DataElement of the parsed document
Throws:
IOException

parseTag

protected DataElement parseTag(String fullTag,
                               DataElement parent)
Deserializes a single DataElement from the XML stream.

Parameters:
fullTag - the DataElement XML tag
parent - the DataElement that container for the deserialized DataElement
Returns:
the parsed DataElement

replaceSpecial

public static String replaceSpecial(String input)

convertStringFromXML

public static String convertStringFromXML(String input)
Converts XML special character representations to the appropriate characters

Parameters:
input - buffer to convert
Returns:
the converted buffer

Remote System Explorer DataStore
Release 1.0

Guidelines for using DataStore APIs.