List of usage examples for java.lang Short Short
@Deprecated(since = "9") public Short(String s) throws NumberFormatException
From source file:net.sourceforge.msscodefactory.cfcore.v2_0.CFGenKbXMsgRspnHandler.CFGenKbXMsgRspnUuidFormatterRecHandler.java
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { try {// w ww . ja va2 s .c om // Common XML Attributes String attrId = null; String attrRevision = null; // GenItem Attributes String attrTenantId = null; String attrCartridgeId = null; String attrItemId = null; String attrRuleTypeId = null; String attrName = null; String attrToolSetId = null; String attrScopeDefId = null; String attrGenDefId = null; String attrGelExecutableId = null; // GenBind Attributes // GenFormatter Attributes // UuidFormatter Attributes // Attribute Extraction String attrLocalName; int numAttrs; int idxAttr; final String S_ProcName = "startElement"; final String S_LocalName = "LocalName"; assert qName.equals("UuidFormatter"); CFGenKbXMsgRspnHandler xmsgRspnHandler = (CFGenKbXMsgRspnHandler) getParser(); if (xmsgRspnHandler == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "getParser()"); } ICFGenKbSchemaObj schemaObj = xmsgRspnHandler.getSchemaObj(); if (schemaObj == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "getParser().getSchemaObj()"); } // Extract Attributes numAttrs = attrs.getLength(); for (idxAttr = 0; idxAttr < numAttrs; idxAttr++) { attrLocalName = attrs.getLocalName(idxAttr); if (attrLocalName.equals("Id")) { if (attrId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("Revision")) { if (attrRevision != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrRevision = attrs.getValue(idxAttr); } else if (attrLocalName.equals("TenantId")) { if (attrTenantId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrTenantId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("CartridgeId")) { if (attrCartridgeId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrCartridgeId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("ItemId")) { if (attrItemId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrItemId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("RuleTypeId")) { if (attrRuleTypeId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrRuleTypeId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("Name")) { if (attrName != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrName = attrs.getValue(idxAttr); } else if (attrLocalName.equals("ToolSetId")) { if (attrToolSetId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrToolSetId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("ScopeDefId")) { if (attrScopeDefId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrScopeDefId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("GenDefId")) { if (attrGenDefId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrGenDefId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("GelExecutableId")) { if (attrGelExecutableId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrGelExecutableId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("schemaLocation")) { // ignored } else { throw CFLib.getDefaultExceptionFactory().newUnrecognizedAttributeException(getClass(), S_ProcName, getParser().getLocationInfo(), attrLocalName); } } // Ensure that required attributes have values if ((attrTenantId == null) || (attrTenantId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "TenantId"); } if ((attrCartridgeId == null) || (attrCartridgeId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "CartridgeId"); } if ((attrItemId == null) || (attrItemId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "ItemId"); } if ((attrRuleTypeId == null) || (attrRuleTypeId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "RuleTypeId"); } if (attrName == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "Name"); } if ((attrToolSetId == null) || (attrToolSetId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "ToolSetId"); } if ((attrGenDefId == null) || (attrGenDefId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "GenDefId"); } // Save named attributes to context CFLibXmlCoreContext curContext = xmsgRspnHandler.getCurContext(); // Convert string attributes to native Java types long natTenantId = Long.parseLong(attrTenantId); long natCartridgeId = Long.parseLong(attrCartridgeId); int natItemId = Integer.parseInt(attrItemId); short natRuleTypeId = Short.parseShort(attrRuleTypeId); String natName = attrName; short natToolSetId = Short.parseShort(attrToolSetId); Short natScopeDefId; if ((attrScopeDefId == null) || (attrScopeDefId.length() <= 0)) { natScopeDefId = null; } else { natScopeDefId = new Short(Short.parseShort(attrScopeDefId)); } short natGenDefId = Short.parseShort(attrGenDefId); Integer natGelExecutableId; if ((attrGelExecutableId == null) || (attrGelExecutableId.length() <= 0)) { natGelExecutableId = null; } else { natGelExecutableId = new Integer(Integer.parseInt(attrGelExecutableId)); } int natRevision = Integer.parseInt(attrRevision); // Get the parent context CFLibXmlCoreContext parentContext = curContext.getPrevContext(); // Instantiate a buffer for the parsed information ICFGenKbUuidFormatterObj obj = schemaObj.getUuidFormatterTableObj().newInstance(); CFGenKbUuidFormatterBuff dataBuff = obj.getUuidFormatterBuff(); dataBuff.setRequiredTenantId(natTenantId); dataBuff.setRequiredCartridgeId(natCartridgeId); dataBuff.setRequiredItemId(natItemId); dataBuff.setRequiredRuleTypeId(natRuleTypeId); dataBuff.setRequiredName(natName); dataBuff.setRequiredToolSetId(natToolSetId); dataBuff.setOptionalScopeDefId(natScopeDefId); dataBuff.setRequiredGenDefId(natGenDefId); dataBuff.setOptionalGelExecutableId(natGelExecutableId); dataBuff.setRequiredRevision(natRevision); obj.copyBuffToPKey(); SortedMap<CFGenKbGenItemPKey, ICFGenKbGenItemObj> sortedMap = (SortedMap<CFGenKbGenItemPKey, ICFGenKbGenItemObj>) xmsgRspnHandler .getSortedMapOfObjects(); ICFGenKbUuidFormatterObj realized = (ICFGenKbUuidFormatterObj) 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.CFGenKbXMsgRspnTokenFormatterRecHandler.java
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { try {/*from ww w. ja va 2 s . c om*/ // Common XML Attributes String attrId = null; String attrRevision = null; // GenItem Attributes String attrTenantId = null; String attrCartridgeId = null; String attrItemId = null; String attrRuleTypeId = null; String attrName = null; String attrToolSetId = null; String attrScopeDefId = null; String attrGenDefId = null; String attrGelExecutableId = null; // GenBind Attributes // GenFormatter Attributes // TokenFormatter Attributes // Attribute Extraction String attrLocalName; int numAttrs; int idxAttr; final String S_ProcName = "startElement"; final String S_LocalName = "LocalName"; assert qName.equals("TokenFormatter"); CFGenKbXMsgRspnHandler xmsgRspnHandler = (CFGenKbXMsgRspnHandler) getParser(); if (xmsgRspnHandler == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "getParser()"); } ICFGenKbSchemaObj schemaObj = xmsgRspnHandler.getSchemaObj(); if (schemaObj == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "getParser().getSchemaObj()"); } // Extract Attributes numAttrs = attrs.getLength(); for (idxAttr = 0; idxAttr < numAttrs; idxAttr++) { attrLocalName = attrs.getLocalName(idxAttr); if (attrLocalName.equals("Id")) { if (attrId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("Revision")) { if (attrRevision != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrRevision = attrs.getValue(idxAttr); } else if (attrLocalName.equals("TenantId")) { if (attrTenantId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrTenantId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("CartridgeId")) { if (attrCartridgeId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrCartridgeId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("ItemId")) { if (attrItemId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrItemId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("RuleTypeId")) { if (attrRuleTypeId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrRuleTypeId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("Name")) { if (attrName != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrName = attrs.getValue(idxAttr); } else if (attrLocalName.equals("ToolSetId")) { if (attrToolSetId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrToolSetId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("ScopeDefId")) { if (attrScopeDefId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrScopeDefId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("GenDefId")) { if (attrGenDefId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrGenDefId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("GelExecutableId")) { if (attrGelExecutableId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrGelExecutableId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("schemaLocation")) { // ignored } else { throw CFLib.getDefaultExceptionFactory().newUnrecognizedAttributeException(getClass(), S_ProcName, getParser().getLocationInfo(), attrLocalName); } } // Ensure that required attributes have values if ((attrTenantId == null) || (attrTenantId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "TenantId"); } if ((attrCartridgeId == null) || (attrCartridgeId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "CartridgeId"); } if ((attrItemId == null) || (attrItemId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "ItemId"); } if ((attrRuleTypeId == null) || (attrRuleTypeId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "RuleTypeId"); } if (attrName == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "Name"); } if ((attrToolSetId == null) || (attrToolSetId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "ToolSetId"); } if ((attrGenDefId == null) || (attrGenDefId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "GenDefId"); } // Save named attributes to context CFLibXmlCoreContext curContext = xmsgRspnHandler.getCurContext(); // Convert string attributes to native Java types long natTenantId = Long.parseLong(attrTenantId); long natCartridgeId = Long.parseLong(attrCartridgeId); int natItemId = Integer.parseInt(attrItemId); short natRuleTypeId = Short.parseShort(attrRuleTypeId); String natName = attrName; short natToolSetId = Short.parseShort(attrToolSetId); Short natScopeDefId; if ((attrScopeDefId == null) || (attrScopeDefId.length() <= 0)) { natScopeDefId = null; } else { natScopeDefId = new Short(Short.parseShort(attrScopeDefId)); } short natGenDefId = Short.parseShort(attrGenDefId); Integer natGelExecutableId; if ((attrGelExecutableId == null) || (attrGelExecutableId.length() <= 0)) { natGelExecutableId = null; } else { natGelExecutableId = new Integer(Integer.parseInt(attrGelExecutableId)); } int natRevision = Integer.parseInt(attrRevision); // Get the parent context CFLibXmlCoreContext parentContext = curContext.getPrevContext(); // Instantiate a buffer for the parsed information ICFGenKbTokenFormatterObj obj = schemaObj.getTokenFormatterTableObj().newInstance(); CFGenKbTokenFormatterBuff dataBuff = obj.getTokenFormatterBuff(); dataBuff.setRequiredTenantId(natTenantId); dataBuff.setRequiredCartridgeId(natCartridgeId); dataBuff.setRequiredItemId(natItemId); dataBuff.setRequiredRuleTypeId(natRuleTypeId); dataBuff.setRequiredName(natName); dataBuff.setRequiredToolSetId(natToolSetId); dataBuff.setOptionalScopeDefId(natScopeDefId); dataBuff.setRequiredGenDefId(natGenDefId); dataBuff.setOptionalGelExecutableId(natGelExecutableId); dataBuff.setRequiredRevision(natRevision); obj.copyBuffToPKey(); SortedMap<CFGenKbGenItemPKey, ICFGenKbGenItemObj> sortedMap = (SortedMap<CFGenKbGenItemPKey, ICFGenKbGenItemObj>) xmsgRspnHandler .getSortedMapOfObjects(); ICFGenKbTokenFormatterObj realized = (ICFGenKbTokenFormatterObj) 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.CFGenKbXMsgRspnNumberFormatterRecHandler.java
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { try {//w w w . j a va2 s .com // Common XML Attributes String attrId = null; String attrRevision = null; // GenItem Attributes String attrTenantId = null; String attrCartridgeId = null; String attrItemId = null; String attrRuleTypeId = null; String attrName = null; String attrToolSetId = null; String attrScopeDefId = null; String attrGenDefId = null; String attrGelExecutableId = null; // GenBind Attributes // GenFormatter Attributes // NumberFormatter Attributes // Attribute Extraction String attrLocalName; int numAttrs; int idxAttr; final String S_ProcName = "startElement"; final String S_LocalName = "LocalName"; assert qName.equals("NumberFormatter"); CFGenKbXMsgRspnHandler xmsgRspnHandler = (CFGenKbXMsgRspnHandler) getParser(); if (xmsgRspnHandler == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "getParser()"); } ICFGenKbSchemaObj schemaObj = xmsgRspnHandler.getSchemaObj(); if (schemaObj == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "getParser().getSchemaObj()"); } // Extract Attributes numAttrs = attrs.getLength(); for (idxAttr = 0; idxAttr < numAttrs; idxAttr++) { attrLocalName = attrs.getLocalName(idxAttr); if (attrLocalName.equals("Id")) { if (attrId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("Revision")) { if (attrRevision != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrRevision = attrs.getValue(idxAttr); } else if (attrLocalName.equals("TenantId")) { if (attrTenantId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrTenantId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("CartridgeId")) { if (attrCartridgeId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrCartridgeId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("ItemId")) { if (attrItemId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrItemId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("RuleTypeId")) { if (attrRuleTypeId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrRuleTypeId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("Name")) { if (attrName != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrName = attrs.getValue(idxAttr); } else if (attrLocalName.equals("ToolSetId")) { if (attrToolSetId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrToolSetId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("ScopeDefId")) { if (attrScopeDefId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrScopeDefId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("GenDefId")) { if (attrGenDefId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrGenDefId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("GelExecutableId")) { if (attrGelExecutableId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrGelExecutableId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("schemaLocation")) { // ignored } else { throw CFLib.getDefaultExceptionFactory().newUnrecognizedAttributeException(getClass(), S_ProcName, getParser().getLocationInfo(), attrLocalName); } } // Ensure that required attributes have values if ((attrTenantId == null) || (attrTenantId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "TenantId"); } if ((attrCartridgeId == null) || (attrCartridgeId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "CartridgeId"); } if ((attrItemId == null) || (attrItemId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "ItemId"); } if ((attrRuleTypeId == null) || (attrRuleTypeId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "RuleTypeId"); } if (attrName == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "Name"); } if ((attrToolSetId == null) || (attrToolSetId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "ToolSetId"); } if ((attrGenDefId == null) || (attrGenDefId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "GenDefId"); } // Save named attributes to context CFLibXmlCoreContext curContext = xmsgRspnHandler.getCurContext(); // Convert string attributes to native Java types long natTenantId = Long.parseLong(attrTenantId); long natCartridgeId = Long.parseLong(attrCartridgeId); int natItemId = Integer.parseInt(attrItemId); short natRuleTypeId = Short.parseShort(attrRuleTypeId); String natName = attrName; short natToolSetId = Short.parseShort(attrToolSetId); Short natScopeDefId; if ((attrScopeDefId == null) || (attrScopeDefId.length() <= 0)) { natScopeDefId = null; } else { natScopeDefId = new Short(Short.parseShort(attrScopeDefId)); } short natGenDefId = Short.parseShort(attrGenDefId); Integer natGelExecutableId; if ((attrGelExecutableId == null) || (attrGelExecutableId.length() <= 0)) { natGelExecutableId = null; } else { natGelExecutableId = new Integer(Integer.parseInt(attrGelExecutableId)); } int natRevision = Integer.parseInt(attrRevision); // Get the parent context CFLibXmlCoreContext parentContext = curContext.getPrevContext(); // Instantiate a buffer for the parsed information ICFGenKbNumberFormatterObj obj = schemaObj.getNumberFormatterTableObj().newInstance(); CFGenKbNumberFormatterBuff dataBuff = obj.getNumberFormatterBuff(); dataBuff.setRequiredTenantId(natTenantId); dataBuff.setRequiredCartridgeId(natCartridgeId); dataBuff.setRequiredItemId(natItemId); dataBuff.setRequiredRuleTypeId(natRuleTypeId); dataBuff.setRequiredName(natName); dataBuff.setRequiredToolSetId(natToolSetId); dataBuff.setOptionalScopeDefId(natScopeDefId); dataBuff.setRequiredGenDefId(natGenDefId); dataBuff.setOptionalGelExecutableId(natGelExecutableId); dataBuff.setRequiredRevision(natRevision); obj.copyBuffToPKey(); SortedMap<CFGenKbGenItemPKey, ICFGenKbGenItemObj> sortedMap = (SortedMap<CFGenKbGenItemPKey, ICFGenKbGenItemObj>) xmsgRspnHandler .getSortedMapOfObjects(); ICFGenKbNumberFormatterObj realized = (ICFGenKbNumberFormatterObj) 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.CFGenKbXMsgRspnStringFormatterRecHandler.java
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { try {/* w w w . j av a2s .c o m*/ // Common XML Attributes String attrId = null; String attrRevision = null; // GenItem Attributes String attrTenantId = null; String attrCartridgeId = null; String attrItemId = null; String attrRuleTypeId = null; String attrName = null; String attrToolSetId = null; String attrScopeDefId = null; String attrGenDefId = null; String attrGelExecutableId = null; // GenBind Attributes // GenFormatter Attributes // StringFormatter Attributes // Attribute Extraction String attrLocalName; int numAttrs; int idxAttr; final String S_ProcName = "startElement"; final String S_LocalName = "LocalName"; assert qName.equals("StringFormatter"); CFGenKbXMsgRspnHandler xmsgRspnHandler = (CFGenKbXMsgRspnHandler) getParser(); if (xmsgRspnHandler == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "getParser()"); } ICFGenKbSchemaObj schemaObj = xmsgRspnHandler.getSchemaObj(); if (schemaObj == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "getParser().getSchemaObj()"); } // Extract Attributes numAttrs = attrs.getLength(); for (idxAttr = 0; idxAttr < numAttrs; idxAttr++) { attrLocalName = attrs.getLocalName(idxAttr); if (attrLocalName.equals("Id")) { if (attrId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("Revision")) { if (attrRevision != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrRevision = attrs.getValue(idxAttr); } else if (attrLocalName.equals("TenantId")) { if (attrTenantId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrTenantId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("CartridgeId")) { if (attrCartridgeId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrCartridgeId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("ItemId")) { if (attrItemId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrItemId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("RuleTypeId")) { if (attrRuleTypeId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrRuleTypeId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("Name")) { if (attrName != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrName = attrs.getValue(idxAttr); } else if (attrLocalName.equals("ToolSetId")) { if (attrToolSetId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrToolSetId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("ScopeDefId")) { if (attrScopeDefId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrScopeDefId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("GenDefId")) { if (attrGenDefId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrGenDefId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("GelExecutableId")) { if (attrGelExecutableId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrGelExecutableId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("schemaLocation")) { // ignored } else { throw CFLib.getDefaultExceptionFactory().newUnrecognizedAttributeException(getClass(), S_ProcName, getParser().getLocationInfo(), attrLocalName); } } // Ensure that required attributes have values if ((attrTenantId == null) || (attrTenantId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "TenantId"); } if ((attrCartridgeId == null) || (attrCartridgeId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "CartridgeId"); } if ((attrItemId == null) || (attrItemId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "ItemId"); } if ((attrRuleTypeId == null) || (attrRuleTypeId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "RuleTypeId"); } if (attrName == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "Name"); } if ((attrToolSetId == null) || (attrToolSetId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "ToolSetId"); } if ((attrGenDefId == null) || (attrGenDefId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "GenDefId"); } // Save named attributes to context CFLibXmlCoreContext curContext = xmsgRspnHandler.getCurContext(); // Convert string attributes to native Java types long natTenantId = Long.parseLong(attrTenantId); long natCartridgeId = Long.parseLong(attrCartridgeId); int natItemId = Integer.parseInt(attrItemId); short natRuleTypeId = Short.parseShort(attrRuleTypeId); String natName = attrName; short natToolSetId = Short.parseShort(attrToolSetId); Short natScopeDefId; if ((attrScopeDefId == null) || (attrScopeDefId.length() <= 0)) { natScopeDefId = null; } else { natScopeDefId = new Short(Short.parseShort(attrScopeDefId)); } short natGenDefId = Short.parseShort(attrGenDefId); Integer natGelExecutableId; if ((attrGelExecutableId == null) || (attrGelExecutableId.length() <= 0)) { natGelExecutableId = null; } else { natGelExecutableId = new Integer(Integer.parseInt(attrGelExecutableId)); } int natRevision = Integer.parseInt(attrRevision); // Get the parent context CFLibXmlCoreContext parentContext = curContext.getPrevContext(); // Instantiate a buffer for the parsed information ICFGenKbStringFormatterObj obj = schemaObj.getStringFormatterTableObj().newInstance(); CFGenKbStringFormatterBuff dataBuff = obj.getStringFormatterBuff(); dataBuff.setRequiredTenantId(natTenantId); dataBuff.setRequiredCartridgeId(natCartridgeId); dataBuff.setRequiredItemId(natItemId); dataBuff.setRequiredRuleTypeId(natRuleTypeId); dataBuff.setRequiredName(natName); dataBuff.setRequiredToolSetId(natToolSetId); dataBuff.setOptionalScopeDefId(natScopeDefId); dataBuff.setRequiredGenDefId(natGenDefId); dataBuff.setOptionalGelExecutableId(natGelExecutableId); dataBuff.setRequiredRevision(natRevision); obj.copyBuffToPKey(); SortedMap<CFGenKbGenItemPKey, ICFGenKbGenItemObj> sortedMap = (SortedMap<CFGenKbGenItemPKey, ICFGenKbGenItemObj>) xmsgRspnHandler .getSortedMapOfObjects(); ICFGenKbStringFormatterObj realized = (ICFGenKbStringFormatterObj) 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.CFGenKbXMsgRspnTZDateFormatterRecHandler.java
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { try {/* ww w.j a v a 2 s .c om*/ // Common XML Attributes String attrId = null; String attrRevision = null; // GenItem Attributes String attrTenantId = null; String attrCartridgeId = null; String attrItemId = null; String attrRuleTypeId = null; String attrName = null; String attrToolSetId = null; String attrScopeDefId = null; String attrGenDefId = null; String attrGelExecutableId = null; // GenBind Attributes // GenFormatter Attributes // TZDateFormatter Attributes // Attribute Extraction String attrLocalName; int numAttrs; int idxAttr; final String S_ProcName = "startElement"; final String S_LocalName = "LocalName"; assert qName.equals("TZDateFormatter"); CFGenKbXMsgRspnHandler xmsgRspnHandler = (CFGenKbXMsgRspnHandler) getParser(); if (xmsgRspnHandler == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "getParser()"); } ICFGenKbSchemaObj schemaObj = xmsgRspnHandler.getSchemaObj(); if (schemaObj == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "getParser().getSchemaObj()"); } // Extract Attributes numAttrs = attrs.getLength(); for (idxAttr = 0; idxAttr < numAttrs; idxAttr++) { attrLocalName = attrs.getLocalName(idxAttr); if (attrLocalName.equals("Id")) { if (attrId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("Revision")) { if (attrRevision != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrRevision = attrs.getValue(idxAttr); } else if (attrLocalName.equals("TenantId")) { if (attrTenantId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrTenantId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("CartridgeId")) { if (attrCartridgeId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrCartridgeId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("ItemId")) { if (attrItemId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrItemId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("RuleTypeId")) { if (attrRuleTypeId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrRuleTypeId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("Name")) { if (attrName != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrName = attrs.getValue(idxAttr); } else if (attrLocalName.equals("ToolSetId")) { if (attrToolSetId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrToolSetId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("ScopeDefId")) { if (attrScopeDefId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrScopeDefId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("GenDefId")) { if (attrGenDefId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrGenDefId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("GelExecutableId")) { if (attrGelExecutableId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrGelExecutableId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("schemaLocation")) { // ignored } else { throw CFLib.getDefaultExceptionFactory().newUnrecognizedAttributeException(getClass(), S_ProcName, getParser().getLocationInfo(), attrLocalName); } } // Ensure that required attributes have values if ((attrTenantId == null) || (attrTenantId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "TenantId"); } if ((attrCartridgeId == null) || (attrCartridgeId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "CartridgeId"); } if ((attrItemId == null) || (attrItemId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "ItemId"); } if ((attrRuleTypeId == null) || (attrRuleTypeId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "RuleTypeId"); } if (attrName == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "Name"); } if ((attrToolSetId == null) || (attrToolSetId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "ToolSetId"); } if ((attrGenDefId == null) || (attrGenDefId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "GenDefId"); } // Save named attributes to context CFLibXmlCoreContext curContext = xmsgRspnHandler.getCurContext(); // Convert string attributes to native Java types long natTenantId = Long.parseLong(attrTenantId); long natCartridgeId = Long.parseLong(attrCartridgeId); int natItemId = Integer.parseInt(attrItemId); short natRuleTypeId = Short.parseShort(attrRuleTypeId); String natName = attrName; short natToolSetId = Short.parseShort(attrToolSetId); Short natScopeDefId; if ((attrScopeDefId == null) || (attrScopeDefId.length() <= 0)) { natScopeDefId = null; } else { natScopeDefId = new Short(Short.parseShort(attrScopeDefId)); } short natGenDefId = Short.parseShort(attrGenDefId); Integer natGelExecutableId; if ((attrGelExecutableId == null) || (attrGelExecutableId.length() <= 0)) { natGelExecutableId = null; } else { natGelExecutableId = new Integer(Integer.parseInt(attrGelExecutableId)); } int natRevision = Integer.parseInt(attrRevision); // Get the parent context CFLibXmlCoreContext parentContext = curContext.getPrevContext(); // Instantiate a buffer for the parsed information ICFGenKbTZDateFormatterObj obj = schemaObj.getTZDateFormatterTableObj().newInstance(); CFGenKbTZDateFormatterBuff dataBuff = obj.getTZDateFormatterBuff(); dataBuff.setRequiredTenantId(natTenantId); dataBuff.setRequiredCartridgeId(natCartridgeId); dataBuff.setRequiredItemId(natItemId); dataBuff.setRequiredRuleTypeId(natRuleTypeId); dataBuff.setRequiredName(natName); dataBuff.setRequiredToolSetId(natToolSetId); dataBuff.setOptionalScopeDefId(natScopeDefId); dataBuff.setRequiredGenDefId(natGenDefId); dataBuff.setOptionalGelExecutableId(natGelExecutableId); dataBuff.setRequiredRevision(natRevision); obj.copyBuffToPKey(); SortedMap<CFGenKbGenItemPKey, ICFGenKbGenItemObj> sortedMap = (SortedMap<CFGenKbGenItemPKey, ICFGenKbGenItemObj>) xmsgRspnHandler .getSortedMapOfObjects(); ICFGenKbTZDateFormatterObj realized = (ICFGenKbTZDateFormatterObj) 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.CFGenKbXMsgRspnTZTimeFormatterRecHandler.java
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { try {// w ww.j a v a2 s .c o m // Common XML Attributes String attrId = null; String attrRevision = null; // GenItem Attributes String attrTenantId = null; String attrCartridgeId = null; String attrItemId = null; String attrRuleTypeId = null; String attrName = null; String attrToolSetId = null; String attrScopeDefId = null; String attrGenDefId = null; String attrGelExecutableId = null; // GenBind Attributes // GenFormatter Attributes // TZTimeFormatter Attributes // Attribute Extraction String attrLocalName; int numAttrs; int idxAttr; final String S_ProcName = "startElement"; final String S_LocalName = "LocalName"; assert qName.equals("TZTimeFormatter"); CFGenKbXMsgRspnHandler xmsgRspnHandler = (CFGenKbXMsgRspnHandler) getParser(); if (xmsgRspnHandler == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "getParser()"); } ICFGenKbSchemaObj schemaObj = xmsgRspnHandler.getSchemaObj(); if (schemaObj == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "getParser().getSchemaObj()"); } // Extract Attributes numAttrs = attrs.getLength(); for (idxAttr = 0; idxAttr < numAttrs; idxAttr++) { attrLocalName = attrs.getLocalName(idxAttr); if (attrLocalName.equals("Id")) { if (attrId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("Revision")) { if (attrRevision != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrRevision = attrs.getValue(idxAttr); } else if (attrLocalName.equals("TenantId")) { if (attrTenantId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrTenantId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("CartridgeId")) { if (attrCartridgeId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrCartridgeId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("ItemId")) { if (attrItemId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrItemId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("RuleTypeId")) { if (attrRuleTypeId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrRuleTypeId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("Name")) { if (attrName != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrName = attrs.getValue(idxAttr); } else if (attrLocalName.equals("ToolSetId")) { if (attrToolSetId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrToolSetId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("ScopeDefId")) { if (attrScopeDefId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrScopeDefId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("GenDefId")) { if (attrGenDefId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrGenDefId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("GelExecutableId")) { if (attrGelExecutableId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrGelExecutableId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("schemaLocation")) { // ignored } else { throw CFLib.getDefaultExceptionFactory().newUnrecognizedAttributeException(getClass(), S_ProcName, getParser().getLocationInfo(), attrLocalName); } } // Ensure that required attributes have values if ((attrTenantId == null) || (attrTenantId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "TenantId"); } if ((attrCartridgeId == null) || (attrCartridgeId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "CartridgeId"); } if ((attrItemId == null) || (attrItemId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "ItemId"); } if ((attrRuleTypeId == null) || (attrRuleTypeId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "RuleTypeId"); } if (attrName == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "Name"); } if ((attrToolSetId == null) || (attrToolSetId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "ToolSetId"); } if ((attrGenDefId == null) || (attrGenDefId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "GenDefId"); } // Save named attributes to context CFLibXmlCoreContext curContext = xmsgRspnHandler.getCurContext(); // Convert string attributes to native Java types long natTenantId = Long.parseLong(attrTenantId); long natCartridgeId = Long.parseLong(attrCartridgeId); int natItemId = Integer.parseInt(attrItemId); short natRuleTypeId = Short.parseShort(attrRuleTypeId); String natName = attrName; short natToolSetId = Short.parseShort(attrToolSetId); Short natScopeDefId; if ((attrScopeDefId == null) || (attrScopeDefId.length() <= 0)) { natScopeDefId = null; } else { natScopeDefId = new Short(Short.parseShort(attrScopeDefId)); } short natGenDefId = Short.parseShort(attrGenDefId); Integer natGelExecutableId; if ((attrGelExecutableId == null) || (attrGelExecutableId.length() <= 0)) { natGelExecutableId = null; } else { natGelExecutableId = new Integer(Integer.parseInt(attrGelExecutableId)); } int natRevision = Integer.parseInt(attrRevision); // Get the parent context CFLibXmlCoreContext parentContext = curContext.getPrevContext(); // Instantiate a buffer for the parsed information ICFGenKbTZTimeFormatterObj obj = schemaObj.getTZTimeFormatterTableObj().newInstance(); CFGenKbTZTimeFormatterBuff dataBuff = obj.getTZTimeFormatterBuff(); dataBuff.setRequiredTenantId(natTenantId); dataBuff.setRequiredCartridgeId(natCartridgeId); dataBuff.setRequiredItemId(natItemId); dataBuff.setRequiredRuleTypeId(natRuleTypeId); dataBuff.setRequiredName(natName); dataBuff.setRequiredToolSetId(natToolSetId); dataBuff.setOptionalScopeDefId(natScopeDefId); dataBuff.setRequiredGenDefId(natGenDefId); dataBuff.setOptionalGelExecutableId(natGelExecutableId); dataBuff.setRequiredRevision(natRevision); obj.copyBuffToPKey(); SortedMap<CFGenKbGenItemPKey, ICFGenKbGenItemObj> sortedMap = (SortedMap<CFGenKbGenItemPKey, ICFGenKbGenItemObj>) xmsgRspnHandler .getSortedMapOfObjects(); ICFGenKbTZTimeFormatterObj realized = (ICFGenKbTZTimeFormatterObj) 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.CFGenKbXMsgRspnUInt16FormatterRecHandler.java
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { try {//from w w w . j av a 2s .c om // Common XML Attributes String attrId = null; String attrRevision = null; // GenItem Attributes String attrTenantId = null; String attrCartridgeId = null; String attrItemId = null; String attrRuleTypeId = null; String attrName = null; String attrToolSetId = null; String attrScopeDefId = null; String attrGenDefId = null; String attrGelExecutableId = null; // GenBind Attributes // GenFormatter Attributes // UInt16Formatter Attributes // Attribute Extraction String attrLocalName; int numAttrs; int idxAttr; final String S_ProcName = "startElement"; final String S_LocalName = "LocalName"; assert qName.equals("UInt16Formatter"); CFGenKbXMsgRspnHandler xmsgRspnHandler = (CFGenKbXMsgRspnHandler) getParser(); if (xmsgRspnHandler == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "getParser()"); } ICFGenKbSchemaObj schemaObj = xmsgRspnHandler.getSchemaObj(); if (schemaObj == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "getParser().getSchemaObj()"); } // Extract Attributes numAttrs = attrs.getLength(); for (idxAttr = 0; idxAttr < numAttrs; idxAttr++) { attrLocalName = attrs.getLocalName(idxAttr); if (attrLocalName.equals("Id")) { if (attrId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("Revision")) { if (attrRevision != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrRevision = attrs.getValue(idxAttr); } else if (attrLocalName.equals("TenantId")) { if (attrTenantId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrTenantId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("CartridgeId")) { if (attrCartridgeId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrCartridgeId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("ItemId")) { if (attrItemId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrItemId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("RuleTypeId")) { if (attrRuleTypeId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrRuleTypeId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("Name")) { if (attrName != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrName = attrs.getValue(idxAttr); } else if (attrLocalName.equals("ToolSetId")) { if (attrToolSetId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrToolSetId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("ScopeDefId")) { if (attrScopeDefId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrScopeDefId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("GenDefId")) { if (attrGenDefId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrGenDefId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("GelExecutableId")) { if (attrGelExecutableId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrGelExecutableId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("schemaLocation")) { // ignored } else { throw CFLib.getDefaultExceptionFactory().newUnrecognizedAttributeException(getClass(), S_ProcName, getParser().getLocationInfo(), attrLocalName); } } // Ensure that required attributes have values if ((attrTenantId == null) || (attrTenantId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "TenantId"); } if ((attrCartridgeId == null) || (attrCartridgeId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "CartridgeId"); } if ((attrItemId == null) || (attrItemId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "ItemId"); } if ((attrRuleTypeId == null) || (attrRuleTypeId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "RuleTypeId"); } if (attrName == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "Name"); } if ((attrToolSetId == null) || (attrToolSetId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "ToolSetId"); } if ((attrGenDefId == null) || (attrGenDefId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "GenDefId"); } // Save named attributes to context CFLibXmlCoreContext curContext = xmsgRspnHandler.getCurContext(); // Convert string attributes to native Java types long natTenantId = Long.parseLong(attrTenantId); long natCartridgeId = Long.parseLong(attrCartridgeId); int natItemId = Integer.parseInt(attrItemId); short natRuleTypeId = Short.parseShort(attrRuleTypeId); String natName = attrName; short natToolSetId = Short.parseShort(attrToolSetId); Short natScopeDefId; if ((attrScopeDefId == null) || (attrScopeDefId.length() <= 0)) { natScopeDefId = null; } else { natScopeDefId = new Short(Short.parseShort(attrScopeDefId)); } short natGenDefId = Short.parseShort(attrGenDefId); Integer natGelExecutableId; if ((attrGelExecutableId == null) || (attrGelExecutableId.length() <= 0)) { natGelExecutableId = null; } else { natGelExecutableId = new Integer(Integer.parseInt(attrGelExecutableId)); } int natRevision = Integer.parseInt(attrRevision); // Get the parent context CFLibXmlCoreContext parentContext = curContext.getPrevContext(); // Instantiate a buffer for the parsed information ICFGenKbUInt16FormatterObj obj = schemaObj.getUInt16FormatterTableObj().newInstance(); CFGenKbUInt16FormatterBuff dataBuff = obj.getUInt16FormatterBuff(); dataBuff.setRequiredTenantId(natTenantId); dataBuff.setRequiredCartridgeId(natCartridgeId); dataBuff.setRequiredItemId(natItemId); dataBuff.setRequiredRuleTypeId(natRuleTypeId); dataBuff.setRequiredName(natName); dataBuff.setRequiredToolSetId(natToolSetId); dataBuff.setOptionalScopeDefId(natScopeDefId); dataBuff.setRequiredGenDefId(natGenDefId); dataBuff.setOptionalGelExecutableId(natGelExecutableId); dataBuff.setRequiredRevision(natRevision); obj.copyBuffToPKey(); SortedMap<CFGenKbGenItemPKey, ICFGenKbGenItemObj> sortedMap = (SortedMap<CFGenKbGenItemPKey, ICFGenKbGenItemObj>) xmsgRspnHandler .getSortedMapOfObjects(); ICFGenKbUInt16FormatterObj realized = (ICFGenKbUInt16FormatterObj) 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.CFGenKbXMsgRspnUInt32FormatterRecHandler.java
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { try {/*from w w w .ja v a 2 s .c om*/ // Common XML Attributes String attrId = null; String attrRevision = null; // GenItem Attributes String attrTenantId = null; String attrCartridgeId = null; String attrItemId = null; String attrRuleTypeId = null; String attrName = null; String attrToolSetId = null; String attrScopeDefId = null; String attrGenDefId = null; String attrGelExecutableId = null; // GenBind Attributes // GenFormatter Attributes // UInt32Formatter Attributes // Attribute Extraction String attrLocalName; int numAttrs; int idxAttr; final String S_ProcName = "startElement"; final String S_LocalName = "LocalName"; assert qName.equals("UInt32Formatter"); CFGenKbXMsgRspnHandler xmsgRspnHandler = (CFGenKbXMsgRspnHandler) getParser(); if (xmsgRspnHandler == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "getParser()"); } ICFGenKbSchemaObj schemaObj = xmsgRspnHandler.getSchemaObj(); if (schemaObj == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "getParser().getSchemaObj()"); } // Extract Attributes numAttrs = attrs.getLength(); for (idxAttr = 0; idxAttr < numAttrs; idxAttr++) { attrLocalName = attrs.getLocalName(idxAttr); if (attrLocalName.equals("Id")) { if (attrId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("Revision")) { if (attrRevision != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrRevision = attrs.getValue(idxAttr); } else if (attrLocalName.equals("TenantId")) { if (attrTenantId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrTenantId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("CartridgeId")) { if (attrCartridgeId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrCartridgeId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("ItemId")) { if (attrItemId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrItemId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("RuleTypeId")) { if (attrRuleTypeId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrRuleTypeId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("Name")) { if (attrName != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrName = attrs.getValue(idxAttr); } else if (attrLocalName.equals("ToolSetId")) { if (attrToolSetId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrToolSetId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("ScopeDefId")) { if (attrScopeDefId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrScopeDefId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("GenDefId")) { if (attrGenDefId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrGenDefId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("GelExecutableId")) { if (attrGelExecutableId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrGelExecutableId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("schemaLocation")) { // ignored } else { throw CFLib.getDefaultExceptionFactory().newUnrecognizedAttributeException(getClass(), S_ProcName, getParser().getLocationInfo(), attrLocalName); } } // Ensure that required attributes have values if ((attrTenantId == null) || (attrTenantId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "TenantId"); } if ((attrCartridgeId == null) || (attrCartridgeId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "CartridgeId"); } if ((attrItemId == null) || (attrItemId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "ItemId"); } if ((attrRuleTypeId == null) || (attrRuleTypeId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "RuleTypeId"); } if (attrName == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "Name"); } if ((attrToolSetId == null) || (attrToolSetId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "ToolSetId"); } if ((attrGenDefId == null) || (attrGenDefId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "GenDefId"); } // Save named attributes to context CFLibXmlCoreContext curContext = xmsgRspnHandler.getCurContext(); // Convert string attributes to native Java types long natTenantId = Long.parseLong(attrTenantId); long natCartridgeId = Long.parseLong(attrCartridgeId); int natItemId = Integer.parseInt(attrItemId); short natRuleTypeId = Short.parseShort(attrRuleTypeId); String natName = attrName; short natToolSetId = Short.parseShort(attrToolSetId); Short natScopeDefId; if ((attrScopeDefId == null) || (attrScopeDefId.length() <= 0)) { natScopeDefId = null; } else { natScopeDefId = new Short(Short.parseShort(attrScopeDefId)); } short natGenDefId = Short.parseShort(attrGenDefId); Integer natGelExecutableId; if ((attrGelExecutableId == null) || (attrGelExecutableId.length() <= 0)) { natGelExecutableId = null; } else { natGelExecutableId = new Integer(Integer.parseInt(attrGelExecutableId)); } int natRevision = Integer.parseInt(attrRevision); // Get the parent context CFLibXmlCoreContext parentContext = curContext.getPrevContext(); // Instantiate a buffer for the parsed information ICFGenKbUInt32FormatterObj obj = schemaObj.getUInt32FormatterTableObj().newInstance(); CFGenKbUInt32FormatterBuff dataBuff = obj.getUInt32FormatterBuff(); dataBuff.setRequiredTenantId(natTenantId); dataBuff.setRequiredCartridgeId(natCartridgeId); dataBuff.setRequiredItemId(natItemId); dataBuff.setRequiredRuleTypeId(natRuleTypeId); dataBuff.setRequiredName(natName); dataBuff.setRequiredToolSetId(natToolSetId); dataBuff.setOptionalScopeDefId(natScopeDefId); dataBuff.setRequiredGenDefId(natGenDefId); dataBuff.setOptionalGelExecutableId(natGelExecutableId); dataBuff.setRequiredRevision(natRevision); obj.copyBuffToPKey(); SortedMap<CFGenKbGenItemPKey, ICFGenKbGenItemObj> sortedMap = (SortedMap<CFGenKbGenItemPKey, ICFGenKbGenItemObj>) xmsgRspnHandler .getSortedMapOfObjects(); ICFGenKbUInt32FormatterObj realized = (ICFGenKbUInt32FormatterObj) 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.CFGenKbXMsgRspnUInt64FormatterRecHandler.java
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { try {/*from ww w .j a v a 2 s. c o m*/ // Common XML Attributes String attrId = null; String attrRevision = null; // GenItem Attributes String attrTenantId = null; String attrCartridgeId = null; String attrItemId = null; String attrRuleTypeId = null; String attrName = null; String attrToolSetId = null; String attrScopeDefId = null; String attrGenDefId = null; String attrGelExecutableId = null; // GenBind Attributes // GenFormatter Attributes // UInt64Formatter Attributes // Attribute Extraction String attrLocalName; int numAttrs; int idxAttr; final String S_ProcName = "startElement"; final String S_LocalName = "LocalName"; assert qName.equals("UInt64Formatter"); CFGenKbXMsgRspnHandler xmsgRspnHandler = (CFGenKbXMsgRspnHandler) getParser(); if (xmsgRspnHandler == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "getParser()"); } ICFGenKbSchemaObj schemaObj = xmsgRspnHandler.getSchemaObj(); if (schemaObj == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "getParser().getSchemaObj()"); } // Extract Attributes numAttrs = attrs.getLength(); for (idxAttr = 0; idxAttr < numAttrs; idxAttr++) { attrLocalName = attrs.getLocalName(idxAttr); if (attrLocalName.equals("Id")) { if (attrId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("Revision")) { if (attrRevision != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrRevision = attrs.getValue(idxAttr); } else if (attrLocalName.equals("TenantId")) { if (attrTenantId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrTenantId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("CartridgeId")) { if (attrCartridgeId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrCartridgeId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("ItemId")) { if (attrItemId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrItemId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("RuleTypeId")) { if (attrRuleTypeId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrRuleTypeId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("Name")) { if (attrName != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrName = attrs.getValue(idxAttr); } else if (attrLocalName.equals("ToolSetId")) { if (attrToolSetId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrToolSetId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("ScopeDefId")) { if (attrScopeDefId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrScopeDefId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("GenDefId")) { if (attrGenDefId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrGenDefId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("GelExecutableId")) { if (attrGelExecutableId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrGelExecutableId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("schemaLocation")) { // ignored } else { throw CFLib.getDefaultExceptionFactory().newUnrecognizedAttributeException(getClass(), S_ProcName, getParser().getLocationInfo(), attrLocalName); } } // Ensure that required attributes have values if ((attrTenantId == null) || (attrTenantId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "TenantId"); } if ((attrCartridgeId == null) || (attrCartridgeId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "CartridgeId"); } if ((attrItemId == null) || (attrItemId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "ItemId"); } if ((attrRuleTypeId == null) || (attrRuleTypeId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "RuleTypeId"); } if (attrName == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "Name"); } if ((attrToolSetId == null) || (attrToolSetId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "ToolSetId"); } if ((attrGenDefId == null) || (attrGenDefId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "GenDefId"); } // Save named attributes to context CFLibXmlCoreContext curContext = xmsgRspnHandler.getCurContext(); // Convert string attributes to native Java types long natTenantId = Long.parseLong(attrTenantId); long natCartridgeId = Long.parseLong(attrCartridgeId); int natItemId = Integer.parseInt(attrItemId); short natRuleTypeId = Short.parseShort(attrRuleTypeId); String natName = attrName; short natToolSetId = Short.parseShort(attrToolSetId); Short natScopeDefId; if ((attrScopeDefId == null) || (attrScopeDefId.length() <= 0)) { natScopeDefId = null; } else { natScopeDefId = new Short(Short.parseShort(attrScopeDefId)); } short natGenDefId = Short.parseShort(attrGenDefId); Integer natGelExecutableId; if ((attrGelExecutableId == null) || (attrGelExecutableId.length() <= 0)) { natGelExecutableId = null; } else { natGelExecutableId = new Integer(Integer.parseInt(attrGelExecutableId)); } int natRevision = Integer.parseInt(attrRevision); // Get the parent context CFLibXmlCoreContext parentContext = curContext.getPrevContext(); // Instantiate a buffer for the parsed information ICFGenKbUInt64FormatterObj obj = schemaObj.getUInt64FormatterTableObj().newInstance(); CFGenKbUInt64FormatterBuff dataBuff = obj.getUInt64FormatterBuff(); dataBuff.setRequiredTenantId(natTenantId); dataBuff.setRequiredCartridgeId(natCartridgeId); dataBuff.setRequiredItemId(natItemId); dataBuff.setRequiredRuleTypeId(natRuleTypeId); dataBuff.setRequiredName(natName); dataBuff.setRequiredToolSetId(natToolSetId); dataBuff.setOptionalScopeDefId(natScopeDefId); dataBuff.setRequiredGenDefId(natGenDefId); dataBuff.setOptionalGelExecutableId(natGelExecutableId); dataBuff.setRequiredRevision(natRevision); obj.copyBuffToPKey(); SortedMap<CFGenKbGenItemPKey, ICFGenKbGenItemObj> sortedMap = (SortedMap<CFGenKbGenItemPKey, ICFGenKbGenItemObj>) xmsgRspnHandler .getSortedMapOfObjects(); ICFGenKbUInt64FormatterObj realized = (ICFGenKbUInt64FormatterObj) 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:com.examples.with.different.packagename.testcarver.NumberConverter.java
/** * Convert any Number object to the specified type for this * <i>Converter</i>./*from w w w . j ava 2s . com*/ * <p> * This method handles conversion to the following types: * <ul> * <li><code>java.lang.Byte</code></li> * <li><code>java.lang.Short</code></li> * <li><code>java.lang.Integer</code></li> * <li><code>java.lang.Long</code></li> * <li><code>java.lang.Float</code></li> * <li><code>java.lang.Double</code></li> * <li><code>java.math.BigDecimal</code></li> * <li><code>java.math.BigInteger</code></li> * </ul> * @param sourceType The type being converted from * @param targetType The Number type to convert to * @param value The Number to convert. * * @return The converted value. */ private Number toNumber(Class sourceType, Class targetType, Number value) { // Correct Number type already if (targetType.equals(value.getClass())) { return value; } // Byte if (targetType.equals(Byte.class)) { long longValue = value.longValue(); if (longValue > Byte.MAX_VALUE) { throw new ConversionException( toString(sourceType) + " value '" + value + "' is too large for " + toString(targetType)); } if (longValue < Byte.MIN_VALUE) { throw new ConversionException( toString(sourceType) + " value '" + value + "' is too small " + toString(targetType)); } return new Byte(value.byteValue()); } // Short if (targetType.equals(Short.class)) { long longValue = value.longValue(); if (longValue > Short.MAX_VALUE) { throw new ConversionException( toString(sourceType) + " value '" + value + "' is too large for " + toString(targetType)); } if (longValue < Short.MIN_VALUE) { throw new ConversionException( toString(sourceType) + " value '" + value + "' is too small " + toString(targetType)); } return new Short(value.shortValue()); } // Integer if (targetType.equals(Integer.class)) { long longValue = value.longValue(); if (longValue > Integer.MAX_VALUE) { throw new ConversionException( toString(sourceType) + " value '" + value + "' is too large for " + toString(targetType)); } if (longValue < Integer.MIN_VALUE) { throw new ConversionException( toString(sourceType) + " value '" + value + "' is too small " + toString(targetType)); } return new Integer(value.intValue()); } // Long if (targetType.equals(Long.class)) { return new Long(value.longValue()); } // Float if (targetType.equals(Float.class)) { if (value.doubleValue() > Float.MAX_VALUE) { throw new ConversionException( toString(sourceType) + " value '" + value + "' is too large for " + toString(targetType)); } return new Float(value.floatValue()); } // Double if (targetType.equals(Double.class)) { return new Double(value.doubleValue()); } // BigDecimal if (targetType.equals(BigDecimal.class)) { if (value instanceof Float || value instanceof Double) { return new BigDecimal(value.toString()); } else if (value instanceof BigInteger) { return new BigDecimal((BigInteger) value); } else { return BigDecimal.valueOf(value.longValue()); } } // BigInteger if (targetType.equals(BigInteger.class)) { if (value instanceof BigDecimal) { return ((BigDecimal) value).toBigInteger(); } else { return BigInteger.valueOf(value.longValue()); } } String msg = toString(getClass()) + " cannot handle conversion to '" + toString(targetType) + "'"; throw new ConversionException(msg); }