List of usage examples for java.util Vector copyInto
public synchronized void copyInto(Object[] anArray)
From source file:StringUtils.java
public static String[] split(String string, char[] separatorChars) { if (string == null || string.equals("")) return new String[] { string }; int len = string.length(); Vector separators = new Vector(separatorChars.length); for (int s = 0; s < separatorChars.length; s++) separators.addElement(new Character(separatorChars[s])); Vector list = new Vector(); int i = 0;//from w w w .j a v a 2s.c o m int start = 0; boolean match = false; while (i < len) { if (separators.contains(new Character(string.charAt(i)))) { if (match) { list.addElement(string.substring(start, i)); match = false; } start = ++i; continue; } match = true; i++; } if (match) { list.addElement(string.substring(start, i)); } String[] arr = new String[list.size()]; list.copyInto(arr); return arr; }
From source file:com.adito.boot.CommandRunner.java
/** * Constructor. The first argument supplied must be the name of the command * (if it is on the system path) or the full path the command. Any command * arguments should be supplied as further elements. * /*from w ww . j a v a 2 s . co m*/ * @param arguments */ public CommandRunner(Vector arguments) { this.arguments = new String[arguments.size()]; arguments.copyInto(this.arguments); }
From source file:com.yahoo.messenger.data.json.UserList.java
public void unserializeJSON(JSONArray a) throws JSONException { Vector v = new Vector(); // Mandatory fields for (int i = 0; i < a.length(); i++) { JSONObject o = a.getJSONObject(i); User c = new User(); c.unserializeJSON(o.getJSONObject("user")); v.addElement(c);//from w w w . j av a2s.c o m } users = new User[v.size()]; v.copyInto(users); }
From source file:com.yahoo.messenger.data.json.GroupList.java
public void unserializeJSON(JSONArray a) throws JSONException { Vector v = new Vector(); // Mandatory fields for (int i = 0; i < a.length(); i++) { JSONObject o = a.getJSONObject(i); Group c = new Group(); c.unserializeJSON(o.getJSONObject("group")); v.addElement(c);//from www .ja va 2 s . co m } groups = new Group[v.size()]; v.copyInto(groups); }
From source file:org.soaplab.services.events.EventManager.java
/************************************************************************** * *************************************************************************/ public EventManager() { // loads all classes interested in event listening if (eventListeners == null) { Enumeration<EventListener> spe = GenUtils.spiProviders(EventListener.class); Vector<EventListener> v = new Vector<EventListener>(); while (spe.hasMoreElements()) { v.addElement(spe.nextElement()); }//from ww w . j a v a 2s . co m int size = v.size(); eventListeners = new EventListener[size]; v.copyInto(eventListeners); log.info("Registered " + size + " event listener(s)"); } }
From source file:com.yahoo.messenger.data.json.ContactList.java
public void unserializeJSON(JSONArray a) throws JSONException { Vector v = new Vector(); // Mandatory fields for (int i = 0; i < a.length(); i++) { JSONObject o = a.getJSONObject(i); Contact c = new Contact(); c.unserializeJSON(o.getJSONObject("contact")); v.addElement(c);/*from w w w. jav a 2s. co m*/ } contacts = new Contact[v.size()]; v.copyInto(contacts); }
From source file:com.yahoo.messenger.data.notification.json.BuddyInfoContactList.java
public void unserializeJSON(JSONArray a) throws JSONException { Vector v = new Vector(); // Mandatory fields for (int i = 0; i < a.length(); i++) { JSONObject o = a.getJSONObject(i); BuddyInfoContact c = new BuddyInfoContact(); c.unserializeJSON(o);// w w w . j ava 2s .co m v.addElement(c); } buddyInfoContacts = new BuddyInfoContact[v.size()]; v.copyInto(buddyInfoContacts); }
From source file:com.phonegap.PhoneGap.java
public static final String[] splitString(final String data, final char splitChar, final boolean allowEmpty) { Vector v = new Vector(); int indexStart = 0; int indexEnd = data.indexOf(splitChar); if (indexEnd != -1) { while (indexEnd != -1) { String s = data.substring(indexStart, indexEnd); if (allowEmpty || s.length() > 0) { v.addElement(s);//from ww w . j a v a 2 s .com } s = null; indexStart = indexEnd + 1; indexEnd = data.indexOf(splitChar, indexStart); } if (indexStart != data.length()) { // Add the rest of the string String s = data.substring(indexStart); if (allowEmpty || s.length() > 0) { v.addElement(s); } s = null; } } else { if (allowEmpty || data.length() > 0) { v.addElement(data); } } String[] result = new String[v.size()]; v.copyInto(result); v = null; return result; }
From source file:com.yahoo.messenger.data.json.PreferenceList.java
public void unserializeJSON(JSONArray a) throws JSONException { Vector v = new Vector(); // Mandatory fields for (int i = 0; i < a.length(); i++) { JSONObject o = a.getJSONObject(i); Preference c = new Preference(); c.unserializeJSON(o.getJSONObject("preference")); v.addElement(c);/*from w w w.ja v a 2 s. c o m*/ } preferences = new Preference[v.size()]; v.copyInto(preferences); }
From source file:com.yahoo.messenger.data.json.IgnoredUserList.java
public void unserializeJSON(JSONArray a) throws JSONException { Vector v = new Vector(); // Mandatory fields for (int i = 0; i < a.length(); i++) { JSONObject o = a.getJSONObject(i); IgnoredUser c = new IgnoredUser(); c.unserializeJSON(o.getJSONObject("ignoredUser")); v.addElement(c);/*ww w .j a v a 2 s. com*/ } ignoredUsers = new IgnoredUser[v.size()]; v.copyInto(ignoredUsers); }