List of usage examples for java.util Hashtable containsKey
public synchronized boolean containsKey(Object key)
From source file:com.circles.model.ApplicationJSON.java
public Hashtable<String, Object> processParent(String key, Hashtable<String, Object> parent, Object childobj) { Hashtable<String, Object> newhead = parent; Hashtable<String, Object> newparent = newhead; if (!key.equals("")) { String[] splitkey = key.split("\\."); for (int i = 0; i < splitkey.length; i++) { if (splitkey.length - 1 == i) { newparent.put(splitkey[i], childobj); } else { if (newparent.containsKey(splitkey[i])) { Object parentobj = newparent.get(splitkey[i]); if (parentobj.getClass().equals(Hashtable.class)) { newparent = (Hashtable<String, Object>) parentobj; } else { Hashtable<String, Object> childhash = new Hashtable<String, Object>(); newparent.put(splitkey[i], childhash); newparent = childhash; }/* ww w.j av a 2 s . co m*/ } else { Hashtable<String, Object> childhash = new Hashtable<String, Object>(); newparent.put(splitkey[i], childhash); newparent = childhash; } } } } return newhead; }
From source file:com.fiorano.openesb.application.aps.Route.java
public void populate(FioranoStaxParser cursor) throws XMLStreamException, FioranoException { //Set cursor to the current DMI element. You can use either markCursor/getNextElement(<element>) API. if (cursor.markCursor(APSConstants.APP_ROUTE)) { // Get Attributes. This MUST be done before accessing any data of element. Hashtable attributes = cursor.getAttributes(); if (attributes != null && attributes.containsKey(APSConstants.IS_P2PROUTE)) { boolean isP2PRoute = XMLUtils.getStringAsBoolean((String) attributes.get(APSConstants.IS_P2PROUTE)); setIsP2PRoute(isP2PRoute);// w w w . ja v a2 s . c o m } if (attributes != null && attributes.containsKey(APSConstants.IS_PERSISTANT)) { boolean isPersistant = XMLUtils .getStringAsBoolean((String) attributes.get(APSConstants.IS_PERSISTANT)); setIsPersitant(isPersistant); } if (attributes != null && attributes.containsKey(APSConstants.IS_DURABLE)) { boolean isDurable = XMLUtils.getStringAsBoolean((String) attributes.get(APSConstants.IS_DURABLE)); setIsDurable(isDurable); } if (attributes != null && attributes.containsKey(APSConstants.APPLY_TRANSFORMATION_AT_SRC)) { boolean applyTransformationAtSrc = XMLUtils .getStringAsBoolean((String) attributes.get(APSConstants.APPLY_TRANSFORMATION_AT_SRC)); setApplyTransformationAtSrc(applyTransformationAtSrc); } //Get associated Data //String nodeVal = cursor.getText(); // Get Child Elements while (cursor.nextElement()) { String nodeName = cursor.getLocalName(); // For debugging. Remove this befor chekin... // Get Attributes attributes = cursor.getAttributes(); if (nodeName.equalsIgnoreCase("Name")) { String nodeValue = cursor.getText(); setRouteName(nodeValue); } else if (nodeName.equalsIgnoreCase("RouteGUID")) { String nodeValue = cursor.getText(); setRouteGUID(nodeValue); } else if (nodeName.equalsIgnoreCase("TimeToLive")) { long nodeValue = XMLUtils.getStringAsLong(cursor.getText()); setTimeToLive(nodeValue); } else if (nodeName.equalsIgnoreCase("SrcServiceInstance")) { String nodeValue = cursor.getText(); setSrcServInst(nodeValue); } else if (nodeName.equalsIgnoreCase("SrcPort")) { String nodeValue = cursor.getText(); setSrcPortName(nodeValue); } else if (nodeName.equalsIgnoreCase("TransformationXSL")) { String nodeValue = cursor.getCData(); setTransformationXSL(nodeValue); } else if (nodeName.equalsIgnoreCase("Selector")) { String type = (String) attributes.get("type"); //Iterator itr = attributes.values().iterator(); Enumeration namesItr = attributes.keys(); HashMap namespace = null; if (type.equalsIgnoreCase(XPATH_SELECTOR_OLD)) type = MESSAGE_BODY_XPATH; if (type.equalsIgnoreCase(MESSAGE_BODY_XPATH) || type.equalsIgnoreCase(APP_CONTEXT_XPATH)) { while (namesItr.hasMoreElements()) { String attrName = (String) namesItr.nextElement(); if (attrName.startsWith("esb_")) { if (namespace == null) namespace = new HashMap(); String val = (String) attributes.get(attrName); namespace.put(attrName.substring(4), val); } } String value = cursor.getText(); addXPathSelector(type, value, namespace); } else { String value = cursor.getText(); m_selectors.put(type, value); } } else if (nodeName.equalsIgnoreCase("TgtServiceInstance")) { String nodeValue = cursor.getText(); setTrgtServInst(nodeValue); } else if (nodeName.equalsIgnoreCase("TgtPort")) { String nodeValue = cursor.getText(); setTrgtPortName(nodeValue); } else if (nodeName.equalsIgnoreCase("LongDescription")) { String nodeValue = cursor.getText(); setLongDescription(nodeValue); } else if (nodeName.equalsIgnoreCase("ShortDescription")) { String nodeValue = cursor.getText(); setShortDescription(nodeValue); } else if (nodeName.equalsIgnoreCase("Param")) { String nodeValue = cursor.getText(); Param param = new Param(); String name = (String) attributes.get("name"); param.setParamName(name); param.setParamValue(nodeValue); m_params.add(param); } else if (nodeName.equalsIgnoreCase("AlternateDestination")) { AlternateDestination altDestination = new AlternateDestination(); altDestination.setFieldValues(cursor); setAlternateDestination(altDestination); } } } validate(); }
From source file:com.hybris.mobile.adapter.FormAdapter.java
@SuppressWarnings({ "rawtypes", "unchecked" }) @Override//from w w w .j a v a2 s . c o m public View getView(final int position, View convertView, ViewGroup parent) { LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View rowView = inflater.inflate(R.layout.form_row, parent, false); LinearLayout lnr = (LinearLayout) rowView.findViewById(R.id.linear_layout_form); final Hashtable<String, Object> obj = (Hashtable<String, Object>) objects.get(position); String className = "com.hybris.mobile.view." + obj.get("cellIdentifier").toString(); Object someObj = null; try { Class cell; cell = Class.forName(className); Constructor constructor = cell.getConstructor(new Class[] { Context.class }); someObj = constructor.newInstance(this.context); } catch (Exception e) { LoggingUtils.e(LOG_TAG, "Error loading class \"" + className + "\". " + e.getLocalizedMessage(), Hybris.getAppContext()); } /* * Text Cell */ if (someObj != null && someObj instanceof HYFormTextEntryCell) { final HYFormTextEntryCell textCell = (HYFormTextEntryCell) someObj; if (isLastEditText(position)) { textCell.setImeDone(this); } lnr.addView(textCell); textCell.setId(position); if (obj.containsKey("inputType")) { Integer val = mInputTypes.get(obj.get("inputType").toString()); textCell.setContentInputType(val); } if (obj.containsKey("value")) { textCell.setContentText(obj.get("value").toString()); } if (obj.containsKey("keyboardType") && StringUtils.equals(obj.get("keyboardType").toString(), "UIKeyboardTypeEmailAddress")) { textCell.setContentInputType(mInputTypes.get("textEmailAddress")); } textCell.addContentChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { obj.put("value", s.toString()); notifyFormDataChangedListner(); } }); textCell.setOnFocusChangeListener(new OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (!hasFocus) { textCell.setTextColor(context.getResources().getColor(R.color.textMedium)); if (!fieldIsValid(position)) { setIsValid(false); textCell.showMessage(true); } else { textCell.showMessage(false); } showInvalidField(); validateAllFields(); } else { textCell.setTextColor(context.getResources().getColor(R.color.textHighlighted)); setCurrentFocusIndex(position); } } }); textCell.setContentTitle(obj.get("title").toString()); if (obj.containsKey("error")) { textCell.setMessage(obj.get("error").toString()); } if (obj.containsKey("showerror")) { Boolean showerror = Boolean.parseBoolean(obj.get("showerror").toString()); textCell.showMessage(showerror); } else { textCell.showMessage(false); } if (currentFocusIndex == position) { textCell.setFocus(); } } /* * Secure Text Cell */ else if (someObj instanceof HYFormSecureTextEntryCell) { final HYFormSecureTextEntryCell secureTextCell = (HYFormSecureTextEntryCell) someObj; if (isLastEditText(position)) { secureTextCell.setImeDone(this); } lnr.addView(secureTextCell); secureTextCell.setId(position); if (obj.containsKey("value")) { secureTextCell.setContentText(obj.get("value").toString()); } if (obj.containsKey("inputType")) { Integer val = mInputTypes.get(obj.get("inputType").toString()); secureTextCell.setContentInputType(val); } secureTextCell.addContentChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { obj.put("value", s.toString()); notifyFormDataChangedListner(); } }); secureTextCell.setOnFocusChangeListener(new OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (!hasFocus) { if (!fieldIsValid(position)) { setIsValid(false); secureTextCell.showMessage(true); } else { secureTextCell.showMessage(false); } showInvalidField(); validateAllFields(); } else { setCurrentFocusIndex(position); } } }); secureTextCell.setContentTitle(obj.get("title").toString()); if (obj.containsKey("error")) { secureTextCell.setMessage(obj.get("error").toString()); } if (obj.containsKey("showerror")) { Boolean showerror = Boolean.parseBoolean(obj.get("showerror").toString()); secureTextCell.showMessage(showerror); } else { secureTextCell.showMessage(false); } if (currentFocusIndex == position) { secureTextCell.setFocus(); } } else if (someObj instanceof HYFormTextSelectionCell) { setIsValid(fieldIsValid(position)); HYFormTextSelectionCell selectionTextCell = (HYFormTextSelectionCell) someObj; lnr.addView(selectionTextCell); if (StringUtils.isNotBlank((String) obj.get("value"))) { StringBuilder b = new StringBuilder(obj.get("value").toString()); selectionTextCell.setSpinnerText(b.replace(0, 1, b.substring(0, 1).toUpperCase()).toString()); } else { selectionTextCell.setSpinnerText(obj.get("title").toString()); } } else if (someObj instanceof HYFormTextSelectionCell2) { HYFormTextSelectionCell2 selectionTextCell = (HYFormTextSelectionCell2) someObj; lnr.addView(selectionTextCell); selectionTextCell.init(obj); } else if (someObj instanceof HYFormSwitchCell) { HYFormSwitchCell checkBox = (HYFormSwitchCell) someObj; lnr.addView(checkBox); checkBox.setCheckboxText(obj.get("title").toString()); if (StringUtils.isNotBlank((String) obj.get("value"))) { checkBox.setCheckboxChecked(Boolean.parseBoolean((String) obj.get("value"))); } checkBox.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { HYFormSwitchCell chk = (HYFormSwitchCell) v; chk.toggleCheckbox(); obj.put("value", String.valueOf(chk.isCheckboxChecked())); notifyFormDataChangedListner(); } }); } else if (someObj instanceof HYFormSubmitButton) { HYFormSubmitButton btnCell = (HYFormSubmitButton) someObj; lnr.addView(btnCell); btnCell.setButtonText(obj.get("title").toString()); btnCell.setOnButtonClickListener(new OnClickListener() { @Override public void onClick(View v) { submit(); } }); } return rowView; }
From source file:oscar.dms.actions.DmsInboxManageAction.java
private void setProviderDocsInSession(ArrayList<EDoc> privatedocs, HttpServletRequest request) { ArrayList<Hashtable<String, String>> providers = ProviderData.getProviderListOfAllTypes(); Hashtable<String, List<EDoc>> providerDocs = new Hashtable<String, List<EDoc>>(); for (int i = 0; i < providers.size(); i++) { Hashtable<String, String> ht = providers.get(i); List<EDoc> EDocs = new ArrayList<EDoc>(); String providerNo = ht.get("providerNo"); providerDocs.put(providerNo, EDocs); }//from www .j a v a 2s . co m for (int i = 0; i < privatedocs.size(); i++) { EDoc eDoc = privatedocs.get(i); List<String> providerList = new ArrayList<String>(); String createrId = eDoc.getCreatorId(); if (providerDocs.containsKey(createrId)) { List<EDoc> EDocs = new ArrayList<EDoc>(); EDocs = providerDocs.get(createrId); EDocs.add(eDoc); providerDocs.put(createrId, EDocs); } String docId = eDoc.getDocId(); providerList.add(createrId); List<ProviderInboxItem> routeList = providerInboxRoutingDAO .getProvidersWithRoutingForDocument(LabResultData.DOCUMENT, docId); for (ProviderInboxItem pii : routeList) { String routingPId = pii.getProviderNo(); if (!routingPId.equals(createrId) && providerDocs.containsKey(routingPId)) { List<EDoc> EDocs = new ArrayList<EDoc>(); EDocs = providerDocs.get(routingPId); EDocs.add(eDoc); providerDocs.put(routingPId, EDocs); } } } // remove providers which has no docs linked to Enumeration<String> keys = providerDocs.keys(); while (keys.hasMoreElements()) { String key = keys.nextElement(); List<EDoc> EDocs = new ArrayList<EDoc>(); EDocs = providerDocs.get(key); if (EDocs == null || EDocs.size() == 0) { providerDocs.remove(key); } } request.getSession().setAttribute("providerDocs", providerDocs); }
From source file:org.hdiv.filter.ValidatorHelperRequest.java
/** * Checks if the cookies received in the request are correct. For that, it checks if they are in the user session. * //from www . j av a 2 s.c om * @param request * HttpServletRequest to validate * @param target * Part of the url that represents the target action * @return valid result if all the cookies received in the request are correct. They must have been previously * stored in the user session by HDIV to be correct. False otherwise. * @since HDIV 1.1 */ public ValidatorHelperResult validateRequestCookies(HttpServletRequest request, String target) { Cookie[] requestCookies = request.getCookies(); if ((requestCookies == null) || (requestCookies.length == 0)) { return ValidatorHelperResult.VALID; } Hashtable sessionCookies = (Hashtable) request.getSession().getAttribute(Constants.HDIV_COOKIES_KEY); if (sessionCookies == null) { return ValidatorHelperResult.VALID; } boolean cookiesConfidentiality = Boolean.TRUE.equals(this.hdivConfig.getConfidentiality()) && this.hdivConfig.isCookiesConfidentialityActivated(); for (int i = 0; i < requestCookies.length; i++) { boolean found = false; if (requestCookies[i].getName().equals(Constants.JSESSIONID)) { continue; } if (sessionCookies.containsKey(requestCookies[i].getName())) { SavedCookie savedCookie = (SavedCookie) sessionCookies.get(requestCookies[i].getName()); if (savedCookie.equals(requestCookies[i], cookiesConfidentiality)) { found = true; if (cookiesConfidentiality) { if (savedCookie.getValue() != null) { requestCookies[i].setValue(savedCookie.getValue()); } } } } if (!found) { this.logger.log(HDIVErrorCodes.COOKIE_INCORRECT, target, "cookie:" + requestCookies[i].getName(), requestCookies[i].getValue()); return new ValidatorHelperResult(HDIVErrorCodes.COOKIE_INCORRECT); } } return ValidatorHelperResult.VALID; }
From source file:org.mycore.frontend.editor.MCREditorSubmission.java
private void setRepeatsFromVariables() { Hashtable maxtable = new Hashtable(); for (Object variable : variables) { MCREditorVariable var = (MCREditorVariable) variable; String[] path = var.getPathElements(); String prefix = "/" + path[0]; for (int j = 1; j < path.length; j++) { String name = path[j]; int pos1 = name.lastIndexOf("["); int pos2 = name.lastIndexOf("]"); if (pos1 != -1) { String elem = name.substring(0, pos1); String num = name.substring(pos1 + 1, pos2); String key = prefix + "/" + elem; int numNew = Integer.parseInt(num); if (maxtable.containsKey(key)) { int numOld = Integer.parseInt((String) maxtable.get(key)); maxtable.remove(key); numNew = Math.max(numOld, numNew); }/*from www . j a va 2s . c o m*/ maxtable.put(key, String.valueOf(numNew)); } prefix = prefix + "/" + name; } } for (Enumeration e = maxtable.keys(); e.hasMoreElements();) { String path = (String) e.nextElement(); String value = (String) maxtable.get(path); repeats.add(new MCREditorVariable(path, value)); LOGGER.debug("Editor repeats " + path + " = " + value); } }
From source file:metabest.transformations.MetaModel2Use.java
private String simultaneousCompositionConstraint(List<Reference> references) { String constraints = ""; // obtain the containment references that can contain each class Hashtable<String, List<Reference>> containers = new Hashtable<String, List<Reference>>(); for (Reference ref : references) { if (ref.isAnnotated(Composition.NAME)) { String classname = ref.getReference().getName(); if (!containers.containsKey(classname)) containers.put(classname, new ArrayList<Reference>()); containers.get(classname).add(ref); }//w w w . j a v a 2 s. c om if (ref.getOpposite() != null && ref.getOpposite().isAnnotated(Composition.NAME)) { String classname = ref.getOpposite().getReference().getName(); if (!containers.containsKey(classname)) containers.put(classname, new ArrayList<Reference>()); containers.get(classname).add(ref.getOpposite()); } } // if a class can potentially be in more than two containers, add a constraint for (Entry<String, List<Reference>> entry : containers.entrySet()) { if (entry.getValue().size() > 1) { constraints += "\n\ncontext " + entry.getKey() + "\n\tinv single_container: "; constraints += "\n"; for (Reference ref : entry.getValue()) constraints += "\t" + ((MetaClass) ref.eContainer()).getName() + ".allInstances()->collect(o | o." + ref.getName() + ")->count(self) +\n"; constraints = constraints.substring(0, constraints.lastIndexOf("+")) + "<= 1"; } } if (!constraints.isEmpty()) constraints += "\n"; return constraints; }
From source file:org.globus.workspace.network.defaults.Util.java
/** * @param associationDir association directory, may not be null * @param previous previous entries/*w w w. j a v a2 s .com*/ * @return updated entries * @throws Exception problem */ static Hashtable loadDirectory(File associationDir, Hashtable previous) throws Exception { if (associationDir == null) { throw new IllegalArgumentException("null associationDir"); } final String[] listing = associationDir.list(); if (listing == null) { // null return from list() is different than zero results, it denotes a real problem throw new Exception( "Problem listing contents of directory '" + associationDir.getAbsolutePath() + '\''); } final Hashtable newAssocSet = new Hashtable(listing.length); for (int i = 0; i < listing.length; i++) { final String path = associationDir.getAbsolutePath() + File.separator + listing[i]; final File associationFile = new File(path); if (!associationFile.isFile()) { logger.warn("not a file: '" + path + "'"); continue; } final String assocName = associationFile.getName(); Association oldassoc = null; if (previous != null) { oldassoc = (Association) previous.get(assocName); // skip reading if file modification time isn't newer than last // container boot if (oldassoc != null) { if (oldassoc.getFileTime() == associationFile.lastModified()) { logger.info("file modification time for network '" + assocName + "' is not newer, using old configuration"); newAssocSet.put(assocName, oldassoc); continue; } } } final Association newassoc = getNewAssoc(assocName, associationFile, oldassoc); if (newassoc != null) { newAssocSet.put(assocName, newassoc); } } if (previous == null || previous.isEmpty()) { return newAssocSet; } // Now look at previous entries in database for entries that were // there and now entirely gone. // If in use, we don't do anything. When retired and the entry is // not in DB, a warning will trip but that is it. From then on, the // address will be gone. final Enumeration en = previous.keys(); while (en.hasMoreElements()) { final String assocname = (String) en.nextElement(); final Association oldassoc = (Association) previous.get(assocname); if (oldassoc == null) { throw new ProgrammingError("all networks " + "in the hashmap should be non-null"); } if (newAssocSet.containsKey(assocname)) { logChangedAssoc(assocname, (Association) newAssocSet.get(assocname), oldassoc); } else { logger.info("Previously configured network '" + assocname + "' is not present in the new configuration. " + goneStatus(oldassoc)); } } return newAssocSet; }
From source file:com.smartitengineering.dao.impl.hibernate.AbstractDAOTest.java
private Hashtable<String, QueryParameter> getQueryParamHashtable(QueryParameter... params) { Hashtable<String, QueryParameter> table = new Hashtable<String, QueryParameter>(); for (QueryParameter parameter : params) { String paramName = getPropertyName(parameter); if (table.containsKey(paramName)) { int i = 1; while (table.containsKey(new StringBuilder(paramName).append(i).toString())) { i++;//from ww w . ja v a2 s.c o m } paramName = new StringBuilder(paramName).append(i).toString(); } table.put(paramName, parameter); } return table; }
From source file:edu.eurac.commul.pepperModules.mmax2.Salt2MMAX2Mapper.java
private SaltExtendedMarkable mapStruct(SStructure struct) throws MMAX2WrapperException { ArrayList<SaltExtendedMarkable> sDomRelMarkableList = new ArrayList<SaltExtendedMarkable>(); Hashtable<SaltExtendedMarkable, SRelationMapping> sDomRelMarkableHash = new Hashtable<SaltExtendedMarkable, SRelationMapping>(); ArrayList<String> spans = new ArrayList<String>(); for (SRelation rel : getDocument().getDocumentGraph().getOutRelations(struct.getId())) { if (rel instanceof SDominanceRelation) { SDominanceRelation sDomRel = (SDominanceRelation) rel; SaltExtendedMarkable sDomRelMarkable = getSRelationMarkable(sDomRel); spans.add(sDomRelMarkable.getSpan()); SRelationMapping validated = matchSRelation(sDomRel); sDomRelMarkableList.add(sDomRelMarkable); if (validated != null) { sDomRelMarkableHash.put(sDomRelMarkable, validated); }//from w w w.j a v a 2 s . com } } SaltExtendedMarkable markable = createMarkableForSNode(getNewId(), makeSpan(spans), struct, SaltExtendedMmax2Infos.SALT_INFO_TYPE_SSTRUCT); for (SaltExtendedMarkable sDomRelMarkable : sDomRelMarkableList) { if (sDomRelMarkableHash.containsKey(sDomRelMarkable)) { SRelationMapping validated = sDomRelMarkableHash.get(sDomRelMarkable); SaltExtendedMarkable containerSourceMarkable = getSContainerMarkable(markable, validated.getSourceAssociatedSchemeName(), markable.getSpan(), markable.getSName(), markable.getId(), markable.getId(), markable.getFactory().getScheme().getName()); addPointerAttribute(containerSourceMarkable, validated.getSourceAssociatedSchemeName(), validated.getTargetAssociatedSchemeName(), validated.getPointedAssociatedAttributeName(), sDomRelMarkable.getAttribute("id_target").getValue()); sDomRelMarkable.removeAttribute(sDomRelMarkable.getAttribute("id_target")); addFreetextAttribute(sDomRelMarkable, SaltExtendedMmax2Infos.SALT_INFO_TYPE_SDOMINANCE_REL, "struct_attr", validated.getPointedAssociatedAttributeName()); addFreetextAttribute(sDomRelMarkable, SaltExtendedMmax2Infos.SALT_INFO_TYPE_SDOMINANCE_REL, "struct_scheme", validated.getSourceAssociatedSchemeName()); addFreetextAttribute(sDomRelMarkable, SaltExtendedMmax2Infos.SALT_INFO_TYPE_SDOMINANCE_REL, "struct", containerSourceMarkable.getId()); } else { addPointerAttribute(sDomRelMarkable, SaltExtendedMmax2Infos.SALT_INFO_TYPE_SDOMINANCE_REL, SaltExtendedMmax2Infos.SALT_INFO_TYPE_SSTRUCT, "struct", markable.getId()); } } return markable; }