public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { try { // Common XML Attributes String attrId = null; // SecApp Attributes String attrJEEMountName = null; // SecApp References ICFDbTestClusterObj refCluster = null; // Attribute Extraction String attrLocalName; int numAttrs; int idxAttr; final String S_ProcName = "startElement"; final String S_LocalName = "LocalName"; assert qName.equals("SecApp"); CFDbTestSaxLoader saxLoader = (CFDbTestSaxLoader) getParser(); if (saxLoader == null) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "getParser()"); } ICFDbTestSchemaObj schemaObj = saxLoader.getSchemaObj(); if (schemaObj == null) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "getParser().getSchemaObj()"); } // Instantiate an edit buffer for the parsed information ICFDbTestSecAppEditObj editBuff = (ICFDbTestSecAppEditObj) schemaObj.getSecAppTableObj().newInstance().beginEdit(); // 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("JEEMountName")) { if (attrJEEMountName != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrJEEMountName = 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 (attrJEEMountName == null) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "JEEMountName"); } // Save named attributes to context CFLibXmlCoreContext curContext = getParser().getCurContext(); curContext.putNamedValue("Id", attrId); curContext.putNamedValue("JEEMountName", attrJEEMountName); // Convert string attributes to native Java types // and apply the converted attributes to the editBuff. Integer natId; if ((attrId != null) && (attrId.length() > 0)) { natId = new Integer(Integer.parseInt(attrId)); } else { natId = null; } String natJEEMountName = attrJEEMountName; editBuff.setRequiredJEEMountName(natJEEMountName); // Get the scope/container object CFLibXmlCoreContext parentContext = curContext.getPrevContext(); Object scopeObj; if (parentContext != null) { scopeObj = parentContext.getNamedValue("Object"); } else { scopeObj = null; } // Resolve and apply required Container reference if (scopeObj == null) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "scopeObj"); } else if (scopeObj instanceof ICFDbTestClusterObj) { refCluster = (ICFDbTestClusterObj) scopeObj; editBuff.setRequiredContainerCluster(refCluster); } else { throw CFLib.getDefaultExceptionFactory() .newUnsupportedClassException( getClass(), S_ProcName, "scopeObj", scopeObj, "ICFDbTestClusterObj"); } CFDbTestSaxLoader.LoaderBehaviourEnum loaderBehaviour = saxLoader.getSecAppLoaderBehaviour(); ICFDbTestSecAppEditObj editSecApp = null; ICFDbTestSecAppObj origSecApp = (ICFDbTestSecAppObj) schemaObj .getSecAppTableObj() .readSecAppByUJEEMountIdx( refCluster.getRequiredId(), editBuff.getRequiredJEEMountName()); if (origSecApp == null) { editSecApp = editBuff; } else { switch (loaderBehaviour) { case Insert: break; case Update: editSecApp = (ICFDbTestSecAppEditObj) origSecApp.beginEdit(); editSecApp.setRequiredJEEMountName(editBuff.getRequiredJEEMountName()); break; case Replace: editSecApp = (ICFDbTestSecAppEditObj) origSecApp.beginEdit(); editSecApp.delete(); editSecApp.endEdit(); origSecApp = null; editSecApp = editBuff; break; } } if (editSecApp != null) { if (origSecApp != null) { editSecApp.update(); } else { origSecApp = (ICFDbTestSecAppObj) editSecApp.create(); } editSecApp.endEdit(); } curContext.putNamedValue("Object", origSecApp); } 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); } }
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { try { // Common XML Attributes String attrId = null; // OptMaxValue Attributes String attrDescription = null; String attrTestInt16 = null; String attrTestInt32 = null; String attrTestInt64 = null; String attrTestUInt16 = null; String attrTestUInt32 = null; String attrTestUInt64 = null; String attrTestFloat = null; String attrTestDouble = null; String attrTestNumber = null; String attrTestDate = null; String attrTestTimestamp = null; String attrTestTZDate = null; String attrTestTZTimestamp = null; // OptMaxValue References ICFDbTestTenantObj refTenant = null; // Attribute Extraction String attrLocalName; int numAttrs; int idxAttr; final String S_ProcName = "startElement"; final String S_LocalName = "LocalName"; assert qName.equals("OptMaxValue"); CFDbTestSaxLoader saxLoader = (CFDbTestSaxLoader) getParser(); if (saxLoader == null) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "getParser()"); } ICFDbTestSchemaObj schemaObj = saxLoader.getSchemaObj(); if (schemaObj == null) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "getParser().getSchemaObj()"); } // Instantiate an edit buffer for the parsed information ICFDbTestOptMaxValueEditObj editBuff = (ICFDbTestOptMaxValueEditObj) schemaObj.getOptMaxValueTableObj().newInstance().beginEdit(); // 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("Description")) { if (attrDescription != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrDescription = attrs.getValue(idxAttr); } else if (attrLocalName.equals("TestInt16")) { if (attrTestInt16 != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrTestInt16 = attrs.getValue(idxAttr); } else if (attrLocalName.equals("TestInt32")) { if (attrTestInt32 != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrTestInt32 = attrs.getValue(idxAttr); } else if (attrLocalName.equals("TestInt64")) { if (attrTestInt64 != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrTestInt64 = attrs.getValue(idxAttr); } else if (attrLocalName.equals("TestUInt16")) { if (attrTestUInt16 != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrTestUInt16 = attrs.getValue(idxAttr); } else if (attrLocalName.equals("TestUInt32")) { if (attrTestUInt32 != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrTestUInt32 = attrs.getValue(idxAttr); } else if (attrLocalName.equals("TestUInt64")) { if (attrTestUInt64 != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrTestUInt64 = attrs.getValue(idxAttr); } else if (attrLocalName.equals("TestFloat")) { if (attrTestFloat != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrTestFloat = attrs.getValue(idxAttr); } else if (attrLocalName.equals("TestDouble")) { if (attrTestDouble != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrTestDouble = attrs.getValue(idxAttr); } else if (attrLocalName.equals("TestNumber")) { if (attrTestNumber != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrTestNumber = attrs.getValue(idxAttr); } else if (attrLocalName.equals("TestDate")) { if (attrTestDate != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrTestDate = attrs.getValue(idxAttr); } else if (attrLocalName.equals("TestTimestamp")) { if (attrTestTimestamp != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrTestTimestamp = attrs.getValue(idxAttr); } else if (attrLocalName.equals("TestTZDate")) { if (attrTestTZDate != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrTestTZDate = attrs.getValue(idxAttr); } else if (attrLocalName.equals("TestTZTimestamp")) { if (attrTestTZTimestamp != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrTestTZTimestamp = 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 (attrDescription == null) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "Description"); } // Save named attributes to context CFLibXmlCoreContext curContext = getParser().getCurContext(); curContext.putNamedValue("Id", attrId); curContext.putNamedValue("Description", attrDescription); curContext.putNamedValue("TestInt16", attrTestInt16); curContext.putNamedValue("TestInt32", attrTestInt32); curContext.putNamedValue("TestInt64", attrTestInt64); curContext.putNamedValue("TestUInt16", attrTestUInt16); curContext.putNamedValue("TestUInt32", attrTestUInt32); curContext.putNamedValue("TestUInt64", attrTestUInt64); curContext.putNamedValue("TestFloat", attrTestFloat); curContext.putNamedValue("TestDouble", attrTestDouble); curContext.putNamedValue("TestNumber", attrTestNumber); curContext.putNamedValue("TestDate", attrTestDate); curContext.putNamedValue("TestTimestamp", attrTestTimestamp); curContext.putNamedValue("TestTZDate", attrTestTZDate); curContext.putNamedValue("TestTZTimestamp", attrTestTZTimestamp); // Convert string attributes to native Java types // and apply the converted attributes to the editBuff. Integer natId; if ((attrId != null) && (attrId.length() > 0)) { natId = new Integer(Integer.parseInt(attrId)); } else { natId = null; } String natDescription = attrDescription; editBuff.setRequiredDescription(natDescription); Short natTestInt16; if ((attrTestInt16 == null) || (attrTestInt16.length() <= 0)) { natTestInt16 = null; } else { natTestInt16 = new Short(Short.parseShort(attrTestInt16)); } editBuff.setOptionalTestInt16(natTestInt16); Integer natTestInt32; if ((attrTestInt32 == null) || (attrTestInt32.length() <= 0)) { natTestInt32 = null; } else { natTestInt32 = new Integer(Integer.parseInt(attrTestInt32)); } editBuff.setOptionalTestInt32(natTestInt32); Long natTestInt64; if ((attrTestInt64 == null) || (attrTestInt64.length() <= 0)) { natTestInt64 = null; } else { natTestInt64 = new Long(Long.parseLong(attrTestInt64)); } editBuff.setOptionalTestInt64(natTestInt64); Integer natTestUInt16; if ((attrTestUInt16 == null) || (attrTestUInt16.length() <= 0)) { natTestUInt16 = null; } else { natTestUInt16 = new Integer(Integer.parseInt(attrTestUInt16)); } editBuff.setOptionalTestUInt16(natTestUInt16); Long natTestUInt32; if ((attrTestUInt32 == null) || (attrTestUInt32.length() <= 0)) { natTestUInt32 = null; } else { natTestUInt32 = new Long(Long.parseLong(attrTestUInt32)); } editBuff.setOptionalTestUInt32(natTestUInt32); BigDecimal natTestUInt64; if ((attrTestUInt64 == null) || (attrTestUInt64.length() <= 0)) { natTestUInt64 = null; } else { natTestUInt64 = CFLibBigDecimalUtil.parse("CFDbTest.OptMaxValue.TestUInt64", 19, 0, attrTestUInt64); } editBuff.setOptionalTestUInt64(natTestUInt64); Float natTestFloat; if ((attrTestFloat == null) || (attrTestFloat.length() <= 0)) { natTestFloat = null; } else { natTestFloat = new Float(Float.parseFloat(attrTestFloat)); } editBuff.setOptionalTestFloat(natTestFloat); Double natTestDouble; if ((attrTestDouble == null) || (attrTestDouble.length() <= 0)) { natTestDouble = null; } else { natTestDouble = new Double(Double.parseDouble(attrTestDouble)); } editBuff.setOptionalTestDouble(natTestDouble); BigDecimal natTestNumber; if ((attrTestNumber == null) || (attrTestNumber.length() <= 0)) { natTestNumber = null; } else { natTestNumber = CFLibBigDecimalUtil.parse("CFDbTest.OptMaxValue.TestNumber", 20, 0, attrTestNumber); } editBuff.setOptionalTestNumber(natTestNumber); Calendar natTestDate; if ((attrTestDate == null) || (attrTestDate.length() <= 0)) { natTestDate = null; } else { try { natTestDate = CFLibXmlUtil.parseDate(attrTestDate); } catch (RuntimeException e) { throw CFLib.getDefaultExceptionFactory() .newInvalidArgumentException(getClass(), S_ProcName, 0, "TestDate", attrTestDate, e); } } editBuff.setOptionalTestDate(natTestDate); Calendar natTestTimestamp; if ((attrTestTimestamp == null) || (attrTestTimestamp.length() <= 0)) { natTestTimestamp = null; } else { try { natTestTimestamp = CFLibXmlUtil.parseTimestamp(attrTestTimestamp); } catch (RuntimeException e) { throw CFLib.getDefaultExceptionFactory() .newInvalidArgumentException( getClass(), S_ProcName, 0, "TestTimestamp", attrTestTimestamp, e); } } editBuff.setOptionalTestTimestamp(natTestTimestamp); Calendar natTestTZDate; if ((attrTestTZDate == null) || (attrTestTZDate.length() <= 0)) { natTestTZDate = null; } else { try { natTestTZDate = CFLibXmlUtil.parseTZDate(attrTestTZDate); } catch (RuntimeException e) { throw CFLib.getDefaultExceptionFactory() .newInvalidArgumentException( getClass(), S_ProcName, 0, "TestTZDate", attrTestTZDate, e); } } editBuff.setOptionalTestTZDate(natTestTZDate); Calendar natTestTZTimestamp; if ((attrTestTZTimestamp == null) || (attrTestTZTimestamp.length() <= 0)) { natTestTZTimestamp = null; } else { try { natTestTZTimestamp = CFLibXmlUtil.parseTZTimestamp(attrTestTZTimestamp); } catch (RuntimeException e) { throw CFLib.getDefaultExceptionFactory() .newInvalidArgumentException( getClass(), S_ProcName, 0, "TestTZTimestamp", attrTestTZTimestamp, e); } } editBuff.setOptionalTestTZTimestamp(natTestTZTimestamp); // Get the scope/container object CFLibXmlCoreContext parentContext = curContext.getPrevContext(); Object scopeObj; if (parentContext != null) { scopeObj = parentContext.getNamedValue("Object"); } else { scopeObj = null; } // Resolve and apply required Container reference if (scopeObj == null) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "scopeObj"); } else if (scopeObj instanceof ICFDbTestTenantObj) { refTenant = (ICFDbTestTenantObj) scopeObj; editBuff.setRequiredContainerTenant(refTenant); } else { throw CFLib.getDefaultExceptionFactory() .newUnsupportedClassException( getClass(), S_ProcName, "scopeObj", scopeObj, "ICFDbTestTenantObj"); } CFDbTestSaxLoader.LoaderBehaviourEnum loaderBehaviour = saxLoader.getOptMaxValueLoaderBehaviour(); ICFDbTestOptMaxValueEditObj editOptMaxValue = null; ICFDbTestOptMaxValueObj origOptMaxValue = (ICFDbTestOptMaxValueObj) schemaObj .getOptMaxValueTableObj() .readOptMaxValueByUDescrIdx( refTenant.getRequiredId(), editBuff.getRequiredDescription()); if (origOptMaxValue == null) { editOptMaxValue = editBuff; } else { switch (loaderBehaviour) { case Insert: break; case Update: editOptMaxValue = (ICFDbTestOptMaxValueEditObj) origOptMaxValue.beginEdit(); editOptMaxValue.setRequiredDescription(editBuff.getRequiredDescription()); editOptMaxValue.setOptionalTestInt16(editBuff.getOptionalTestInt16()); editOptMaxValue.setOptionalTestInt32(editBuff.getOptionalTestInt32()); editOptMaxValue.setOptionalTestInt64(editBuff.getOptionalTestInt64()); editOptMaxValue.setOptionalTestUInt16(editBuff.getOptionalTestUInt16()); editOptMaxValue.setOptionalTestUInt32(editBuff.getOptionalTestUInt32()); editOptMaxValue.setOptionalTestUInt64(editBuff.getOptionalTestUInt64()); editOptMaxValue.setOptionalTestFloat(editBuff.getOptionalTestFloat()); editOptMaxValue.setOptionalTestDouble(editBuff.getOptionalTestDouble()); editOptMaxValue.setOptionalTestNumber(editBuff.getOptionalTestNumber()); editOptMaxValue.setOptionalTestDate(editBuff.getOptionalTestDate()); editOptMaxValue.setOptionalTestTimestamp(editBuff.getOptionalTestTimestamp()); editOptMaxValue.setOptionalTestTZDate(editBuff.getOptionalTestTZDate()); editOptMaxValue.setOptionalTestTZTimestamp(editBuff.getOptionalTestTZTimestamp()); break; case Replace: editOptMaxValue = (ICFDbTestOptMaxValueEditObj) origOptMaxValue.beginEdit(); editOptMaxValue.delete(); editOptMaxValue.endEdit(); origOptMaxValue = null; editOptMaxValue = editBuff; break; } } if (editOptMaxValue != null) { if (origOptMaxValue != null) { editOptMaxValue.update(); } else { origOptMaxValue = (ICFDbTestOptMaxValueObj) editOptMaxValue.create(); } editOptMaxValue.endEdit(); } curContext.putNamedValue("Object", origOptMaxValue); } 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); } }