List of usage examples for java.util LinkedList getFirst
public E getFirst()
From source file:org.jbpm.db.JbpmSession.java
/** * @deprecated use {@link org.jbpm.JbpmConfiguration#getCurrentJbpmContext()} instead. *//*from ww w.j a va 2 s. c o m*/ public static JbpmSession getCurrentJbpmSession() { JbpmSession jbpmSession = null; LinkedList stack = (LinkedList) currentJbpmSessionStack.get(); if ((stack != null) && (!stack.isEmpty())) { jbpmSession = (JbpmSession) stack.getFirst(); } return jbpmSession; }
From source file:com.insightml.utils.Collections.java
public static <T, N extends Number> LinkedList<Pair<T, N>> getMax(final Iterable<Pair<T, N>> map) { LinkedList<Pair<T, N>> maxEntry = new LinkedList<>(); for (final Pair<T, N> entry : map) { if (maxEntry.size() == 0 || entry.getSecond().doubleValue() > maxEntry.getFirst().getSecond().doubleValue()) { maxEntry = new LinkedList<>(); maxEntry.add(entry);// www.java 2s. co m } else if (entry.getSecond().doubleValue() == maxEntry.getFirst().getSecond().doubleValue()) { maxEntry.add(entry); } } return maxEntry; }
From source file:com.kabone.research.common.utils.FileUtil.java
/** * ?/*from ww w. java 2 s .c om*/ * @param map * @param realPath * @param dirPath * @param thumbnail * @return * @throws IllegalStateException * @throws IOException */ public static List<Map<String, Object>> getFileInfo(MultiValueMap<String, MultipartFile> map, String realPath, String dirPath, boolean thumbnail) throws IllegalStateException, IOException { Date time = Calendar.getInstance().getTime(); SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmssS"); String formatDate = formatter.format(time); List<Map<String, Object>> fileList = new ArrayList<Map<String, Object>>(); Iterator<String> iterator = map.keySet().iterator(); // savePath ? /yyyy/mm/ ?? String savePath = dirPath + File.separator + StringUtils.substring(formatDate, 0, 4) + File.separator + StringUtils.substring(formatDate, 4, 6) + File.separator; String realFilePath = realPath + savePath; String logicalPath = savePath; if (File.separator.equalsIgnoreCase("\\")) { logicalPath = savePath.replaceAll("\\\\", "/"); } while (iterator.hasNext()) { Map<String, Object> fileMap = new HashMap<String, Object>(); String key = iterator.next(); LinkedList<MultipartFile> df = (LinkedList<MultipartFile>) map.get(key); CommonsMultipartFile fileInfo = (CommonsMultipartFile) df.getFirst(); if (fileInfo.getSize() > 0) { fileMap.put("key", key); int idx = fileInfo.getOriginalFilename().lastIndexOf("."); String extName = ""; if (idx != -1) { extName = fileInfo.getOriginalFilename().substring(idx, fileInfo.getOriginalFilename().length()); } File fDir = new File(realFilePath); if (!fDir.exists()) { fDir.mkdirs(); } File file1 = new File(realFilePath + formatDate + fileInfo.getName() + extName); fileInfo.transferTo(file1); logger.info("fileInfo.realFilePath() : " + realFilePath); logger.info("fileInfo.logicalPath() : " + logicalPath); logger.info("fileInfo.getOriginalFilename() : " + fileInfo.getOriginalFilename()); logger.info("fileInfo.getName() : " + fileInfo.getName()); logger.info("fileInfo.path() : " + logicalPath + formatDate + fileInfo.getName() + extName); fileMap.put("path", logicalPath + formatDate + fileInfo.getName() + extName); fileMap.put("name", fileInfo.getOriginalFilename()); fileMap.put("size", "" + fileInfo.getSize()); //?? if (thumbnail) { int imageWidth = 0; int imageHeight = 0; //? ? ?? ? if ("mainImg".equals(fileInfo.getName())) { logger.info("? ? ?? ?"); imageWidth = 645; imageHeight = 485; } else if ("cardImg".equals(fileInfo.getName())) { logger.info(" ? ?? ?"); imageWidth = 240; imageHeight = 180; } if (imageWidth != 0 && imageHeight != 0) { File originFileName = new File(realFilePath + formatDate + fileInfo.getName() + extName); File thumbFileName = new File( realFilePath + "thumbnail_" + formatDate + fileInfo.getName() + extName); thumbnail(imageWidth, imageHeight, originFileName, thumbFileName); fileMap.put("thumb", logicalPath + "thumbnail_" + formatDate + fileInfo.getName() + extName); } } fileList.add(fileMap); } } return fileList; }
From source file:com.kabone.research.common.utils.FileUtil.java
public static List<Map<String, Object>> getFileInfo2(String BUCKET_NAME, String S3_ENDPOINT, String ACCESS_KEY, String SECRET_KEY, MultiValueMap<String, MultipartFile> map, String realPath, String dirPath, boolean thumbnail) throws Exception { //public static List<Map<String,Object>> getFileInfo2(MultiValueMap<String, MultipartFile> map, String realPath, String dirPath, boolean thumbnail) throws Exception { Date time = Calendar.getInstance().getTime(); SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmssS"); String formatDate = formatter.format(time); List<Map<String, Object>> fileList = new ArrayList<Map<String, Object>>(); Iterator<String> iterator = map.keySet().iterator(); String savePath = dirPath + "/"; String realFilePath = realPath + savePath; /*/*from w w w .j a v a 2s .c om*/ String logicalPath = savePath; if(File.separator.equalsIgnoreCase("\\")) { logicalPath = savePath.replaceAll("\\\\", "/"); } */ File fDir = new File(realFilePath); if (!fDir.exists()) { fDir.mkdirs(); } AWSUtil.s3MakeFolder(S3_ENDPOINT, BUCKET_NAME, ACCESS_KEY, SECRET_KEY, dirPath); while (iterator.hasNext()) { Map<String, Object> fileMap = new HashMap<String, Object>(); String key = iterator.next(); LinkedList<MultipartFile> df = (LinkedList<MultipartFile>) map.get(key); CommonsMultipartFile fileInfo = (CommonsMultipartFile) df.getFirst(); if (fileInfo.getSize() > 0) { fileMap.put("key", key); int idx = fileInfo.getOriginalFilename().lastIndexOf("."); String extName = ""; if (idx != -1) { extName = fileInfo.getOriginalFilename().substring(idx, fileInfo.getOriginalFilename().length()); } String fileName = formatDate + fileInfo.getName() + extName; File file1 = new File(realFilePath + fileName); fileInfo.transferTo(file1); logger.info("fileInfo.getOriginalFilename() : " + fileInfo.getOriginalFilename()); String filePath = AWSUtil.s3FileUpload(S3_ENDPOINT, BUCKET_NAME, ACCESS_KEY, SECRET_KEY, savePath + fileName, realFilePath + fileName); logger.info("filePath : " + filePath); fileMap.put("path", filePath); fileMap.put("name", fileInfo.getOriginalFilename()); fileMap.put("size", "" + fileInfo.getSize()); //?? if (thumbnail) { int imageWidth = 0; int imageHeight = 0; //? ? ?? ? if ("mainImg".equals(fileInfo.getName())) { //?? imageWidth = 645; imageHeight = 485; } else if ("cardImg".equals(fileInfo.getName())) { //? imageWidth = 224; imageHeight = 180; } else if ("storyImg".equals(fileInfo.getName())) { // imageWidth = 148; imageHeight = 98; } else if ("ftypeMainImg".equals(fileInfo.getName())) { // ?? imageWidth = 980; imageHeight = 400; } else if ("choiceImg".equals(fileInfo.getName())) { // Editor's Choice ? imageWidth = 160; imageHeight = 70; } if (imageWidth != 0 && imageHeight != 0) { File originFileName = new File(realFilePath + fileName); File thumbFileName = new File(realFilePath + "thumbnail_" + fileName); boolean result = thumbnail(imageWidth, imageHeight, originFileName, thumbFileName); String filePath2 = ""; if (result) { filePath2 = AWSUtil.s3FileUpload(S3_ENDPOINT, BUCKET_NAME, ACCESS_KEY, SECRET_KEY, savePath + "thumbnail_" + fileName, realFilePath + "thumbnail_" + fileName); } if (thumbFileName.exists()) { thumbFileName.delete(); } fileMap.put("thumbPath", filePath2); } } if (file1.exists()) { file1.delete(); } fileList.add(fileMap); } } return fileList; }
From source file:org.xchain.namespaces.jsl.AbstractTemplateCommand.java
protected static ElementOutputState[] getElementOutputState() { LinkedList<ElementOutputState[]> stack = elementOutputStateStackTL.get(); if (stack == null || stack.isEmpty()) { throw new IllegalStateException("getElementOutputState() called outside of execute method."); }//from w ww .ja v a 2 s . c o m return stack.getFirst(); }
From source file:org.xchain.namespaces.jsl.AbstractTemplateCommand.java
/** * Returns the command execute state array for the current thread. *///from ww w .j ava 2 s. c om protected static CommandExecutionState[] getCommandExecutionState() { LinkedList<CommandExecutionState[]> stack = commandExecutionStateStackTL.get(); if (stack == null || stack.isEmpty()) { throw new IllegalStateException("getCommandExecutionState() called outside of execute method."); } return stack.getFirst(); }
From source file:org.rhq.enterprise.gui.legacy.util.SessionUtils.java
/** * Unset the "return path" that locates the point at which a subflow was included into a primary workflow. * * @param session the http session// w w w .j a v a 2s . c o m */ public static void unsetReturnPathIgnoredForOk(HttpSession session) { LinkedList stack = (LinkedList) session.getAttribute(AttrConstants.RETURN_LOC_SES_ATTR); ReturnPath returnPath = (ReturnPath) stack.getFirst(); returnPath.setIgnore(Boolean.TRUE); }
From source file:com.dsclab.loader.app.Loader.java
public static Produce getProduce() { TableTask firstTableTask = tableTask.getFirst(); if (tableTask.size() != 0) { LinkedList<String> firstTaskSql = firstTableTask.getTaskSqlList(); while (firstTaskSql.size() == 0) { tableTask.removeFirst();// w w w . j av a2 s . c om if (tableTask.size() == 0) { return null; } firstTableTask = tableTask.getFirst(); firstTaskSql = firstTableTask.getTaskSqlList(); } //firstTableTask = tableTask.getFirst(); //firstTaskSql = firstTableTask.getTaskSqlList(); Table firstTableInfo = firstTableTask.getTableInfo(); System.out.println("Tablename:" + firstTableInfo.getTableName()); System.out.println("next table:" + tableTask.getFirst().getTableInfo().getTableName()); String taskSql = firstTaskSql.getFirst(); firstTaskSql.removeFirst(); System.out.println("TaskSql:" + taskSql); return new Produce(firstTableInfo, taskSql); } return null; }
From source file:org.rhq.enterprise.gui.legacy.util.SessionUtils.java
/** * Retrieve the "return path" that locates the point at which a subflow was included into a primary workflow. * * @param session the http session/*ww w.j a v a 2s. c om*/ */ public static String getReturnPath(HttpSession session) { LinkedList stack = (LinkedList) session.getAttribute(AttrConstants.RETURN_LOC_SES_ATTR); if ((stack == null) || stack.isEmpty()) { return null; } ReturnPath returnPath = (ReturnPath) stack.getFirst(); return returnPath.getPath(); }
From source file:org.rhq.enterprise.gui.legacy.util.SessionUtils.java
/** * Retrieve wether the "return path" should be paid attention to for new. should default to false, which means that * it is not ignored./*ww w . j ava 2s . c om*/ * * @param session the http session * * @return whether or not to ignore the return path */ public static Boolean getReturnPathIgnoredForOk(HttpSession session) { LinkedList stack = (LinkedList) session.getAttribute(AttrConstants.RETURN_LOC_SES_ATTR); if ((stack == null) || stack.isEmpty()) { return Boolean.FALSE; } ReturnPath returnPath = (ReturnPath) stack.getFirst(); if (returnPath == null) { return Boolean.FALSE; } return returnPath.getIgnore(); }