List of usage examples for java.util Map put
V put(K key, V value);
From source file:com.glaf.core.el.Mvel2ExpressionEvaluator.java
public static void main(String[] args) throws Exception { String expression = null;/*w w w . jav a 2 s. co m*/ Object obj = null; Map<String, Object> context = new java.util.HashMap<String, Object>(); context.put("roleId", "admin"); context.put("roleType", "-5"); expression = "#{roleType > 0}"; obj = Mvel2ExpressionEvaluator.evaluate(expression, context); if (obj != null) { System.out.println("[type]=" + obj.getClass().getName() + "\t[value]=" + obj); } context.put("roleType", "2345"); expression = "#{roleType > 0}"; obj = Mvel2ExpressionEvaluator.evaluate(expression, context); if (obj != null) { System.out.println("[type]=" + obj.getClass().getName() + "\t[value]=" + obj); } context.put("a", 123); context.put("b", 789); expression = "#{ a + b }"; obj = Mvel2ExpressionEvaluator.evaluate(expression, context); if (obj != null) { System.out.println("[type]=" + obj.getClass().getName() + "\t[value]=" + obj); } context.put("a", "123"); context.put("b", "789"); expression = "#{ a*1.0 + b*1.0 }"; obj = Mvel2ExpressionEvaluator.evaluate(expression, context); if (obj != null) { System.out.println("[type]=" + obj.getClass().getName() + "\t[value]=" + obj); } context.put("c", 123D); context.put("d", 789D); expression = "#{ c / d }"; obj = Mvel2ExpressionEvaluator.evaluate(expression, context); if (obj != null) { System.out.println("[type]=" + obj.getClass().getName() + "\t[value]=" + obj); } context.put("a", "123"); context.put("b", "789"); expression = "#{ a*1.0 / b*1.0 }"; obj = Mvel2ExpressionEvaluator.evaluate(expression, context); if (obj != null) { System.out.println("[type]=" + obj.getClass().getName() + "\t[value]=" + obj); } expression = "#{ c >= 0 and d >0 }"; obj = Mvel2ExpressionEvaluator.evaluate(expression, context); if (obj != null) { System.out.println("[type]=" + obj.getClass().getName() + "\t[value]=" + obj); } expression = "#{ c >= 0 and d > 0 and c/d > 0.16 }"; obj = Mvel2ExpressionEvaluator.evaluate(expression, context); if (obj != null) { System.out.println("[type]=" + obj.getClass().getName() + "\t[value]=" + obj); } expression = "#{ c >= 0 and d >0 and c/d > 0.15 }"; obj = Mvel2ExpressionEvaluator.evaluate(expression, context); if (obj != null) { System.out.println("[type]=" + obj.getClass().getName() + "\t[value]=" + obj); } }
From source file:lapispaste.Main.java
public static void main(String[] args) throws Exception { // create Options object Options options = new Options(); String version;/*from ww w. ja va 2 s . com*/ version = "0.1"; // populate Options with.. well options :P options.addOption("v", false, "Display version"); options.addOption("f", true, "File to paste"); // non-critical options options.addOption("t", true, "Code language"); options.addOption("p", false, "Read from pipe"); CommandLineParser parser = new PosixParser(); CommandLine cmd = parser.parse(options, args); // assemble a map of values final Map<String, String> pastemap = new HashMap<String, String>(); if (cmd.hasOption("t")) pastemap.put("format", cmd.getOptionValue("t").toString()); else pastemap.put("format", "text"); // critical options if (cmd.hasOption("v")) System.out.println("lapispaste version " + version); else if (cmd.hasOption("f")) { File file = new File(cmd.getOptionValue("f")); StringBuffer pdata = readData(new FileReader(file)); paster(pastemap, pdata); } else if (cmd.hasOption("p")) { StringBuffer pdata = readData(new InputStreamReader(System.in)); paster(pastemap, pdata); } else { // Did not recieve what was expected HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("lapispaste [OPTIONS] [FILE]", options); } }
From source file:com.hihframework.core.utils.BeanUtils.java
public static void main(String[] args) { TsysParameter rp = new TsysParameter(); Map<String, String> map = new HashMap<String, String>(); map.put("paraOrder", "1"); mapToBean(map, rp);//from w ww.j a va 2s .co m System.out.println(rp.getParaOrder()); }
From source file:Main.java
public static void main(String[] argv) throws Exception { final int MAX_ENTRIES = 100; Map cache = new LinkedHashMap(MAX_ENTRIES + 1, .75F, true) { public boolean removeEldestEntry(Map.Entry eldest) { return size() > MAX_ENTRIES; }//from w w w . j a va 2 s . c o m }; Object key = "key"; Object value = "value"; cache.put(key, value); Object o = cache.get(key); if (o == null && !cache.containsKey(key)) { } cache = (Map) Collections.synchronizedMap(cache); }
From source file:com.myjeeva.poi.ExcelWorkSheetHandlerTest.java
/** * @param args/*w ww. ja va 2 s .c o m*/ * @throws Exception */ public static void main(String[] args) throws Exception { String SAMPLE_PERSON_DATA_FILE_PATH = "src/test/resources/Sample-Person-Data.xlsx"; // Input File initialize File file = new File(SAMPLE_PERSON_DATA_FILE_PATH); InputStream inputStream = new FileInputStream(file); // Excel Cell Mapping Map<String, String> cellMapping = new HashMap<String, String>(); cellMapping.put("HEADER", "Person Id,Name,Height,Email Address,DOB,Salary"); cellMapping.put("A", "personId"); cellMapping.put("B", "name"); cellMapping.put("C", "height"); cellMapping.put("D", "emailId"); cellMapping.put("E", "dob"); cellMapping.put("F", "salary"); // The package open is instantaneous, as it should be. OPCPackage pkg = null; try { ExcelWorkSheetHandler<PersonVO> workSheetHandler = new ExcelWorkSheetHandler<PersonVO>(PersonVO.class, cellMapping); pkg = OPCPackage.open(inputStream); ExcelSheetCallback sheetCallback = new ExcelSheetCallback() { private int sheetNumber = 0; @Override public void startSheet(int sheetNum, String sheetName) { this.sheetNumber = sheetNum; System.out.println("Started processing sheet number=" + sheetNumber + " and Sheet Name is '" + sheetName + "'"); } @Override public void endSheet() { System.out.println("Processing completed for sheet number=" + sheetNumber); } }; System.out.println("Constructor: pkg, workSheetHandler, sheetCallback"); ExcelReader example1 = new ExcelReader(pkg, workSheetHandler, sheetCallback); example1.process(); if (workSheetHandler.getValueList().isEmpty()) { // No data present LOG.error("sHandler.getValueList() is empty"); } else { LOG.info(workSheetHandler.getValueList().size() + " no. of records read from given excel worksheet successfully."); // Displaying data ead from Excel file displayPersonList(workSheetHandler.getValueList()); } System.out.println("\nConstructor: filePath, workSheetHandler, sheetCallback"); ExcelReader example2 = new ExcelReader(SAMPLE_PERSON_DATA_FILE_PATH, workSheetHandler, sheetCallback); example2.process(); System.out.println("\nConstructor: file, workSheetHandler, sheetCallback"); ExcelReader example3 = new ExcelReader(file, workSheetHandler, null); example3.process(); } catch (RuntimeException are) { LOG.error(are.getMessage(), are.getCause()); } catch (InvalidFormatException ife) { LOG.error(ife.getMessage(), ife.getCause()); } catch (IOException ioe) { LOG.error(ioe.getMessage(), ioe.getCause()); } finally { IOUtils.closeQuietly(inputStream); try { if (null != pkg) { pkg.close(); } } catch (IOException e) { // just ignore IO exception } } }
From source file:com.amazon.advertising.api.sample.ItemLookupSample.java
public static void main(String[] args) { /*/* w w w . j a va2 s.com*/ * Set up the signed requests helper */ SignedRequestsHelper helper; try { helper = SignedRequestsHelper.getInstance(ENDPOINT, AWS_ACCESS_KEY_ID, AWS_SECRET_KEY); } catch (Exception e) { e.printStackTrace(); return; } String requestUrl = null; String title = null; /* The helper can sign requests in two forms - map form and string form */ /* * Here is an example in map form, where the request parameters are stored in a map. */ System.out.println("Map form example:"); Map<String, String> params = new HashMap<String, String>(); params.put("Service", "AWSECommerceService"); params.put("Version", "2011-08-01"); params.put("Operation", "ItemSearch"); params.put("SearchIndex", "Books"); params.put("Keywords", "Harry"); // params.put("ResponseGroup", "Small"); requestUrl = helper.sign(params); // System.out.println("Signed Request is \"" + requestUrl + "\""); // title = fetchTitle(requestUrl); // System.out.println("Signed Title is \"" + title + "\""); // System.out.println(); /* Here is an example with string form, where the requests parameters have already been concatenated * into a query string. */ // System.out.println("String form example:"); // String queryString = "Service=AWSECommerceService&Version=2009-03-31&Operation=ItemSearch&ResponseGroup=Small&SearchIndex=Books&keywords=harry" // + ITEM_ID; // requestUrl = helper.sign(queryString); NodeList nodelist = fetchASIN(requestUrl); System.out.println(nodelist.getLength()); for (int i = 0; i < nodelist.getLength(); i++) { String asin = nodelist.item(i).getTextContent(); println(asin); getItemInfo(asin, helper); break; } }
From source file:com.fengduo.bee.commons.util.ObjectUtils.java
public static void main(String[] args) { Map<String, String> kvMap = new HashMap<String, String>(); kvMap.put(" _zll_ ", " zsdfasdaaaaaaaaaaa "); kvMap.put(" zxc ", " zsdfasdaaqrwerqweraaaaa "); kvMap.put(" _qwl", " rrrrrrrrrrrrrrrrrrrr "); kvMap.put("12safa", "qweweq"); trim(kvMap);// w w w . j a va 2 s . c o m System.out.println(kvMap); }
From source file:com.glaf.core.el.Jexl2ExpressionEvaluator.java
public static void main(String[] args) throws Exception { String expression = null;//w w w . j a va 2 s .co m Object obj = null; Map<String, Object> context = new java.util.HashMap<String, Object>(); context.put("roleId", "admin"); context.put("roleType", "-5"); expression = "#{roleType > 0}"; obj = Jexl2ExpressionEvaluator.evaluate(expression, context); if (obj != null) { System.out.println("[type]=" + obj.getClass().getName() + "\t[value]=" + obj); } context.put("roleType", "2345"); expression = "#{roleType > 0}"; obj = Jexl2ExpressionEvaluator.evaluate(expression, context); if (obj != null) { System.out.println("[type]=" + obj.getClass().getName() + "\t[value]=" + obj); } context.put("a", 123); context.put("b", 789); expression = "#{ a + b }"; obj = Jexl2ExpressionEvaluator.evaluate(expression, context); if (obj != null) { System.out.println("[type]=" + obj.getClass().getName() + "\t[value]=" + obj); } context.put("a", "123"); context.put("b", "789"); expression = "#{ a*1.0 + b*1.0 }"; obj = Jexl2ExpressionEvaluator.evaluate(expression, context); if (obj != null) { System.out.println("[type]=" + obj.getClass().getName() + "\t[value]=" + obj); } context.put("c", 123D); context.put("d", 789D); expression = "#{ c / d }"; obj = Jexl2ExpressionEvaluator.evaluate(expression, context); if (obj != null) { System.out.println("[type]=" + obj.getClass().getName() + "\t[value]=" + obj); } context.put("a", "123"); context.put("b", "789"); expression = "#{ a*1.0 / b*1.0 }"; obj = Jexl2ExpressionEvaluator.evaluate(expression, context); if (obj != null) { System.out.println("[type]=" + obj.getClass().getName() + "\t[value]=" + obj); } expression = "#{ c >= 0 and d >0 }"; obj = Jexl2ExpressionEvaluator.evaluate(expression, context); if (obj != null) { System.out.println("[type]=" + obj.getClass().getName() + "\t[value]=" + obj); } expression = "#{ c >= 0 and d >0 and c/d > 0.16 }"; obj = Jexl2ExpressionEvaluator.evaluate(expression, context); if (obj != null) { System.out.println("[type]=" + obj.getClass().getName() + "\t[value]=" + obj); } expression = "#{ c >= 0 and d >0 and c/d > 0.15 }"; obj = Jexl2ExpressionEvaluator.evaluate(expression, context); if (obj != null) { System.out.println("[type]=" + obj.getClass().getName() + "\t[value]=" + obj); } expression = "#{ 0 > 10 }"; obj = Jexl2ExpressionEvaluator.evaluate(expression, context); System.out.println("[type]=" + obj.getClass().getName() + "\t[value]=" + obj); expression = "#{ a +'-xy-'+ b }"; obj = Jexl2ExpressionEvaluator.evaluate(expression, context); System.out.println("[type]=" + obj.getClass().getName() + "\t[value]=" + obj); expression = "#{ 0x10}"; obj = Jexl2ExpressionEvaluator.evaluate(expression, context); System.out.println("[type]=" + obj.getClass().getName() + "\t[value]=" + obj); }
From source file:net.itransformers.idiscover.discoverylisteners.XmlTopologyDeviceLogger.java
public static void main(String[] args) throws IOException, JAXBException { String path = "devices_and_models\\lab\\undirected"; File dir = new File(path); String[] files = dir.list(new FilenameFilter() { public boolean accept(File dir, String name) { return (name.endsWith(".hml")); }//from ww w.jav a 2 s.com }); Map<String, String> params = new HashMap<String, String>(); params.put("path", path); params.put("conf/xslt", "iDiscover\\conf\\xslt\\transformator3.xslt"); XmlTopologyDeviceLogger logger = new XmlTopologyDeviceLogger(params, null, null); for (String fileName : files) { FileInputStream is = new FileInputStream(path + File.separator + fileName); DiscoveredDeviceData discoveredDeviceData; try { discoveredDeviceData = JaxbMarshalar.unmarshal(DiscoveredDeviceData.class, is); } finally { is.close(); } String deviceName = fileName.substring("device-".length(), fileName.length() - ".xml".length()); logger.handleDevice(deviceName, null, discoveredDeviceData, null); } }
From source file:com.coul.common.mapper.JsonMapper.java
/** * /*from w w w. jav a 2 s . c om*/ */ public static void main(String[] args) { List<Map<String, Object>> list = Lists.newArrayList(); Map<String, Object> map = Maps.newHashMap(); map.put("id", 1); map.put("pId", -1); map.put("name", ""); list.add(map); map = Maps.newHashMap(); map.put("id", 2); map.put("pId", 1); map.put("name", ""); map.put("open", true); list.add(map); String json = JsonMapper.getInstance().toJson(list); System.out.println(json); }