List of usage examples for java.util Vector size
public synchronized int size()
From source file:edu.umn.cs.sthadoop.hdfs.KNNJoin.java
public static void serializeText(Text t, Vector<Partition> partitions) throws IOException, InterruptedException { byte[] bytes = ("&" + partitions.get(0).filename).getBytes(); t.append(bytes, 0, bytes.length);/*from w w w.j a va2 s.c om*/ for (int i = 1; i < partitions.size(); i++) { bytes = ("#" + partitions.get(i).filename).getBytes(); t.append(bytes, 0, bytes.length); } }
From source file:core.PlanC.java
private static void initEnviorement() { try {//from w ww .j av a 2 s . c o m connectToLocalDB(); TSplash splash = new TSplash(); // connection a perfiles de datos DBAccess dba = ConnectionManager.getAccessTo("t_connections"); Vector v = dba.search(null, null); Properties prps = new Properties(); for (int i = 0; i < v.size(); i++) { Record r = (Record) v.elementAt(i); // for planc: save the conection user as master user if (r.getFieldValue("t_cnname").equals("SleOracle")) { Session.setMasterUser((String) r.getFieldValue("t_cnuser")); // 1823: override fields value from table values to values stored in jdbc.properties file String[] rp = PUserLogIn.getJdbcProperties("jdbc.username", "jdbc.password", "jdbc.url"); r.setFieldValue("T_CNUSER", rp[0]); r.setFieldValue("T_CNPASSWORD", rp[1]); r.setFieldValue("T_CNURL", rp[2]); } String pl = (String) r.getFieldValue("T_CNEXTENDED_PRP"); prps.clear(); TStringUtils.parseProperties(pl, prps); String sc = " (" + prps.getProperty("*schema", "") + ")"; String msg = "Connecting to database " + r.getFieldValue("t_cnname") + sc; String ac = prps.getProperty("*autoconnection", ""); SystemLog.info(msg + " with *autoconnection=" + ac); if (!ac.equals("false")) { splash.increment(msg); ConnectionManager.connect(r); } } // update running hardware info splash.increment("Updating instalation info"); // checkInstalation(); // EN ESTE ORDEN splash.increment("Starting download subsystem"); DownloadManager.init(); // patch update need download manager splash.increment("Checking for updates"); // UpdateManager.checkForPTF(); splash.increment("Starting task manager"); TTaskManager.init(); // load plugins MUST BE last splash.increment("Loading plugins"); PluginManager.init(); splash.increment("Configuring general aspect and L&F..."); setContentPane(SIGNIN); splash.dispose(); } catch (Exception e) { SystemLog.logException1(e, true); System.exit(-1); } }
From source file:common.email.MailServiceImpl.java
/** * this method loads email template into StringBuilder * this method sends email using a given template * @param params names of parameters to replace in template * @param values values by whitch to replace names * @param pathToTemplate path to template for email message * @return stringBuilder this email/*w w w . ja va2s.co m*/ * @throws java.io.FileNotFoundException * @throws java.io.IOException */ protected static StringBuilder getMailMsg(Vector<String> params, Vector<String> values, String pathToTemplate) throws FileNotFoundException, IOException { String line = ""; StringBuilder rez = new StringBuilder(); if (params != null && values != null) { BufferedReader read = new BufferedReader( new InputStreamReader(new FileInputStream(pathToTemplate), "UTF-8")); while ((line = read.readLine()) != null) { for (int i = 0; i < params.size(); i++) { line = line.replaceAll(params.get(i), values.get(i)); } rez.append(line); rez.append("\n"); } read.close(); } else { BufferedReader read = new BufferedReader( new InputStreamReader(new FileInputStream(pathToTemplate), "UTF-8")); while ((line = read.readLine()) != null) { rez.append(line); rez.append("\n"); } read.close(); } return rez; }
From source file:it.eng.spagobi.tools.downloadFiles.service.DownloadZipAction.java
/** getSortedArray. * /*from w w w . ja va 2s . co m*/ * @return File[] */ static public final File[] getSortedArray(File directory, String prefix) { File[] allFiles = directory.listFiles(); Vector labelFilesVector = new Vector<File>(); for (int i = 0; i < allFiles.length; i++) { String fileName = allFiles[i].getName(); if (fileName.startsWith(prefix)) { labelFilesVector.add(allFiles[i]); } } if (labelFilesVector.size() == 0) { return null; } // I need an array int j = 0; File[] labelFiles = new File[labelFilesVector.size()]; for (Iterator iterator = labelFilesVector.iterator(); iterator.hasNext();) { File object = (File) iterator.next(); labelFiles[j] = object; j++; } Arrays.sort(labelFiles, new Comparator() { public int compare(final Object o1, final Object o2) { if (((File) o1).lastModified() > ((File) o2).lastModified()) { return +1; } else if (((File) o1).lastModified() < ((File) o2).lastModified()) { return -1; } else { return 0; } } }); return labelFiles; }
From source file:gov.nih.nci.caIMAGE.util.NewDropdownUtil.java
/** * Returns a list of all Gender /*from ww w.ja v a2 s . c o m*/ * Used for submission and search screens * * @return genders * @throws Exception */ private static List getQueryGenderList(HttpServletRequest inRequest, String inAddBlank) throws Exception { log.debug("Entering NewDropdownUtil.getQueryGenderList"); // Get values for dropdown lists for Gender Gender gen = new Gender(); Vector gender = gen.retrieveAllWhere("gender_name IS NOT NULL ORDER BY gender_name"); List<DropdownOption> theReturnList = new ArrayList<DropdownOption>(); for (int j = 0; j < gender.size(); j++) { Gender Gen = (Gender) gender.elementAt(j); if (Gen.getGender_id() != null) { DropdownOption theOption = new DropdownOption(Gen.getGender_name(), Gen.getGender_id().toString()); theReturnList.add(theOption); } } log.debug("Exiting getQueryGenderList.size " + theReturnList.size()); return theReturnList; }
From source file:Main.java
/** * J2ME implementation of String.split(). Is very fragile. * //www . j ava2 s . co m * @param string * @param separator * @return */ public static String[] stringSplit(String string, char separator) { Vector parts = new Vector(); int start = 0; for (int i = 0; i <= string.length(); i++) { if ((i == string.length()) || (string.charAt(i) == separator)) { if (start == i) { // no data between separators parts.addElement(""); } else { // data between separators String part = string.substring(start, i); parts.addElement(part); } // start of next part is the char after this separator start = i + 1; } } // return as array String[] partsArray = new String[parts.size()]; for (int i = 0; i < partsArray.length; i++) { partsArray[i] = (String) parts.elementAt(i); } return partsArray; }
From source file:com.concursive.connect.web.modules.wiki.portlets.main.WikiPortlet.java
public static void populateQueueStats(PortletRequest request, int userId) throws SchedulerException { Scheduler scheduler = PortalUtils.getScheduler(request); Vector<WikiExportBean> queue = (Vector) scheduler.getContext().get(WikiExporterJob.WIKI_EXPORT_ARRAY); Vector<WikiExportBean> available = (Vector) scheduler.getContext() .get(WikiExporterJob.WIKI_AVAILABLE_ARRAY); // Determine where user is in queue int queueValue = 0; int queueCount = 0; for (WikiExportBean bean : queue) { ++queueCount;/*w ww .ja v a2s . com*/ if (bean.getUserId() == userId) { queueValue = queueCount; break; } } int queueTotal = queue.size(); request.setAttribute(QUEUE_VALUE, String.valueOf(queueValue)); request.setAttribute(QUEUE_TOTAL, String.valueOf(queueTotal)); // Provide the user with a list of their exports... ArrayList<WikiExportBean> exportsForUser = new ArrayList<WikiExportBean>(); for (WikiExportBean bean : available) { if (bean.getUserId() == userId) { exportsForUser.add(bean); } } request.setAttribute(EXPORTS_FOR_USER, exportsForUser); }
From source file:Sort.java
/** * This is a generic version of C.A.R Hoare's Quick Sort algorithm. This * will handle vectors that are already sorted, and vectors with duplicate * keys. Equivalent to:// w w w. j av a 2s .c om * * <pre> * QuickSort(v, 0, v.size() - 1); * </pre> * * @param v * A <code>Vector</code> of <code>Ordered</code> items. * @exception ClassCastException * If the vector contains objects that are not * <code>Ordered</code>. */ public static void QuickSort(Vector v) throws ClassCastException { QuickSort(v, 0, v.size() - 1); }
From source file:com.chinamobile.bcbsp.fault.tools.Zip.java
/** * Compress files to *.zip.// ww w . j av a 2 s.co m * @param fileName * file name to compress * @return compressed file. */ public static String compress(String fileName) { String targetFile = null; File sourceFile = new File(fileName); Vector<File> vector = getAllFiles(sourceFile); try { if (sourceFile.isDirectory()) { targetFile = fileName + ".zip"; } else { char ch = '.'; targetFile = fileName.substring(0, fileName.lastIndexOf(ch)) + ".zip"; } BufferedInputStream bis = null; BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(targetFile)); ZipOutputStream zipos = new ZipOutputStream(bos); byte[] data = new byte[BUFFER]; if (vector.size() > 0) { for (int i = 0; i < vector.size(); i++) { File file = vector.get(i); zipos.putNextEntry(new ZipEntry(getEntryName(fileName, file))); bis = new BufferedInputStream(new FileInputStream(file)); int count; while ((count = bis.read(data, 0, BUFFER)) != -1) { zipos.write(data, 0, count); } bis.close(); zipos.closeEntry(); } zipos.close(); bos.close(); return targetFile; } else { File zipNullfile = new File(targetFile); zipNullfile.getParentFile().mkdirs(); zipNullfile.mkdir(); return zipNullfile.getAbsolutePath(); } } catch (IOException e) { LOG.error("[compress]", e); return "error"; } }
From source file:Sort.java
/** * Binary search for an object/*from ww w . ja v a 2s. com*/ * * @param vector * The vector of <code>Ordered</code> objects. * @param ref * The name to search for. * @return The index at which reference was found or is to be inserted. */ public static int bsearch(Vector vector, Ordered ref) { return (bsearch(vector, ref, 0, vector.size() - 1)); }