org.sandev.TaskHeap.util
Class HeapDataConverter

java.lang.Object
  extended by org.sandev.TaskHeap.util.HeapDataConverter
All Implemented Interfaces:
org.xml.sax.ContentHandler

public class HeapDataConverter
extends java.lang.Object
implements org.xml.sax.ContentHandler

Utility class for finding and converting heap data for import.


Field Summary
protected  long baseoffset
          The offset to use when converting old standalone data uniqueIDs.
protected  org.xml.sax.Locator documentLocator
          During a callback method implementation, the locator can be used to report where you are in the XML file.
protected  Plan future
           
protected  HeapAttributes heap
          A reference to the HeapAttributes we are converting.
protected  Plan immediate
           
protected  int itemindex
          The index of the instance we are currently writing.
protected static int LOGDEBUG
           
protected static int LOGERROR
           
protected static int LOGINFO
           
protected static int LOGWARN
           
protected  Plan near
           
protected  java.io.PrintWriter out
          Converted file output writer.
protected  org.sandev.basics.util.UIFormOwner owner
          Back reference to the owner, mainly for logging.
protected  Plan recycling
           
protected  int removalCount
          A record of how many entries are going to be removed as part of the file conversion.
 
Constructor Summary
HeapDataConverter()
           
 
Method Summary
 void characters(char[] ch, int start, int length)
          Receive notification of character data.
protected  java.lang.String convertIDCSV(java.lang.String sourceCSV)
          Add the baseoffset to the IDs in the given serialized CSV value and return the result.
protected  java.lang.String convertStandaloneHeapFile(java.lang.String filespec)
          Convert the specified standalone heap data file and return the converted filespec for import processing.
protected  java.lang.String convertVal(java.lang.String msgclass, java.lang.String name, java.lang.String attr, java.lang.String val)
          Convert the given value as needed and return the result.
protected  void debug(java.lang.String text)
           
 void endDocument()
          Receive notification of the end of a document.
 void endElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName)
          Receive notification of the end of an element
 void endPrefixMapping(java.lang.String prefix)
          Hook for notifying close of prefix mapping.
 org.xml.sax.Locator getDocumentLocator()
          accessor for documentLocator
 java.lang.String getImportFilespec(org.sandev.basics.util.UIFormContext uifc, org.sandev.basics.util.UserWorkLog uwl, org.sandev.basics.util.UIFormOwner owner, Account user, HeapAttributes heap, Plan[] topLevelPlans, java.lang.String impfileName, long baseoffset)
          Get the file to use for importing the current heap data.
 void ignorableWhitespace(char[] ch, int start, int length)
          Receive notification of ignorable whitespace in element content.
protected  boolean ignoreAttr(java.lang.String msgclass, java.lang.String attr, java.lang.String val)
          Return true if the given field is no longer valid and should be removed from the converted output.
 void processingInstruction(java.lang.String target, java.lang.String data)
          Receive notification of a processing instruction.
 void setDocumentLocator(org.xml.sax.Locator loc)
          mutator for documentLocator
 void skippedEntity(java.lang.String name)
          Receive notification of a skipped entity.
 void startDocument()
          Receive notification of the beginning of a document.
 void startElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes atts)
          Receive notification of the beginning of an element
 void startPrefixMapping(java.lang.String prefix, java.lang.String uri)
          Hook for handling prefix URIs for Namespace expansion.
protected  java.lang.String verifyImportFile(java.lang.String filespec)
          If the specified file needs to be converted, then do that and pass back the converted file name for import processing.
protected  void writeAdditionalFields(java.lang.String msgclass, java.lang.String assignedToVal)
          Write out any additional field values needed to read the converted class from file
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOGDEBUG

protected static final int LOGDEBUG
See Also:
Constant Field Values

LOGINFO

protected static final int LOGINFO
See Also:
Constant Field Values

LOGWARN

protected static final int LOGWARN
See Also:
Constant Field Values

LOGERROR

protected static final int LOGERROR
See Also:
Constant Field Values

owner

protected org.sandev.basics.util.UIFormOwner owner
Back reference to the owner, mainly for logging.


out

protected java.io.PrintWriter out
Converted file output writer.


heap

protected HeapAttributes heap
A reference to the HeapAttributes we are converting.


immediate

protected Plan immediate

near

protected Plan near

future

protected Plan future

recycling

protected Plan recycling

baseoffset

protected long baseoffset
The offset to use when converting old standalone data uniqueIDs. This needs to be relatively close to the max value currently in use, but we add the existing uniqueID values to this offset so there's plenty of buffer space.


removalCount

protected int removalCount
A record of how many entries are going to be removed as part of the file conversion.


itemindex

protected int itemindex
The index of the instance we are currently writing.


documentLocator

protected org.xml.sax.Locator documentLocator
During a callback method implementation, the locator can be used to report where you are in the XML file. This may be null, and it is not valid to refer to it outside of the scope of one of the callback methods.

Constructor Detail

HeapDataConverter

public HeapDataConverter()
Method Detail

debug

protected void debug(java.lang.String text)

getImportFilespec

public java.lang.String getImportFilespec(org.sandev.basics.util.UIFormContext uifc,
                                          org.sandev.basics.util.UserWorkLog uwl,
                                          org.sandev.basics.util.UIFormOwner owner,
                                          Account user,
                                          HeapAttributes heap,
                                          Plan[] topLevelPlans,
                                          java.lang.String impfileName,
                                          long baseoffset)
Get the file to use for importing the current heap data.


verifyImportFile

protected java.lang.String verifyImportFile(java.lang.String filespec)
                                     throws java.io.IOException,
                                            org.xml.sax.SAXException
If the specified file needs to be converted, then do that and pass back the converted file name for import processing. Otherwise just pass back the name we got.

Throws:
java.io.IOException
org.xml.sax.SAXException

convertStandaloneHeapFile

protected java.lang.String convertStandaloneHeapFile(java.lang.String filespec)
                                              throws java.io.IOException,
                                                     org.xml.sax.SAXException
Convert the specified standalone heap data file and return the converted filespec for import processing.

Throws:
java.io.IOException
org.xml.sax.SAXException

getDocumentLocator

public org.xml.sax.Locator getDocumentLocator()
accessor for documentLocator


setDocumentLocator

public void setDocumentLocator(org.xml.sax.Locator loc)
mutator for documentLocator

Specified by:
setDocumentLocator in interface org.xml.sax.ContentHandler

startDocument

public void startDocument()
                   throws org.xml.sax.SAXException
Receive notification of the beginning of a document.

Specified by:
startDocument in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException

endDocument

public void endDocument()
Receive notification of the end of a document.

Specified by:
endDocument in interface org.xml.sax.ContentHandler

startPrefixMapping

public void startPrefixMapping(java.lang.String prefix,
                               java.lang.String uri)
                        throws org.xml.sax.SAXException
Hook for handling prefix URIs for Namespace expansion. Does nothing.

Specified by:
startPrefixMapping in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException

endPrefixMapping

public void endPrefixMapping(java.lang.String prefix)
                      throws org.xml.sax.SAXException
Hook for notifying close of prefix mapping. Does nothing.

Specified by:
endPrefixMapping in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException

startElement

public void startElement(java.lang.String namespaceURI,
                         java.lang.String localName,
                         java.lang.String qName,
                         org.xml.sax.Attributes atts)
                  throws org.xml.sax.SAXException
Receive notification of the beginning of an element

Specified by:
startElement in interface org.xml.sax.ContentHandler
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
Receive notification of the end of an element

Specified by:
endElement in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException

characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws org.xml.sax.SAXException
Receive notification of character data.

Specified by:
characters in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException

ignorableWhitespace

public void ignorableWhitespace(char[] ch,
                                int start,
                                int length)
                         throws org.xml.sax.SAXException
Receive notification of ignorable whitespace in element content. Does nothing.

Specified by:
ignorableWhitespace in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException

processingInstruction

public void processingInstruction(java.lang.String target,
                                  java.lang.String data)
                           throws org.xml.sax.SAXException
Receive notification of a processing instruction. Does nothing.

Specified by:
processingInstruction in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException

skippedEntity

public void skippedEntity(java.lang.String name)
                   throws org.xml.sax.SAXException
Receive notification of a skipped entity. Does nothing.

Specified by:
skippedEntity in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException

ignoreAttr

protected boolean ignoreAttr(java.lang.String msgclass,
                             java.lang.String attr,
                             java.lang.String val)
Return true if the given field is no longer valid and should be removed from the converted output.


convertVal

protected java.lang.String convertVal(java.lang.String msgclass,
                                      java.lang.String name,
                                      java.lang.String attr,
                                      java.lang.String val)
Convert the given value as needed and return the result.


writeAdditionalFields

protected void writeAdditionalFields(java.lang.String msgclass,
                                     java.lang.String assignedToVal)
Write out any additional field values needed to read the converted class from file


convertIDCSV

protected java.lang.String convertIDCSV(java.lang.String sourceCSV)
Add the baseoffset to the IDs in the given serialized CSV value and return the result.