|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.legstar.cob2xsd.Cob2Xsd
public class Cob2Xsd
Implements the COBOL Structure to XML Schema translator. This is the API made available to invoke the COBOL to XML Schema translator from your own java code.
There are 6 steps involved:Cob2XsdModel
instance that is received at
construction time.
To invoke the translator, you normally call one of:
translate(String)
#translate(File, File)
#translate(File, String, File)
getErrorHistory()
.
Constructor Summary | |
---|---|
Cob2Xsd()
Default constructor. |
|
Cob2Xsd(Cob2XsdModel model)
|
Method Summary | |
---|---|
protected void |
checkCobolSourceFile(File cobolSourceFile)
make sure the COBOL file is valid. |
protected void |
checkTarget(File target)
make sure the target, folder or file, is valid. |
String |
clean(String cobolSource)
Remove any non COBOL Structure characters from the source. |
protected org.apache.ws.commons.schema.XmlSchema |
createXmlSchema(String encoding)
Create an empty XML Schema. |
List<com.legstar.cobol.model.CobolDataItem> |
emitModel(org.antlr.runtime.tree.CommonTree ast)
Generates a model from an Abstract Syntax Tree. |
org.apache.ws.commons.schema.XmlSchema |
emitXsd(List<com.legstar.cobol.model.CobolDataItem> cobolDataItems)
Generate an XML Schema using a model of COBOL data items. |
List<String> |
getErrorHistory()
list of errors encountered while translating. |
Cob2XsdModel |
getModel()
The execution parameters for the COBOL to XML Schema utility. |
protected static void |
getNonUniqueCobolNames(com.legstar.cobol.model.CobolDataItem cobolDataItem,
List<String> cobolNames,
List<String> nonUniqueCobolNames)
If data item COBOL name is already used, we add it to the non unique list. |
static List<String> |
getNonUniqueCobolNames(List<com.legstar.cobol.model.CobolDataItem> cobolDataItems)
Create a list of COBOL names which are not unique. |
org.antlr.runtime.CommonTokenStream |
lex(String cleanedCobolSource)
Apply the lexer to produce a token stream from source. |
org.antlr.runtime.tree.CommonTree |
parse(org.antlr.runtime.CommonTokenStream tokens)
Apply Parser to produce an abstract syntax tree from a token stream. |
List<com.legstar.cobol.model.CobolDataItem> |
toModel(String cobolSource)
Parses a COBOL source into an in-memory model. |
String |
translate(String cobolSource)
Execute the translation from COBOL to XML Schema. |
String |
xsdToString(org.apache.ws.commons.schema.XmlSchema xsd)
Serialize the XML Schema to a string. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Cob2Xsd()
public Cob2Xsd(Cob2XsdModel model)
model
- execution parameters for the COBOL to XML Schema utilityMethod Detail |
---|
public String translate(String cobolSource) throws RecognizerException, XsdGenerationException
cobolSource
- the COBOL source code
RecognizerException
- if COBOL recognition fails
XsdGenerationException
- if XML schema generation process failsprotected void checkCobolSourceFile(File cobolSourceFile) throws IOException
cobolSourceFile
- the COBOL source file
IOException
- if file cannot be locatedprotected void checkTarget(File target) throws IOException
target
- the target folder or file
IOException
- if file cannot be locatedpublic List<com.legstar.cobol.model.CobolDataItem> toModel(String cobolSource) throws RecognizerException
cobolSource
- the COBOL source
RecognizerException
- if COBOL recognition failspublic String clean(String cobolSource) throws CleanerException
cobolSource
- the raw source
CleanerException
- if source cannot be readpublic org.antlr.runtime.CommonTokenStream lex(String cleanedCobolSource) throws RecognizerException
cleanedCobolSource
- the source code (clean outside columns 7 to 72)
RecognizerException
- if lexer failed to tokenize COBOL sourcepublic org.antlr.runtime.tree.CommonTree parse(org.antlr.runtime.CommonTokenStream tokens) throws RecognizerException
tokens
- the stream token produced by lexer
RecognizerException
- if source contains unsupported statementspublic List<com.legstar.cobol.model.CobolDataItem> emitModel(org.antlr.runtime.tree.CommonTree ast) throws RecognizerException
ast
- the abstract syntax tree produced by parser
RecognizerException
- if tree cannot be walkedpublic org.apache.ws.commons.schema.XmlSchema emitXsd(List<com.legstar.cobol.model.CobolDataItem> cobolDataItems)
cobolDataItems
- a list of COBOL data items
public String xsdToString(org.apache.ws.commons.schema.XmlSchema xsd) throws XsdGenerationException
xsd
- the XML Schema before customization
XsdGenerationException
- if customization failspublic static List<String> getNonUniqueCobolNames(List<com.legstar.cobol.model.CobolDataItem> cobolDataItems)
cobolDataItems
- a list of root data items
protected static void getNonUniqueCobolNames(com.legstar.cobol.model.CobolDataItem cobolDataItem, List<String> cobolNames, List<String> nonUniqueCobolNames)
cobolDataItem
- a COBOL data itemcobolNames
- the list of all COBOL names used so farnonUniqueCobolNames
- the list of non unique COBOL namesprotected org.apache.ws.commons.schema.XmlSchema createXmlSchema(String encoding)
encoding
- the character set used to encode this XML Schema
public Cob2XsdModel getModel()
public List<String> getErrorHistory()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |