wt.util.xml
Class PrepMapFile

java.lang.Object
  extended bywt.util.xml.PrepMapFile

public class PrepMapFile
extends Object


Nested Class Summary
(package private)  class PrepMapFile.DtdEntry
           
 
Field Summary
private  StringBuffer _dtdBuff
           
(package private) static Hashtable _entityMap
           
private  File _file
           
private  String _nl
           
private  StringBuffer _outBuff
           
(package private) static Hashtable _substMap
           
private static String beg
           
private static String end
           
private static String space
           
private static boolean VERBOSE
           
 
Constructor Summary
PrepMapFile(String fname)
           
 
Method Summary
private  void addElement(String name)
           
static String doEncoding(String startString)
           
private  String doSuperTag(String str)
           
private  void doTopLevel(Enumeration keys, StringBuffer buff)
           
 void generateLoadFile(File outputDir, File inDir, String inFile)
           
 void generateLoadFile(File outputDir, File inDir, String inFile, String token)
           
 StringBuffer generateLoadFile(String fname)
          Given a csv load file name, generates an XML version of it.
 StringBuffer generateLoadFile(String fname, String token)
           
 String getDtd()
           
 StringBuffer getDtdBuff()
           
private  boolean isElementNew(String elem)
           
 void makeDtd()
          Generates a DTD corresponding to the constraints in the mapfile.
 StringBuffer processCsvFile(BufferedReader br)
           
 StringBuffer processCsvFile(BufferedReader br, String token)
           
private  String processCsvLine(String str, String token)
           
private  void processEntities(String key)
           
 void processFile()
           
private  void processLine(String str)
           
private  String replaceSpaceByUnderScore(String str)
           
private  String substStr(String inStr, String key, String repl)
           
private  void testDecoding(StringBuffer testBuff, String origStr)
           
 String toString()
           
private  void validateState()
           
 void writeTemplateDB(PrintWriter out)
          Writes out mapping between entities and handlers to a file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_file

private File _file

_outBuff

private StringBuffer _outBuff

_dtdBuff

private StringBuffer _dtdBuff

_nl

private String _nl

beg

private static final String beg
See Also:
Constant Field Values

end

private static final String end
See Also:
Constant Field Values

_entityMap

static Hashtable _entityMap

_substMap

static Hashtable _substMap

VERBOSE

private static boolean VERBOSE

space

private static final String space
See Also:
Constant Field Values
Constructor Detail

PrepMapFile

public PrepMapFile(String fname)
Method Detail

processFile

public void processFile()
                 throws IOException
Throws:
IOException

makeDtd

public void makeDtd()
             throws IOException
Generates a DTD corresponding to the constraints in the mapfile. The generated DTD can be modified to incorporate any attribute constraints which should be enforced for import. We are interested in reproducting the behaviour of the existing csv file so we are going to assign a sequence number to each of the attribute sets which corresponds to its index in the csv file.

Throws:
IOException

getDtdBuff

public StringBuffer getDtdBuff()
                        throws WTException
Throws:
WTException

isElementNew

private boolean isElementNew(String elem)

writeTemplateDB

public void writeTemplateDB(PrintWriter out)
                     throws IOException
Writes out mapping between entities and handlers to a file. Used for prototyping Template processor.

Throws:
IOException

processEntities

private void processEntities(String key)

addElement

private void addElement(String name)

doTopLevel

private void doTopLevel(Enumeration keys,
                        StringBuffer buff)

getDtd

public String getDtd()

toString

public String toString()

processLine

private void processLine(String str)

replaceSpaceByUnderScore

private String replaceSpaceByUnderScore(String str)

doSuperTag

private String doSuperTag(String str)

generateLoadFile

public StringBuffer generateLoadFile(String fname)
                              throws IOException,
                                     FileNotFoundException,
                                     Exception
Given a csv load file name, generates an XML version of it.

Throws:
IOException
FileNotFoundException
Exception

generateLoadFile

public void generateLoadFile(File outputDir,
                             File inDir,
                             String inFile)
                      throws IOException,
                             Exception
Throws:
IOException
Exception

generateLoadFile

public StringBuffer generateLoadFile(String fname,
                                     String token)
                              throws IOException,
                                     FileNotFoundException,
                                     Exception
Throws:
IOException
FileNotFoundException
Exception

generateLoadFile

public void generateLoadFile(File outputDir,
                             File inDir,
                             String inFile,
                             String token)
                      throws IOException,
                             Exception
Throws:
IOException
Exception

processCsvFile

public StringBuffer processCsvFile(BufferedReader br)
                            throws IOException,
                                   Exception
Throws:
IOException
Exception

processCsvFile

public StringBuffer processCsvFile(BufferedReader br,
                                   String token)
                            throws IOException,
                                   Exception
Throws:
IOException
Exception

processCsvLine

private String processCsvLine(String str,
                              String token)
                       throws Exception
Throws:
Exception

doEncoding

public static String doEncoding(String startString)

testDecoding

private void testDecoding(StringBuffer testBuff,
                          String origStr)

substStr

private String substStr(String inStr,
                        String key,
                        String repl)

validateState

private void validateState()
                    throws IOException
Throws:
IOException