hr.fer.tel.nims.dsa.server.serviceprofilehandler
Class ProfileParser

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by hr.fer.tel.nims.dsa.server.serviceprofilehandler.ProfileParser
All Implemented Interfaces:
ProfileInterface, org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler

public class ProfileParser
extends org.xml.sax.helpers.DefaultHandler
implements ProfileInterface

ProfileParser is used to parse and modify client, service or final profiles.

Author:
Mirko Suznjevic

Constructor Summary
ProfileParser()
           
 
Method Summary
 java.lang.String addParameters(java.lang.String source, XmlElement existingTag, java.util.LinkedList insertingTags)
          adds parameters from insertingTags list to the profile in the existingTag element
 void characters(char[] buf, int offset, int len)
          handles the characthers event of the SAX parser
 java.lang.String editParameters(java.lang.String source, XmlElement existingTag, XmlElement newTag)
          edits parameters of existing tag and sets them to match new tag element
 void endDocument()
          handles the end document event of the SAX parser
 void endElement(java.lang.String namespaceURI, java.lang.String sName, java.lang.String qName)
          handles the end element event of the SAX parser
 java.lang.String getParameter(java.lang.String source, XmlElement existingTag)
          returns requested existing tag (if it exists in the source)
 java.lang.String getParameterValue(java.lang.String source, XmlElement existingTag)
          returns requested existing tags value
 void startDocument()
          handles the start document event of the SAX parser
 void startElement(java.lang.String namespaceURI, java.lang.String lName, java.lang.String qName, org.xml.sax.Attributes attrs)
          handles the start element event of the SAX parser
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProfileParser

public ProfileParser()
Method Detail

startDocument

public void startDocument()
                   throws org.xml.sax.SAXException
handles the start document event of the SAX parser

Specified by:
startDocument in interface org.xml.sax.ContentHandler
Overrides:
startDocument in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception

endDocument

public void endDocument()
                 throws org.xml.sax.SAXException
handles the end document event of the SAX parser

Specified by:
endDocument in interface org.xml.sax.ContentHandler
Overrides:
endDocument in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception

startElement

public void startElement(java.lang.String namespaceURI,
                         java.lang.String lName,
                         java.lang.String qName,
                         org.xml.sax.Attributes attrs)
                  throws org.xml.sax.SAXException
handles the start element event of the SAX parser

Specified by:
startElement in interface org.xml.sax.ContentHandler
Overrides:
startElement in class org.xml.sax.helpers.DefaultHandler
Parameters:
namespaceURI - namespace URI
attrs - Default attributes or specified atributes
lName - The local name or the empty string if Namespace processing is not being performed
qName - The qualified name or the empty string if qualified names are not available
Throws:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception

endElement

public void endElement(java.lang.String namespaceURI,
                       java.lang.String sName,
                       java.lang.String qName)
                throws org.xml.sax.SAXException
handles the end element event of the SAX parser

Specified by:
endElement in interface org.xml.sax.ContentHandler
Overrides:
endElement in class org.xml.sax.helpers.DefaultHandler
Parameters:
namespaceURI - namespace URI
sName - the local name or the empty string if Namespace processing is not being performed
qName - the qualified XML 1.0 name or the empty string if qualified names are not available
Throws:
org.xml.sax.SAXException - any SAX exception, possibly wrapping another exception

characters

public void characters(char[] buf,
                       int offset,
                       int len)
                throws org.xml.sax.SAXException
handles the characthers event of the SAX parser

Specified by:
characters in interface org.xml.sax.ContentHandler
Overrides:
characters in class org.xml.sax.helpers.DefaultHandler
Parameters:
buf - character array
offset - the start position in the character array
len - length of the character array to be used
Throws:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception

addParameters

public java.lang.String addParameters(java.lang.String source,
                                      XmlElement existingTag,
                                      java.util.LinkedList insertingTags)
adds parameters from insertingTags list to the profile in the existingTag element

Specified by:
addParameters in interface ProfileInterface
Parameters:
source - profile in String format
existingTag - xml tag that we are looking for
insertingTags - list of tags which are inserted
Returns:
source with inserted parameters

editParameters

public java.lang.String editParameters(java.lang.String source,
                                       XmlElement existingTag,
                                       XmlElement newTag)
edits parameters of existing tag and sets them to match new tag element

Specified by:
editParameters in interface ProfileInterface
Parameters:
source - profile in String format
existingTag - xml tag that we are looking for
newTag - xml tag that replaces the existing tag
Returns:
source with edited parameters

getParameter

public java.lang.String getParameter(java.lang.String source,
                                     XmlElement existingTag)
returns requested existing tag (if it exists in the source)

Specified by:
getParameter in interface ProfileInterface
Parameters:
source - profile in String format
xml - tag that we are looking for
Returns:
existing tag and his value if it doesnt exist in the source returns empty String

getParameterValue

public java.lang.String getParameterValue(java.lang.String source,
                                          XmlElement existingTag)
returns requested existing tags value

Specified by:
getParameterValue in interface ProfileInterface
Parameters:
profile - in String format
existingTag - xml tag that we are looking for
Returns:
existing tags value if that tag doesnt exist in the source returns empty String