List of usage examples for java.lang Integer decode
public static Integer decode(String nm) throws NumberFormatException
From source file:org.jboss.dashboard.workspace.export.WorkspaceBuilder.java
protected void createSection(CreateResult result, WorkspaceImpl workspace, XMLNode node, Map attributes, boolean onStartup) throws Exception { String id = node.getAttributes().getProperty(ExportVisitor.SECTION_ATTR_ID); String idTemplate = node.getAttributes().getProperty(ExportVisitor.SECTION_ATTR_ID_TEMPLATE); String position = node.getAttributes().getProperty(ExportVisitor.SECTION_ATTR_POSITION); String visible = node.getAttributes().getProperty(ExportVisitor.SECTION_ATTR_VISIBLE); String regionSpacing = node.getAttributes().getProperty(ExportVisitor.SECTION_ATTR_REGIONSPACING); String panelSpacing = node.getAttributes().getProperty(ExportVisitor.SECTION_ATTR_PANELSPACING); String parentId = node.getAttributes().getProperty(ExportVisitor.SECTION_ATTR_PARENT_ID); String friendlyUrl = node.getAttributes().getProperty(ExportVisitor.SECTION_ATTR_FR_URL); String idSkin = node.getAttributes().getProperty(ExportVisitor.SECTION_ATTR_SKIN_ID); String idEnvelope = node.getAttributes().getProperty(ExportVisitor.SECTION_ATTR_ENVELOPE_ID); Section section = new Section(); section.setId(Long.decode(id)); section.setLayoutId(idTemplate);//from w ww .j a va 2 s. c o m section.setPosition(Integer.decode(position).intValue()); section.setVisible(Boolean.valueOf(visible)); section.setRegionsCellSpacing(Integer.decode(regionSpacing)); section.setPanelsCellSpacing(Integer.decode(panelSpacing)); if (parentId != null) section.setParentSectionId(Long.decode(parentId)); section.setFriendlyUrl(friendlyUrl); section.setSkinId(idSkin); section.setEnvelopeId(idEnvelope); section.setWorkspace(workspace); UIServices.lookup().getSectionsManager().store(section); workspace.addSection(section); UIServices.lookup().getWorkspacesManager().store(workspace); //Children for (int i = 0; i < node.getChildren().size(); i++) { XMLNode child = (XMLNode) node.getChildren().get(i); if (ExportVisitor.PARAMETER.equals(child.getObjectName())) { String name = child.getAttributes().getProperty(ExportVisitor.PARAMETER_ATTR_NAME); if (ExportVisitor.SECTION_CHILD_TITLE.equals(name)) { String value = child.getAttributes().getProperty(ExportVisitor.PARAMETER_ATTR_VALUE); String lang = child.getAttributes().getProperty(ExportVisitor.PARAMETER_ATTR_LANG); section.setTitle(value, lang); } } else if (ExportVisitor.RESOURCE.equals(child.getObjectName())) { createResource(result, workspace.getId(), section.getId(), null, child, attributes, onStartup); } else if (ExportVisitor.PANEL.equals(child.getObjectName())) { createPanel(result, section, child, attributes, onStartup); } else if (ExportVisitor.PERMISSION.equals(child.getObjectName())) { createPermission(result, section.getWorkspace(), section, child, attributes); } } }
From source file:fr.dutra.confluence2wordpress.core.settings.DefaultPluginSettingsManager.java
private synchronized void createClient() { try {/*from www .ja v a2 s .co m*/ URL url = new URL(getWordpressXmlRpcUrl()); WordpressConnection wordpressConnection = new WordpressConnection(url, getWordpressUserName(), getWordpressPassword(), getWordpressBlogId(), Integer.parseInt(getWordpressMaxConnections())); wordpressConnection.setProxyHost(getProxyHost()); wordpressConnection .setProxyPort(StringUtils.isEmpty(getProxyPort()) ? null : Integer.decode(getProxyHost())); this.client = new WordpressClient(wordpressConnection); } catch (MalformedURLException e) { //this has been validated previously } }
From source file:it.eng.spagobi.engines.chart.bo.charttypes.scattercharts.ScatterCharts.java
/** * Calculates chart value;/*from www. j ava 2s .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"; } //reading default color if present if (confParameters.get("default_color") != null) { defaultColor = (String) confParameters.get("default_color"); } else { defaultColor = ""; } //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 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); } } } //reading annotations choice if present if (confParameters.get("view_annotation") != null) { viewAnnotations = (String) confParameters.get("view_annotation"); } else { viewAnnotations = ""; } logger.debug("OUT"); }
From source file:marytts.server.MaryProperties.java
/** * Get an integer property from the underlying properties, throwing an exception if * it is not defined. //from www . ja v a2s.co m * @param property the property requested * @return the integer property value * @throws NoSuchPropertyException if the property is not defined. */ public static int needInteger(String property) throws NoSuchPropertyException { String value = getProperty(property); if (value == null) { throw new NoSuchPropertyException("Missing property `" + property + "' in configuration files"); } try { return Integer.decode(value).intValue(); } catch (NumberFormatException e) { throw new NoSuchPropertyException( "Integer property `" + property + "' in configuration files has wrong value `" + value + "'"); } }
From source file:org.kchine.r.server.http.RHttpProxy.java
public static void interrupt(String url, String sessionId) throws TunnelingException { GetMethod getInterrupt = null;/* w ww . j a v a2 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=interrupt"); 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:jenkins.util.SystemProperties.java
/** * Determines the integer value of the system property with the * specified name, or a default value.//from w ww.j av a 2 s .com * * This behaves just like <code>Integer.getInteger(String,Integer)</code>, except that it * also consults the <code>ServletContext</code>'s "init" parameters. If neither exist, * return the default value. * * @param name property name. * @param def a default value. * @param logLevel the level of the log if the provided system property name cannot be decoded into Integer. * @return the {@code Integer} value of the property. * If the property is missing, return the default value. * Result may be {@code null} only if the default value is {@code null}. */ public static Integer getInteger(String name, Integer def, Level logLevel) { String v = getString(name); if (v != null) { try { return Integer.decode(v); } catch (NumberFormatException e) { // Ignore, fallback to default if (LOGGER.isLoggable(logLevel)) { LOGGER.log(logLevel, "Property. Value is not integer: {0} => {1}", new Object[] { name, v }); } } } return def; }
From source file:it.geosolutions.geobatch.opensdi.ndvi.NDVIStatsAction.java
/** * Generate CSV file with the parameters * /* w w w . j a v a2 s .c om*/ * @param coverage tiff file to use in stats * @param fc zones to obtain the NDVI * @param classifier * @param mask * @param ndviFileName * @param csvSeparator * @param maskFullPath * * @throws Exception */ private void generateCSV(GridCoverage2D coverage, SimpleFeatureCollection fc, CLASSIFIER_TYPE classifier, MASK_TYPE mask, String ndviFileName, String csvSeparator, String maskFullPath) throws Exception { // Prepare for CSV generation String csvPath = getCSVFullPath(classifier, mask, ndviFileName); // obtain header List<String> header = getHeader(classifier); // values String year = ""; String month = ""; String dekad = ""; String factor = "NDVI_avg"; String distr = ""; String prov = ""; // Obtain year, month, decad from the name of the file: // dv_20130101_20130110.tif year = ndviFileName.substring(3, 7); month = ndviFileName.substring(7, 9); // Remove "0" if (month.startsWith("0")) { month = month.replace("0", ""); } month = getMonthName(Integer.decode(month)); dekad = ndviFileName.substring(9, 11); dekad = dekad.equals("01") ? "1" : dekad.equals("11") ? "2" : "3"; @SuppressWarnings("unchecked") Set<Object[]> data = new ListOrderedSet(); data.add(header.toArray()); int i = 1; List<FeatureAggregation> result = new ArrayList<FeatureAggregation>(); // only one band int[] bands = new int[] { 0 }; StatsType[] stats = new StatsType[] { StatsType.MEAN }; // get the world to grid transformation final GridGeometry2D gg2D = coverage.getGridGeometry(); final MathTransform worldToGrid = gg2D.getGridToCRS(PixelInCell.CELL_CORNER).inverse(); final CoordinateReferenceSystem rasterCRS = gg2D.getCoordinateReferenceSystem(); // ROI for the MASK in raster space final ROIGeometry maskROI = getROIMask(mask, worldToGrid, rasterCRS, maskFullPath); // getting the ROI in raster space for the zones final List<ROI> zonesROI = new ArrayList<ROI>(); SimpleFeatureIterator iterator = null; // Selection of the FeatureCollection CoordinateReferenceSystem final CoordinateReferenceSystem featureCollectionCRS = fc.getSchema().getCoordinateReferenceSystem(); if (featureCollectionCRS == null) { throw new IllegalArgumentException("The input features need a CRS"); } // do we need to reproject? if (!CRS.equalsIgnoreMetadata(rasterCRS, featureCollectionCRS)) { // create a transformation final MathTransform transform = CRS.findMathTransform(featureCollectionCRS, rasterCRS, true);// lenient tranformation if (!transform.isIdentity()) { // reproject fc = new ReprojectProcess().execute(fc, featureCollectionCRS, rasterCRS); } } // Cycle on the features for creating a list of geometries try { iterator = fc.features(); listenerForwarder.progressing(1f, "Classifing zones..."); while (iterator.hasNext()) { SimpleFeature feature = iterator.next(); // zones ROI ROI transformedROI = new ROIGeometry( JTS.transform((Geometry) feature.getDefaultGeometry(), worldToGrid)); zonesROI.add(transformedROI); // CSV Data if (CLASSIFIER_TYPE.DISTRICT.equals(classifier) || CLASSIFIER_TYPE.PROVINCE.equals(classifier)) { prov = feature.getProperty("province").getValue().toString(); } if (CLASSIFIER_TYPE.DISTRICT.equals(classifier)) { distr = feature.getProperty("district").getValue().toString(); } Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put("rowId", i++); parameters.put("year", year); parameters.put("mon", month); parameters.put("dec", dekad); parameters.put("factor", factor); parameters.put("prov", prov); parameters.put("distr", distr); // parameters.put("NDVI_avg", avg.toString()); FeatureAggregation featureAgregation = new FeatureAggregation(parameters, header, ",", true); result.add(featureAgregation); } listenerForwarder.progressing(10f, ("Found " + result.size() + " zones for statistic generation")); } finally { if (iterator != null) iterator.close(); if (dbStore != null) { dbStore.dispose(); } } // Definition of the ZonalStats operation listenerForwarder.progressing(15f, "Zonal statistics"); RenderedOp op = ZonalStatsDescriptor.create(coverage.getRenderedImage(), null, null, zonesROI, null, maskROI, false, bands, stats, null, null, null, null, false, null); // Calculation of the ZonalStats property @SuppressWarnings("unchecked") List<ZoneGeometry> statsResult = (List<ZoneGeometry>) op.getProperty(ZonalStatsDescriptor.ZS_PROPERTY); int index = 0; listenerForwarder.progressing(90f, "Result Post Processing"); for (ZoneGeometry statResult : statsResult) { FeatureAggregation featureAgregation = result.get(index++); Double mean = (Double) statResult.getStatsPerBandNoClassifierNoRange(0)[0].getResult(); // If the mean is 0, then no calculations are performed if (mean != 0.0) { // apply NDVI: Physical value = pixel value*0.004 - 0.1 Double ndvi = (mean * 0.004) - 0.1; featureAgregation.getProperties().put("NDVI_avg", ndvi.toString()); if (mean > 0.0) { // include data data.add(featureAgregation.toRow()); } else { // log error: the mean shouldn't be never less than 0 LOGGER.error("Zonal statistics corrupted not included for: " + featureAgregation.toRow()); } } } File csv = new File(csvPath); listenerForwarder.progressing(95f, "writing output file..."); CSVWriter.writeCsv(LOGGER, data, csv, csvSeparator, true); listenerForwarder.progressing(100f, "output file " + csvPath + " generated successfully!"); }
From source file:org.jaxygen.http.HttpRequestParser.java
@Override public List<Integer> getAsListOfInt(String listName) throws InvalidRequestParameter { Vector<Integer> rc = new Vector<Integer>(); List<String> sl = getIndexedList(request, listName); for (String s : sl) { if (s != null) { rc.add(Integer.decode(s)); }/*from w ww. j av a 2s. c o m*/ } return rc; }
From source file:it.eng.spagobi.engines.chart.bo.charttypes.scattercharts.MarkerScatter.java
public JFreeChart createChart(DatasetMap datasets) { DefaultXYDataset dataset = (DefaultXYDataset) datasets.getDatasets().get("1"); JFreeChart chart = ChartFactory.createScatterPlot(name, yLabel, xLabel, dataset, PlotOrientation.HORIZONTAL, false, true, false);/*from ww w . j av a 2 s. c o m*/ TextTitle title = setStyleTitle(name, styleTitle); chart.setTitle(title); chart.setBackgroundPaint(Color.white); if (subName != null && !subName.equals("")) { TextTitle subTitle = setStyleTitle(subName, styleSubTitle); chart.addSubtitle(subTitle); } XYPlot plot = (XYPlot) chart.getPlot(); plot.setForegroundAlpha(0.65f); XYItemRenderer renderer = plot.getRenderer(); //defines colors int seriesN = dataset.getSeriesCount(); if ((colorMap != null && colorMap.size() > 0) || (defaultColor != null && !defaultColor.equals(""))) { for (int i = 0; i < seriesN; i++) { String serieName = (String) dataset.getSeriesKey(i); Color color = new Color(Integer.decode(defaultColor).intValue()); if (colorMap != null && colorMap.size() > 0) color = (Color) colorMap.get(serieName); if (color != null) renderer.setSeriesPaint(i, color); } } // add un interval marker for the Y axis... if (yMarkerStartInt != null && yMarkerEndInt != null && !yMarkerStartInt.equals("") && !yMarkerEndInt.equals("")) { Marker intMarkerY = new IntervalMarker(Double.parseDouble(yMarkerStartInt), Double.parseDouble(yMarkerEndInt)); intMarkerY.setLabelOffsetType(LengthAdjustmentType.EXPAND); intMarkerY.setPaint( new Color(Integer.decode((yMarkerIntColor.equals("")) ? "0" : yMarkerIntColor).intValue())); //intMarkerY.setLabel(yMarkerLabel); intMarkerY.setLabelAnchor(RectangleAnchor.BOTTOM_RIGHT); intMarkerY.setLabelTextAnchor(TextAnchor.TOP_RIGHT); plot.addDomainMarker(intMarkerY, Layer.BACKGROUND); } // add un interval marker for the X axis... if (xMarkerStartInt != null && xMarkerEndInt != null && !xMarkerStartInt.equals("") && !xMarkerEndInt.equals("")) { Marker intMarkerX = new IntervalMarker(Double.parseDouble(xMarkerStartInt), Double.parseDouble(xMarkerEndInt)); intMarkerX.setLabelOffsetType(LengthAdjustmentType.EXPAND); intMarkerX.setPaint( new Color(Integer.decode((xMarkerIntColor.equals("")) ? "0" : xMarkerIntColor).intValue())); //intMarkerX.setLabel(xMarkerLabel); intMarkerX.setLabelAnchor(RectangleAnchor.BOTTOM_RIGHT); intMarkerX.setLabelTextAnchor(TextAnchor.TOP_RIGHT); plot.addRangeMarker(intMarkerX, Layer.BACKGROUND); } // add a labelled marker for the Y axis... if (yMarkerValue != null && !yMarkerValue.equals("")) { Marker markerY = new ValueMarker(Double.parseDouble(yMarkerValue)); markerY.setLabelOffsetType(LengthAdjustmentType.EXPAND); if (!yMarkerColor.equals("")) markerY.setPaint(new Color(Integer.decode(yMarkerColor).intValue())); markerY.setLabel(yMarkerLabel); markerY.setLabelFont(new Font("Arial", Font.BOLD, 11)); markerY.setLabelAnchor(RectangleAnchor.TOP_RIGHT); markerY.setLabelTextAnchor(TextAnchor.TOP_RIGHT); plot.addDomainMarker(markerY, Layer.BACKGROUND); } // add a labelled marker for the X axis... if (xMarkerValue != null && !xMarkerValue.equals("")) { Marker markerX = new ValueMarker(Double.parseDouble(xMarkerValue)); markerX.setLabelOffsetType(LengthAdjustmentType.EXPAND); if (!xMarkerColor.equals("")) markerX.setPaint(new Color(Integer.decode(xMarkerColor).intValue())); markerX.setLabel(xMarkerLabel); markerX.setLabelAnchor(RectangleAnchor.BOTTOM_RIGHT); markerX.setLabelTextAnchor(TextAnchor.TOP_RIGHT); plot.addRangeMarker(markerX, Layer.BACKGROUND); } if (xRangeLow != null && !xRangeLow.equals("") && xRangeHigh != null && !xRangeHigh.equals("")) { if (Double.valueOf(xRangeLow).doubleValue() > xMin) xRangeLow = String.valueOf(xMin); if (Double.valueOf(xRangeHigh).doubleValue() < xMax) xRangeHigh = String.valueOf(xMax); ValueAxis rangeAxis = plot.getRangeAxis(); //rangeAxis.setRange(Double.parseDouble(xRangeLow), Double.parseDouble(xRangeHigh)); rangeAxis.setRangeWithMargins(Double.parseDouble(xRangeLow), Double.parseDouble(xRangeHigh)); } else { NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setAutoRange(true); rangeAxis.setRange(xMin, xMax); } if (yRangeLow != null && !yRangeLow.equals("") && yRangeHigh != null && !yRangeHigh.equals("")) { if (Double.valueOf(yRangeLow).doubleValue() > yMin) yRangeLow = String.valueOf(yMin); if (Double.valueOf(yRangeHigh).doubleValue() < yMax) yRangeHigh = String.valueOf(yMax); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); //domainAxis.setRange(Double.parseDouble(yRangeLow), Double.parseDouble(yRangeHigh)); domainAxis.setRangeWithMargins(Double.parseDouble(yRangeLow), Double.parseDouble(yRangeHigh)); domainAxis.setAutoRangeIncludesZero(false); } else { NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setAutoRange(true); domainAxis.setRange(yMin, yMax); domainAxis.setAutoRangeIncludesZero(false); } //add annotations if requested if (viewAnnotations != null && viewAnnotations.equalsIgnoreCase("true")) { if (annotationMap == null || annotationMap.size() == 0) logger.error("Annotations on the chart are requested but the annotationMap is null!"); else { int cont = 1; for (Iterator iterator = annotationMap.keySet().iterator(); iterator.hasNext();) { String text = (String) iterator.next(); String pos = (String) annotationMap.get(text); double x = Double.parseDouble(pos.substring(0, pos.indexOf("__"))); double y = Double.parseDouble(pos.substring(pos.indexOf("__") + 2)); //default up position XYTextAnnotation annotation = new XYTextAnnotation(text, y - 1, x + ((text.length() > 20) ? text.length() / 3 + 1 : text.length() / 2 + 1)); if (cont % 2 != 0) //dx annotation = new XYTextAnnotation(text, y, x + ((text.length() > 20) ? text.length() / 3 + 1 : text.length() / 2 + 1)); else //sx //annotation = new XYTextAnnotation(text, y, x-((text.length()%2==0)?text.length():text.length()-1)); annotation = new XYTextAnnotation(text, y, x - (text.length() - 1)); annotation.setFont(new Font("SansSerif", Font.PLAIN, 11)); //annotation.setRotationAngle(Math.PI / 4.0); annotation.setRotationAngle(0.0); // horizontal plot.addAnnotation(annotation); cont++; } renderer.setShape(new Ellipse2D.Double(-3, -5, 8, 8)); } } else if (viewAnnotations != null && viewAnnotations.equalsIgnoreCase("false")) { renderer.setShape(new Ellipse2D.Double(-3, -5, 8, 8)); } if (legend == true) { drawLegend(chart); } return chart; }