List of usage examples for java.util SortedMap put
V put(K key, V value);
From source file:net.sourceforge.msscodefactory.cfensyntax.v2_0.CFEnSyntaxXMsgRspnHandler.CFEnSyntaxXMsgRspnEnTenseRecHandler.java
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { try {// w w w . ja v a2 s. c om // Common XML Attributes String attrId = null; String attrRevision = null; // EnglishParse Attributes String attrScopeId = null; String attrName = null; // EnTense Attributes // Attribute Extraction String attrLocalName; int numAttrs; int idxAttr; final String S_ProcName = "startElement"; final String S_LocalName = "LocalName"; assert qName.equals("EnTense"); CFEnSyntaxXMsgRspnHandler xmsgRspnHandler = (CFEnSyntaxXMsgRspnHandler) getParser(); if (xmsgRspnHandler == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "getParser()"); } ICFEnSyntaxSchemaObj 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("ScopeId")) { if (attrScopeId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrScopeId = 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("schemaLocation")) { // ignored } else { throw CFLib.getDefaultExceptionFactory().newUnrecognizedAttributeException(getClass(), S_ProcName, getParser().getLocationInfo(), attrLocalName); } } // Ensure that required attributes have values if ((attrId == null) || (attrId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "Id"); } if (attrName == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "Name"); } // Save named attributes to context CFLibXmlCoreContext curContext = xmsgRspnHandler.getCurContext(); // Convert string attributes to native Java types long natId = Long.parseLong(attrId); Long natScopeId; if ((attrScopeId == null) || (attrScopeId.length() <= 0)) { natScopeId = null; } else { natScopeId = new Long(Long.parseLong(attrScopeId)); } String natName = attrName; int natRevision = Integer.parseInt(attrRevision); // Get the parent context CFLibXmlCoreContext parentContext = curContext.getPrevContext(); // Instantiate a buffer for the parsed information ICFEnSyntaxEnTenseObj obj = schemaObj.getEnTenseTableObj().newInstance(); CFEnSyntaxEnTenseBuff dataBuff = obj.getEnTenseBuff(); dataBuff.setRequiredId(natId); dataBuff.setOptionalScopeId(natScopeId); dataBuff.setRequiredName(natName); dataBuff.setRequiredRevision(natRevision); obj.copyBuffToPKey(); SortedMap<CFEnSyntaxEnglishParsePKey, ICFEnSyntaxEnglishParseObj> sortedMap = (SortedMap<CFEnSyntaxEnglishParsePKey, ICFEnSyntaxEnglishParseObj>) xmsgRspnHandler .getSortedMapOfObjects(); ICFEnSyntaxEnTenseObj realized = (ICFEnSyntaxEnTenseObj) 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.CFGenKbXMsgRspnRuleCartRecHandler.java
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { try {//from w w w . ja va2 s . c om // Common XML Attributes String attrId = null; String attrRevision = null; // RuleCart Attributes String attrTenantId = null; String attrName = null; String attrDescr = null; String attrRevisionString = null; // Attribute Extraction String attrLocalName; int numAttrs; int idxAttr; final String S_ProcName = "startElement"; final String S_LocalName = "LocalName"; assert qName.equals("RuleCart"); 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("Name")) { if (attrName != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrName = attrs.getValue(idxAttr); } else if (attrLocalName.equals("Descr")) { if (attrDescr != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrDescr = attrs.getValue(idxAttr); } else if (attrLocalName.equals("RevisionString")) { if (attrRevisionString != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrRevisionString = 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 ((attrId == null) || (attrId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "Id"); } if (attrName == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "Name"); } // Save named attributes to context CFLibXmlCoreContext curContext = xmsgRspnHandler.getCurContext(); // Convert string attributes to native Java types long natTenantId = Long.parseLong(attrTenantId); long natId = Long.parseLong(attrId); String natName = attrName; String natDescr = attrDescr; String natRevisionString = attrRevisionString; int natRevision = Integer.parseInt(attrRevision); // Get the parent context CFLibXmlCoreContext parentContext = curContext.getPrevContext(); // Instantiate a buffer for the parsed information ICFGenKbRuleCartObj obj = schemaObj.getRuleCartTableObj().newInstance(); CFGenKbRuleCartBuff dataBuff = obj.getRuleCartBuff(); dataBuff.setRequiredTenantId(natTenantId); dataBuff.setRequiredId(natId); dataBuff.setRequiredName(natName); dataBuff.setOptionalDescr(natDescr); dataBuff.setOptionalRevisionString(natRevisionString); dataBuff.setRequiredRevision(natRevision); obj.copyBuffToPKey(); SortedMap<CFGenKbRuleCartPKey, ICFGenKbRuleCartObj> sortedMap = (SortedMap<CFGenKbRuleCartPKey, ICFGenKbRuleCartObj>) xmsgRspnHandler .getSortedMapOfObjects(); ICFGenKbRuleCartObj realized = (ICFGenKbRuleCartObj) 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.ripe.rpki.commons.crypto.rfc3779.ResourceExtensionParser.java
/** * IPAddressFamily ::= SEQUENCE { -- AFI & opt SAFI -- addressFamily OCTET * STRING (SIZE (2..3)), ipAddressChoice IPAddressChoice } */// w w w .jav a 2 s . c o m void derToIpAddressFamily(ASN1Encodable der, SortedMap<AddressFamily, IpResourceSet> map) { ASN1Sequence seq = expect(der, ASN1Sequence.class); Validate.isTrue(seq.size() == 2, "IpAddressFamily must have exactly two entries: addressFamily and IpAddressChoice"); AddressFamily addressFamily = AddressFamily.fromDer(seq.getObjectAt(0)); IpResourceSet resources = derToIpAddressChoice(addressFamily.toIpResourceType(), seq.getObjectAt(1)); map.put(addressFamily, resources); }
From source file:eu.ggnet.dwoss.misc.op.listings.SalesListingProducerOperation.java
private SortedMap<UniqueUnit, StockUnit> toSortedMap(List<UniqueUnit> uniqueUnits, List<StockUnit> stockUnits, Comparator<UniqueUnit> comparator) { Map<Integer, UniqueUnit> uuIdMs = new HashMap<>(uniqueUnits.size()); for (UniqueUnit uniqueUnit : uniqueUnits) { uuIdMs.put(uniqueUnit.getId(), uniqueUnit); }//from w w w.jav a 2 s. c o m SortedMap<UniqueUnit, StockUnit> uusu = new TreeMap<>(comparator); for (StockUnit stockUnit : stockUnits) { uusu.put(uuIdMs.get(stockUnit.getUniqueUnitId()), stockUnit); } return uusu; }
From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccXMsgRspnHandler.CFAccXMsgRspnClusterRecHandler.java
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { try {/*from www . j av a 2 s . c o m*/ // Common XML Attributes String attrId = null; String attrRevision = null; // Cluster Attributes String attrFullDomainName = null; String attrCreatedAt = null; String attrCreatedBy = null; String attrUpdatedAt = null; String attrUpdatedBy = null; // Attribute Extraction String attrLocalName; int numAttrs; int idxAttr; final String S_ProcName = "startElement"; final String S_LocalName = "LocalName"; assert qName.equals("Cluster"); CFAccXMsgRspnHandler xmsgRspnHandler = (CFAccXMsgRspnHandler) getParser(); if (xmsgRspnHandler == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "getParser()"); } ICFAccSchemaObj schemaObj = xmsgRspnHandler.getSchemaObj(); if (schemaObj == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "getParser().getSchemaObj()"); } // Extract Attributes numAttrs = attrs.getLength(); for (idxAttr = 0; idxAttr < numAttrs; idxAttr++) { attrLocalName = attrs.getLocalName(idxAttr); if (attrLocalName.equals("Id")) { if (attrId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("Revision")) { if (attrRevision != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrRevision = attrs.getValue(idxAttr); } else if (attrLocalName.equals("CreatedAt")) { if (attrCreatedAt != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrCreatedAt = attrs.getValue(idxAttr); } else if (attrLocalName.equals("CreatedBy")) { if (attrCreatedBy != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrCreatedBy = attrs.getValue(idxAttr); } else if (attrLocalName.equals("UpdatedAt")) { if (attrUpdatedAt != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrUpdatedAt = attrs.getValue(idxAttr); } else if (attrLocalName.equals("UpdatedBy")) { if (attrUpdatedBy != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrUpdatedBy = attrs.getValue(idxAttr); } else if (attrLocalName.equals("FullDomainName")) { if (attrFullDomainName != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrFullDomainName = 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 ((attrId == null) || (attrId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "Id"); } if (attrFullDomainName == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "FullDomainName"); } // Save named attributes to context CFLibXmlCoreContext curContext = xmsgRspnHandler.getCurContext(); // Convert string attributes to native Java types long natId = Long.parseLong(attrId); String natFullDomainName = attrFullDomainName; int natRevision = Integer.parseInt(attrRevision); UUID createdBy = null; if (attrCreatedBy != null) { createdBy = UUID.fromString(attrCreatedBy); } Calendar createdAt = null; if (attrCreatedAt != null) { createdAt = CFLibXmlUtil.parseTimestamp(attrCreatedAt); } UUID updatedBy = null; if (attrUpdatedBy != null) { updatedBy = UUID.fromString(attrUpdatedBy); } Calendar updatedAt = null; if (attrUpdatedAt != null) { updatedAt = CFLibXmlUtil.parseTimestamp(attrUpdatedAt); } // Get the parent context CFLibXmlCoreContext parentContext = curContext.getPrevContext(); // Instantiate a buffer for the parsed information ICFAccClusterObj obj = schemaObj.getClusterTableObj().newInstance(); CFAccClusterBuff dataBuff = obj.getClusterBuff(); dataBuff.setRequiredId(natId); dataBuff.setRequiredFullDomainName(natFullDomainName); dataBuff.setRequiredRevision(natRevision); if (createdBy != null) { dataBuff.setCreatedByUserId(createdBy); } if (createdAt != null) { dataBuff.setCreatedAt(createdAt); } if (updatedBy != null) { dataBuff.setUpdatedByUserId(updatedBy); } if (updatedAt != null) { dataBuff.setUpdatedAt(updatedAt); } obj.copyBuffToPKey(); SortedMap<CFAccClusterPKey, ICFAccClusterObj> sortedMap = (SortedMap<CFAccClusterPKey, ICFAccClusterObj>) xmsgRspnHandler .getSortedMapOfObjects(); ICFAccClusterObj realized = (ICFAccClusterObj) 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.cfasterisk.v2_0.CFAstXMsgRspnHandler.CFAstXMsgRspnClusterRecHandler.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; // Cluster Attributes String attrFullDomainName = null; String attrCreatedAt = null; String attrCreatedBy = null; String attrUpdatedAt = null; String attrUpdatedBy = null; // Attribute Extraction String attrLocalName; int numAttrs; int idxAttr; final String S_ProcName = "startElement"; final String S_LocalName = "LocalName"; assert qName.equals("Cluster"); CFAstXMsgRspnHandler xmsgRspnHandler = (CFAstXMsgRspnHandler) getParser(); if (xmsgRspnHandler == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "getParser()"); } ICFAstSchemaObj schemaObj = xmsgRspnHandler.getSchemaObj(); if (schemaObj == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "getParser().getSchemaObj()"); } // Extract Attributes numAttrs = attrs.getLength(); for (idxAttr = 0; idxAttr < numAttrs; idxAttr++) { attrLocalName = attrs.getLocalName(idxAttr); if (attrLocalName.equals("Id")) { if (attrId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("Revision")) { if (attrRevision != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrRevision = attrs.getValue(idxAttr); } else if (attrLocalName.equals("CreatedAt")) { if (attrCreatedAt != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrCreatedAt = attrs.getValue(idxAttr); } else if (attrLocalName.equals("CreatedBy")) { if (attrCreatedBy != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrCreatedBy = attrs.getValue(idxAttr); } else if (attrLocalName.equals("UpdatedAt")) { if (attrUpdatedAt != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrUpdatedAt = attrs.getValue(idxAttr); } else if (attrLocalName.equals("UpdatedBy")) { if (attrUpdatedBy != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrUpdatedBy = attrs.getValue(idxAttr); } else if (attrLocalName.equals("FullDomainName")) { if (attrFullDomainName != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrFullDomainName = 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 ((attrId == null) || (attrId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "Id"); } if (attrFullDomainName == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "FullDomainName"); } // Save named attributes to context CFLibXmlCoreContext curContext = xmsgRspnHandler.getCurContext(); // Convert string attributes to native Java types long natId = Long.parseLong(attrId); String natFullDomainName = attrFullDomainName; int natRevision = Integer.parseInt(attrRevision); UUID createdBy = null; if (attrCreatedBy != null) { createdBy = UUID.fromString(attrCreatedBy); } Calendar createdAt = null; if (attrCreatedAt != null) { createdAt = CFLibXmlUtil.parseTimestamp(attrCreatedAt); } UUID updatedBy = null; if (attrUpdatedBy != null) { updatedBy = UUID.fromString(attrUpdatedBy); } Calendar updatedAt = null; if (attrUpdatedAt != null) { updatedAt = CFLibXmlUtil.parseTimestamp(attrUpdatedAt); } // Get the parent context CFLibXmlCoreContext parentContext = curContext.getPrevContext(); // Instantiate a buffer for the parsed information ICFAstClusterObj obj = schemaObj.getClusterTableObj().newInstance(); CFAstClusterBuff dataBuff = obj.getClusterBuff(); dataBuff.setRequiredId(natId); dataBuff.setRequiredFullDomainName(natFullDomainName); dataBuff.setRequiredRevision(natRevision); if (createdBy != null) { dataBuff.setCreatedByUserId(createdBy); } if (createdAt != null) { dataBuff.setCreatedAt(createdAt); } if (updatedBy != null) { dataBuff.setUpdatedByUserId(updatedBy); } if (updatedAt != null) { dataBuff.setUpdatedAt(updatedAt); } obj.copyBuffToPKey(); SortedMap<CFAstClusterPKey, ICFAstClusterObj> sortedMap = (SortedMap<CFAstClusterPKey, ICFAstClusterObj>) xmsgRspnHandler .getSortedMapOfObjects(); ICFAstClusterObj realized = (ICFAstClusterObj) 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.cfacc.v2_0.CFAccXMsgRspnHandler.CFAccXMsgRspnSecSessionRecHandler.java
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { try {/* w ww.j a v a 2 s .com*/ // Common XML Attributes String attrId = null; String attrRevision = null; // SecSession Attributes String attrSecSessionId = null; String attrSecUserId = null; String attrStart = null; String attrFinish = null; // Attribute Extraction String attrLocalName; int numAttrs; int idxAttr; final String S_ProcName = "startElement"; final String S_LocalName = "LocalName"; assert qName.equals("SecSession"); CFAccXMsgRspnHandler xmsgRspnHandler = (CFAccXMsgRspnHandler) getParser(); if (xmsgRspnHandler == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "getParser()"); } ICFAccSchemaObj 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("SecSessionId")) { if (attrSecSessionId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrSecSessionId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("SecUserId")) { if (attrSecUserId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrSecUserId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("Start")) { if (attrStart != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrStart = attrs.getValue(idxAttr); } else if (attrLocalName.equals("Finish")) { if (attrFinish != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrFinish = 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 ((attrSecSessionId == null) || (attrSecSessionId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "SecSessionId"); } if ((attrSecUserId == null) || (attrSecUserId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "SecUserId"); } if ((attrStart == null) || (attrStart.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "Start"); } // Save named attributes to context CFLibXmlCoreContext curContext = xmsgRspnHandler.getCurContext(); // Convert string attributes to native Java types UUID natSecSessionId = UUID.fromString(attrSecSessionId); UUID natSecUserId = UUID.fromString(attrSecUserId); Calendar natStart; try { natStart = CFLibXmlUtil.parseTimestamp(attrStart); } catch (RuntimeException e) { throw CFLib.getDefaultExceptionFactory().newInvalidArgumentException(getClass(), S_ProcName, 0, "Start", attrStart, e); } Calendar natFinish; if ((attrFinish == null) || (attrFinish.length() <= 0)) { natFinish = null; } else { try { natFinish = CFLibXmlUtil.parseTimestamp(attrFinish); } catch (RuntimeException e) { throw CFLib.getDefaultExceptionFactory().newInvalidArgumentException(getClass(), S_ProcName, 0, "Finish", attrFinish, e); } } int natRevision = Integer.parseInt(attrRevision); // Get the parent context CFLibXmlCoreContext parentContext = curContext.getPrevContext(); // Instantiate a buffer for the parsed information ICFAccSecSessionObj obj = schemaObj.getSecSessionTableObj().newInstance(); CFAccSecSessionBuff dataBuff = obj.getSecSessionBuff(); dataBuff.setRequiredSecSessionId(natSecSessionId); dataBuff.setRequiredSecUserId(natSecUserId); dataBuff.setRequiredStart(natStart); dataBuff.setOptionalFinish(natFinish); dataBuff.setRequiredRevision(natRevision); obj.copyBuffToPKey(); SortedMap<CFAccSecSessionPKey, ICFAccSecSessionObj> sortedMap = (SortedMap<CFAccSecSessionPKey, ICFAccSecSessionObj>) xmsgRspnHandler .getSortedMapOfObjects(); ICFAccSecSessionObj realized = (ICFAccSecSessionObj) 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.cfasterisk.v2_0.CFAstXMsgRspnHandler.CFAstXMsgRspnSecSessionRecHandler.java
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { try {/*w ww .ja v a 2 s . c o m*/ // Common XML Attributes String attrId = null; String attrRevision = null; // SecSession Attributes String attrSecSessionId = null; String attrSecUserId = null; String attrStart = null; String attrFinish = null; // Attribute Extraction String attrLocalName; int numAttrs; int idxAttr; final String S_ProcName = "startElement"; final String S_LocalName = "LocalName"; assert qName.equals("SecSession"); CFAstXMsgRspnHandler xmsgRspnHandler = (CFAstXMsgRspnHandler) getParser(); if (xmsgRspnHandler == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "getParser()"); } ICFAstSchemaObj 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("SecSessionId")) { if (attrSecSessionId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrSecSessionId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("SecUserId")) { if (attrSecUserId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrSecUserId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("Start")) { if (attrStart != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrStart = attrs.getValue(idxAttr); } else if (attrLocalName.equals("Finish")) { if (attrFinish != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrFinish = 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 ((attrSecSessionId == null) || (attrSecSessionId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "SecSessionId"); } if ((attrSecUserId == null) || (attrSecUserId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "SecUserId"); } if ((attrStart == null) || (attrStart.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "Start"); } // Save named attributes to context CFLibXmlCoreContext curContext = xmsgRspnHandler.getCurContext(); // Convert string attributes to native Java types UUID natSecSessionId = UUID.fromString(attrSecSessionId); UUID natSecUserId = UUID.fromString(attrSecUserId); Calendar natStart; try { natStart = CFLibXmlUtil.parseTimestamp(attrStart); } catch (RuntimeException e) { throw CFLib.getDefaultExceptionFactory().newInvalidArgumentException(getClass(), S_ProcName, 0, "Start", attrStart, e); } Calendar natFinish; if ((attrFinish == null) || (attrFinish.length() <= 0)) { natFinish = null; } else { try { natFinish = CFLibXmlUtil.parseTimestamp(attrFinish); } catch (RuntimeException e) { throw CFLib.getDefaultExceptionFactory().newInvalidArgumentException(getClass(), S_ProcName, 0, "Finish", attrFinish, e); } } int natRevision = Integer.parseInt(attrRevision); // Get the parent context CFLibXmlCoreContext parentContext = curContext.getPrevContext(); // Instantiate a buffer for the parsed information ICFAstSecSessionObj obj = schemaObj.getSecSessionTableObj().newInstance(); CFAstSecSessionBuff dataBuff = obj.getSecSessionBuff(); dataBuff.setRequiredSecSessionId(natSecSessionId); dataBuff.setRequiredSecUserId(natSecUserId); dataBuff.setRequiredStart(natStart); dataBuff.setOptionalFinish(natFinish); dataBuff.setRequiredRevision(natRevision); obj.copyBuffToPKey(); SortedMap<CFAstSecSessionPKey, ICFAstSecSessionObj> sortedMap = (SortedMap<CFAstSecSessionPKey, ICFAstSecSessionObj>) xmsgRspnHandler .getSortedMapOfObjects(); ICFAstSecSessionObj realized = (ICFAstSecSessionObj) 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.cafbit.netlib.dns.DNSMessage.java
public String toString() { StringBuilder sb = new StringBuilder(); // questions//w w w . ja v a2s. co m for (DNSQuestion q : questions) { sb.append("\nQuestion: " + q.toString() + "\n"); } // group answers by name SortedMap<String, List<DNSAnswer>> answersByName = new TreeMap<String, List<DNSAnswer>>(); for (DNSAnswer a : answers) { List<DNSAnswer> list; if (answersByName.containsKey(a.name)) { list = answersByName.get(a.name); } else { list = new LinkedList<DNSAnswer>(); answersByName.put(a.name, list); } list.add(a); } for (DNSAnswer a : authorities) { List<DNSAnswer> list; if (answersByName.containsKey(a.name)) { list = answersByName.get(a.name); } else { list = new LinkedList<DNSAnswer>(); answersByName.put(a.name, list); } list.add(a); } for (DNSAnswer a : addrecords) { List<DNSAnswer> list; if (answersByName.containsKey(a.name)) { list = answersByName.get(a.name); } else { list = new LinkedList<DNSAnswer>(); answersByName.put(a.name, list); } list.add(a); } for (Map.Entry<String, List<DNSAnswer>> entry : answersByName.entrySet()) { sb.append(entry.getKey() + "\n"); for (DNSAnswer a : entry.getValue()) { sb.append(" " + a.type.toString() + " " + a.getRdataString() + "\n"); } } return sb.toString(); }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAstXMsgRspnHandler.CFAstXMsgRspnConfigurationFileRecHandler.java
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { try {//from w w w.j av a 2 s.c om // Common XML Attributes String attrId = null; String attrRevision = null; // ConfigurationFile Attributes String attrClusterId = null; String attrHostNodeId = null; String attrFileFullName = null; // Attribute Extraction String attrLocalName; int numAttrs; int idxAttr; final String S_ProcName = "startElement"; final String S_LocalName = "LocalName"; assert qName.equals("ConfigurationFile"); CFAstXMsgRspnHandler xmsgRspnHandler = (CFAstXMsgRspnHandler) getParser(); if (xmsgRspnHandler == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "getParser()"); } ICFAstSchemaObj 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("ClusterId")) { if (attrClusterId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrClusterId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("HostNodeId")) { if (attrHostNodeId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrHostNodeId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("FileFullName")) { if (attrFileFullName != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrFileFullName = 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 ((attrClusterId == null) || (attrClusterId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "ClusterId"); } if ((attrId == null) || (attrId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "Id"); } if ((attrHostNodeId == null) || (attrHostNodeId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "HostNodeId"); } if (attrFileFullName == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "FileFullName"); } // Save named attributes to context CFLibXmlCoreContext curContext = xmsgRspnHandler.getCurContext(); // Convert string attributes to native Java types long natClusterId = Long.parseLong(attrClusterId); long natId = Long.parseLong(attrId); long natHostNodeId = Long.parseLong(attrHostNodeId); String natFileFullName = attrFileFullName; int natRevision = Integer.parseInt(attrRevision); // Get the parent context CFLibXmlCoreContext parentContext = curContext.getPrevContext(); // Instantiate a buffer for the parsed information ICFAstConfigurationFileObj obj = schemaObj.getConfigurationFileTableObj().newInstance(); CFAstConfigurationFileBuff dataBuff = obj.getConfigurationFileBuff(); dataBuff.setRequiredClusterId(natClusterId); dataBuff.setRequiredId(natId); dataBuff.setRequiredHostNodeId(natHostNodeId); dataBuff.setRequiredFileFullName(natFileFullName); dataBuff.setRequiredRevision(natRevision); obj.copyBuffToPKey(); SortedMap<CFAstConfigurationFilePKey, ICFAstConfigurationFileObj> sortedMap = (SortedMap<CFAstConfigurationFilePKey, ICFAstConfigurationFileObj>) xmsgRspnHandler .getSortedMapOfObjects(); ICFAstConfigurationFileObj realized = (ICFAstConfigurationFileObj) 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); } }