org.jenkinsci.plugins.darcs
Class DarcsSaxHandler

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by org.jenkinsci.plugins.darcs.DarcsSaxHandler
All Implemented Interfaces:
ContentHandler, DTDHandler, EntityResolver, ErrorHandler

 class DarcsSaxHandler
extends DefaultHandler

SAS based change log parser.

Author:
Sven Strittmatter

Nested Class Summary
private static class DarcsSaxHandler.DarcsChangelogTag
          The tags used in the change log XML.
private static class DarcsSaxHandler.DarcsMoveTagAttribute
          Attributes the <move> has.
private static class DarcsSaxHandler.DarcsPatchTagAttribute
          Attributes the <patch> has.
 
Field Summary
private static String ATTR_FALSE
          False attribute value for boolean tag attributes.
private static String ATTR_TRUE
          True attribute value for boolean tag attributes.
private  List<DarcsChangeSet> changeSets
          Change sets collected during the parse process.
private  DarcsChangeSet currentChangeSet
          Current processed change set.
private  DarcsSaxHandler.DarcsChangelogTag currentTag
          The current parsed tag.
private  StringBuilder literalBuffer
          Buffers scanned literals.
private static Logger LOGGER
          Logging facility.
private  boolean ready
          Signals that parsing has ended.
 
Constructor Summary
DarcsSaxHandler()
          Dedicated constructor.
 
Method Summary
 void characters(char[] ch, int start, int length)
           
 void endDocument()
           
 void endElement(String uri, String name, String qName)
           
 void error(SAXParseException saxpe)
           
 void fatalError(SAXParseException saxpe)
           
 List<DarcsChangeSet> getChangeSets()
          Get the list of parsed change sets.
 boolean isReady()
          Returns if the parsing of the XML has ended.
private  boolean isWhiteSpace(char c)
          Determine whether a character is a whitespace character or not.
private  void recognizeTag(String tagName)
          Recognizes the current scanned tag.
private  boolean skipWhiteSpace()
          Return whether to skip white spaces.
 void startElement(String uri, String name, String qName, Attributes atts)
           
(package private) static String stripIgnoreThisFromComment(String comment)
          Strips out strings like "Ignore-this: 606c40ef0d257da9b7a916e7f1c594aa".
 void warning(SAXParseException saxpe)
           
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endPrefixMapping, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOGGER

private static final Logger LOGGER
Logging facility.


ATTR_TRUE

private static final String ATTR_TRUE
True attribute value for boolean tag attributes.

See Also:
Constant Field Values

ATTR_FALSE

private static final String ATTR_FALSE
False attribute value for boolean tag attributes.

See Also:
Constant Field Values

currentTag

private DarcsSaxHandler.DarcsChangelogTag currentTag
The current parsed tag.


currentChangeSet

private DarcsChangeSet currentChangeSet
Current processed change set.


ready

private boolean ready
Signals that parsing has ended.


changeSets

private final List<DarcsChangeSet> changeSets
Change sets collected during the parse process.


literalBuffer

private StringBuilder literalBuffer
Buffers scanned literals.

Constructor Detail

DarcsSaxHandler

public DarcsSaxHandler()
Dedicated constructor.

Method Detail

isReady

public boolean isReady()
Returns if the parsing of the XML has ended.

Returns:
true if end of document reached, else false

getChangeSets

public List<DarcsChangeSet> getChangeSets()
Get the list of parsed change sets.

Returns:
may be an empty list, but never null

endDocument

public void endDocument()
Specified by:
endDocument in interface ContentHandler
Overrides:
endDocument in class DefaultHandler

recognizeTag

private void recognizeTag(String tagName)
Recognizes the current scanned tag. Logs a warning if unrecognizable tag occurred and set currentTag to .

Parameters:
tagName - scanned tag name

startElement

public void startElement(String uri,
                         String name,
                         String qName,
                         Attributes atts)
Specified by:
startElement in interface ContentHandler
Overrides:
startElement in class DefaultHandler

endElement

public void endElement(String uri,
                       String name,
                       String qName)
Specified by:
endElement in interface ContentHandler
Overrides:
endElement in class DefaultHandler

stripIgnoreThisFromComment

static String stripIgnoreThisFromComment(String comment)
Strips out strings like "Ignore-this: 606c40ef0d257da9b7a916e7f1c594aa". It is assumed that after the hash a single line break occurred.

Parameters:
comment - comment message
Returns:
cleaned comment message

isWhiteSpace

private boolean isWhiteSpace(char c)
Determine whether a character is a whitespace character or not.

Parameters:
c - character to check
Returns:
true if passed in char is one of \n, \r, \t, ' '; else false

skipWhiteSpace

private boolean skipWhiteSpace()
Return whether to skip white spaces. White spaces are not skipped if parsing the text of name and comment tags.

Returns:
false if current tag is or ; else false

characters

public void characters(char[] ch,
                       int start,
                       int length)
Specified by:
characters in interface ContentHandler
Overrides:
characters in class DefaultHandler

error

public void error(SAXParseException saxpe)
Specified by:
error in interface ErrorHandler
Overrides:
error in class DefaultHandler

fatalError

public void fatalError(SAXParseException saxpe)
Specified by:
fatalError in interface ErrorHandler
Overrides:
fatalError in class DefaultHandler

warning

public void warning(SAXParseException saxpe)
Specified by:
warning in interface ErrorHandler
Overrides:
warning in class DefaultHandler


Copyright © 2004-2013 weltraumschaf.de. All Rights Reserved.