List of usage examples for java.lang Short parseShort
public static short parseShort(String s) throws NumberFormatException
From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccXMsgRqstHandler.CFAccXMsgRqstISOCountryLanguageReadByLanguageIdxHandler.java
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { try {/*from w w w . j ava 2 s .c o m*/ // Common XML Attributes String attrId = null; String attrISOLanguageId = null; // Attribute Extraction String attrLocalName; int numAttrs; int idxAttr; final String S_ProcName = "startElement"; final String S_LocalName = "LocalName"; assert qName.equals("RqstISOCountryLanguageReadByLanguageIdx"); CFAccXMsgRqstHandler xmsgRqstHandler = (CFAccXMsgRqstHandler) getParser(); if (xmsgRqstHandler == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "getParser()"); } ICFAccSchemaObj schemaObj = xmsgRqstHandler.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("ISOLanguageId")) { if (attrISOLanguageId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrISOLanguageId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("schemaLocation")) { // ignored } else { throw CFLib.getDefaultExceptionFactory().newUnrecognizedAttributeException(getClass(), S_ProcName, getParser().getLocationInfo(), attrLocalName); } } // Ensure that required attributes have values$implRqstTableReadByHandlerCheckReqKeyAttrs$ // Save named attributes to context CFLibXmlCoreContext curContext = getParser().getCurContext(); // Convert string attributes to native Java types // and apply the converted attributes to the editBuff. short natISOLanguageId; natISOLanguageId = Short.parseShort(attrISOLanguageId); // Read the objects SortedMap<CFAccISOCountryLanguagePKey, ICFAccISOCountryLanguageObj> map = schemaObj .getISOCountryLanguageTableObj().readISOCountryLanguageByLanguageIdx(natISOLanguageId); String responseOpening = CFAccXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFAccXMsgISOCountryLanguageMessageFormatter.formatISOCountryLanguageRspnListOpenTag(); xmsgRqstHandler.appendResponse(responseOpening); Iterator<ICFAccISOCountryLanguageObj> iter = map.values().iterator(); ICFAccISOCountryLanguageObj cur; String subxml; while (iter.hasNext()) { cur = iter.next(); subxml = CFAccXMsgISOCountryLanguageMessageFormatter .formatISOCountryLanguageRspnDerivedRec("\n\t\t", cur.getISOCountryLanguageBuff()); xmsgRqstHandler.appendResponse(subxml); } String responseClosing = "\n" + "\t" + CFAccXMsgISOCountryLanguageMessageFormatter.formatISOCountryLanguageRspnListCloseTag() + CFAccXMsgSchemaMessageFormatter.formatRspnXmlPostamble(); xmsgRqstHandler.appendResponse(responseClosing); } catch (RuntimeException e) { String response = CFAccXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFAccXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n" + CFAccXMsgSchemaMessageFormatter.formatRspnXmlPostamble(); CFAccXMsgRqstHandler xmsgRqstHandler = ((CFAccXMsgRqstHandler) getParser()); xmsgRqstHandler.resetResponse(); xmsgRqstHandler.appendResponse(response); xmsgRqstHandler.setCaughtException(true); } catch (Error e) { String response = CFAccXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFAccXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n" + CFAccXMsgSchemaMessageFormatter.formatRspnXmlPostamble(); CFAccXMsgRqstHandler xmsgRqstHandler = ((CFAccXMsgRqstHandler) getParser()); xmsgRqstHandler.resetResponse(); xmsgRqstHandler.appendResponse(response); xmsgRqstHandler.setCaughtException(true); } }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAstXMsgRqstHandler.CFAstXMsgRqstISOCountryCurrencyReadByCurrencyIdxHandler.java
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { try {//w ww . j a va2s . c om // Common XML Attributes String attrId = null; String attrISOCurrencyId = null; // Attribute Extraction String attrLocalName; int numAttrs; int idxAttr; final String S_ProcName = "startElement"; final String S_LocalName = "LocalName"; assert qName.equals("RqstISOCountryCurrencyReadByCurrencyIdx"); CFAstXMsgRqstHandler xmsgRqstHandler = (CFAstXMsgRqstHandler) getParser(); if (xmsgRqstHandler == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "getParser()"); } ICFAstSchemaObj schemaObj = xmsgRqstHandler.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("ISOCurrencyId")) { if (attrISOCurrencyId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrISOCurrencyId = 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$implRqstTableReadByHandlerCheckReqKeyAttrs$ // Save named attributes to context CFLibXmlCoreContext curContext = getParser().getCurContext(); // Convert string attributes to native Java types // and apply the converted attributes to the editBuff. short natISOCurrencyId; natISOCurrencyId = Short.parseShort(attrISOCurrencyId); // Read the objects SortedMap<CFAstISOCountryCurrencyPKey, ICFAstISOCountryCurrencyObj> map = schemaObj .getISOCountryCurrencyTableObj().readISOCountryCurrencyByCurrencyIdx(natISOCurrencyId); String responseOpening = CFAstXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFAstXMsgISOCountryCurrencyMessageFormatter.formatISOCountryCurrencyRspnListOpenTag(); xmsgRqstHandler.appendResponse(responseOpening); Iterator<ICFAstISOCountryCurrencyObj> iter = map.values().iterator(); ICFAstISOCountryCurrencyObj cur; String subxml; while (iter.hasNext()) { cur = iter.next(); subxml = CFAstXMsgISOCountryCurrencyMessageFormatter .formatISOCountryCurrencyRspnDerivedRec("\n\t\t", cur.getISOCountryCurrencyBuff()); xmsgRqstHandler.appendResponse(subxml); } String responseClosing = "\n" + "\t" + CFAstXMsgISOCountryCurrencyMessageFormatter.formatISOCountryCurrencyRspnListCloseTag() + CFAstXMsgSchemaMessageFormatter.formatRspnXmlPostamble(); xmsgRqstHandler.appendResponse(responseClosing); } catch (RuntimeException e) { String response = CFAstXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFAstXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n" + CFAstXMsgSchemaMessageFormatter.formatRspnXmlPostamble(); CFAstXMsgRqstHandler xmsgRqstHandler = ((CFAstXMsgRqstHandler) getParser()); xmsgRqstHandler.resetResponse(); xmsgRqstHandler.appendResponse(response); xmsgRqstHandler.setCaughtException(true); } catch (Error e) { String response = CFAstXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFAstXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n" + CFAstXMsgSchemaMessageFormatter.formatRspnXmlPostamble(); CFAstXMsgRqstHandler xmsgRqstHandler = ((CFAstXMsgRqstHandler) getParser()); xmsgRqstHandler.resetResponse(); xmsgRqstHandler.appendResponse(response); xmsgRqstHandler.setCaughtException(true); } }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAstXMsgRqstHandler.CFAstXMsgRqstISOCountryLanguageReadByLanguageIdxHandler.java
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { try {/*from w ww.j a v a 2 s .c o m*/ // Common XML Attributes String attrId = null; String attrISOLanguageId = null; // Attribute Extraction String attrLocalName; int numAttrs; int idxAttr; final String S_ProcName = "startElement"; final String S_LocalName = "LocalName"; assert qName.equals("RqstISOCountryLanguageReadByLanguageIdx"); CFAstXMsgRqstHandler xmsgRqstHandler = (CFAstXMsgRqstHandler) getParser(); if (xmsgRqstHandler == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "getParser()"); } ICFAstSchemaObj schemaObj = xmsgRqstHandler.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("ISOLanguageId")) { if (attrISOLanguageId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrISOLanguageId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("schemaLocation")) { // ignored } else { throw CFLib.getDefaultExceptionFactory().newUnrecognizedAttributeException(getClass(), S_ProcName, getParser().getLocationInfo(), attrLocalName); } } // Ensure that required attributes have values$implRqstTableReadByHandlerCheckReqKeyAttrs$ // Save named attributes to context CFLibXmlCoreContext curContext = getParser().getCurContext(); // Convert string attributes to native Java types // and apply the converted attributes to the editBuff. short natISOLanguageId; natISOLanguageId = Short.parseShort(attrISOLanguageId); // Read the objects SortedMap<CFAstISOCountryLanguagePKey, ICFAstISOCountryLanguageObj> map = schemaObj .getISOCountryLanguageTableObj().readISOCountryLanguageByLanguageIdx(natISOLanguageId); String responseOpening = CFAstXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFAstXMsgISOCountryLanguageMessageFormatter.formatISOCountryLanguageRspnListOpenTag(); xmsgRqstHandler.appendResponse(responseOpening); Iterator<ICFAstISOCountryLanguageObj> iter = map.values().iterator(); ICFAstISOCountryLanguageObj cur; String subxml; while (iter.hasNext()) { cur = iter.next(); subxml = CFAstXMsgISOCountryLanguageMessageFormatter .formatISOCountryLanguageRspnDerivedRec("\n\t\t", cur.getISOCountryLanguageBuff()); xmsgRqstHandler.appendResponse(subxml); } String responseClosing = "\n" + "\t" + CFAstXMsgISOCountryLanguageMessageFormatter.formatISOCountryLanguageRspnListCloseTag() + CFAstXMsgSchemaMessageFormatter.formatRspnXmlPostamble(); xmsgRqstHandler.appendResponse(responseClosing); } catch (RuntimeException e) { String response = CFAstXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFAstXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n" + CFAstXMsgSchemaMessageFormatter.formatRspnXmlPostamble(); CFAstXMsgRqstHandler xmsgRqstHandler = ((CFAstXMsgRqstHandler) getParser()); xmsgRqstHandler.resetResponse(); xmsgRqstHandler.appendResponse(response); xmsgRqstHandler.setCaughtException(true); } catch (Error e) { String response = CFAstXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFAstXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n" + CFAstXMsgSchemaMessageFormatter.formatRspnXmlPostamble(); CFAstXMsgRqstHandler xmsgRqstHandler = ((CFAstXMsgRqstHandler) getParser()); xmsgRqstHandler.resetResponse(); xmsgRqstHandler.appendResponse(response); xmsgRqstHandler.setCaughtException(true); } }
From source file:net.sourceforge.msscodefactory.cfgcash.v2_0.CFGCashXMsgRqstHandler.CFGCashXMsgRqstISOLanguageReadByCountryIdxHandler.java
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { try {/*from w ww .ja va 2s. co m*/ // Common XML Attributes String attrId = null; String attrISOCountryId = null; // Attribute Extraction String attrLocalName; int numAttrs; int idxAttr; final String S_ProcName = "startElement"; final String S_LocalName = "LocalName"; assert qName.equals("RqstISOLanguageReadByCountryIdx"); CFGCashXMsgRqstHandler xmsgRqstHandler = (CFGCashXMsgRqstHandler) getParser(); if (xmsgRqstHandler == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "getParser()"); } ICFGCashSchemaObj schemaObj = xmsgRqstHandler.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("ISOCountryId")) { if (attrISOCountryId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrISOCountryId = 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$implRqstTableReadByHandlerCheckReqKeyAttrs$ // Save named attributes to context CFLibXmlCoreContext curContext = getParser().getCurContext(); // Convert string attributes to native Java types // and apply the converted attributes to the editBuff. Short natISOCountryId; natISOCountryId = new Short(Short.parseShort(attrISOCountryId)); // Read the objects SortedMap<CFGCashISOLanguagePKey, ICFGCashISOLanguageObj> map = schemaObj.getISOLanguageTableObj() .readISOLanguageByCountryIdx(natISOCountryId); String responseOpening = CFGCashXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFGCashXMsgISOLanguageMessageFormatter.formatISOLanguageRspnListOpenTag(); xmsgRqstHandler.appendResponse(responseOpening); Iterator<ICFGCashISOLanguageObj> iter = map.values().iterator(); ICFGCashISOLanguageObj cur; String subxml; while (iter.hasNext()) { cur = iter.next(); subxml = CFGCashXMsgISOLanguageMessageFormatter.formatISOLanguageRspnDerivedRec("\n\t\t", cur.getISOLanguageBuff()); xmsgRqstHandler.appendResponse(subxml); } String responseClosing = "\n" + "\t" + CFGCashXMsgISOLanguageMessageFormatter.formatISOLanguageRspnListCloseTag() + CFGCashXMsgSchemaMessageFormatter.formatRspnXmlPostamble(); xmsgRqstHandler.appendResponse(responseClosing); } catch (RuntimeException e) { String response = CFGCashXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFGCashXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n" + CFGCashXMsgSchemaMessageFormatter.formatRspnXmlPostamble(); CFGCashXMsgRqstHandler xmsgRqstHandler = ((CFGCashXMsgRqstHandler) getParser()); xmsgRqstHandler.resetResponse(); xmsgRqstHandler.appendResponse(response); xmsgRqstHandler.setCaughtException(true); } catch (Error e) { String response = CFGCashXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFGCashXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n" + CFGCashXMsgSchemaMessageFormatter.formatRspnXmlPostamble(); CFGCashXMsgRqstHandler xmsgRqstHandler = ((CFGCashXMsgRqstHandler) getParser()); xmsgRqstHandler.resetResponse(); xmsgRqstHandler.appendResponse(response); xmsgRqstHandler.setCaughtException(true); } }
From source file:net.sourceforge.msscodefactory.cfgcash.v2_0.CFGCashXMsgRqstHandler.CFGCashXMsgRqstContactURLReadByProtocolIdxHandler.java
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { try {/*from ww w. j a v a 2s .com*/ // Common XML Attributes String attrId = null; String attrURLProtocolId = null; // Attribute Extraction String attrLocalName; int numAttrs; int idxAttr; final String S_ProcName = "startElement"; final String S_LocalName = "LocalName"; assert qName.equals("RqstContactURLReadByProtocolIdx"); CFGCashXMsgRqstHandler xmsgRqstHandler = (CFGCashXMsgRqstHandler) getParser(); if (xmsgRqstHandler == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "getParser()"); } ICFGCashSchemaObj schemaObj = xmsgRqstHandler.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("URLProtocolId")) { if (attrURLProtocolId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrURLProtocolId = 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$implRqstTableReadByHandlerCheckReqKeyAttrs$ // Save named attributes to context CFLibXmlCoreContext curContext = getParser().getCurContext(); // Convert string attributes to native Java types // and apply the converted attributes to the editBuff. Short natURLProtocolId; natURLProtocolId = new Short(Short.parseShort(attrURLProtocolId)); // Read the objects SortedMap<CFGCashContactURLPKey, ICFGCashContactURLObj> map = schemaObj.getContactURLTableObj() .readContactURLByProtocolIdx(natURLProtocolId); String responseOpening = CFGCashXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFGCashXMsgContactURLMessageFormatter.formatContactURLRspnListOpenTag(); xmsgRqstHandler.appendResponse(responseOpening); Iterator<ICFGCashContactURLObj> iter = map.values().iterator(); ICFGCashContactURLObj cur; String subxml; while (iter.hasNext()) { cur = iter.next(); subxml = CFGCashXMsgContactURLMessageFormatter.formatContactURLRspnDerivedRec("\n\t\t", cur.getContactURLBuff()); xmsgRqstHandler.appendResponse(subxml); } String responseClosing = "\n" + "\t" + CFGCashXMsgContactURLMessageFormatter.formatContactURLRspnListCloseTag() + CFGCashXMsgSchemaMessageFormatter.formatRspnXmlPostamble(); xmsgRqstHandler.appendResponse(responseClosing); } catch (RuntimeException e) { String response = CFGCashXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFGCashXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n" + CFGCashXMsgSchemaMessageFormatter.formatRspnXmlPostamble(); CFGCashXMsgRqstHandler xmsgRqstHandler = ((CFGCashXMsgRqstHandler) getParser()); xmsgRqstHandler.resetResponse(); xmsgRqstHandler.appendResponse(response); xmsgRqstHandler.setCaughtException(true); } catch (Error e) { String response = CFGCashXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFGCashXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n" + CFGCashXMsgSchemaMessageFormatter.formatRspnXmlPostamble(); CFGCashXMsgRqstHandler xmsgRqstHandler = ((CFGCashXMsgRqstHandler) getParser()); xmsgRqstHandler.resetResponse(); xmsgRqstHandler.appendResponse(response); xmsgRqstHandler.setCaughtException(true); } }
From source file:net.sourceforge.msscodefactory.cffreeswitch.v2_0.CFFswXMsgRqstHandler.CFFswXMsgRqstISOCountryLanguageReadByLanguageIdxHandler.java
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { try {/*w w w . ja v a 2 s .com*/ // Common XML Attributes String attrId = null; String attrISOLanguageId = null; // Attribute Extraction String attrLocalName; int numAttrs; int idxAttr; final String S_ProcName = "startElement"; final String S_LocalName = "LocalName"; assert qName.equals("RqstISOCountryLanguageReadByLanguageIdx"); CFFswXMsgRqstHandler xmsgRqstHandler = (CFFswXMsgRqstHandler) getParser(); if (xmsgRqstHandler == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "getParser()"); } ICFFswSchemaObj schemaObj = xmsgRqstHandler.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("ISOLanguageId")) { if (attrISOLanguageId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrISOLanguageId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("schemaLocation")) { // ignored } else { throw CFLib.getDefaultExceptionFactory().newUnrecognizedAttributeException(getClass(), S_ProcName, getParser().getLocationInfo(), attrLocalName); } } // Ensure that required attributes have values$implRqstTableReadByHandlerCheckReqKeyAttrs$ // Save named attributes to context CFLibXmlCoreContext curContext = getParser().getCurContext(); // Convert string attributes to native Java types // and apply the converted attributes to the editBuff. short natISOLanguageId; natISOLanguageId = Short.parseShort(attrISOLanguageId); // Read the objects SortedMap<CFFswISOCountryLanguagePKey, ICFFswISOCountryLanguageObj> map = schemaObj .getISOCountryLanguageTableObj().readISOCountryLanguageByLanguageIdx(natISOLanguageId); String responseOpening = CFFswXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFFswXMsgISOCountryLanguageMessageFormatter.formatISOCountryLanguageRspnListOpenTag(); xmsgRqstHandler.appendResponse(responseOpening); Iterator<ICFFswISOCountryLanguageObj> iter = map.values().iterator(); ICFFswISOCountryLanguageObj cur; String subxml; while (iter.hasNext()) { cur = iter.next(); subxml = CFFswXMsgISOCountryLanguageMessageFormatter .formatISOCountryLanguageRspnDerivedRec("\n\t\t", cur.getISOCountryLanguageBuff()); xmsgRqstHandler.appendResponse(subxml); } String responseClosing = "\n" + "\t" + CFFswXMsgISOCountryLanguageMessageFormatter.formatISOCountryLanguageRspnListCloseTag() + CFFswXMsgSchemaMessageFormatter.formatRspnXmlPostamble(); xmsgRqstHandler.appendResponse(responseClosing); } catch (RuntimeException e) { String response = CFFswXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFFswXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n" + CFFswXMsgSchemaMessageFormatter.formatRspnXmlPostamble(); CFFswXMsgRqstHandler xmsgRqstHandler = ((CFFswXMsgRqstHandler) getParser()); xmsgRqstHandler.resetResponse(); xmsgRqstHandler.appendResponse(response); xmsgRqstHandler.setCaughtException(true); } catch (Error e) { String response = CFFswXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFFswXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n" + CFFswXMsgSchemaMessageFormatter.formatRspnXmlPostamble(); CFFswXMsgRqstHandler xmsgRqstHandler = ((CFFswXMsgRqstHandler) getParser()); xmsgRqstHandler.resetResponse(); xmsgRqstHandler.appendResponse(response); xmsgRqstHandler.setCaughtException(true); } }
From source file:com.jroossien.boxx.aliases.items.Items.java
/** * Get the {@link ItemData} for the specified string. * The string can be any of the following. (Casing doesn't matter) * <ul>// w w w .j a va 2 s . c o m * <li>Material name with underscores (DIAMOND_SWORD)</li> * <li>Material name without underscores (DIAMONDSWORD)</li> * <li>Display name with underscores (Diamond_Sword)</li> * <li>Display name without underscores (DiamondSword)</li> * <li>Any of the aliases (diasword, dsword, etc)</li> * <li>The item ID</li> * </ul> * You can follow up the string with a semicolon(:), hashtag(#), dot(.) or a dash(-) and the data. * For example wool:9, cloth#9, whitewool.9 or 35-9 would return Cyan Wool. * When you specify a specific item with data like cyanwool and specify data the data will be used. * So if you do cyanwool:10 you would get Purple Wool and not Cyan Wool. * * @param string The string to find matching {@link ItemData} for. (See description for values) * @return The {@link ItemData} that matches the string. (Will be {@code null} when there is no match found!) */ public static ItemData getItem(String string) { string = string.toLowerCase().trim(); String[] split; if (string.contains("-")) { split = string.split("\\-"); } else if (string.contains("#")) { split = string.split("#"); } else if (string.contains(".")) { split = string.split("\\."); } else { split = string.split(":"); } String search = split[0]; short data = 0; if (split.length > 1) { try { data = Short.parseShort(split[1]); } catch (Exception e) { } } //Get item from ID try { int id = Integer.parseInt(search); Material mat = Material.getMaterial(id); if (mat != null) { return getItem(mat, data); } } catch (Exception e) { } //Get item from string if (matchLookup.containsKey(search)) { ItemData match = itemLookup.get(matchLookup.get(search)); return getItem(match.getType(), data > 0 ? data : match.getData()); } //No match return null; }
From source file:net.sourceforge.msscodefactory.cfgcash.v2_0.CFGCashXMsgRqstHandler.CFGCashXMsgRqstISOCountryCurrencyReadByCountryIdxHandler.java
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { try {//from w ww. j a v a2s. c om // Common XML Attributes String attrId = null; String attrISOCountryId = null; // Attribute Extraction String attrLocalName; int numAttrs; int idxAttr; final String S_ProcName = "startElement"; final String S_LocalName = "LocalName"; assert qName.equals("RqstISOCountryCurrencyReadByCountryIdx"); CFGCashXMsgRqstHandler xmsgRqstHandler = (CFGCashXMsgRqstHandler) getParser(); if (xmsgRqstHandler == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "getParser()"); } ICFGCashSchemaObj schemaObj = xmsgRqstHandler.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("ISOCountryId")) { if (attrISOCountryId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrISOCountryId = 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$implRqstTableReadByHandlerCheckReqKeyAttrs$ // Save named attributes to context CFLibXmlCoreContext curContext = getParser().getCurContext(); // Convert string attributes to native Java types // and apply the converted attributes to the editBuff. short natISOCountryId; natISOCountryId = Short.parseShort(attrISOCountryId); // Read the objects SortedMap<CFGCashISOCountryCurrencyPKey, ICFGCashISOCountryCurrencyObj> map = schemaObj .getISOCountryCurrencyTableObj().readISOCountryCurrencyByCountryIdx(natISOCountryId); String responseOpening = CFGCashXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFGCashXMsgISOCountryCurrencyMessageFormatter.formatISOCountryCurrencyRspnListOpenTag(); xmsgRqstHandler.appendResponse(responseOpening); Iterator<ICFGCashISOCountryCurrencyObj> iter = map.values().iterator(); ICFGCashISOCountryCurrencyObj cur; String subxml; while (iter.hasNext()) { cur = iter.next(); subxml = CFGCashXMsgISOCountryCurrencyMessageFormatter .formatISOCountryCurrencyRspnDerivedRec("\n\t\t", cur.getISOCountryCurrencyBuff()); xmsgRqstHandler.appendResponse(subxml); } String responseClosing = "\n" + "\t" + CFGCashXMsgISOCountryCurrencyMessageFormatter.formatISOCountryCurrencyRspnListCloseTag() + CFGCashXMsgSchemaMessageFormatter.formatRspnXmlPostamble(); xmsgRqstHandler.appendResponse(responseClosing); } catch (RuntimeException e) { String response = CFGCashXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFGCashXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n" + CFGCashXMsgSchemaMessageFormatter.formatRspnXmlPostamble(); CFGCashXMsgRqstHandler xmsgRqstHandler = ((CFGCashXMsgRqstHandler) getParser()); xmsgRqstHandler.resetResponse(); xmsgRqstHandler.appendResponse(response); xmsgRqstHandler.setCaughtException(true); } catch (Error e) { String response = CFGCashXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFGCashXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n" + CFGCashXMsgSchemaMessageFormatter.formatRspnXmlPostamble(); CFGCashXMsgRqstHandler xmsgRqstHandler = ((CFGCashXMsgRqstHandler) getParser()); xmsgRqstHandler.resetResponse(); xmsgRqstHandler.appendResponse(response); xmsgRqstHandler.setCaughtException(true); } }
From source file:net.sourceforge.msscodefactory.cfgcash.v2_0.CFGCashXMsgRqstHandler.CFGCashXMsgRqstISOCountryLanguageReadByCountryIdxHandler.java
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { try {// ww w. j ava 2s.c o m // Common XML Attributes String attrId = null; String attrISOCountryId = null; // Attribute Extraction String attrLocalName; int numAttrs; int idxAttr; final String S_ProcName = "startElement"; final String S_LocalName = "LocalName"; assert qName.equals("RqstISOCountryLanguageReadByCountryIdx"); CFGCashXMsgRqstHandler xmsgRqstHandler = (CFGCashXMsgRqstHandler) getParser(); if (xmsgRqstHandler == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "getParser()"); } ICFGCashSchemaObj schemaObj = xmsgRqstHandler.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("ISOCountryId")) { if (attrISOCountryId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrISOCountryId = 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$implRqstTableReadByHandlerCheckReqKeyAttrs$ // Save named attributes to context CFLibXmlCoreContext curContext = getParser().getCurContext(); // Convert string attributes to native Java types // and apply the converted attributes to the editBuff. short natISOCountryId; natISOCountryId = Short.parseShort(attrISOCountryId); // Read the objects SortedMap<CFGCashISOCountryLanguagePKey, ICFGCashISOCountryLanguageObj> map = schemaObj .getISOCountryLanguageTableObj().readISOCountryLanguageByCountryIdx(natISOCountryId); String responseOpening = CFGCashXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFGCashXMsgISOCountryLanguageMessageFormatter.formatISOCountryLanguageRspnListOpenTag(); xmsgRqstHandler.appendResponse(responseOpening); Iterator<ICFGCashISOCountryLanguageObj> iter = map.values().iterator(); ICFGCashISOCountryLanguageObj cur; String subxml; while (iter.hasNext()) { cur = iter.next(); subxml = CFGCashXMsgISOCountryLanguageMessageFormatter .formatISOCountryLanguageRspnDerivedRec("\n\t\t", cur.getISOCountryLanguageBuff()); xmsgRqstHandler.appendResponse(subxml); } String responseClosing = "\n" + "\t" + CFGCashXMsgISOCountryLanguageMessageFormatter.formatISOCountryLanguageRspnListCloseTag() + CFGCashXMsgSchemaMessageFormatter.formatRspnXmlPostamble(); xmsgRqstHandler.appendResponse(responseClosing); } catch (RuntimeException e) { String response = CFGCashXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFGCashXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n" + CFGCashXMsgSchemaMessageFormatter.formatRspnXmlPostamble(); CFGCashXMsgRqstHandler xmsgRqstHandler = ((CFGCashXMsgRqstHandler) getParser()); xmsgRqstHandler.resetResponse(); xmsgRqstHandler.appendResponse(response); xmsgRqstHandler.setCaughtException(true); } catch (Error e) { String response = CFGCashXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFGCashXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n" + CFGCashXMsgSchemaMessageFormatter.formatRspnXmlPostamble(); CFGCashXMsgRqstHandler xmsgRqstHandler = ((CFGCashXMsgRqstHandler) getParser()); xmsgRqstHandler.resetResponse(); xmsgRqstHandler.appendResponse(response); xmsgRqstHandler.setCaughtException(true); } }
From source file:net.sourceforge.msscodefactory.cfcrm.v2_1.CFCrmXMsgRqstHandler.CFCrmXMsgRqstURLProtocolDeleteHandler.java
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { try {// w ww . j a v a 2 s . c o m // Common XML Attributes String attrId = null; String attrRevision = null; // Primary Key Attributes for Constant Enum support String attrURLProtocolId = null; // Attribute Extraction String attrLocalName; int numAttrs; int idxAttr; final String S_ProcName = "startElement"; final String S_LocalName = "LocalName"; assert qName.equals("RqstURLProtocolDelete"); CFCrmXMsgRqstHandler xmsgRqstHandler = (CFCrmXMsgRqstHandler) getParser(); if (xmsgRqstHandler == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "getParser()"); } ICFCrmSchemaObj schemaObj = xmsgRqstHandler.getSchemaObj(); if (schemaObj == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "getParser().getSchemaObj()"); } // Instantiate a PKey buffer for the parsed information CFCrmURLProtocolPKey pkey = schemaObj.getBackingStore().getFactoryURLProtocol().newPKey(); // 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("URLProtocolId")) { if (attrURLProtocolId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrURLProtocolId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("schemaLocation")) { // ignored } else { throw CFLib.getDefaultExceptionFactory().newUnrecognizedAttributeException(getClass(), S_ProcName, getParser().getLocationInfo(), attrLocalName); } } // Ensure that required attributes have values if ((attrURLProtocolId == null) || (attrURLProtocolId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "URLProtocolId"); } if ((attrRevision == null) || (attrRevision.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "Revision"); } // Get current context CFLibXmlCoreContext curContext = getParser().getCurContext(); // Convert string attributes to native Java types // and apply the converted attributes to the editBuff. short natURLProtocolId; natURLProtocolId = Short.parseShort(attrURLProtocolId); pkey.setRequiredURLProtocolId(natURLProtocolId); pkey.setRequiredURLProtocolId(natURLProtocolId); int natRevision = Integer.parseInt(attrRevision); // Delete the object ICFCrmURLProtocolObj read = schemaObj.getURLProtocolTableObj().readURLProtocol(pkey); if (read != null) { if (read.getURLProtocolBuff().getRequiredRevision() > natRevision) { throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), S_ProcName, "Collision detected preparing to delete URLProtocol"); } else { ICFCrmURLProtocolEditObj editBuff = (ICFCrmURLProtocolEditObj) read.beginEdit(); if (editBuff != null) { editBuff.delete(); editBuff.endEdit(); String response = CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFCrmXMsgURLProtocolMessageFormatter.formatURLProtocolRspnDeleted() + "\n" + CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPostamble(); ((CFCrmXMsgRqstHandler) getParser()).appendResponse(response); } else { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "read.beginEdit()"); } } } else { String response = CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFCrmXMsgSchemaMessageFormatter.formatRspnNoDataFound() + "\n" + CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPostamble(); ((CFCrmXMsgRqstHandler) getParser()).appendResponse(response); } } catch (RuntimeException e) { String response = CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFCrmXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n" + CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPostamble(); CFCrmXMsgRqstHandler xmsgRqstHandler = ((CFCrmXMsgRqstHandler) getParser()); xmsgRqstHandler.resetResponse(); xmsgRqstHandler.appendResponse(response); xmsgRqstHandler.setCaughtException(true); } catch (Error e) { String response = CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFCrmXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n" + CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPostamble(); CFCrmXMsgRqstHandler xmsgRqstHandler = ((CFCrmXMsgRqstHandler) getParser()); xmsgRqstHandler.resetResponse(); xmsgRqstHandler.appendResponse(response); xmsgRqstHandler.setCaughtException(true); } }