Example usage for java.util Hashtable keySet

List of usage examples for java.util Hashtable keySet

Introduction

In this page you can find the example usage for java.util Hashtable keySet.

Prototype

Set keySet

To view the source code for java.util Hashtable keySet.

Click Source Link

Document

Each of these fields are initialized to contain an instance of the appropriate view the first time this view is requested.

Usage

From source file:info.novatec.testit.livingdoc.repository.FileSystemRepositoryTest.java

@SuppressWarnings("unchecked")
private void assertNamesInHierarchy(Hashtable<Object, Object> branch, List<String> names) {
    Iterator<Object> iter = branch.keySet().iterator();
    while (iter.hasNext()) {
        String name = (String) iter.next();
        Vector<Object> child = (Vector<Object>) branch.get(name);
        assertTrue(names.contains(child.get(0)));
        assertNamesInHierarchy((Hashtable<Object, Object>) child.get(3), names);
    }// w w w  . j  ava 2s. c  o m
}

From source file:net.aepik.alasca.core.ldap.Schema.java

/**
 * Get sorted object identifiers keys, to loop on object identifiers
 * into a valid order./* www .ja v  a2s  . c  om*/
 * @param oids Object identifiers.
 * @return String[] Sorted keys
 */
public static String[] getSortedObjectsIdentifiersKeys(Properties oids) {
    Hashtable<String, String> ht = new Hashtable<String, String>();
    for (Enumeration keys = oids.propertyNames(); keys.hasMoreElements();) {
        String k = (String) keys.nextElement();
        Oid o = new Oid(oids.getProperty(k));
        String v = o.toString();
        String p = o.getPrefix();
        while (p != null) {
            v = v.replaceFirst(p + ":", oids.getProperty(p) + ".");
            p = (new Oid(oids.getProperty(p))).getPrefix();
        }
        ht.put(v, k);
    }
    String[] st = ht.keySet().toArray(new String[0]);
    Arrays.sort(st);
    String[] result = new String[st.length];
    int result_index = 0;
    for (String k : st) {
        result[result_index] = ht.get(k);
        result_index++;
    }
    return result;
}

From source file:com.globalsight.util.file.XliffFileUtil.java

/**
 * Handle a list of files to verify if they are Xliff files and for each
 * file, 1.If it is single Xliff file with only one <File> tags, need not
 * process 2.If it is Xliff file with multiple <File> tags, it needs to be
 * separated into single Xliff files with content in each <File> tags. All
 * separated files will have the same header and footer as original file.
 * 3.If it is XLZ file, then unpack the file first and process each Xliff in
 * the package with step #2./*from   w  ww  . j a v a2  s. co m*/
 * 
 * @param p_fileList
 *            A list of original uploaded or selected files and their
 *            corresponding file profile
 * @return java.util.Hashtable<String, FileProfile> List of files that are
 *         processed.
 * 
 * @version 1.0
 * @since 8.2.2
 */
public static Hashtable<String, FileProfile> processXliffFiles(Hashtable<String, FileProfile> p_fileList) {
    Hashtable<String, FileProfile> files = new Hashtable<String, FileProfile>();
    if (p_fileList == null || p_fileList.size() == 0)
        return files;

    String filename = "";
    FileProfile fp = null;
    try {
        Iterator<String> fileKeys = p_fileList.keySet().iterator();

        while (fileKeys.hasNext()) {
            filename = fileKeys.next();
            fp = p_fileList.get(filename);

            switch ((int) fp.getKnownFormatTypeId()) {
            case KNOWN_FILE_FORMAT_XLIFF:
                processMultipleFileTags(files, filename, fp);
                break;
            case KNOWN_FILE_FORMAT_XLZ:
                separateXlzFile(files, filename, fp);
                break;
            default:
                files.put(filename, fp);
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return files;
}

From source file:ch.rgw.tools.StringTool.java

@SuppressWarnings("unchecked")
public static void dumpHashtable(final Log log, final Hashtable table) {
    Set<String> keys = table.keySet();
    log.log("Dump Hashtable\n", Log.INFOS);
    for (String key : keys) {
        log.log(key + ": " + table.get(key).toString(), Log.INFOS);
    }/*from ww  w.  j  a  v a  2s. co m*/
    log.log("End dump\n", Log.INFOS);
}

From source file:com.htm.query.jxpath.JXpathQueryEvaluator.java

public List<?> evaluateQuery(IQuery query) throws com.htm.exceptions.IllegalArgumentException {
    log.debug("JXPath: Evaluating XPath query '" + query.getQuery() + "' within context "
            + jXpathContext.getContextBean());
    if (query instanceof XPathQueryImpl) {
        XPathQueryImpl xpath = (XPathQueryImpl) query;
        Hashtable<String, String> namespaces = xpath.getNamespaces();
        if (namespaces != null) {
            for (String key : namespaces.keySet()) {
                this.jXpathContext.registerNamespace(key, namespaces.get(key));
            }//from  w ww  . j  a v  a2 s  .  c o m
        }
    }
    try {
        // TODO if a jdom object is addressed by an xpath expression that is
        // no leaf node
        // then the values of all leaf nodes are returned. This ha to be
        // handled somehow

        // Object result = this.jXpathContext.getValue(query.getQuery());
        //
        // /* Return empty list if xpath query doesn't match any property */
        // if (result == null) {
        // log.debug("JXPath: Query didn't match");
        // return new ArrayList<Object>();
        // } else if (result instanceof List<?>) {
        // log.debug("JXPath: Query matched. Result type "
        // + result.getClass().getName());
        // return (List<?>) result;
        //
        // } else {
        // log.debug("JXPath: Query matched. Result type "
        // + result.getClass().getName());
        // List<Object> resultList = new ArrayList<Object>();
        // resultList.add(result);
        //
        // return resultList;
        // }
        //            if (log.isDebugEnabled()) {
        //                log.debug("Evaluating all paths for query'" + query.getQuery() + "'");
        //                Iterator paths = this.jXpathContext.iteratePointers("/taskParentContext/properties/child::*");
        //                Pointer path;
        //                while (paths.hasNext()) {
        //                    path = (Pointer) paths.next();
        //                    log.debug("Path found: " + path.asPath());
        //                }
        //            }

        ArrayList<Object> list = new ArrayList<Object>();

        Iterator iterator = this.jXpathContext.iteratePointers(query.getQuery());
        Pointer pointer;
        while (iterator.hasNext()) {
            pointer = (Pointer) iterator.next();
            log.debug("JXPath pointer: " + pointer.asPath());
            list.add(pointer.getNode());
        }
        return list;
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        throw new InvalidQueryException(e);
    }

}

From source file:org.hdiv.web.multipart.HDIVMultipartResolver.java

/**
 * Return the multipart files as Map of field name to MultipartFile instance.
 *///  www .jav a  2 s  . c  om
public MultiValueMap<String, MultipartFile> getMultipartFileElements(Hashtable fileElements) {

    MultiValueMap<String, MultipartFile> multipartFiles = new LinkedMultiValueMap<String, MultipartFile>();
    for (Object key : fileElements.keySet()) {
        multipartFiles.add((String) key, (MultipartFile) fileElements.get(key));
    }

    return multipartFiles;
}

From source file:org.hdiv.webflow.validator.EditableParameterValidator.java

/**
 * Obtains the errors from request detected by HDIV during the validation
 * process of the editable parameters./*from   w  w w .ja va  2  s. c  om*/
 * 
 * @param formObject form object
 * @param errors errors detected by HDIV during the validation process of
 *            the editable parameters.
 */
public void validateEditableParameters(Object formObject, Errors errors) {

    ExternalContext externalContext = ExternalContextHolder.getExternalContext();
    Hashtable editableParameters = (Hashtable) externalContext.getRequestMap().get(EDITABLE_PARAMETER_ERROR);

    if ((editableParameters != null) && (editableParameters.size() > 0)) {

        for (Iterator it = editableParameters.keySet().iterator(); it.hasNext();) {

            String currentParameter = (String) it.next();
            String[] currentUnauthorizedValues = (String[]) editableParameters.get(currentParameter);

            if ((currentUnauthorizedValues.length == 1)
                    && (currentUnauthorizedValues[0].equals(HDIV_EDITABLE_PASSWORD_ERROR))) {

                errors.rejectValue(currentParameter, HDIV_EDITABLE_PASSWORD_ERROR);

            } else {
                String printedValue = this.createMessageError(currentUnauthorizedValues);
                errors.rejectValue(currentParameter, HDIV_EDITABLE_ERROR, new String[] { printedValue },
                        printedValue + " has not allowed characters");
            }
        }
    }
}

From source file:org.hdiv.web.validator.AbstractEditableParameterValidator.java

/**
 * Obtains the errors from request detected by HDIV during the validation process of the editable parameters.
 * /*from w w w . j  a  v a2s. c om*/
 * @param errors
 *            errors detected by HDIV during the validation process of the editable parameters.
 */
@SuppressWarnings("unchecked")
protected void validateEditableParameters(Errors errors) {

    RequestAttributes attr = RequestContextHolder.getRequestAttributes();
    if (attr == null) {
        // This is not a web request
        return;
    }

    Hashtable<String, String[]> parameters = (Hashtable<String, String[]>) attr
            .getAttribute(Constants.EDITABLE_PARAMETER_ERROR, 0);
    if (parameters != null && parameters.size() > 0) {

        for (String param : parameters.keySet()) {

            String[] unauthorizedValues = parameters.get(param);

            this.rejectParamValues(param, unauthorizedValues, errors);
        }
    }
}

From source file:com.talkdesk.geo.GeoCodeResolver.java

/**
 * Get the minimum distance//from w w  w . j  a va  2  s  . c o m
 * @param numberList
 * @return
 * @throws GeoResolverException
 */
public String getClosestNumber(Hashtable<String, Double> numberList) throws GeoResolverException {
    String closest = "";
    Double lowestDistance = Double.MAX_VALUE;

    for (String key : numberList.keySet()) {
        Double currentDistance = numberList.get(key);
        if (currentDistance < lowestDistance) {
            lowestDistance = currentDistance;
            closest = key;
        }
    }
    return !closest.isEmpty() ? getTownFromNumber(closest) + " - " + closest : null;
}

From source file:org.apache.axis.providers.BasicProvider.java

public QName[] getOperationQNames() {
    Hashtable operations = (Hashtable) getOption("Operations");
    if (operations == null)
        return null;
    Object[] keys = operations.keySet().toArray();
    QName[] qnames = new QName[keys.length];
    System.arraycopy(keys, 0, qnames, 0, keys.length);
    return qnames;
}