peer2me.util
Class XMLTool

java.lang.Object
  extended by peer2me.util.XMLTool

public class XMLTool
extends java.lang.Object

This class uses the open source xml pull parser, KXmlParser. It searches through an xml string or file that follows the filesystem.dtd described in the prestudy by Bjørnsgård and Saxlund.

Author:
Kim Saxlund
See Also:
org.kxml2.io.KXmlParser, org.xmlpull.v1

Constructor Summary
XMLTool()
          Creates a new instance of the KXmlParser
 
Method Summary
 ShareObject[] getFolderContents(java.lang.String folder)
          Gets the shareObjects in a folder and returns them in an array.
 java.lang.String getFullPathOfFile(int fileID)
          Gets the full path of a file with the specified fileID
 java.lang.String makeUniqueIDPropertiesField()
          Replaces all occurences of id="X" with a unique X".
 boolean openXMLFile(java.lang.String filename)
          Opens the XML-file for reading.
 void openXMLString(java.lang.String plainText)
          Opens the XML-string for reading.
 java.lang.String removeFullPathAttribute()
          Removes the full path attributes in the xml tags in the xmlString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLTool

public XMLTool()
Creates a new instance of the KXmlParser

Method Detail

getFolderContents

public ShareObject[] getFolderContents(java.lang.String folder)
Gets the shareObjects in a folder and returns them in an array. Uses one of the private methods getRootFolderContents() or getSubFolderContents(String) in order to achieve this.

Parameters:
folder - the folder to get the contents of. The folder path must be absolute.
Returns:
an ShareObject array with the elements found in the folder

getFullPathOfFile

public java.lang.String getFullPathOfFile(int fileID)
Gets the full path of a file with the specified fileID

Parameters:
fileID - The unique fileID to search for
Returns:
the fullpath of the file

makeUniqueIDPropertiesField

public java.lang.String makeUniqueIDPropertiesField()
Replaces all occurences of id="X" with a unique X".

Returns:
the xmlString with unique ids.

removeFullPathAttribute

public java.lang.String removeFullPathAttribute()
Removes the full path attributes in the xml tags in the xmlString

Returns:
the xmlstring without the fullpath attribute

openXMLFile

public boolean openXMLFile(java.lang.String filename)
Opens the XML-file for reading.

Parameters:
filename - the name of the file to open
Returns:
true if the file got opened, else false

openXMLString

public void openXMLString(java.lang.String plainText)
Opens the XML-string for reading.

Parameters:
plainText - the xmlstring to open for parsing