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); } }
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { try { // Common XML Attributes String attrId = null; // Value Attributes String attrName = null; String attrDefaultVisibility = null; // Value References ICFDbTestTenantObj refTenant = null; ICFDbTestScopeObj refScope = null; // Atom Attributes // Atom References // UInt64Def Attributes // UInt64Def References // UInt64Type Attributes // UInt64Type References ICFDbTestSchemaDefObj refSchemaDef = null; // Attribute Extraction String attrLocalName; int numAttrs; int idxAttr; final String S_ProcName = "startElement"; final String S_LocalName = "LocalName"; assert qName.equals("UInt64Type"); 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 ICFDbTestUInt64TypeEditObj editBuff = (ICFDbTestUInt64TypeEditObj) schemaObj.getUInt64TypeTableObj().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("Name")) { if (attrName != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrName = attrs.getValue(idxAttr); } else if (attrLocalName.equals("DefaultVisibility")) { if (attrDefaultVisibility != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrDefaultVisibility = 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 (attrName == null) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "Name"); } if ((attrDefaultVisibility == null) || (attrDefaultVisibility.length() <= 0)) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "DefaultVisibility"); } // Save named attributes to context CFLibXmlCoreContext curContext = getParser().getCurContext(); curContext.putNamedValue("Id", attrId); curContext.putNamedValue("Name", attrName); curContext.putNamedValue("DefaultVisibility", attrDefaultVisibility); // 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 natName = attrName; editBuff.setRequiredName(natName); boolean natDefaultVisibility; if (attrDefaultVisibility.equals("true") || attrDefaultVisibility.equals("yes") || attrDefaultVisibility.equals("1")) { natDefaultVisibility = true; } else if (attrDefaultVisibility.equals("false") || attrDefaultVisibility.equals("no") || attrDefaultVisibility.equals("0")) { natDefaultVisibility = false; } else { throw CFLib.getDefaultExceptionFactory() .newUsageException( getClass(), S_ProcName, "Unexpected DefaultVisibility value, must be one of true, false, yes, no, 1, or 0, not \"" + attrDefaultVisibility + "\""); } editBuff.setRequiredDefaultVisibility(natDefaultVisibility); // 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 ICFDbTestSchemaDefObj) { refSchemaDef = (ICFDbTestSchemaDefObj) scopeObj; editBuff.setRequiredContainerSchemaDef(refSchemaDef); refTenant = (ICFDbTestTenantObj) editBuff.getRequiredOwnerTenant(); } else { throw CFLib.getDefaultExceptionFactory() .newUnsupportedClassException( getClass(), S_ProcName, "scopeObj", scopeObj, "ICFDbTestSchemaDefObj"); } // Resolve and apply Owner reference if (refTenant == null) { if (scopeObj instanceof ICFDbTestTenantObj) { refTenant = (ICFDbTestTenantObj) scopeObj; editBuff.setRequiredOwnerTenant(refTenant); } else { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "Owner<Tenant>"); } } refScope = refSchemaDef; CFDbTestSaxLoader.LoaderBehaviourEnum loaderBehaviour = saxLoader.getUInt64TypeLoaderBehaviour(); ICFDbTestUInt64TypeEditObj editUInt64Type = null; ICFDbTestUInt64TypeObj origUInt64Type = (ICFDbTestUInt64TypeObj) schemaObj .getUInt64TypeTableObj() .readUInt64TypeByUNameIdx( refTenant.getRequiredId(), refScope.getRequiredId(), editBuff.getRequiredName()); if (origUInt64Type == null) { editUInt64Type = editBuff; } else { switch (loaderBehaviour) { case Insert: break; case Update: editUInt64Type = (ICFDbTestUInt64TypeEditObj) origUInt64Type.beginEdit(); editUInt64Type.setRequiredName(editBuff.getRequiredName()); editUInt64Type.setRequiredDefaultVisibility(editBuff.getRequiredDefaultVisibility()); break; case Replace: editUInt64Type = (ICFDbTestUInt64TypeEditObj) origUInt64Type.beginEdit(); editUInt64Type.delete(); editUInt64Type.endEdit(); origUInt64Type = null; editUInt64Type = editBuff; break; } } if (editUInt64Type != null) { if (origUInt64Type != null) { editUInt64Type.update(); } else { origUInt64Type = (ICFDbTestUInt64TypeObj) editUInt64Type.create(); } editUInt64Type.endEdit(); } curContext.putNamedValue("Object", origUInt64Type); } 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); } }