1 23 24 package org.objectweb.cjdbc.controller.loadbalancer; 25 26 import java.util.HashMap ; 27 import java.util.Iterator ; 28 29 import org.objectweb.cjdbc.common.xml.DatabasesXmlTags; 30 31 38 public abstract class WeightedBalancer 39 { 40 46 public static final String getWeightedXml(HashMap weights) 47 { 48 if (weights == null) 49 return ""; 50 StringBuffer info = new StringBuffer (); 51 String nametmp; 52 for (Iterator iterator = weights.keySet().iterator(); iterator.hasNext();) 53 { 54 nametmp = (String ) iterator.next(); 55 info 56 .append("<" + DatabasesXmlTags.ELT_BackendWeight + " " 57 + DatabasesXmlTags.ATT_name + "=\"" + nametmp + "\" " 58 + DatabasesXmlTags.ATT_weight + "=\"" + weights.get(nametmp) 59 + "\"/>"); 60 } 61 return info.toString(); 62 } 63 64 71 public static final String getRaidbXml(HashMap weights, String xmltag) 72 { 73 StringBuffer info = new StringBuffer (); 74 info.append("<" + xmltag + ">"); 75 info.append(WeightedBalancer.getWeightedXml(weights)); 76 info.append("</" + xmltag + ">"); 77 return info.toString(); 78 } 79 } | Popular Tags |