List of usage examples for java.util Hashtable containsKey
public synchronized boolean containsKey(Object key)
From source file:org.wso2.carbon.appmgt.usage.client.billing.PaymentPlan.java
/** * @param billOrder is hash table that contains data parameter name and value pairs * @return BigDecimal value of cost in billing order * @throws Exception @ error in evaluating */// w w w. ja v a2s .co m public BigDecimal evaluate(Hashtable billOrder) throws Exception { BigDecimal total = new BigDecimal(0); for (DataParameter iterator : elementVector) { if (billOrder.containsKey(iterator.objectName)) { Integer amount = (Integer) billOrder.get(iterator.objectName); total = total.add((BigDecimal) iterator.evaluate(amount).get("total")); } } return total; }
From source file:eu.europa.ec.markt.dss.signature.pades.PAdESProfileEPES.java
CMSSignedDataGenerator createCMSSignedDataGenerator(ContentSigner contentSigner, DigestCalculatorProvider digestCalculatorProvider, final SignatureParameters parameters, final byte[] messageDigest) throws IOException { try {/*from w ww . ja va 2s. co m*/ CMSSignedDataGenerator generator = new CMSSignedDataGenerator(); X509Certificate signerCertificate = parameters.getSigningCertificate(); X509CertificateHolder certHolder = new X509CertificateHolder(signerCertificate.getEncoded()); SignerInfoGeneratorBuilder sigenb = new SignerInfoGeneratorBuilder(digestCalculatorProvider); final CAdESProfileEPES profile = new CAdESProfileEPES(true); sigenb = sigenb.setSignedAttributeGenerator(new CMSAttributeTableGenerator() { @Override public AttributeTable getAttributes(Map params) throws CMSAttributeTableGenerationException { Hashtable clone = (Hashtable) profile.getSignedAttributes(parameters).clone(); if (!clone.containsKey(CMSAttributes.contentType)) { DERObjectIdentifier contentType = (DERObjectIdentifier) params .get(CMSAttributeTableGenerator.CONTENT_TYPE); // contentType will be null if we're trying to generate a counter signature. if (contentType != null) { Attribute attr = new Attribute(CMSAttributes.contentType, new DERSet(contentType)); clone.put(attr.getAttrType(), attr); } } if (!clone.containsKey(CMSAttributes.messageDigest)) { System.out.println("Digest propos : " + org.apache.commons.codec.binary.Hex.encodeHexString(messageDigest)); // byte[] messageDigest = (byte[]) params.get(CMSAttributeTableGenerator.DIGEST); Attribute attr = new Attribute(CMSAttributes.messageDigest, new DERSet(new DEROctetString(messageDigest))); clone.put(attr.getAttrType(), attr); } if (parameters.getCommitmentTypeIndication() != null && !parameters.getCommitmentTypeIndication().isEmpty()) { ASN1EncodableVector vector = new ASN1EncodableVector(); for (String id : parameters.getCommitmentTypeIndication()) { vector.add(new DERObjectIdentifier(id)); } DERSet set = new DERSet(new DERSequence(vector)); Attribute attr = new Attribute(new DERObjectIdentifier("1.2.840.113549.1.9.16.2.16"), set); clone.put(attr.getAttrType(), attr); } return new AttributeTable(clone); } }); // sigenb.setUnsignedAttributeGenerator(new SimpleAttributeTableGenerator(new AttributeTable( // new Hashtable<ASN1ObjectIdentifier, ASN1Encodable>()))); /* * We don't include a unsigned attribute table if not needed : a unsignedAttrs of signerInfo includes no * Attribute, UnsignedAttributes ::= SET SIZE (1..MAX) OF Attribute(defined in RFC3852). */ SignerInfoGenerator sigen = sigenb.build(contentSigner, certHolder); generator.addSignerInfoGenerator(sigen); Collection<X509Certificate> certs = new ArrayList<X509Certificate>(); if (parameters.getCertificateChain() == null || !parameters.getCertificateChain().contains(parameters.getSigningCertificate())) { certs.add(parameters.getSigningCertificate()); } certs.addAll(parameters.getCertificateChain()); JcaCertStore certStore = new JcaCertStore(certs); generator.addCertificates(certStore); System.out.println("Gnrator cr"); return generator; } catch (CertificateException e) { throw new IOException(e); } catch (OperatorCreationException e) { throw new IOException(e); } catch (CMSException e) { throw new IOException(e); } }
From source file:com.jaspersoft.jasperserver.export.RemoveDuplicatedDisplayName.java
private int findUniqueDisplayNameNumber(Hashtable ht, int appValue, String name) { String returnDisplayName = name; int tempValue = appValue; while (ht.containsKey(returnDisplayName + " (" + tempValue + ")")) { tempValue++;// ww w .ja v a 2 s. co m } return tempValue; }
From source file:opennlp.tools.textsimilarity.TextProcessor.java
public static Hashtable<String, Integer> getAllBigrams(ArrayList<String> tokens, boolean retainPunc) { Hashtable<String, Integer> bGramCandidates = new Hashtable<String, Integer>(); ArrayList<String> r = new ArrayList<String>(); for (int i = 0; i < tokens.size() - 1; i++) { String b = (String) tokens.get(i) + " " + (String) tokens.get(i + 1); b = b.toLowerCase();/*from w ww .j ava2 s . c o m*/ // don't add punc tokens if (b.indexOf("<punc>") != -1 && !retainPunc) continue; int freq = 1; if (bGramCandidates.containsKey(b)) { freq = ((Integer) bGramCandidates.get(b)).intValue() + 1; } bGramCandidates.put(b, new Integer(freq)); } return bGramCandidates; }
From source file:org.acegisecurity.ldap.DefaultInitialDirContextFactory.java
private InitialDirContext connect(Hashtable env) { if (logger.isDebugEnabled()) { Hashtable envClone = (Hashtable) env.clone(); if (envClone.containsKey(Context.SECURITY_CREDENTIALS)) { envClone.put(Context.SECURITY_CREDENTIALS, "******"); }/*from w w w .ja v a2 s.c o m*/ logger.debug("Creating InitialDirContext with environment " + envClone); } try { return useLdapContext ? new InitialLdapContext(env, null) : new InitialDirContext(env); } catch (NamingException ne) { if ((ne instanceof javax.naming.AuthenticationException) || (ne instanceof OperationNotSupportedException)) { throw new BadCredentialsException( messages.getMessage("DefaultIntitalDirContextFactory.badCredentials", "Bad credentials"), ne); } if (ne instanceof CommunicationException) { throw new LdapDataAccessException( messages.getMessage("DefaultIntitalDirContextFactory.communicationFailure", "Unable to connect to LDAP server"), ne); } throw new LdapDataAccessException( messages.getMessage("DefaultIntitalDirContextFactory.unexpectedException", "Failed to obtain InitialDirContext due to unexpected exception"), ne); } }
From source file:com.jaspersoft.jasperserver.export.RemoveDuplicatedDisplayName.java
private boolean hashNames(List objects) { Hashtable ht = new Hashtable(); for (int i = 0; i < objects.size(); i++) { String curDisplayName = ((Resource) objects.get(i)).getLabel(); if (!ht.containsKey(curDisplayName)) { ArrayList checkList = new ArrayList(); checkList.add(objects.get(i)); ht.put(curDisplayName, checkList); } else {// ww w .j a va2 s.c om ((List) (ht.get(curDisplayName))).add(objects.get(i)); } } updateDuplicateNames(ht); return true; }
From source file:StringNode.java
public String toJSONObject(String prependId, Hashtable htLinks, boolean level1) { StringBuffer stb = new StringBuffer(); if (htLinks != null) { if (!name.startsWith("class ") && !name.startsWith("interface ") && !name.equals("Classes") && !name.equals("Interfaces") && htLinks.containsKey(name) && !level1) { stb.append("{title:'link::"); stb.append(htLinks.get(name)); stb.append("',widgetId:'"); stb.append(prependId);// www .java 2 s . co m stb.append("'}"); return stb.toString(); } else { htLinks.put(name, prependId); } } stb.append("{title:'"); if (name != null) stb.append(name); stb.append("',widgetId:'"); stb.append(prependId); if (childs == null || childs.size() == 0) { stb.append("',children:[]}"); } else { stb.append("',children:["); Collections.sort(childs); for (int i = 0; i < childs.size(); i++) { Object obj = childs.get(i); if (i != 0) stb.append(","); if (obj instanceof StringNode) stb.append(((StringNode) obj).toJSONObject(prependId + "." + i, htLinks)); else { stb.append("{title:'"); stb.append((String) obj); stb.append("',widgetId:'"); stb.append(prependId + "." + i); stb.append("'}"); } } stb.append("]}"); } return stb.toString(); }
From source file:br.gov.frameworkdemoiselle.behave.integration.alm.ALMIntegration.java
/** * Obteem o valor do hash ou retorna um valor padro * /*w w w .j a va 2s . co m*/ * @param result * @param key * @param defaultValue * @return */ private String getHash(Hashtable<String, Object> result, String key, String defaultValue) { if (result.containsKey(key)) { return (String) result.get(key); } else { return defaultValue; } }
From source file:org.esupportail.lecture.domain.model.ManagedCategory.java
/** * @param sourceId/*from w w w . j a v a 2 s .c o m*/ * @return true if this managedCategory contains the source identified by sourceId */ public boolean containsSource(final String sourceId) { if (LOG.isDebugEnabled()) { LOG.debug("profileId=" + getProfileId() + " - containsSource(" + sourceId + ")"); } Hashtable<String, SourceProfile> hashSourceProfile = getSourceProfilesHash(); boolean result = hashSourceProfile.containsKey(sourceId); return result; }
From source file:org.graphwalker.machines.ExtendedFiniteStateMachine.java
/** * Walks the data space, and return the value of the data, if found. * // www. j a v a 2s . c o m * @param dataName * @return * @throws InvalidDataException is thrown if the data is not found in the data space */ public String getDataValue(String dataName) { if (jsEngine != null) { return jsEngine.get(dataName).toString(); } else if (beanShellEngine != null) { Hashtable<String, Object> dataTable = getCurrentBeanShellData(); if (dataTable.containsKey(dataName)) { if (dataTable.get(dataName) instanceof Object[]) { return Arrays.deepToString((Object[]) dataTable.get(dataName)); } else { return dataTable.get(dataName).toString(); } } } return ""; }