public String expandBody(MssCFGenContext genContext) { final String S_ProcName = "CFBamMssCFBindInt16DefMaxValue.expandBody() "; if (genContext == null) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), "expandBody", 1, "genContext"); } ICFLibAnyObj genDef = genContext.getGenDef(); if (genDef == null) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), "expandBody", 1, "genContext.getGenDef()"); } String ret; if (genDef instanceof ICFBamInt16DefObj) { Short maxValue = ((ICFBamInt16DefObj) genDef).getOptionalMaxValue(); if (maxValue == null) { ret = null; } else { ret = maxValue.toString(); } } else { throw CFLib.getDefaultExceptionFactory() .newUnsupportedClassException( getClass(), "expandBody", "genContext.getGenDef()", genDef, "ICFBamInt16DefObj"); } return (ret); }
public String expandBody(MssCFGenContext genContext) { final String S_ProcName = "CFBamMssCFBindStringDefShowLines.expandBody() "; if (genContext == null) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), "expandBody", 1, "genContext"); } ICFLibAnyObj genDef = genContext.getGenDef(); if (genDef == null) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), "expandBody", 1, "genContext.getGenDef()"); } String ret; if (genDef instanceof ICFBamStringDefObj) { short showLines = ((ICFBamStringDefObj) genDef).getRequiredShowLines(); ret = Short.toString(showLines); } else { throw CFLib.getDefaultExceptionFactory() .newUnsupportedClassException( getClass(), "expandBody", "genContext.getGenDef()", genDef, "ICFBamStringDefObj"); } return (ret); }
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { try { // Common XML Attributes String attrId = null; String attrRevision = null; // Value Attributes String attrTenantId = null; String attrScopeId = null; String attrDefSchemaTenantId = null; String attrDefSchemaId = null; String attrName = null; String attrShortName = null; String attrLabel = null; String attrShortDescription = null; String attrDescription = null; String attrIsNullable = null; String attrGenerateId = null; String attrDataScope = null; String attrViewAccessSecurity = null; String attrEditAccessSecurity = null; String attrViewAccessFrequency = null; String attrEditAccessFrequency = null; String attrPrevTenantId = null; String attrPrevId = null; String attrNextTenantId = null; String attrNextId = null; String attrDefaultVisibility = null; String attrCreatedAt = null; String attrCreatedBy = null; String attrUpdatedAt = null; String attrUpdatedBy = null; // Atom Attributes String attrDbName = null; // NmTokenDef Attributes String attrMaxLen = null; String attrInitValue = null; String attrDefaultValue = null; String attrNullValue = null; String attrUnknownValue = null; String attrShowLines = null; // NmTokenCol Attributes String attrTableId = null; // Attribute Extraction String attrLocalName; int numAttrs; int idxAttr; final String S_ProcName = "startElement"; final String S_LocalName = "LocalName"; assert qName.equals("NmTokenCol"); CFBamXMsgRspnHandler xmsgRspnHandler = (CFBamXMsgRspnHandler) getParser(); if (xmsgRspnHandler == null) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "getParser()"); } ICFBamSchemaObj 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("ScopeId")) { if (attrScopeId != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrScopeId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("DefSchemaTenantId")) { if (attrDefSchemaTenantId != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrDefSchemaTenantId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("DefSchemaId")) { if (attrDefSchemaId != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrDefSchemaId = 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("ShortName")) { if (attrShortName != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrShortName = attrs.getValue(idxAttr); } else if (attrLocalName.equals("Label")) { if (attrLabel != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrLabel = attrs.getValue(idxAttr); } else if (attrLocalName.equals("ShortDescription")) { if (attrShortDescription != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrShortDescription = 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("IsNullable")) { if (attrIsNullable != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrIsNullable = attrs.getValue(idxAttr); } else if (attrLocalName.equals("GenerateId")) { if (attrGenerateId != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrGenerateId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("DataScope")) { if (attrDataScope != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrDataScope = attrs.getValue(idxAttr); } else if (attrLocalName.equals("ViewAccessSecurity")) { if (attrViewAccessSecurity != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrViewAccessSecurity = attrs.getValue(idxAttr); } else if (attrLocalName.equals("EditAccessSecurity")) { if (attrEditAccessSecurity != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrEditAccessSecurity = attrs.getValue(idxAttr); } else if (attrLocalName.equals("ViewAccessFrequency")) { if (attrViewAccessFrequency != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrViewAccessFrequency = attrs.getValue(idxAttr); } else if (attrLocalName.equals("EditAccessFrequency")) { if (attrEditAccessFrequency != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrEditAccessFrequency = attrs.getValue(idxAttr); } else if (attrLocalName.equals("PrevTenantId")) { if (attrPrevTenantId != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrPrevTenantId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("PrevId")) { if (attrPrevId != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrPrevId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("NextTenantId")) { if (attrNextTenantId != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrNextTenantId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("NextId")) { if (attrNextId != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrNextId = 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("DbName")) { if (attrDbName != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrDbName = attrs.getValue(idxAttr); } else if (attrLocalName.equals("MaxLen")) { if (attrMaxLen != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrMaxLen = attrs.getValue(idxAttr); } else if (attrLocalName.equals("InitValue")) { if (attrInitValue != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrInitValue = attrs.getValue(idxAttr); } else if (attrLocalName.equals("DefaultValue")) { if (attrDefaultValue != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrDefaultValue = attrs.getValue(idxAttr); } else if (attrLocalName.equals("NullValue")) { if (attrNullValue != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrNullValue = attrs.getValue(idxAttr); } else if (attrLocalName.equals("UnknownValue")) { if (attrUnknownValue != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrUnknownValue = attrs.getValue(idxAttr); } else if (attrLocalName.equals("ShowLines")) { if (attrShowLines != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrShowLines = attrs.getValue(idxAttr); } else if (attrLocalName.equals("TableId")) { if (attrTableId != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrTableId = 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 ((attrScopeId == null) || (attrScopeId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "ScopeId"); } if ((attrId == null) || (attrId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "Id"); } if (attrName == null) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "Name"); } if ((attrIsNullable == null) || (attrIsNullable.length() <= 0)) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "IsNullable"); } if ((attrDefaultVisibility == null) || (attrDefaultVisibility.length() <= 0)) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "DefaultVisibility"); } if ((attrMaxLen == null) || (attrMaxLen.length() <= 0)) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "MaxLen"); } if ((attrShowLines == null) || (attrShowLines.length() <= 0)) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "ShowLines"); } if ((attrTableId == null) || (attrTableId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "TableId"); } // Save named attributes to context CFLibXmlCoreContext curContext = xmsgRspnHandler.getCurContext(); // Convert string attributes to native Java types long natTenantId = Long.parseLong(attrTenantId); long natScopeId = Long.parseLong(attrScopeId); long natId = Long.parseLong(attrId); Long natDefSchemaTenantId; if ((attrDefSchemaTenantId == null) || (attrDefSchemaTenantId.length() <= 0)) { natDefSchemaTenantId = null; } else { natDefSchemaTenantId = new Long(Long.parseLong(attrDefSchemaTenantId)); } Long natDefSchemaId; if ((attrDefSchemaId == null) || (attrDefSchemaId.length() <= 0)) { natDefSchemaId = null; } else { natDefSchemaId = new Long(Long.parseLong(attrDefSchemaId)); } String natName = attrName; String natShortName = attrShortName; String natLabel = attrLabel; String natShortDescription = attrShortDescription; String natDescription = attrDescription; boolean natIsNullable; if (attrIsNullable.equals("true") || attrIsNullable.equals("yes") || attrIsNullable.equals("1")) { natIsNullable = true; } else if (attrIsNullable.equals("false") || attrIsNullable.equals("no") || attrIsNullable.equals("0")) { natIsNullable = false; } else { throw CFLib.getDefaultExceptionFactory() .newUsageException( getClass(), S_ProcName, "Unexpected IsNullable value, must be one of true, false, yes, no, 1, or 0, not \"" + attrIsNullable + "\""); } Boolean natGenerateId; if ((attrGenerateId == null) || (attrGenerateId.length() <= 0)) { natGenerateId = null; } else if (attrGenerateId.equals("true") || attrGenerateId.equals("yes") || attrGenerateId.equals("1")) { natGenerateId = true; } else if (attrGenerateId.equals("false") || attrGenerateId.equals("no") || attrGenerateId.equals("0")) { natGenerateId = false; } else { throw CFLib.getDefaultExceptionFactory() .newUsageException( getClass(), S_ProcName, "Unexpected GenerateId value, must be one of true, false, yes, no, 1, or 0, not \"" + attrGenerateId + "\""); } ICFBamSchema.DataScopeEnum natDataScope; if ((attrDataScope == null) || (attrDataScope.length() <= 0)) { natDataScope = null; } else { natDataScope = CFBamSchema.parseDataScopeEnum(attrDataScope); } ICFBamSchema.AccessSecurityEnum natViewAccessSecurity; if ((attrViewAccessSecurity == null) || (attrViewAccessSecurity.length() <= 0)) { natViewAccessSecurity = null; } else { natViewAccessSecurity = CFBamSchema.parseAccessSecurityEnum(attrViewAccessSecurity); } ICFBamSchema.AccessSecurityEnum natEditAccessSecurity; if ((attrEditAccessSecurity == null) || (attrEditAccessSecurity.length() <= 0)) { natEditAccessSecurity = null; } else { natEditAccessSecurity = CFBamSchema.parseAccessSecurityEnum(attrEditAccessSecurity); } ICFBamSchema.AccessFrequencyEnum natViewAccessFrequency; if ((attrViewAccessFrequency == null) || (attrViewAccessFrequency.length() <= 0)) { natViewAccessFrequency = null; } else { natViewAccessFrequency = CFBamSchema.parseAccessFrequencyEnum(attrViewAccessFrequency); } ICFBamSchema.AccessFrequencyEnum natEditAccessFrequency; if ((attrEditAccessFrequency == null) || (attrEditAccessFrequency.length() <= 0)) { natEditAccessFrequency = null; } else { natEditAccessFrequency = CFBamSchema.parseAccessFrequencyEnum(attrEditAccessFrequency); } Long natPrevTenantId; if ((attrPrevTenantId == null) || (attrPrevTenantId.length() <= 0)) { natPrevTenantId = null; } else { natPrevTenantId = new Long(Long.parseLong(attrPrevTenantId)); } Long natPrevId; if ((attrPrevId == null) || (attrPrevId.length() <= 0)) { natPrevId = null; } else { natPrevId = new Long(Long.parseLong(attrPrevId)); } Long natNextTenantId; if ((attrNextTenantId == null) || (attrNextTenantId.length() <= 0)) { natNextTenantId = null; } else { natNextTenantId = new Long(Long.parseLong(attrNextTenantId)); } Long natNextId; if ((attrNextId == null) || (attrNextId.length() <= 0)) { natNextId = null; } else { natNextId = new Long(Long.parseLong(attrNextId)); } 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 + "\""); } 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); } String natDbName = attrDbName; int natMaxLen = Integer.parseInt(attrMaxLen); String natInitValue = attrInitValue; String natDefaultValue = attrDefaultValue; String natNullValue = attrNullValue; String natUnknownValue = attrUnknownValue; short natShowLines = Short.parseShort(attrShowLines); long natTableId = Long.parseLong(attrTableId); // Get the parent context CFLibXmlCoreContext parentContext = curContext.getPrevContext(); // Instantiate a buffer for the parsed information ICFBamNmTokenColObj obj = (ICFBamNmTokenColObj) (schemaObj.getNmTokenColTableObj().newInstance()); CFBamNmTokenColBuff dataBuff = obj.getNmTokenColBuff(); dataBuff.setRequiredTenantId(natTenantId); dataBuff.setRequiredScopeId(natScopeId); dataBuff.setRequiredId(natId); dataBuff.setOptionalDefSchemaTenantId(natDefSchemaTenantId); dataBuff.setOptionalDefSchemaId(natDefSchemaId); dataBuff.setRequiredName(natName); dataBuff.setOptionalShortName(natShortName); dataBuff.setOptionalLabel(natLabel); dataBuff.setOptionalShortDescription(natShortDescription); dataBuff.setOptionalDescription(natDescription); dataBuff.setRequiredIsNullable(natIsNullable); dataBuff.setOptionalGenerateId(natGenerateId); dataBuff.setOptionalDataScope(natDataScope); dataBuff.setOptionalViewAccessSecurity(natViewAccessSecurity); dataBuff.setOptionalEditAccessSecurity(natEditAccessSecurity); dataBuff.setOptionalViewAccessFrequency(natViewAccessFrequency); dataBuff.setOptionalEditAccessFrequency(natEditAccessFrequency); dataBuff.setOptionalPrevTenantId(natPrevTenantId); dataBuff.setOptionalPrevId(natPrevId); dataBuff.setOptionalNextTenantId(natNextTenantId); dataBuff.setOptionalNextId(natNextId); dataBuff.setRequiredDefaultVisibility(natDefaultVisibility); 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); } dataBuff.setOptionalDbName(natDbName); dataBuff.setRequiredMaxLen(natMaxLen); dataBuff.setOptionalInitValue(natInitValue); dataBuff.setOptionalDefaultValue(natDefaultValue); dataBuff.setOptionalNullValue(natNullValue); dataBuff.setOptionalUnknownValue(natUnknownValue); dataBuff.setRequiredShowLines(natShowLines); dataBuff.setRequiredTableId(natTableId); obj.copyBuffToPKey(); @SuppressWarnings("unchecked") List<ICFBamValueObj> list = (List<ICFBamValueObj>) xmsgRspnHandler.getListOfObjects(); ICFBamNmTokenColObj realized = (ICFBamNmTokenColObj) obj.realize(); xmsgRspnHandler.setLastObjectProcessed(realized); if (list != null) { list.add(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); } }
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 attrShortName = null; String attrLabel = null; String attrShortDescription = null; String attrDescription = null; String attrIsNullable = null; String attrGenerateId = null; String attrDataScope = null; String attrViewAccessSecurity = null; String attrEditAccessSecurity = null; String attrViewAccessFrequency = null; String attrEditAccessFrequency = null; String attrDefaultVisibility = null; String attrDefSchema = null; // Value References ICFBamTenantObj refTenant = null; ICFBamScopeObj refScope = null; ICFBamSchemaDefObj refDefSchema = null; // Atom Attributes String attrDbName = null; // Atom References // NmTokensDef Attributes String attrMaxLen = null; String attrInitValue = null; String attrDefaultValue = null; String attrNullValue = null; String attrUnknownValue = null; String attrShowLines = null; // NmTokensDef References // Attribute Extraction String attrLocalName; int numAttrs; int idxAttr; final String S_ProcName = "startElement"; final String S_LocalName = "LocalName"; assert qName.equals("NmTokensDef"); CFBamSaxLoader saxLoader = (CFBamSaxLoader) getParser(); if (saxLoader == null) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "getParser()"); } ICFBamSchemaObj schemaObj = saxLoader.getSchemaObj(); if (schemaObj == null) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "getParser().getSchemaObj()"); } // Instantiate an edit buffer for the parsed information ICFBamNmTokensDefEditObj editBuff = (ICFBamNmTokensDefEditObj) schemaObj.getNmTokensDefTableObj().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("ShortName")) { if (attrShortName != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrShortName = attrs.getValue(idxAttr); } else if (attrLocalName.equals("Label")) { if (attrLabel != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrLabel = attrs.getValue(idxAttr); } else if (attrLocalName.equals("ShortDescription")) { if (attrShortDescription != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrShortDescription = 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("IsNullable")) { if (attrIsNullable != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrIsNullable = attrs.getValue(idxAttr); } else if (attrLocalName.equals("GenerateId")) { if (attrGenerateId != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrGenerateId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("DataScope")) { if (attrDataScope != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrDataScope = attrs.getValue(idxAttr); } else if (attrLocalName.equals("ViewAccessSecurity")) { if (attrViewAccessSecurity != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrViewAccessSecurity = attrs.getValue(idxAttr); } else if (attrLocalName.equals("EditAccessSecurity")) { if (attrEditAccessSecurity != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrEditAccessSecurity = attrs.getValue(idxAttr); } else if (attrLocalName.equals("ViewAccessFrequency")) { if (attrViewAccessFrequency != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrViewAccessFrequency = attrs.getValue(idxAttr); } else if (attrLocalName.equals("EditAccessFrequency")) { if (attrEditAccessFrequency != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrEditAccessFrequency = 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("DefSchema")) { if (attrDefSchema != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrDefSchema = attrs.getValue(idxAttr); } else if (attrLocalName.equals("DbName")) { if (attrDbName != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrDbName = attrs.getValue(idxAttr); } else if (attrLocalName.equals("MaxLen")) { if (attrMaxLen != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrMaxLen = attrs.getValue(idxAttr); } else if (attrLocalName.equals("InitValue")) { if (attrInitValue != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrInitValue = attrs.getValue(idxAttr); } else if (attrLocalName.equals("DefaultValue")) { if (attrDefaultValue != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrDefaultValue = attrs.getValue(idxAttr); } else if (attrLocalName.equals("NullValue")) { if (attrNullValue != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrNullValue = attrs.getValue(idxAttr); } else if (attrLocalName.equals("UnknownValue")) { if (attrUnknownValue != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrUnknownValue = attrs.getValue(idxAttr); } else if (attrLocalName.equals("ShowLines")) { if (attrShowLines != null) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, S_LocalName, attrLocalName); } attrShowLines = 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 ((attrIsNullable == null) || (attrIsNullable.length() <= 0)) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "IsNullable"); } if ((attrDefaultVisibility == null) || (attrDefaultVisibility.length() <= 0)) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "DefaultVisibility"); } if ((attrMaxLen == null) || (attrMaxLen.length() <= 0)) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "MaxLen"); } if ((attrShowLines == null) || (attrShowLines.length() <= 0)) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "ShowLines"); } // Save named attributes to context CFLibXmlCoreContext curContext = getParser().getCurContext(); curContext.putNamedValue("Id", attrId); curContext.putNamedValue("Name", attrName); curContext.putNamedValue("ShortName", attrShortName); curContext.putNamedValue("Label", attrLabel); curContext.putNamedValue("ShortDescription", attrShortDescription); curContext.putNamedValue("Description", attrDescription); curContext.putNamedValue("IsNullable", attrIsNullable); curContext.putNamedValue("GenerateId", attrGenerateId); curContext.putNamedValue("DataScope", attrDataScope); curContext.putNamedValue("ViewAccessSecurity", attrViewAccessSecurity); curContext.putNamedValue("EditAccessSecurity", attrEditAccessSecurity); curContext.putNamedValue("ViewAccessFrequency", attrViewAccessFrequency); curContext.putNamedValue("EditAccessFrequency", attrEditAccessFrequency); curContext.putNamedValue("DefaultVisibility", attrDefaultVisibility); curContext.putNamedValue("DefSchema", attrDefSchema); curContext.putNamedValue("DbName", attrDbName); curContext.putNamedValue("MaxLen", attrMaxLen); curContext.putNamedValue("InitValue", attrInitValue); curContext.putNamedValue("DefaultValue", attrDefaultValue); curContext.putNamedValue("NullValue", attrNullValue); curContext.putNamedValue("UnknownValue", attrUnknownValue); curContext.putNamedValue("ShowLines", attrShowLines); // 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); String natShortName = attrShortName; editBuff.setOptionalShortName(natShortName); String natLabel = attrLabel; editBuff.setOptionalLabel(natLabel); String natShortDescription = attrShortDescription; editBuff.setOptionalShortDescription(natShortDescription); String natDescription = attrDescription; editBuff.setOptionalDescription(natDescription); boolean natIsNullable; if (attrIsNullable.equals("true") || attrIsNullable.equals("yes") || attrIsNullable.equals("1")) { natIsNullable = true; } else if (attrIsNullable.equals("false") || attrIsNullable.equals("no") || attrIsNullable.equals("0")) { natIsNullable = false; } else { throw CFLib.getDefaultExceptionFactory() .newUsageException( getClass(), S_ProcName, "Unexpected IsNullable value, must be one of true, false, yes, no, 1, or 0, not \"" + attrIsNullable + "\""); } editBuff.setRequiredIsNullable(natIsNullable); Boolean natGenerateId; if ((attrGenerateId == null) || (attrGenerateId.length() <= 0)) { natGenerateId = null; } else if (attrGenerateId.equals("true") || attrGenerateId.equals("yes") || attrGenerateId.equals("1")) { natGenerateId = true; } else if (attrGenerateId.equals("false") || attrGenerateId.equals("no") || attrGenerateId.equals("0")) { natGenerateId = false; } else { throw CFLib.getDefaultExceptionFactory() .newUsageException( getClass(), S_ProcName, "Unexpected GenerateId value, must be one of true, false, yes, no, 1, or 0, not \"" + attrGenerateId + "\""); } editBuff.setOptionalGenerateId(natGenerateId); ICFBamSchema.DataScopeEnum natDataScope; if ((attrDataScope == null) || (attrDataScope.length() <= 0)) { natDataScope = null; } else { natDataScope = CFBamSchema.parseDataScopeEnum(attrDataScope); } editBuff.setOptionalDataScope(natDataScope); ICFBamSchema.AccessSecurityEnum natViewAccessSecurity; if ((attrViewAccessSecurity == null) || (attrViewAccessSecurity.length() <= 0)) { natViewAccessSecurity = null; } else { natViewAccessSecurity = CFBamSchema.parseAccessSecurityEnum(attrViewAccessSecurity); } editBuff.setOptionalViewAccessSecurity(natViewAccessSecurity); ICFBamSchema.AccessSecurityEnum natEditAccessSecurity; if ((attrEditAccessSecurity == null) || (attrEditAccessSecurity.length() <= 0)) { natEditAccessSecurity = null; } else { natEditAccessSecurity = CFBamSchema.parseAccessSecurityEnum(attrEditAccessSecurity); } editBuff.setOptionalEditAccessSecurity(natEditAccessSecurity); ICFBamSchema.AccessFrequencyEnum natViewAccessFrequency; if ((attrViewAccessFrequency == null) || (attrViewAccessFrequency.length() <= 0)) { natViewAccessFrequency = null; } else { natViewAccessFrequency = CFBamSchema.parseAccessFrequencyEnum(attrViewAccessFrequency); } editBuff.setOptionalViewAccessFrequency(natViewAccessFrequency); ICFBamSchema.AccessFrequencyEnum natEditAccessFrequency; if ((attrEditAccessFrequency == null) || (attrEditAccessFrequency.length() <= 0)) { natEditAccessFrequency = null; } else { natEditAccessFrequency = CFBamSchema.parseAccessFrequencyEnum(attrEditAccessFrequency); } editBuff.setOptionalEditAccessFrequency(natEditAccessFrequency); 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); String natDbName = attrDbName; editBuff.setOptionalDbName(natDbName); int natMaxLen = Integer.parseInt(attrMaxLen); editBuff.setRequiredMaxLen(natMaxLen); String natInitValue = attrInitValue; editBuff.setOptionalInitValue(natInitValue); String natDefaultValue = attrDefaultValue; editBuff.setOptionalDefaultValue(natDefaultValue); String natNullValue = attrNullValue; editBuff.setOptionalNullValue(natNullValue); String natUnknownValue = attrUnknownValue; editBuff.setOptionalUnknownValue(natUnknownValue); short natShowLines = Short.parseShort(attrShowLines); editBuff.setRequiredShowLines(natShowLines); // 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 ICFBamScopeObj) { refScope = (ICFBamScopeObj) scopeObj; editBuff.setRequiredContainerScope(refScope); refTenant = (ICFBamTenantObj) editBuff.getRequiredOwnerTenant(); } else { throw CFLib.getDefaultExceptionFactory() .newUnsupportedClassException( getClass(), S_ProcName, "scopeObj", scopeObj, "ICFBamScopeObj"); } // Resolve and apply Owner reference if (refTenant == null) { if (scopeObj instanceof ICFBamTenantObj) { refTenant = (ICFBamTenantObj) scopeObj; editBuff.setRequiredOwnerTenant(refTenant); } else { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 0, "Owner<Tenant>"); } } // Lookup refDefSchema by qualified name if ((attrDefSchema != null) && (attrDefSchema.length() > 0)) { refDefSchema = (ICFBamSchemaDefObj) (editBuff.getNamedObject( schemaObj.getSchemaDefTableObj().getObjQualifyingClass(), attrDefSchema)); if (refDefSchema == null) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException( getClass(), S_ProcName, 0, "Resolve DefSchema reference qualified name \"" + attrDefSchema + "\" to table SchemaDef"); } } else { refDefSchema = null; } editBuff.setOptionalLookupDefSchema(refDefSchema); CFBamSaxLoader.LoaderBehaviourEnum loaderBehaviour = saxLoader.getNmTokensDefLoaderBehaviour(); ICFBamNmTokensDefEditObj editNmTokensDef = null; ICFBamNmTokensDefObj origNmTokensDef = (ICFBamNmTokensDefObj) schemaObj .getNmTokensDefTableObj() .readNmTokensDefByUNameIdx( refTenant.getRequiredId(), refScope.getRequiredId(), editBuff.getRequiredName()); if (origNmTokensDef == null) { editNmTokensDef = editBuff; } else { switch (loaderBehaviour) { case Insert: break; case Update: editNmTokensDef = (ICFBamNmTokensDefEditObj) origNmTokensDef.beginEdit(); editNmTokensDef.setRequiredName(editBuff.getRequiredName()); editNmTokensDef.setOptionalShortName(editBuff.getOptionalShortName()); editNmTokensDef.setOptionalLabel(editBuff.getOptionalLabel()); editNmTokensDef.setOptionalShortDescription(editBuff.getOptionalShortDescription()); editNmTokensDef.setOptionalDescription(editBuff.getOptionalDescription()); editNmTokensDef.setRequiredIsNullable(editBuff.getRequiredIsNullable()); editNmTokensDef.setOptionalGenerateId(editBuff.getOptionalGenerateId()); editNmTokensDef.setOptionalDataScope(editBuff.getOptionalDataScope()); editNmTokensDef.setOptionalViewAccessSecurity(editBuff.getOptionalViewAccessSecurity()); editNmTokensDef.setOptionalEditAccessSecurity(editBuff.getOptionalEditAccessSecurity()); editNmTokensDef.setOptionalViewAccessFrequency( editBuff.getOptionalViewAccessFrequency()); editNmTokensDef.setOptionalEditAccessFrequency( editBuff.getOptionalEditAccessFrequency()); editNmTokensDef.setRequiredDefaultVisibility(editBuff.getRequiredDefaultVisibility()); editNmTokensDef.setOptionalDbName(editBuff.getOptionalDbName()); editNmTokensDef.setRequiredMaxLen(editBuff.getRequiredMaxLen()); editNmTokensDef.setOptionalInitValue(editBuff.getOptionalInitValue()); editNmTokensDef.setOptionalDefaultValue(editBuff.getOptionalDefaultValue()); editNmTokensDef.setOptionalNullValue(editBuff.getOptionalNullValue()); editNmTokensDef.setOptionalUnknownValue(editBuff.getOptionalUnknownValue()); editNmTokensDef.setRequiredShowLines(editBuff.getRequiredShowLines()); editNmTokensDef.setOptionalLookupDefSchema(editBuff.getOptionalLookupDefSchema()); break; case Replace: editNmTokensDef = (ICFBamNmTokensDefEditObj) origNmTokensDef.beginEdit(); editNmTokensDef.delete(); editNmTokensDef.endEdit(); origNmTokensDef = null; editNmTokensDef = editBuff; break; } } if (editNmTokensDef != null) { if (origNmTokensDef != null) { editNmTokensDef.update(); } else { origNmTokensDef = (ICFBamNmTokensDefObj) editNmTokensDef.create(); } editNmTokensDef.endEdit(); } curContext.putNamedValue("Object", origNmTokensDef); } 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); } }