Example usage for java.lang Integer decode

List of usage examples for java.lang Integer decode

Introduction

In this page you can find the example usage for java.lang Integer decode.

Prototype

public static Integer decode(String nm) throws NumberFormatException 

Source Link

Document

Decodes a String into an Integer .

Usage

From source file:com.gewara.util.XSSFilter.java

protected String decodeEntities(String s) {
    StringBuffer buf = new StringBuffer();

    Pattern p = Pattern.compile("&#(\\d+);?");
    Matcher m = p.matcher(s);//from   ww  w .  ja  va 2  s . c  o m
    while (m.find()) {
        String match = m.group(1);
        int decimal = Integer.decode(match).intValue();
        m.appendReplacement(buf, chr(decimal));
    }
    m.appendTail(buf);
    s = buf.toString();

    buf = new StringBuffer();
    p = Pattern.compile("&#x([0-9a-f]+);?");
    m = p.matcher(s);
    while (m.find()) {
        String match = m.group(1);
        int decimal = Integer.decode(match).intValue();
        m.appendReplacement(buf, chr(decimal));
    }
    m.appendTail(buf);
    s = buf.toString();

    buf = new StringBuffer();
    p = Pattern.compile("%([0-9a-f]{2});?");
    m = p.matcher(s);
    while (m.find()) {
        String match = m.group(1);
        int decimal = Integer.decode(match).intValue();
        m.appendReplacement(buf, chr(decimal));
    }
    m.appendTail(buf);
    s = buf.toString();

    s = validateEntities(s);
    return s;
}

From source file:it.eng.spagobi.engines.chart.bo.charttypes.barcharts.StackedBarGroup.java

public void configureChart(SourceBean content) {
    logger.debug("IN");
    super.configureChart(content);

    if (confParameters.get(ORIENTATION) != null) {
        String orientation = (String) confParameters.get(ORIENTATION);
        if (orientation.equalsIgnoreCase("vertical")) {
            horizontalViewConfigured = true;
            horizontalView = false;/*from  w  w w . j  a v a 2s  .c o  m*/
        } else if (orientation.equalsIgnoreCase("horizontal")) {
            horizontalViewConfigured = true;
            horizontalView = true;
        }
    }

    if (confParameters.get(SUBCATEGORY_LABEL) != null) {
        subCategoryLabel = (String) confParameters.get(SUBCATEGORY_LABEL);
    } else {
        subCategoryLabel = "";
    }

    if (confParameters.get(ADD_LABELS) != null) {
        String additional = (String) confParameters.get(ADD_LABELS);
        if (additional.equalsIgnoreCase("true")) {
            additionalLabels = true;
            catSerLabels = new LinkedHashMap();
        } else
            additionalLabels = false;
    } else {
        additionalLabels = false;
    }

    if (confParameters.get("percentage_value") != null) {
        String perc = (String) confParameters.get("percentage_value");
        if (perc.equalsIgnoreCase("true")) {
            percentageValue = true;
        } else
            percentageValue = false;
    } else {
        percentageValue = false;
    }

    if (confParameters.get("n_serie_for_group") != null) {
        numSerieForGroup = Integer.valueOf((String) confParameters.get("n_serie_for_group"));
    } else {
        numSerieForGroup = new Integer("1");
    }

    if (confParameters.get("n_groups") != null) {
        numGroups = Integer.valueOf((String) confParameters.get("n_groups"));
    } else {
        numGroups = new Integer("1");
    }

    /*
    SourceBean drillSB = (SourceBean)content.getAttribute("CONF.DRILL");
    if(drillSB!=null){
       String lab=(String)drillSB.getAttribute("document");
       if(lab!=null) drillLabel=lab;
       else{
    logger.error("Drill label not found");
       }
            
       List parameters =drillSB.getAttributeAsList("PARAM");
       if(parameters!=null){
    drillParameter=new HashMap();   
            
    for (Iterator iterator = parameters.iterator(); iterator.hasNext();) {
       SourceBean att = (SourceBean) iterator.next();
       String name=(String)att.getAttribute("name");
       String type=(String)att.getAttribute("type");
       String value=(String)att.getAttribute("value");
            
       if(type!=null && type.equalsIgnoreCase("RELATIVE")){ // Case relative
          if(value.equalsIgnoreCase("serie"))serieUrlname=name;
          if(value.equalsIgnoreCase("category"))categoryUrlName=name;
       }
       else{                                    // Case absolute
          drillParameter.put(name, value);
       }
    }
       }
    }
     */

    //reading series colors if present
    SourceBean colors = (SourceBean) content.getAttribute("SERIES_COLORS");
    if (colors == null) {
        colors = (SourceBean) content.getAttribute("CONF.SERIES_COLORS");
    }
    if (colors != null) {
        colorMap = new LinkedHashMap();
        List atts = colors.getContainedAttributes();
        String colorSerie = "";
        for (Iterator iterator = atts.iterator(); iterator.hasNext();) {
            SourceBeanAttribute object = (SourceBeanAttribute) iterator.next();

            String serieName = new String(object.getKey());
            colorSerie = new String((String) object.getValue());
            Color col = new Color(Integer.decode(colorSerie).intValue());
            if (col != null) {
                colorMap.put(serieName, col);
            }
        }
    }
    //reading gradient colors if present
    SourceBean gradients = (SourceBean) content.getAttribute("GRADIENTS_COLORS");
    if (gradients == null) {
        gradients = (SourceBean) content.getAttribute("CONF.GRADIENTS_COLORS");
    }
    if (gradients != null) {
        gradientMap = new LinkedHashMap();
        List atts = gradients.getContainedAttributes();
        String gradientSerie = "";
        for (Iterator iterator = atts.iterator(); iterator.hasNext();) {
            SourceBeanAttribute object = (SourceBeanAttribute) iterator.next();

            String serieName = new String(object.getKey());
            gradientSerie = new String((String) object.getValue());
            Color col = new Color(Integer.decode(gradientSerie).intValue());
            if (col != null) {
                gradientMap.put(serieName, col);
            }
        }
    }
    //reading subcategories labels
    SourceBean subcatLabels = (SourceBean) content.getAttribute("SUBCATEGORY_LABELS");
    if (subcatLabels == null) {
        subcatLabels = (SourceBean) content.getAttribute("CONF.SUBCATEGORY_LABELS");
    }
    if (subcatLabels != null) {
        subCatLabelsMap = new LinkedHashMap();
        List atts = subcatLabels.getContainedAttributes();
        String label = "";
        for (Iterator iterator = atts.iterator(); iterator.hasNext();) {
            SourceBeanAttribute object = (SourceBeanAttribute) iterator.next();

            String subcatName = new String(object.getKey());
            label = new String((String) object.getValue());
            if (label != null) {
                subCatLabelsMap.put(subcatName, label);
            }
        }

    }

    logger.debug("OUT");
}

From source file:org.tinymediamanager.scraper.util.YoutubeLinkExtractor.java

private void addVideo(List<VideoDownload> sNextVideoURL, String itag, URL url) {
    Integer i = Integer.decode(itag);
    VideoQuality vd = itagMap.get(i);//ww  w .  ja va2  s .  c om

    sNextVideoURL.add(new VideoDownload(vd, url));
}

From source file:lineage2.gameserver.instancemanager.HellboundManager.java

/**
 * Method getHellboundSpawn./* w w  w  . jav  a 2  s .  c om*/
 */
private void getHellboundSpawn() {
    _list = new ArrayList<>();
    _spawnList = new ArrayList<>();
    try {
        File file = new File(Config.DATAPACK_ROOT + "/data/xml/other/hellbound_spawnlist.xml");
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        factory.setValidating(false);
        factory.setIgnoringComments(true);
        Document doc1 = factory.newDocumentBuilder().parse(file);
        int counter = 0;
        for (Node n1 = doc1.getFirstChild(); n1 != null; n1 = n1.getNextSibling()) {
            if ("list".equalsIgnoreCase(n1.getNodeName())) {
                for (Node d1 = n1.getFirstChild(); d1 != null; d1 = d1.getNextSibling()) {
                    if ("data".equalsIgnoreCase(d1.getNodeName())) {
                        counter++;
                        int npcId = Integer.parseInt(d1.getAttributes().getNamedItem("npc_id").getNodeValue());
                        Location spawnLoc = null;
                        if (d1.getAttributes().getNamedItem("loc") != null) {
                            spawnLoc = Location.parseLoc(d1.getAttributes().getNamedItem("loc").getNodeValue());
                        }
                        int count = 1;
                        if (d1.getAttributes().getNamedItem("count") != null) {
                            count = Integer.parseInt(d1.getAttributes().getNamedItem("count").getNodeValue());
                        }
                        int respawn = 60;
                        if (d1.getAttributes().getNamedItem("respawn") != null) {
                            respawn = Integer
                                    .parseInt(d1.getAttributes().getNamedItem("respawn").getNodeValue());
                        }
                        int respawnRnd = 0;
                        if (d1.getAttributes().getNamedItem("respawn_rnd") != null) {
                            respawnRnd = Integer
                                    .parseInt(d1.getAttributes().getNamedItem("respawn_rnd").getNodeValue());
                        }
                        Node att = d1.getAttributes().getNamedItem("stage");
                        StringTokenizer st = new StringTokenizer(att.getNodeValue(), ";");
                        int tokenCount = st.countTokens();
                        int[] stages = new int[tokenCount];
                        for (int i = 0; i < tokenCount; i++) {
                            Integer value = Integer.decode(st.nextToken().trim());
                            stages[i] = value;
                        }
                        Territory territory = null;
                        for (Node s1 = d1.getFirstChild(); s1 != null; s1 = s1.getNextSibling()) {
                            if ("territory".equalsIgnoreCase(s1.getNodeName())) {
                                Polygon poly = new Polygon();
                                for (Node s2 = s1.getFirstChild(); s2 != null; s2 = s2.getNextSibling()) {
                                    if ("add".equalsIgnoreCase(s2.getNodeName())) {
                                        int x = Integer
                                                .parseInt(s2.getAttributes().getNamedItem("x").getNodeValue());
                                        int y = Integer
                                                .parseInt(s2.getAttributes().getNamedItem("y").getNodeValue());
                                        int minZ = Integer.parseInt(
                                                s2.getAttributes().getNamedItem("zmin").getNodeValue());
                                        int maxZ = Integer.parseInt(
                                                s2.getAttributes().getNamedItem("zmax").getNodeValue());
                                        poly.add(x, y).setZmin(minZ).setZmax(maxZ);
                                    }
                                }
                                territory = new Territory().add(poly);
                                if (!poly.validate()) {
                                    _log.error("HellboundManager: Invalid spawn territory : " + poly + "!");
                                    continue;
                                }
                            }
                        }
                        if ((spawnLoc == null) && (territory == null)) {
                            _log.error("HellboundManager: no spawn data for npc id : " + npcId + "!");
                            continue;
                        }
                        HellboundSpawn hbs = new HellboundSpawn(npcId, spawnLoc, count, territory, respawn,
                                respawnRnd, stages);
                        _list.add(hbs);
                    }
                }
            }
        }
        _log.info("HellboundManager: Loaded " + counter + " spawn entries.");
    } catch (Exception e) {
        _log.warn("HellboundManager: Spawn table could not be initialized.");
        e.printStackTrace();
    }
}

From source file:org.encuestame.core.util.HTMLInputFilter.java

protected String decodeEntities(String string) {
    StringBuffer buf = new StringBuffer();

    Pattern pattern = Pattern.compile("&#(\\d+);?");
    Matcher matcher = pattern.matcher(string);
    while (matcher.find()) {
        String match = matcher.group(1);
        int decimal = Integer.decode(match).intValue();
        matcher.appendReplacement(buf, chr(decimal));
    }// www .  j a  va2 s.  c  o  m
    matcher.appendTail(buf);
    string = buf.toString();

    buf = new StringBuffer();
    pattern = Pattern.compile("&#x([0-9a-f]+);?");
    matcher = pattern.matcher(string);
    while (matcher.find()) {
        String match = matcher.group(1);
        int decimal = Integer.decode(match).intValue();
        matcher.appendReplacement(buf, chr(decimal));
    }
    matcher.appendTail(buf);
    string = buf.toString();

    buf = new StringBuffer();
    pattern = Pattern.compile("%([0-9a-f]{2});?");
    matcher = pattern.matcher(string);
    while (matcher.find()) {
        String match = matcher.group(1);
        int decimal = Integer.decode(match).intValue();
        matcher.appendReplacement(buf, chr(decimal));
    }
    matcher.appendTail(buf);
    string = buf.toString();

    string = validateEntities(string);
    return string;
}

From source file:com.l2jfree.gameserver.model.skills.conditions.ConditionParser.java

private Condition parseTargetCondition(String nodeName, String nodeValue) {
    if ("aggro".equalsIgnoreCase(nodeName)) {
        boolean val = Boolean.parseBoolean(nodeValue);
        return new ConditionTargetAggro(val);
    } else if ("siegezone".equalsIgnoreCase(nodeName)) {
        int value = Integer.decode(nodeValue);
        return new ConditionSiegeZone(value, false);
    } else if ("level".equalsIgnoreCase(nodeName)) {
        int lvl = Integer.decode(nodeValue);
        return new ConditionTargetLevel(lvl);
    } else if ("class_id_restriction".equalsIgnoreCase(nodeName)) {
        List<Integer> array = new ArrayList<Integer>();
        StringTokenizer st = new StringTokenizer(nodeValue, ",");
        while (st.hasMoreTokens()) {
            array.add(Integer.decode(st.nextToken().trim()));
        }/*ww  w.j  a v a  2  s .co  m*/
        return new ConditionTargetClassIdRestriction(array);
    } else if ("active_effect_id".equalsIgnoreCase(nodeName)) {
        return new ConditionTargetActiveEffectId(nodeValue);
    } else if ("active_skill_id".equalsIgnoreCase(nodeName)) {
        return new ConditionTargetActiveSkillId(nodeValue);
    } else if ("mindistance".equalsIgnoreCase(nodeName)) {
        int distance = Integer.decode(nodeValue);
        return new ConditionMinDistance(distance * distance);
    }
    // used for npc race
    else if ("race_id".equalsIgnoreCase(nodeName)) {
        ArrayList<Integer> array = new ArrayList<Integer>();
        StringTokenizer st = new StringTokenizer(nodeValue, ",");
        while (st.hasMoreTokens()) {
            //-1 because we want to take effect for exactly race that is by -1 lower in FastList
            array.add(Integer.decode(st.nextToken().trim()) - 1);
        }
        return new ConditionTargetRaceId(array);
    }
    // used for player race
    else if ("race".equalsIgnoreCase(nodeName)) {
        Race race = Race.valueOf(nodeValue);
        return new ConditionTargetRace(race);
    } else if ("undead".equalsIgnoreCase(nodeName)) {
        boolean val = Boolean.parseBoolean(nodeValue);
        return new ConditionTargetUndead(val);
    } else if ("using".equalsIgnoreCase(nodeName)) {
        int mask = 0;
        StringTokenizer st = new StringTokenizer(nodeValue, ",");
        while (st.hasMoreTokens()) {
            String item = st.nextToken().trim();
            for (L2WeaponType wt : L2WeaponType.values()) {
                if (wt.toString().equalsIgnoreCase(item)) {
                    mask |= wt.mask();
                    break;
                }
            }
            for (L2ArmorType at : L2ArmorType.values()) {
                if (at.toString().equalsIgnoreCase(item)) {
                    mask |= at.mask();
                    break;
                }
            }
        }
        return new ConditionTargetUsesWeaponKind(mask);
    } else if ("npcId".equalsIgnoreCase(nodeName)) {
        int[] npcIds = Util.toIntArray(nodeValue.trim(), " ");
        return new ConditionTargetNpcId(npcIds);
    } else if ("npcType".equalsIgnoreCase(nodeName)) {
        String[] npcTypes = nodeValue.trim().split(" ");
        return new ConditionTargetNpcType(npcTypes);
    } else if ("doorId".equalsIgnoreCase(nodeName)) {
        int[] doorIds = Util.toIntArray(nodeValue.trim(), " ");
        return new ConditionTargetDoorId(doorIds);
    } else if ("abnormal".equalsIgnoreCase(nodeName)) {
        int abnormalId = Integer.decode(nodeValue);
        return new ConditionTargetAbnormal(abnormalId);
    }

    throw new IllegalStateException("Invalid attribute at <target>: " + nodeName + "='" + nodeValue + "'");
}

From source file:it.eng.spagobi.engines.chart.bo.charttypes.clusterchart.ClusterCharts.java

/**
 * Calculates chart value;/*from   w  w  w .j ava2 s.  c o m*/
 * 
 * 
 * public Dataset calculateValue(String cat, Map parameters) throws Exception {
 * logger.debug("IN");
 * String res=DataSetAccessFunctions.getDataSetResult(profile, getData(),parameters);
 * 
 * DefaultCategoryDataset dataset = new DefaultCategoryDataset();
 * 
 * SourceBean sbRows=SourceBean.fromXMLString(res);
 * List listAtts=sbRows.getAttributeAsList("ROW");
 * 
 * 
 * // run all categories (one for each row)
 * categoriesNumber=0;
 * for (Iterator iterator = listAtts.iterator(); iterator.hasNext();) {
 * SourceBean category = (SourceBean) iterator.next();
 * List atts=category.getContainedAttributes();
 * 
 * HashMap series=new HashMap();
 * String catValue="";
 * 
 * String name="";
 * String value="";
 * 
 * //run all the attributes, to define series!
 * for (Iterator iterator2 = atts.iterator(); iterator2.hasNext();) {
 * SourceBeanAttribute object = (SourceBeanAttribute) iterator2.next();
 * 
 * name=new String(object.getKey());
 * value=new String((String)object.getValue());
 * if(name.equalsIgnoreCase("x"))catValue=value;
 * else series.put(name, value);
 * }
 * for (Iterator iterator3 = series.keySet().iterator(); iterator3.hasNext();) {
 * String nameS = (String) iterator3.next();
 * String valueS=(String)series.get(nameS);
 * dataset.addValue(Double.valueOf(valueS).doubleValue(), nameS, catValue);
 * categoriesNumber=categoriesNumber+1;
 * }
 * 
 * }
 * logger.debug("OUT");
 * return dataset;
 * }
 * 
 * @param content the content
 */

public void configureChart(SourceBean content) {
    logger.debug("IN");
    super.configureChart(content);
    confParameters = new HashMap();
    SourceBean confSB = (SourceBean) content.getAttribute("CONF");

    if (confSB == null)
        return;
    List confAttrsList = confSB.getAttributeAsList("PARAMETER");

    Iterator confAttrsIter = confAttrsList.iterator();
    while (confAttrsIter.hasNext()) {
        SourceBean param = (SourceBean) confAttrsIter.next();
        String nameParam = (String) param.getAttribute("name");
        String valueParam = (String) param.getAttribute("value");
        confParameters.put(nameParam, valueParam);
    }

    if (confParameters.get("x_label") != null) {
        xLabel = (String) confParameters.get("x_label");
    } else {
        xLabel = "x";
    }

    if (confParameters.get("y_label") != null) {
        yLabel = (String) confParameters.get("y_label");
    } else {
        yLabel = "y";
    }

    //'column_sel' defines the column in witch there is the indicator of serie selected, 
    //so the widget can colors the bubbles with the color read into template, otherwise the bubble is white/trasparent.
    //'default_color' defines the default series color.
    if (confParameters.get("column_sel") != null)
        colSel = (String) confParameters.get("column_sel");
    else
        colSel = "";

    if (confParameters.get("default_color") != null)
        defaultColor = (String) confParameters.get("default_color");
    else
        defaultColor = "#FFFFFF";

    //reading series colors if present
    SourceBean colors = (SourceBean) content.getAttribute("SERIES_COLORS");
    if (colors == null) {
        colors = (SourceBean) content.getAttribute("CONF.SERIES_COLORS");
    }
    if (colors != null) {
        colorMap = new HashMap();
        List atts = colors.getContainedAttributes();
        String colorNum = "";
        String colorSerie = "";
        String num = "";
        for (Iterator iterator = atts.iterator(); iterator.hasNext();) {
            SourceBeanAttribute object = (SourceBeanAttribute) iterator.next();
            //System.out.println(object.getKey());
            String seriesName = new String(object.getKey());

            colorSerie = new String((String) object.getValue());
            Color col = new Color(Integer.decode(colorSerie).intValue());
            if (col != null) {
                colorMap.put(seriesName, col);
            }
        }
    }

    //      check if there is some info about additional labels style

    SourceBean styleXaxisLabelsSB = (SourceBean) content.getAttribute("STYLE_X_AXIS_LABELS");
    if (styleXaxisLabelsSB != null) {

        String fontS = (String) content.getAttribute("STYLE_X_AXIS_LABELS.font");
        if (fontS == null) {
            fontS = defaultLabelsStyle.getFontName();
        }
        String sizeS = (String) content.getAttribute("STYLE_X_AXIS_LABELS.size");
        String colorS = (String) content.getAttribute("STYLE_X_AXIS_LABELS.color");
        String orientationS = (String) content.getAttribute("STYLE_X_AXIS_LABELS.orientation");
        if (orientationS == null) {
            orientationS = "horizontal";
        }

        try {
            Color color = Color.BLACK;
            if (colorS != null) {
                color = Color.decode(colorS);
            } else {
                defaultLabelsStyle.getColor();
            }
            int size = 12;
            if (sizeS != null) {
                size = Integer.valueOf(sizeS).intValue();
            } else {
                size = defaultLabelsStyle.getSize();
            }

            styleXaxesLabels = new StyleLabel(fontS, size, color);

        } catch (Exception e) {
            logger.error("Wrong style labels settings, use default");
        }

    } else {
        styleXaxesLabels = defaultLabelsStyle;
    }

    SourceBean styleYaxisLabelsSB = (SourceBean) content.getAttribute("STYLE_Y_AXIS_LABELS");
    if (styleYaxisLabelsSB != null) {

        String fontS = (String) content.getAttribute("STYLE_Y_AXIS_LABELS.font");
        if (fontS == null) {
            fontS = defaultLabelsStyle.getFontName();
        }
        String sizeS = (String) content.getAttribute("STYLE_Y_AXIS_LABELS.size");
        String colorS = (String) content.getAttribute("STYLE_Y_AXIS_LABELS.color");
        String orientationS = (String) content.getAttribute("STYLE_Y_AXIS_LABELS.orientation");
        if (orientationS == null) {
            orientationS = "horizontal";
        }

        try {
            Color color = Color.BLACK;
            if (colorS != null) {
                color = Color.decode(colorS);
            } else {
                defaultLabelsStyle.getColor();
            }
            int size = 12;
            if (sizeS != null) {
                size = Integer.valueOf(sizeS).intValue();
            } else {
                size = defaultLabelsStyle.getSize();
            }

            styleYaxesLabels = new StyleLabel(fontS, size, color);

        } catch (Exception e) {
            logger.error("Wrong style labels settings, use default");
        }

    } else {
        styleYaxesLabels = defaultLabelsStyle;
    }

    SourceBean styleValueLabelsSB = (SourceBean) content.getAttribute("STYLE_VALUE_LABELS");
    if (styleValueLabelsSB != null) {

        String fontS = (String) content.getAttribute("STYLE_VALUE_LABELS.font");
        if (fontS == null) {
            fontS = defaultLabelsStyle.getFontName();
        }
        String sizeS = (String) content.getAttribute("STYLE_VALUE_LABELS.size");
        String colorS = (String) content.getAttribute("STYLE_VALUE_LABELS.color");
        String orientationS = (String) content.getAttribute("STYLE_VALUE_LABELS.orientation");
        if (orientationS == null) {
            orientationS = "horizontal";
        }

        try {
            Color color = Color.BLACK;
            if (colorS != null) {
                color = Color.decode(colorS);
            } else {
                defaultLabelsStyle.getColor();
            }
            int size = 12;
            if (sizeS != null) {
                size = Integer.valueOf(sizeS).intValue();
            } else {
                size = defaultLabelsStyle.getSize();
            }

            styleValueLabels = new StyleLabel(fontS, size, color);

        } catch (Exception e) {
            logger.error("Wrong style labels settings, use default");
        }

    } else {
        styleValueLabels = defaultLabelsStyle;
    }

    logger.debug("OUT");
}

From source file:org.kchine.r.server.http.RHttpProxy.java

public static String[] listWorkers(String url, String sessionId) throws TunnelingException {
    GetMethod getList = null;// ww w.  j  av a 2 s  . co m
    try {
        Object result = null;
        mainHttpClient = new HttpClient();
        if (System.getProperty("proxy_host") != null && !System.getProperty("proxy_host").equals("")) {
            mainHttpClient.getHostConfiguration().setProxy(System.getProperty("proxy_host"),
                    Integer.decode(System.getProperty("proxy_port")));
        }
        getList = new GetMethod(url + "?method=list");
        try {
            if (sessionId != null && !sessionId.equals("")) {
                getList.getParams().setCookiePolicy(CookiePolicy.IGNORE_COOKIES);
                getList.setRequestHeader("Cookie", "JSESSIONID=" + sessionId);
            }
            mainHttpClient.executeMethod(getList);
            result = new ObjectInputStream(getList.getResponseBodyAsStream()).readObject();
        } catch (ConnectException e) {
            throw new ConnectionFailedException();
        } catch (Exception e) {
            throw new TunnelingException("", e);
        }
        if (result != null && result instanceof TunnelingException) {
            throw (TunnelingException) result;
        }

        return (String[]) result;

    } finally {
        if (getList != null) {
            getList.releaseConnection();
        }
        if (mainHttpClient != null) {
        }
    }
}

From source file:it.eng.spagobi.engines.chart.bo.ChartImpl.java

/**
 * configureChart reads the content of the template and sets the chart parameters.
 * /*from  w w  w  .j a  va 2 s.  co m*/
 * @param content the content
 */
public void configureChart(SourceBean content) {
    logger.debug("IN");
    // common part for all charts
    //setting the title with parameter values if is necessary
    if (content.getAttribute(NAME) != null) {
        String titleChart = (String) content.getAttribute(NAME);
        String tmpTitle = titleChart;
        while (!tmpTitle.equals("")) {
            if (tmpTitle.indexOf("$P{") >= 0) {
                String parName = tmpTitle.substring(tmpTitle.indexOf("$P{") + 3, tmpTitle.indexOf("}"));

                String parValue = (parametersObject.get(parName) == null) ? ""
                        : (String) parametersObject.get(parName);
                parValue = parValue.replaceAll("\'", "");

                if (parValue.equals("%"))
                    parValue = "";
                int pos = tmpTitle.indexOf("$P{" + parName + "}") + (parName.length() + 4);
                titleChart = titleChart.replace("$P{" + parName + "}", parValue);
                tmpTitle = tmpTitle.substring(pos);
            } else
                tmpTitle = "";
        }
        setName(titleChart);
    } else
        setName("");

    SourceBean styleTitleSB = (SourceBean) content.getAttribute(STYLE_TITLE);
    if (styleTitleSB != null) {

        String fontS = (String) styleTitleSB.getAttribute(FONT_STYLE);
        String sizeS = (String) styleTitleSB.getAttribute(SIZE_STYLE);
        String colorS = (String) styleTitleSB.getAttribute(COLOR_STYLE);

        try {
            Color color = Color.decode(colorS);
            int size = Integer.valueOf(sizeS).intValue();
            styleTitle = new StyleLabel(fontS, size, color);

        } catch (Exception e) {
            logger.error("Wrong style Title settings, use default");
        }

    }

    SourceBean styleSubTitleSB = (SourceBean) content.getAttribute(STYLE_SUBTITLE);
    if (styleSubTitleSB != null) {

        String subTitle = (String) styleSubTitleSB.getAttribute(NAME_STYLE);
        if (subTitle != null) {
            String tmpSubTitle = subTitle;
            while (!tmpSubTitle.equals("")) {
                if (tmpSubTitle.indexOf("$P{") >= 0) {
                    String parName = tmpSubTitle.substring(tmpSubTitle.indexOf("$P{") + 3,
                            tmpSubTitle.indexOf("}"));
                    String parValue = (parametersObject.get(parName) == null) ? ""
                            : (String) parametersObject.get(parName);
                    parValue = parValue.replaceAll("\'", "");
                    if (parValue.equals("%"))
                        parValue = "";
                    int pos = tmpSubTitle.indexOf("$P{" + parName + "}") + (parName.length() + 4);
                    subTitle = subTitle.replace("$P{" + parName + "}", parValue);
                    tmpSubTitle = tmpSubTitle.substring(pos);
                } else
                    tmpSubTitle = "";
            }
            setSubName(subTitle);
        } else
            setSubName("");

        String fontS = (String) styleSubTitleSB.getAttribute(FONT_STYLE);
        String sizeS = (String) styleSubTitleSB.getAttribute(SIZE_STYLE);
        String colorS = (String) styleSubTitleSB.getAttribute(COLOR_STYLE);

        try {
            Color color = Color.decode(colorS);
            int size = Integer.valueOf(sizeS).intValue();
            styleSubTitle = new StyleLabel(fontS, size, color);
        } catch (Exception e) {
            logger.error("Wrong style SubTitle settings, use default");
        }

    }

    SourceBean styleLabelsSB = (SourceBean) content.getAttribute(STYLE_LABELS_DEFAULT);
    if (styleLabelsSB != null) {

        String fontS = (String) styleLabelsSB.getAttribute(FONT_STYLE);
        if (fontS == null) {
            fontS = "Arial";
        }
        String sizeS = (String) styleLabelsSB.getAttribute(SIZE_STYLE);
        if (sizeS == null) {
            sizeS = "12";
        }
        String colorS = (String) styleLabelsSB.getAttribute(COLOR_STYLE);
        if (colorS == null) {
            colorS = "#000000";
        }
        String orientationS = (String) styleLabelsSB.getAttribute(ORIENTATION_STYLE);
        if (orientationS == null) {
            orientationS = "horizontal";
        }

        try {
            Color color = Color.decode(colorS);
            int size = Integer.valueOf(sizeS).intValue();
            defaultLabelsStyle = new StyleLabel(fontS, size, color, orientationS);

        } catch (Exception e) {
            logger.error("Wrong style labels settings, use default");
        }

    } else {
        defaultLabelsStyle = new StyleLabel("Arial", 12, Color.BLACK);
    }

    if (content.getAttribute("title_dimension") != null) {
        String titleD = ((String) content.getAttribute(TITLE_DIMENSION));
        titleDimension = Integer.valueOf(titleD).intValue();
    } else
        setTitleDimension(18);

    String colS = (String) content.getAttribute(COLORS_BACKGROUND);
    if (colS != null) {
        Color col = new Color(Integer.decode(colS).intValue());
        if (col != null) {
            setColor(col);
        } else {
            setColor(Color.white);
        }
    } else {
        setColor(Color.white);
    }

    String widthS = (String) content.getAttribute(DIMENSION_WIDTH);
    String heightS = (String) content.getAttribute(DIMENSION_HEIGHT);
    if (widthS == null || heightS == null) {
        logger.warn("Width or height non defined, use default ones");
        widthS = "400";
        heightS = "300";
    }

    width = Integer.valueOf(widthS).intValue();
    height = Integer.valueOf(heightS).intValue();

    // get all the data parameters 

    try {
        Map dataParameters = new HashMap();
        SourceBean dataSB = (SourceBean) content.getAttribute(CONF);
        List dataAttrsList = dataSB.getContainedSourceBeanAttributes();
        Iterator dataAttrsIter = dataAttrsList.iterator();
        while (dataAttrsIter.hasNext()) {
            SourceBeanAttribute paramSBA = (SourceBeanAttribute) dataAttrsIter.next();
            SourceBean param = (SourceBean) paramSBA.getValue();
            String nameParam = (String) param.getAttribute("name");
            String valueParam = (String) param.getAttribute("value");
            dataParameters.put(nameParam, valueParam);
        }

        if (dataParameters.get(CONF_DATASET) != null
                && !(((String) dataParameters.get(CONF_DATASET)).equalsIgnoreCase(""))) {
            confDataset = (String) dataParameters.get(CONF_DATASET);
            isLovConfDefined = true;
        } else {
            isLovConfDefined = false;
        }

        legend = true;
        if (dataParameters.get(LEGEND) != null
                && !(((String) dataParameters.get(LEGEND)).equalsIgnoreCase(""))) {
            String leg = (String) dataParameters.get(LEGEND);
            if (leg.equalsIgnoreCase("false"))
                legend = false;
        }

        legendPosition = "bottom";
        if (dataParameters.get(LEGEND_POSITION) != null
                && !(((String) dataParameters.get(LEGEND_POSITION)).equalsIgnoreCase(""))) {
            String leg = (String) dataParameters.get(LEGEND_POSITION);
            if (leg.equalsIgnoreCase("bottom") || leg.equalsIgnoreCase("left") || leg.equalsIgnoreCase("right")
                    || leg.equalsIgnoreCase("top"))
                legendPosition = leg;
        }

        filter = true;
        if (dataParameters.get(VIEW_FILTER) != null
                && !(((String) dataParameters.get(VIEW_FILTER)).equalsIgnoreCase(""))) {
            String fil = (String) dataParameters.get(VIEW_FILTER);
            if (fil.equalsIgnoreCase("false"))
                filter = false;
        }

        slider = true;
        if (dataParameters.get(VIEW_SLIDER) != null
                && !(((String) dataParameters.get(VIEW_SLIDER)).equalsIgnoreCase(""))) {
            String sli = (String) dataParameters.get(VIEW_SLIDER);
            if (sli.equalsIgnoreCase("false"))
                slider = false;
        }

        sliderStartFromEnd = false;
        if (dataParameters.get(SLIDER_START_FROM_END) != null
                && !(((String) dataParameters.get(SLIDER_START_FROM_END)).equalsIgnoreCase(""))) {
            String sli = (String) dataParameters.get(SLIDER_START_FROM_END);
            if (sli.equalsIgnoreCase("true"))
                sliderStartFromEnd = true;
        }

        positionSlider = "top";
        if (dataParameters.get(POSITION_SLIDER) != null
                && !(((String) dataParameters.get(POSITION_SLIDER)).equalsIgnoreCase(""))) {
            positionSlider = (String) dataParameters.get(POSITION_SLIDER);
        }

        //reading series orders if present
        SourceBean sbSerieLabels = (SourceBean) content.getAttribute(SERIES_LABELS);
        // back compatibility
        if (sbSerieLabels == null) {
            sbSerieLabels = (SourceBean) content.getAttribute("CONF.SERIES_LABELS");
        }
        if (sbSerieLabels != null) {
            seriesLabelsMap = new LinkedHashMap();
            List atts = sbSerieLabels.getContainedAttributes();
            String serieLabel = "";
            for (Iterator iterator = atts.iterator(); iterator.hasNext();) {
                SourceBeanAttribute object = (SourceBeanAttribute) iterator.next();
                String serieName = (String) object.getKey();
                serieLabel = new String((String) object.getValue());
                if (serieLabel != null) {
                    seriesLabelsMap.put(serieName, serieLabel);
                }
            }
        }

        SourceBean styleLegendSB = (SourceBean) content.getAttribute(LEGEND_STYLE);
        if (styleLegendSB != null) {

            String fontS = (String) styleLegendSB.getAttribute(FONT_STYLE);
            String sizeS = (String) styleLegendSB.getAttribute(SIZE_STYLE);
            String colorS = (String) styleLegendSB.getAttribute(COLOR_STYLE);

            try {
                Color color = Color.decode(colorS);
                int size = Integer.valueOf(sizeS).intValue();
                styleLegend = new StyleLabel(fontS, size, color);

            } catch (Exception e) {
                logger.error("Wrong style Legend settings, use default");
            }
        }

    } catch (Exception e) {
        logger.error(e.getCause() + " " + e.getStackTrace());
        logger.error("many error in reading data source parameters", e);
    }

}

From source file:com.mm.yamingapp.core.MethodDescriptor.java

/** Returns the converters for {@code String}, {@code Integer} and {@code Boolean}. */
private static Map<Class<?>, Converter<?>> populateConverters() {
    Map<Class<?>, Converter<?>> converters = new HashMap<Class<?>, Converter<?>>();
    converters.put(String.class, new Converter<String>() {
        @Override/*  www  . java2s  .co  m*/
        public String convert(String value) {
            return value;
        }
    });
    converters.put(Integer.class, new Converter<Integer>() {
        @Override
        public Integer convert(String input) {
            try {
                return Integer.decode(input);
            } catch (NumberFormatException e) {
                throw new IllegalArgumentException("'" + input + "' is not an integer");
            }
        }
    });
    converters.put(Boolean.class, new Converter<Boolean>() {
        @Override
        public Boolean convert(String input) {
            if (input == null) {
                return null;
            }
            input = input.toLowerCase();
            if (input.equals("true")) {
                return Boolean.TRUE;
            }
            if (input.equals("false")) {
                return Boolean.FALSE;
            }
            throw new IllegalArgumentException("'" + input + "' is not a boolean");
        }
    });
    return converters;
}