List of usage examples for java.util ArrayList set
public E set(int index, E element)
From source file:classif.ahc.AHCSymbolicSequence.java
void merge(int iMin1, int iMin2, double fDist1, double fDist2, ArrayList<Integer>[] nClusterID, ArrayList<Sequence> centroidsForNumberOfClusters, Node[] clusterNodes, double[][] distances2) { if (iMin1 > iMin2) { int h = iMin1; iMin1 = iMin2;/*from w ww . j a v a 2 s. c o m*/ iMin2 = h; double f = fDist1; fDist1 = fDist2; fDist2 = f; } nClusterID[iMin1].addAll(nClusterID[iMin2]); int medoidIndex = Sequences.medoidIndex(nClusterID[iMin1], distances); Sequence medoid = data.get(medoidIndex); Sequence[] setOfSequences = new Sequence[nClusterID[iMin1].size()]; for (int i = 0; i < setOfSequences.length; i++) { setOfSequences[i] = data.get(nClusterID[iMin1].get(i)); } centroidsForNumberOfClusters.set(iMin1, Sequences.meanWithMedoid(medoid, setOfSequences)); nClusterID[iMin2].clear(); centroidsForNumberOfClusters.set(iMin2, null); Node node = new Node(); if (clusterNodes[iMin1] == null) { node.m_iLeftInstance = iMin1; } else { node.m_left = clusterNodes[iMin1]; clusterNodes[iMin1].m_parent = node; } if (clusterNodes[iMin2] == null) { node.m_iRightInstance = iMin2; } else { node.m_right = clusterNodes[iMin2]; clusterNodes[iMin2].m_parent = node; } node.setHeight(fDist1, fDist2); clusterNodes[iMin1] = node; }
From source file:org.openmrs.module.accessmonitor.web.controller.AccessMonitorVisitController.java
@RequestMapping(value = "/module/accessmonitor/visit", method = RequestMethod.GET) public void person(ModelMap model, HttpServletRequest request) { // ((OrderAccessService) Context.getService(OrderAccessService.class)).generateData(); // ((VisitAccessService) Context.getService(VisitAccessService.class)).generateData(); // ((PersonAccessService) Context.getService(PersonAccessService.class)).generateData(); offset = 0;/*from w w w. j a va 2s . c om*/ // parse them to Date, null is acceptabl DateFormat format = new SimpleDateFormat("MM/dd/yyyy"); // Get the from date and to date Date to = null; Date from = null; try { from = format.parse(request.getParameter("datepickerFrom")); } catch (Exception e) { //System.out.println("======From Date Empty======="); } try { to = format.parse(request.getParameter("datepickerTo")); } catch (Exception e) { //System.out.println("======To Date Empty======="); } // get all the records in the date range visitAccessData = ((VisitAccessService) Context.getService(VisitAccessService.class)) .getVisitAccessesByAccessDateOrderByPatientId(from, to); if (visitAccessData == null) { visitAccessData = new ArrayList<VisitServiceAccess>(); } // get date for small graph Date toSmall = to; Date fromSmall = null; Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.DATE, 1); if (toSmall == null) { toSmall = calendar.getTime(); } else { calendar.setTime(toSmall); } calendar.add(Calendar.DATE, -DAYNUM); fromSmall = calendar.getTime(); List<String> dateStrings = new ArrayList<String>(); for (int i = 0; i < DAYNUM; i++) { if (i == DAYNUM - 1) { dateStrings.add(format.format(toSmall)); } else if (i == 0) { dateStrings.add(format.format(fromSmall)); } else { dateStrings.add(""); } } ArrayList<ArrayList<Integer>> tooltip = new ArrayList<ArrayList<Integer>>(); tooltip.add(new ArrayList<Integer>()); for (int j = 0; j < SHOWNUM + 1; j++) { tooltip.get(0).add(1000 + j); } for (int i = 1; i < DAYNUM + 1; i++) { tooltip.add(new ArrayList<Integer>()); tooltip.get(i).add(i); for (int j = 0; j < SHOWNUM; j++) { tooltip.get(i).add(0); } } ArrayList<String> patientIds = new ArrayList<String>(); ArrayList<Integer> patientCounts = new ArrayList<Integer>(); for (VisitServiceAccess va : visitAccessData) { // data for big graph String idString = (va.getPatientId() == null) ? "No ID" : va.getPatientId().toString(); int index = patientIds.indexOf(idString); if (index < 0) { if (patientIds.size() >= SHOWNUM) break; patientIds.add(idString); patientCounts.add(1); index = patientIds.size() - 1;//index = patientIds.indexOf(idString); } else { patientCounts.set(index, patientCounts.get(index) + 1); } // data for small graph if (va.getAccessDate().after(fromSmall) && va.getAccessDate().before(toSmall)) { int index2 = (int) ((va.getAccessDate().getTime() - fromSmall.getTime()) / (1000 * 60 * 60 * 24)); if (index2 < DAYNUM && index2 >= 0) tooltip.get(index2 + 1).set(index + 1, tooltip.get(index2 + 1).get(index + 1) + 1); } } String patientIdString = JSONValue.toJSONString(patientIds); String patientCountString = JSONValue.toJSONString(patientCounts); String dateSmallString = JSONValue.toJSONString(dateStrings); String tooltipdata = JSONValue.toJSONString(tooltip); model.addAttribute("patientIds", patientIdString); model.addAttribute("patientCounts", patientCountString); model.addAttribute("dateSmallString", dateSmallString); model.addAttribute("tooltipdata", tooltipdata); model.addAttribute("user", Context.getAuthenticatedUser()); // model.addAttribute("tables1", visitAccessData); // model.addAttribute("dateSmall", dateStrings); model.addAttribute("currentoffset", String.valueOf(offset)); }
From source file:net.rllcommunity.plugins.rpgitems.item.RPGItem.java
public void save(ConfigurationSection s) { s.set("name", name); s.set("id", id); s.set("display", displayName.replaceAll("" + ChatColor.COLOR_CHAR, "&")); s.set("quality", quality.toString()); s.set("damageMin", damageMin); s.set("damageMax", damageMax); s.set("armour", armour); s.set("type", type.replaceAll("" + ChatColor.COLOR_CHAR, "&")); s.set("hand", hand.replaceAll("" + ChatColor.COLOR_CHAR, "&")); s.set("lore", loreText.replaceAll("" + ChatColor.COLOR_CHAR, "&")); ArrayList<String> descriptionConv = new ArrayList<String>(description); for (int i = 0; i < descriptionConv.size(); i++) { descriptionConv.set(i, descriptionConv.get(i).replaceAll("" + ChatColor.COLOR_CHAR, "&")); }/*from www. j av a2s . c o m*/ s.set("description", descriptionConv); s.set("item", item.getType().toString()); s.set("ignoreWorldGuard", ignoreWorldGuard); ItemMeta meta = localeMeta.get("en_GB"); if (meta instanceof LeatherArmorMeta) { s.set("item_colour", ((LeatherArmorMeta) meta).getColor().asRGB()); } else { s.set("item_data", item.getDurability()); } ConfigurationSection powerConfigs = s.createSection("powers"); int i = 0; for (Power p : powers) { MemoryConfiguration pConfig = new MemoryConfiguration(); pConfig.set("powerName", p.getName()); p.save(pConfig); powerConfigs.set(Integer.toString(i), pConfig); i++; } // Recipes s.set("hasRecipe", hasRecipe); if (hasRecipe) { s.set("recipe", recipe); } ConfigurationSection drops = s.createSection("dropChances"); for (String key : dropChances.keySet()) { drops.set(key, dropChances.get(key)); } s.set("maxDurability", maxDurability); s.set("forceBar", forceBar); }
From source file:think.rpgitems.item.RPGItem.java
public void save(ConfigurationSection s) { s.set("name", name); s.set("id", id); s.set("haspermission", haspermission); s.set("permission", permission); s.set("display", displayName.replaceAll("" + ChatColor.COLOR_CHAR, "&")); s.set("quality", quality.toString()); s.set("damageMin", damageMin); s.set("damageMax", damageMax); s.set("armour", armour); s.set("type", type.replaceAll("" + ChatColor.COLOR_CHAR, "&")); s.set("hand", hand.replaceAll("" + ChatColor.COLOR_CHAR, "&")); s.set("lore", loreText.replaceAll("" + ChatColor.COLOR_CHAR, "&")); ArrayList<String> descriptionConv = new ArrayList<String>(description); for (int i = 0; i < descriptionConv.size(); i++) { descriptionConv.set(i, descriptionConv.get(i).replaceAll("" + ChatColor.COLOR_CHAR, "&")); }//from ww w .j ava 2s .c om s.set("description", descriptionConv); s.set("item", item.getType().toString()); s.set("ignoreWorldGuard", ignoreWorldGuard); ItemMeta meta = localeMeta; if (meta instanceof LeatherArmorMeta) { s.set("item_colour", ((LeatherArmorMeta) meta).getColor().asRGB()); } else { s.set("item_data", item.getDurability()); } ConfigurationSection powerConfigs = s.createSection("powers"); int i = 0; for (Power p : powers) { MemoryConfiguration pConfig = new MemoryConfiguration(); pConfig.set("powerName", p.getName()); p.save(pConfig); powerConfigs.set(Integer.toString(i), pConfig); i++; } // Recipes s.set("recipechance", recipechance); s.set("hasRecipe", hasRecipe); if (hasRecipe) { s.set("recipe", recipe); } ConfigurationSection drops = s.createSection("dropChances"); for (String key : dropChances.keySet()) { drops.set(key, dropChances.get(key)); } s.set("maxDurability", maxDurability); s.set("forceBar", forceBar); }
From source file:com.parse.ParseAddUniqueOperation.java
@Override public Object apply(Object oldValue, String key) { if (oldValue == null) { return new ArrayList<>(objects); } else if (oldValue instanceof JSONArray) { ArrayList<Object> old = ParseFieldOperations.jsonArrayAsArrayList((JSONArray) oldValue); @SuppressWarnings("unchecked") ArrayList<Object> newValue = (ArrayList<Object>) this.apply(old, key); return new JSONArray(newValue); } else if (oldValue instanceof List) { ArrayList<Object> result = new ArrayList<>((List<?>) oldValue); // Build up a Map of objectIds of the existing ParseObjects in this field. HashMap<String, Integer> existingObjectIds = new HashMap<>(); for (int i = 0; i < result.size(); i++) { if (result.get(i) instanceof ParseObject) { existingObjectIds.put(((ParseObject) result.get(i)).getObjectId(), i); }//from w w w . ja v a2 s.c o m } // Iterate over the objects to add. If it already exists in the field, // remove the old one and add the new one. Otherwise, just add normally. for (Object obj : objects) { if (obj instanceof ParseObject) { String objectId = ((ParseObject) obj).getObjectId(); if (objectId != null && existingObjectIds.containsKey(objectId)) { result.set(existingObjectIds.get(objectId), obj); } else if (!result.contains(obj)) { result.add(obj); } } else { if (!result.contains(obj)) { result.add(obj); } } } return result; } else { throw new IllegalArgumentException("Operation is invalid after previous operation."); } }
From source file:org.apache.kylin.monitor.QueryParser.java
public void parseQueryLog(String filePath, String dPath) throws ParseException, IOException { logger.info("Start parsing file " + filePath + " !"); // writer config init FileSystem fs = this.getHdfsFileSystem(); org.apache.hadoop.fs.Path resultStorePath = new org.apache.hadoop.fs.Path(dPath); OutputStreamWriter writer = new OutputStreamWriter(fs.append(resultStorePath)); CSVWriter cwriter = new CSVWriter(writer, '|', CSVWriter.NO_QUOTE_CHARACTER); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss,SSS"); Pattern p_query_start = Pattern.compile("^\\[.*\\]:\\[(.*),.*\\]\\[.*\\]\\[.*QueryService.logQuery.*\\].*"); Pattern p_query_end = Pattern.compile("^Message:(.*)$"); Pattern p_query_body = Pattern.compile( "^\\[.*\\]:\\[((\\d{4}-\\d{2}-\\d{2}).*)\\]\\[.*\\]\\[.*\\].*\n^=+\\[QUERY\\]=+\n^SQL:(.*)\n^User:(.*)\n^Success:(.*)\n^Duration:(.*)\n^Project:(.*)\n^(Realization Names|Cube Names): \\[(.*)\\]\n^Cuboid Ids: \\[(.*)\\]\n^Total scan count:(.*)\n^Result row count:(.*)\n^Accept Partial:(.*)\n(^Is Partial Result:(.*)\n)?^Hit Cache:(.*)\n^Message:(.*)", Pattern.MULTILINE);// w ww . j a v a 2 s.c om Matcher m_query_start = p_query_start.matcher(""); Matcher m_query_end = p_query_end.matcher(""); Matcher m_query_body = p_query_body.matcher(""); boolean query_start = false; StringBuffer query_body = new StringBuffer(""); Path path = Paths.get(filePath); try { BufferedReader reader = Files.newBufferedReader(path, ENCODING); String line = null; while ((line = reader.readLine()) != null) { m_query_start.reset(line); //reset the input m_query_end.reset(line); // set start flag ,clear StringBuffer if (m_query_start.find()) { query_start = true; query_body = new StringBuffer(""); } if (query_start) { query_body.append(line + "\n"); } if (m_query_end.find()) { query_start = false; m_query_body.reset(query_body); logger.info("parsing query..."); logger.info(query_body); // skip group(8) and group(14) if (m_query_body.find()) { ArrayList<String> groups = new ArrayList<String>(); int grp_count = m_query_body.groupCount(); for (int i = 1; i <= grp_count; i++) { if (i != 8 && i != 14) { String grp_item = m_query_body.group(i); grp_item = grp_item == null ? "" : grp_item.trim(); groups.add(grp_item); } } long start_time = format.parse(groups.get(0)).getTime() - (int) (Double.parseDouble(groups.get(5)) * 1000); groups.set(0, format.format(new Date(start_time))); groups.add(DEPLOY_ENV); String[] recordArray = groups.toArray(new String[groups.size()]); // write to hdfs cwriter.writeNext(recordArray); } } } } catch (IOException ex) { logger.info("Failed to write to hdfs:", ex); } finally { if (writer != null) { writer.close(); } if (cwriter != null) { cwriter.close(); } if (fs != null) { fs.close(); } } logger.info("Finish parsing file " + filePath + " !"); }
From source file:it.doqui.index.ecmengine.business.personalization.multirepository.index.lucene.RepositoryAwareADMLuceneSearcherImpl.java
public ResultSet query(SearchParameters searchParameters) { // final Query filter; if (searchParameters.getStores().size() != 1) { throw new IllegalStateException("Only one store can be searched at present"); }//from w w w. j av a 2s .c o m ArrayList<StoreRef> stores = searchParameters.getStores(); stores.set(0, tenantService.getName(searchParameters.getStores().get(0))); final StoreRef queryStore = stores.get(0); if (logger.isDebugEnabled()) { logger.debug("[RepositoryAwareADMLuceneSearcherImpl::query] Repository '" + getRepository() + "' -- Executing query on store: " + queryStore); } String parameterisedQueryString; if (!searchParameters.getQueryParameterDefinitions().isEmpty()) { Map<QName, QueryParameterDefinition> map = new HashMap<QName, QueryParameterDefinition>(); for (QueryParameterDefinition qpd : searchParameters.getQueryParameterDefinitions()) { map.put(qpd.getQName(), qpd); } parameterisedQueryString = parameterise(searchParameters.getQuery(), map, null, namespacePrefixResolver); } else { parameterisedQueryString = searchParameters.getQuery(); } if (searchParameters.getLanguage().equalsIgnoreCase(SearchService.LANGUAGE_LUCENE)) { try { final Operator defaultOperator = (searchParameters.getDefaultOperator() == SearchParameters.AND) ? LuceneQueryParser.AND_OPERATOR : LuceneQueryParser.OR_OPERATOR; // Query userQuery = LuceneQueryParser.parse(parameterisedQueryString, DEFAULT_FIELD, // new LuceneAnalyser(getDictionaryService(), // (searchParameters.getMlAnalaysisMode() == null) // ? getLuceneConfig().getDefaultMLSearchAnalysisMode() // : searchParameters.getMlAnalaysisMode()), // namespacePrefixResolver, // getDictionaryService(), // defaultOperator, // searchParameters, // getLuceneConfig()); // // Aggiunta filtraggio per permessi di lettura // BooleanQuery query = new BooleanQuery(); // query.add(userQuery, BooleanClause.Occur.MUST); // if (filter != null) { // query.add(filter, BooleanClause.Occur.MUST); // } if (logger.isDebugEnabled()) { logger.debug("[RepositoryAwareADMLuceneSearcherImpl::query] Repository '" + getRepository() + "' -- Retrieving searcher for Indexer: " + indexer); } RepositoryAwareClosingIndexSearcher searcher = getSearcher(indexer); Query query = LuceneQueryParser.parse(parameterisedQueryString, DEFAULT_FIELD, new LuceneAnalyser(getDictionaryService(), searchParameters.getMlAnalaysisMode() == null ? getLuceneConfig().getDefaultMLSearchAnalysisMode() : searchParameters.getMlAnalaysisMode()), namespacePrefixResolver, getDictionaryService(), tenantService, defaultOperator, searchParameters, getLuceneConfig(), searcher.getIndexReader()); if (logger.isDebugEnabled()) { logger.debug( "[RepositoryAwareADMLuceneSearcherImpl::query] Query is '" + query.toString() + "'"); } if (searcher == null) { // no index return an empty result set return new EmptyResultSet(); } Hits hits; if (!searchParameters.getSortDefinitions().isEmpty()) { int index = 0; SortField[] fields = new SortField[searchParameters.getSortDefinitions().size()]; for (SearchParameters.SortDefinition sd : searchParameters.getSortDefinitions()) { switch (sd.getSortType()) { case FIELD: String field = sd.getField(); if (field.startsWith("@")) { field = expandAttributeFieldName(field); PropertyDefinition propertyDef = getDictionaryService() .getProperty(QName.createQName(field.substring(1))); if (propertyDef.getDataType().getName().equals(DataTypeDefinition.DATETIME)) { DataTypeDefinition dataType = propertyDef.getDataType(); String analyserClassName = dataType.getAnalyserClassName(); if (analyserClassName.equals(DateTimeAnalyser.class.getCanonicalName())) { field = field + ".sort"; } } } if (fieldHasTerm(searcher.getReader(), field)) { fields[index++] = new SortField(field, !sd.isAscending()); } else { fields[index++] = new SortField(null, SortField.DOC, !sd.isAscending()); } break; case DOCUMENT: fields[index++] = new SortField(null, SortField.DOC, !sd.isAscending()); break; case SCORE: fields[index++] = new SortField(null, SortField.SCORE, !sd.isAscending()); break; } } hits = searcher.search(query, new Sort(fields)); } else { hits = searcher.search(query); } if (logger.isDebugEnabled()) { logger.debug("[RepositoryAwareADMLuceneSearcherImpl::query] Repository '" + getRepository() + "' -- Lucene query executed: " + query.toString()); logger.debug("[RepositoryAwareADMLuceneSearcherImpl::query] Repository '" + getRepository() + "' -- Lucene Results count: " + hits.length()); } Path[] paths = searchParameters.getAttributePaths().toArray(new Path[0]); LuceneResultSet rs = new LuceneResultSet(hits, searcher, nodeService, tenantService, paths, searchParameters); if (logger.isDebugEnabled()) { logger.debug("[RepositoryAwareADMLuceneSearcherImpl::query] Repository '" + getRepository() + "' -- Lucene Results created"); } return rs; } catch (ParseException e) { throw new SearcherException("Failed to parse query: " + parameterisedQueryString, e); } catch (IOException e) { throw new SearcherException("IO exception during search", e); } } else if (searchParameters.getLanguage().equalsIgnoreCase(SearchService.LANGUAGE_XPATH)) { try { XPathReader reader = new XPathReader(); LuceneXPathHandler handler = new LuceneXPathHandler(); handler.setNamespacePrefixResolver(namespacePrefixResolver); handler.setDictionaryService(getDictionaryService()); // TODO: Handler should have the query parameters to use in // building its lucene query // At the moment xpath style parameters in the PATH // expression are not supported. reader.setXPathHandler(handler); reader.parse(parameterisedQueryString); Query userQuery = handler.getQuery(); // Aggiunta filtraggio per permessi di lettura BooleanQuery query = new BooleanQuery(); query.add(userQuery, BooleanClause.Occur.MUST); // if (filter != null) { // query.add(filter, BooleanClause.Occur.MUST); // } if (logger.isDebugEnabled()) { logger.debug("[RepositoryAwareADMLuceneSearcherImpl::query] Repository '" + getRepository() + "' -- Retrieving searcher for Indexer: " + indexer); } // Searcher searcher = getSearcher(null); Searcher searcher = getSearcher(indexer); if (searcher == null) { // no index return an empty result set return new EmptyResultSet(); } Hits hits = searcher.search(query); if (logger.isDebugEnabled()) { logger.debug("[RepositoryAwareADMLuceneSearcherImpl::query] Repository '" + getRepository() + "' -- XPath query executed: " + query.toString()); logger.debug("[RepositoryAwareADMLuceneSearcherImpl::query] Repository '" + getRepository() + "' -- XPath Results count: " + hits.length()); } Path[] paths = searchParameters.getAttributePaths().toArray(new Path[0]); LuceneResultSet rs = new LuceneResultSet(hits, searcher, nodeService, tenantService, paths, searchParameters); if (logger.isDebugEnabled()) { logger.debug("[RepositoryAwareADMLuceneSearcherImpl::query] Repository '" + getRepository() + "' -- XPath Results created"); } return rs; //return new LuceneResultSet(hits, searcher, nodeService, tenantService, searchParameters.getAttributePaths().toArray(new Path[0]), searchParameters); } catch (SAXPathException e) { throw new SearcherException("Failed to parse query: " + searchParameters.getQuery(), e); } catch (IOException e) { throw new SearcherException("IO exception during search", e); } } else { throw new SearcherException("Unknown query language: " + searchParameters.getLanguage()); } }
From source file:org.eclairjs.nashorn.Utils.java
public static Object jsToJava(Object o) { if (o != null && !(o instanceof Undefined)) { logger.debug("jsToJava" + o.getClass().getName()); } else {/*from ww w . j a v a2 s .c o m*/ return o; } if (o instanceof jdk.nashorn.internal.objects.NativeArray) { Object array[] = ((NativeArray) o).asObjectArray(); ArrayList al = new ArrayList(); for (int i = 0; i < array.length; i++) { al.add(jsToJava(array[i])); } return al.toArray(); } if (o.getClass().isPrimitive()) return o; String packageName = o.getClass().getCanonicalName(); switch (packageName) { case "java.lang.String": case "java.lang.Integer": case "java.lang.Float": case "java.lang.Double": case "java.lang.Boolean": case "java.lang.Long": case "org.json.simple.JSONObject": case "java.lang.Object[]": case "java.lang.String[]": case "scala.Tuple2": case "scala.Tuple3": case "scala.Tuple4": return o; } if (packageName.startsWith("org.apache.spark")) return o; if (o instanceof WrappedClass) return ((WrappedClass) o).getJavaObject(); if (o instanceof ScriptObjectMirror) { ScriptObjectMirror m = (ScriptObjectMirror) o; if (m.hasMember("getJavaObject")) { return m.callMember("getJavaObject"); } if (m.isArray()) { try { if (m.containsKey("0")) { Object v = m.get("0"); if (v instanceof Double) { double[] doubleArray = (double[]) ScriptUtils.convert(m, double[].class); return doubleArray; } else if (v instanceof Integer) { int[] intArray = (int[]) ScriptUtils.convert(m, int[].class); return intArray; } else { Object[] objectArray = (Object[]) ScriptUtils.convert(m, Object[].class); return objectArray; } } } catch (ClassCastException e) { /* If the array contains ScriptObjectMirror the above conversions throws exception so we have to convert the contents of the array as well. */ ArrayList list = new ArrayList(); for (Object item : m.values()) { list.add(jsToJava(item)); } Object x = list.toArray(); return x; } } else { // throw new RuntimeException("js2java IMPLEMENT"+o); Object obj = ScriptObjectMirror.wrapAsJSONCompatible(o, null); String j = JSONValue.toJSONString(obj); return JSONValue.parse(j); } } else if (o instanceof jdk.nashorn.internal.runtime.ScriptObject) { ScriptObjectMirror jsObj = ScriptUtils.wrap((jdk.nashorn.internal.runtime.ScriptObject) o); if (jsObj.hasMember("getJavaObject")) { return jsObj.callMember("getJavaObject"); } } else if (o instanceof java.util.ArrayList) { ArrayList list = (ArrayList) o; int size = list.size(); for (int i = 0; i < size; i++) list.set(i, jsToJava(list.get(i))); return list; } else if (o instanceof StaticClass) { return o; } logger.warn("js2java NOT HANDLED " + packageName); return o; // Just return the Java object, it might user created like java.net.Socket //new RuntimeException().printStackTrace(); //throw new RuntimeException("js2java NOT HANDLED "+packageName); }
From source file:org.apache.axis.encoding.ser.ArrayDeserializer.java
/** * set is called during deserialization to assign * the Object value to the array position indicated by hint. * The hint is always a single Integer. If the array being * deserialized is a multi-dimensional array, the hint is * converted into a series of indices to set the correct * nested position./* ww w .ja v a 2 s. co m*/ * The array deserializer always deserializes into * an ArrayList, which is converted and copied into the * actual array after completion (by valueComplete). * It is important to wait until all indices have been * processed before invoking valueComplete. * @param value value of the array element * @param hint index of the array element (Integer) **/ public void setChildValue(Object value, Object hint) throws SAXException { if (log.isDebugEnabled()) { log.debug("Enter: ArrayDeserializer::setValue(" + value + ", " + hint + ")"); } ArrayList list = (ArrayList) this.value; int offset = ((Integer) hint).intValue(); if (this.mDimLength == null) { // Normal Case: Set the element in the list // grow the list if necessary to accomodate the new member while (list.size() <= offset) { list.add(null); } list.set(offset, value); } else { // Multi-Dim Array case: Need to find the nested ArrayList // and set the proper element. // Convert the offset into a series of indices ArrayList mDimIndex = toMultiIndex(offset); // Get/Create the nested ArrayList for (int i = 0; i < mDimLength.size(); i++) { int length = ((Integer) mDimLength.get(i)).intValue(); int index = ((Integer) mDimIndex.get(i)).intValue(); while (list.size() < length) { list.add(null); } // If not the last dimension, get the nested ArrayList // Else set the value if (i < mDimLength.size() - 1) { if (list.get(index) == null) { list.set(index, new ArrayList()); } list = (ArrayList) list.get(index); } else { list.set(index, value); } } } }
From source file:classes.MyVisitor.java
public ArrayList<String> dimensiones(int size, int cuantos, ArrayList<String> lista) { int cuanto = size / cuantos; int count = 0; for (int i = 0; i < cuantos; i++) { for (int j = 0; j < cuanto; j++) { int pos = (count + turn) % size; lista.set(pos, lista.get(pos).concat(i + ",")); count++;/*from ww w. ja v a2 s . c o m*/ } } turn += 1; return lista; }