Example usage for java.lang Short Short

List of usage examples for java.lang Short Short

Introduction

In this page you can find the example usage for java.lang Short Short.

Prototype

@Deprecated(since = "9")
public Short(String s) throws NumberFormatException 

Source Link

Document

Constructs a newly allocated Short object that represents the short value indicated by the String parameter.

Usage

From source file:net.sourceforge.msscodefactory.cfcore.v2_0.CFGenKbXMsgRspnHandler.CFGenKbXMsgRspnTokenFormatterUpdatedHandler.java

public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
    try {/*  w ww  .j  ava 2s  .  co  m*/
        // Common XML Attributes
        String attrId = null;
        String attrRevision = null;
        // GenItem Attributes
        String attrTenantId = null;
        String attrCartridgeId = null;
        String attrItemId = null;
        String attrRuleTypeId = null;
        String attrName = null;
        String attrToolSetId = null;
        String attrScopeDefId = null;
        String attrGenDefId = null;
        String attrGelExecutableId = null;
        // GenBind Attributes
        // GenFormatter Attributes
        // TokenFormatter Attributes
        // Attribute Extraction
        String attrLocalName;
        int numAttrs;
        int idxAttr;
        final String S_ProcName = "startElement";
        final String S_LocalName = "LocalName";

        assert qName.equals("RspnTokenFormatterUpdated");

        CFGenKbXMsgRspnHandler xmsgRspnHandler = (CFGenKbXMsgRspnHandler) getParser();
        if (xmsgRspnHandler == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "getParser()");
        }

        ICFGenKbSchemaObj schemaObj = xmsgRspnHandler.getSchemaObj();
        if (schemaObj == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "getParser().getSchemaObj()");
        }

        // Extract Attributes
        numAttrs = attrs.getLength();
        for (idxAttr = 0; idxAttr < numAttrs; idxAttr++) {
            attrLocalName = attrs.getLocalName(idxAttr);
            if (attrLocalName.equals("Id")) {
                if (attrId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("Revision")) {
                if (attrRevision != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrRevision = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("TenantId")) {
                if (attrTenantId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrTenantId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("CartridgeId")) {
                if (attrCartridgeId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCartridgeId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ItemId")) {
                if (attrItemId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrItemId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("RuleTypeId")) {
                if (attrRuleTypeId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrRuleTypeId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("Name")) {
                if (attrName != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrName = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ToolSetId")) {
                if (attrToolSetId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrToolSetId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ScopeDefId")) {
                if (attrScopeDefId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrScopeDefId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("GenDefId")) {
                if (attrGenDefId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrGenDefId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("GelExecutableId")) {
                if (attrGelExecutableId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrGelExecutableId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("schemaLocation")) {
                // ignored
            } else {
                throw CFLib.getDefaultExceptionFactory().newUnrecognizedAttributeException(getClass(),
                        S_ProcName, getParser().getLocationInfo(), attrLocalName);
            }
        }

        // Ensure that required attributes have values
        if ((attrTenantId == null) || (attrTenantId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "TenantId");
        }
        if ((attrCartridgeId == null) || (attrCartridgeId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "CartridgeId");
        }
        if ((attrItemId == null) || (attrItemId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "ItemId");
        }
        if ((attrRuleTypeId == null) || (attrRuleTypeId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "RuleTypeId");
        }
        if (attrName == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "Name");
        }
        if ((attrToolSetId == null) || (attrToolSetId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "ToolSetId");
        }
        if ((attrGenDefId == null) || (attrGenDefId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "GenDefId");
        }
        if ((attrRevision == null) || (attrRevision.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "Revision");
        }

        // Save named attributes to context
        CFLibXmlCoreContext curContext = getParser().getCurContext();

        // Convert string attributes to native Java types

        long natTenantId = Long.parseLong(attrTenantId);

        long natCartridgeId = Long.parseLong(attrCartridgeId);

        int natItemId = Integer.parseInt(attrItemId);

        short natRuleTypeId = Short.parseShort(attrRuleTypeId);

        String natName = attrName;

        short natToolSetId = Short.parseShort(attrToolSetId);

        Short natScopeDefId;
        if ((attrScopeDefId == null) || (attrScopeDefId.length() <= 0)) {
            natScopeDefId = null;
        } else {
            natScopeDefId = new Short(Short.parseShort(attrScopeDefId));
        }

        short natGenDefId = Short.parseShort(attrGenDefId);

        Integer natGelExecutableId;
        if ((attrGelExecutableId == null) || (attrGelExecutableId.length() <= 0)) {
            natGelExecutableId = null;
        } else {
            natGelExecutableId = new Integer(Integer.parseInt(attrGelExecutableId));
        }

        int natRevision = Integer.parseInt(attrRevision);
        // Instantiate a buffer for the parsed information
        ICFGenKbTokenFormatterObj obj = schemaObj.getTokenFormatterTableObj().newInstance();
        CFGenKbTokenFormatterBuff dataBuff = obj.getTokenFormatterBuff();
        dataBuff.setRequiredTenantId(natTenantId);
        dataBuff.setRequiredCartridgeId(natCartridgeId);
        dataBuff.setRequiredItemId(natItemId);
        dataBuff.setRequiredRuleTypeId(natRuleTypeId);
        dataBuff.setRequiredName(natName);
        dataBuff.setRequiredToolSetId(natToolSetId);
        dataBuff.setOptionalScopeDefId(natScopeDefId);
        dataBuff.setRequiredGenDefId(natGenDefId);
        dataBuff.setOptionalGelExecutableId(natGelExecutableId);
        dataBuff.setRequiredRevision(natRevision);
        obj.copyBuffToPKey();
        ICFGenKbTokenFormatterObj realized = (ICFGenKbTokenFormatterObj) obj.realize();
        xmsgRspnHandler.setLastObjectProcessed(realized);
    } catch (RuntimeException e) {
        throw new RuntimeException("Near " + getParser().getLocationInfo() + ": Caught and rethrew "
                + e.getClass().getName() + " - " + e.getMessage(), e);
    } catch (Error e) {
        throw new Error("Near " + getParser().getLocationInfo() + ": Caught and rethrew "
                + e.getClass().getName() + " - " + e.getMessage(), e);
    }
}

From source file:com.feilong.commons.core.lang.ObjectUtil.java

/**
 * object to short./*from  ww w .j  a v a2s. c o  m*/
 * 
 * @param value
 *            the value
 * @return the short
 */
public static final Short toShort(Object value) {
    if (Validator.isNotNullOrEmpty(value)) {
        if (value instanceof Short) {
            return (Short) value;
        }
        return new Short(value.toString());
    }
    return null;
}

From source file:net.sourceforge.msscodefactory.cfcore.v2_0.CFGenKbXMsgRspnHandler.CFGenKbXMsgRspnNumberFormatterLockedHandler.java

public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
    try {/*  w  w w  .  java2s.c om*/
        // Common XML Attributes
        String attrId = null;
        String attrRevision = null;
        // GenItem Attributes
        String attrTenantId = null;
        String attrCartridgeId = null;
        String attrItemId = null;
        String attrRuleTypeId = null;
        String attrName = null;
        String attrToolSetId = null;
        String attrScopeDefId = null;
        String attrGenDefId = null;
        String attrGelExecutableId = null;
        // GenBind Attributes
        // GenFormatter Attributes
        // NumberFormatter Attributes
        // Attribute Extraction
        String attrLocalName;
        int numAttrs;
        int idxAttr;
        final String S_ProcName = "startElement";
        final String S_LocalName = "LocalName";

        assert qName.equals("RspnNumberFormatterLocked");

        CFGenKbXMsgRspnHandler xmsgRspnHandler = (CFGenKbXMsgRspnHandler) getParser();
        if (xmsgRspnHandler == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "getParser()");
        }

        ICFGenKbSchemaObj schemaObj = xmsgRspnHandler.getSchemaObj();
        if (schemaObj == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "getParser().getSchemaObj()");
        }

        // Extract Attributes
        numAttrs = attrs.getLength();
        for (idxAttr = 0; idxAttr < numAttrs; idxAttr++) {
            attrLocalName = attrs.getLocalName(idxAttr);
            if (attrLocalName.equals("Id")) {
                if (attrId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("Revision")) {
                if (attrRevision != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrRevision = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("TenantId")) {
                if (attrTenantId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrTenantId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("CartridgeId")) {
                if (attrCartridgeId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCartridgeId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ItemId")) {
                if (attrItemId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrItemId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("RuleTypeId")) {
                if (attrRuleTypeId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrRuleTypeId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("Name")) {
                if (attrName != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrName = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ToolSetId")) {
                if (attrToolSetId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrToolSetId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ScopeDefId")) {
                if (attrScopeDefId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrScopeDefId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("GenDefId")) {
                if (attrGenDefId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrGenDefId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("GelExecutableId")) {
                if (attrGelExecutableId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrGelExecutableId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("schemaLocation")) {
                // ignored
            } else {
                throw CFLib.getDefaultExceptionFactory().newUnrecognizedAttributeException(getClass(),
                        S_ProcName, getParser().getLocationInfo(), attrLocalName);
            }
        }

        // Ensure that required attributes have values
        if ((attrTenantId == null) || (attrTenantId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "TenantId");
        }
        if ((attrCartridgeId == null) || (attrCartridgeId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "CartridgeId");
        }
        if ((attrItemId == null) || (attrItemId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "ItemId");
        }
        if ((attrRuleTypeId == null) || (attrRuleTypeId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "RuleTypeId");
        }
        if (attrName == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "Name");
        }
        if ((attrToolSetId == null) || (attrToolSetId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "ToolSetId");
        }
        if ((attrGenDefId == null) || (attrGenDefId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "GenDefId");
        }
        if ((attrRevision == null) || (attrRevision.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "Revision");
        }

        // Save named attributes to context
        CFLibXmlCoreContext curContext = getParser().getCurContext();

        // Convert string attributes to native Java types

        long natTenantId = Long.parseLong(attrTenantId);

        long natCartridgeId = Long.parseLong(attrCartridgeId);

        int natItemId = Integer.parseInt(attrItemId);

        short natRuleTypeId = Short.parseShort(attrRuleTypeId);

        String natName = attrName;

        short natToolSetId = Short.parseShort(attrToolSetId);

        Short natScopeDefId;
        if ((attrScopeDefId == null) || (attrScopeDefId.length() <= 0)) {
            natScopeDefId = null;
        } else {
            natScopeDefId = new Short(Short.parseShort(attrScopeDefId));
        }

        short natGenDefId = Short.parseShort(attrGenDefId);

        Integer natGelExecutableId;
        if ((attrGelExecutableId == null) || (attrGelExecutableId.length() <= 0)) {
            natGelExecutableId = null;
        } else {
            natGelExecutableId = new Integer(Integer.parseInt(attrGelExecutableId));
        }

        int natRevision = Integer.parseInt(attrRevision);
        // Instantiate a buffer for the parsed information
        ICFGenKbNumberFormatterObj obj = schemaObj.getNumberFormatterTableObj().newInstance();
        CFGenKbNumberFormatterBuff dataBuff = obj.getNumberFormatterBuff();
        dataBuff.setRequiredTenantId(natTenantId);
        dataBuff.setRequiredCartridgeId(natCartridgeId);
        dataBuff.setRequiredItemId(natItemId);
        dataBuff.setRequiredRuleTypeId(natRuleTypeId);
        dataBuff.setRequiredName(natName);
        dataBuff.setRequiredToolSetId(natToolSetId);
        dataBuff.setOptionalScopeDefId(natScopeDefId);
        dataBuff.setRequiredGenDefId(natGenDefId);
        dataBuff.setOptionalGelExecutableId(natGelExecutableId);
        dataBuff.setRequiredRevision(natRevision);
        obj.copyBuffToPKey();
        ICFGenKbNumberFormatterObj realized = (ICFGenKbNumberFormatterObj) obj.realize();
        xmsgRspnHandler.setLastObjectProcessed(realized);
    } catch (RuntimeException e) {
        throw new RuntimeException("Near " + getParser().getLocationInfo() + ": Caught and rethrew "
                + e.getClass().getName() + " - " + e.getMessage(), e);
    } catch (Error e) {
        throw new Error("Near " + getParser().getLocationInfo() + ": Caught and rethrew "
                + e.getClass().getName() + " - " + e.getMessage(), e);
    }
}

From source file:net.sourceforge.msscodefactory.cfcore.v2_0.CFGenKbXMsgRspnHandler.CFGenKbXMsgRspnStringFormatterLockedHandler.java

public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
    try {//  ww w .  ja  va  2s . co  m
        // Common XML Attributes
        String attrId = null;
        String attrRevision = null;
        // GenItem Attributes
        String attrTenantId = null;
        String attrCartridgeId = null;
        String attrItemId = null;
        String attrRuleTypeId = null;
        String attrName = null;
        String attrToolSetId = null;
        String attrScopeDefId = null;
        String attrGenDefId = null;
        String attrGelExecutableId = null;
        // GenBind Attributes
        // GenFormatter Attributes
        // StringFormatter Attributes
        // Attribute Extraction
        String attrLocalName;
        int numAttrs;
        int idxAttr;
        final String S_ProcName = "startElement";
        final String S_LocalName = "LocalName";

        assert qName.equals("RspnStringFormatterLocked");

        CFGenKbXMsgRspnHandler xmsgRspnHandler = (CFGenKbXMsgRspnHandler) getParser();
        if (xmsgRspnHandler == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "getParser()");
        }

        ICFGenKbSchemaObj schemaObj = xmsgRspnHandler.getSchemaObj();
        if (schemaObj == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "getParser().getSchemaObj()");
        }

        // Extract Attributes
        numAttrs = attrs.getLength();
        for (idxAttr = 0; idxAttr < numAttrs; idxAttr++) {
            attrLocalName = attrs.getLocalName(idxAttr);
            if (attrLocalName.equals("Id")) {
                if (attrId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("Revision")) {
                if (attrRevision != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrRevision = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("TenantId")) {
                if (attrTenantId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrTenantId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("CartridgeId")) {
                if (attrCartridgeId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCartridgeId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ItemId")) {
                if (attrItemId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrItemId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("RuleTypeId")) {
                if (attrRuleTypeId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrRuleTypeId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("Name")) {
                if (attrName != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrName = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ToolSetId")) {
                if (attrToolSetId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrToolSetId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ScopeDefId")) {
                if (attrScopeDefId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrScopeDefId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("GenDefId")) {
                if (attrGenDefId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrGenDefId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("GelExecutableId")) {
                if (attrGelExecutableId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrGelExecutableId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("schemaLocation")) {
                // ignored
            } else {
                throw CFLib.getDefaultExceptionFactory().newUnrecognizedAttributeException(getClass(),
                        S_ProcName, getParser().getLocationInfo(), attrLocalName);
            }
        }

        // Ensure that required attributes have values
        if ((attrTenantId == null) || (attrTenantId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "TenantId");
        }
        if ((attrCartridgeId == null) || (attrCartridgeId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "CartridgeId");
        }
        if ((attrItemId == null) || (attrItemId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "ItemId");
        }
        if ((attrRuleTypeId == null) || (attrRuleTypeId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "RuleTypeId");
        }
        if (attrName == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "Name");
        }
        if ((attrToolSetId == null) || (attrToolSetId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "ToolSetId");
        }
        if ((attrGenDefId == null) || (attrGenDefId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "GenDefId");
        }
        if ((attrRevision == null) || (attrRevision.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "Revision");
        }

        // Save named attributes to context
        CFLibXmlCoreContext curContext = getParser().getCurContext();

        // Convert string attributes to native Java types

        long natTenantId = Long.parseLong(attrTenantId);

        long natCartridgeId = Long.parseLong(attrCartridgeId);

        int natItemId = Integer.parseInt(attrItemId);

        short natRuleTypeId = Short.parseShort(attrRuleTypeId);

        String natName = attrName;

        short natToolSetId = Short.parseShort(attrToolSetId);

        Short natScopeDefId;
        if ((attrScopeDefId == null) || (attrScopeDefId.length() <= 0)) {
            natScopeDefId = null;
        } else {
            natScopeDefId = new Short(Short.parseShort(attrScopeDefId));
        }

        short natGenDefId = Short.parseShort(attrGenDefId);

        Integer natGelExecutableId;
        if ((attrGelExecutableId == null) || (attrGelExecutableId.length() <= 0)) {
            natGelExecutableId = null;
        } else {
            natGelExecutableId = new Integer(Integer.parseInt(attrGelExecutableId));
        }

        int natRevision = Integer.parseInt(attrRevision);
        // Instantiate a buffer for the parsed information
        ICFGenKbStringFormatterObj obj = schemaObj.getStringFormatterTableObj().newInstance();
        CFGenKbStringFormatterBuff dataBuff = obj.getStringFormatterBuff();
        dataBuff.setRequiredTenantId(natTenantId);
        dataBuff.setRequiredCartridgeId(natCartridgeId);
        dataBuff.setRequiredItemId(natItemId);
        dataBuff.setRequiredRuleTypeId(natRuleTypeId);
        dataBuff.setRequiredName(natName);
        dataBuff.setRequiredToolSetId(natToolSetId);
        dataBuff.setOptionalScopeDefId(natScopeDefId);
        dataBuff.setRequiredGenDefId(natGenDefId);
        dataBuff.setOptionalGelExecutableId(natGelExecutableId);
        dataBuff.setRequiredRevision(natRevision);
        obj.copyBuffToPKey();
        ICFGenKbStringFormatterObj realized = (ICFGenKbStringFormatterObj) obj.realize();
        xmsgRspnHandler.setLastObjectProcessed(realized);
    } catch (RuntimeException e) {
        throw new RuntimeException("Near " + getParser().getLocationInfo() + ": Caught and rethrew "
                + e.getClass().getName() + " - " + e.getMessage(), e);
    } catch (Error e) {
        throw new Error("Near " + getParser().getLocationInfo() + ": Caught and rethrew "
                + e.getClass().getName() + " - " + e.getMessage(), e);
    }
}

From source file:net.sourceforge.msscodefactory.cfcore.v2_0.CFGenKbXMsgRspnHandler.CFGenKbXMsgRspnTZDateFormatterLockedHandler.java

public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
    try {//from  w  ww .j  a v a 2 s .  c o m
        // Common XML Attributes
        String attrId = null;
        String attrRevision = null;
        // GenItem Attributes
        String attrTenantId = null;
        String attrCartridgeId = null;
        String attrItemId = null;
        String attrRuleTypeId = null;
        String attrName = null;
        String attrToolSetId = null;
        String attrScopeDefId = null;
        String attrGenDefId = null;
        String attrGelExecutableId = null;
        // GenBind Attributes
        // GenFormatter Attributes
        // TZDateFormatter Attributes
        // Attribute Extraction
        String attrLocalName;
        int numAttrs;
        int idxAttr;
        final String S_ProcName = "startElement";
        final String S_LocalName = "LocalName";

        assert qName.equals("RspnTZDateFormatterLocked");

        CFGenKbXMsgRspnHandler xmsgRspnHandler = (CFGenKbXMsgRspnHandler) getParser();
        if (xmsgRspnHandler == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "getParser()");
        }

        ICFGenKbSchemaObj schemaObj = xmsgRspnHandler.getSchemaObj();
        if (schemaObj == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "getParser().getSchemaObj()");
        }

        // Extract Attributes
        numAttrs = attrs.getLength();
        for (idxAttr = 0; idxAttr < numAttrs; idxAttr++) {
            attrLocalName = attrs.getLocalName(idxAttr);
            if (attrLocalName.equals("Id")) {
                if (attrId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("Revision")) {
                if (attrRevision != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrRevision = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("TenantId")) {
                if (attrTenantId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrTenantId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("CartridgeId")) {
                if (attrCartridgeId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCartridgeId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ItemId")) {
                if (attrItemId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrItemId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("RuleTypeId")) {
                if (attrRuleTypeId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrRuleTypeId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("Name")) {
                if (attrName != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrName = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ToolSetId")) {
                if (attrToolSetId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrToolSetId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ScopeDefId")) {
                if (attrScopeDefId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrScopeDefId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("GenDefId")) {
                if (attrGenDefId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrGenDefId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("GelExecutableId")) {
                if (attrGelExecutableId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrGelExecutableId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("schemaLocation")) {
                // ignored
            } else {
                throw CFLib.getDefaultExceptionFactory().newUnrecognizedAttributeException(getClass(),
                        S_ProcName, getParser().getLocationInfo(), attrLocalName);
            }
        }

        // Ensure that required attributes have values
        if ((attrTenantId == null) || (attrTenantId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "TenantId");
        }
        if ((attrCartridgeId == null) || (attrCartridgeId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "CartridgeId");
        }
        if ((attrItemId == null) || (attrItemId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "ItemId");
        }
        if ((attrRuleTypeId == null) || (attrRuleTypeId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "RuleTypeId");
        }
        if (attrName == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "Name");
        }
        if ((attrToolSetId == null) || (attrToolSetId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "ToolSetId");
        }
        if ((attrGenDefId == null) || (attrGenDefId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "GenDefId");
        }
        if ((attrRevision == null) || (attrRevision.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "Revision");
        }

        // Save named attributes to context
        CFLibXmlCoreContext curContext = getParser().getCurContext();

        // Convert string attributes to native Java types

        long natTenantId = Long.parseLong(attrTenantId);

        long natCartridgeId = Long.parseLong(attrCartridgeId);

        int natItemId = Integer.parseInt(attrItemId);

        short natRuleTypeId = Short.parseShort(attrRuleTypeId);

        String natName = attrName;

        short natToolSetId = Short.parseShort(attrToolSetId);

        Short natScopeDefId;
        if ((attrScopeDefId == null) || (attrScopeDefId.length() <= 0)) {
            natScopeDefId = null;
        } else {
            natScopeDefId = new Short(Short.parseShort(attrScopeDefId));
        }

        short natGenDefId = Short.parseShort(attrGenDefId);

        Integer natGelExecutableId;
        if ((attrGelExecutableId == null) || (attrGelExecutableId.length() <= 0)) {
            natGelExecutableId = null;
        } else {
            natGelExecutableId = new Integer(Integer.parseInt(attrGelExecutableId));
        }

        int natRevision = Integer.parseInt(attrRevision);
        // Instantiate a buffer for the parsed information
        ICFGenKbTZDateFormatterObj obj = schemaObj.getTZDateFormatterTableObj().newInstance();
        CFGenKbTZDateFormatterBuff dataBuff = obj.getTZDateFormatterBuff();
        dataBuff.setRequiredTenantId(natTenantId);
        dataBuff.setRequiredCartridgeId(natCartridgeId);
        dataBuff.setRequiredItemId(natItemId);
        dataBuff.setRequiredRuleTypeId(natRuleTypeId);
        dataBuff.setRequiredName(natName);
        dataBuff.setRequiredToolSetId(natToolSetId);
        dataBuff.setOptionalScopeDefId(natScopeDefId);
        dataBuff.setRequiredGenDefId(natGenDefId);
        dataBuff.setOptionalGelExecutableId(natGelExecutableId);
        dataBuff.setRequiredRevision(natRevision);
        obj.copyBuffToPKey();
        ICFGenKbTZDateFormatterObj realized = (ICFGenKbTZDateFormatterObj) obj.realize();
        xmsgRspnHandler.setLastObjectProcessed(realized);
    } catch (RuntimeException e) {
        throw new RuntimeException("Near " + getParser().getLocationInfo() + ": Caught and rethrew "
                + e.getClass().getName() + " - " + e.getMessage(), e);
    } catch (Error e) {
        throw new Error("Near " + getParser().getLocationInfo() + ": Caught and rethrew "
                + e.getClass().getName() + " - " + e.getMessage(), e);
    }
}

From source file:net.sourceforge.msscodefactory.cfcore.v2_0.CFGenKbXMsgRspnHandler.CFGenKbXMsgRspnTZTimeFormatterLockedHandler.java

public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
    try {//  w  w w .j a  va  2s  .c o m
        // Common XML Attributes
        String attrId = null;
        String attrRevision = null;
        // GenItem Attributes
        String attrTenantId = null;
        String attrCartridgeId = null;
        String attrItemId = null;
        String attrRuleTypeId = null;
        String attrName = null;
        String attrToolSetId = null;
        String attrScopeDefId = null;
        String attrGenDefId = null;
        String attrGelExecutableId = null;
        // GenBind Attributes
        // GenFormatter Attributes
        // TZTimeFormatter Attributes
        // Attribute Extraction
        String attrLocalName;
        int numAttrs;
        int idxAttr;
        final String S_ProcName = "startElement";
        final String S_LocalName = "LocalName";

        assert qName.equals("RspnTZTimeFormatterLocked");

        CFGenKbXMsgRspnHandler xmsgRspnHandler = (CFGenKbXMsgRspnHandler) getParser();
        if (xmsgRspnHandler == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "getParser()");
        }

        ICFGenKbSchemaObj schemaObj = xmsgRspnHandler.getSchemaObj();
        if (schemaObj == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "getParser().getSchemaObj()");
        }

        // Extract Attributes
        numAttrs = attrs.getLength();
        for (idxAttr = 0; idxAttr < numAttrs; idxAttr++) {
            attrLocalName = attrs.getLocalName(idxAttr);
            if (attrLocalName.equals("Id")) {
                if (attrId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("Revision")) {
                if (attrRevision != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrRevision = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("TenantId")) {
                if (attrTenantId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrTenantId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("CartridgeId")) {
                if (attrCartridgeId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCartridgeId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ItemId")) {
                if (attrItemId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrItemId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("RuleTypeId")) {
                if (attrRuleTypeId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrRuleTypeId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("Name")) {
                if (attrName != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrName = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ToolSetId")) {
                if (attrToolSetId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrToolSetId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ScopeDefId")) {
                if (attrScopeDefId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrScopeDefId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("GenDefId")) {
                if (attrGenDefId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrGenDefId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("GelExecutableId")) {
                if (attrGelExecutableId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrGelExecutableId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("schemaLocation")) {
                // ignored
            } else {
                throw CFLib.getDefaultExceptionFactory().newUnrecognizedAttributeException(getClass(),
                        S_ProcName, getParser().getLocationInfo(), attrLocalName);
            }
        }

        // Ensure that required attributes have values
        if ((attrTenantId == null) || (attrTenantId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "TenantId");
        }
        if ((attrCartridgeId == null) || (attrCartridgeId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "CartridgeId");
        }
        if ((attrItemId == null) || (attrItemId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "ItemId");
        }
        if ((attrRuleTypeId == null) || (attrRuleTypeId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "RuleTypeId");
        }
        if (attrName == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "Name");
        }
        if ((attrToolSetId == null) || (attrToolSetId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "ToolSetId");
        }
        if ((attrGenDefId == null) || (attrGenDefId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "GenDefId");
        }
        if ((attrRevision == null) || (attrRevision.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "Revision");
        }

        // Save named attributes to context
        CFLibXmlCoreContext curContext = getParser().getCurContext();

        // Convert string attributes to native Java types

        long natTenantId = Long.parseLong(attrTenantId);

        long natCartridgeId = Long.parseLong(attrCartridgeId);

        int natItemId = Integer.parseInt(attrItemId);

        short natRuleTypeId = Short.parseShort(attrRuleTypeId);

        String natName = attrName;

        short natToolSetId = Short.parseShort(attrToolSetId);

        Short natScopeDefId;
        if ((attrScopeDefId == null) || (attrScopeDefId.length() <= 0)) {
            natScopeDefId = null;
        } else {
            natScopeDefId = new Short(Short.parseShort(attrScopeDefId));
        }

        short natGenDefId = Short.parseShort(attrGenDefId);

        Integer natGelExecutableId;
        if ((attrGelExecutableId == null) || (attrGelExecutableId.length() <= 0)) {
            natGelExecutableId = null;
        } else {
            natGelExecutableId = new Integer(Integer.parseInt(attrGelExecutableId));
        }

        int natRevision = Integer.parseInt(attrRevision);
        // Instantiate a buffer for the parsed information
        ICFGenKbTZTimeFormatterObj obj = schemaObj.getTZTimeFormatterTableObj().newInstance();
        CFGenKbTZTimeFormatterBuff dataBuff = obj.getTZTimeFormatterBuff();
        dataBuff.setRequiredTenantId(natTenantId);
        dataBuff.setRequiredCartridgeId(natCartridgeId);
        dataBuff.setRequiredItemId(natItemId);
        dataBuff.setRequiredRuleTypeId(natRuleTypeId);
        dataBuff.setRequiredName(natName);
        dataBuff.setRequiredToolSetId(natToolSetId);
        dataBuff.setOptionalScopeDefId(natScopeDefId);
        dataBuff.setRequiredGenDefId(natGenDefId);
        dataBuff.setOptionalGelExecutableId(natGelExecutableId);
        dataBuff.setRequiredRevision(natRevision);
        obj.copyBuffToPKey();
        ICFGenKbTZTimeFormatterObj realized = (ICFGenKbTZTimeFormatterObj) obj.realize();
        xmsgRspnHandler.setLastObjectProcessed(realized);
    } catch (RuntimeException e) {
        throw new RuntimeException("Near " + getParser().getLocationInfo() + ": Caught and rethrew "
                + e.getClass().getName() + " - " + e.getMessage(), e);
    } catch (Error e) {
        throw new Error("Near " + getParser().getLocationInfo() + ": Caught and rethrew "
                + e.getClass().getName() + " - " + e.getMessage(), e);
    }
}

From source file:net.sourceforge.msscodefactory.cfcore.v2_0.CFGenKbXMsgRspnHandler.CFGenKbXMsgRspnUInt16FormatterLockedHandler.java

public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
    try {/*www. j  a v  a2 s  .c o m*/
        // Common XML Attributes
        String attrId = null;
        String attrRevision = null;
        // GenItem Attributes
        String attrTenantId = null;
        String attrCartridgeId = null;
        String attrItemId = null;
        String attrRuleTypeId = null;
        String attrName = null;
        String attrToolSetId = null;
        String attrScopeDefId = null;
        String attrGenDefId = null;
        String attrGelExecutableId = null;
        // GenBind Attributes
        // GenFormatter Attributes
        // UInt16Formatter Attributes
        // Attribute Extraction
        String attrLocalName;
        int numAttrs;
        int idxAttr;
        final String S_ProcName = "startElement";
        final String S_LocalName = "LocalName";

        assert qName.equals("RspnUInt16FormatterLocked");

        CFGenKbXMsgRspnHandler xmsgRspnHandler = (CFGenKbXMsgRspnHandler) getParser();
        if (xmsgRspnHandler == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "getParser()");
        }

        ICFGenKbSchemaObj schemaObj = xmsgRspnHandler.getSchemaObj();
        if (schemaObj == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "getParser().getSchemaObj()");
        }

        // Extract Attributes
        numAttrs = attrs.getLength();
        for (idxAttr = 0; idxAttr < numAttrs; idxAttr++) {
            attrLocalName = attrs.getLocalName(idxAttr);
            if (attrLocalName.equals("Id")) {
                if (attrId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("Revision")) {
                if (attrRevision != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrRevision = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("TenantId")) {
                if (attrTenantId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrTenantId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("CartridgeId")) {
                if (attrCartridgeId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCartridgeId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ItemId")) {
                if (attrItemId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrItemId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("RuleTypeId")) {
                if (attrRuleTypeId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrRuleTypeId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("Name")) {
                if (attrName != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrName = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ToolSetId")) {
                if (attrToolSetId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrToolSetId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ScopeDefId")) {
                if (attrScopeDefId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrScopeDefId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("GenDefId")) {
                if (attrGenDefId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrGenDefId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("GelExecutableId")) {
                if (attrGelExecutableId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrGelExecutableId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("schemaLocation")) {
                // ignored
            } else {
                throw CFLib.getDefaultExceptionFactory().newUnrecognizedAttributeException(getClass(),
                        S_ProcName, getParser().getLocationInfo(), attrLocalName);
            }
        }

        // Ensure that required attributes have values
        if ((attrTenantId == null) || (attrTenantId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "TenantId");
        }
        if ((attrCartridgeId == null) || (attrCartridgeId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "CartridgeId");
        }
        if ((attrItemId == null) || (attrItemId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "ItemId");
        }
        if ((attrRuleTypeId == null) || (attrRuleTypeId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "RuleTypeId");
        }
        if (attrName == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "Name");
        }
        if ((attrToolSetId == null) || (attrToolSetId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "ToolSetId");
        }
        if ((attrGenDefId == null) || (attrGenDefId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "GenDefId");
        }
        if ((attrRevision == null) || (attrRevision.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "Revision");
        }

        // Save named attributes to context
        CFLibXmlCoreContext curContext = getParser().getCurContext();

        // Convert string attributes to native Java types

        long natTenantId = Long.parseLong(attrTenantId);

        long natCartridgeId = Long.parseLong(attrCartridgeId);

        int natItemId = Integer.parseInt(attrItemId);

        short natRuleTypeId = Short.parseShort(attrRuleTypeId);

        String natName = attrName;

        short natToolSetId = Short.parseShort(attrToolSetId);

        Short natScopeDefId;
        if ((attrScopeDefId == null) || (attrScopeDefId.length() <= 0)) {
            natScopeDefId = null;
        } else {
            natScopeDefId = new Short(Short.parseShort(attrScopeDefId));
        }

        short natGenDefId = Short.parseShort(attrGenDefId);

        Integer natGelExecutableId;
        if ((attrGelExecutableId == null) || (attrGelExecutableId.length() <= 0)) {
            natGelExecutableId = null;
        } else {
            natGelExecutableId = new Integer(Integer.parseInt(attrGelExecutableId));
        }

        int natRevision = Integer.parseInt(attrRevision);
        // Instantiate a buffer for the parsed information
        ICFGenKbUInt16FormatterObj obj = schemaObj.getUInt16FormatterTableObj().newInstance();
        CFGenKbUInt16FormatterBuff dataBuff = obj.getUInt16FormatterBuff();
        dataBuff.setRequiredTenantId(natTenantId);
        dataBuff.setRequiredCartridgeId(natCartridgeId);
        dataBuff.setRequiredItemId(natItemId);
        dataBuff.setRequiredRuleTypeId(natRuleTypeId);
        dataBuff.setRequiredName(natName);
        dataBuff.setRequiredToolSetId(natToolSetId);
        dataBuff.setOptionalScopeDefId(natScopeDefId);
        dataBuff.setRequiredGenDefId(natGenDefId);
        dataBuff.setOptionalGelExecutableId(natGelExecutableId);
        dataBuff.setRequiredRevision(natRevision);
        obj.copyBuffToPKey();
        ICFGenKbUInt16FormatterObj realized = (ICFGenKbUInt16FormatterObj) obj.realize();
        xmsgRspnHandler.setLastObjectProcessed(realized);
    } catch (RuntimeException e) {
        throw new RuntimeException("Near " + getParser().getLocationInfo() + ": Caught and rethrew "
                + e.getClass().getName() + " - " + e.getMessage(), e);
    } catch (Error e) {
        throw new Error("Near " + getParser().getLocationInfo() + ": Caught and rethrew "
                + e.getClass().getName() + " - " + e.getMessage(), e);
    }
}

From source file:net.sourceforge.msscodefactory.cfcore.v2_0.CFGenKbXMsgRspnHandler.CFGenKbXMsgRspnUInt32FormatterLockedHandler.java

public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
    try {// w  w w . j  a va  2s  .  com
        // Common XML Attributes
        String attrId = null;
        String attrRevision = null;
        // GenItem Attributes
        String attrTenantId = null;
        String attrCartridgeId = null;
        String attrItemId = null;
        String attrRuleTypeId = null;
        String attrName = null;
        String attrToolSetId = null;
        String attrScopeDefId = null;
        String attrGenDefId = null;
        String attrGelExecutableId = null;
        // GenBind Attributes
        // GenFormatter Attributes
        // UInt32Formatter Attributes
        // Attribute Extraction
        String attrLocalName;
        int numAttrs;
        int idxAttr;
        final String S_ProcName = "startElement";
        final String S_LocalName = "LocalName";

        assert qName.equals("RspnUInt32FormatterLocked");

        CFGenKbXMsgRspnHandler xmsgRspnHandler = (CFGenKbXMsgRspnHandler) getParser();
        if (xmsgRspnHandler == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "getParser()");
        }

        ICFGenKbSchemaObj schemaObj = xmsgRspnHandler.getSchemaObj();
        if (schemaObj == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "getParser().getSchemaObj()");
        }

        // Extract Attributes
        numAttrs = attrs.getLength();
        for (idxAttr = 0; idxAttr < numAttrs; idxAttr++) {
            attrLocalName = attrs.getLocalName(idxAttr);
            if (attrLocalName.equals("Id")) {
                if (attrId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("Revision")) {
                if (attrRevision != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrRevision = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("TenantId")) {
                if (attrTenantId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrTenantId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("CartridgeId")) {
                if (attrCartridgeId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCartridgeId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ItemId")) {
                if (attrItemId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrItemId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("RuleTypeId")) {
                if (attrRuleTypeId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrRuleTypeId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("Name")) {
                if (attrName != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrName = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ToolSetId")) {
                if (attrToolSetId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrToolSetId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ScopeDefId")) {
                if (attrScopeDefId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrScopeDefId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("GenDefId")) {
                if (attrGenDefId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrGenDefId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("GelExecutableId")) {
                if (attrGelExecutableId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrGelExecutableId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("schemaLocation")) {
                // ignored
            } else {
                throw CFLib.getDefaultExceptionFactory().newUnrecognizedAttributeException(getClass(),
                        S_ProcName, getParser().getLocationInfo(), attrLocalName);
            }
        }

        // Ensure that required attributes have values
        if ((attrTenantId == null) || (attrTenantId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "TenantId");
        }
        if ((attrCartridgeId == null) || (attrCartridgeId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "CartridgeId");
        }
        if ((attrItemId == null) || (attrItemId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "ItemId");
        }
        if ((attrRuleTypeId == null) || (attrRuleTypeId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "RuleTypeId");
        }
        if (attrName == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "Name");
        }
        if ((attrToolSetId == null) || (attrToolSetId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "ToolSetId");
        }
        if ((attrGenDefId == null) || (attrGenDefId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "GenDefId");
        }
        if ((attrRevision == null) || (attrRevision.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "Revision");
        }

        // Save named attributes to context
        CFLibXmlCoreContext curContext = getParser().getCurContext();

        // Convert string attributes to native Java types

        long natTenantId = Long.parseLong(attrTenantId);

        long natCartridgeId = Long.parseLong(attrCartridgeId);

        int natItemId = Integer.parseInt(attrItemId);

        short natRuleTypeId = Short.parseShort(attrRuleTypeId);

        String natName = attrName;

        short natToolSetId = Short.parseShort(attrToolSetId);

        Short natScopeDefId;
        if ((attrScopeDefId == null) || (attrScopeDefId.length() <= 0)) {
            natScopeDefId = null;
        } else {
            natScopeDefId = new Short(Short.parseShort(attrScopeDefId));
        }

        short natGenDefId = Short.parseShort(attrGenDefId);

        Integer natGelExecutableId;
        if ((attrGelExecutableId == null) || (attrGelExecutableId.length() <= 0)) {
            natGelExecutableId = null;
        } else {
            natGelExecutableId = new Integer(Integer.parseInt(attrGelExecutableId));
        }

        int natRevision = Integer.parseInt(attrRevision);
        // Instantiate a buffer for the parsed information
        ICFGenKbUInt32FormatterObj obj = schemaObj.getUInt32FormatterTableObj().newInstance();
        CFGenKbUInt32FormatterBuff dataBuff = obj.getUInt32FormatterBuff();
        dataBuff.setRequiredTenantId(natTenantId);
        dataBuff.setRequiredCartridgeId(natCartridgeId);
        dataBuff.setRequiredItemId(natItemId);
        dataBuff.setRequiredRuleTypeId(natRuleTypeId);
        dataBuff.setRequiredName(natName);
        dataBuff.setRequiredToolSetId(natToolSetId);
        dataBuff.setOptionalScopeDefId(natScopeDefId);
        dataBuff.setRequiredGenDefId(natGenDefId);
        dataBuff.setOptionalGelExecutableId(natGelExecutableId);
        dataBuff.setRequiredRevision(natRevision);
        obj.copyBuffToPKey();
        ICFGenKbUInt32FormatterObj realized = (ICFGenKbUInt32FormatterObj) obj.realize();
        xmsgRspnHandler.setLastObjectProcessed(realized);
    } catch (RuntimeException e) {
        throw new RuntimeException("Near " + getParser().getLocationInfo() + ": Caught and rethrew "
                + e.getClass().getName() + " - " + e.getMessage(), e);
    } catch (Error e) {
        throw new Error("Near " + getParser().getLocationInfo() + ": Caught and rethrew "
                + e.getClass().getName() + " - " + e.getMessage(), e);
    }
}

From source file:net.sourceforge.msscodefactory.cfcore.v2_0.CFGenKbXMsgRspnHandler.CFGenKbXMsgRspnUInt64FormatterLockedHandler.java

public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
    try {/*from   ww  w .  ja v  a 2  s .c om*/
        // Common XML Attributes
        String attrId = null;
        String attrRevision = null;
        // GenItem Attributes
        String attrTenantId = null;
        String attrCartridgeId = null;
        String attrItemId = null;
        String attrRuleTypeId = null;
        String attrName = null;
        String attrToolSetId = null;
        String attrScopeDefId = null;
        String attrGenDefId = null;
        String attrGelExecutableId = null;
        // GenBind Attributes
        // GenFormatter Attributes
        // UInt64Formatter Attributes
        // Attribute Extraction
        String attrLocalName;
        int numAttrs;
        int idxAttr;
        final String S_ProcName = "startElement";
        final String S_LocalName = "LocalName";

        assert qName.equals("RspnUInt64FormatterLocked");

        CFGenKbXMsgRspnHandler xmsgRspnHandler = (CFGenKbXMsgRspnHandler) getParser();
        if (xmsgRspnHandler == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "getParser()");
        }

        ICFGenKbSchemaObj schemaObj = xmsgRspnHandler.getSchemaObj();
        if (schemaObj == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "getParser().getSchemaObj()");
        }

        // Extract Attributes
        numAttrs = attrs.getLength();
        for (idxAttr = 0; idxAttr < numAttrs; idxAttr++) {
            attrLocalName = attrs.getLocalName(idxAttr);
            if (attrLocalName.equals("Id")) {
                if (attrId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("Revision")) {
                if (attrRevision != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrRevision = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("TenantId")) {
                if (attrTenantId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrTenantId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("CartridgeId")) {
                if (attrCartridgeId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCartridgeId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ItemId")) {
                if (attrItemId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrItemId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("RuleTypeId")) {
                if (attrRuleTypeId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrRuleTypeId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("Name")) {
                if (attrName != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrName = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ToolSetId")) {
                if (attrToolSetId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrToolSetId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ScopeDefId")) {
                if (attrScopeDefId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrScopeDefId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("GenDefId")) {
                if (attrGenDefId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrGenDefId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("GelExecutableId")) {
                if (attrGelExecutableId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrGelExecutableId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("schemaLocation")) {
                // ignored
            } else {
                throw CFLib.getDefaultExceptionFactory().newUnrecognizedAttributeException(getClass(),
                        S_ProcName, getParser().getLocationInfo(), attrLocalName);
            }
        }

        // Ensure that required attributes have values
        if ((attrTenantId == null) || (attrTenantId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "TenantId");
        }
        if ((attrCartridgeId == null) || (attrCartridgeId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "CartridgeId");
        }
        if ((attrItemId == null) || (attrItemId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "ItemId");
        }
        if ((attrRuleTypeId == null) || (attrRuleTypeId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "RuleTypeId");
        }
        if (attrName == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "Name");
        }
        if ((attrToolSetId == null) || (attrToolSetId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "ToolSetId");
        }
        if ((attrGenDefId == null) || (attrGenDefId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "GenDefId");
        }
        if ((attrRevision == null) || (attrRevision.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "Revision");
        }

        // Save named attributes to context
        CFLibXmlCoreContext curContext = getParser().getCurContext();

        // Convert string attributes to native Java types

        long natTenantId = Long.parseLong(attrTenantId);

        long natCartridgeId = Long.parseLong(attrCartridgeId);

        int natItemId = Integer.parseInt(attrItemId);

        short natRuleTypeId = Short.parseShort(attrRuleTypeId);

        String natName = attrName;

        short natToolSetId = Short.parseShort(attrToolSetId);

        Short natScopeDefId;
        if ((attrScopeDefId == null) || (attrScopeDefId.length() <= 0)) {
            natScopeDefId = null;
        } else {
            natScopeDefId = new Short(Short.parseShort(attrScopeDefId));
        }

        short natGenDefId = Short.parseShort(attrGenDefId);

        Integer natGelExecutableId;
        if ((attrGelExecutableId == null) || (attrGelExecutableId.length() <= 0)) {
            natGelExecutableId = null;
        } else {
            natGelExecutableId = new Integer(Integer.parseInt(attrGelExecutableId));
        }

        int natRevision = Integer.parseInt(attrRevision);
        // Instantiate a buffer for the parsed information
        ICFGenKbUInt64FormatterObj obj = schemaObj.getUInt64FormatterTableObj().newInstance();
        CFGenKbUInt64FormatterBuff dataBuff = obj.getUInt64FormatterBuff();
        dataBuff.setRequiredTenantId(natTenantId);
        dataBuff.setRequiredCartridgeId(natCartridgeId);
        dataBuff.setRequiredItemId(natItemId);
        dataBuff.setRequiredRuleTypeId(natRuleTypeId);
        dataBuff.setRequiredName(natName);
        dataBuff.setRequiredToolSetId(natToolSetId);
        dataBuff.setOptionalScopeDefId(natScopeDefId);
        dataBuff.setRequiredGenDefId(natGenDefId);
        dataBuff.setOptionalGelExecutableId(natGelExecutableId);
        dataBuff.setRequiredRevision(natRevision);
        obj.copyBuffToPKey();
        ICFGenKbUInt64FormatterObj realized = (ICFGenKbUInt64FormatterObj) obj.realize();
        xmsgRspnHandler.setLastObjectProcessed(realized);
    } catch (RuntimeException e) {
        throw new RuntimeException("Near " + getParser().getLocationInfo() + ": Caught and rethrew "
                + e.getClass().getName() + " - " + e.getMessage(), e);
    } catch (Error e) {
        throw new Error("Near " + getParser().getLocationInfo() + ": Caught and rethrew "
                + e.getClass().getName() + " - " + e.getMessage(), e);
    }
}

From source file:net.sourceforge.msscodefactory.cfcore.v2_0.CFGenKbXMsgRspnHandler.CFGenKbXMsgRspnNumberFormatterCreatedHandler.java

public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
    try {//from w w  w  .  j  a  v  a2 s .c  o  m
        // Common XML Attributes
        String attrId = null;
        String attrRevision = null;
        // GenItem Attributes
        String attrTenantId = null;
        String attrCartridgeId = null;
        String attrItemId = null;
        String attrRuleTypeId = null;
        String attrName = null;
        String attrToolSetId = null;
        String attrScopeDefId = null;
        String attrGenDefId = null;
        String attrGelExecutableId = null;
        // GenBind Attributes
        // GenFormatter Attributes
        // NumberFormatter Attributes
        // Attribute Extraction
        String attrLocalName;
        int numAttrs;
        int idxAttr;
        final String S_ProcName = "startElement";
        final String S_LocalName = "LocalName";

        assert qName.equals("RspnNumberFormatterCreated");

        CFGenKbXMsgRspnHandler xmsgRspnHandler = (CFGenKbXMsgRspnHandler) getParser();
        if (xmsgRspnHandler == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "getParser()");
        }

        ICFGenKbSchemaObj schemaObj = xmsgRspnHandler.getSchemaObj();
        if (schemaObj == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "getParser().getSchemaObj()");
        }

        // Extract Attributes
        numAttrs = attrs.getLength();
        for (idxAttr = 0; idxAttr < numAttrs; idxAttr++) {
            attrLocalName = attrs.getLocalName(idxAttr);
            if (attrLocalName.equals("Id")) {
                if (attrId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("Revision")) {
                if (attrRevision != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrRevision = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("TenantId")) {
                if (attrTenantId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrTenantId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("CartridgeId")) {
                if (attrCartridgeId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCartridgeId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ItemId")) {
                if (attrItemId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrItemId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("RuleTypeId")) {
                if (attrRuleTypeId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrRuleTypeId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("Name")) {
                if (attrName != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrName = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ToolSetId")) {
                if (attrToolSetId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrToolSetId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ScopeDefId")) {
                if (attrScopeDefId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrScopeDefId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("GenDefId")) {
                if (attrGenDefId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrGenDefId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("GelExecutableId")) {
                if (attrGelExecutableId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrGelExecutableId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("schemaLocation")) {
                // ignored
            } else {
                throw CFLib.getDefaultExceptionFactory().newUnrecognizedAttributeException(getClass(),
                        S_ProcName, getParser().getLocationInfo(), attrLocalName);
            }
        }

        // Ensure that required attributes have values
        if ((attrTenantId == null) || (attrTenantId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "TenantId");
        }
        if ((attrCartridgeId == null) || (attrCartridgeId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "CartridgeId");
        }
        if ((attrItemId == null) || (attrItemId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "ItemId");
        }
        if ((attrRuleTypeId == null) || (attrRuleTypeId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "RuleTypeId");
        }
        if (attrName == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "Name");
        }
        if ((attrToolSetId == null) || (attrToolSetId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "ToolSetId");
        }
        if ((attrGenDefId == null) || (attrGenDefId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "GenDefId");
        }
        if ((attrRevision == null) || (attrRevision.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "Revision");
        }

        // Save named attributes to context
        CFLibXmlCoreContext curContext = getParser().getCurContext();

        // Convert string attributes to native Java types

        long natTenantId = Long.parseLong(attrTenantId);

        long natCartridgeId = Long.parseLong(attrCartridgeId);

        int natItemId = Integer.parseInt(attrItemId);

        short natRuleTypeId = Short.parseShort(attrRuleTypeId);

        String natName = attrName;

        short natToolSetId = Short.parseShort(attrToolSetId);

        Short natScopeDefId;
        if ((attrScopeDefId == null) || (attrScopeDefId.length() <= 0)) {
            natScopeDefId = null;
        } else {
            natScopeDefId = new Short(Short.parseShort(attrScopeDefId));
        }

        short natGenDefId = Short.parseShort(attrGenDefId);

        Integer natGelExecutableId;
        if ((attrGelExecutableId == null) || (attrGelExecutableId.length() <= 0)) {
            natGelExecutableId = null;
        } else {
            natGelExecutableId = new Integer(Integer.parseInt(attrGelExecutableId));
        }

        int natRevision = Integer.parseInt(attrRevision);
        // Instantiate a buffer for the parsed information
        ICFGenKbNumberFormatterObj obj = schemaObj.getNumberFormatterTableObj().newInstance();
        CFGenKbNumberFormatterBuff dataBuff = obj.getNumberFormatterBuff();
        dataBuff.setRequiredTenantId(natTenantId);
        dataBuff.setRequiredCartridgeId(natCartridgeId);
        dataBuff.setRequiredItemId(natItemId);
        dataBuff.setRequiredRuleTypeId(natRuleTypeId);
        dataBuff.setRequiredName(natName);
        dataBuff.setRequiredToolSetId(natToolSetId);
        dataBuff.setOptionalScopeDefId(natScopeDefId);
        dataBuff.setRequiredGenDefId(natGenDefId);
        dataBuff.setOptionalGelExecutableId(natGelExecutableId);
        dataBuff.setRequiredRevision(natRevision);
        obj.copyBuffToPKey();
        ICFGenKbNumberFormatterObj realized = (ICFGenKbNumberFormatterObj) obj.realize();
        xmsgRspnHandler.setLastObjectProcessed(realized);
    } catch (RuntimeException e) {
        throw new RuntimeException("Near " + getParser().getLocationInfo() + ": Caught and rethrew "
                + e.getClass().getName() + " - " + e.getMessage(), e);
    } catch (Error e) {
        throw new Error("Near " + getParser().getLocationInfo() + ": Caught and rethrew "
                + e.getClass().getName() + " - " + e.getMessage(), e);
    }
}