List of usage examples for java.util Vector add
public synchronized boolean add(E e)
From source file:Gen.java
public static void genWeb() throws Exception { String GEN_WEBINF = GEN_ROOT + FILE_SEPARATOR + "war" + FILE_SEPARATOR + "WEB-INF"; String WAR_NAME = System.getProperty("warname") != null && !System.getProperty("warname").equals("") ? System.getProperty("warname") : MAPPING_JAR_NAME.substring(0, MAPPING_JAR_NAME.length() - "jar".length()) + "war"; if (!WAR_NAME.endsWith(".war")) WAR_NAME += ".war"; String PROPS_EMBED = System.getProperty("propsembed") != null && !System.getProperty("propsembed").equals("") ? System.getProperty("propsembed") : null; deleteDir(GEN_ROOT + FILE_SEPARATOR + "war"); regenerateDir(GEN_WEBINF + FILE_SEPARATOR + "classes"); regenerateDir(GEN_WEBINF + FILE_SEPARATOR + "lib"); Vector<String> warJars = new Vector<String>(); warJars.add(GEN_ROOT_LIB + FILE_SEPARATOR + MAPPING_JAR_NAME); InputStream inputStreamCore = Gen.class.getResourceAsStream("/biocep-core-tomcat.jar"); if (inputStreamCore != null) { try {// w ww . j av a2 s. c o m byte data[] = new byte[BUFFER_SIZE]; FileOutputStream fos = new FileOutputStream( GEN_WEBINF + FILE_SEPARATOR + "lib" + "/biocep-core.jar"); int count = 0; while ((count = inputStreamCore.read(data, 0, BUFFER_SIZE)) != -1) { fos.write(data, 0, count); } fos.flush(); fos.close(); } catch (Exception e) { e.printStackTrace(); } } else { warJars.add("RJB.jar"); warJars.add("lib/desktop/JRI.jar"); FilenameFilter jarsFilter = new FilenameFilter() { public boolean accept(File arg0, String arg1) { return arg1.endsWith(".jar"); } }; { String[] derby_jdbc_jars = new File("lib/jdbc").list(jarsFilter); for (int i = 0; i < derby_jdbc_jars.length; ++i) { warJars.add("lib/jdbc" + FILE_SEPARATOR + derby_jdbc_jars[i]); } } { String[] pool_jars = new File("lib/pool").list(jarsFilter); for (int i = 0; i < pool_jars.length; ++i) { warJars.add("lib/pool" + FILE_SEPARATOR + pool_jars[i]); } } { String[] httpclient_jars = new File("lib/j2ee").list(jarsFilter); for (int i = 0; i < httpclient_jars.length; ++i) { warJars.add("lib/j2ee" + FILE_SEPARATOR + httpclient_jars[i]); } } } log.info(warJars); for (int i = 0; i < warJars.size(); ++i) { Copy copyTask = new Copy(); copyTask.setProject(_project); copyTask.setTaskName("copy to war"); copyTask.setTodir(new File(GEN_WEBINF + FILE_SEPARATOR + "lib")); copyTask.setFile(new File(warJars.elementAt(i))); copyTask.init(); copyTask.execute(); } unzip(Gen.class.getResourceAsStream("/jaxws.zip"), GEN_WEBINF + FILE_SEPARATOR + "lib", new EqualNameFilter("activation.jar", "jaxb-api.jar", "jaxb-impl.jar", "jaxb-xjc.jar", "jaxws-api.jar", "jaxws-libs.jar", "jaxws-rt.jar", "jaxws-tools.jar", "jsr173_api.jar", "jsr181-api.jar", "jsr250-api.jar", "saaj-api.jar", "saaj-impl.jar", "sjsxp.jar", "FastInfoset.jar", "http.jar", "mysql-connector-java-5.1.0-bin.jar", "ojdbc-14.jar"), BUFFER_SIZE, false, "Unzipping psTools..", 17); PrintWriter pw_web_xml = new PrintWriter(GEN_WEBINF + FILE_SEPARATOR + "web.xml"); pw_web_xml.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); pw_web_xml.println( "<web-app version=\"2.4\" xmlns=\"http://java.sun.com/xml/ns/j2ee\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd\">"); pw_web_xml.println( "<listener><listener-class>com.sun.xml.ws.transport.http.servlet.WSServletContextListener</listener-class></listener>"); for (String className : DirectJNI._rPackageInterfacesHash.keySet()) { String shortClassName = className.substring(className.lastIndexOf('.') + 1); pw_web_xml.println("<servlet><servlet-name>" + shortClassName + "_servlet</servlet-name><servlet-class>org.kchine.r.server.http.frontend.InterceptorServlet</servlet-class><load-on-startup>1</load-on-startup></servlet>"); } pw_web_xml.println("<servlet><servlet-name>" + "WSServlet" + "</servlet-name><servlet-class>com.sun.xml.ws.transport.http.servlet.WSServlet</servlet-class><load-on-startup>1</load-on-startup></servlet>"); pw_web_xml.println("<servlet><servlet-name>" + "MappingClassServlet" + "</servlet-name><servlet-class>org.kchine.r.server.http.frontend.MappingClassServlet</servlet-class><load-on-startup>1</load-on-startup></servlet>"); for (String className : DirectJNI._rPackageInterfacesHash.keySet()) { String shortClassName = className.substring(className.lastIndexOf('.') + 1); pw_web_xml.println( "<servlet-mapping><servlet-name>" + shortClassName + "_servlet</servlet-name><url-pattern>/" + shortClassName + "</url-pattern></servlet-mapping>"); } pw_web_xml.println("<servlet-mapping><servlet-name>" + "MappingClassServlet" + "</servlet-name><url-pattern>" + "/mapping/classes/*" + "</url-pattern></servlet-mapping>"); pw_web_xml.println("<session-config><session-timeout>30</session-timeout></session-config>"); pw_web_xml.println("</web-app>"); pw_web_xml.flush(); pw_web_xml.close(); PrintWriter pw_sun_jaxws_xml = new PrintWriter(GEN_WEBINF + FILE_SEPARATOR + "sun-jaxws.xml"); pw_sun_jaxws_xml.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); pw_sun_jaxws_xml.println("<endpoints xmlns='http://java.sun.com/xml/ns/jax-ws/ri/runtime' version='2.0'>"); for (String className : DirectJNI._rPackageInterfacesHash.keySet()) { String shortClassName = className.substring(className.lastIndexOf('.') + 1); pw_sun_jaxws_xml.println(" <endpoint name='name_" + shortClassName + "' implementation='" + className + "Web" + "' url-pattern='/" + shortClassName + "'/>"); } pw_sun_jaxws_xml.println("</endpoints>"); pw_sun_jaxws_xml.flush(); pw_sun_jaxws_xml.close(); if (PROPS_EMBED != null) { InputStream is = new FileInputStream(PROPS_EMBED); byte[] buffer = new byte[is.available()]; is.read(buffer); RandomAccessFile raf = new RandomAccessFile( GEN_WEBINF + FILE_SEPARATOR + "classes" + FILE_SEPARATOR + "globals.properties", "rw"); raf.setLength(0); raf.write(buffer); raf.close(); } War warTask = new War(); warTask.setProject(_project); warTask.setTaskName("war"); warTask.setBasedir(new File(GEN_ROOT + FILE_SEPARATOR + "war")); warTask.setDestFile(new File(GEN_ROOT + FILE_SEPARATOR + WAR_NAME)); warTask.setIncludes("**/*"); warTask.init(); warTask.execute(); }
From source file:JavaSort.java
public JavaSort() { Vector list = new Vector(); list.add("\u00e4pple"); list.add("banan"); list.add("p\u00e4ron"); list.add("orange"); // Obtain a Swedish collator Collator collate = Collator.getInstance(new Locale("sv", "")); Collections.sort(list, collate); StringBuffer result = new StringBuffer(); for (int i = 0; i < list.size(); i++) { result.append(list.elementAt(i)); result.append(" "); }//from www .ja va2 s . c o m add(new JLabel(result.toString())); }
From source file:marytts.util.string.StringUtils.java
/** * Divides the example text of a voice into * sentences in a vector/*from ww w . jav a 2 s . c om*/ * @param text the example text * @return vector of example sentences */ public static Vector<String> processVoiceExampleText(String text) { StringTokenizer st = new StringTokenizer(text, "#"); Vector<String> sentences = null; while (st.hasMoreTokens()) { if (sentences == null) sentences = new Vector<String>(); sentences.add(st.nextToken()); } return sentences; }
From source file:Main.java
public static Vector<byte[]> split(int command, byte[] dataToTransport, int chunksize) { Vector<byte[]> result = new Vector<byte[]>(); if (chunksize < 8) { throw new RuntimeException("Invalid chunk size"); }//from w w w . j a v a2 s . c o m ByteArrayOutputStream baos = new ByteArrayOutputStream(); int remaining_length = dataToTransport.length; int offset = 0; int seq = 0; boolean firstPacket = true; while (remaining_length > 0) { int l = 0; if (!firstPacket) { baos.write(seq); l = Math.min(chunksize - 1, remaining_length); } else { baos.write(command); // first packet has the total transport length baos.write(remaining_length >> 8); baos.write(remaining_length); l = Math.min(chunksize - 3, remaining_length); } baos.write(dataToTransport, offset, l); remaining_length -= l; offset += l; result.add(baos.toByteArray()); baos.reset(); if (!firstPacket) { seq++; } firstPacket = false; } return result; }
From source file:edu.umn.cs.spatialHadoop.operations.Indexer.java
private static void indexLocal(Path inPath, Path outPath, OperationsParams params) throws IOException { JobConf job = new JobConf(params); String sindex = params.get("sindex"); Partitioner partitioner = createPartitioner(inPath, outPath, job, sindex); // Start reading input file Vector<InputSplit> splits = new Vector<InputSplit>(); final ShapeIterInputFormat inputFormat = new ShapeIterInputFormat(); FileSystem inFs = inPath.getFileSystem(params); FileStatus inFStatus = inFs.getFileStatus(inPath); if (inFStatus != null && !inFStatus.isDir()) { // One file, retrieve it immediately. // This is useful if the input is a hidden file which is automatically // skipped by FileInputFormat. We need to plot a hidden file for the case // of plotting partition boundaries of a spatial index splits.add(new FileSplit(inPath, 0, inFStatus.getLen(), new String[0])); } else {// w w w.ja v a 2s .co m ShapeIterInputFormat.addInputPath(job, inPath); for (InputSplit s : inputFormat.getSplits(job, 1)) splits.add(s); } // Copy splits to a final array to be used in parallel final FileSplit[] fsplits = splits.toArray(new FileSplit[splits.size()]); boolean replicate = job.getBoolean("replicate", false); final IndexRecordWriter<Shape> recordWriter = new IndexRecordWriter<Shape>(partitioner, replicate, sindex, outPath, params); for (FileSplit fsplit : fsplits) { RecordReader<Rectangle, Iterable<? extends Shape>> reader = inputFormat.getRecordReader(fsplit, job, null); Rectangle partitionMBR = reader.createKey(); Iterable<? extends Shape> shapes = reader.createValue(); final IntWritable partitionID = new IntWritable(); while (reader.next(partitionMBR, shapes)) { if (replicate) { // Replicate each shape to all overlapping partitions for (final Shape s : shapes) { partitioner.overlapPartitions(s, new ResultCollector<Integer>() { @Override public void collect(Integer id) { partitionID.set(id); try { recordWriter.write(partitionID, s); } catch (IOException e) { throw new RuntimeException(e); } } }); } } else { for (Shape s : shapes) { partitionID.set(partitioner.overlapPartition(s)); recordWriter.write(partitionID, s); } } } reader.close(); } recordWriter.close(null); }
From source file:MainClass.java
MainClass() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Vector v = new Vector(); v.add("First item"); v.add("Second item"); v.add("Third item"); v.add("Fourth item"); JPanel p = new JPanel(); p.setPreferredSize(new Dimension(200, 100)); JList jl = new JList(v); jl.setPreferredSize(new Dimension(100, 75)); p.add(new JScrollPane(jl)); getContentPane().add(p);//from w w w. j a v a 2 s . c om pack(); setVisible(true); }
From source file:MainClass.java
MainClass(String title) { super(title); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel jp = new JPanel(); Vector v = new Vector(); v.add("A"); v.add("B");//from w w w .j av a2 s . c o m v.add("C"); jcb = new JComboBox(v); jcb.setEditable(true); KeyStroke ks = KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, Event.CTRL_MASK); jcb.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(ks, "clearEditor"); jcb.getActionMap().put("clearEditor", new ClearEditorAction()); jp.setPreferredSize(new Dimension(200, 35)); jp.add(jcb); getContentPane().add(jp); pack(); setVisible(true); }
From source file:Main.java
Main(String title) { super(title); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel jp = new JPanel(); Vector v = new Vector(); v.add("A"); v.add("B");//from w w w . jav a2 s .c o m v.add("C"); jcb = new JComboBox(v); jcb.setEditable(true); jcb.getActionMap().put("selectNext", new DownAction()); jp.setPreferredSize(new Dimension(200, 35)); jp.add(jcb); getContentPane().add(jp); pack(); setVisible(true); }
From source file:MainClass.java
MainClass(String title) { super(title); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel jp = new JPanel(); Vector v = new Vector(); v.add("A"); v.add("B");/*from w ww .jav a2 s.co m*/ v.add("C"); jcb = new JComboBox(v); jcb.setEditable(true); jcb.getActionMap().put("selectNext", new DownAction()); jp.setPreferredSize(new Dimension(200, 35)); jp.add(jcb); getContentPane().add(jp); pack(); setVisible(true); }
From source file:com.bluexml.xforms.demo.Util.java
public static Set<Vector<String>> getPooledTasks(String alfrescohost, String user) { Set<Vector<String>> result = new HashSet<Vector<String>>(); try {/*from w w w . jav a2s. com*/ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); // the mapping.xml file is private to the controller. Better use the API. // Document mappingDocument = builder.parse(mapping); PostMethod post = new PostMethod(alfrescohost + "service/xforms/workflow"); post.setParameter("username", user); post.setParameter("method", "getPooledTasks"); post.setParameter("arg0", user); HttpClient client = new HttpClient(); client.executeMethod(post); Document document = builder.parse(new ByteArrayInputStream( ("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" + post.getResponseBodyAsString()).getBytes())); Node root = document.getDocumentElement(); root = findNode(root.getChildNodes(), "list"); for (int i = 0; i < root.getChildNodes().getLength(); i++) { Node n = root.getChildNodes().item(i); if (n.getNodeType() == Element.ELEMENT_NODE) { Vector<String> v = new Vector<String>(); String instanceId = findNode( findNode(findNode(n.getChildNodes(), "path").getChildNodes(), "instance") .getChildNodes(), "id").getTextContent(); String taskId = findNode(n.getChildNodes(), "id").getTextContent(); v.add(taskId); v.add(findNode(n.getChildNodes(), "title").getTextContent()); v.add(findNode(n.getChildNodes(), "description").getTextContent()); String name = findNode(n.getChildNodes(), "name").getTextContent(); v.add(getFormName(name)); v.add(getContentId(alfrescohost, user, taskId)); v.add(instanceId); result.add(v); } } } catch (Exception e) { e.printStackTrace(); } return result; }