net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAstXMsgClient.CFAstXMsgClientSchema.java Source code

Java tutorial

Introduction

Here is the source code for net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAstXMsgClient.CFAstXMsgClientSchema.java

Source

// Description: Java 7 XMsg Client DbIO implementation for CFAst.

/*
 *   CF Asterisk 11 Configuration Model
 *
 *   Copyright (c) 2013-2014 Mark Sobkow
 *   
 *   This program is available as free software under the GNU GPL v3, or
 *   under a commercial license from Mark Sobkow.  For commercial licensing
 *   details, please contact msobkow@sasktel.net.
 *   
 *   Under the terms of the GPL:
 *   
 *      This program is free software: you can redistribute it and/or modify
 *      it under the terms of the GNU General Public License as published by
 *      the Free Software Foundation, either version 3 of the License, or
 *      (at your option) any later version.
 *     
 *      This program is distributed in the hope that it will be useful,
 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *      GNU General Public License for more details.
 *     
 *      You should have received a copy of the GNU General Public License
 *      along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *   
 *      This source code incorporates modified modules originally licensed
 *      under the Apache 2.0 license by MSS Code Factory including CFSecurity
 *      (net-sourceforge-msscodefactory-2.0-cfsecurity.xml),
 *      CFInternet (net-sourceforge-msscodefactory-2.0-cfinternet.xml), and
 *      CFCrm 2.0 (net-sourceforge-msscodefactory-2.0-cfcrm.xml), with all of the
 *      required models being available as part of the MSS Code Factory 1.11
 *      distribution source and install zips.
 *   
 *      You can download installations of MSS Code Factory 1.11 from
 *      http://msscodefactory.sourceforge.net/
 *   
 * ***********************************************************************
 *
 *   Code manufactured by MSS Code Factory
 */

package net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAstXMsgClient;

import java.lang.reflect.*;
import java.math.*;
import java.sql.*;
import java.text.*;
import java.util.*;
import javax.naming.*;
import javax.sql.*;
import net.sourceforge.msscodefactory.cflib.v1_11.CFLib.*;
import org.apache.commons.codec.binary.Base64;
import net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAst.*;
import net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAstObj.*;
import net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAstXMsg.*;
import net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAstXMsgRspnHandler.*;

public class CFAstXMsgClientSchema extends CFAstSchema {
    protected CFAstXMsgRspnHandler responseHandler = null;
    protected boolean transactionOpen = false;

    public CFAstXMsgClientSchema() {
        super();
        tableAsteriskConf = new CFAstXMsgClientAsteriskConfTable(this);
        tableAuditAction = new CFAstXMsgClientAuditActionTable(this);
        tableCluster = new CFAstXMsgClientClusterTable(this);
        tableConfigurationFile = new CFAstXMsgClientConfigurationFileTable(this);
        tableDomain = new CFAstXMsgClientDomainTable(this);
        tableDomainBase = new CFAstXMsgClientDomainBaseTable(this);
        tableExtConfigConf = new CFAstXMsgClientExtConfigConfTable(this);
        tableExtensionsConf = new CFAstXMsgClientExtensionsConfTable(this);
        tableHostNode = new CFAstXMsgClientHostNodeTable(this);
        tableISOCountry = new CFAstXMsgClientISOCountryTable(this);
        tableISOCountryCurrency = new CFAstXMsgClientISOCountryCurrencyTable(this);
        tableISOCountryLanguage = new CFAstXMsgClientISOCountryLanguageTable(this);
        tableISOCurrency = new CFAstXMsgClientISOCurrencyTable(this);
        tableISOLanguage = new CFAstXMsgClientISOLanguageTable(this);
        tableISOTimezone = new CFAstXMsgClientISOTimezoneTable(this);
        tableMajorVersion = new CFAstXMsgClientMajorVersionTable(this);
        tableMimeType = new CFAstXMsgClientMimeTypeTable(this);
        tableMinorVersion = new CFAstXMsgClientMinorVersionTable(this);
        tableProjectBase = new CFAstXMsgClientProjectBaseTable(this);
        tableRealProject = new CFAstXMsgClientRealProjectTable(this);
        tableSecApp = new CFAstXMsgClientSecAppTable(this);
        tableSecForm = new CFAstXMsgClientSecFormTable(this);
        tableSecGroup = new CFAstXMsgClientSecGroupTable(this);
        tableSecGroupForm = new CFAstXMsgClientSecGroupFormTable(this);
        tableSecGroupInclude = new CFAstXMsgClientSecGroupIncludeTable(this);
        tableSecGroupMember = new CFAstXMsgClientSecGroupMemberTable(this);
        tableSecSession = new CFAstXMsgClientSecSessionTable(this);
        tableSecUser = new CFAstXMsgClientSecUserTable(this);
        tableService = new CFAstXMsgClientServiceTable(this);
        tableServiceType = new CFAstXMsgClientServiceTypeTable(this);
        tableSipConf = new CFAstXMsgClientSipConfTable(this);
        tableSubProject = new CFAstXMsgClientSubProjectTable(this);
        tableTSecGroup = new CFAstXMsgClientTSecGroupTable(this);
        tableTSecGroupInclude = new CFAstXMsgClientTSecGroupIncludeTable(this);
        tableTSecGroupMember = new CFAstXMsgClientTSecGroupMemberTable(this);
        tableTenant = new CFAstXMsgClientTenantTable(this);
        tableTld = new CFAstXMsgClientTldTable(this);
        tableTopDomain = new CFAstXMsgClientTopDomainTable(this);
        tableTopProject = new CFAstXMsgClientTopProjectTable(this);
        tableURLProtocol = new CFAstXMsgClientURLProtocolTable(this);
        tableVersion = new CFAstXMsgClientVersionTable(this);
        tableVoicemailConf = new CFAstXMsgClientVoicemailConfTable(this);
        setResponseHandlerSchemaObj(null);
    }

    public CFAstXMsgClientSchema(CFAstSchemaObj handlerSchema) {
        super();
        tableAsteriskConf = new CFAstXMsgClientAsteriskConfTable(this);
        tableAuditAction = new CFAstXMsgClientAuditActionTable(this);
        tableCluster = new CFAstXMsgClientClusterTable(this);
        tableConfigurationFile = new CFAstXMsgClientConfigurationFileTable(this);
        tableDomain = new CFAstXMsgClientDomainTable(this);
        tableDomainBase = new CFAstXMsgClientDomainBaseTable(this);
        tableExtConfigConf = new CFAstXMsgClientExtConfigConfTable(this);
        tableExtensionsConf = new CFAstXMsgClientExtensionsConfTable(this);
        tableHostNode = new CFAstXMsgClientHostNodeTable(this);
        tableISOCountry = new CFAstXMsgClientISOCountryTable(this);
        tableISOCountryCurrency = new CFAstXMsgClientISOCountryCurrencyTable(this);
        tableISOCountryLanguage = new CFAstXMsgClientISOCountryLanguageTable(this);
        tableISOCurrency = new CFAstXMsgClientISOCurrencyTable(this);
        tableISOLanguage = new CFAstXMsgClientISOLanguageTable(this);
        tableISOTimezone = new CFAstXMsgClientISOTimezoneTable(this);
        tableMajorVersion = new CFAstXMsgClientMajorVersionTable(this);
        tableMimeType = new CFAstXMsgClientMimeTypeTable(this);
        tableMinorVersion = new CFAstXMsgClientMinorVersionTable(this);
        tableProjectBase = new CFAstXMsgClientProjectBaseTable(this);
        tableRealProject = new CFAstXMsgClientRealProjectTable(this);
        tableSecApp = new CFAstXMsgClientSecAppTable(this);
        tableSecForm = new CFAstXMsgClientSecFormTable(this);
        tableSecGroup = new CFAstXMsgClientSecGroupTable(this);
        tableSecGroupForm = new CFAstXMsgClientSecGroupFormTable(this);
        tableSecGroupInclude = new CFAstXMsgClientSecGroupIncludeTable(this);
        tableSecGroupMember = new CFAstXMsgClientSecGroupMemberTable(this);
        tableSecSession = new CFAstXMsgClientSecSessionTable(this);
        tableSecUser = new CFAstXMsgClientSecUserTable(this);
        tableService = new CFAstXMsgClientServiceTable(this);
        tableServiceType = new CFAstXMsgClientServiceTypeTable(this);
        tableSipConf = new CFAstXMsgClientSipConfTable(this);
        tableSubProject = new CFAstXMsgClientSubProjectTable(this);
        tableTSecGroup = new CFAstXMsgClientTSecGroupTable(this);
        tableTSecGroupInclude = new CFAstXMsgClientTSecGroupIncludeTable(this);
        tableTSecGroupMember = new CFAstXMsgClientTSecGroupMemberTable(this);
        tableTenant = new CFAstXMsgClientTenantTable(this);
        tableTld = new CFAstXMsgClientTldTable(this);
        tableTopDomain = new CFAstXMsgClientTopDomainTable(this);
        tableTopProject = new CFAstXMsgClientTopProjectTable(this);
        tableURLProtocol = new CFAstXMsgClientURLProtocolTable(this);
        tableVersion = new CFAstXMsgClientVersionTable(this);
        tableVoicemailConf = new CFAstXMsgClientVoicemailConfTable(this);
        setResponseHandlerSchemaObj(handlerSchema);
    }

    public CFAstXMsgClientSchema(CFAstSchemaObj handlerSchema, CFAstConfigurationFile conf) {
        super(conf);
        tableAsteriskConf = new CFAstXMsgClientAsteriskConfTable(this);
        tableAuditAction = new CFAstXMsgClientAuditActionTable(this);
        tableCluster = new CFAstXMsgClientClusterTable(this);
        tableConfigurationFile = new CFAstXMsgClientConfigurationFileTable(this);
        tableDomain = new CFAstXMsgClientDomainTable(this);
        tableDomainBase = new CFAstXMsgClientDomainBaseTable(this);
        tableExtConfigConf = new CFAstXMsgClientExtConfigConfTable(this);
        tableExtensionsConf = new CFAstXMsgClientExtensionsConfTable(this);
        tableHostNode = new CFAstXMsgClientHostNodeTable(this);
        tableISOCountry = new CFAstXMsgClientISOCountryTable(this);
        tableISOCountryCurrency = new CFAstXMsgClientISOCountryCurrencyTable(this);
        tableISOCountryLanguage = new CFAstXMsgClientISOCountryLanguageTable(this);
        tableISOCurrency = new CFAstXMsgClientISOCurrencyTable(this);
        tableISOLanguage = new CFAstXMsgClientISOLanguageTable(this);
        tableISOTimezone = new CFAstXMsgClientISOTimezoneTable(this);
        tableMajorVersion = new CFAstXMsgClientMajorVersionTable(this);
        tableMimeType = new CFAstXMsgClientMimeTypeTable(this);
        tableMinorVersion = new CFAstXMsgClientMinorVersionTable(this);
        tableProjectBase = new CFAstXMsgClientProjectBaseTable(this);
        tableRealProject = new CFAstXMsgClientRealProjectTable(this);
        tableSecApp = new CFAstXMsgClientSecAppTable(this);
        tableSecForm = new CFAstXMsgClientSecFormTable(this);
        tableSecGroup = new CFAstXMsgClientSecGroupTable(this);
        tableSecGroupForm = new CFAstXMsgClientSecGroupFormTable(this);
        tableSecGroupInclude = new CFAstXMsgClientSecGroupIncludeTable(this);
        tableSecGroupMember = new CFAstXMsgClientSecGroupMemberTable(this);
        tableSecSession = new CFAstXMsgClientSecSessionTable(this);
        tableSecUser = new CFAstXMsgClientSecUserTable(this);
        tableService = new CFAstXMsgClientServiceTable(this);
        tableServiceType = new CFAstXMsgClientServiceTypeTable(this);
        tableSipConf = new CFAstXMsgClientSipConfTable(this);
        tableSubProject = new CFAstXMsgClientSubProjectTable(this);
        tableTSecGroup = new CFAstXMsgClientTSecGroupTable(this);
        tableTSecGroupInclude = new CFAstXMsgClientTSecGroupIncludeTable(this);
        tableTSecGroupMember = new CFAstXMsgClientTSecGroupMemberTable(this);
        tableTenant = new CFAstXMsgClientTenantTable(this);
        tableTld = new CFAstXMsgClientTldTable(this);
        tableTopDomain = new CFAstXMsgClientTopDomainTable(this);
        tableTopProject = new CFAstXMsgClientTopProjectTable(this);
        tableURLProtocol = new CFAstXMsgClientURLProtocolTable(this);
        tableVersion = new CFAstXMsgClientVersionTable(this);
        tableVoicemailConf = new CFAstXMsgClientVoicemailConfTable(this);
        setSchemaDbName(conf.getDbDatabase());
        setResponseHandlerSchemaObj(handlerSchema);
    }

    public CFAstXMsgClientSchema(CFAstSchemaObj handlerSchema, String argJndiName) {
        super(argJndiName);
        tableAsteriskConf = new CFAstXMsgClientAsteriskConfTable(this);
        tableAuditAction = new CFAstXMsgClientAuditActionTable(this);
        tableCluster = new CFAstXMsgClientClusterTable(this);
        tableConfigurationFile = new CFAstXMsgClientConfigurationFileTable(this);
        tableDomain = new CFAstXMsgClientDomainTable(this);
        tableDomainBase = new CFAstXMsgClientDomainBaseTable(this);
        tableExtConfigConf = new CFAstXMsgClientExtConfigConfTable(this);
        tableExtensionsConf = new CFAstXMsgClientExtensionsConfTable(this);
        tableHostNode = new CFAstXMsgClientHostNodeTable(this);
        tableISOCountry = new CFAstXMsgClientISOCountryTable(this);
        tableISOCountryCurrency = new CFAstXMsgClientISOCountryCurrencyTable(this);
        tableISOCountryLanguage = new CFAstXMsgClientISOCountryLanguageTable(this);
        tableISOCurrency = new CFAstXMsgClientISOCurrencyTable(this);
        tableISOLanguage = new CFAstXMsgClientISOLanguageTable(this);
        tableISOTimezone = new CFAstXMsgClientISOTimezoneTable(this);
        tableMajorVersion = new CFAstXMsgClientMajorVersionTable(this);
        tableMimeType = new CFAstXMsgClientMimeTypeTable(this);
        tableMinorVersion = new CFAstXMsgClientMinorVersionTable(this);
        tableProjectBase = new CFAstXMsgClientProjectBaseTable(this);
        tableRealProject = new CFAstXMsgClientRealProjectTable(this);
        tableSecApp = new CFAstXMsgClientSecAppTable(this);
        tableSecForm = new CFAstXMsgClientSecFormTable(this);
        tableSecGroup = new CFAstXMsgClientSecGroupTable(this);
        tableSecGroupForm = new CFAstXMsgClientSecGroupFormTable(this);
        tableSecGroupInclude = new CFAstXMsgClientSecGroupIncludeTable(this);
        tableSecGroupMember = new CFAstXMsgClientSecGroupMemberTable(this);
        tableSecSession = new CFAstXMsgClientSecSessionTable(this);
        tableSecUser = new CFAstXMsgClientSecUserTable(this);
        tableService = new CFAstXMsgClientServiceTable(this);
        tableServiceType = new CFAstXMsgClientServiceTypeTable(this);
        tableSipConf = new CFAstXMsgClientSipConfTable(this);
        tableSubProject = new CFAstXMsgClientSubProjectTable(this);
        tableTSecGroup = new CFAstXMsgClientTSecGroupTable(this);
        tableTSecGroupInclude = new CFAstXMsgClientTSecGroupIncludeTable(this);
        tableTSecGroupMember = new CFAstXMsgClientTSecGroupMemberTable(this);
        tableTenant = new CFAstXMsgClientTenantTable(this);
        tableTld = new CFAstXMsgClientTldTable(this);
        tableTopDomain = new CFAstXMsgClientTopDomainTable(this);
        tableTopProject = new CFAstXMsgClientTopProjectTable(this);
        tableURLProtocol = new CFAstXMsgClientURLProtocolTable(this);
        tableVersion = new CFAstXMsgClientVersionTable(this);
        tableVoicemailConf = new CFAstXMsgClientVoicemailConfTable(this);
        setResponseHandlerSchemaObj(handlerSchema);
    }

    /**
     *   Get the CFAstSchemaObj that is used by the response processor to
     *   import the response objects during the parsing of response message strings.
     *
     *   @return   The CFAstSchemaObj that is providing a persistence implementation
     *         for the parsing of response message strings.
     */
    public ICFAstSchemaObj getResponseHandlerSchemaObj() {
        ICFAstSchemaObj handlerSchema = getResponseHandler().getSchemaObj();
        return (handlerSchema);
    }

    /**
     *   Set the CFAstSchemaObj that is to be used by the response processor to
     *   import the response objects during the parsing of response message strings.
     *
     *   @param   handlerSchema The CFAstSchemaObj that is to provide a persistence implementation
     *         for the parsing of response message strings.
     */
    public void setResponseHandlerSchemaObj(ICFAstSchemaObj handlerSchema) {
        getResponseHandler().setSchemaObj(handlerSchema);
    }

    public ICFLibMessageLog getLog() {
        ICFLibMessageLog mylog = getResponseHandler().getLog();
        return (mylog);
    }

    public void setLog(ICFLibMessageLog newlog) {
        getResponseHandler().setLog(newlog);
    }

    /**
     *   Get the CFAstDeleted flag that is used by the response processor to
     *   indate that a Deleted response was processed.
     *
     *   @return   True if a Deleted message was processed, otherwise false.
     */
    public boolean getResponseHandlerDeleted() {
        boolean deleted = getResponseHandler().getDeleted();
        return (deleted);
    }

    /**
     *   Set the CFAstDeleted flag that is to be used by the response processor to
     *   indicate that a Deleted response was processed.
     *
     *   @param   deleted True if a Deleted response was processed, otherwise false.
     */
    public void setResponseHandlerDeleted(boolean deleted) {
        getResponseHandler().setDeleted(deleted);
    }

    public boolean isConnected() {
        ICFAstSchemaObj schemaObj = getResponseHandlerSchemaObj();
        if (schemaObj.getAuthorization() != null) {
            return (true);
        } else {
            return (false);
        }
    }

    /**
     *   Send the request and receive a response string from the server.
     *   <p>
     *   You are expected to overload the implementation of this method
     *   when binding an XMsgClient package to a particular transport
     *   mechanism.  The implementation of sendReceive() is for pure XML
     *   strings, so you can wire it to pretty much any implementation
     *   you choose.
     *
     *   @param   Authorization -- null for connection requests
     *
     *   @param   rqst The String to send to the server
     *
     *   @return   rspn The response string recieved from the server, ready to be parsed as an XML file content.
     */
    public String sendReceive(CFAstAuthorization Authorization, String rqst) {
        throw CFLib.getDefaultExceptionFactory().newMustOverrideException(getClass(), "sendReceive");
    }

    public CFAstXMsgRspnHandler getResponseHandler() {
        if (responseHandler == null) {
            responseHandler = new CFAstXMsgRspnHandler();
        }
        return (responseHandler);
    }

    public boolean connect() {
        throw CFLib.getDefaultExceptionFactory().newNotSupportedException(getClass(), "connect");
    }

    public boolean connect(String username, String password) {
        throw CFLib.getDefaultExceptionFactory().newNotSupportedException(getClass(), "connect-userpw");
    }

    public boolean connect(String clusterName, String tenantName, String secUserName, String dbusername,
            String dbpassword) {
        final String S_ProcName = "connect-auth-userpw";
        String rqst = CFAstXMsgSchemaMessageFormatter.formatRqstXmlPreamble()
                + "\n" + "\t" + CFAstXMsgSchemaMessageFormatter.formatRqstLogIn("\n\t\t\t", clusterName, tenantName,
                        secUserName, dbusername, dbpassword)
                + "\n" + CFAstXMsgSchemaMessageFormatter.formatRqstXmlPostamble();
        String rspn = sendReceive(null, rqst);
        if ((rspn == null) || (rspn.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "rspn");
        }
        // The response handler sets up the authorization
        responseHandler.parseStringContents(rspn);
        CFLibRuntimeException exceptionRaised = responseHandler.getExceptionRaised();
        if (exceptionRaised != null) {
            throw exceptionRaised;
        }
        // If we got a response instead of an exception, we succeeded at logging in.
        return (true);
    }

    public void disconnect(boolean doCommit) {
    }

    public void logout(CFAstAuthorization auth) {
        final String S_ProcName = "logout";
        if ((auth == null) || (null == auth.getSecSessionId())) {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Not authorized/connected");
        }
        String rqst = CFAstXMsgSchemaMessageFormatter.formatRqstXmlPreamble() + "\n" + "\t"
                + CFAstXMsgSchemaMessageFormatter.formatRqstLogOut("\n\t\t\t", auth.getSecSessionId()) + "\n"
                + CFAstXMsgSchemaMessageFormatter.formatRqstXmlPostamble();
        String rspn = sendReceive(auth, rqst);
        if ((rspn == null) || (rspn.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "rspn");
        }
        responseHandler.parseStringContents(rspn);
        CFLibRuntimeException exceptionRaised = responseHandler.getExceptionRaised();
        if (exceptionRaised != null) {
            throw exceptionRaised;
        }
    }

    public boolean isTransactionOpen() {
        return (transactionOpen);
    }

    public boolean beginTransaction() {
        if (transactionOpen) {
            return (false);
        } else {
            transactionOpen = true;
            return (true);
        }
    }

    public void commit() {
        transactionOpen = false;
    }

    public void rollback() {
        transactionOpen = false;
    }

    public boolean isSystemUser(CFAstAuthorization Authorization) {
        throw CFLib.getDefaultExceptionFactory().newNotSupportedException(getClass(), "isSystemUser");
    }

    public boolean isClusterUser(CFAstAuthorization Authorization, long clusterId, String groupName) {
        throw CFLib.getDefaultExceptionFactory().newNotSupportedException(getClass(), "isClusterUser");
    }

    public boolean isTenantUser(CFAstAuthorization Authorization, long tenantId, String groupName) {
        throw CFLib.getDefaultExceptionFactory().newNotSupportedException(getClass(), "isTenantUser");
    }

    public int nextServiceTypeIdGen() {
        throw CFLib.getDefaultExceptionFactory().newNotSupportedException(getClass(), "nextServiceTypeIdGen");
    }

    public int nextMimeTypeIdGen() {
        throw CFLib.getDefaultExceptionFactory().newNotSupportedException(getClass(), "nextMimeTypeIdGen");
    }

    public long nextClusterIdGen() {
        throw CFLib.getDefaultExceptionFactory().newNotSupportedException(getClass(), "nextClusterIdGen");
    }

    public long nextTenantIdGen() {
        throw CFLib.getDefaultExceptionFactory().newNotSupportedException(getClass(), "nextTenantIdGen");
    }

    public UUID nextSecSessionIdGen() {
        throw CFLib.getDefaultExceptionFactory().newNotSupportedException(getClass(), "nextSecSessionIdGen");
    }

    public UUID nextSecUserIdGen() {
        throw CFLib.getDefaultExceptionFactory().newNotSupportedException(getClass(), "nextSecUserIdGen");
    }

    /**
     *   Release the prepared statements.
     *   <p>
     *   When the schema changes connections, the prepared statements
     *   have to be released because they contain connection-specific
     *   information for most databases.
     */
    public void releasePreparedStatements() {
        throw CFLib.getDefaultExceptionFactory().newNotSupportedException(getClass(), "releasePreparedStatements");
    }

    public static String getQuotedString(String val) {
        if (val == null) {
            return ("null");
        } else {
            char c;
            StringBuilder quoted = new StringBuilder();
            quoted.append("'");
            int len = val.length();
            for (int i = 0; i < len; i++) {
                if (val.charAt(i) == '\'') {
                    quoted.append("''");
                } else if (val.charAt(i) == '\\') {
                    quoted.append("'||E'\\\\'||'");
                } else {
                    c = val.charAt(i);
                    if ((c == '0') || (c == '1') || (c == '2') || (c == '3') || (c == '4') || (c == '5')
                            || (c == '6') || (c == '7') || (c == '8') || (c == '9') || (c == 'a') || (c == 'b')
                            || (c == 'c') || (c == 'd') || (c == 'e') || (c == 'f') || (c == 'g') || (c == 'h')
                            || (c == 'i') || (c == 'j') || (c == 'k') || (c == 'l') || (c == 'm') || (c == 'n')
                            || (c == 'o') || (c == 'p') || (c == 'q') || (c == 'r') || (c == 's') || (c == 't')
                            || (c == 'u') || (c == 'v') || (c == 'w') || (c == 'x') || (c == 'y') || (c == 'z')
                            || (c == 'A') || (c == 'B') || (c == 'C') || (c == 'D') || (c == 'E') || (c == 'F')
                            || (c == 'G') || (c == 'H') || (c == 'I') || (c == 'J') || (c == 'K') || (c == 'L')
                            || (c == 'M') || (c == 'N') || (c == 'O') || (c == 'P') || (c == 'Q') || (c == 'R')
                            || (c == 'S') || (c == 'T') || (c == 'U') || (c == 'V') || (c == 'W') || (c == 'X')
                            || (c == 'Y') || (c == 'Z') || (c == ' ') || (c == '\t') || (c == '\r') || (c == '\n')
                            || (c == '`') || (c == '~') || (c == '!') || (c == '@') || (c == '#') || (c == '$')
                            || (c == '%') || (c == '^') || (c == '&') || (c == '*') || (c == '(') || (c == ')')
                            || (c == '-') || (c == '_') || (c == '=') || (c == '+') || (c == '[') || (c == ']')
                            || (c == '{') || (c == '}') || (c == '|') || (c == ';') || (c == ':') || (c == '"')
                            || (c == '<') || (c == '>') || (c == ',') || (c == '.') || (c == '/') || (c == '?')) {
                        quoted.append(c);
                    } else {
                        //                  Syslog.warn("\t\t\tReplacing invalid character '" + c + "' with space");
                        quoted.append(' ');
                    }
                }
            }
            quoted.append("'");
            return (quoted.toString());
        }
    }

    public static String getNullableString(ResultSet reader, int colidx) {
        try {
            String val = reader.getString(colidx);
            if (reader.wasNull()) {
                return (null);
            } else {
                return (val);
            }
        } catch (SQLException e) {
            throw CFLib.getDefaultExceptionFactory().newDbException(CFAstXMsgClientSchema.class,
                    "getNullableString", e);
        }
    }

    public static String getBlobString(byte[] val) {
        if (val == null) {
            return ("null");
        } else {
            return ("'" + Base64.encodeBase64(val).toString() + "'");
        }
    }

    public static String getBoolString(Boolean val) {
        if (val == null) {
            return ("null");
        } else {
            if (val) {
                return ("true");
            } else {
                return ("false");
            }
        }
    }

    public static String getBoolString(boolean val) {
        if (val) {
            return ("true");
        } else {
            return ("false");
        }
    }

    public static String getInt16String(Short val) {
        if (val == null) {
            return ("null");
        } else {
            return (val.toString());
        }
    }

    public static String getInt16String(short val) {
        return (Short.toString(val));
    }

    public static String getInt32String(Integer val) {
        if (val == null) {
            return ("null");
        } else {
            return (val.toString());
        }
    }

    public static String getInt32String(int val) {
        return (Integer.toString(val));
    }

    public static String getInt64String(Long val) {
        if (val == null) {
            return ("null");
        } else {
            return (val.toString());
        }
    }

    public static String getInt64String(long val) {
        return (Long.toString(val));
    }

    public static String getUInt16String(Integer val) {
        if (val == null) {
            return ("null");
        } else {
            return (val.toString());
        }
    }

    public static String getUInt16String(int val) {
        return (Integer.toString(val));
    }

    public static String getUInt32String(Long val) {
        if (val == null) {
            return ("null");
        } else {
            return (val.toString());
        }
    }

    public static String getUInt32String(long val) {
        return (Long.toString(val));
    }

    public static String getUInt64String(BigDecimal val) {
        if (val == null) {
            return ("null");
        } else {
            return (val.toString());
        }
    }

    public static String getFloatString(Float val) {
        if (val == null) {
            return ("null");
        } else {
            return (val.toString());
        }
    }

    public static String getFloatString(float val) {
        return (Float.toString(val));
    }

    public static String getDoubleString(Double val) {
        if (val == null) {
            return ("null");
        } else {
            return (val.toString());
        }
    }

    public static String getDoubleString(double val) {
        return (Double.toString(val));
    }

    public static String getNumberString(BigDecimal val) {
        if (val == null) {
            return ("null");
        } else {
            return (val.toString());
        }
    }

    public static Integer getNullableInt32(ResultSet reader, int colidx) {
        try {
            int val = reader.getInt(colidx);
            if (reader.wasNull()) {
                return (null);
            } else {
                return (new Integer(val));
            }
        } catch (SQLException e) {
            throw CFLib.getDefaultExceptionFactory().newDbException(CFAstXMsgClientSchema.class, "getNullableInt32",
                    e);
        }
    }

    public static Short getNullableInt16(ResultSet reader, int colidx) {
        try {
            short val = reader.getShort(colidx);
            if (reader.wasNull()) {
                return (null);
            } else {
                return (new Short(val));
            }
        } catch (SQLException e) {
            throw CFLib.getDefaultExceptionFactory().newDbException(CFAstXMsgClientSchema.class, "getNullableInt64",
                    e);
        }
    }

    public static Integer getNullableUInt16(ResultSet reader, int colidx) {
        try {
            int val = reader.getInt(colidx);
            if (reader.wasNull()) {
                return (null);
            } else {
                return (new Integer(val));
            }
        } catch (SQLException e) {
            throw CFLib.getDefaultExceptionFactory().newDbException(CFAstXMsgClientSchema.class,
                    "getNullableUInt16", e);
        }
    }

    public static Long getNullableUInt32(ResultSet reader, int colidx) {
        try {
            long val = reader.getLong(colidx);
            if (reader.wasNull()) {
                return (null);
            } else {
                return (new Long(val));
            }
        } catch (SQLException e) {
            throw CFLib.getDefaultExceptionFactory().newDbException(CFAstXMsgClientSchema.class,
                    "getNullableUInt32", e);
        }
    }

    public static BigDecimal getNullableUInt64(ResultSet reader, int colidx) {
        try {
            String strval = reader.getString(colidx);
            if (reader.wasNull() || (strval == null) || (strval.length() <= 0)) {
                return (null);
            } else {
                BigDecimal retval = new BigDecimal(strval);
                return (retval);
            }
        } catch (SQLException e) {
            throw CFLib.getDefaultExceptionFactory().newDbException(CFAstXMsgClientSchema.class,
                    "getNullableUInt64", e);
        }
    }

    public static Byte getNullableByte(ResultSet reader, int colidx) {
        try {
            byte val = reader.getByte(colidx);
            if (reader.wasNull()) {
                return (null);
            } else {
                return (new Byte(val));
            }
        } catch (SQLException e) {
            throw CFLib.getDefaultExceptionFactory().newDbException(CFAstXMsgClientSchema.class, "getNullableByte",
                    e);
        }
    }

    public static String getQuotedDateString(Calendar val) {
        if (val == null) {
            return ("null");
        } else {
            StringBuffer buff = new StringBuffer("'");
            Formatter fmt = new Formatter(buff);
            Calendar db = CFLibDbUtil.getDbServerCalendar(val);
            fmt.format("%1$04d", db.get(Calendar.YEAR));
            buff.append("-");
            fmt.format("%1$02d", db.get(Calendar.MONTH) + 1);
            buff.append("-");
            fmt.format("%1$02d", db.get(Calendar.DAY_OF_MONTH));
            buff.append("'");
            fmt.close();
            return (buff.toString());
        }
    }

    public static String getQuotedTimeString(Calendar val) {
        if (val == null) {
            return ("null");
        } else {
            StringBuffer buff = new StringBuffer("'");
            Formatter fmt = new Formatter(buff);
            Calendar db = CFLibDbUtil.getDbServerCalendar(val);
            fmt.format("%1$02d", db.get(Calendar.HOUR_OF_DAY));
            buff.append(":");
            fmt.format("%1$02d", db.get(Calendar.MINUTE));
            buff.append(":");
            fmt.format("%1$02d", db.get(Calendar.SECOND));
            buff.append("'");
            fmt.close();
            return (buff.toString());
        }
    }

    public static String getQuotedTimestampString(Calendar val) {
        if (val == null) {
            return ("null");
        } else {
            StringBuffer buff = new StringBuffer("'");
            Formatter fmt = new Formatter(buff);
            Calendar db = CFLibDbUtil.getDbServerCalendar(val);
            fmt.format("%1$04d", db.get(Calendar.YEAR));
            buff.append("-");
            fmt.format("%1$02d", db.get(Calendar.MONTH) + 1);
            buff.append("-");
            fmt.format("%1$02d", db.get(Calendar.DAY_OF_MONTH));
            buff.append(" ");
            fmt.format("%1$02d", db.get(Calendar.HOUR_OF_DAY));
            buff.append(":");
            fmt.format("%1$02d", db.get(Calendar.MINUTE));
            buff.append(":");
            fmt.format("%1$02d", db.get(Calendar.SECOND));
            buff.append("'");
            fmt.close();
            return (buff.toString());
        }
    }

    public static String getQuotedTZDateString(Calendar val) {
        if (val == null) {
            return ("null");
        } else {
            Calendar db = CFLibDbUtil.getDbServerCalendar(val);
            StringBuffer buff = new StringBuffer("'");
            Formatter fmt = new Formatter(buff);
            fmt.format("%1$04d", db.get(Calendar.YEAR));
            buff.append("-");
            fmt.format("%1$02d", db.get(Calendar.MONTH) + 1);
            buff.append("-");
            fmt.format("%1$02d", db.get(Calendar.DAY_OF_MONTH));
            buff.append(" ");
            fmt.format("%1$02d", db.get(Calendar.HOUR_OF_DAY));
            buff.append(":");
            fmt.format("%1$02d", db.get(Calendar.MINUTE));
            buff.append(":");
            fmt.format("%1$02d", db.get(Calendar.SECOND));
            buff.append("'");
            fmt.close();
            return (buff.toString());
        }
    }

    public static String getQuotedTZTimeString(Calendar val) {
        if (val == null) {
            return ("null");
        } else {
            Calendar db = CFLibDbUtil.getDbServerCalendar(val);
            StringBuffer buff = new StringBuffer("'");
            Formatter fmt = new Formatter(buff);
            fmt.format("%1$04d", db.get(Calendar.YEAR));
            buff.append("-");
            fmt.format("%1$02d", db.get(Calendar.MONTH) + 1);
            buff.append("-");
            fmt.format("%1$02d", db.get(Calendar.DAY_OF_MONTH));
            buff.append(" ");
            fmt.format("%1$02d", db.get(Calendar.HOUR_OF_DAY));
            buff.append(":");
            fmt.format("%1$02d", db.get(Calendar.MINUTE));
            buff.append(":");
            fmt.format("%1$02d", db.get(Calendar.SECOND));
            buff.append("'");
            fmt.close();
            return (buff.toString());
        }
    }

    public static String getQuotedTZTimestampString(Calendar val) {
        if (val == null) {
            return ("null");
        } else {
            Calendar db = CFLibDbUtil.getDbServerCalendar(val);
            StringBuffer buff = new StringBuffer("'");
            Formatter fmt = new Formatter(buff);
            fmt.format("%1$04d", db.get(Calendar.YEAR));
            buff.append("-");
            fmt.format("%1$02d", db.get(Calendar.MONTH) + 1);
            buff.append("-");
            fmt.format("%1$02d", db.get(Calendar.DAY_OF_MONTH));
            buff.append(" ");
            fmt.format("%1$02d", db.get(Calendar.HOUR_OF_DAY));
            buff.append(":");
            fmt.format("%1$02d", db.get(Calendar.MINUTE));
            buff.append(":");
            fmt.format("%1$02d", db.get(Calendar.SECOND));
            buff.append("'");
            fmt.close();
            return (buff.toString());
        }
    }

    public static String getDateString(Calendar val) {
        if (val == null) {
            return ("null");
        } else {
            StringBuffer buff = new StringBuffer();
            Formatter fmt = new Formatter(buff);
            Calendar db = CFLibDbUtil.getDbServerCalendar(val);
            fmt.format("%1$04d", db.get(Calendar.YEAR));
            buff.append("-");
            fmt.format("%1$02d", db.get(Calendar.MONTH) + 1);
            buff.append("-");
            fmt.format("%1$02d", db.get(Calendar.DAY_OF_MONTH));
            fmt.close();
            return (buff.toString());
        }
    }

    public static String getTimeString(Calendar val) {
        if (val == null) {
            return ("null");
        } else {
            StringBuffer buff = new StringBuffer();
            Formatter fmt = new Formatter(buff);
            Calendar db = CFLibDbUtil.getDbServerCalendar(val);
            fmt.format("%1$02d", db.get(Calendar.HOUR_OF_DAY));
            buff.append(":");
            fmt.format("%1$02d", db.get(Calendar.MINUTE));
            buff.append(":");
            fmt.format("%1$02d", db.get(Calendar.SECOND));
            fmt.close();
            return (buff.toString());
        }
    }

    public static String getTimestampString(Calendar val) {
        if (val == null) {
            return ("null");
        } else {
            StringBuffer buff = new StringBuffer();
            Formatter fmt = new Formatter(buff);
            Calendar db = CFLibDbUtil.getDbServerCalendar(val);
            fmt.format("%1$04d", db.get(Calendar.YEAR));
            buff.append("-");
            fmt.format("%1$02d", db.get(Calendar.MONTH) + 1);
            buff.append("-");
            fmt.format("%1$02d", db.get(Calendar.DAY_OF_MONTH));
            buff.append(" ");
            fmt.format("%1$02d", db.get(Calendar.HOUR_OF_DAY));
            buff.append(":");
            fmt.format("%1$02d", db.get(Calendar.MINUTE));
            buff.append(":");
            fmt.format("%1$02d", db.get(Calendar.SECOND));
            fmt.close();
            return (buff.toString());
        }
    }

    public static String getTZDateString(Calendar val) {
        if (val == null) {
            return ("null");
        } else {
            Calendar db = CFLibDbUtil.getDbServerCalendar(val);
            StringBuffer buff = new StringBuffer();
            Formatter fmt = new Formatter(buff);
            fmt.format("%1$04d", db.get(Calendar.YEAR));
            buff.append("-");
            fmt.format("%1$02d", db.get(Calendar.MONTH) + 1);
            buff.append("-");
            fmt.format("%1$02d", db.get(Calendar.DAY_OF_MONTH));
            buff.append(" ");
            fmt.format("%1$02d", db.get(Calendar.HOUR_OF_DAY));
            buff.append(":");
            fmt.format("%1$02d", db.get(Calendar.MINUTE));
            buff.append(":");
            fmt.format("%1$02d", db.get(Calendar.SECOND));
            fmt.close();
            return (buff.toString());
        }
    }

    public static String getTZTimeString(Calendar val) {
        if (val == null) {
            return ("null");
        } else {
            Calendar db = CFLibDbUtil.getDbServerCalendar(val);
            StringBuffer buff = new StringBuffer();
            Formatter fmt = new Formatter(buff);
            fmt.format("%1$04d", db.get(Calendar.YEAR));
            buff.append("-");
            fmt.format("%1$02d", db.get(Calendar.MONTH) + 1);
            buff.append("-");
            fmt.format("%1$02d", db.get(Calendar.DAY_OF_MONTH));
            buff.append(" ");
            fmt.format("%1$02d", db.get(Calendar.HOUR_OF_DAY));
            buff.append(":");
            fmt.format("%1$02d", db.get(Calendar.MINUTE));
            buff.append(":");
            fmt.format("%1$02d", db.get(Calendar.SECOND));
            fmt.close();
            return (buff.toString());
        }
    }

    public static String getTZTimestampString(Calendar val) {
        if (val == null) {
            return ("null");
        } else {
            Calendar db = CFLibDbUtil.getDbServerCalendar(val);
            StringBuffer buff = new StringBuffer();
            Formatter fmt = new Formatter(buff);
            fmt.format("%1$04d", db.get(Calendar.YEAR));
            buff.append("-");
            fmt.format("%1$02d", db.get(Calendar.MONTH) + 1);
            buff.append("-");
            fmt.format("%1$02d", db.get(Calendar.DAY_OF_MONTH));
            buff.append(" ");
            fmt.format("%1$02d", db.get(Calendar.HOUR_OF_DAY));
            buff.append(":");
            fmt.format("%1$02d", db.get(Calendar.MINUTE));
            buff.append(":");
            fmt.format("%1$02d", db.get(Calendar.SECOND));
            fmt.close();
            return (buff.toString());
        }
    }

    public static String getUuidString(UUID val) {
        if (val == null) {
            return ("null");
        } else {
            return ("'" + val.toString() + "'");
        }
    }

    public static Calendar convertDateString(String val) {
        if ((val == null) || (val.length() == 0)) {
            return (null);
        } else if (val.length() != 10) {
            throw CFLib.getDefaultExceptionFactory().newUsageException(CFAstXMsgClientSchema.class,
                    "convertDateString", "Value must be in YYYY-MM-DD format, \"" + val + "\" is invalid");
        } else if (((val.charAt(0) >= '0') && (val.charAt(0) <= '9'))
                && ((val.charAt(1) >= '0') && (val.charAt(1) <= '9'))
                && ((val.charAt(2) >= '0') && (val.charAt(2) <= '9'))
                && ((val.charAt(3) >= '0') && (val.charAt(3) <= '9')) && (val.charAt(4) == '-')
                && ((val.charAt(5) >= '0') && (val.charAt(5) <= '1'))
                && ((val.charAt(6) >= '0') && (val.charAt(6) <= '9')) && (val.charAt(7) == '-')
                && ((val.charAt(8) >= '0') && (val.charAt(8) <= '3'))
                && ((val.charAt(9) >= '0') && (val.charAt(9) <= '9'))) {
            /*
             *   NOTE:
             *      .Net uses substring( startcol, lengthOfSubstring )
             *      Java uses substring( startcol, endcol ) and does not
             *         include charAt( endcol );
             */
            int year = Integer.parseInt(val.substring(0, 4));
            int month = Integer.parseInt(val.substring(5, 7));
            int day = Integer.parseInt(val.substring(8, 10));
            Calendar retval = new GregorianCalendar(CFLibDbUtil.getDbServerTimeZone());
            retval.set(Calendar.YEAR, year);
            retval.set(Calendar.MONTH, month - 1);
            retval.set(Calendar.DAY_OF_MONTH, day);
            retval.set(Calendar.HOUR_OF_DAY, 0);
            retval.set(Calendar.MINUTE, 0);
            retval.set(Calendar.SECOND, 0);
            Calendar local = new GregorianCalendar();
            local.setTimeInMillis(retval.getTimeInMillis());
            return (local);
        } else {
            throw CFLib.getDefaultExceptionFactory().newUsageException(CFAstXMsgClientSchema.class,
                    "convertDateString", "Value must be in YYYY-MM-DD format, \"" + val + "\" is invalid");
        }
    }

    public static Calendar convertTimeString(String val) {
        if ((val == null) || (val.length() == 0)) {
            return (null);
        } else if (val.length() != 8) {
            throw CFLib.getDefaultExceptionFactory().newUsageException(CFAstXMsgClientSchema.class,
                    "convertTimeString", "Value must be in HH24:MI:SS format, \"" + val + "\" is invalid");
        } else if (((val.charAt(0) >= '0') && (val.charAt(0) <= '2'))
                && ((val.charAt(1) >= '0') && (val.charAt(1) <= '9')) && (val.charAt(2) == ':')
                && ((val.charAt(3) >= '0') && (val.charAt(3) <= '5'))
                && ((val.charAt(4) >= '0') && (val.charAt(4) <= '9')) && (val.charAt(5) == ':')
                && ((val.charAt(6) >= '0') && (val.charAt(6) <= '5'))
                && ((val.charAt(7) >= '0') && (val.charAt(7) <= '9'))) {
            /*
             *   NOTE:
             *      .Net uses substring( startcol, lengthOfSubstring )
             *      Java uses substring( startcol, endcol ) and does not
             *         include charAt( endcol );
             */
            int hour = Integer.parseInt(val.substring(0, 2));
            int minute = Integer.parseInt(val.substring(3, 5));
            int second = Integer.parseInt(val.substring(6, 8));
            Calendar retval = new GregorianCalendar(CFLibDbUtil.getDbServerTimeZone());
            retval.set(Calendar.YEAR, 2000);
            retval.set(Calendar.MONTH, 0);
            retval.set(Calendar.DAY_OF_MONTH, 1);
            retval.set(Calendar.HOUR_OF_DAY, hour);
            retval.set(Calendar.MINUTE, minute);
            retval.set(Calendar.SECOND, second);
            Calendar local = new GregorianCalendar();
            local.setTimeInMillis(retval.getTimeInMillis());
            return (local);
        } else {
            throw CFLib.getDefaultExceptionFactory().newUsageException(CFAstXMsgClientSchema.class,
                    "convertTimeString", "Value must be in HH24:MI:SS format \"" + val + "\" is invalid");
        }
    }

    public static Calendar convertTimestampString(String val) {
        if ((val == null) || (val.length() == 0)) {
            return (null);
        } else if (val.length() != 19) {
            throw CFLib.getDefaultExceptionFactory().newUsageException(CFAstXMsgClientSchema.class,
                    "convertTimestampString",
                    "Value must be in YYYY-MM-DD HH24:MI:SS format \"" + val + "\" is invalid");
        } else if (((val.charAt(0) >= '0') && (val.charAt(0) <= '9'))
                && ((val.charAt(1) >= '0') && (val.charAt(1) <= '9'))
                && ((val.charAt(2) >= '0') && (val.charAt(2) <= '9'))
                && ((val.charAt(3) >= '0') && (val.charAt(3) <= '9')) && (val.charAt(4) == '-')
                && ((val.charAt(5) >= '0') && (val.charAt(5) <= '1'))
                && ((val.charAt(6) >= '0') && (val.charAt(6) <= '9')) && (val.charAt(7) == '-')
                && ((val.charAt(8) >= '0') && (val.charAt(8) <= '3'))
                && ((val.charAt(9) >= '0') && (val.charAt(9) <= '9')) && (val.charAt(10) == ' ')
                && ((val.charAt(11) >= '0') && (val.charAt(11) <= '2'))
                && ((val.charAt(12) >= '0') && (val.charAt(12) <= '9')) && (val.charAt(13) == ':')
                && ((val.charAt(14) >= '0') && (val.charAt(14) <= '5'))
                && ((val.charAt(15) >= '0') && (val.charAt(15) <= '9')) && (val.charAt(16) == ':')
                && ((val.charAt(17) >= '0') && (val.charAt(17) <= '5'))
                && ((val.charAt(18) >= '0') && (val.charAt(18) <= '9'))) {
            /*
             *   NOTE:
             *      .Net uses substring( startcol, lengthOfSubstring )
             *      Java uses substring( startcol, endcol ) and does not
             *         include charAt( endcol );
             */
            int year = Integer.parseInt(val.substring(0, 4));
            int month = Integer.parseInt(val.substring(5, 7));
            int day = Integer.parseInt(val.substring(8, 10));
            int hour = Integer.parseInt(val.substring(11, 13));
            int minute = Integer.parseInt(val.substring(14, 16));
            int second = Integer.parseInt(val.substring(17, 19));
            Calendar retval = new GregorianCalendar(CFLibDbUtil.getDbServerTimeZone());
            retval.set(Calendar.YEAR, year);
            retval.set(Calendar.MONTH, month - 1);
            retval.set(Calendar.DAY_OF_MONTH, day);
            retval.set(Calendar.HOUR_OF_DAY, hour);
            retval.set(Calendar.MINUTE, minute);
            retval.set(Calendar.SECOND, second);
            Calendar local = new GregorianCalendar();
            local.setTimeInMillis(retval.getTimeInMillis());
            return (local);
        } else {
            throw CFLib.getDefaultExceptionFactory().newUsageException(CFAstXMsgClientSchema.class,
                    "convertTimestampString",
                    "Value must be in YYYY-MM-DD HH24:MI:SS format \"" + val + "\" is invalid");
        }
    }

    public static Calendar convertTZDateString(String val) {
        if ((val == null) || (val.length() == 0)) {
            return (null);
        } else if (val.length() != 19) {
            throw CFLib.getDefaultExceptionFactory().newUsageException(CFAstXMsgClientSchema.class,
                    "convertTZDateString",
                    "Value must be in YYYY-MM-DD HH24:MI:SS format \"" + val + "\" is invalid");
        } else if (((val.charAt(0) >= '0') && (val.charAt(0) <= '9'))
                && ((val.charAt(1) >= '0') && (val.charAt(1) <= '9'))
                && ((val.charAt(2) >= '0') && (val.charAt(2) <= '9'))
                && ((val.charAt(3) >= '0') && (val.charAt(3) <= '9')) && (val.charAt(4) == '-')
                && ((val.charAt(5) >= '0') && (val.charAt(5) <= '1'))
                && ((val.charAt(6) >= '0') && (val.charAt(6) <= '9')) && (val.charAt(7) == '-')
                && ((val.charAt(8) >= '0') && (val.charAt(8) <= '3'))
                && ((val.charAt(9) >= '0') && (val.charAt(9) <= '9')) && (val.charAt(10) == ' ')
                && ((val.charAt(11) >= '0') && (val.charAt(11) <= '2'))
                && ((val.charAt(12) >= '0') && (val.charAt(12) <= '9')) && (val.charAt(13) == ':')
                && ((val.charAt(14) >= '0') && (val.charAt(14) <= '5'))
                && ((val.charAt(15) >= '0') && (val.charAt(15) <= '9')) && (val.charAt(16) == ':')
                && ((val.charAt(17) >= '0') && (val.charAt(17) <= '5'))
                && ((val.charAt(18) >= '0') && (val.charAt(18) <= '9'))) {
            /*
             *   NOTE:
             *      .Net uses substring( startcol, lengthOfSubstring )
             *      Java uses substring( startcol, endcol ) and does not
             *         include charAt( endcol );
             */
            int year = Integer.parseInt(val.substring(0, 4));
            int month = Integer.parseInt(val.substring(5, 7));
            int day = Integer.parseInt(val.substring(8, 10));
            int hour = Integer.parseInt(val.substring(11, 13));
            int minute = Integer.parseInt(val.substring(14, 16));
            int second = Integer.parseInt(val.substring(17, 19));
            Calendar retval = new GregorianCalendar(CFLibDbUtil.getDbServerTimeZone());
            retval.set(Calendar.YEAR, year);
            retval.set(Calendar.MONTH, month - 1);
            retval.set(Calendar.DAY_OF_MONTH, day);
            retval.set(Calendar.HOUR_OF_DAY, hour);
            retval.set(Calendar.MINUTE, minute);
            retval.set(Calendar.SECOND, second);
            Calendar utc = CFLibDbUtil.getUTCCalendar(retval);
            return (utc);
        } else {
            throw CFLib.getDefaultExceptionFactory().newUsageException(CFAstXMsgClientSchema.class,
                    "convertTZDateString",
                    "Value must be in YYYY-MM-DD HH24:MI:SS format \"" + val + "\" is invalid");
        }
    }

    public static Calendar convertTZTimeString(String val) {
        if ((val == null) || (val.length() == 0)) {
            return (null);
        } else if (val.length() != 19) {
            throw CFLib.getDefaultExceptionFactory().newUsageException(CFAstXMsgClientSchema.class,
                    "convertTZTimeString",
                    "Value must be in YYYY-MM-DD HH24:MI:SS format \"" + val + "\" is invalid");
        } else if (((val.charAt(0) >= '0') && (val.charAt(0) <= '9'))
                && ((val.charAt(1) >= '0') && (val.charAt(1) <= '9'))
                && ((val.charAt(2) >= '0') && (val.charAt(2) <= '9'))
                && ((val.charAt(3) >= '0') && (val.charAt(3) <= '9')) && (val.charAt(4) == '-')
                && ((val.charAt(5) >= '0') && (val.charAt(5) <= '1'))
                && ((val.charAt(6) >= '0') && (val.charAt(6) <= '9')) && (val.charAt(7) == '-')
                && ((val.charAt(8) >= '0') && (val.charAt(8) <= '3'))
                && ((val.charAt(9) >= '0') && (val.charAt(9) <= '9')) && (val.charAt(10) == ' ')
                && ((val.charAt(11) >= '0') && (val.charAt(11) <= '2'))
                && ((val.charAt(12) >= '0') && (val.charAt(12) <= '9')) && (val.charAt(13) == ':')
                && ((val.charAt(14) >= '0') && (val.charAt(14) <= '5'))
                && ((val.charAt(15) >= '0') && (val.charAt(15) <= '9')) && (val.charAt(16) == ':')
                && ((val.charAt(17) >= '0') && (val.charAt(17) <= '5'))
                && ((val.charAt(18) >= '0') && (val.charAt(18) <= '9'))) {
            /*
             *   NOTE:
             *      .Net uses substring( startcol, lengthOfSubstring )
             *      Java uses substring( startcol, endcol ) and does not
             *         include charAt( endcol );
             */
            int year = Integer.parseInt(val.substring(0, 4));
            int month = Integer.parseInt(val.substring(5, 7));
            int day = Integer.parseInt(val.substring(8, 10));
            int hour = Integer.parseInt(val.substring(11, 13));
            int minute = Integer.parseInt(val.substring(14, 16));
            int second = Integer.parseInt(val.substring(17, 19));
            Calendar retval = new GregorianCalendar(CFLibDbUtil.getDbServerTimeZone());
            retval.set(Calendar.YEAR, year);
            retval.set(Calendar.MONTH, month - 1);
            retval.set(Calendar.DAY_OF_MONTH, day);
            retval.set(Calendar.HOUR_OF_DAY, hour);
            retval.set(Calendar.MINUTE, minute);
            retval.set(Calendar.SECOND, second);
            Calendar utc = CFLibDbUtil.getUTCCalendar(retval);
            return (utc);
        } else {
            throw CFLib.getDefaultExceptionFactory().newUsageException(CFAstXMsgClientSchema.class,
                    "convertTZTimeString",
                    "Value must be in YYYY-MM-DD HH24:MI:SS format \"" + val + "\" is invalid");
        }
    }

    public static Calendar convertTZTimestampString(String val) {
        if ((val == null) || (val.length() == 0)) {
            return (null);
        } else if (val.length() != 19) {
            throw CFLib.getDefaultExceptionFactory().newUsageException(CFAstXMsgClientSchema.class,
                    "convertTZTimestampString",
                    "Value must be in YYYY-MM-DD HH24:MI:SS format \"" + val + "\" is invalid");
        } else if (((val.charAt(0) >= '0') && (val.charAt(0) <= '9'))
                && ((val.charAt(1) >= '0') && (val.charAt(1) <= '9'))
                && ((val.charAt(2) >= '0') && (val.charAt(2) <= '9'))
                && ((val.charAt(3) >= '0') && (val.charAt(3) <= '9')) && (val.charAt(4) == '-')
                && ((val.charAt(5) >= '0') && (val.charAt(5) <= '1'))
                && ((val.charAt(6) >= '0') && (val.charAt(6) <= '9')) && (val.charAt(7) == '-')
                && ((val.charAt(8) >= '0') && (val.charAt(8) <= '3'))
                && ((val.charAt(9) >= '0') && (val.charAt(9) <= '9')) && (val.charAt(10) == ' ')
                && ((val.charAt(11) >= '0') && (val.charAt(11) <= '2'))
                && ((val.charAt(12) >= '0') && (val.charAt(12) <= '9')) && (val.charAt(13) == ':')
                && ((val.charAt(14) >= '0') && (val.charAt(14) <= '5'))
                && ((val.charAt(15) >= '0') && (val.charAt(15) <= '9')) && (val.charAt(16) == ':')
                && ((val.charAt(17) >= '0') && (val.charAt(17) <= '5'))
                && ((val.charAt(18) >= '0') && (val.charAt(18) <= '9'))) {
            /*
             *   NOTE:
             *      .Net uses substring( startcol, lengthOfSubstring )
             *      Java uses substring( startcol, endcol ) and does not
             *         include charAt( endcol );
             */
            int year = Integer.parseInt(val.substring(0, 4));
            int month = Integer.parseInt(val.substring(5, 7));
            int day = Integer.parseInt(val.substring(8, 10));
            int hour = Integer.parseInt(val.substring(11, 13));
            int minute = Integer.parseInt(val.substring(14, 16));
            int second = Integer.parseInt(val.substring(17, 19));
            Calendar retval = new GregorianCalendar(CFLibDbUtil.getDbServerTimeZone());
            retval.set(Calendar.YEAR, year);
            retval.set(Calendar.MONTH, month - 1);
            retval.set(Calendar.DAY_OF_MONTH, day);
            retval.set(Calendar.HOUR_OF_DAY, hour);
            retval.set(Calendar.MINUTE, minute);
            retval.set(Calendar.SECOND, second);
            Calendar utc = CFLibDbUtil.getUTCCalendar(retval);
            return (utc);
        } else {
            throw CFLib.getDefaultExceptionFactory().newUsageException(CFAstXMsgClientSchema.class,
                    "convertTZTimestampString",
                    "Value must be in YYYY-MM-DD HH24:MI:SS format \"" + val + "\" is invalid");
        }
    }

    public static UUID convertUuidString(String val) {
        if ((val == null) || (val.length() == 0)) {
            return (null);
        } else {
            return (UUID.fromString(val));
        }
    }
}