List of usage examples for java.util Vector insertElementAt
public synchronized void insertElementAt(E obj, int index)
From source file:MainClass.java
public static void main(String args[]) { Vector v = new Vector(5); for (int i = 0; i < 10; i++) { v.insertElementAt(i, 0); }//from w w w. j av a 2 s . c o m System.out.println(v); }
From source file:Main.java
public static void main(String[] args) { Vector vec = new Vector(4); vec.add(4);// w ww. j a v a 2 s . c om vec.add(3); vec.add(2); vec.add(1); System.out.println(vec); // let us insert element at 1st position vec.insertElementAt(133, 1); System.out.println(vec); }
From source file:MainClass.java
public static void main(String args[]) { Vector vector = new Vector(); vector.addElement(new Integer(5)); vector.addElement(new Float(-14.14f)); System.out.println(vector);/*from w w w . j av a2 s . c om*/ String s = new String("String to be inserted"); vector.insertElementAt(s, 1); System.out.println(vector); vector.removeElementAt(2); System.out.println(vector); }
From source file:Main.java
private static Vector getVectorPathFromNode(Node node) { Vector path = new Vector(); while (node != null) { path.insertElementAt(node, 0); node = node.getParentNode();//from w ww . j av a2 s .com } return path; }
From source file:Main.java
public static void copyIntoVector(Vector paramVector1, int paramInt, Vector paramVector2) { int i = paramInt; try {//from ww w .j a va 2 s .co m while (i < paramVector1.size()) { paramVector2.insertElementAt(paramVector1.elementAt(i), i - paramInt); i++; } return; } finally { } }
From source file:Main.java
/** Adds an object to the start of a list if not already contained. */ public static void tryInsert(Vector vector, Object object) { if (object == null) { return;/* ww w. j av a2 s .com*/ } if (!vector.contains(object)) { vector.insertElementAt(object, 0); } }
From source file:edu.ku.brc.af.core.SchemaI18NService.java
/** * @param includeSepLocale/*from ww w . j a v a 2s . com*/ * @return */ public Vector<Locale> getStdLocaleList(final boolean includeSepLocale) { /*for (Locale l : locales) { System.out.println(String.format("%s - %s, %s, %s", l.getDisplayName(), l.getLanguage(), l.getCountry(), l.getVariant())); }*/ Vector<Locale> freqLocales = new Vector<Locale>(); int i = 0; while (i < priorityLocales.length) { String lang = priorityLocales[i++]; String ctry = priorityLocales[i++]; String vari = priorityLocales[i++]; Locale l = getLocaleByLangCountry(lang, ctry, vari); if (l != null) { freqLocales.add(l); } } HashSet<String> freqSet = new HashSet<String>(); for (Locale l : freqLocales) { freqSet.add(l.getDisplayName()); } Vector<Locale> stdLocaleList = new Vector<Locale>(); for (Locale l : locales) { if (!freqSet.contains(l.getDisplayName())) { stdLocaleList.add(l); } } if (includeSepLocale) { stdLocaleList.insertElementAt(new Locale("-", "-", "-"), 0); } for (i = freqLocales.size() - 1; i > -1; i--) { stdLocaleList.insertElementAt(freqLocales.get(i), 0); } return stdLocaleList; }
From source file:com.alfaariss.oa.profile.aselect.ws.security.OACrypto.java
/** * Retrieve /*from w w w . j a v a2 s . c om*/ * @see Crypto#getCertificateData(boolean, X509Certificate[]) */ public byte[] getCertificateData(boolean reverse, X509Certificate[] certs) throws WSSecurityException { try { Vector<X509Certificate> list = new Vector<X509Certificate>(); for (int i = 0; i < certs.length; i++) { if (reverse) { list.insertElementAt(certs[i], 0); } else { list.add(certs[i]); } } CertPath path = getCertificateFactory().generateCertPath(list); return path.getEncoded(); } catch (CertificateEncodingException e) { _logger.warn("Could not encode certificate path", e); throw new WSSecurityException(WSSecurityException.SECURITY_TOKEN_UNAVAILABLE, "encodeError", null, e); } catch (CertificateException e) { _logger.warn("Could not generate certificate path", e); throw new WSSecurityException(WSSecurityException.SECURITY_TOKEN_UNAVAILABLE, "parseError", null, e); } }
From source file:FileTree2.java
public boolean expand(DefaultMutableTreeNode parent) { DefaultMutableTreeNode flag = (DefaultMutableTreeNode) parent.getFirstChild(); if (flag == null) // No flag return false; Object obj = flag.getUserObject(); if (!(obj instanceof Boolean)) return false; // Already expanded parent.removeAllChildren(); // Remove Flag File[] files = listFiles();// w ww . j a v a 2s. c om if (files == null) return true; Vector v = new Vector(); for (int k = 0; k < files.length; k++) { File f = files[k]; if (!(f.isDirectory())) continue; FileNode newNode = new FileNode(f); boolean isAdded = false; for (int i = 0; i < v.size(); i++) { FileNode nd = (FileNode) v.elementAt(i); if (newNode.compareTo(nd) < 0) { v.insertElementAt(newNode, i); isAdded = true; break; } } if (!isAdded) v.addElement(newNode); } for (int i = 0; i < v.size(); i++) { FileNode nd = (FileNode) v.elementAt(i); IconData idata = new IconData(FileTree2.ICON_FOLDER, FileTree2.ICON_EXPANDEDFOLDER, nd); DefaultMutableTreeNode node = new DefaultMutableTreeNode(idata); parent.add(node); if (nd.hasSubDirs()) node.add(new DefaultMutableTreeNode(new Boolean(true))); } return true; }
From source file:edu.ku.brc.util.HelpIndexer.java
/** * /*from www .jav a2 s .c o m*/ */ @SuppressWarnings("unchecked") public void indexIt() { if (!jhm.exists()) { System.out.println("jhm file not found."); return; } if (!topDir.isDirectory()) { System.out.println("directory does not exist."); return; } try { mapLines = FileUtils.readLines(jhm); } catch (IOException ex) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(HelpIndexer.class, ex); System.out.println("Error reading map file: " + ex.getMessage()); return; } Vector<String> lines = new Vector<String>(); String[] ext = { "html" }; Iterator<File> helpFiles = FileUtils.iterateFiles(topDir, ext, true); while (helpFiles.hasNext()) { File file = helpFiles.next(); System.out.println("Processing " + file.getName()); processFile(file, lines); } System.out.println(); System.out.println("all done."); File outFile = new File(outFileName); try { //add lines to top of file lines.insertElementAt("<?xml version='1.0' encoding='ISO-8859-1' ?>", 0); lines.insertElementAt("<!DOCTYPE index", 1); lines.insertElementAt(" PUBLIC \"-//Sun Microsystems Inc.//DTD JavaHelp Index Version 1.0//EN\"", 2); lines.insertElementAt(" \"http://java.sun.com/products/javahelp/index_1_0.dtd\">", 3); lines.insertElementAt("<index version=\"1.0\">", 4); lines.insertElementAt(" ", 5); //and bottom... lines.add(" "); lines.add("</index>"); FileUtils.writeLines(outFile, lines); } catch (IOException ex) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(HelpIndexer.class, ex); System.out.println("error writing output file: " + ex.getMessage()); } }