sabdakosh
Class Xdochandler

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by sabdakosh.Xdochandler
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler

public class Xdochandler
extends org.xml.sax.helpers.DefaultHandler

The Class Xdochandler is the class that represent the logic of the application. The actual parsing of the xml file is performed in this class.


Field Summary
private  java.lang.String bool
          The bool is the string variable that checks if the word entered by the user is present in the xml file.
private  java.io.CharArrayWriter contents
          The contents is the object for CharArrayWriter class.
 java.lang.String eg1
          eg1 variable represents the value of first example for a given word present in xml file.
 java.lang.String eg2
          eg2 variable represents the value of second example for a given word present in xml file.
 java.lang.String eg3
          eg3 variable represents the value of third example for a given word present in xml file.
private  java.lang.String input
          The input variable represents the value provided by the user.
 java.lang.String mean1
          mean1 variable represents the first english meaning of a given word present in xml file.
 java.lang.String mean2
          mean2 variable represents the second english meaning of a given word present in xml file.
 java.lang.String mean3
          mean3 variable represents the third english meaning of a given word present in xml file.
 java.lang.String nepali_meaning
          The nepali_meaning is the variable that represents the value of nepali meaning in nepali language.
 java.lang.String total_meaning
          The total_meaning is the variable that represents the value of english meaining and it's associated forms and examples.
private  java.lang.String xinput
          The xinput is the variable that represents the element value returned by the parser.
 
Constructor Summary
Xdochandler(java.lang.String input)
          Instantiates a new xdochandler.
 
Method Summary
 void characters(char[] ch, int start, int length)
          The characters is a callback method used by the SAX parser to return the characters found in the xml file.
 void endElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName)
          endElement is also a callback method used by SAX parser that returns the ending element present in xml file.
 void startElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes attr)
          startElement is the callback method used by SAX parser that returns all the starting elements present in xml file.
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

input

private java.lang.String input
The input variable represents the value provided by the user. It is the value passed from Dictionary class.


xinput

private java.lang.String xinput
The xinput is the variable that represents the element value returned by the parser. It is the localname of the element in the xml file.


mean1

public java.lang.String mean1
mean1 variable represents the first english meaning of a given word present in xml file.


eg1

public java.lang.String eg1
eg1 variable represents the value of first example for a given word present in xml file.


mean2

public java.lang.String mean2
mean2 variable represents the second english meaning of a given word present in xml file.


eg2

public java.lang.String eg2
eg2 variable represents the value of second example for a given word present in xml file.


mean3

public java.lang.String mean3
mean3 variable represents the third english meaning of a given word present in xml file.


eg3

public java.lang.String eg3
eg3 variable represents the value of third example for a given word present in xml file.


nepali_meaning

public java.lang.String nepali_meaning
The nepali_meaning is the variable that represents the value of nepali meaning in nepali language.


total_meaning

public java.lang.String total_meaning
The total_meaning is the variable that represents the value of english meaining and it's associated forms and examples.


bool

private java.lang.String bool
The bool is the string variable that checks if the word entered by the user is present in the xml file. If the word exists in the xml file then true is returned else false is returned.


contents

private java.io.CharArrayWriter contents
The contents is the object for CharArrayWriter class. It stores the values of english meaning, examples, nepali meaning returned after parsing the xml file. This stored value is then passed to the front end.

Constructor Detail

Xdochandler

public Xdochandler(java.lang.String input)
Instantiates a new xdochandler.

Parameters:
input - the input variable represents the value provided by the user. It is the value passed from Dictionary class.
Method Detail

startElement

public void startElement(java.lang.String namespaceURI,
                         java.lang.String localName,
                         java.lang.String qName,
                         org.xml.sax.Attributes attr)
                  throws org.xml.sax.SAXException
startElement is the callback method used by SAX parser that returns all the starting elements present in xml file. It returns both the local name, qualified name of the starting element and it's attributes. However, for our application we use local name only and the attributes reprsent the nepali meaning for the given english word. This method retrieves the value of this attribute.

Specified by:
startElement in interface org.xml.sax.ContentHandler
Overrides:
startElement in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException

endElement

public void endElement(java.lang.String namespaceURI,
                       java.lang.String localName,
                       java.lang.String qName)
                throws org.xml.sax.SAXException
endElement is also a callback method used by SAX parser that returns the ending element present in xml file. Here also we use local name only which is returned by the parser. If the given word maps with the ending element then this method retrieves the value of associated english meanings and it's corresponding examples.

Specified by:
endElement in interface org.xml.sax.ContentHandler
Overrides:
endElement in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException

characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws org.xml.sax.SAXException
The characters is a callback method used by the SAX parser to return the characters found in the xml file. These characters are stored in the buffer. The characters represents the values of english meaning and it's corresponding examples i.e., the text betweent the starting and ending elements in the xml file.

Specified by:
characters in interface org.xml.sax.ContentHandler
Overrides:
characters in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException