List of usage examples for java.util HashMap isEmpty
public boolean isEmpty()
From source file:ai.api.sample.AIDialogSampleActivity.java
private void forMobile(Result result) { /*String mobile_browsenode; String mobile_minprice;/*from ww w . ja v a 2 s .c o m*/ String mobile_maxprice; String mobile_carrier; String mobile_os; String mobile_brand;*/ // if(result.getAction().equals("phone.carrier")) // { // //browse node for carrier // mobile_browsenode = "2407748011"; // // } // if(result.getAction().equals("phone.unlocked")) // { // //browse node for unlocked // mobile_browsenode = "2407749011"; // mobile_carrier = " none "; // } mobile_browsenode = "2407749011"; // if(result.getAction().equals("phone.carrier.selected")) // { // final HashMap<String, JsonElement> params = result.getParameters(); // if (params != null && !params.isEmpty()) { // Log.i(TAG, "Parameters: "); // for (final Map.Entry<String, JsonElement> entry : params.entrySet()) { // Log.i(TAG, String.format("%s: %s", entry.getKey(), entry.getValue().toString())); // if (entry.getKey().equalsIgnoreCase("phone_addcarrier")) // mobile_carrier = entry.getValue().toString(); // } // } // } //checking for OS if (result.getAction().equals("phone.windows")) { mobile_os = "Windows"; } if (result.getAction().equals("phone.android")) { mobile_os = "Android"; } // if(result.getAction().equals("phone.blackberry")) // { // mobile_os = "Blackberry"; // mobile_brand = " Blackberry "; // //set bran manually // } if (result.getAction().equals("phone.iOS")) { mobile_os = "IOS"; mobile_brand = " Apple "; //set brand manually } //checking for brand if (result.getAction().equals("phone.brand")) { final HashMap<String, JsonElement> params = result.getParameters(); if (params != null && !params.isEmpty()) { Log.i(TAG, "Parameters: "); for (final Map.Entry<String, JsonElement> entry : params.entrySet()) { Log.i(TAG, String.format("%s: %s", entry.getKey(), entry.getValue().toString())); if (entry.getKey().equalsIgnoreCase("phone_brand")) mobile_brand = entry.getValue().toString(); } } if (result.getResolvedQuery().contains("Nokia") || result.getResolvedQuery().contains("nokia")) { mobile_brand = " Nokia "; } if (result.getResolvedQuery().contains("HTC") || result.getResolvedQuery().contains("htc") || result.getResolvedQuery().contains("HBC") || result.getResolvedQuery().contains("HDC")) { mobile_brand = " HTC "; } if (result.getResolvedQuery().contains("Samsung") || result.getResolvedQuery().contains("samsung")) { mobile_brand = " Samsung "; } if (result.getResolvedQuery().contains("LG") || result.getResolvedQuery().contains("lg")) { mobile_brand = " LG "; } if (result.getResolvedQuery().contains("Motorola") || result.getResolvedQuery().contains("motorola")) { mobile_brand = " Motorola "; } } if (result.getAction().equals("phone.price.finished")) { final HashMap<String, JsonElement> params = result.getParameters(); if (params != null && !params.isEmpty()) { Log.i(TAG, "Parameters: "); for (final Map.Entry<String, JsonElement> entry : params.entrySet()) { Log.i(TAG, String.format("%s: %s", entry.getKey(), entry.getValue().toString())); if (entry.getKey().equalsIgnoreCase("price_start")) mobile_minprice = entry.getValue().toString(); if (entry.getKey().equalsIgnoreCase("price_end")) mobile_maxprice = entry.getValue().toString(); } } if (mobile_maxprice == null) mobile_maxprice = " above "; if (mobile_minprice == null) mobile_minprice = " below "; //checking final values Log.i("final mobile params", mobile_brand); Log.i("final mobile params", mobile_browsenode); //Log.i("final mobile params",mobile_carrier ); Log.i("final mobile params", mobile_maxprice); Log.i("final mobile params", mobile_minprice); Log.i("final mobile params", mobile_os); mobile_brand = mobile_brand.substring(1, mobile_brand.length() - 1); mobile_minprice = mobile_minprice.substring(1, mobile_minprice.length() - 1); mobile_maxprice = mobile_maxprice.substring(1, mobile_maxprice.length() - 1); //mobile_carrier = mobile_carrier.substring(1,mobile_carrier.length()-1); isDialogEnd = true; searchMobileAmazon(mobile_brand, mobile_browsenode, mobile_maxprice, mobile_minprice, mobile_os); } }
From source file:ai.api.sample.AIDialogSampleActivity.java
private void laptop(Result result) { if (result.getAction().equals("laptop.addbrand")) { boolean found; found = false;//from w w w .ja v a2 s . c om if (result.getResolvedQuery().contains("HP") || result.getResolvedQuery().contains("hp")) { brand = "HP"; found = true; } if (result.getResolvedQuery().contains("Dell") || result.getResolvedQuery().contains("dell")) { brand = "Dell"; found = true; } if (result.getResolvedQuery().contains("Samsung") || result.getResolvedQuery().contains("samsung")) { brand = "samsung"; found = true; } if (result.getResolvedQuery().contains("Asus") || result.getResolvedQuery().contains("asus")) { brand = "asus"; found = true; } //brand = result.getResolvedQuery(); if (found == false) { final HashMap<String, JsonElement> params = result.getParameters(); if (params != null && !params.isEmpty()) { for (final Map.Entry<String, JsonElement> entry : params.entrySet()) { Log.i(TAG + "getting brand", String.format("%s: %s", entry.getKey(), entry.getValue().toString())); if (entry.getKey().equalsIgnoreCase("laptop_brand")) brand = entry.getValue().toString(); } } } } if (result.getAction().equals("laptop.addtopfeature")) { //topfeature = result.getParameters().get("Laptop"); if (result.getResolvedQuery().contains("gaming") || result.getResolvedQuery().contains("Gaming")) topfeature = "Gaming"; if (result.getResolvedQuery().contains("Business") || result.getResolvedQuery().contains("business")) topfeature = "business"; if (result.getResolvedQuery().contains("Multimedia") || result.getResolvedQuery().contains("multimedia")) topfeature = "multimedia"; if (result.getResolvedQuery().contains("Everyday") || result.getResolvedQuery().contains("everyday")) topfeature = "everyday"; /*final HashMap<String, JsonElement> params = result.getParameters(); if (params != null && !params.isEmpty()) { for (final Map.Entry<String, JsonElement> entry : params.entrySet()) { Log.i(TAG + "getting top", String.format("%s: %s", entry.getKey(), entry.getValue().toString())); if(entry.getKey().equalsIgnoreCase("laptop"))topfeature = entry.getValue().toString(); } }*/ } //if action is finished adding if (result.getAction().equals("laptop.finishadding")) { isDialogEnd = true; AIOutputContext laptop = result.getContext("laptop"); final Map<String, JsonElement> params = laptop.getParameters(); if (params != null && !params.isEmpty()) { Log.i(TAG, "Parameters: "); for (final Map.Entry<String, JsonElement> entry : params.entrySet()) { Log.i(TAG, String.format("%s: %s", entry.getKey(), entry.getValue().toString())); //if(entry.getKey().equalsIgnoreCase("laptop")) topfeature = entry.getValue().toString(); //if(entry.getKey().equalsIgnoreCase("laptop_brand")) brand = entry.getValue().toString(); if (entry.getKey().equalsIgnoreCase("operating_system")) OS = entry.getValue().toString(); if (entry.getKey().equalsIgnoreCase("price_start")) minprice = (entry.getValue().toString()); if (entry.getKey().equalsIgnoreCase("price_end")) maxprice = (entry.getValue().toString()); } } Log.i("Final params", topfeature); if (OS.length() > 2) { OS = OS.substring(1, OS.length() - 1); Log.i("Final params", OS); if (OS.contains("Mac") || OS.contains("Michael")) { brand = "Apple"; } } Log.i("Final params", brand); if (minprice != null && minprice.length() > 2) { minprice = minprice.substring(1, minprice.length() - 1); Log.i("Final params", minprice); } else { minprice = "000"; } if (maxprice != null && maxprice.length() > 2) { maxprice = maxprice.substring(1, maxprice.length() - 1); Log.i("Final params", maxprice); } else { maxprice = "100000"; } Toast.makeText(AIDialogSampleActivity.this, "Searching for laptops now", Toast.LENGTH_SHORT).show(); //do search here from amazon serachLaptopAmazon(topfeature, brand, minprice, maxprice); } }
From source file:org.geefive.salesforce.soqleditor.SOQLQueryEngine.java
private Vector<HashMap<String, String>> hashObj(JSONObject results, HashMap<String, String> newRow, Vector<HashMap<String, String>> newRows, String object) throws JSONException { Iterator keys = results.keys(); while (keys.hasNext()) { String column = (String) keys.next(); if (results.get(column).getClass().equals(JSONObject.class) && !column.equalsIgnoreCase("attributes")) { if (results.getJSONObject(column).has("records")) { //its a many child json object treat accordingly newRows = getResults(results.getJSONObject(column).getJSONArray("records"), new HashMap<String, String>(newRow), newRows, column); //get rid of parent row.. only keep the children newRow.clear();/* ww w .j a va 2 s . c o m*/ } else { hashObj(results.getJSONObject(column), newRow, new Vector<HashMap<String, String>>(), column); } } else if (!column.equalsIgnoreCase("attributes")) { String pre = object.equals("") ? "" : object + "."; String columnValue = results.getString(column); newRow.put(pre + column, columnValue); } } if (!newRow.isEmpty()) newRows.add(newRow); return newRows; }
From source file:ai.api.sample.AIDialogSampleActivity.java
private void forTablet(Result result) { tablet_browsenode = "1232597011"; if (result.getAction().equals("tablet.addos")) { final HashMap<String, JsonElement> params = result.getParameters(); if (params != null && !params.isEmpty()) { Log.i(TAG, "Parameters: "); for (final Map.Entry<String, JsonElement> entry : params.entrySet()) { Log.i(TAG, String.format("%s: %s", entry.getKey(), entry.getValue().toString())); if (entry.getKey().equalsIgnoreCase("Tablet_OS") && entry.getValue().toString() != null) tablet_os = entry.getValue().toString(); }// w w w . ja v a2 s.c o m } } if (result.getAction().equals("tablet.addios")) { final HashMap<String, JsonElement> params = result.getParameters(); if (params != null && !params.isEmpty()) { Log.i(TAG, "Parameters: "); for (final Map.Entry<String, JsonElement> entry : params.entrySet()) { Log.i(TAG, String.format("%s: %s", entry.getKey(), entry.getValue().toString())); if (entry.getKey().equalsIgnoreCase("Tablet_OS") && entry.getValue().toString() != null) { tablet_os = entry.getValue().toString(); tablet_brand = " apple "; } } } } if (result.getAction().equals("tablet.addmodel")) { final HashMap<String, JsonElement> params = result.getParameters(); if (params != null && !params.isEmpty()) { Log.i(TAG, "Parameters: "); for (final Map.Entry<String, JsonElement> entry : params.entrySet()) { Log.i(TAG, String.format("%s: %s", entry.getKey(), entry.getValue().toString())); if (entry.getKey().equalsIgnoreCase("Tablet_apple") && entry.getValue().toString() != null) tablet_model = entry.getValue().toString(); else tablet_model = "null"; } } } //checking for brand if (result.getAction().equals("tablet.addbrand")) { if (result.getResolvedQuery().contains("Samsung") || result.getResolvedQuery().contains("samsung") || result.getResolvedQuery().contains("samson")) { tablet_brand = " Samsung "; } if (result.getResolvedQuery().contains("Amazon") || result.getResolvedQuery().contains("amazon")) { tablet_brand = " Amazon "; } if (result.getResolvedQuery().contains("Asus") || result.getResolvedQuery().contains("asus")) { tablet_brand = " Asus "; } if (result.getResolvedQuery().contains("HP") || result.getResolvedQuery().contains("hp")) { tablet_brand = " HP "; } if (result.getResolvedQuery().contains("Lenovo") || result.getResolvedQuery().contains("lenovo")) { tablet_brand = " Lenovo "; } /* final HashMap<String, JsonElement> params = result.getParameters(); if (params != null && !params.isEmpty()) { Log.i(TAG, "Parameters: "); for (final Map.Entry<String, JsonElement> entry : params.entrySet()) { Log.i(TAG, String.format("%s: %s", entry.getKey(), entry.getValue().toString())); if (entry.getKey().equalsIgnoreCase("Tablet_Brand")) tablet_brand = entry.getValue().toString(); } }*/ tablet_model = "null"; } // if(result.getAction().equals("tablet.addbrand")) { // final HashMap<String, JsonElement> params = result.getParameters(); // if (params != null && !params.isEmpty()) { // Log.i(TAG, "Parameters: "); // for (final Map.Entry<String, JsonElement> entry : params.entrySet()) { // Log.i(TAG, String.format("%s: %s", entry.getKey(), entry.getValue().toString())); // if (entry.getKey().equalsIgnoreCase("Tablet_Brand") && entry.getValue().toString() != null) { // tablet_brand = entry.getValue().toString(); // tablet_model = " null "; // } // } // } // } if (result.getAction().equals("tablet.finished")) { final HashMap<String, JsonElement> params = result.getParameters(); if (params != null && !params.isEmpty()) { Log.i(TAG, "Parameters: "); for (final Map.Entry<String, JsonElement> entry : params.entrySet()) { Log.i(TAG, String.format("%s: %s", entry.getKey(), entry.getValue().toString())); if (entry.getKey().equalsIgnoreCase("min")) tablet_minprice = entry.getValue().toString(); if (entry.getKey().equalsIgnoreCase("max")) tablet_maxprice = entry.getValue().toString(); // if (entry.getKey().equalsIgnoreCase("Tablet_OS")) // tablet_os = entry.getValue().toString(); } } if (tablet_maxprice == null) tablet_maxprice = " above "; if (tablet_minprice == null) tablet_minprice = " below "; Log.i("final tablet min", tablet_minprice); Log.i("final tablet max", tablet_maxprice); Log.i("final tablet os", tablet_os); Log.i("final tablet model", tablet_model); Log.i("final tablet brand", tablet_brand); tablet_brand = tablet_brand.substring(1, tablet_brand.length() - 1); tablet_minprice = tablet_minprice.substring(1, tablet_minprice.length() - 1); tablet_maxprice = tablet_maxprice.substring(1, tablet_maxprice.length() - 1); isDialogEnd = true; searchTabletAmazon(tablet_brand, tablet_browsenode, tablet_maxprice, tablet_minprice, tablet_os, tablet_model); } }
From source file:monakhv.samlib.http.HttpClientController.java
private HashMap<String, ArrayList<AuthorCard>> parseSearchAuthorData(String text) throws SamlibParseException { String[] lines = text.split("\n"); HashMap<String, ArrayList<AuthorCard>> res = new HashMap<String, ArrayList<AuthorCard>>(); for (String line : lines) { if (SamLibConfig.testSplit(line) < 7) { Log.e(DEBUG_TAG, "Line Search parse Error: length=" + SamLibConfig.testSplit(line) + "\nline: " + line + "\nlines: " + lines.length); throw new SamlibParseException("Parse Search Author error\nline: " + line); }/*from www . j a va 2s. c o m*/ try { AuthorCard card = new AuthorCard(line); String name = card.getName(); if (res.containsKey(name)) { res.get(name).add(card); } else { ArrayList<AuthorCard> aa = new ArrayList<AuthorCard>(); aa.add(card); res.put(name, aa); } } catch (SamLibNullAuthorException ex) { //Log.i(DEBUG_TAG,"Skip author with no book"); } } if (res.isEmpty()) { return null; } return res; }
From source file:Controladores.controladorFuncionario.java
@RequestMapping(value = "salva-funcionario-restrito", produces = "text/html; charset=UTF-8") @ResponseBody/*from www . ja v a 2 s.c om*/ public String salvaFuncionario(String funcionarioJson, String operacao, String img) { try { HashMap<String, String> erros = new HashMap<String, String>(); Funcionario funcionario = new Gson().fromJson(funcionarioJson, Funcionario.class); funcionario.setImgperfil(img); if (funcionario.getNome().trim().length() == 0) { erros.put("erroNome", "Informe o nome"); } if (funcionario.getSobrenome().trim().length() == 0) { erros.put("erroSobrenome", "Informe o sobrenome"); } if (funcionario.getEmail().trim().length() == 0) { erros.put("erroEmail", "Informe um email vlido"); } if (funcionario.getPassword().trim().length() < 6) { erros.put("erroPassword", "Informe uma senha com pelo menos 6 caracteres"); } if (funcionario.getTpcargo().getId() == 0) { erros.put("erroTpCargo", "Selecione o cargo"); } if (img == null) { erros.put("erroImg", "Selecione uma imagem"); } if (operacao.equalsIgnoreCase("I")) { funcionario.setDtcriacao(new Date()); funcionario.setIsAtivo(Boolean.TRUE); } if (erros.isEmpty()) { FuncionarioDAO.salvarFuncionario(funcionario); } Gson gson = new Gson(); JsonObject myObj = new JsonObject(); myObj.addProperty("sucesso", erros.isEmpty()); JsonElement objetoErrosEmJson = gson.toJsonTree(erros); myObj.add("erros", objetoErrosEmJson); return myObj.toString(); } catch (Exception erro) { return null; } }
From source file:opendap.threddsHandler.ThreddsCatalogUtil.java
private HashMap<String, Element> collectServices(Element threddsCatalog, SERVICE s) throws InterruptedException { HashMap<String, Element> services = collectServices(threddsCatalog); HashMap<String, Element> childSrvcs; // If they aren't asking for everything... if (s != SERVICE.ALL) { /* boolean done = false; */ Element service;/*from w w w . j a v a 2 s.c om*/ Vector<String> taggedForRemoval = new Vector<String>(); for (String serviceName : services.keySet()) { service = services.get(serviceName); if (service.getAttributeValue("serviceType").equalsIgnoreCase(SERVICE.Compound.toString())) { childSrvcs = collectServices(service, s); if (childSrvcs.isEmpty()) { taggedForRemoval.add(serviceName); } } else if (!service.getAttributeValue("serviceType").equalsIgnoreCase(s.toString())) { taggedForRemoval.add(serviceName); } } for (String serviceName : taggedForRemoval) { services.remove(serviceName); } } return services; }
From source file:org.wandora.modules.ModuleManager.java
/** * Parses a single param element and returns its value. Handles all the * different cases of how a param elements value can be determined. * //from w w w .j a v a 2s. c o m * @param e The xml param element. * @return The value of the parameter. */ public Object parseXMLParamElement(Element e) throws ReflectiveOperationException, IllegalArgumentException, ScriptException { String instance = e.getAttribute("instance"); if (instance != null && instance.length() > 0) { Class cls = Class.forName(instance); HashMap<String, Object> params = parseXMLOptionsElement(e); if (!params.isEmpty()) { Collection<Object> constructorParams = params.values(); Constructor[] cs = cls.getConstructors(); ConstructorLoop: for (int i = 0; i < cs.length; i++) { Constructor c = cs[i]; Class[] paramTypes = c.getParameterTypes(); if (paramTypes.length != constructorParams.size()) continue; int j = -1; for (Object o : constructorParams) { j++; if (o == null) { if (!paramTypes[j].isPrimitive()) continue; else continue ConstructorLoop; } if (paramTypes[j].isPrimitive()) { if (paramTypes[j] == int.class) { if (o.getClass() != Integer.class) continue ConstructorLoop; } else if (paramTypes[j] == long.class) { if (o.getClass() != Long.class) continue ConstructorLoop; } else if (paramTypes[j] == double.class) { if (o.getClass() != Double.class) continue ConstructorLoop; } else if (paramTypes[j] == float.class) { if (o.getClass() != Float.class) continue ConstructorLoop; } else if (paramTypes[j] == byte.class) { if (o.getClass() != Byte.class) continue ConstructorLoop; } else continue ConstructorLoop; //did we forget some primitive type? } else if (!o.getClass().isAssignableFrom(paramTypes[j])) continue ConstructorLoop; } return c.newInstance(constructorParams.toArray()); } throw new NoSuchMethodException( "Couldn't find a constructor that matches parameters parsed from XML."); } else { return cls.newInstance(); } } String clas = e.getAttribute("class"); if (clas != null && clas.length() > 0) { Class cls = Class.forName(clas); return cls; } if (e.hasAttribute("null")) return null; if (e.hasAttribute("script")) { String engine = e.getAttribute("script"); if (engine.length() == 0 || engine.equalsIgnoreCase("default")) engine = ScriptManager.getDefaultScriptEngine(); ScriptManager scriptManager = new ScriptManager(); ScriptEngine scriptEngine = scriptManager.getScriptEngine(engine); scriptEngine.put("moduleManager", this); scriptEngine.put("element", e); try { String script = ((String) xpath.evaluate("text()", e, XPathConstants.STRING)).trim(); return scriptManager.executeScript(script, scriptEngine); } catch (XPathExpressionException xpee) { throw new RuntimeException(xpee); } } if (e.hasAttribute("module")) { String moduleName = e.getAttribute("module").trim(); return new ModuleDelegate(this, moduleName); } try { String value = ((String) xpath.evaluate("text()", e, XPathConstants.STRING)).trim(); return replaceVariables(value, variables); } catch (XPathExpressionException xpee) { throw new RuntimeException(xpee); } }
From source file:org.apereo.services.persondir.support.AttributeBasedCacheKeyGenerator.java
/** * Gets the hash of the key elements from the seed {@link Map}. The key elements are specified by * the <code>cacheKeyAttributes</code> {@link Set} or if it is <code>null</code> the * <code>defaultAttributeName</code> is used as the key attribute. * * @param seed Seed//from www . jav a2 s .com * @return Hash of key elements from the seed */ protected Integer getKeyHash(final Map<String, Object> seed) { //Determine the attributes to build the cache key with final Set<String> cacheAttributes; if (this.useAllAttributes) { cacheAttributes = seed.keySet(); } else if (this.cacheKeyAttributes != null) { cacheAttributes = this.cacheKeyAttributes; } else { cacheAttributes = this.defaultAttributeNameSet; } //Build the cache key based on the attribute Set final HashMap<String, Object> cacheKey = new HashMap<>(cacheAttributes.size()); for (final String attr : cacheAttributes) { if (seed.containsKey(attr)) { final Object value = seed.get(attr); if (!this.ignoreEmptyAttributes) { cacheKey.put(attr, value); } else if (value instanceof Collection) { if (!CollectionUtils.isEmpty((Collection<?>) value)) { cacheKey.put(attr, value); } } else if (value instanceof String) { if (StringUtils.isNotEmpty((String) value)) { cacheKey.put(attr, value); } } else if (value != null) { cacheKey.put(attr, value); } } } if (this.logger.isDebugEnabled()) { this.logger.debug("Generated cache Map " + cacheKey + " from seed Map " + seed); } //If no entries don't return a key if (cacheKey.isEmpty()) { return null; } //Return the key map's hash code return cacheKey.hashCode(); }
From source file:org.apache.axis2.engine.MessageContextSaveATest.java
public void testMapping() throws Exception { String title = "MessageContextSaveATest:testMapping(): "; log.debug(title + "start - - - - - - - - - - - - - - - -"); MessageContext restoredMC = null; //--------------------------------------------------------------------- // make sure that the operation context messageContexts table // has an entry for the message context that we working with //--------------------------------------------------------------------- // look at the OperationContext messageContexts table HashMap mcMap1 = mc.getOperationContext().getMessageContexts(); if ((mcMap1 == null) || (mcMap1.isEmpty())) { mc.getAxisOperation().addMessageContext(mc, mc.getOperationContext()); }/*from ww w. ja v a 2 s . c o m*/ // update the table mcMap1 = mc.getOperationContext().getMessageContexts(); log.debug(title + "- - - - - original message contexts table- - - - - - - - - - -"); showMcMap(mcMap1); //--------------------------------------------------------------------- // save and restore the message context //--------------------------------------------------------------------- File theFile; String theFilename = null; boolean pause = false; boolean savedMessageContext = false; boolean restoredMessageContext = false; boolean comparesOk = false; try { theFile = File.createTempFile("McMappings", null); theFilename = theFile.getName(); log.debug(title + "temp file = [" + theFilename + "]"); } catch (Exception ex) { log.debug(title + "error creating temp file = [" + ex.getMessage() + "]"); theFile = null; } if (theFile != null) { // --------------------------------------------------------- // save to the temporary file // --------------------------------------------------------- try { // setup an output stream to a physical file FileOutputStream outStream = new FileOutputStream(theFile); // attach a stream capable of writing objects to the // stream connected to the file ObjectOutputStream outObjStream = new ObjectOutputStream(outStream); // try to save the message context log.debug(title + "saving message context....."); savedMessageContext = false; outObjStream.writeObject(mc); // close out the streams outObjStream.flush(); outObjStream.close(); outStream.flush(); outStream.close(); savedMessageContext = true; log.debug(title + "....saved message context....."); long filesize = theFile.length(); log.debug(title + "file size after save [" + filesize + "] temp file = [" + theFilename + "]"); } catch (Exception ex2) { log.debug(title + "error with saving message context = [" + ex2.getClass().getName() + " : " + ex2.getMessage() + "]"); ex2.printStackTrace(); } assertTrue(savedMessageContext); // --------------------------------------------------------- // restore from the temporary file // --------------------------------------------------------- try { // setup an input stream to the file FileInputStream inStream = new FileInputStream(theFile); // attach a stream capable of reading objects from the // stream connected to the file ObjectInputStream inObjStream = new ObjectInputStream(inStream); // try to restore the message context log.debug(title + "restoring a message context....."); restoredMessageContext = false; restoredMC = (MessageContext) inObjStream.readObject(); inObjStream.close(); inStream.close(); restoredMC.activate(configurationContext); restoredMessageContext = true; log.debug(title + "....restored message context....."); // get the table after the restore HashMap mcMap2 = restoredMC.getOperationContext().getMessageContexts(); log.debug( "MessageContextSaveATest:testMapping(): - - - - - restored message contexts table- - - - - - - - - - -"); showMcMap(mcMap2); boolean okMap = compareMCMaps(mcMap1, mcMap2); assertTrue(okMap); } catch (Exception ex2) { log.debug(title + "error with restoring message context = [" + ex2.getClass().getName() + " : " + ex2.getMessage() + "]"); ex2.printStackTrace(); } assertTrue(restoredMessageContext); // if the save/restore of the message context succeeded, // then don't keep the temporary file around boolean removeTmpFile = savedMessageContext && restoredMessageContext && comparesOk; if (removeTmpFile) { try { theFile.delete(); } catch (Exception e) { // just absorb it } } } log.debug(title + "end - - - - - - - - - - - - - - - -"); }