⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 actionutil.java.svn-base

📁 EasyJWeb是基于java技术
💻 SVN-BASE
字号:
package com.easyjf.core.support;

import java.io.File;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import org.apache.log4j.Logger;

import com.easyjf.util.CommUtil;
import com.easyjf.web.ActionContext;
import com.easyjf.web.IWebAction;
import com.easyjf.web.Module;
import com.easyjf.web.WebForm;

public class ActionUtil {

	private static final Logger logger = Logger.getLogger(ActionUtil.class);

	// private static final SimpleDateFormat df = new
	// SimpleDateFormat("yyyyMMdd");

	// private static final String SEPARATOR = "/";

	public static WebForm getWebForm() {
		return getForm();
	}

	public static String getUrlType() {
		return ActionContext.getContext().getWebInvocationParam().getUrlType();
	}

	public static IWebAction getAction() {
		return ActionContext.getContext().getWebInvocationParam().getAction();
	}

	public static WebForm getForm() {
		return ActionContext.getContext().getWebInvocationParam().getForm();
	}

	public static Module getModule() {
		return ActionContext.getContext().getWebInvocationParam().getModule();
	}

	public static List<Serializable> processIds(WebForm form) {
		return processIds(form, "");
	}

	public static List<Serializable> processIds(WebForm form, String idsName) {
		if (logger.isDebugEnabled()) {
			logger.debug("processIds(WebForm) - start");
		}
		String key;
		if (idsName.equals("")) {
			key = "mulitId";
		} else {
			key = idsName;
		}

		String mulitId = CommUtil.null2String(form.get(key));
		if (mulitId.endsWith(","))
			mulitId = mulitId.substring(0, mulitId.length() - 1);
		String[] idsStr = mulitId.split(",");
		if (idsStr.length > 0) {
			List<Serializable> ids = new ArrayList<Serializable>(idsStr.length);
			for (String id : idsStr) {
				if (!"".equals(id))
					ids.add(Long.parseLong(id));
			}
			return ids;
		}

		if (logger.isDebugEnabled()) {
			logger.debug("processIds(WebForm) - end");
		}
		return null;
	}

	/**
	 * private static boolean saveFile(InputStream in, String fileName) {
	 * logger.debug("fileName" + fileName); File outFile = new File(fileName);
	 * if (!outFile.getParentFile().exists()) outFile.getParentFile().mkdirs();
	 * try { FileOutputStream out = new FileOutputStream(outFile); byte[] temp =
	 * new byte[11024]; int length = -1; while ((length = in.read(temp)) > 0) {
	 * out.write(temp, 0, length); } out.flush(); out.close(); in.close(); }
	 * catch (Exception e) { logger.error("saveFile(InputStream, String)", e);
	 * 
	 * e.printStackTrace();
	 * 
	 * if (logger.isDebugEnabled()) { logger.debug("saveFile(InputStream,
	 * String) - end"); } return false; }
	 * 
	 * if (logger.isDebugEnabled()) { logger.debug("saveFile(InputStream,
	 * String) - end"); } return true; }
	 */
	/**
	 * private static InputStream getInputStream(FileItem file) { if
	 * (logger.isDebugEnabled()) { logger.debug("getInputStream(FileItem) -
	 * start"); }
	 * 
	 * try { InputStream returnInputStream = file.getInputStream(); if
	 * (logger.isDebugEnabled()) { logger.debug("getInputStream(FileItem) -
	 * end"); } return returnInputStream; } catch (Exception e) {
	 * logger.error("getInputStream(FileItem)", e);
	 * 
	 * if (logger.isDebugEnabled()) { logger.debug("getInputStream(FileItem) -
	 * end"); } return null; } }
	 */
	public static void removeImage(String path) {
		if (path != null) {
			File bigFile = new File(com.easyjf.web.Globals.APP_BASE_DIR + path);
			File smallFile = new File(com.easyjf.web.Globals.APP_BASE_DIR
					+ smallPath(path));
			if (bigFile.exists()) {
				bigFile.delete();
			}
			if (smallFile.exists()) {
				smallFile.delete();
			}
		}
	}

	private static String smallPath(String path) {
		int dotIndex = path.lastIndexOf('.');
		String preffix = path.substring(0, dotIndex);
		String suffix = path.substring(dotIndex);
		String name = preffix + "_small" + suffix;
		return name;
	}

	public static void removeFile(String path) {
		if (path != null) {
			File file = new File(path);
			if (file.exists()) {
				file.delete();
			}
		}

	}

	public String generateOption(String value) {
		return "<option value=" + value + ">" + value + "</option>";
	}

	// public List<String> filter(WebForm source,String
	// preffix){
	// if(ddddd){
	// source.remove(i);
	// }
	// }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -