src/main/java/com/billybyte/marketdata/YqlOptionPdiQuery.java
public Map<String, YqlInfo> parseIt(Set<String> keySet) {
	    Map<String, YqlInfo> ret = new HashMap<String, YqlOptionPdiQuery.YqlInfo>();
		try {
			Set<String> productSet = new TreeSet<String>();
			for(String key:keySet){
				productSet.add(key.split("\\.")[0]);
			}
			ShortNameProcessor snp = new ShortNameProcessor(".", productSet);
			// break up into 50's if necessary
			List<String> nameList = new ArrayList<String>(keySet);
//			String stockSymbolListCommaSep = "";
			for(int k = 0;k<keySet.size();k+=MAX_GETS_BEFORE_WAIT){
				for(int j = 0;j<MAX_GETS_BEFORE_WAIT;j++){
					int index = k + j;
					if(index>=nameList.size()) break;
					ShortNameInfo sni = snp.getShortNameInfo(nameList.get(index));
					String stockName = sni.getSymbol();
					int contractYear = sni.getContractYear();
					int contractMonth = sni.getContractMonth();
					String porc = sni.getRight();
					if(porc==null){
						continue;
					}
					
					BigDecimal optionStrike = sni.getStrike();
					if(optionStrike==null){
						continue;
					}
					
					optionStrike = optionStrike.multiply(strikeMultiplier).setScale(0);
					String url = specificOption.replace(STOCK_NAME, stockName);
					url = url.replace(CONTRACT_YEAR, new Integer(contractYear).toString());
					url = url.replace(CONTRACT_MONTH, monthFormat.format(new Integer(contractMonth)));
					url = url.replace(PORC, porc);
					String yqlUrlToFetch = url.replace(OPTION_STRIKE, optionStrike.toString());
							
					DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
					DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
					Document doc = dBuilder.parse(Utils.getInputStreamFromHttpFtp(yqlUrlToFetch));
					doc.getDocumentElement().normalize();
				 
				    // Get the document's root XML node
				    NodeList root = doc.getChildNodes();
				 
				    // Navigate down the hierarchy to get to the CEO node
				    Node query = getNode("query", root);
				    Node results = getNode("results", query.getChildNodes() );
				    Node optionsChain = getNode("optionsChain", results.getChildNodes() );
				    NodeList nodes = optionsChain.getChildNodes();
				    
				    for(int i = 0;i<nodes.getLength();i++){
				    	Node quote = nodes.item(i);
					    String bid = getNodeValue("bid", quote.getChildNodes());
					    String ask = getNodeValue("ask", quote.getChildNodes());
					    String last = getNodeValue("lastPrice", quote.getChildNodes());
					    String change = getNodeValue("change", quote.getChildNodes());
					    BigDecimal bdLast = new BigDecimal(last);
					    BigDecimal bdChange = new BigDecimal(change);
					    
					    String close = bdLast.subtract(bdChange).toString();
					    String symbol = getNodeValue("Symbol", quote.getChildNodes());
				    	YqlInfo info = new YqlInfo(symbol, bid, ask, last, close);
				    	ret.put(sni.getShortName(), info);
				    }
					
				    Thread.sleep(SLEEP_TIME_BETWEEN_YQL_QUERIES);
					
				}
			}
		}
		catch ( Exception e ) {
		    e.printStackTrace();
		}
	    return ret;
	}
/**
	 * Main parsing of xml using DocumentBuilderFactory
	 * @param keySet
	 * @return
	 */
Main parsing of xml using DocumentBuilderFactory
@param keySet
@return
Main parsing of xml using DocumentBuilderFactory @param keySet @return
public Map<String, YqlInfo> parseIt(Set<String> keySet) {
	    Map<String, YqlInfo> ret = new HashMap<String, YqlOptionPdiQuery.YqlInfo>();
		try {
			Set<String> productSet = new TreeSet<String>();
			for(String key:keySet){
				productSet.add(key.split("\\.")[0]);
			}
			ShortNameProcessor snp = new ShortNameProcessor(".", productSet);
			List<String> nameList = new ArrayList<String>(keySet);
			for(int k = 0;k<keySet.size();k+=MAX_GETS_BEFORE_WAIT){
				for(int j = 0;j<MAX_GETS_BEFORE_WAIT;j++){
					int index = k + j;
					if(index>=nameList.size()) break;
					ShortNameInfo sni = snp.getShortNameInfo(nameList.get(index));
					String stockName = sni.getSymbol();
					int contractYear = sni.getContractYear();
					int contractMonth = sni.getContractMonth();
					String porc = sni.getRight();
					if(porc==null){
						continue;
					}
					BigDecimal optionStrike = sni.getStrike();
					if(optionStrike==null){
						continue;
					}
					optionStrike = optionStrike.multiply(strikeMultiplier).setScale(0);
					String url = specificOption.replace(STOCK_NAME, stockName);
					url = url.replace(CONTRACT_YEAR, new Integer(contractYear).toString());
					url = url.replace(CONTRACT_MONTH, monthFormat.format(new Integer(contractMonth)));
					url = url.replace(PORC, porc);
					String yqlUrlToFetch = url.replace(OPTION_STRIKE, optionStrike.toString());
					DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
					DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
					Document doc = dBuilder.parse(Utils.getInputStreamFromHttpFtp(yqlUrlToFetch));
					doc.getDocumentElement().normalize();
				    NodeList root = doc.getChildNodes();
				    Node query = getNode("query", root);
				    Node results = getNode("results", query.getChildNodes() );
				    Node optionsChain = getNode("optionsChain", results.getChildNodes() );
				    NodeList nodes = optionsChain.getChildNodes();
				    for(int i = 0;i<nodes.getLength();i++){
				    	Node quote = nodes.item(i);
					    String bid = getNodeValue("bid", quote.getChildNodes());
					    String ask = getNodeValue("ask", quote.getChildNodes());
					    String last = getNodeValue("lastPrice", quote.getChildNodes());
					    String change = getNodeValue("change", quote.getChildNodes());
					    BigDecimal bdLast = new BigDecimal(last);
					    BigDecimal bdChange = new BigDecimal(change);
					    String close = bdLast.subtract(bdChange).toString();
					    String symbol = getNodeValue("Symbol", quote.getChildNodes());
				    	YqlInfo info = new YqlInfo(symbol, bid, ask, last, close);
				    	ret.put(sni.getShortName(), info);
				    }
				    Thread.sleep(SLEEP_TIME_BETWEEN_YQL_QUERIES);
				}
			}
		}
		catch ( Exception e ) {
		    e.printStackTrace();
		}
	    return ret;
	}
public Map < String , YqlInfo > parseIt ( Set < String > keySet ) { Map < String , YqlInfo > ret = new HashMap < String , YqlOptionPdiQuery . YqlInfo > ( ) ; try { Set < String > productSet = new TreeSet < String > ( ) ; for ( String key : keySet ) { productSet . add ( key . split ( "\\." ) [ 0 ] ) ; } ShortNameProcessor snp = new ShortNameProcessor ( "." , productSet ) ; List < String > nameList = new ArrayList < String > ( keySet ) ; for ( int k = 0 ; k < keySet . size ( ) ; k += MAX_GETS_BEFORE_WAIT ) { for ( int j = 0 ; j < MAX_GETS_BEFORE_WAIT ; j ++ ) { int index = k + j ; if ( index >= nameList . size ( ) ) break ; ShortNameInfo sni = snp . getShortNameInfo ( nameList . get ( index ) ) ; String stockName = sni . getSymbol ( ) ; int contractYear = sni . getContractYear ( ) ; int contractMonth = sni . getContractMonth ( ) ; String porc = sni . getRight ( ) ; if ( porc == null ) { continue ; } BigDecimal optionStrike = sni . getStrike ( ) ; if ( optionStrike == null ) { continue ; } optionStrike = optionStrike . multiply ( strikeMultiplier ) . setScale ( 0 ) ; String url = specificOption . replace ( STOCK_NAME , stockName ) ; url = url . replace ( CONTRACT_YEAR , new Integer ( contractYear ) . toString ( ) ) ; url = url . replace ( CONTRACT_MONTH , monthFormat . format ( new Integer ( contractMonth ) ) ) ; url = url . replace ( PORC , porc ) ; String yqlUrlToFetch = url . replace ( OPTION_STRIKE , optionStrike . toString ( ) ) ; DocumentBuilderFactory dbFactory = DocumentBuilderFactory . newInstance ( ) ; DocumentBuilder dBuilder = dbFactory . newDocumentBuilder ( ) ; Document doc = dBuilder . parse ( Utils . getInputStreamFromHttpFtp ( yqlUrlToFetch ) ) ; doc . getDocumentElement ( ) . normalize ( ) ; NodeList root = doc . getChildNodes ( ) ; Node query = getNode ( "query" , root ) ; Node results = getNode ( "results" , query . getChildNodes ( ) ) ; Node optionsChain = getNode ( "optionsChain" , results . getChildNodes ( ) ) ; NodeList nodes = optionsChain . getChildNodes ( ) ; for ( int i = 0 ; i < nodes . getLength ( ) ; i ++ ) { Node quote = nodes . item ( i ) ; String bid = getNodeValue ( "bid" , quote . getChildNodes ( ) ) ; String ask = getNodeValue ( "ask" , quote . getChildNodes ( ) ) ; String last = getNodeValue ( "lastPrice" , quote . getChildNodes ( ) ) ; String change = getNodeValue ( "change" , quote . getChildNodes ( ) ) ; BigDecimal bdLast = new BigDecimal ( last ) ; BigDecimal bdChange = new BigDecimal ( change ) ; String close = bdLast . subtract ( bdChange ) . toString ( ) ; String symbol = getNodeValue ( "Symbol" , quote . getChildNodes ( ) ) ; YqlInfo info = new YqlInfo ( symbol , bid , ask , last , close ) ; ret . put ( sni . getShortName ( ) , info ) ; } Thread . sleep ( SLEEP_TIME_BETWEEN_YQL_QUERIES ) ; } } } catch ( Exception e ) { e . printStackTrace ( ) ; } return ret ; }
Main parsing of xml using DocumentBuilderFactory
 @param keySet
 @return
Main parsing of xml using DocumentBuilderFactory @param keySet @return
// break up into 50's if necessary //			String stockSymbolListCommaSep = ""; // Get the document's root XML node // Navigate down the hierarchy to get to the CEO node