List of usage examples for java.lang Integer decode
public static Integer decode(String nm) throws NumberFormatException
From source file:com.l2jfree.gameserver.model.skills.conditions.ConditionParser.java
private Condition parseGameCondition(String nodeName, String nodeValue) { if ("night".equalsIgnoreCase(nodeName)) { boolean val = Boolean.parseBoolean(nodeValue); return new ConditionGameTime(CheckGameTime.NIGHT, val); } else if ("chance".equalsIgnoreCase(nodeName)) { int val = Integer.decode(nodeValue); return new ConditionGameChance(val); } else if ("skill".equalsIgnoreCase(nodeName)) { boolean val = Boolean.parseBoolean(nodeValue); return new ConditionWithSkill(val); }//from w ww . j av a 2 s .co m throw new IllegalStateException("Invalid attribute at <game>: " + nodeName + "='" + nodeValue + "'"); }
From source file:com.aurel.track.exchange.docx.exporter.AssembleWordprocessingMLPackage.java
private static void replaceIssueLinksWithDescription(String psrc, List<Integer> itemIDs, List<Section> sections, boolean isInline) { StringBuilder src = new StringBuilder(psrc); int startIndex = src.indexOf(ISSUE_TAG); String paragraph = "<p>"; if (startIndex == -1) { //add the original description (no inline content) sections.add(new Section(isInline, src.toString())); } else {//from w w w . ja va2s. co m while ((startIndex = src.toString().indexOf(ISSUE_TAG/*, startIndex*/)) != -1) { int endIndex = src.toString().indexOf(CLOSE, startIndex); if (endIndex == -1 || (endIndex <= startIndex)) { //no closing tag found: remove the opening tag and go on src = src.replace(startIndex, startIndex + ISSUE_TAG.length(), EMPTY); continue; } String key = src.substring(startIndex + ISSUE_TAG.length(), endIndex).trim(); try { Integer itemID = Integer.decode(key); LOGGER.debug("ItemID " + itemID + " found"); itemIDs.add(itemID); TWorkItemBean itemBean = null; try { itemBean = ItemBL.loadWorkItem(itemID); } catch (ItemLoaderException e) { LOGGER.warn("Loading the workItemID " + itemID + " failed with " + e.getMessage()); } if (itemBean == null) { //item not found, neglect the link to this item src = src.replace(startIndex, endIndex + CLOSE.length(), EMPTY); } else { //item found sections.add(new Section(isInline, src.substring(0, startIndex))); String description = itemBean.getDescription(); boolean noDescription = false; if (description == null || description.length() == 0) { noDescription = true; description = itemBean.getSynopsis(); } else { description = removeHtmlHeadings(description); } //add itemNo before the inline description String itemNo = AssembleWordprocessingMLPackage.getItemNo(itemBean); if (description.startsWith(paragraph)) { description = paragraph + itemNo + description.substring(paragraph.length()); } else { description = itemNo + description; } if (noDescription) { sections.add(new Section(true, description)); } else { exportDescription(description, itemIDs, sections, true); } src = new StringBuilder(src.substring(endIndex + CLOSE.length())); } } catch (NumberFormatException e) { LOGGER.info("The key " + key + " is not a number. Remove the start and end tag but do not remove the content between the two"); src = src.replace(startIndex, startIndex + ISSUE_TAG.length(), EMPTY); //recalculate end index endIndex = src.toString().indexOf(CLOSE, startIndex); src = src.replace(endIndex, endIndex + CLOSE.length(), EMPTY); } } sections.add(new Section(isInline, src.toString())); } }
From source file:org.jbpm.formModeler.components.editor.WysiwygFormEditor.java
public synchronized void actionMoveFirst(CommandRequest request) throws Exception { checkEditionContext(request);/*ww w .j a v a 2s .c om*/ int fieldPosition = Integer.decode(request.getParameter("position")).intValue(); Form form = getCurrentForm(); if (form == null) { log.error("Cannot modify unexistant form."); } else { getFormManager().moveTop(form, fieldPosition); setLastMovedFieldPosition(0); if (getCurrentEditFieldPosition() == fieldPosition) setCurrentEditFieldPosition(getLastMovedFieldPosition()); else if (getCurrentEditFieldPosition() > -1 && fieldPosition > getCurrentEditFieldPosition()) setCurrentEditFieldPosition(getCurrentEditFieldPosition() + 1); } }
From source file:dk.netarkivet.harvester.datamodel.PartialHarvest.java
private void saveAttributes(DomainConfiguration dc, Map<String, String> attributeValues) { if (dc.getID() == null) { log.warn("Attributes not saved to database. Id of domainConfiguration not yet available"); return;/*from w w w . ja va 2 s . co m*/ } // EAV try { long entity_id = dc.getID(); log.info("Saving attributes for domain config id {} and name {} and domain {}", entity_id, dc.getName(), dc.getDomainName()); EAV eav = EAV.getInstance(); List<AttributeAndType> attributeTypes = eav.getAttributesAndTypes(EAV.DOMAIN_TREE_ID, (int) entity_id); log.debug("3 attributes available for entity {}", entity_id); AttributeAndType attributeAndType; AttributeTypeBase attributeType; AttributeBase attribute; for (int i = 0; i < attributeTypes.size(); ++i) { attributeAndType = attributeTypes.get(i); attributeType = attributeAndType.attributeType; log.debug("Examining attribute {}", attributeType.name); attribute = attributeAndType.attribute; if (attribute == null) { attribute = attributeType.instanceOf(); attribute.entity_id = (int) entity_id; } switch (attributeType.viewtype) { case 1: String paramValue = attributeValues.get(attributeType.name); int intValue; if (paramValue != null) { intValue = Integer.decode(paramValue); } else { intValue = attributeType.def_int; } log.info("Setting attribute {} to value {}", attributeType.name, intValue); attribute.setInteger(intValue); break; case 5: case 6: paramValue = attributeValues.get(attributeType.name); int intVal = 0; if (paramValue != null && !"0".equals(paramValue)) { intVal = 1; } log.debug("Set intVal = 1 for attribute {} when receiving paramValue={}", attributeType.name, paramValue); attribute.setInteger(intVal); break; } eav.saveAttribute(attribute); } } catch (SQLException e) { throw new RuntimeException("Unable to store EAV data!", e); } }
From source file:com.neophob.sematrix.core.properties.ApplicationConfigurationHelper.java
/** * Parses the i2c address./*from w w w . j a v a2 s. c o m*/ * * @return the int */ private int parseI2cAddress() { i2cAddr = new ArrayList<Integer>(); String rawConfig = config.getProperty(ConfigConstant.RAINBOWDUINO_V2_ROW1); if (StringUtils.isNotBlank(rawConfig)) { this.deviceXResolution = 8; this.deviceYResolution = 8; for (String s : rawConfig.split(ConfigConstant.DELIM)) { i2cAddr.add(Integer.decode(StringUtils.strip(s))); devicesInRow1++; } } rawConfig = config.getProperty(ConfigConstant.RAINBOWDUINO_V2_ROW2); if (StringUtils.isNotBlank(rawConfig)) { for (String s : rawConfig.split(ConfigConstant.DELIM)) { i2cAddr.add(Integer.decode(StringUtils.strip(s))); devicesInRow2++; } } return i2cAddr.size(); }
From source file:org.jbpm.formModeler.components.editor.WysiwygFormEditor.java
public synchronized void actionMoveLast(CommandRequest request) throws Exception { checkEditionContext(request);/*from ww w . j a v a 2s . com*/ int fieldPosition = Integer.decode(request.getParameter("position")).intValue(); Form form = getCurrentForm(); if (form == null) { log.error("Cannot modify unexistant form."); } else { getFormManager().moveBottom(form, fieldPosition); setLastMovedFieldPosition(form.getFormFields().size() - 1); if (getCurrentEditFieldPosition() == fieldPosition) setCurrentEditFieldPosition(getLastMovedFieldPosition()); else if (fieldPosition < getCurrentEditFieldPosition()) setCurrentEditFieldPosition(getCurrentEditFieldPosition() - 1); } }
From source file:net.rptools.maptool.client.functions.StrListFunctions.java
/** Tries to convert a string to a number, returning <code>null</code> on failure. */ public Integer strToInt(String s) { Integer intval = null;/*w w w. j a va2s.c om*/ try { // convert to numeric value if possible intval = Integer.decode(s); } catch (Exception e) { intval = null; } return intval; }
From source file:it.eng.spagobi.engines.chart.bo.charttypes.barcharts.BarCharts.java
/** * Calculates chart value;//w ww . j a v a 2 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("category_label") != null) { categoryLabel = (String) confParameters.get("category_label"); } else { //categoryLabel="category"; categoryLabel = ""; } if (confParameters.get(VALUE_LABEL) != null) { valueLabel = (String) confParameters.get(VALUE_LABEL); String tmpValueLabel = valueLabel; while (!tmpValueLabel.equals("")) { if (tmpValueLabel.indexOf("$P{") >= 0) { String parName = tmpValueLabel.substring(tmpValueLabel.indexOf("$P{") + 3, tmpValueLabel.indexOf("}")); String parValue = (parametersObject.get(parName) == null) ? "" : (String) parametersObject.get(parName); parValue = parValue.replaceAll("\'", ""); if (parValue.equals("%")) parValue = ""; int pos = tmpValueLabel.indexOf("$P{" + parName + "}") + (parName.length() + 4); valueLabel = valueLabel.replace("$P{" + parName + "}", parValue); tmpValueLabel = tmpValueLabel.substring(pos); } else tmpValueLabel = ""; } setValueLabel(valueLabel); } else { //valueLabel="values"; setValueLabel(""); } if (confParameters.get(N_CAT_VISUALIZATION) != null || confParameters.get(N_VISUALIZATION) != null) { String nu = (String) confParameters.get(N_VISUALIZATION); if (nu == null) nu = (String) confParameters.get(N_CAT_VISUALIZATION); numberCatVisualization = Integer.valueOf(nu); } else { numberCatVisualization = new Integer(1); } dynamicNumberCatVisualization = false; if (confParameters.get(DYNAMIC_N_VISUALIZATION) != null) { String dynamicS = (String) confParameters.get(DYNAMIC_N_VISUALIZATION); if (dynamicS.equalsIgnoreCase("true")) dynamicNumberCatVisualization = true; } if (confParameters.get(N_SER_VISUALIZATION) != null) { String nu = (String) confParameters.get(N_SER_VISUALIZATION); numberSerVisualization = Integer.valueOf(nu); } else { numberSerVisualization = new Integer(0); } if (confParameters.get(FILTER_CAT_GROUPS) != null) { String filterCatGroupsS = (String) confParameters.get(FILTER_CAT_GROUPS); if (filterCatGroupsS.equalsIgnoreCase("false")) filterCatGroups = false; else filterCatGroups = true; } else { filterCatGroups = true; } if (confParameters.get(FILTER_SERIES) != null) { String filterSeriesS = (String) confParameters.get(FILTER_SERIES); if (filterSeriesS.equalsIgnoreCase("false")) filterSeries = false; else filterSeries = true; } else { filterSeries = true; } if (confParameters.get(FILTER_SERIES_BUTTONS) != null) { String filterSeriesS = (String) confParameters.get(FILTER_SERIES_BUTTONS); if (filterSeriesS.equalsIgnoreCase("false")) filterSeriesButtons = false; } if (confParameters.get(FILTER_CATEGORIES) != null) { String filterCategoriesS = (String) confParameters.get(FILTER_CATEGORIES); if (filterCategoriesS.equalsIgnoreCase("false")) filterCategories = false; else filterCategories = true; } else { filterCategories = true; } if (confParameters.get(SHOW_VALUE_LABLES) != null) { String valueLabelsS = (String) confParameters.get(SHOW_VALUE_LABLES); if (valueLabelsS.equalsIgnoreCase("true")) showValueLabels = true; } valueLabelsPosition = "inside"; if (confParameters.get(VALUE_LABELS_POSITION) != null) { String valueLabelpos = (String) confParameters.get(VALUE_LABELS_POSITION); if (valueLabelpos.equalsIgnoreCase("outside")) valueLabelsPosition = "outside"; } if (confParameters.get(ENABLE_TOOLTIPS) != null) { String enableTooltipsS = (String) confParameters.get(ENABLE_TOOLTIPS); if (enableTooltipsS.equalsIgnoreCase("true")) enableToolTips = true; } if (confParameters.get(MAXIMUM_BAR_WIDTH) != null) { String maxBarWidthS = (String) confParameters.get(MAXIMUM_BAR_WIDTH); try { maxBarWidth = Double.valueOf(maxBarWidthS); } catch (NumberFormatException e) { logger.error("error in defining parameter " + MAXIMUM_BAR_WIDTH + ": should be a double, it will be ignored", e); } } if (confParameters.get(RANGE_INTEGER_VALUES) != null) { String rangeIntegerValuesS = (String) confParameters.get(RANGE_INTEGER_VALUES); if (rangeIntegerValuesS.equalsIgnoreCase("true")) rangeIntegerValues = true; } if (confParameters.get(RANGE_AXIS_LOCATION) != null) { //BOTTOM_OR_LEFT, BOTTOM_OR_RIGHT, TOP_OR_RIGHT, TOP_OR_LEFT String axisLocation = (String) confParameters.get(RANGE_AXIS_LOCATION); if (axisLocation.equalsIgnoreCase("BOTTOM_OR_LEFT") || axisLocation.equalsIgnoreCase("BOTTOM_OR_RIGHT") || axisLocation.equalsIgnoreCase("TOP_OR_LEFT") || axisLocation.equalsIgnoreCase("TOP_OR_RIGHT")) { rangeAxisLocation = axisLocation; } else { logger.warn("Range Axis location specified: " + axisLocation + " not a valid value."); } } if (confParameters.get(FIRST_AXIS_LB) != null) { String axis = confParameters.get(FIRST_AXIS_LB).toString(); Integer axisInte = Integer.valueOf(axis); firstAxisLB = axisInte; } if (confParameters.get(FIRST_AXIS_UB) != null) { String axis = confParameters.get(FIRST_AXIS_UB).toString(); Integer axisInte = Integer.valueOf(axis); firstAxisUB = axisInte; } if (confParameters.get(SECOND_AXIS_LB) != null) { String axis = confParameters.get(SECOND_AXIS_LB).toString(); Integer axisInte = Integer.valueOf(axis); secondAxisLB = axisInte; } if (confParameters.get(SECOND_AXIS_UB) != null) { String axis = confParameters.get(SECOND_AXIS_UB).toString(); Integer axisInte = Integer.valueOf(axis); secondAxisUB = axisInte; } //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(); 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 series colors if present, if present this overrides series colors!!! SourceBean orderColors = (SourceBean) content.getAttribute(SERIES_ORDER_COLORS); if (orderColors == null) { orderColors = (SourceBean) content.getAttribute("CONF." + SERIES_ORDER_COLORS); } if (orderColors != null) { orderColorVector = new Vector<Color>(); List atts = orderColors.getContainedAttributes(); String numSerie = ""; String colorSerie = ""; for (Iterator iterator = atts.iterator(); iterator.hasNext();) { SourceBeanAttribute object = (SourceBeanAttribute) iterator.next(); numSerie = new String(object.getKey()); colorSerie = new String((String) object.getValue()); Color col = new Color(Integer.decode(colorSerie).intValue()); if (col != null) { orderColorVector.add(col); //colorMap.put(numSerie,col); } } } //reading filter style if present SourceBean sbSerieStyle = (SourceBean) content.getAttribute("STYLE_SLIDER_AREA"); if (sbSerieStyle == null) { sbSerieStyle = (SourceBean) content.getAttribute("CONF.STYLE_SLIDER_AREA"); } if (sbSerieStyle != null) { List atts = sbSerieStyle.getContainedAttributes(); String StyleValue = ""; for (Iterator iterator = atts.iterator(); iterator.hasNext();) { SourceBeanAttribute object = (SourceBeanAttribute) iterator.next(); String styleLabel = (String) object.getKey(); StyleValue = new String((String) object.getValue()); if (StyleValue != null) { if (styleLabel.equalsIgnoreCase("font")) styleLabel = "font-family"; else if (styleLabel.equalsIgnoreCase("size")) styleLabel = "font-size"; else if (styleLabel.equalsIgnoreCase("color")) styleLabel = "color"; filterStyle += styleLabel + ":" + StyleValue + ";"; } } } // check if there is some serie to be hidden boolean moreHiddenSeries = true; int i = 1; hiddenSeries = new Vector(); while (moreHiddenSeries) { String iS = new Integer(i).toString(); if (confParameters.get("hidden_serie" + iS) != null) { String hiddenSerName = (String) confParameters.get("hidden_serie" + iS); hiddenSeries.add(hiddenSerName); i++; } else moreHiddenSeries = false; } // 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, orientationS); } catch (Exception e) { logger.error("Wrong style labels settings, use default"); } } else { styleValueLabels = defaultLabelsStyle; } seriesNumber = new HashMap(); logger.debug("OUT"); }
From source file:org.kchine.r.server.http.RHttpProxy.java
public static void saveimage(String url, String sessionId) throws TunnelingException { GetMethod getInterrupt = null;// w w w.java 2 s . c om 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"))); } getInterrupt = new GetMethod(url + "?method=saveimage"); try { if (sessionId != null && !sessionId.equals("")) { getInterrupt.getParams().setCookiePolicy(CookiePolicy.IGNORE_COOKIES); getInterrupt.setRequestHeader("Cookie", "JSESSIONID=" + sessionId); } mainHttpClient.executeMethod(getInterrupt); result = new ObjectInputStream(getInterrupt.getResponseBodyAsStream()).readObject(); } catch (ConnectException e) { throw new ConnectionFailedException(); } catch (Exception e) { throw new TunnelingException("", e); } if (result != null && result instanceof TunnelingException) { throw (TunnelingException) result; } } finally { if (getInterrupt != null) { getInterrupt.releaseConnection(); } if (mainHttpClient != null) { } } }
From source file:org.jboss.dashboard.ui.components.DashboardFilterHandler.java
public void actionRefresh(CommandRequest request) throws Exception { String timeOutValue = request.getRequestObject().getParameter("refreshTimeOut"); if (!StringUtils.isBlank(timeOutValue)) { try {/* ww w .j a va 2 s .co m*/ autoRefreshTimeout = Integer.decode(timeOutValue).intValue(); } catch (NumberFormatException e) { log.warn("Cannot parse auto refresh value as a number."); } } getDashboard().refresh(); }