|
From: <de...@us...> - 2003-12-18 00:32:06
|
Update of /cvsroot/pymerase/pymerase/pymerase/output
In directory sc8-pr-cvs1:/tmp/cvs-serv24848
Added Files:
CreateJava.py
Log Message:
Begin a java/ojb output module
--- NEW FILE: CreateJava.py ---
###########################################################################
# #
# C O P Y R I G H T N O T I C E #
# Copyright (c) 2001 by: #
# * California Institute of Technology #
# #
# All Rights Reserved. #
# #
# Permission is hereby granted, free of charge, to any person #
# obtaining a copy of this software and associated documentation files #
# (the "Software"), to deal in the Software without restriction, #
# including without limitation the rights to use, copy, modify, merge, #
# publish, distribute, sublicense, and/or sell copies of the Software, #
# and to permit persons to whom the Software is furnished to do so, #
# subject to the following conditions: #
# #
# The above copyright notice and this permission notice shall be #
# included in all copies or substantial portions of the Software. #
# #
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, #
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF #
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND #
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS #
# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN #
# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN #
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE #
# SOFTWARE. #
###########################################################################
# Authors: $Author: detrout $
# Last Modified: $Date: 2003/12/18 00:32:03 $
"""Creates Java API"""
from __future__ import nested_scopes
import os
import sys
import string
import re
import types
import shutil
from pymerase.util.Template import Template
from pymerase.util.output import *
from pymerase.util.SortMetaInfo import forwardDeclarationSort
from pymerase.util.Template import Template
from pymerase.output.dbAPI import fkeyTypes
import warnings
from pymerase.util.Warnings import DebugWarning
from warnings import warn
############################
# helper files
def getMITCopyright():
return """
###########################################################################
# #
# C O P Y R I G H T N O T I C E #
# Copyright (c) %4s by: #
# * California Institute of Technology #
# #
# All Rights Reserved. #
# #
# Permission is hereby granted, free of charge, to any person #
# obtaining a copy of this software and associated documentation files #
# (the "Software"), to deal in the Software without restriction, #
# including without limitation the rights to use, copy, modify, merge, #
# publish, distribute, sublicense, and/or sell copies of the Software, #
# and to permit persons to whom the Software is furnished to do so, #
# subject to the following conditions: #
# #
# The above copyright notice and this permission notice shall be #
# included in all copies or substantial portions of the Software. #
# #
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, #
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF #
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND #
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS #
# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN #
# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN #
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE #
# SOFTWARE. #
###########################################################################
""" % (str(2003))
TRANSLATOR_NAME='CreateJava'
SQL_TRANSLATOR_NAME='CreateSQL'
class JavaTemplate(Template):
def __init__(self):
Template.__init__(self)
#######################################
# Output Translater Interface
def writeClass(destination, classMetaInfo):
"""Generate the java classes.
"""
c = []
c += ["/** "]
c += [" * Create a new %(ClassName)s"]
c += [" *"]
c += [" * All collections will be initialized (as empty)."]
c += [" */"]
c += [""]
c += ["public %(ClassName)s()"]
c += ["{"]
if not classMetaInfo.isBaseClass():
c += [" super();"]
c += [""]
c += ["%(ClasInitializer)s"]
c += [""]
c += ["/**"]
c += [" * Create a new %(ClassName)s with all fields initialized."]
c += [" */"]
c += ["%(DefaultConstructor)s"]
c += [""]
c += ["/**"]
c += [" * Prints a string represenation of this class to aid in deubbing"]
c += [" */"]
c += ["public void debugPrint()"]
c += ["{"]
c += [" System.out.println(class %(ClassName)s)"]
c += [" debugDumpAttributes();"]
c += [" System.out.println();"]
c += ["}"]
c += [""]
c += ["protected void de"]
c += [""]
c += [""]
c += [""]
c += [""]
c += [""]
c += [""]
c += [""]
c += [""]
c += [""]
c += [""]
def write(destination, parsedInput):
# Write out all the individual package members
if not os.path.exists(destination):
os.mkdir(destination)
elif not os.path.isdir(destination):
msg = "PATH(%s) is not a directory!" % (destination)
raise ValueError(msg)
package_information = []
for t in tables:
try:
package_information.append(writeClass(destination, t))
except NotImplementedError, e:
warn("Skipping %s" % ( t.getName() ), DebugWarning)
|