Example usage for java.util SortedMap put

List of usage examples for java.util SortedMap put

Introduction

In this page you can find the example usage for java.util SortedMap put.

Prototype

V put(K key, V value);

Source Link

Document

Associates the specified value with the specified key in this map (optional operation).

Usage

From source file:net.sourceforge.msscodefactory.cfgcash.v2_0.CFGCashXMsgRspnHandler.CFGCashXMsgRspnContactListRecHandler.java

public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
    try {//  w  ww. j  a v  a  2s . c o m
        // Common XML Attributes
        String attrId = null;
        String attrRevision = null;
        // ContactList Attributes
        String attrContactListId = null;
        String attrTenantId = null;
        String attrDescription = null;
        String attrStripDigits = null;
        String attrCreatedAt = null;
        String attrCreatedBy = null;
        String attrUpdatedAt = null;
        String attrUpdatedBy = null;
        // Attribute Extraction
        String attrLocalName;
        int numAttrs;
        int idxAttr;
        final String S_ProcName = "startElement";
        final String S_LocalName = "LocalName";

        assert qName.equals("ContactList");

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

        ICFGCashSchemaObj 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("CreatedAt")) {
                if (attrCreatedAt != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCreatedAt = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("CreatedBy")) {
                if (attrCreatedBy != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCreatedBy = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("UpdatedAt")) {
                if (attrUpdatedAt != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrUpdatedAt = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("UpdatedBy")) {
                if (attrUpdatedBy != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrUpdatedBy = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ContactListId")) {
                if (attrContactListId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrContactListId = 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("Description")) {
                if (attrDescription != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrDescription = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("StripDigits")) {
                if (attrStripDigits != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrStripDigits = 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 ((attrContactListId == null) || (attrContactListId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "ContactListId");
        }
        if ((attrTenantId == null) || (attrTenantId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "TenantId");
        }
        if (attrDescription == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "Description");
        }

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

        // Convert string attributes to native Java types

        long natContactListId = Long.parseLong(attrContactListId);

        long natTenantId = Long.parseLong(attrTenantId);

        String natDescription = attrDescription;

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

        int natRevision = Integer.parseInt(attrRevision);
        UUID createdBy = null;
        if (attrCreatedBy != null) {
            createdBy = UUID.fromString(attrCreatedBy);
        }
        Calendar createdAt = null;
        if (attrCreatedAt != null) {
            createdAt = CFLibXmlUtil.parseTimestamp(attrCreatedAt);
        }
        UUID updatedBy = null;
        if (attrUpdatedBy != null) {
            updatedBy = UUID.fromString(attrUpdatedBy);
        }
        Calendar updatedAt = null;
        if (attrUpdatedAt != null) {
            updatedAt = CFLibXmlUtil.parseTimestamp(attrUpdatedAt);
        }
        // Get the parent context
        CFLibXmlCoreContext parentContext = curContext.getPrevContext();
        // Instantiate a buffer for the parsed information
        ICFGCashContactListObj obj = schemaObj.getContactListTableObj().newInstance();
        CFGCashContactListBuff dataBuff = obj.getContactListBuff();
        dataBuff.setRequiredContactListId(natContactListId);
        dataBuff.setRequiredTenantId(natTenantId);
        dataBuff.setRequiredDescription(natDescription);
        dataBuff.setOptionalStripDigits(natStripDigits);
        dataBuff.setRequiredRevision(natRevision);
        if (createdBy != null) {
            dataBuff.setCreatedByUserId(createdBy);
        }
        if (createdAt != null) {
            dataBuff.setCreatedAt(createdAt);
        }
        if (updatedBy != null) {
            dataBuff.setUpdatedByUserId(updatedBy);
        }
        if (updatedAt != null) {
            dataBuff.setUpdatedAt(updatedAt);
        }
        obj.copyBuffToPKey();
        SortedMap<CFGCashContactListPKey, ICFGCashContactListObj> sortedMap = (SortedMap<CFGCashContactListPKey, ICFGCashContactListObj>) xmsgRspnHandler
                .getSortedMapOfObjects();
        ICFGCashContactListObj realized = (ICFGCashContactListObj) obj.realize();
        xmsgRspnHandler.setLastObjectProcessed(realized);
        if (sortedMap != null) {
            sortedMap.put(realized.getPKey(), 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.CFGenKbXMsgRspnServiceRecHandler.java

public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
    try {/*from  ww  w. j  ava 2s .  c  o  m*/
        // Common XML Attributes
        String attrId = null;
        String attrRevision = null;
        // Service Attributes
        String attrClusterId = null;
        String attrServiceId = null;
        String attrHostNodeId = null;
        String attrServiceTypeId = null;
        String attrHostPort = null;
        String attrCreatedAt = null;
        String attrCreatedBy = null;
        String attrUpdatedAt = null;
        String attrUpdatedBy = null;
        // Attribute Extraction
        String attrLocalName;
        int numAttrs;
        int idxAttr;
        final String S_ProcName = "startElement";
        final String S_LocalName = "LocalName";

        assert qName.equals("Service");

        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("CreatedAt")) {
                if (attrCreatedAt != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCreatedAt = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("CreatedBy")) {
                if (attrCreatedBy != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCreatedBy = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("UpdatedAt")) {
                if (attrUpdatedAt != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrUpdatedAt = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("UpdatedBy")) {
                if (attrUpdatedBy != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrUpdatedBy = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ClusterId")) {
                if (attrClusterId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrClusterId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ServiceId")) {
                if (attrServiceId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrServiceId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("HostNodeId")) {
                if (attrHostNodeId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrHostNodeId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ServiceTypeId")) {
                if (attrServiceTypeId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrServiceTypeId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("HostPort")) {
                if (attrHostPort != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrHostPort = 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 ((attrClusterId == null) || (attrClusterId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "ClusterId");
        }
        if ((attrServiceId == null) || (attrServiceId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "ServiceId");
        }
        if ((attrHostNodeId == null) || (attrHostNodeId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "HostNodeId");
        }
        if ((attrServiceTypeId == null) || (attrServiceTypeId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "ServiceTypeId");
        }
        if ((attrHostPort == null) || (attrHostPort.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "HostPort");
        }

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

        // Convert string attributes to native Java types

        long natClusterId = Long.parseLong(attrClusterId);

        long natServiceId = Long.parseLong(attrServiceId);

        long natHostNodeId = Long.parseLong(attrHostNodeId);

        int natServiceTypeId = Integer.parseInt(attrServiceTypeId);

        short natHostPort = Short.parseShort(attrHostPort);

        int natRevision = Integer.parseInt(attrRevision);
        UUID createdBy = null;
        if (attrCreatedBy != null) {
            createdBy = UUID.fromString(attrCreatedBy);
        }
        Calendar createdAt = null;
        if (attrCreatedAt != null) {
            createdAt = CFLibXmlUtil.parseTimestamp(attrCreatedAt);
        }
        UUID updatedBy = null;
        if (attrUpdatedBy != null) {
            updatedBy = UUID.fromString(attrUpdatedBy);
        }
        Calendar updatedAt = null;
        if (attrUpdatedAt != null) {
            updatedAt = CFLibXmlUtil.parseTimestamp(attrUpdatedAt);
        }
        // Get the parent context
        CFLibXmlCoreContext parentContext = curContext.getPrevContext();
        // Instantiate a buffer for the parsed information
        ICFGenKbServiceObj obj = schemaObj.getServiceTableObj().newInstance();
        CFGenKbServiceBuff dataBuff = obj.getServiceBuff();
        dataBuff.setRequiredClusterId(natClusterId);
        dataBuff.setRequiredServiceId(natServiceId);
        dataBuff.setRequiredHostNodeId(natHostNodeId);
        dataBuff.setRequiredServiceTypeId(natServiceTypeId);
        dataBuff.setRequiredHostPort(natHostPort);
        dataBuff.setRequiredRevision(natRevision);
        if (createdBy != null) {
            dataBuff.setCreatedByUserId(createdBy);
        }
        if (createdAt != null) {
            dataBuff.setCreatedAt(createdAt);
        }
        if (updatedBy != null) {
            dataBuff.setUpdatedByUserId(updatedBy);
        }
        if (updatedAt != null) {
            dataBuff.setUpdatedAt(updatedAt);
        }
        obj.copyBuffToPKey();
        SortedMap<CFGenKbServicePKey, ICFGenKbServiceObj> sortedMap = (SortedMap<CFGenKbServicePKey, ICFGenKbServiceObj>) xmsgRspnHandler
                .getSortedMapOfObjects();
        ICFGenKbServiceObj realized = (ICFGenKbServiceObj) obj.realize();
        xmsgRspnHandler.setLastObjectProcessed(realized);
        if (sortedMap != null) {
            sortedMap.put(realized.getPKey(), 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.cfensyntax.v2_0.CFEnSyntaxXMsgRspnHandler.CFEnSyntaxXMsgRspnISOCountryLanguageRecHandler.java

public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
    try {//from  w  w  w . j  a va2s.  co m
        // Common XML Attributes
        String attrId = null;
        String attrRevision = null;
        // ISOCountryLanguage Attributes
        String attrISOCountryId = null;
        String attrISOLanguageId = null;
        String attrCreatedAt = null;
        String attrCreatedBy = null;
        String attrUpdatedAt = null;
        String attrUpdatedBy = null;
        // Attribute Extraction
        String attrLocalName;
        int numAttrs;
        int idxAttr;
        final String S_ProcName = "startElement";
        final String S_LocalName = "LocalName";

        assert qName.equals("ISOCountryLanguage");

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

        ICFEnSyntaxSchemaObj 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("CreatedAt")) {
                if (attrCreatedAt != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCreatedAt = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("CreatedBy")) {
                if (attrCreatedBy != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCreatedBy = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("UpdatedAt")) {
                if (attrUpdatedAt != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrUpdatedAt = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("UpdatedBy")) {
                if (attrUpdatedBy != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrUpdatedBy = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ISOCountryId")) {
                if (attrISOCountryId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrISOCountryId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ISOLanguageId")) {
                if (attrISOLanguageId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrISOLanguageId = 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 ((attrISOCountryId == null) || (attrISOCountryId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "ISOCountryId");
        }
        if ((attrISOLanguageId == null) || (attrISOLanguageId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "ISOLanguageId");
        }

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

        // Convert string attributes to native Java types

        short natISOCountryId = Short.parseShort(attrISOCountryId);

        short natISOLanguageId = Short.parseShort(attrISOLanguageId);

        int natRevision = Integer.parseInt(attrRevision);
        UUID createdBy = null;
        if (attrCreatedBy != null) {
            createdBy = UUID.fromString(attrCreatedBy);
        }
        Calendar createdAt = null;
        if (attrCreatedAt != null) {
            createdAt = CFLibXmlUtil.parseTimestamp(attrCreatedAt);
        }
        UUID updatedBy = null;
        if (attrUpdatedBy != null) {
            updatedBy = UUID.fromString(attrUpdatedBy);
        }
        Calendar updatedAt = null;
        if (attrUpdatedAt != null) {
            updatedAt = CFLibXmlUtil.parseTimestamp(attrUpdatedAt);
        }
        // Get the parent context
        CFLibXmlCoreContext parentContext = curContext.getPrevContext();
        // Instantiate a buffer for the parsed information
        ICFEnSyntaxISOCountryLanguageObj obj = schemaObj.getISOCountryLanguageTableObj().newInstance();
        CFEnSyntaxISOCountryLanguageBuff dataBuff = obj.getISOCountryLanguageBuff();
        dataBuff.setRequiredISOCountryId(natISOCountryId);
        dataBuff.setRequiredISOLanguageId(natISOLanguageId);
        dataBuff.setRequiredRevision(natRevision);
        if (createdBy != null) {
            dataBuff.setCreatedByUserId(createdBy);
        }
        if (createdAt != null) {
            dataBuff.setCreatedAt(createdAt);
        }
        if (updatedBy != null) {
            dataBuff.setUpdatedByUserId(updatedBy);
        }
        if (updatedAt != null) {
            dataBuff.setUpdatedAt(updatedAt);
        }
        obj.copyBuffToPKey();
        SortedMap<CFEnSyntaxISOCountryLanguagePKey, ICFEnSyntaxISOCountryLanguageObj> sortedMap = (SortedMap<CFEnSyntaxISOCountryLanguagePKey, ICFEnSyntaxISOCountryLanguageObj>) xmsgRspnHandler
                .getSortedMapOfObjects();
        ICFEnSyntaxISOCountryLanguageObj realized = (ICFEnSyntaxISOCountryLanguageObj) obj.realize();
        xmsgRspnHandler.setLastObjectProcessed(realized);
        if (sortedMap != null) {
            sortedMap.put(realized.getPKey(), 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:org.openmrs.module.rwandaprimarycare.AllEncountersController.java

@RequestMapping("/module/rwandaprimarycare/allEncounters")
public String listAllEncounters(@RequestParam("patientId") int patientId, ModelMap model)
        throws PrimaryCareException {

    //LK: Need to ensure that all primary care methods only throw a PrimaryCareException
    //So that errors will be directed to a touch screen error page
    try {//from w w w . j  a  va2  s  .com
        Patient patient = Context.getPatientService().getPatient(patientId);
        SortedMap<Date, List<Encounter>> encounters = new TreeMap<Date, List<Encounter>>(
                Collections.reverseOrder());
        for (Encounter e : Context.getEncounterService().getEncountersByPatient(patient)) {
            Calendar cal = Calendar.getInstance();
            cal.setTime(e.getEncounterDatetime());
            cal.set(Calendar.HOUR_OF_DAY, 0);
            cal.set(Calendar.MINUTE, 0);
            cal.set(Calendar.SECOND, 0);
            cal.set(Calendar.MILLISECOND, 0);
            Date day = cal.getTime();
            List<Encounter> holder = encounters.get(day);
            if (holder == null) {
                holder = new ArrayList<Encounter>();
                encounters.put(day, holder);
            }
            holder.add(e);
        }
        model.addAttribute("patient", patient);
        model.addAttribute("encounters", encounters);
        model.addAttribute("vitalsEncounterType", PrimaryCareBusinessLogic.getVitalsEncounterType());
        model.addAttribute("registrationEncounterType",
                PrimaryCareBusinessLogic.getRegistrationEncounterType());
    } catch (Exception e) {
        throw new PrimaryCareException(e);
    }
    return "/module/rwandaprimarycare/allEncounters";
}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccXMsgRspnHandler.CFAccXMsgRspnAccountContactRecHandler.java

public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
    try {/*from  w ww. ja v  a  2s.c  o m*/
        // Common XML Attributes
        String attrId = null;
        String attrRevision = null;
        // AccountContact Attributes
        String attrTenantId = null;
        String attrAccountId = null;
        String attrContactListId = null;
        String attrContactId = null;
        String attrCreatedAt = null;
        String attrCreatedBy = null;
        String attrUpdatedAt = null;
        String attrUpdatedBy = null;
        // Attribute Extraction
        String attrLocalName;
        int numAttrs;
        int idxAttr;
        final String S_ProcName = "startElement";
        final String S_LocalName = "LocalName";

        assert qName.equals("AccountContact");

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

        ICFAccSchemaObj 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("CreatedAt")) {
                if (attrCreatedAt != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCreatedAt = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("CreatedBy")) {
                if (attrCreatedBy != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCreatedBy = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("UpdatedAt")) {
                if (attrUpdatedAt != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrUpdatedAt = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("UpdatedBy")) {
                if (attrUpdatedBy != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrUpdatedBy = 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("AccountId")) {
                if (attrAccountId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrAccountId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ContactListId")) {
                if (attrContactListId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrContactListId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ContactId")) {
                if (attrContactId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrContactId = 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 ((attrAccountId == null) || (attrAccountId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "AccountId");
        }
        if ((attrContactListId == null) || (attrContactListId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "ContactListId");
        }
        if ((attrContactId == null) || (attrContactId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "ContactId");
        }

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

        // Convert string attributes to native Java types

        long natTenantId = Long.parseLong(attrTenantId);

        long natAccountId = Long.parseLong(attrAccountId);

        long natContactListId = Long.parseLong(attrContactListId);

        long natContactId = Long.parseLong(attrContactId);

        int natRevision = Integer.parseInt(attrRevision);
        UUID createdBy = null;
        if (attrCreatedBy != null) {
            createdBy = UUID.fromString(attrCreatedBy);
        }
        Calendar createdAt = null;
        if (attrCreatedAt != null) {
            createdAt = CFLibXmlUtil.parseTimestamp(attrCreatedAt);
        }
        UUID updatedBy = null;
        if (attrUpdatedBy != null) {
            updatedBy = UUID.fromString(attrUpdatedBy);
        }
        Calendar updatedAt = null;
        if (attrUpdatedAt != null) {
            updatedAt = CFLibXmlUtil.parseTimestamp(attrUpdatedAt);
        }
        // Get the parent context
        CFLibXmlCoreContext parentContext = curContext.getPrevContext();
        // Instantiate a buffer for the parsed information
        ICFAccAccountContactObj obj = schemaObj.getAccountContactTableObj().newInstance();
        CFAccAccountContactBuff dataBuff = obj.getAccountContactBuff();
        dataBuff.setRequiredTenantId(natTenantId);
        dataBuff.setRequiredAccountId(natAccountId);
        dataBuff.setRequiredContactListId(natContactListId);
        dataBuff.setRequiredContactId(natContactId);
        dataBuff.setRequiredRevision(natRevision);
        if (createdBy != null) {
            dataBuff.setCreatedByUserId(createdBy);
        }
        if (createdAt != null) {
            dataBuff.setCreatedAt(createdAt);
        }
        if (updatedBy != null) {
            dataBuff.setUpdatedByUserId(updatedBy);
        }
        if (updatedAt != null) {
            dataBuff.setUpdatedAt(updatedAt);
        }
        obj.copyBuffToPKey();
        SortedMap<CFAccAccountContactPKey, ICFAccAccountContactObj> sortedMap = (SortedMap<CFAccAccountContactPKey, ICFAccAccountContactObj>) xmsgRspnHandler
                .getSortedMapOfObjects();
        ICFAccAccountContactObj realized = (ICFAccAccountContactObj) obj.realize();
        xmsgRspnHandler.setLastObjectProcessed(realized);
        if (sortedMap != null) {
            sortedMap.put(realized.getPKey(), 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.cfacc.v2_0.CFAccXMsgRspnHandler.CFAccXMsgRspnSecGroupMemberRecHandler.java

public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
    try {/*from  w w  w.ja v  a  2s . c om*/
        // Common XML Attributes
        String attrId = null;
        String attrRevision = null;
        // SecGroupMember Attributes
        String attrClusterId = null;
        String attrSecGroupMemberId = null;
        String attrSecGroupId = null;
        String attrSecUserId = null;
        String attrCreatedAt = null;
        String attrCreatedBy = null;
        String attrUpdatedAt = null;
        String attrUpdatedBy = null;
        // Attribute Extraction
        String attrLocalName;
        int numAttrs;
        int idxAttr;
        final String S_ProcName = "startElement";
        final String S_LocalName = "LocalName";

        assert qName.equals("SecGroupMember");

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

        ICFAccSchemaObj 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("CreatedAt")) {
                if (attrCreatedAt != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCreatedAt = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("CreatedBy")) {
                if (attrCreatedBy != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCreatedBy = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("UpdatedAt")) {
                if (attrUpdatedAt != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrUpdatedAt = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("UpdatedBy")) {
                if (attrUpdatedBy != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrUpdatedBy = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ClusterId")) {
                if (attrClusterId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrClusterId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("SecGroupMemberId")) {
                if (attrSecGroupMemberId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrSecGroupMemberId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("SecGroupId")) {
                if (attrSecGroupId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrSecGroupId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("SecUserId")) {
                if (attrSecUserId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrSecUserId = 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 ((attrClusterId == null) || (attrClusterId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "ClusterId");
        }
        if ((attrSecGroupMemberId == null) || (attrSecGroupMemberId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "SecGroupMemberId");
        }
        if ((attrSecGroupId == null) || (attrSecGroupId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "SecGroupId");
        }
        if ((attrSecUserId == null) || (attrSecUserId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "SecUserId");
        }

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

        // Convert string attributes to native Java types

        long natClusterId = Long.parseLong(attrClusterId);

        long natSecGroupMemberId = Long.parseLong(attrSecGroupMemberId);

        int natSecGroupId = Integer.parseInt(attrSecGroupId);

        UUID natSecUserId = UUID.fromString(attrSecUserId);

        int natRevision = Integer.parseInt(attrRevision);
        UUID createdBy = null;
        if (attrCreatedBy != null) {
            createdBy = UUID.fromString(attrCreatedBy);
        }
        Calendar createdAt = null;
        if (attrCreatedAt != null) {
            createdAt = CFLibXmlUtil.parseTimestamp(attrCreatedAt);
        }
        UUID updatedBy = null;
        if (attrUpdatedBy != null) {
            updatedBy = UUID.fromString(attrUpdatedBy);
        }
        Calendar updatedAt = null;
        if (attrUpdatedAt != null) {
            updatedAt = CFLibXmlUtil.parseTimestamp(attrUpdatedAt);
        }
        // Get the parent context
        CFLibXmlCoreContext parentContext = curContext.getPrevContext();
        // Instantiate a buffer for the parsed information
        ICFAccSecGroupMemberObj obj = schemaObj.getSecGroupMemberTableObj().newInstance();
        CFAccSecGroupMemberBuff dataBuff = obj.getSecGroupMemberBuff();
        dataBuff.setRequiredClusterId(natClusterId);
        dataBuff.setRequiredSecGroupMemberId(natSecGroupMemberId);
        dataBuff.setRequiredSecGroupId(natSecGroupId);
        dataBuff.setRequiredSecUserId(natSecUserId);
        dataBuff.setRequiredRevision(natRevision);
        if (createdBy != null) {
            dataBuff.setCreatedByUserId(createdBy);
        }
        if (createdAt != null) {
            dataBuff.setCreatedAt(createdAt);
        }
        if (updatedBy != null) {
            dataBuff.setUpdatedByUserId(updatedBy);
        }
        if (updatedAt != null) {
            dataBuff.setUpdatedAt(updatedAt);
        }
        obj.copyBuffToPKey();
        SortedMap<CFAccSecGroupMemberPKey, ICFAccSecGroupMemberObj> sortedMap = (SortedMap<CFAccSecGroupMemberPKey, ICFAccSecGroupMemberObj>) xmsgRspnHandler
                .getSortedMapOfObjects();
        ICFAccSecGroupMemberObj realized = (ICFAccSecGroupMemberObj) obj.realize();
        xmsgRspnHandler.setLastObjectProcessed(realized);
        if (sortedMap != null) {
            sortedMap.put(realized.getPKey(), 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.cfacc.v2_0.CFAccXMsgRspnHandler.CFAccXMsgRspnURLProtocolRecHandler.java

public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
    try {/*from   w ww.  java 2  s  . c o m*/
        // Common XML Attributes
        String attrId = null;
        String attrRevision = null;
        // URLProtocol Attributes
        String attrURLProtocolId = null;
        String attrName = null;
        String attrDescription = null;
        String attrIsSecure = null;
        String attrCreatedAt = null;
        String attrCreatedBy = null;
        String attrUpdatedAt = null;
        String attrUpdatedBy = null;
        // Attribute Extraction
        String attrLocalName;
        int numAttrs;
        int idxAttr;
        final String S_ProcName = "startElement";
        final String S_LocalName = "LocalName";

        assert qName.equals("URLProtocol");

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

        ICFAccSchemaObj 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("CreatedAt")) {
                if (attrCreatedAt != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCreatedAt = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("CreatedBy")) {
                if (attrCreatedBy != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCreatedBy = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("UpdatedAt")) {
                if (attrUpdatedAt != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrUpdatedAt = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("UpdatedBy")) {
                if (attrUpdatedBy != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrUpdatedBy = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("URLProtocolId")) {
                if (attrURLProtocolId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrURLProtocolId = 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("Description")) {
                if (attrDescription != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrDescription = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("IsSecure")) {
                if (attrIsSecure != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrIsSecure = 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 ((attrURLProtocolId == null) || (attrURLProtocolId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "URLProtocolId");
        }
        if (attrName == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "Name");
        }
        if (attrDescription == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "Description");
        }
        if ((attrIsSecure == null) || (attrIsSecure.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "IsSecure");
        }

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

        // Convert string attributes to native Java types

        short natURLProtocolId = Short.parseShort(attrURLProtocolId);

        String natName = attrName;

        String natDescription = attrDescription;

        boolean natIsSecure;
        if (attrIsSecure.equals("true") || attrIsSecure.equals("yes") || attrIsSecure.equals("1")) {
            natIsSecure = true;
        } else if (attrIsSecure.equals("false") || attrIsSecure.equals("no") || attrIsSecure.equals("0")) {
            natIsSecure = false;
        } else {
            throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                    "Unexpected IsSecure value, must be one of true, false, yes, no, 1, or 0, not \""
                            + attrIsSecure + "\"");
        }

        int natRevision = Integer.parseInt(attrRevision);
        UUID createdBy = null;
        if (attrCreatedBy != null) {
            createdBy = UUID.fromString(attrCreatedBy);
        }
        Calendar createdAt = null;
        if (attrCreatedAt != null) {
            createdAt = CFLibXmlUtil.parseTimestamp(attrCreatedAt);
        }
        UUID updatedBy = null;
        if (attrUpdatedBy != null) {
            updatedBy = UUID.fromString(attrUpdatedBy);
        }
        Calendar updatedAt = null;
        if (attrUpdatedAt != null) {
            updatedAt = CFLibXmlUtil.parseTimestamp(attrUpdatedAt);
        }
        // Get the parent context
        CFLibXmlCoreContext parentContext = curContext.getPrevContext();
        // Instantiate a buffer for the parsed information
        ICFAccURLProtocolObj obj = schemaObj.getURLProtocolTableObj().newInstance();
        CFAccURLProtocolBuff dataBuff = obj.getURLProtocolBuff();
        dataBuff.setRequiredURLProtocolId(natURLProtocolId);
        dataBuff.setRequiredName(natName);
        dataBuff.setRequiredDescription(natDescription);
        dataBuff.setRequiredIsSecure(natIsSecure);
        dataBuff.setRequiredRevision(natRevision);
        if (createdBy != null) {
            dataBuff.setCreatedByUserId(createdBy);
        }
        if (createdAt != null) {
            dataBuff.setCreatedAt(createdAt);
        }
        if (updatedBy != null) {
            dataBuff.setUpdatedByUserId(updatedBy);
        }
        if (updatedAt != null) {
            dataBuff.setUpdatedAt(updatedAt);
        }
        obj.copyBuffToPKey();
        SortedMap<CFAccURLProtocolPKey, ICFAccURLProtocolObj> sortedMap = (SortedMap<CFAccURLProtocolPKey, ICFAccURLProtocolObj>) xmsgRspnHandler
                .getSortedMapOfObjects();
        ICFAccURLProtocolObj realized = (ICFAccURLProtocolObj) obj.realize();
        xmsgRspnHandler.setLastObjectProcessed(realized);
        if (sortedMap != null) {
            sortedMap.put(realized.getPKey(), 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.cfasterisk.v2_0.CFAstXMsgRspnHandler.CFAstXMsgRspnSecGroupMemberRecHandler.java

public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
    try {//from  ww  w  .j a  va2 s  .  c om
        // Common XML Attributes
        String attrId = null;
        String attrRevision = null;
        // SecGroupMember Attributes
        String attrClusterId = null;
        String attrSecGroupMemberId = null;
        String attrSecGroupId = null;
        String attrSecUserId = null;
        String attrCreatedAt = null;
        String attrCreatedBy = null;
        String attrUpdatedAt = null;
        String attrUpdatedBy = null;
        // Attribute Extraction
        String attrLocalName;
        int numAttrs;
        int idxAttr;
        final String S_ProcName = "startElement";
        final String S_LocalName = "LocalName";

        assert qName.equals("SecGroupMember");

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

        ICFAstSchemaObj 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("CreatedAt")) {
                if (attrCreatedAt != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCreatedAt = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("CreatedBy")) {
                if (attrCreatedBy != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCreatedBy = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("UpdatedAt")) {
                if (attrUpdatedAt != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrUpdatedAt = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("UpdatedBy")) {
                if (attrUpdatedBy != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrUpdatedBy = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ClusterId")) {
                if (attrClusterId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrClusterId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("SecGroupMemberId")) {
                if (attrSecGroupMemberId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrSecGroupMemberId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("SecGroupId")) {
                if (attrSecGroupId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrSecGroupId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("SecUserId")) {
                if (attrSecUserId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrSecUserId = 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 ((attrClusterId == null) || (attrClusterId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "ClusterId");
        }
        if ((attrSecGroupMemberId == null) || (attrSecGroupMemberId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "SecGroupMemberId");
        }
        if ((attrSecGroupId == null) || (attrSecGroupId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "SecGroupId");
        }
        if ((attrSecUserId == null) || (attrSecUserId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "SecUserId");
        }

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

        // Convert string attributes to native Java types

        long natClusterId = Long.parseLong(attrClusterId);

        long natSecGroupMemberId = Long.parseLong(attrSecGroupMemberId);

        int natSecGroupId = Integer.parseInt(attrSecGroupId);

        UUID natSecUserId = UUID.fromString(attrSecUserId);

        int natRevision = Integer.parseInt(attrRevision);
        UUID createdBy = null;
        if (attrCreatedBy != null) {
            createdBy = UUID.fromString(attrCreatedBy);
        }
        Calendar createdAt = null;
        if (attrCreatedAt != null) {
            createdAt = CFLibXmlUtil.parseTimestamp(attrCreatedAt);
        }
        UUID updatedBy = null;
        if (attrUpdatedBy != null) {
            updatedBy = UUID.fromString(attrUpdatedBy);
        }
        Calendar updatedAt = null;
        if (attrUpdatedAt != null) {
            updatedAt = CFLibXmlUtil.parseTimestamp(attrUpdatedAt);
        }
        // Get the parent context
        CFLibXmlCoreContext parentContext = curContext.getPrevContext();
        // Instantiate a buffer for the parsed information
        ICFAstSecGroupMemberObj obj = schemaObj.getSecGroupMemberTableObj().newInstance();
        CFAstSecGroupMemberBuff dataBuff = obj.getSecGroupMemberBuff();
        dataBuff.setRequiredClusterId(natClusterId);
        dataBuff.setRequiredSecGroupMemberId(natSecGroupMemberId);
        dataBuff.setRequiredSecGroupId(natSecGroupId);
        dataBuff.setRequiredSecUserId(natSecUserId);
        dataBuff.setRequiredRevision(natRevision);
        if (createdBy != null) {
            dataBuff.setCreatedByUserId(createdBy);
        }
        if (createdAt != null) {
            dataBuff.setCreatedAt(createdAt);
        }
        if (updatedBy != null) {
            dataBuff.setUpdatedByUserId(updatedBy);
        }
        if (updatedAt != null) {
            dataBuff.setUpdatedAt(updatedAt);
        }
        obj.copyBuffToPKey();
        SortedMap<CFAstSecGroupMemberPKey, ICFAstSecGroupMemberObj> sortedMap = (SortedMap<CFAstSecGroupMemberPKey, ICFAstSecGroupMemberObj>) xmsgRspnHandler
                .getSortedMapOfObjects();
        ICFAstSecGroupMemberObj realized = (ICFAstSecGroupMemberObj) obj.realize();
        xmsgRspnHandler.setLastObjectProcessed(realized);
        if (sortedMap != null) {
            sortedMap.put(realized.getPKey(), 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.cfasterisk.v2_0.CFAstXMsgRspnHandler.CFAstXMsgRspnURLProtocolRecHandler.java

public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
    try {//from w  ww .j av  a  2s .co m
        // Common XML Attributes
        String attrId = null;
        String attrRevision = null;
        // URLProtocol Attributes
        String attrURLProtocolId = null;
        String attrName = null;
        String attrDescription = null;
        String attrIsSecure = null;
        String attrCreatedAt = null;
        String attrCreatedBy = null;
        String attrUpdatedAt = null;
        String attrUpdatedBy = null;
        // Attribute Extraction
        String attrLocalName;
        int numAttrs;
        int idxAttr;
        final String S_ProcName = "startElement";
        final String S_LocalName = "LocalName";

        assert qName.equals("URLProtocol");

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

        ICFAstSchemaObj 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("CreatedAt")) {
                if (attrCreatedAt != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCreatedAt = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("CreatedBy")) {
                if (attrCreatedBy != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCreatedBy = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("UpdatedAt")) {
                if (attrUpdatedAt != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrUpdatedAt = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("UpdatedBy")) {
                if (attrUpdatedBy != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrUpdatedBy = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("URLProtocolId")) {
                if (attrURLProtocolId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrURLProtocolId = 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("Description")) {
                if (attrDescription != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrDescription = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("IsSecure")) {
                if (attrIsSecure != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrIsSecure = 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 ((attrURLProtocolId == null) || (attrURLProtocolId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "URLProtocolId");
        }
        if (attrName == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "Name");
        }
        if (attrDescription == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "Description");
        }
        if ((attrIsSecure == null) || (attrIsSecure.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "IsSecure");
        }

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

        // Convert string attributes to native Java types

        short natURLProtocolId = Short.parseShort(attrURLProtocolId);

        String natName = attrName;

        String natDescription = attrDescription;

        boolean natIsSecure;
        if (attrIsSecure.equals("true") || attrIsSecure.equals("yes") || attrIsSecure.equals("1")) {
            natIsSecure = true;
        } else if (attrIsSecure.equals("false") || attrIsSecure.equals("no") || attrIsSecure.equals("0")) {
            natIsSecure = false;
        } else {
            throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                    "Unexpected IsSecure value, must be one of true, false, yes, no, 1, or 0, not \""
                            + attrIsSecure + "\"");
        }

        int natRevision = Integer.parseInt(attrRevision);
        UUID createdBy = null;
        if (attrCreatedBy != null) {
            createdBy = UUID.fromString(attrCreatedBy);
        }
        Calendar createdAt = null;
        if (attrCreatedAt != null) {
            createdAt = CFLibXmlUtil.parseTimestamp(attrCreatedAt);
        }
        UUID updatedBy = null;
        if (attrUpdatedBy != null) {
            updatedBy = UUID.fromString(attrUpdatedBy);
        }
        Calendar updatedAt = null;
        if (attrUpdatedAt != null) {
            updatedAt = CFLibXmlUtil.parseTimestamp(attrUpdatedAt);
        }
        // Get the parent context
        CFLibXmlCoreContext parentContext = curContext.getPrevContext();
        // Instantiate a buffer for the parsed information
        ICFAstURLProtocolObj obj = schemaObj.getURLProtocolTableObj().newInstance();
        CFAstURLProtocolBuff dataBuff = obj.getURLProtocolBuff();
        dataBuff.setRequiredURLProtocolId(natURLProtocolId);
        dataBuff.setRequiredName(natName);
        dataBuff.setRequiredDescription(natDescription);
        dataBuff.setRequiredIsSecure(natIsSecure);
        dataBuff.setRequiredRevision(natRevision);
        if (createdBy != null) {
            dataBuff.setCreatedByUserId(createdBy);
        }
        if (createdAt != null) {
            dataBuff.setCreatedAt(createdAt);
        }
        if (updatedBy != null) {
            dataBuff.setUpdatedByUserId(updatedBy);
        }
        if (updatedAt != null) {
            dataBuff.setUpdatedAt(updatedAt);
        }
        obj.copyBuffToPKey();
        SortedMap<CFAstURLProtocolPKey, ICFAstURLProtocolObj> sortedMap = (SortedMap<CFAstURLProtocolPKey, ICFAstURLProtocolObj>) xmsgRspnHandler
                .getSortedMapOfObjects();
        ICFAstURLProtocolObj realized = (ICFAstURLProtocolObj) obj.realize();
        xmsgRspnHandler.setLastObjectProcessed(realized);
        if (sortedMap != null) {
            sortedMap.put(realized.getPKey(), 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.cfacc.v2_0.CFAccXMsgRspnHandler.CFAccXMsgRspnISOCurrencyRecHandler.java

public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
    try {//  w  w  w .j av  a2 s .co  m
        // Common XML Attributes
        String attrId = null;
        String attrRevision = null;
        // ISOCurrency Attributes
        String attrISOCode = null;
        String attrName = null;
        String attrUnitSymbol = null;
        String attrFracSymbol = null;
        String attrPrecis = null;
        String attrCreatedAt = null;
        String attrCreatedBy = null;
        String attrUpdatedAt = null;
        String attrUpdatedBy = null;
        // Attribute Extraction
        String attrLocalName;
        int numAttrs;
        int idxAttr;
        final String S_ProcName = "startElement";
        final String S_LocalName = "LocalName";

        assert qName.equals("ISOCurrency");

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

        ICFAccSchemaObj 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("CreatedAt")) {
                if (attrCreatedAt != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCreatedAt = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("CreatedBy")) {
                if (attrCreatedBy != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCreatedBy = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("UpdatedAt")) {
                if (attrUpdatedAt != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrUpdatedAt = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("UpdatedBy")) {
                if (attrUpdatedBy != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrUpdatedBy = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ISOCode")) {
                if (attrISOCode != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrISOCode = 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("UnitSymbol")) {
                if (attrUnitSymbol != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrUnitSymbol = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("FracSymbol")) {
                if (attrFracSymbol != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrFracSymbol = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("Precis")) {
                if (attrPrecis != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrPrecis = 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 ((attrId == null) || (attrId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "Id");
        }
        if (attrISOCode == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "ISOCode");
        }
        if (attrName == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "Name");
        }
        if ((attrPrecis == null) || (attrPrecis.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "Precis");
        }

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

        // Convert string attributes to native Java types

        short natId = Short.parseShort(attrId);

        String natISOCode = attrISOCode;

        String natName = attrName;

        String natUnitSymbol = attrUnitSymbol;

        String natFracSymbol = attrFracSymbol;

        short natPrecis = Short.parseShort(attrPrecis);

        int natRevision = Integer.parseInt(attrRevision);
        UUID createdBy = null;
        if (attrCreatedBy != null) {
            createdBy = UUID.fromString(attrCreatedBy);
        }
        Calendar createdAt = null;
        if (attrCreatedAt != null) {
            createdAt = CFLibXmlUtil.parseTimestamp(attrCreatedAt);
        }
        UUID updatedBy = null;
        if (attrUpdatedBy != null) {
            updatedBy = UUID.fromString(attrUpdatedBy);
        }
        Calendar updatedAt = null;
        if (attrUpdatedAt != null) {
            updatedAt = CFLibXmlUtil.parseTimestamp(attrUpdatedAt);
        }
        // Get the parent context
        CFLibXmlCoreContext parentContext = curContext.getPrevContext();
        // Instantiate a buffer for the parsed information
        ICFAccISOCurrencyObj obj = schemaObj.getISOCurrencyTableObj().newInstance();
        CFAccISOCurrencyBuff dataBuff = obj.getISOCurrencyBuff();
        dataBuff.setRequiredId(natId);
        dataBuff.setRequiredISOCode(natISOCode);
        dataBuff.setRequiredName(natName);
        dataBuff.setOptionalUnitSymbol(natUnitSymbol);
        dataBuff.setOptionalFracSymbol(natFracSymbol);
        dataBuff.setRequiredPrecis(natPrecis);
        dataBuff.setRequiredRevision(natRevision);
        if (createdBy != null) {
            dataBuff.setCreatedByUserId(createdBy);
        }
        if (createdAt != null) {
            dataBuff.setCreatedAt(createdAt);
        }
        if (updatedBy != null) {
            dataBuff.setUpdatedByUserId(updatedBy);
        }
        if (updatedAt != null) {
            dataBuff.setUpdatedAt(updatedAt);
        }
        obj.copyBuffToPKey();
        SortedMap<CFAccISOCurrencyPKey, ICFAccISOCurrencyObj> sortedMap = (SortedMap<CFAccISOCurrencyPKey, ICFAccISOCurrencyObj>) xmsgRspnHandler
                .getSortedMapOfObjects();
        ICFAccISOCurrencyObj realized = (ICFAccISOCurrencyObj) obj.realize();
        xmsgRspnHandler.setLastObjectProcessed(realized);
        if (sortedMap != null) {
            sortedMap.put(realized.getPKey(), 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);
    }
}