List of usage examples for java.util Vector add
public synchronized boolean add(E e)
From source file:it.acubelab.smaph.entityfilters.LibSvmEntityFilter.java
/** * Turns a frature_name-feature_value mapping to an array of features. * //w w w . j a v a2s . c o m * @param features * the mapping from feature names to feature values. * @return an array of feature values. */ public static double[] featuresToFtrVectStatic(HashMap<String, Double> features) { if (!checkFeatures(features)) { for (String ftrName : features.keySet()) System.err.printf("%s -> %f%n", ftrName, features.get(ftrName)); throw new RuntimeException("Implementation error -- check the features"); } Vector<Double> ftrValues = new Vector<>(); for (String ftrName : ftrNames) ftrValues.add(getOrDefault(features, ftrName, 0.0)); return ArrayUtils.toPrimitive(ftrValues.toArray(new Double[] {})); }
From source file:com.mmone.gpdati.allotment.reader.AvailCrud.java
private static int modifyAllotment(XmlRpcClient client, java.util.Date dateStart, java.util.Date dateEnd, String action, int availability, int reservation, Integer invCode, Integer hotelCode) { Vector parameters = new Vector(); DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); parameters.add(new Integer(hotelCode)); //1 parameters.add(new Integer(invCode)); //2 //todo gestire con inventario unico -1 int rate = 1; ///fisso nr da verificare per iu parameters.add(new Integer(rate)); //3 offerta parameters.add(new Integer(availability)); //4 disponibilit parameters.add(new Integer(reservation)); //5 prenotazione parameters.add(action); //6 Azione : set,increase,decrease parameters.add(df.format(dateStart).toString()); //7 parameters.add(df.format(dateEnd).toString()); //8 Vector result = new Vector(); int ret = XRPC_SET_ALLOTMENT_RESULT_ERROR; String logData = "hotelCode=" + hotelCode + " - invCode=" + invCode + " - offerta=" + rate + " - availability=" + availability + " - reservation=" + reservation + " - action=" + action + " - dateStart=" + df.format(dateStart).toString() + " - dateEnd=" + df.format(dateEnd).toString() ;/*ww w.j a va2s .co m*/ Logger.getLogger("AvailCrud").log(Level.INFO, logData); try { result = (Vector) client.execute("backend.modifyAllotment", parameters); } catch (Exception e) { Logger.getLogger("AvailCrud").log(Level.SEVERE, "", e); // addError(ResponseBuilder.EWT_UNKNOWN, ResponseBuilder.ERR_SYSTEM_ERROR, "Error on updating allotment (modifyAllotment)"); return ret; } try { Map hret = (Map) result.get(0); ret = new Integer((String) hret.get("unique_allotment_service_response")); } catch (Exception e) { } Map hret = (Map) result.get(0); ret = new Integer((String) hret.get("unique_allotment_service_response")); Logger.getLogger("AvailCrud").log(Level.INFO, "Xrpc done "); return ret; }
From source file:Main.java
public static Vector<String> split(String s, char sep) { if (s == null) { return null; }//from w w w .java 2 s. c o m Vector v = new Vector<String>(); while (s.length() != 0) { int pos = s.indexOf(sep); if (pos >= 0) { v.add(s.substring(0, pos)); s = s.substring(pos + 1, s.length()); if (s.length() == 0) { v.add(""); // letztes (leeres) Element hinter letztem Trennzeichen } } else if (s.length() > 0) { v.add(s); s = ""; } } return v; }
From source file:com.nineteendrops.tracdrops.client.core.Utils.java
public static Vector fillVectorFromArrayList(ArrayList<String> arrayList) { Vector vector = new Vector(); if (arrayList != null) { for (String s : arrayList) { vector.add(s); }//from w ww .j av a 2 s. c o m } return vector; }
From source file:Main.java
public static synchronized Element[] getChildElements(Element element) { if (element == null) { return null; }//w w w . j a v a 2 s .c o m Vector childs = new Vector(); for (Node node = element.getFirstChild(); node != null; node = node.getNextSibling()) { if (node instanceof Element) { childs.add((Element) node); } } Element[] elmt = new Element[childs.size()]; childs.toArray(elmt); return elmt; }
From source file:Main.java
public static synchronized Element[] getChildElements(Element element, String childName) { if (element == null || childName == null || childName.length() == 0) { return null; }/* w w w .ja va 2 s . c o m*/ Vector childs = new Vector(); for (Node node = element.getFirstChild(); node != null; node = node.getNextSibling()) { if (node instanceof Element) { childs.add((Element) node); } } Element[] elmt = new Element[childs.size()]; childs.toArray(elmt); return elmt; }
From source file:Main.java
public static void initializeMap(InputStream is, boolean isPositive) { try {/*ww w . ja v a 2 s. co m*/ BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8")); String line = null; while ((line = reader.readLine()) != null) { StringTokenizer tokenizer = new StringTokenizer(line, "\t\n", false); String key = null; Vector<String> tokens = new Vector<String>(); if (tokenizer.hasMoreTokens()) key = tokenizer.nextToken(); while (tokenizer.hasMoreTokens()) { tokens.add(tokenizer.nextToken()); } if (key != null) { if (isPositive) posMap.put(key, tokens); else negMap.put(key, tokens); } } } catch (Exception e) { } }
From source file:Main.java
public static Vector<Long> convertToVectorOfLongs(long[] a_aLongArray) /* */ {/*from w ww . j a v a 2 s . co m*/ /* 487 */Vector vecReturn = null; /* 488 */if (a_aLongArray != null) /* */ { /* 490 */vecReturn = new Vector(a_aLongArray.length); /* 491 */for (long lLong : a_aLongArray) /* */ { /* 493 */vecReturn.add(Long.valueOf(lLong)); /* */} /* */} /* */ /* 497 */return vecReturn; /* */}
From source file:Main.java
/** * Splits a string into substrings. /*w ww .jav a 2s. co m*/ * @param str The string which is to split. * @param delim The delimiter character, for example a space <code>' '</code>. * @param trailing The ending which is added as a substring though it wasn't * in the <code>str</code>. This parameter is just for the * <code>IRCParser</code> class which uses this method to * split the <code>middle</code> part into the parameters. * But as last parameter always the <code>trailing</code> is * added. This is done here because it's the fastest way to * do it here.<br /> * If the <code>end</code> is <code>null</code> or * <code>""</code>, nothing is appended. * @return An array with all substrings. * @see #split(String, int) */ public static String[] split(String str, int delim, String trailing) { Vector items = new Vector(15); int last = 0; int index = 0; int len = str.length(); while (index < len) { if (str.charAt(index) == delim) { items.add(str.substring(last, index)); last = index + 1; } index++; } if (last != len) items.add(str.substring(last)); if (trailing != null && trailing.length() != 0) items.add(trailing); String[] result = new String[items.size()]; items.copyInto(result); return result; }
From source file:Main.java
public static Vector<Integer> mergeSet(Vector<Integer> leftSet, Vector<Integer> rightSet, String mergeType) { if (leftSet == null || rightSet == null) return null; if (mergeType.trim().compareToIgnoreCase("or") == 0) { // OR set Vector<Integer> orSet = new Vector<Integer>(); orSet = leftSet;//from w w w . j av a 2 s . co m for (int i = 0; i < rightSet.size(); i++) { if (orSet.contains(rightSet.get(i)) == false) orSet.add(rightSet.get(i)); } return orSet; } else if (mergeType.trim().compareToIgnoreCase("and") == 0) { // AND // set Vector<Integer> andSet = new Vector<Integer>(); if (leftSet.size() > rightSet.size()) { for (int i = 0; i < rightSet.size(); i++) { if (leftSet.contains(rightSet.get(i)) == true) andSet.add(rightSet.get(i)); } } else { for (int i = 0; i < leftSet.size(); i++) { if (rightSet.contains(leftSet.get(i)) == true) andSet.add(leftSet.get(i)); } } return andSet; } else if (mergeType.trim().compareToIgnoreCase("xor") == 0) { // XoR // set // Left is Universal Set and right Set is getting Exclusive XoR Vector<Integer> xorSet = new Vector<Integer>(); for (int i = 0; i < leftSet.size(); i++) { if (rightSet.contains(leftSet.get(i)) == false) xorSet.add(leftSet.get(i)); } return xorSet; } return leftSet; }