|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.ObjectxmlParsing.PlanetLabConfigXmlParser
public class PlanetLabConfigXmlParser
This class parses the PlanetLabConfig.xml for the login stuff.
| Field Summary | |
|---|---|
private org.w3c.dom.Document |
document
Represents the XML-DOM document |
private java.lang.String |
fileName
The path to the configuration file |
private static java.lang.String |
PASSWORD_ATTRIB
The XML attribute name of the ROOT_TAG which contains the PlanetLab password |
private static java.lang.String |
ROLE_ATTRIB
The XML attribute name of the ROOT_TAG which contains the PlanetLab user role |
private static java.lang.String |
ROOT_TAG
The name of the XML root tag which contains all other needed elements. |
private static java.lang.String |
SLICE_NAME_TAG
The XML tag which textContent contains the name of ONE slice |
private static java.lang.String |
SLICE_TAG
The XML tag which contains information about ONE slice |
private static java.lang.String |
SLICES_TAG
The XML tag that contains the slices of the user |
private static java.lang.String |
USERNAME_ATTRIB
The XML attribute name of the ROOT_TAG which contains the PlanetLab username |
| Constructor Summary | |
|---|---|
PlanetLabConfigXmlParser()
Construct a PlanetLabConfigXmlParser with default parameters. |
|
PlanetLabConfigXmlParser(java.lang.String fileName)
Construct a PlanetLabConfigXmlParser with the given file. |
|
| Method Summary | |
|---|---|
private javax.xml.parsers.DocumentBuilder |
createDocumentBuilder()
Creates a new documentBuilder with the needed preferences |
java.lang.String |
getFileName()
get the name of the file to be parsed |
java.lang.String |
getPassword()
Returns the password of the PlanetLab Central API user. |
java.lang.String |
getRole()
Returns the role of the PlanetLab Central API user. |
private java.lang.String |
getRootAttribute(java.lang.String attribName)
Returns the value of the specified attribute name. |
java.lang.String[] |
getSlicenames()
Returns an array containing all the slice names. |
java.lang.String |
getUsername()
Returns the username of the PlanetLab Central API user. |
static void |
main(java.lang.String[] args)
This method is used to test this class. |
org.w3c.dom.Document |
parseFile()
Parse the file into an XML-DOM Document |
org.w3c.dom.Document |
parseFile(java.lang.String fileName)
Parse the file into an XML-DOM Document using the given fileName |
boolean |
saveConfig()
Saves the previously loaded document into the XML file. |
private boolean |
saveConfig(java.lang.String fileName,
org.w3c.dom.Document doc)
Saves XML Document into XML file. |
void |
setFileName(java.lang.String fileName)
set the name of the file to be parsed |
void |
setPassword(java.lang.String password)
Sets the password of the PlanetLab Central API user. |
void |
setRole(java.lang.String role)
Sets the role of the PlanetLab Central API user. |
private boolean |
setRootAttribute(java.lang.String attribName,
java.lang.String value)
Returns the value of the specified attribute name. |
void |
setSlicenames(java.util.Vector<java.lang.String> slicenames)
Sets the slicenames of the PlanetLab Central API user. |
void |
setUsername(java.lang.String username)
Sets the username of the PlanetLab Central API user. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private static final java.lang.String ROOT_TAG
private static final java.lang.String USERNAME_ATTRIB
private static final java.lang.String PASSWORD_ATTRIB
private static final java.lang.String ROLE_ATTRIB
private static final java.lang.String SLICES_TAG
private static final java.lang.String SLICE_TAG
private static final java.lang.String SLICE_NAME_TAG
private org.w3c.dom.Document document
private java.lang.String fileName
| Constructor Detail |
|---|
public PlanetLabConfigXmlParser()
public PlanetLabConfigXmlParser(java.lang.String fileName)
throws org.xml.sax.SAXException,
javax.xml.parsers.ParserConfigurationException,
java.io.IOException
fileName - - the path to the config file
org.xml.sax.SAXException
javax.xml.parsers.ParserConfigurationException
java.io.IOException| Method Detail |
|---|
public org.w3c.dom.Document parseFile()
throws org.xml.sax.SAXException,
javax.xml.parsers.ParserConfigurationException,
java.io.IOException
org.xml.sax.SAXException
javax.xml.parsers.ParserConfigurationException
java.io.IOException
public org.w3c.dom.Document parseFile(java.lang.String fileName)
throws org.xml.sax.SAXException,
javax.xml.parsers.ParserConfigurationException,
java.io.IOException
fileName -
org.xml.sax.SAXException
javax.xml.parsers.ParserConfigurationException
java.io.IOException
private javax.xml.parsers.DocumentBuilder createDocumentBuilder()
throws javax.xml.parsers.ParserConfigurationException
javax.xml.parsers.ParserConfigurationExceptionpublic java.lang.String getFileName()
public void setFileName(java.lang.String fileName)
fileName - the fileName to set
public java.lang.String getUsername()
throws java.lang.Exception
java.lang.Exception - if the username could not be found
public void setUsername(java.lang.String username)
throws java.lang.Exception
username - - the username
java.lang.Exception - if the role could not be found
public java.lang.String getPassword()
throws java.lang.Exception
java.lang.Exception - if the password could not be found
public void setPassword(java.lang.String password)
throws java.lang.Exception
password - - the password value
java.lang.Exception - if the role could not be found
public java.lang.String getRole()
throws java.lang.Exception
java.lang.Exception - if the role could not be found
public void setRole(java.lang.String role)
throws java.lang.Exception
role - - the role name
java.lang.Exception - if the role could not be found
public java.lang.String[] getSlicenames()
throws java.lang.Exception
java.lang.Exception - if something could not be found
public void setSlicenames(java.util.Vector<java.lang.String> slicenames)
throws java.lang.Exception
slicenames - - the slicenames to set.
java.lang.Exception - if the slicenames tags could not be created
private java.lang.String getRootAttribute(java.lang.String attribName)
throws java.lang.Exception
attribName - - the name of the attribute, which value is needed.
java.lang.Exception - if the attribute could not be found
private boolean setRootAttribute(java.lang.String attribName,
java.lang.String value)
throws java.lang.Exception
attribName - - the name of the attribute, which value is needed.
java.lang.Exception - if the attribute could not be found
public boolean saveConfig()
throws java.lang.Exception
java.lang.Exception
private boolean saveConfig(java.lang.String fileName,
org.w3c.dom.Document doc)
throws java.lang.Exception
fileName - XML file namedoc - XML document to save
java.lang.Exceptionpublic static void main(java.lang.String[] args)
args - - [0] .. loadFilePath, [1] .. saveFilePath
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||