List of usage examples for java.util Vector get
public synchronized E get(int index)
From source file:net.rim.ejde.internal.model.BlackBerryPropertiesFactory.java
/** * Gets the icons./* w ww . j a v a 2s . com*/ * * @param project * the project * @param iProject * the i project * * @return the icons */ protected static Icon[] getIcons(final Project project, final IProject iProject) { IJavaProject javaProject = JavaCore.create(iProject); final Vector<Icon> newIcons = new Vector<Icon>(); Icon icon = null, rooloverIcon; Vector<File> iconFiles = project.getIcons(); // we only get the first icon if ((iconFiles != null) && (iconFiles.size() > 0)) { final File iconFile = iconFiles.get(0); if (iconFile.exists()) { icon = new Icon(getTargetRelFilePath(iconFile, project, javaProject)); newIcons.add(icon); } } iconFiles = project.getRolloverIcons(); // we only get the first rollover icon if ((iconFiles != null) && (iconFiles.size() > 0)) { final File iconFile = iconFiles.get(0); if (iconFile.exists()) { // If there is only 1 icon it cannot be a focus icon, so set focus status based on existence of first icon rooloverIcon = new Icon(getTargetRelFilePath(iconFile, project, javaProject), Boolean.valueOf(icon != null)); newIcons.add(rooloverIcon); } } return newIcons.toArray(new Icon[newIcons.size()]); }
From source file:com.nec.nsgui.action.cifs.CommonUtil.java
public static String getCurSessionsID(HttpServletRequest request) throws Exception { SessionManager sm = SessionManager.getInstance(); Vector admvec = (Vector) (sm.getActiveSessionsInfo(request).get(NSActionConst.NSUSER_NSADMIN)); Vector viwvec = (Vector) (sm.getActiveSessionsInfo(request).get(NSActionConst.NSUSER_NSVIEW)); String sessionsId = new String(); sessionsId = ""; if (admvec != null) { for (int i = 0; i < admvec.size(); i++) { ClientInfoBean cib = (ClientInfoBean) admvec.get(i); String sid = cib.getSessionId(); sessionsId = sessionsId + sid + " "; }//ww w . j av a 2 s .com } if (viwvec != null) { for (int i = 0; i < viwvec.size(); i++) { ClientInfoBean cib = (ClientInfoBean) viwvec.get(i); String sid = cib.getSessionId(); sessionsId = sessionsId + sid + " "; } } return sessionsId; }
From source file:Main.java
public static void cleanText(Node node) { try {// w w w . j a va 2 s . com NodeList childNodes = node.getChildNodes(); int noChildren = childNodes.getLength(); Node n = null; short type = 0; Vector rem = new Vector(); for (int i = 0; i < noChildren; i++) { n = childNodes.item(i); type = n.getNodeType(); if (type == Node.TEXT_NODE) { rem.add(n); } else if (type == Node.ELEMENT_NODE) { cleanText(n); } } for (int i = 0; i < rem.size(); i++) { node.removeChild((Node) rem.get(i)); } } catch (Exception e) { //DebugUtil.debug(e); } }
From source file:edu.ku.brc.dbsupport.DatabaseDriverInfo.java
/** * Locates a DatabaseDriverInfo object by name. * @param dbDrivers a list of drivers//w ww .j av a2 s .c om * @param name the name to look up * @return the info object */ public static DatabaseDriverInfo getInfoByName(final Vector<DatabaseDriverInfo> dbDrivers, final String name) { int inx = Collections.binarySearch(dbDrivers, new DatabaseDriverInfo(name, null, null, false, null)); return inx > -1 ? dbDrivers.get(inx) : null; }
From source file:com.fiorano.openesb.application.common.Param.java
/** * Returns param with name for class/* www . j a va2s .c o m*/ */ public static Param getParamWithName(Vector params, String name) { int size = params.size(); if (size == 0) return null; try { for (int i = 0; i < size; i++) { Param param = (Param) params.get(i); //raf.writeBytes(param.toString()); if (param.getParamName().equals(name)) return param; } } catch (Exception e) { e.printStackTrace(); } return null; }
From source file:com.ricemap.spateDB.mapred.FileSplitUtil.java
/** * Takes a list of locations as a vector, and returns a unique array of * locations where locations on the head are more frequent in the original * vector than the ones on the tail.//from w ww. j a v a 2s .c om * * @param vlocations - A vector of locations with possible duplicates * @return - A unique array of locations. */ public static String[] prioritizeLocations(Vector<String> vlocations) { Collections.sort(vlocations); @SuppressWarnings("unchecked") Vector<String>[] locations_by_count = new Vector[vlocations.size() + 1]; int unique_location_count = 0; int first_in_run = 0; int i = 1; while (i < vlocations.size()) { if (vlocations.get(first_in_run).equals(vlocations.get(i))) { i++; } else { // End of run unique_location_count++; int count = i - first_in_run; if (locations_by_count[count] == null) { locations_by_count[count] = new Vector<String>(); } locations_by_count[count].add(vlocations.get(first_in_run)); first_in_run = i; } } // add last run unique_location_count++; int count = i - first_in_run; if (locations_by_count[count] == null) { locations_by_count[count] = new Vector<String>(); } locations_by_count[count].add(vlocations.get(first_in_run)); String[] unique_locations = new String[unique_location_count]; for (Vector<String> locations_with_same_count : locations_by_count) { if (locations_with_same_count == null) continue; for (String loc : locations_with_same_count) { unique_locations[--unique_location_count] = loc; } } if (unique_location_count != 0) throw new RuntimeException(); return unique_locations; }
From source file:gdt.data.grain.Support.java
private static boolean itemExists(String name, Vector<String> vec) { if (name == null) return false; if (vec == null) return false; int cnt = vec.size(); for (int i = 0; i < cnt; i++) { if (name.compareTo((String) vec.get(i)) == 0) return true; }//w w w .j a v a 2 s . c om return false; }
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 va 2 s . c o m*/ for (int i = 1; i < partitions.size(); i++) { bytes = ("#" + partitions.get(i).filename).getBytes(); t.append(bytes, 0, bytes.length); } }
From source file:net.rim.ejde.internal.model.BlackBerryPropertiesFactory.java
/** * Initialize from a given legacy project. * * @param properties// w ww . j ava 2 s. c om * * @param project * the project * @param javaProj * the java proj */ static private void initializeFromLegacy(BlackBerryProperties properties, final Project project, final IJavaProject javaProj) { // Initialize the general section properties._general.setTitle(project.getTitle()); properties._general.setVersion(project.getVersion()); properties._general.setDescription(project.getDescription()); properties._general.setVendor(project.getVendor()); // Initialize the application section properties._application.setHomeScreenPosition(project.getRibbonPosition()); properties._application.setIsAutostartup(project.getRunOnStartup()); properties._application.setIsSystemModule(project.getSystemModule()); switch (project.getType()) { case Project.MIDLET: { properties._application.setMainArgs(IConstants.EMPTY_STRING); properties._application.setMainMIDletName(project.getMidletClass()); break; } case Project.CLDC_APPLICATION: { properties._application.setMainArgs(project.getMidletClass()); properties._application.setMainMIDletName(IConstants.EMPTY_STRING); break; } case Project.LIBRARY: { properties._application.setIsSystemModule(Boolean.TRUE); // No break falling through to default case } default: { properties._application.setMainArgs(IConstants.EMPTY_STRING); properties._application.setMainMIDletName(IConstants.EMPTY_STRING); } } properties._application .setStartupTier(Math.max(project.getStartupTier(), ProjectUtils.getStartupTiers()[0])); properties._application.setType(GeneralSection.projectTypeChoiceList[project.getType()]); // Initialize the resources section properties._resources.setHasTitleResource(project.isTitleResourceBundleActive()); properties._resources.setTitleResourceBundleName(project.getTitleResourceBundleName()); properties._resources.setTitleResourceBundleKey(project.getTitleResourceTitleKey()); properties._resources.setTitleResourceBundleClassName(project.getTitleResourceBundleClassName()); final IProject iProject = javaProj.getProject(); final String resourceBundlePath = project.getTitleResourceBundlePath(); if (!StringUtils.isBlank(resourceBundlePath)) { final String resourceBundleFilePath = Util.makeAbsolute(resourceBundlePath, project.getFile()); properties._resources.setTitleResourceBundleRelativePath( getTargetRelFilePath(new File(resourceBundleFilePath), project, JavaCore.create(iProject))); } else { properties._resources.setTitleResourceBundleRelativePath(IConstants.EMPTY_STRING); } properties._resources.setDescriptionId(project.getTitleResourceDescriptionKey()); properties._resources.setIconFiles(getIcons(project, iProject)); // Initialize the keyword section // TODO we use the KeywordResourceBundleKey to store ID for now, later on when we implemented the UI part, we need to // change properties.getKeywordResources().setKeywordResourceBundleKey(project.getKeywordResourceBundleId()); properties.getKeywordResources() .setKeywordResourceBundleClassName(project.getKeywordResourceBundleClassName()); // Initialize the compiler section properties._compile.setAliasList(project.getAlias()); properties._compile.setCompressResources(project.getWorkspace().getResourcesCompressed()); properties._compile.setConvertImages(!project.getIsNoConvertPng()); properties._compile.setCreateWarningForNoExportedRoutine(!project.getIsNoMainWarn()); properties._compile.setOutputCompilerMessages(project.getIsNoWarn()); final Vector<String> defines = project.getDefines(); properties._compile.setPreprocessorDefines( PreprocessorTag.create(defines.toArray(new String[defines.size()]), PreprocessorTag.PJ_SCOPE)); // Initialize the packaging section final Vector<File> alxFileVector = project.getAlxImports(); final String[] alxFiles = new String[alxFileVector.size()]; for (int i = 0; i < alxFileVector.size(); i++) { final File alxFile = alxFileVector.get(i); alxFiles[i] = alxFile.getPath(); } properties._packaging.setAlxFiles(alxFiles); properties._packaging.setCleanStep(project.getCleanBuild()); properties.setValidOutputFileName(project.getOutputFileName()); properties._packaging.setPostBuildStep(project.getPostBuild()); properties._packaging.setPreBuildStep(project.getPreBuild()); properties._packaging.setGenerateALXFile(PackagingUtils.getDefaultGenerateAlxFile()); // Initialize alternate entry points final int AEPNumber = project.getNumEntries(); properties._alternateEntryPoints = new AlternateEntryPoint[AEPNumber]; for (int i = 0; i < AEPNumber; i++) { final Project entry = project.getEntry(i); try { properties._alternateEntryPoints[i] = createAlternateEntryPoint(entry, iProject); } catch (final CoreException e) { _log.error(e.getMessage(), e); } } // Initialize hidden properties properties._hiddenProperties.setClassProtection(project.getClassProtection()); properties._hiddenProperties.setPackageProtection(project.getPackageProtection()); }
From source file:Main.java
public static NodeList getChildsByTagName(Element root, String name) { final Vector<Node> v = new Vector<Node>(); NodeList nl = root.getChildNodes(); for (int i = 0; i < nl.getLength(); i++) { Node n = nl.item(i);/*from ww w. j av a 2 s .co m*/ if (n.getNodeType() == Element.ELEMENT_NODE) { Element e = (Element) n; if (name.equals("*") || e.getNodeName().equalsIgnoreCase(name)) v.add(n); } } return new NodeList() { public Node item(int index) { if (index >= v.size() || index < 0) return null; else return v.get(index); } public int getLength() { return v.size(); } }; }