List of usage examples for java.util List set
E set(int index, E element);
From source file:net.sf.json.JSONUtils.java
/** * DOCUMENT ME!//from www. ja v a 2 s . com * * @param jsonArray DOCUMENT ME! * @param dims DOCUMENT ME! * @param index DOCUMENT ME! */ static void processArrayDimensions(JSONArray jsonArray, List dims, int index) { if (dims.size() <= index) { dims.add(new Integer(jsonArray.length())); } else { int i = ((Integer) dims.get(index)).intValue(); if (jsonArray.length() > i) { dims.set(index, new Integer(jsonArray.length())); } } for (Iterator i = jsonArray.iterator(); i.hasNext();) { Object item = i.next(); if (item instanceof JSONArray) { processArrayDimensions((JSONArray) item, dims, index + 1); } } }
From source file:CookieUtils.java
/** * Maintain a list of CookieData objects (add, replace, or delete a cookie) * /*w w w . ja va 2 s . com*/ * @param cookieList * CookieData list * @param cookie * A CookieData object */ public static void storeCookie(List cookieList, CookieData cookie) { int size = cookieList.size(); for (int i = 0; i < size; i++) { CookieData cd = (CookieData) cookieList.get(i); if (cookie.equals(cd)) { if (cookie.getMaxAge() == 0) { cookieList.remove(i); return; } cookieList.set(i, cookie); return; } } if (cookie.getMaxAge() != 0) { cookieList.add(cookie); } }
From source file:exm.stc.ic.ICUtil.java
public static void replaceArgsInList(Map<Var, Arg> renames, List<Arg> args, boolean nullsOk) { if (renames.isEmpty()) { return;//from w w w. j ava 2 s .c o m } for (int i = 0; i < args.size(); i++) { Arg oa = args.get(i); if (oa == null) { if (nullsOk) { continue; } else { throw new STCRuntimeError("null arg in list: " + args); } } if (oa.isVar()) { Arg val = renames.get(oa.getVar()); if (val != null) { args.set(i, val); } } } }
From source file:com.tmo.swagger.main.GenrateSwaggerJson.java
protected static List<Responses> getResponsesFormProperties(Properties prop) { List<Responses> responses = new ArrayList<Responses>(); Responses response = null;/*from w w w . ja v a 2 s. c o m*/ String code = prop.getProperty("path.operation.responses.code"); for (String s : code.split(",")) { response = new Responses(); response.setCode(s); responses.add(response); } response = null; int count = 0; String description = prop.getProperty("path.operation.responses.code.description"); for (String s : description.split(",")) { response = responses.get(count); response.setDescription(s); responses.set(count, response); count++; } response = null; count = 0; String schema = prop.getProperty("path.operation.responses.code.schema"); for (String s : schema.split(",")) { response = responses.get(count); response.setSchema(s); responses.set(count, response); count++; } response = null; count = 0; return responses; }
From source file:jrouter.spring.DefaultActionFactoryBean.java
/** * Convert the {@code String} element of the list into {@code Class}. * * @param listArray the array of list.//from w w w . j a va 2 s . c o m * * @throws ClassNotFoundException If the class was not found. */ private static void convertList(List... listArray) throws ClassNotFoundException { for (List componentList : listArray) { if (CollectionUtil.isNotEmpty(componentList)) { for (int i = 0; i < componentList.size(); i++) { Object obj = componentList.get(i); if (obj instanceof String) { componentList.set(i, ClassUtil.loadClass((String) obj)); } } } } }
From source file:com.akop.bach.parser.Parser.java
protected static void setValue(List<NameValuePair> inputs, String name, Object value) { for (int i = inputs.size() - 1; i >= 0; i--) { if (inputs.get(i).getName().equals(name)) { inputs.set(i, new BasicNameValuePair(name, value.toString())); return; }//from w ww. j a v a 2 s.c o m } inputs.add(new BasicNameValuePair(name, value.toString())); }
From source file:net.rllcommunity.plugins.rpgitems.item.RPGItem.java
public static void updateItem(ItemStack item, String locale, RPGMetadata rpgMeta, boolean updateDurability) { RPGItem rItem = ItemManager.toRPGItem(item); if (rItem == null) return;//from w w w .jav a 2 s . c o m item.setType(rItem.item.getType()); ItemMeta meta = rItem.getLocaleMeta(locale); if (!(meta instanceof LeatherArmorMeta) && updateDurability) { item.setDurability(rItem.item.getDurability()); } List<String> lore = meta.getLore(); rItem.addExtra(rpgMeta, item, lore); lore.set(0, meta.getLore().get(0) + rpgMeta.toMCString()); meta.setLore(lore); item.setItemMeta(meta); }
From source file:com.tmo.swagger.main.GenrateSwaggerJson.java
protected static List<Parameters> getParametersFormProperties(Properties prop) { List<Parameters> parameters = new ArrayList<Parameters>(); ///*from w ww . j a v a 2s . c om*/ Parameters parameter = null; String name = prop.getProperty("path.operation.parameters.name"); for (String s : name.split(",")) { parameter = new Parameters(); parameter.setName(s); parameters.add(parameter); } parameter = null; int count = 0; String in = prop.getProperty("path.operation.parameters.in"); for (String s : in.split(",")) { parameter = parameters.get(count); parameter.setIn(s); parameters.set(count, parameter); count++; } parameter = null; count = 0; String description = prop.getProperty("path.operation.parameters.description"); for (String s : description.split(",")) { parameter = parameters.get(count); parameter.setDescription(s); parameters.set(count, parameter); count++; } parameter = null; count = 0; String required = prop.getProperty("path.operation.parameters.required"); for (String s : required.split(",")) { parameter = parameters.get(count); Boolean boolean1 = Boolean.valueOf(s); parameter.setRequired(boolean1); parameters.set(count, parameter); count++; } parameter = null; count = 0; String type = prop.getProperty("path.operation.parameters.type"); for (String s : type.split(",")) { parameter = parameters.get(count); parameter.setType(s); parameters.set(count, parameter); count++; } /*parameter = null; count = 0; String maximum = prop.getProperty("path.operation.parameters.maximum"); for (String s : maximum.split(",")) { parameter = parameters.get(count); parameter.setType(s); parameters.set(count, parameter); count++; }*/ count = 0; return parameters; }
From source file:org.mongojack.internal.util.SerializationUtils.java
/** * Serialize the given field/*from ww w . j a v a 2 s . c o m*/ * * @param objectMapper * The object mapper to serialize it with * @param value * The value to serialize * @return The serialized field. May return the same object if no * serialization was necessary. */ public static Object serializeField(ObjectMapper objectMapper, Object value) { if (value == null || BASIC_TYPES.contains(value.getClass())) { // Return as is return value; } else if (value instanceof DBObject) { return serializeFields(objectMapper, (DBObject) value); } else if (value instanceof Collection) { Collection<?> coll = (Collection<?>) value; List<Object> copy = null; int position = 0; for (Object item : coll) { Object returned = serializeField(objectMapper, item); if (returned != item) { if (copy == null) { copy = new ArrayList<Object>(coll); } copy.set(position, returned); } position++; } if (copy != null) { return copy; } else { return coll; } } else if (value.getClass().isArray()) { if (BASIC_TYPES.contains(value.getClass().getComponentType())) { return value; } Object[] array = (Object[]) value; Object[] copy = null; for (int i = 0; i < array.length; i++) { Object returned = serializeField(objectMapper, array[i]); if (returned != array[i]) { if (copy == null) { copy = new Object[array.length]; System.arraycopy(array, 0, copy, 0, array.length); } copy[i] = returned; } } if (copy != null) { return copy; } else { return array; } } else { // We don't know what it is, serialise it BsonObjectGenerator generator = new BsonObjectGenerator(); try { objectMapper.writeValue(generator, value); } catch (JsonMappingException e) { throw new MongoJsonMappingException(e); } catch (IOException e) { throw new RuntimeException("Somehow got an IOException writing to memory", e); } return generator.getValue(); } }
From source file:com.gargoylesoftware.htmlunit.runners.TestCaseCorrector.java
private static void addNotYetImplemented(final List<String> lines, final int i, final String browserString) { final String previous = lines.get(i - 1); if (previous.contains("@NotYetImplemented")) { if (previous.indexOf('(') != -1 && !previous.contains(browserString)) { final int p0 = previous.indexOf('(') + 1; final int p1 = previous.lastIndexOf(')'); String browsers = previous.substring(p0, p1); if (browsers.indexOf('{') != -1) { browsers = browsers.substring(1, browsers.length() - 1).trim(); }/* w w w .j a va2 s . c o m*/ browsers += ", " + browserString; lines.set(i - 1, " @NotYetImplemented({ " + browsers + " })"); } } else { lines.add(i, " @NotYetImplemented(" + browserString + ")"); } }