Java Code Examples for java.util.List.size()

The following are Jave code examples for showing how to use size() of the java.util.List class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: athena   File: OpticalConnectivityIntentCompiler.java   View Source Code Vote up 7 votes
/**
 * Returns list of consecutive resources in given set of lambdas.
 *
 * @param lambdas list of lambdas
 * @param count number of consecutive lambdas to return
 * @return list of consecutive lambdas
 */
private List<OchSignal> findFirstLambda(Set<OchSignal> lambdas, int count) {
    // Sort available lambdas
    List<OchSignal> lambdaList = new ArrayList<>(lambdas);
    lambdaList.sort(new DefaultOchSignalComparator());

    // Look ahead by count and ensure spacing multiplier is as expected (i.e., no gaps)
    for (int i = 0; i < lambdaList.size() - count; i++) {
        if (lambdaList.get(i).spacingMultiplier() + 2 * count ==
                lambdaList.get(i + count).spacingMultiplier()) {
            return lambdaList.subList(i, i + count);
        }
    }

    return Collections.emptyList();
}
 
Example 2
Project: AndroidOpen   File: BannerView.java   View Source Code Vote up 6 votes
/**
 * Sets the picture list
 *
 * @param imagesUrl picture list
 */
public void setBannerImageList(List<?> imagesUrl) {
    if (imagesUrl == null || imagesUrl.size() <= 0) {
        return;
    }
    count = imagesUrl.size();
    initImages();
    for (int i = 0; i <= count + 1; i++) {
        ImageView iv = new ImageView(context);
        iv.setScaleType(ImageView.ScaleType.FIT_XY);
        Object url;
        if (i == 0) {
            url = imagesUrl.get(count - 1);
        } else if (i == count + 1) {
            url = imagesUrl.get(0);
        } else {
            url = imagesUrl.get(i - 1);
        }
        imageViews.add(iv);
        if (defaultImage != -1)
            Glide.with(context).load(url).centerCrop().crossFade().into(iv);
        else
            Glide.with(context).load(url).centerCrop().crossFade().placeholder(defaultImage).into(iv);

    }
    setData();
}
 
Example 3
Project: mumu   File: ExportController.java   View Source Code Vote up 6 votes
/**
 * 导出
 * @param modelName 模型名称
 * @param excelType excel格式
 * @param response
 * @return
 * @throws IOException
 */
@RequestMapping(value = { "/excel/{modelName}","/excel/{modelName}/{excelType}" }, method = RequestMethod.GET)
public void exportExcel(@PathVariable String modelName,@PathVariable(required = false) String excelType, HttpServletResponse response) throws IOException {
    //默认导出xls格式excel
    if(excelType==null||"".equals(excelType)){
        excelType="XLS";
    }
    List<SysExportModel> models = modelService.queryExportModelByCondition(modelName);
    // 模型不存在 直接结束
    if (models == null || models.size() == 0) {
        return;
    }
    // 获取导出数据
    SysExportModel model = models.get(0);
    List<List<Object>> exportData = commonService.getAllData(model.getModelName(), model.getEnames(), null);
    List<String> exportHeaderNames = new ArrayList<String>();
    String[] headerNames = model.getCnames().split(",");
    for (String headerName : headerNames) {
        exportHeaderNames.add(headerName);
    }

    response.reset();
    // 文件下载
    response.setContentType("application/vnd.ms-excel");
    String filename = "报表"+modelName+"("+ new SimpleDateFormat("yyyyMMddHHmmss").format(new Date())+ ")";

    filename = new String(filename.getBytes("gbk"), "iso-8859-1");
    response.setHeader("Content-disposition", "attachment;filename="+ filename + "."+excelType.toLowerCase());
    response.setBufferSize(1024);

    //获取excel表单
    ExcelGenerater excelGenerater=new ExcelGenerater();
    ExcelGeneraterBean excelGeneraterBean = excelGenerater.create(modelName, exportHeaderNames, exportData);
    Workbook workbook = excelGeneraterBean.getWorkbook();
    //写入数据 到流
    workbook.write(response.getOutputStream());
    workbook.close();
}
 
Example 4
Project: Accessibility   File: BaseAccessibility.java   View Source Code Vote up 6 votes
public static boolean isAccessibilityNodeEnable(AccessibilityNodeInfo info, String[] texts) {
    if (texts != null) {
        for (String textItem : texts) {
            List<AccessibilityNodeInfo> nodes = info.findAccessibilityNodeInfosByText(textItem);
            if (nodes != null && !nodes.isEmpty()) {
                AccessibilityNodeInfo node;
                for (int i = 0; i < nodes.size(); i++) {
                    node = nodes.get(i);
                    BaseAccessibility.logPrint("find text=" + textItem + "  enable=" + node.isEnabled());
                    CharSequence text = node.getText();
                    if (TextUtils.equals(text, textItem) && node.isEnabled()) {
                        return true;
                    }
                }
            }
        }
    }
    return false;
}
 
Example 5
Project: keybiner   File: Permission64.java   View Source Code Vote up 6 votes
/**
 *
 * @param ABFSetCodes
 * @return
 */
public static List<String> decode(List<String> ABFSetCodes)   {

    List<String> abfStrings = new ArrayList<>();

    for (int i = 0; i < ABFSetCodes.size(); i++) {
        if(ABFSetCodes.get(i) == null ) continue;
        BitSet bs = convert(Long.parseLong(ABFSetCodes.get(i)));
        for (int j = 0; j < bs.length(); j++) {
            if (bs.get(j)==true) {
                abfStrings.add(ABFMAPPER.inverse().get(j + (64 * i) + ""));
            }
        }
    }
    return abfStrings;
}
 
Example 6
Project: spring-data-gclouddatastore   File: SimpleGcloudDatastoreRepository.java   View Source Code Vote up 6 votes
private void deleteKeys(Iterable<Key> keys) {
	Datastore datastore = this.datastoreOptions.getService();

	List<Key> buffer = new ArrayList<>(BUFFER_SIZE);
	for (Key key : keys) {
		buffer.add(key);

		if (buffer.size() >= BUFFER_SIZE) {
			datastore.delete(buffer.toArray(new Key[buffer.size()]));
			buffer.clear();
		}
	}
	if (buffer.size() > 0) {
		datastore.delete(buffer.toArray(new Key[buffer.size()]));
	}
}
 
Example 7
Project: incubator-netbeans   File: HighlightingManager.java   View Source Code Vote up 6 votes
private static void dumpLayers(StringBuilder sb, String prefix, List<? extends HighlightsLayer> layers) {
    sb.append(prefix).append(" layers:\n"); //NOI18N
    int digitCount = ArrayUtilities.digitCount(layers.size());
    for (int i = 0; i < layers.size(); i++) {
        HighlightsLayer layer = layers.get(i);
        HighlightsLayerAccessor layerAccessor = 
            HighlightingSpiPackageAccessor.get().getHighlightsLayerAccessor(layer);

        sb.append("  ");
        ArrayUtilities.appendBracketedIndex(sb, i, digitCount);
        sb.append(layerAccessor.getLayerTypeId());
        sb.append('['); //NOI18N
        sb.append(layerAccessor.getZOrder().toString()); //NOI18N
        sb.append(layerAccessor.isFixedSize() ? ",Fixed" : ",NonFixed");
        sb.append(']'); //NOI18N
        sb.append('@'); //NOI18N
        sb.append(Integer.toHexString(System.identityHashCode(layer)));
        sb.append("\n"); //NOI18N
    }
}
 
Example 8
Project: OperatieBRP   File: PersoonsvraagOphalenPersoonServiceImpl.java   View Source Code Vote up 5 votes
@Override
protected void valideerAantalZoekResultaten(final List<Persoonslijst> persoonslijsten, final Autorisatiebundel autorisatiebundel,
                                            final ZoekPersoonGeneriekVerzoek.ZoekBereikParameters zoekBereikParameters) throws StapMeldingException {
    if (persoonslijsten.size() > 1) {
        throw new StapMeldingException(Regel.R2289);
    }
}
 
Example 9
Project: UltimateRecyclerView   File: TitleAdapter.java   View Source Code Vote up 5 votes
public void setTitles(List<? extends Object> values) {
    if (mSectionizer == null) {
        throw new NullPointerException("请在设置调用setTitles()之前调用setSectionizer()方法!");
    }

    if (values == null || values.size() == 0) {
        mTitles.clear();
        notifyDataSetChanged();
        return;
    }

    List<Title> titles = convertToTitleList(values);
    Title[] titleArray = new Title[titles.size()];
    Title[] newTitles = titles.toArray(titleArray);

    mTitles.clear();

    Arrays.sort(newTitles, new Comparator<Title>() {
        @Override
        public int compare(Title o1, Title o2) {
            return (o1.firstPosition == o2.firstPosition ? 0 : (o1.firstPosition < o2.firstPosition ? -1 : 1));
        }
    });

    int offset = 0;
    for (Title title : newTitles) {
        title.titlePosition = title.firstPosition + offset;
        mTitles.append(title.titlePosition, title);
        ++offset;
    }

    notifyDataSetChanged();
}
 
Example 10
Project: JavaCommon   File: FindFirstOnceOccurCharactar.java   View Source Code Vote up 5 votes
public static void main(String[] args) {
    BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
    int total = 0;
    List<String> list = new ArrayList<>();
    try {
        total = Integer.parseInt(bufferedReader.readLine());
        for (int i = 0; i < total; i++) {
            list.add(bufferedReader.readLine());
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
    HashMap<Character, Integer> map = new HashMap<>();
    for (int i = 0; i < list.size(); i++) {
        String temp = list.get(i);
        for (int j = 0; j < temp.length(); j++) {
            if (map.containsKey(temp.charAt(j))) {
                map.put(temp.charAt(j), map.get(temp.charAt(j)) + 1);
            } else {
                map.put(temp.charAt(j), 1);
            }
        }
        for (int j = 0; j < temp.length(); j++) {
            if (map.get(temp.charAt(j)) == 1) {
                System.out.println(temp.charAt(j));
                break;
            }
        }
    }
}
 
Example 11
Project: vscrawler   File: TableEvaluator.java   View Source Code Vote up 5 votes
private List<Pair<String, String>> handleRow(List<Element> row) {
    List<Pair<String, String>> ret = Lists.newArrayList();

    for (int i = 0; i < row.size(); i++) {
        ret.add(Pair.of(keys.get(i), valueResolver.resolveValue(row.get(i))));
    }

    return ret;
}
 
Example 12
Project: ureport   File: PagingBuilder.java   View Source Code Vote up 5 votes
public static void computeExistPageFunctionCells(Report report) {
	Context context=report.getContext();
	List<Cell> existPageFunctionCells=context.getExistPageFunctionCells();
	for(Cell cell:existPageFunctionCells){
		List<BindData> dataList=context.buildCellData(cell);
		if(dataList==null || dataList.size()==0){
			continue;
		}
		BindData bindData=dataList.get(0);
		cell.setData(bindData.getValue());
		cell.setBindData(bindData.getDataList());
		cell.doFormat();
		cell.doDataWrapCompute(context);
	}
}
 
Example 13
Project: MiPushFramework   File: CondomMiscTest.java   View Source Code Vote up 5 votes
private static List<EventLog.Event> readNewEvents(final CondomCore.CondomEvent type) throws IOException {
	final List<EventLog.Event> events = new ArrayList<>();
	EventLog.readEvents(new int[] { EVENT_TAG_MARK, "Condom".hashCode() + type.ordinal() }, events);
	if (events.isEmpty()) return Collections.emptyList();
	for (int i = events.size() - 1; i >= 0; i --) {
		final EventLog.Event event = events.get(i);
		if (event.getTag() == EVENT_TAG_MARK) {
			EventLog.writeEvent(EVENT_TAG_MARK);
			return events.subList(i + 1, events.size());
		}
	}
	EventLog.writeEvent(EVENT_TAG_MARK);
	return events;
}
 
Example 14
Project: lams   File: MessageSeqDao.java   View Source Code Vote up 5 votes
@Override
   public MessageSeq getByMessageId(Long messageId) {
List list = doFind(SQL_QUERY_GET_SEQ_BY_MESSAGE, messageId);
if (list != null) {
    if (list.size() > 1) {
	log.warn("Looking up message seq by message id=" + messageId + ". More than one message seq found!"
		+ list.toString());
    }
    return (MessageSeq) list.get(0);
} else {
    return null;
}
   }
 
Example 15
Project: ImageClassify   File: AdminTest.java   View Source Code Vote up 5 votes
@Test
public void getExportHistoryFile() {
	
	AdminService adminService = new AdminService();
	List<ExportLabel> exportHistoryLabels = adminService.getExportHistoryFile(7);
	for (int i = 0; i < exportHistoryLabels.size() ; i++) {
		System.out.println(exportHistoryLabels.get(i).getImg_id());
	} 
}
 
Example 16
Project: mp4parser_android   File: SubSampleInformationBox.java   View Source Code Vote up 4 votes
public void setEntries(List<SampleEntry> entries) {
    this.entries = entries;
    entryCount = entries.size();
}
 
Example 17
Project: ripme   File: NfsfwRipper.java   View Source Code Vote up 4 votes
@Override
public void rip() throws IOException {
    List<Pair> subAlbums = new ArrayList<>();
    int index = 0;
    subAlbums.add(new Pair(this.url.toExternalForm(), ""));
    while (subAlbums.size() > 0) {
        if (isStopped()) {
            break;
        }
        Pair nextAlbum = subAlbums.remove(0);
        String nextURL = nextAlbum.first;
        String nextSubalbum = nextAlbum.second;
        sendUpdate(STATUS.LOADING_RESOURCE, nextURL);
        logger.info("    Retrieving " + nextURL);
        if (albumDoc == null) {
            albumDoc = Http.url(nextURL).get();
        }
        // Subalbums
        for (Element suba : albumDoc.select("td.IMG > a")) {
            if (isStopped() || isThisATest()) {
                break;
            }
            String subURL = "http://nfsfw.com" + suba.attr("href");
            String subdir = subURL;
            while (subdir.endsWith("/")) {
                subdir = subdir.substring(0, subdir.length() - 1);
            }
            subdir = subdir.substring(subdir.lastIndexOf("/") + 1);
            subAlbums.add(new Pair(subURL, subdir));
        }
        // Images
        for (Element thumb : albumDoc.select("td.giItemCell > div > a")) {
            if (isStopped()) {
                break;
            }
            String imagePage = "http://nfsfw.com" + thumb.attr("href");
            try {
                NfsfwImageThread t = new NfsfwImageThread(new URL(imagePage), nextSubalbum, ++index);
                nfsfwThreadPool.addThread(t);
                if (isThisATest()) {
                    break;
                }
            } catch (MalformedURLException mue) {
                logger.warn("Invalid URL: " + imagePage);
            }
        }
        if (isThisATest()) {
            break;
        }
        // Get next page
        for (Element a : albumDoc.select("a.next")) {
            subAlbums.add(0, new Pair("http://nfsfw.com" + a.attr("href"), ""));
            break;
        }
        // Insert next page at the top
        albumDoc = null;
        // Wait
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            logger.error("Interrupted while waiting to load next page", e);
            throw new IOException(e);
        }
    }
    nfsfwThreadPool.waitForThreads();
    waitForThreads();
}
 
Example 18
Project: Elasticsearch   File: AggregationPath.java   View Source Code Vote up 4 votes
public AggregationPath(List<PathElement> tokens) {
    this.pathElements = tokens;
    if (tokens == null || tokens.size() == 0) {
        throw new IllegalArgumentException("Invalid path [" + this + "]");
    }
}
 
Example 19
Project: ImageClassify   File: TaskController.java   View Source Code Vote up 4 votes
/**
 * 获取用户未完成(未提交)的任务列表
 * 
 * @param oauth_token
 * @param request
 * @param response
 * @throws IOException
 */
@RequestMapping(value = "/task/getunfinishedtask", method = RequestMethod.POST)
public void getUnfinishedTask(@RequestParam(Constant.OAUTH_TOKEN) String oauth_token,
		@RequestParam("start") String start, @RequestParam("page_num") String num, HttpServletRequest request,
		HttpServletResponse response) throws IOException {

	response.setCharacterEncoding("UTF-8");
	request.setCharacterEncoding("UTF-8");
	Gson gson = new Gson();
	String json = null;
	PrintWriter out = response.getWriter();

	DateUtils dateUtil = new DateUtils();
	// 得到oauth_token对应的oauth对象
	Oauth oauth = oauthService.findOauthByOauthToken(oauth_token);
	User user = oauth.getUser();
	// 根据指定的user_id提交标识未为0的task列表
	List<Task> tasks = taskService.geTasksOfUnfinished(user.getUser_id(), Integer.parseInt(start),
			Integer.parseInt(num));

	List<UnfinishedTaskLabel> labels = new ArrayList<UnfinishedTaskLabel>();

	for (int i = 0; i < tasks.size(); i++) {
		Task task = tasks.get(i);
		UnfinishedTaskLabel unfinishedTaskLabel = new UnfinishedTaskLabel();
		unfinishedTaskLabel.setTask_id(task.getTask_id() + "");
		// 根据task_id查找对应的所有图片信息列表
		List<Image> images = compositionService.getTaskOfImages(task.getTask_id());

		List<String> image_path_five = new ArrayList<String>();
		// 根据images列表,得到其中5张图片的url并存入到list中
		for (int j = 0; j < images.size(); j++) {
			Image image = new Image();
			image = images.get(j);
			String allname = image.getImg_path() + image.getImg_name();
			image_path_five.add(allname);
		}
		// 设置unfinishedTaskLabel对象的属性
		unfinishedTaskLabel.setTask_img_amount(task.getTask_img_amount() + "");
		unfinishedTaskLabel.setTask_start_time(dateUtil.getFormatDateOfNoneSs(task.getTask_start_time()));
		unfinishedTaskLabel.setImage_path_five(image_path_five);
		// 增添到labels列表中
		labels.add(unfinishedTaskLabel);
	}
	Message<List<UnfinishedTaskLabel>> message = new Message<List<UnfinishedTaskLabel>>("200", "", labels); // 初始化message对象
	json = gson.toJson(message, Message.class); // 使用gson将Message对象转化为字符串
	out.print(json);

}
 
Example 20
Project: Backmemed   File: ConnectedTextures.java   View Source Code Vote up 4 votes
private static TextureAtlasSprite getNeighbourIcon(IBlockAccess p_getNeighbourIcon_0_, IBlockState p_getNeighbourIcon_1_, BlockPos p_getNeighbourIcon_2_, IBlockState p_getNeighbourIcon_3_, int p_getNeighbourIcon_4_)
{
    p_getNeighbourIcon_3_ = p_getNeighbourIcon_3_.getBlock().getActualState(p_getNeighbourIcon_3_, p_getNeighbourIcon_0_, p_getNeighbourIcon_2_);
    IBakedModel ibakedmodel = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getModelForState(p_getNeighbourIcon_3_);

    if (ibakedmodel == null)
    {
        return null;
    }
    else
    {
        EnumFacing enumfacing = getFacing(p_getNeighbourIcon_4_);
        List list = ibakedmodel.getQuads(p_getNeighbourIcon_3_, enumfacing, 0L);

        if (Config.isBetterGrass())
        {
            list = BetterGrass.getFaceQuads(p_getNeighbourIcon_0_, p_getNeighbourIcon_3_, p_getNeighbourIcon_2_, enumfacing, list);
        }

        if (list.size() > 0)
        {
            BakedQuad bakedquad1 = (BakedQuad)list.get(0);
            return bakedquad1.getSprite();
        }
        else
        {
            List list1 = ibakedmodel.getQuads(p_getNeighbourIcon_3_, (EnumFacing)null, 0L);

            for (int i = 0; i < list1.size(); ++i)
            {
                BakedQuad bakedquad = (BakedQuad)list1.get(i);

                if (bakedquad.getFace() == enumfacing)
                {
                    return bakedquad.getSprite();
                }
            }

            return null;
        }
    }
}