List of usage examples for java.util Vector size
public synchronized int size()
From source file:net.aepik.alasca.plugin.schemaconverter.core.SchemaConverter.java
/** * Retourne l'ensemble des dictionnaires possibles pour la syntaxe * du schma, et en fonction des syntaxes disponibles. **//* w w w . j a v a2 s . co m*/ public String[] getAvailableDictionnaries() { String[] result = null; Vector<String> resultTmp = new Vector<String>(); // On rcupre aussi l'ensemble des dictionnaires disponibles dans le // traducteur. On boucle sur chaque entres de cette liste. String[] dictionnaries = traduc.getAvailableDictionnaries(); for (String currentDictionnary : dictionnaries) { if (getAvailableSyntaxes(currentDictionnary) != null) resultTmp.add(currentDictionnary); } result = new String[resultTmp.size()]; Iterator<String> it = resultTmp.iterator(); int compteur = 0; while (it.hasNext()) { result[compteur] = it.next(); compteur++; } return result; }
From source file:charts.Chart.java
public static void Histogram(Vector data, int maxvalue, String net) { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); int i = 0;/*from w w w. jav a 2s .c o m*/ int[] degree = new int[maxvalue];//guarda o grau de cada no int value = 0; for (i = 0; i < data.size(); i++) { value = (Integer) data.get(i); degree[value]++;//determina o grau de cada no == quantas vezes ele apareceu na lista. } int max = Maximum(degree);//pega o grau maximo para gerar o histograma int[] vethistogram = new int[max + 1]; for (i = 0; i < degree.length; i++) { vethistogram[degree[i]]++;//para cada ocorrencia do grau, soma um na sua posicao do histograma. } //codigo para gerar os dados para o grafico MultipleLineChart XYDataset[] xydatasets = new XYDataset[1]; XYSeries serie = new XYSeries("sample"); XYSeries series2 = new XYSeries("Max Value"); float maxvaluef = maxvalue; for (i = 0; i < max + 1; i++) { float nnos = vethistogram[i]; if (i != 0 && nnos != 0 && net.equalsIgnoreCase("BA")) { serie.add(Math.log(i), Math.log(nnos / maxvaluef)); series2.add(Math.log(i), Math.log(nnos / maxvaluef)); } else if (net.equalsIgnoreCase("ER")) { serie.add(i, nnos / maxvaluef); series2.add(i, nnos / maxvaluef); } //serie.add(i, (nnos/maxvaluef)); dataset.addValue((Number) vethistogram[i], 0, i); //datasets[i].addValue(Md[ lineindex[i] ][c], String.valueOf(c)); } XYSeriesCollection series = new XYSeriesCollection(); series.addSeries(series2); ScatterPlot(series, "Validation Graph - Node Degree Distribution", "log(k)", "log(P(k))"); xydatasets[0] = new XYSeriesCollection(serie); Chart.MultipleLineChart(xydatasets, "Line Chart", "degree", "number of nodes", true, 0, 0); Chart.BarChart(dataset, "Histogram of node degree", "samples", "values", true); }
From source file:ca.uqac.info.trace.generation.RandomTraceGenerator.java
@Override public EventTrace generate() { EventTrace trace = new EventTrace(); // We choose the number of messages to produce int n_messages = super.nextInt(m_maxMessages - m_minMessages) + m_minMessages; for (int i = 0; i < n_messages; i++) { Node n = trace.getNode(); Vector<String> available_params = new Vector<String>(); // We produce the list of available parameters for this message for (int j = 0; j < m_numParameters; j++) available_params.add("p" + j); // We choose the number of param-value pairs to generate int arity = super.nextInt(m_maxArity - m_minArity) + m_minArity; for (int j = 0; j < arity; j++) { // We generate as many param-value pairs as required int index = super.nextInt(available_params.size()); int value = super.nextInt(m_domainSize); if (m_minArity == 1 && m_maxArity == 1 && m_flatten) { // For traces of messages with fixed arity = 1, we // simply put the value as the text child of the "Event" // element n.appendChild(trace.createTextNode(new Integer(value).toString())); } else { Node el = trace.createElement("p" + index); el.appendChild(trace.createTextNode(new Integer(value).toString())); n.appendChild(el);// www.jav a2 s . c om if (!m_isMultiValued) { // If event should not be multi-valued, then we remove // the chosen parameter from the list of available choices available_params.removeElementAt(index); } } } Event e = new Event(n); trace.add(e); } return trace; }
From source file:agentlogfileanalyzer.histogram.AbstractHistogram.java
/** * Returns a panel containing a histogram. The data displayed in the * histogram is given as parameter. Data not inside the given limits is * discarded./*from w w w . j a va 2s. c om*/ * * @param _histogramData * the data displayed in the histogram * @param _lowerLimit * the lower limit that was entered by the user * @param _upperLimit * the upper limit that was entered by the user * @return a <code>JPanel</code> containing the histogram */ JPanel createHistogram(Vector<Double> _histogramData, double _lowerLimit, double _upperLimit) { // Remove values outside the given limits... Vector<Double> vectorHistogramDataWithinLimits = new Vector<Double>(); for (Iterator<Double> iterator = _histogramData.iterator(); iterator.hasNext();) { double d = ((Double) iterator.next()).doubleValue(); if (valueWithinLimits(d, _lowerLimit, _upperLimit)) { vectorHistogramDataWithinLimits.add(d); } } // Store number of elements shown in histogram... this.numberOfVisibleClassifiers = vectorHistogramDataWithinLimits.size(); // Convert vector to array... double[] arrayHistogramDataWithinLimits = new double[vectorHistogramDataWithinLimits.size()]; for (int i = 0; i < vectorHistogramDataWithinLimits.size(); i++) { double d = vectorHistogramDataWithinLimits.get(i).doubleValue(); arrayHistogramDataWithinLimits[i] = d; } if (arrayHistogramDataWithinLimits.length > 0) { // Create // histogram... HistogramDataset data = new HistogramDataset(); data.addSeries("Suchwert", // key arrayHistogramDataWithinLimits, // data Math.max(100, arrayHistogramDataWithinLimits.length) // #bins ); JFreeChart chart = ChartFactory.createHistogram(description, // title description, // x axis label "frequency", // y axis label data, // data PlotOrientation.VERTICAL, // orientation false, // legend true, // tooltips false // URL ); return new ChartPanel(chart); } else { return createErrorPanel("No data available (within the given limits)."); } }
From source file:net.aepik.alasca.gui.util.LoadFileFrame.java
/** * Load a file./*from www .ja v a 2s . co m*/ */ public boolean loadFile(String filename, String syntaxe) { if (!(new File(filename)).exists()) { this.errorMessage = "Le fichier n'existe pas."; return false; } try { SchemaSyntax syntax = Schema.getSyntax(syntaxe); SchemaFile schemaFile = Schema.createAndLoad(syntax, filename, true); Schema schema = schemaFile.getSchema(); if (schema == null) { String message = ""; if (schemaFile.isError()) { message += "\n\n" + "Line " + schemaFile.getErrorLine() + ":\n" + schemaFile.getErrorMessage(); } this.errorMessage = "Le format du fichier est incorrect." + message; return false; } if (manager.isSchemaIdExists((new File(filename)).getName())) { this.errorMessage = "Le fichier est dj ouvert."; return false; } Vector<String> files = Pref.getVector(Pref.PREF_LASTOPENFILES); Vector<String> syntaxes = Pref.getVector(Pref.PREF_LASTOPENSYNTAXES); int index = files.indexOf(filename); if (index >= 0) { files.removeElementAt(index); syntaxes.removeElementAt(index); } files.add(filename); syntaxes.add(syntaxe); if (files.size() > 10) { files.removeElementAt(0); syntaxes.removeElementAt(0); } Pref.set(Pref.PREF_LASTOPENFILES, files.toArray(new String[0])); Pref.set(Pref.PREF_LASTOPENSYNTAXES, syntaxes.toArray(new String[0])); manager.addSchema((new File(filename)).getName(), schema); } catch (Exception e) { e.printStackTrace(); this.errorMessage = "Une erreur inattendue est survenue."; return false; } return true; }
From source file:kenh.expl.impl.ExpLParser.java
/** * Get the parameters for function, use ',' to split each parameter. * @param parameter/*from w w w. jav a2 s. c om*/ * @return */ private static String[] splitParameter(String parameter) throws UnsupportedExpressionException { Vector<String> params = new Vector(); StringBuffer param = new StringBuffer(); int count = 0; for (int scan = 0; scan < parameter.length(); scan++) { char c = parameter.charAt(scan); if (c == ',') { if (count > 0) { param.append(c); } else { params.add(param.toString()); param = new StringBuffer(); } } else if (c == '{') { count++; param.append(c); } else if (c == '}') { count--; param.append(c); if (count < 0) { UnsupportedExpressionException e = new UnsupportedExpressionException("Missing '{'."); e.push(parameter); throw e; } } else { param.append(c); } } if (count > 0) { UnsupportedExpressionException e = new UnsupportedExpressionException("Missing '}'."); e.push(parameter); throw e; } String lastParam = param.toString(); if (params.size() == 0 && lastParam.equals("")) { // '()' only, mean no parameter } else { params.add(lastParam); } return params.toArray(new String[] {}); }
From source file:fr.gouv.finances.cp.xemelios.importers.batch.BatchRealImporter.java
private ImportContent files(final String extension, final String titreEtat) { ImportContent ic = new ImportContent(); Vector<File> ret = new Vector<File>(); ret.addAll(files);//ww w . j a v a 2 s . co m // on regarde si l'un des fichiers a importer est un zip for (int i = 0; i < ret.size(); i++) { if (ret.get(i).getName().toLowerCase().endsWith(".zip")) { if (ret.get(i).exists()) { ZipFile zf = null; try { zf = new ZipFile(ret.get(i)); for (Enumeration<? extends ZipEntry> enumer = zf.entries(); enumer.hasMoreElements();) { ZipEntry ze = enumer.nextElement(); if (!ze.isDirectory()) { String fileName = ze.getName(); String entryName = fileName.toLowerCase(); fileName = fileName.replace(File.pathSeparatorChar, '_') .replace(File.separatorChar, '_').replace(':', '|').replace('\'', '_') .replace('/', '_'); logger.debug(entryName); if (PJRef.isPJ(ze)) { PJRef pj = new PJRef(ze); File tmpFile = pj.writeTmpFile(FileUtils.getTempDir(), zf); ic.pjs.add(pj); filesToDrop.add(tmpFile); } else if ((entryName.endsWith(extension.toLowerCase()) || entryName.endsWith(".xml")) && !fileName.startsWith("_")) { // on decompresse le fichier dans le // repertoire temporaire, comme ca il sera // supprime en quittant InputStream is = zf.getInputStream(ze); BufferedInputStream bis = new BufferedInputStream(is); File output = new File(FileUtils.getTempDir(), fileName); BufferedOutputStream bos = new BufferedOutputStream( new FileOutputStream(output)); byte[] buffer = new byte[1024]; int read = bis.read(buffer); while (read > 0) { bos.write(buffer, 0, read); read = bis.read(buffer); } bos.flush(); bos.close(); bis.close(); ic.filesToImport.add(output); filesToDrop.add(output); } } } zf.close(); } catch (ZipException zEx) { System.out.println( "Le fichier " + ret.get(i).getName() + " n'est pas une archive ZIP valide."); } catch (IOException ioEx) { ioEx.printStackTrace(); } finally { if (zf != null) { try { zf.close(); } catch (Throwable t) { } } } } } else if (ret.get(i).getName().toLowerCase().endsWith(".gz")) { try { String fileName = ret.get(i).getName(); fileName = fileName.substring(0, fileName.length() - 3); File output = new File(FileUtils.getTempDir(), fileName); GZIPInputStream gis = new GZIPInputStream(new FileInputStream(ret.get(i))); BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(output)); byte[] buffer = new byte[1024]; int read = gis.read(buffer); while (read > 0) { bos.write(buffer, 0, read); read = gis.read(buffer); } bos.flush(); bos.close(); gis.close(); ic.filesToImport.add(output); filesToDrop.add(output); } catch (IOException ioEx) { // nothing to do } } else { ic.filesToImport.add(ret.get(i)); // dans ce cas l, on ne le supprime pas } } return ic; }
From source file:edu.ku.brc.specify.tasks.subpane.wb.ConfigureXLS.java
@Override protected void nonInteractiveConfig() { try {/*from w ww. j a va 2 s . c o m*/ InputStream input = new FileInputStream(externalFile); POIFSFileSystem fs = new POIFSFileSystem(input); HSSFWorkbook workBook = new HSSFWorkbook(fs); HSSFSheet sheet = workBook.getSheetAt(0); // Calculate the number of rows and columns colInfo = new Vector<ImportColumnInfo>(16); Hashtable<Integer, Boolean> colTracker = new Hashtable<Integer, Boolean>(); boolean firstRow = true; int col = 0; colTracker.clear(); Vector<Integer> badHeads = new Vector<Integer>(); Vector<Integer> emptyCols = new Vector<Integer>(); checkHeadsAndCols(sheet, badHeads, emptyCols); if (firstRowHasHeaders && badHeads.size() > 0) { status = ConfigureExternalDataIFace.Status.Error; showBadHeadingsMsg(badHeads, null, getResourceString("Error")); return; } // Iterate over each row in the sheet @SuppressWarnings("unchecked") Iterator<HSSFRow> rows = sheet.rowIterator(); while (rows.hasNext()) { HSSFRow row = rows.next(); if (firstRow || numRows == 1) { // Iterate over each cell in the row and print out the cell's content int colNum = 0; int maxSize = Math.max(row.getPhysicalNumberOfCells(), row.getLastCellNum()); while (colNum < maxSize) { if (emptyCols.indexOf(new Integer(colNum)) == -1) { ImportColumnInfo.ColumnType disciplinee = ImportColumnInfo.ColumnType.Integer; String value = null; boolean skip = false; HSSFCell cell = row.getCell(colNum); if (cell == null) { //assuming numRows == 1 or not firstRowHasHeaders. //the call to checkHeadsAndCols would have already blank headers. value = ""; disciplinee = ImportColumnInfo.ColumnType.String; } else switch (cell.getCellType()) { case HSSFCell.CELL_TYPE_NUMERIC: double numeric = cell.getNumericCellValue(); value = Double.toString(numeric); disciplinee = ImportColumnInfo.ColumnType.Double; break; case HSSFCell.CELL_TYPE_STRING: HSSFRichTextString richVal = cell.getRichStringCellValue(); value = richVal.getString().trim(); disciplinee = ImportColumnInfo.ColumnType.String; break; case HSSFCell.CELL_TYPE_BLANK: value = ""; disciplinee = ImportColumnInfo.ColumnType.String; break; case HSSFCell.CELL_TYPE_BOOLEAN: boolean bool = cell.getBooleanCellValue(); value = Boolean.toString(bool); disciplinee = ImportColumnInfo.ColumnType.Boolean; break; default: skip = true; break; } if (numRows == 1 && !skip) { colInfo.get(col).setData(value); col++; } else if (!skip) { if (firstRowHasHeaders) { colInfo.add(new ImportColumnInfo(colNum, disciplinee, value, value, null, null, null)); colTracker.put(col, true); } else { String colName = getResourceString("DEFAULT_COLUMN_NAME") + " " + (colNum + 1); colInfo.add(new ImportColumnInfo(colNum, disciplinee, colName, colName, null, null, null)); colTracker.put(colNum, true); } numCols++; } } colNum++; } firstRow = false; } numRows++; } Collections.sort(colInfo); readMappings(fs); status = Status.Valid; } catch (IOException ex) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(ConfigureXLS.class, ex); status = Status.Error; } }
From source file:com.madrobot.net.client.XMLRPCClient.java
/** * Convenience method call with a vectorized parameter (Code contributed by jahbromo from issue #14) * /*from w ww. j ava 2s . co m*/ * @param method * name of method to call * @param paramsv * vector of method's parameter * @return deserialized method return value * @throws XMLRPCException */ public Object call(String method, Vector paramsv) throws XMLRPCException { Object[] params = new Object[paramsv.size()]; for (int i = 0; i < paramsv.size(); i++) { params[i] = paramsv.elementAt(i); } return callEx(method, params); }
From source file:com.naryx.tagfusion.cfm.xml.ws.javaplatform.DynamicWebServiceStubGenerator.java
private StubInfo.Operation[] findOperations(Parser wsdlParser, Port port) { SymbolTable symbolTable = wsdlParser.getSymbolTable(); BindingEntry bEntry = symbolTable.getBindingEntry(port.getBinding().getQName()); Set opSet = bEntry.getParameters().keySet(); Iterator itr = opSet.iterator(); StubInfo.Operation[] siOps = new StubInfo.Operation[opSet.size()]; for (int i = 0; itr.hasNext(); i++) { // Get the operation and add the parameters Operation op = (Operation) itr.next(); Vector parms = bEntry.getParameters(op).list; // Populate the parms StubInfo.Parameter[] siParms = new StubInfo.Parameter[parms.size()]; StubInfo.Operation siOp = new StubInfo.Operation(op.getName(), siParms); siOps[i] = siOp;/* w w w . j a v a 2 s. com*/ Iterator tmpItr = parms.iterator(); for (int j = 0; tmpItr.hasNext(); j++) { Parameter p = (Parameter) tmpItr.next(); siParms[j] = new StubInfo.Parameter(p.getName(), p.isNillable(), p.isOmittable()); } // If there is only 1 parameter and it's a complex object, // gather parameter information for its properties. if (parms.size() == 1) { Vector elems = ((Parameter) parms.get(0)).getType().getContainedElements(); if (elems != null && !elems.isEmpty()) { StubInfo.Parameter[] siSubParms = new StubInfo.Parameter[elems.size()]; tmpItr = elems.iterator(); for (int j = 0; tmpItr.hasNext(); j++) { ElementDecl e = (ElementDecl) tmpItr.next(); siSubParms[j] = new StubInfo.Parameter(e.getName(), e.getNillable(), e.getMinOccursIs0()); } siOp.setSubParameters(siSubParms); } } } // Return the operations return siOps; }