List of usage examples for java.util Vector add
public synchronized boolean add(E e)
From source file:corner.util.VectorUtilsTest.java
public void testSumVector() { Vector<String> v = new Vector<String>(); v.add("1"); v.add("2");/* ww w . j ava2 s.c o m*/ assertEquals(3.0, VectorUtils.sum(v)); v.add("1.2"); assertEquals(4.2, VectorUtils.sum(v)); v.add("1.258"); assertEquals(5.458, VectorUtils.sum(v)); }
From source file:corner.util.VectorUtilsTest.java
public void testSumErrorVector() { Vector<String> v = new Vector<String>(); v.add("1s"); v.add("2");//w w w. j a v a 2 s . c om try { VectorUtils.sum(v); fail("can't reacheable"); } catch (RuntimeException e) { // go here } }
From source file:com.ibm.xsp.xflow.activiti_rest.DominoUserManager.java
@Override public List<User> findUserByQueryCriteria(UserQueryImpl query, Page page) { List<User> userList = new ArrayList<User>(); Vector<String> items = new Vector<String>(); items.add("FirstName"); items.add("LastName"); items.add("FullName"); Vector<String> names = new Vector<String>(); if (StringUtils.isNotEmpty(query.getId())) { // Need to search word separately, otherwise Domino could not find them. String[] words = query.getId().split("\\W"); for (int i = 0; i < words.length; i++) { names.add(words[i]);//w w w . j a va 2 s. com } } if (StringUtils.isNotEmpty(query.getLastName())) { String[] words = query.getLastName().split("\\W"); for (int i = 0; i < words.length; i++) { names.add(words[i]); } } if (StringUtils.isNotEmpty(query.getFirstName())) { String[] words = query.getFirstName().split("\\W"); for (int i = 0; i < words.length; i++) { names.add(words[i]); } } Session session = null; Directory dir = null; try { NotesThread.sinitThread(); session = NotesFactory.createSessionWithFullAccess(); dir = session.getDirectory(""); DirectoryNavigator nav = dir.lookupNames("$Users", names, items, true); if (nav.getCurrentMatch() > 0) { do { User user = new UserEntity(); user.setFirstName((String) nav.getFirstItemValue().get(0)); user.setLastName((String) nav.getNextItemValue().get(0)); Name notesName = session.createName((String) nav.getNextItemValue().get(0)); user.setId(notesName.getAbbreviated()); userList.add(user); } while (nav.findNextMatch()); } } catch (Exception e) { e.printStackTrace(); } finally { try { if (dir != null) dir.recycle(); if (session != null) session.recycle(); } catch (Exception e) { } NotesThread.stermThread(); } return userList; }
From source file:corner.util.VectorUtilsTest.java
public void testSubmVectorList() { Vector<String> v1 = new Vector<String>(); v1.add("1"); v1.add("2");/*from w w w . j a v a 2 s . c o m*/ Vector<String> v2 = new Vector<String>(); v2.add("1"); v2.add("2"); List<Vector<String>> list = new ArrayList<Vector<String>>(); list.add(v1); list.add(v2); Vector<Double> r = VectorUtils.sumList(list); assertTrue(2 == r.get(0)); }
From source file:com.ricemap.spateDB.operations.Repartition.java
public static <S extends Shape> CellInfo[] packInPrisms(FileSystem fs, Path[] files, FileSystem outFileSystem, Path outFile, long blocksize, S stockShape) throws IOException { final Vector<Point3d> sample = new Vector<Point3d>(); double sample_ratio = outFileSystem.getConf().getFloat(SpatialSite.SAMPLE_RATIO, 0.01f); long sample_size = outFileSystem.getConf().getLong(SpatialSite.SAMPLE_SIZE, 100 * 1024 * 1024); // 24 is the estimated size in bytes needed to store each sample point long sample_count = sample_size / 24; LOG.info("Reading a sample of " + (int) Math.round(sample_ratio * 100) + "%"); ResultCollector<Point3d> resultCollector = new ResultCollector<Point3d>() { @Override// w w w.j av a 2 s.co m public void collect(Point3d value) { sample.add(value.clone()); } }; Sampler.sampleWithRatio(fs, files, sample_ratio, sample_count, System.currentTimeMillis(), resultCollector, stockShape, new Point3d()); LOG.info("Finished reading a sample of size: " + sample.size() + " records"); long inFileSize = Sampler.sizeOfLastProcessedFile; // Compute an approximate MBR to determine the desired number of rows // and columns Prism approxMBR = new Prism(Double.MAX_VALUE, Double.MAX_VALUE, Double.MAX_VALUE, -Double.MAX_VALUE, -Double.MAX_VALUE, -Double.MAX_VALUE); for (Point3d pt : sample) { approxMBR.expand(pt); } GridInfo gridInfo = new GridInfo(approxMBR.t1, approxMBR.x1, approxMBR.y1, approxMBR.t2, approxMBR.x2, approxMBR.y2); gridInfo.calculateCellDimensions(Math.max(1, (int) ((inFileSize + blocksize / 2) / blocksize))); gridInfo.set(-Double.MAX_VALUE, -Double.MAX_VALUE, -Double.MAX_VALUE, Double.MAX_VALUE, Double.MAX_VALUE, Double.MAX_VALUE); Prism[] Prisms = RTree.packInPrisms(gridInfo, sample.toArray(new Point3d[sample.size()])); CellInfo[] cellsInfo = new CellInfo[Prisms.length]; for (int i = 0; i < Prisms.length; i++) cellsInfo[i] = new CellInfo(i + 1, Prisms[i]); return cellsInfo; }
From source file:corner.util.VectorUtilsTest.java
@Test public void testSumEmptyVector() { Vector<String> v = new Vector<String>(); v.add("1"); v.add("2");// w w w . j a va 2 s . c o m v.add(""); v.add(""); v.add(""); assertEquals(3.0, VectorUtils.sum(v)); v.add("1.2"); assertEquals(4.2, VectorUtils.sum(v)); v.add("1.258"); assertEquals(5.458, VectorUtils.sum(v)); }
From source file:com.ibm.xsp.xflow.activiti_rest.DominoGroupManager.java
public List<Group> findGroups(Vector<String> names, boolean matchExact) { List<Group> groupList = new ArrayList<Group>(); Vector<String> items = new Vector<String>(); items.add("ListName"); Session session = null;/*w ww . ja v a 2 s.com*/ Directory dir = null; try { NotesThread.sinitThread(); session = NotesFactory.createSessionWithFullAccess(); dir = session.getDirectory(""); DirectoryNavigator nav = dir.lookupNames("$Groups", names, items, matchExact); if (nav.getCurrentMatch() > 0) { do { Group group = new GroupEntity(); String groupName = (String) nav.getFirstItemValue().get(0); group.setId(groupName); group.setName(groupName); group.setType("security-role"); groupList.add(group); } while (nav.findNextMatch()); } } catch (Exception e) { e.printStackTrace(); } finally { try { if (dir != null) dir.recycle(); if (session != null) session.recycle(); } catch (Exception e) { } NotesThread.stermThread(); } return groupList; }
From source file:misc.FocusTraversalDemo.java
public FocusTraversalDemo() { super(new BorderLayout()); JTextField tf1 = new JTextField("Field 1"); JTextField tf2 = new JTextField("A Bigger Field 2"); JTextField tf3 = new JTextField("Field 3"); JTextField tf4 = new JTextField("A Bigger Field 4"); JTextField tf5 = new JTextField("Field 5"); JTextField tf6 = new JTextField("A Bigger Field 6"); JTable table = new JTable(4, 3); togglePolicy = new JCheckBox("Custom FocusTraversalPolicy"); togglePolicy.setActionCommand("toggle"); togglePolicy.addActionListener(this); togglePolicy.setFocusable(false); //Remove it from the focus cycle. //Note that HTML is allowed and will break this run of text //across two lines. label = new JLabel( "<html>Use Tab (or Shift-Tab) to navigate from component to component.<p>Control-Tab (or Control-Shift-Tab) allows you to break out of the JTable.</html>"); JPanel leftTextPanel = new JPanel(new GridLayout(3, 2)); leftTextPanel.add(tf1, BorderLayout.PAGE_START); leftTextPanel.add(tf3, BorderLayout.CENTER); leftTextPanel.add(tf5, BorderLayout.PAGE_END); leftTextPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 5)); JPanel rightTextPanel = new JPanel(new GridLayout(3, 2)); rightTextPanel.add(tf2, BorderLayout.PAGE_START); rightTextPanel.add(tf4, BorderLayout.CENTER); rightTextPanel.add(tf6, BorderLayout.PAGE_END); rightTextPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 5)); JPanel tablePanel = new JPanel(new GridLayout(0, 1)); tablePanel.add(table, BorderLayout.CENTER); tablePanel.setBorder(BorderFactory.createEtchedBorder()); JPanel bottomPanel = new JPanel(new GridLayout(2, 1)); bottomPanel.add(togglePolicy, BorderLayout.PAGE_START); bottomPanel.add(label, BorderLayout.PAGE_END); add(leftTextPanel, BorderLayout.LINE_START); add(rightTextPanel, BorderLayout.CENTER); add(tablePanel, BorderLayout.LINE_END); add(bottomPanel, BorderLayout.PAGE_END); setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); Vector<Component> order = new Vector<Component>(7); order.add(tf1); order.add(tf2);/*from w ww . java 2 s .com*/ order.add(tf3); order.add(tf4); order.add(tf5); order.add(tf6); order.add(table); newPolicy = new MyOwnFocusTraversalPolicy(order); }
From source file:de.unibayreuth.bayeos.goat.table.OctetMatrixTableModel.java
public boolean load(Vector objekts, TimeFilter tFilter, StatusFilter sFilter, Boolean withStatus) { try {//from w w w . j a v a 2 s . c o m Vector params = new Vector(); params.add(getIds(objekts)); params.add(tFilter.getVector()); params.add(sFilter.getVector()); params.add(withStatus); params.add("obj_stream"); setColumnClasses(objekts); setColumnNames(objekts); readStream(xmlClient.executeStream("OctetMatrixHandler.getMatrixOrg", params), objekts); } catch (IOException i) { MsgBox.error(i.getMessage()); return false; } catch (XmlRpcException e) { MsgBox.error(e.getMessage()); return false; } return true; }
From source file:be.e_contract.mycarenet.async.SecuritySOAPHandler.java
private void handleOutboundMessage(SOAPMessageContext context) throws SOAPException, WSSecurityException { LOG.debug("adding WS-Security header"); SOAPMessage soapMessage = context.getMessage(); SOAPPart soapPart = soapMessage.getSOAPPart(); WSSecHeader wsSecHeader = new WSSecHeader(); wsSecHeader.insertSecurityHeader(soapPart); WSSecUsernameToken usernameToken = new WSSecUsernameToken(); usernameToken.setUserInfo(this.packageLicenseKey.getUsername(), this.packageLicenseKey.getPassword()); usernameToken.setPasswordType(WSConstants.PASSWORD_TEXT); usernameToken.prepare(soapPart);/*from w ww . j ava 2 s . c om*/ usernameToken.prependToHeader(wsSecHeader); WSSecTimestamp wsSecTimeStamp = new WSSecTimestamp(); wsSecTimeStamp.build(soapPart, wsSecHeader); WSSecurityCrypto crypto = new WSSecurityCrypto(this.sessionKey); WSSConfig wssConfig = new WSSConfig(); wssConfig.setWsiBSPCompliant(false); WSSecSignature sign = new WSSecSignature(wssConfig); sign.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE); sign.prepare(soapPart, crypto, wsSecHeader); sign.appendBSTElementToHeader(wsSecHeader); Vector<WSEncryptionPart> signParts = new Vector<WSEncryptionPart>(); signParts.add(new WSEncryptionPart(wsSecTimeStamp.getId())); signParts.add(new WSEncryptionPart(usernameToken.getId())); SOAPConstants soapConstants = WSSecurityUtil.getSOAPConstants(soapPart.getDocumentElement()); signParts.add(new WSEncryptionPart(soapConstants.getBodyQName().getLocalPart(), soapConstants.getEnvelopeURI(), "Content")); sign.addReferencesToSign(signParts, wsSecHeader); List<Reference> referenceList = sign.addReferencesToSign(signParts, wsSecHeader); sign.computeSignature(referenceList, false, null); }