Example usage for java.util HashMap clear

List of usage examples for java.util HashMap clear

Introduction

In this page you can find the example usage for java.util HashMap clear.

Prototype

public void clear() 

Source Link

Document

Removes all of the mappings from this map.

Usage

From source file:configuration.Util.java

public static void dictsReset(ArrayList<HashMap> listDicts, HashMap<JCheckBox, JSpinner> DictBoxSpinner,
        HashMap<JCheckBox, JTextField> DictBoxTextField, HashMap<JCheckBox, JComboBox> DictBoxComboBox,
        HashMap<JRadioButton, JSpinner> DictRadioButtonSpinner,
        HashMap<JRadioButton, JTextField> DictRadioButtonTextField) {
    DictBoxSpinner.clear();
    DictBoxTextField.clear();/*  w  ww.j  a v a  2s.  c om*/
    DictBoxComboBox.clear();
    DictRadioButtonSpinner.clear();
    DictRadioButtonTextField.clear();

    listDicts.clear();
    listDicts.add(DictBoxSpinner);
    listDicts.add(DictBoxTextField);
    listDicts.add(DictBoxComboBox);
    listDicts.add(DictRadioButtonSpinner);
    listDicts.add(DictRadioButtonTextField);
}

From source file:fr.paris.lutece.plugins.calendar.service.AgendaSubscriberService.java

/**
 * Send an event to a list of subscribers
 * @param request the http request//from  ww  w .java 2 s .c  om
 * @param listSubscribers a Collection<CalendarSubscriber>
 * @param event the event
 * @param nCalendarId The id of the calendar
 */
public void sendSubscriberMail(HttpServletRequest request, Collection<CalendarSubscriber> listSubscribers,
        Event event, int nCalendarId) {
    String strUnsubscribelink = AppPropertiesService.getProperty(PROPERTY_UNSUBSCRIBE_LINK);
    String strSenderName = AppPropertiesService.getProperty(PROPERTY_SENDER_NAME);
    String strSenderEmail = AppPropertiesService.getProperty(PROPERTY_SENDER_EMAIL);
    String strContent = I18nService.getLocalizedString(PROPERTY_EMAIL_SUBSCRIBER_CONTENT, request.getLocale());
    String strObject = I18nService.getLocalizedString(PROPERTY_EMAIL_SUBSCRIBER_OBJECT, request.getLocale());

    String strBaseUrl = AppPathService.getBaseUrl(request);

    HashMap<String, Object> emailModel = new HashMap<String, Object>();

    for (CalendarSubscriber subscriber : listSubscribers) {
        emailModel.put(MARK_UNSUBSCRIBE_LINK, strUnsubscribelink);
        emailModel.put(MARK_EMAIL_CONTENT, strContent);
        emailModel.put(MARK_BASE_URL, strBaseUrl);
        emailModel.put(MARK_EVENT, event);
        emailModel.put(Constants.MARK_CALENDAR_ID, nCalendarId);
        emailModel.put(Constants.MARK_EVENT_ID, event.getId());
        emailModel.put(MARK_SUBSCRIBER_EMAIL, subscriber.getEmail());
        emailModel.put(Constants.PARAMETER_ACTION, Constants.ACTION_SHOW_RESULT);

        HtmlTemplate templateAgenda = AppTemplateService.getTemplate(TEMPLATE_SEND_NOTIFICATION_MAIL,
                request.getLocale(), emailModel);
        String strNewsLetterCode = templateAgenda.getHtml();

        MailService.sendMailHtml(subscriber.getEmail(), strSenderName, strSenderEmail, strObject,
                strNewsLetterCode);
        emailModel.clear();
    }
}

From source file:com.intuit.wasabi.api.pagination.filters.PaginationFilterTest.java

@Test
public void testTestFields() throws Exception {
    TestObjectFilter objectFilter = new TestObjectFilter();

    HashMap<String, Boolean> testCases = new HashMap<>();
    testCases.put("", true);
    testCases.put(null, true);/*from w w  w. j  av a 2  s. co m*/
    testCases.put("hash=34", true);
    testCases.put("hash=23,string=match", true);
    testCases.put("hash=no match", false);
    testCases.put("hash=23,string=no match", false);
    testCases.put("hash=no match,string=match", false);
    testCases.put("hash=no match,string=no match", false);
    testCases.put("hash=no match,moreKeys=values", false); // since we fail fast, this does not throw!

    for (Map.Entry<String, Boolean> testCase : testCases.entrySet()) {
        objectFilter.replaceFilter(testCase.getKey(), "");
        try {
            Assert.assertEquals("Case handled incorrectly: " + testCase.getKey(), testCase.getValue(),
                    objectFilter.testFields(testObject, TestObjectFilter.Property.class));
        } catch (Exception exception) {
            Assert.fail("Failed due to exception: " + exception.getMessage() + " - Test was: "
                    + testCase.getKey() + " -> " + testCase.getValue());
        }
    }

    testCases.clear();
    testCases.put("moreKeys=values,hash=no match", false);
    testCases.put("hash=23,moreKeys=values", false);
    testCases.put("moreKeys=values,hash=23", false);

    for (Map.Entry<String, Boolean> testCase : testCases.entrySet()) {
        objectFilter.replaceFilter(testCase.getKey(), "");
        try {
            objectFilter.testFields(testObject, TestObjectFilter.Property.class);
            Assert.fail("Failed, no exception was thrown - Test was: " + testCase.getKey() + " -> "
                    + testCase.getValue());
        } catch (PaginationException ignored) {
            // this should happen
        } catch (Exception exception) {
            Assert.fail("Failed due to wrong exception: " + exception.getClass() + " = Test was: "
                    + testCase.getKey() + " -> " + testCase.getValue());
        }
    }
}

From source file:org.openhab.ui.cometvisu.internal.config.ConfigHelper.java

/**
 * add some basic stylings// w  ww  .j  a  v a 2s  . com
 */
private void initBasicStylings() {
    StylingEntry styling = new StylingEntry();
    styling.setName("RedGreen");
    HashMap<String, String> map = new HashMap<String, String>();
    map.put("0", "red");
    map.put("1", "green");
    for (String value : map.keySet()) {
        Entry entry = new Entry();
        entry.setValue(value);
        entry.getContent().add(map.get(value));
        styling.getEntry().add(entry);
    }
    addToStylings(styling);

    styling = new StylingEntry();
    styling.setName("GreyGreen");
    map.clear();
    map.put("0", "grey");
    map.put("1", "green");
    for (String value : map.keySet()) {
        Entry entry = new Entry();
        entry.setValue(value);
        entry.getContent().add(map.get(value));
        styling.getEntry().add(entry);
    }
    addToStylings(styling);

    styling = new StylingEntry();
    styling.setName("GreenGrey");
    map.clear();
    map.put("0", "green");
    map.put("1", "grey");
    for (String value : map.keySet()) {
        Entry entry = new Entry();
        entry.setValue(value);
        entry.getContent().add(map.get(value));
        styling.getEntry().add(entry);
    }
    addToStylings(styling);
}

From source file:org.rhq.enterprise.gui.installer.server.servlet.ServerInstallUtil.java

private static void createNewDatasources_Oracle(ModelControllerClient mcc) throws Exception {
    final HashMap<String, String> props = new HashMap<String, String>(2);
    final DatasourceJBossASClient client = new DatasourceJBossASClient(mcc);

    ModelNode noTxDsRequest = null;//w  ww .j a v  a  2 s.c o  m
    ModelNode xaDsRequest = null;

    if (!client.isDatasource(RHQ_DATASOURCE_NAME_NOTX)) {
        props.put("char.encoding", "UTF-8");
        props.put("SetBigStringTryClob", "true");

        noTxDsRequest = client.createNewDatasourceRequest(RHQ_DATASOURCE_NAME_NOTX, 30000,
                "${rhq.server.database.connection-url:jdbc:oracle:thin:@127.0.0.1:1521:rhq}",
                JDBC_DRIVER_ORACLE, "org.jboss.jca.adapters.jdbc.extensions.oracle.OracleExceptionSorter", 15,
                false, 2, 5, 75, RHQ_DS_SECURITY_DOMAIN,
                "org.jboss.jca.adapters.jdbc.extensions.oracle.OracleStaleConnectionChecker",
                "TRANSACTION_READ_COMMITTED",
                "org.jboss.jca.adapters.jdbc.extensions.oracle.OracleValidConnectionChecker", props);
    } else {
        LOG.info("Oracle datasource [" + RHQ_DATASOURCE_NAME_NOTX + "] already exists");
    }

    if (!client.isDatasource(RHQ_DATASOURCE_NAME_XA)) {
        props.clear();
        props.put("URL", "${rhq.server.database.connection-url:jdbc:oracle:thin:@127.0.0.1:1521:rhq}");
        props.put("ConnectionProperties", "SetBigStringTryClob=true");

        xaDsRequest = client.createNewXADatasourceRequest(RHQ_DATASOURCE_NAME_XA, 30000, JDBC_DRIVER_ORACLE,
                "org.jboss.jca.adapters.jdbc.extensions.oracle.OracleExceptionSorter", 15, 5, 50, 75,
                RHQ_DS_SECURITY_DOMAIN,
                "org.jboss.jca.adapters.jdbc.extensions.oracle.OracleStaleConnectionChecker",
                "TRANSACTION_READ_COMMITTED",
                "org.jboss.jca.adapters.jdbc.extensions.oracle.OracleValidConnectionChecker", props);
    } else {
        LOG.info("Oracle XA datasource [" + RHQ_DATASOURCE_NAME_XA + "] already exists");
    }

    if (noTxDsRequest != null || xaDsRequest != null) {
        ModelNode batch = DatasourceJBossASClient.createBatchRequest(noTxDsRequest, xaDsRequest);
        ModelNode results = client.execute(batch);
        if (!DatasourceJBossASClient.isSuccess(results)) {
            throw new FailureException(results, "Failed to create Oracle datasources");
        }
    }
}

From source file:com.sec.ose.osi.localdb.identification.IdentificationDBManager.java

synchronized public static HashMap<Integer, ArrayList<String>> loadIdentifiedFilesInfoToMemory(
        String projectName) {//from  www  . j  av  a 2s .  co m
    HashMap<Integer, ArrayList<String>> hmIdentifiedFiles = new HashMap<Integer, ArrayList<String>>();
    //   key: match type,    value: each match type's identified file list

    ArrayList<String> alSSIdentifiedFiles = new ArrayList<String>();
    ArrayList<String> alCMIdentifiedFiles = new ArrayList<String>();
    ArrayList<String> alPMIdentifiedFiles = new ArrayList<String>();
    String table = "";
    ResultSet rs = null;

    hmIdentifiedFiles.clear();

    try {
        if (projectName == null || ProjectAPIWrapper.getProjectID(projectName) == null) {
            return hmIdentifiedFiles;
        }
        log.debug("@@@ save identified files to memory... start...");
        table = "stringsearch_" + ProjectAPIWrapper.getProjectID(projectName).replace("-", "_");
        rs = IdentificationDBManager.selectSQL("select distinct(path) from " + table
                + " where path not in (select distinct(path) from " + table + " where status='0');");
        while (rs.next()) {
            alSSIdentifiedFiles.add(rs.getString(1));
        }
        hmIdentifiedFiles.put(IdentificationConstantValue.STRING_MATCH_TYPE, alSSIdentifiedFiles);
        rs.close();

        table = "codematch_" + ProjectAPIWrapper.getProjectID(projectName).replace("-", "_");
        rs = IdentificationDBManager.selectSQL("select distinct(path) from " + table
                + " where path not in (select distinct(path) from " + table + " where status='0');");
        while (rs.next()) {
            alCMIdentifiedFiles.add(rs.getString(1));
        }
        hmIdentifiedFiles.put(IdentificationConstantValue.CODE_MATCH_TYPE, alCMIdentifiedFiles);
        if (rs != null) {
            rs.close();
        }

        table = "patternmatch_" + ProjectAPIWrapper.getProjectID(projectName).replace("-", "_");
        rs = IdentificationDBManager.selectSQL("select distinct(path) from " + table
                + " where path not in (select distinct(path) from " + table + " where status='0');");
        while (rs.next()) {
            alPMIdentifiedFiles.add(rs.getString(1));
        }
        hmIdentifiedFiles.put(IdentificationConstantValue.PATTERN_MATCH_TYPE, alPMIdentifiedFiles);
        if (rs != null) {
            rs.close();
        }

        log.debug("@@@ save identified files to memory... end...");

        return hmIdentifiedFiles;
    } catch (SQLException e1) {
        log.warn(e1);
        return null;
    } finally {
        if (rs != null) {
            try {
                rs.close();
            } catch (SQLException e) {
                log.debug(e);
            }
        }
    }
}

From source file:com.android.talkback.SpeechController.java

private boolean processNextFragmentInternal() {
    if (mCurrentFragmentIterator == null || !mCurrentFragmentIterator.hasNext()) {
        return false;
    }//  w  w  w . ja  v  a  2 s  .  com

    FeedbackFragment fragment = mCurrentFragmentIterator.next();
    playEarconsFromFragment(fragment);
    playHapticsFromFragment(fragment);

    // Reuse the global instance of speech parameters.
    final HashMap<String, String> params = mSpeechParametersMap;
    params.clear();

    // Add all custom speech parameters.
    final Bundle speechParams = fragment.getSpeechParams();
    for (String key : speechParams.keySet()) {
        params.put(key, String.valueOf(speechParams.get(key)));
    }

    // Utterance ID, stream, and volume override item params.
    params.put(Engine.KEY_PARAM_UTTERANCE_ID, mCurrentFeedbackItem.getUtteranceId());
    params.put(Engine.KEY_PARAM_STREAM, String.valueOf(DEFAULT_STREAM));
    params.put(Engine.KEY_PARAM_VOLUME, String.valueOf(mSpeechVolume));

    final float pitch = mSpeechPitch * (mUseIntonation ? parseFloatParam(params, SpeechParam.PITCH, 1) : 1);
    final float rate = mSpeechRate * (mUseIntonation ? parseFloatParam(params, SpeechParam.RATE, 1) : 1);
    final CharSequence text;
    if (shouldSilenceSpeech(mCurrentFeedbackItem) || TextUtils.isEmpty(fragment.getText())) {
        text = null;
    } else {
        text = fragment.getText();
    }

    String logText = text == null ? null : text.toString();
    LogUtils.log(this, Log.VERBOSE, "Speaking fragment text \"%s\"", logText);

    mVoiceRecognitionChecker.onUtteranceStart();

    // It's okay if the utterance is empty, the fail-over TTS will
    // immediately call the fragment completion listener. This process is
    // important for things like continuous reading.
    mFailoverTts.speak(text, pitch, rate, params, DEFAULT_STREAM, mSpeechVolume);

    if (mTtsOverlay != null) {
        mTtsOverlay.speak(text);
    }

    return true;
}

From source file:fr.gouv.culture.vitam.digest.DigestCompute.java

public static int createDigest(File src, File dst, File ftar, File fglobal, boolean oneDigestPerFile,
        String[] extensions, String mask, boolean prefix) {
    if (mask == null) {
        return createDigest(src, dst, ftar, fglobal, oneDigestPerFile, extensions);
    }//from w ww.ja v  a  2s.c o  m
    try {
        if (prefix) {
            // fix mask
            List<File> filesToScan = new ArrayList<File>();
            File dirToSearch = src;
            if (!dirToSearch.isDirectory()) {
                if (dirToSearch.canRead() && dirToSearch.getName().startsWith(mask)) {
                    filesToScan.add(dirToSearch);
                } else {
                    throw new CommandExecutionException("Resources not found");
                }
            } else {
                Collection<File> temp = FileUtils.listFiles(dirToSearch, extensions,
                        StaticValues.config.argument.recursive);
                for (File file : temp) {
                    if (file.getName().startsWith(mask)) {
                        filesToScan.add(file);
                    }
                }
                temp.clear();
            }
            return createDigest(src, dst, ftar, fglobal, oneDigestPerFile, filesToScan);
        } else {
            // RegEx mask
            File dirToSearch = src;
            if (!dirToSearch.isDirectory()) {
                List<File> filesToScan = new ArrayList<File>();
                if (dirToSearch.canRead() && dirToSearch.getName().matches(mask + ".*")) {
                    filesToScan.add(dirToSearch);
                    String global = dirToSearch.getName().replaceAll("[^" + mask + "].*", "")
                            + "_all_digests.xml";
                    fglobal = new File(fglobal, global);
                } else {
                    throw new CommandExecutionException("Resources not found");
                }
                return createDigest(src, dst, ftar, fglobal, oneDigestPerFile, filesToScan);
            } else {
                HashMap<String, List<File>> hashmap = new HashMap<String, List<File>>();
                Collection<File> temp = FileUtils.listFiles(dirToSearch, extensions,
                        StaticValues.config.argument.recursive);
                List<File> filesToScan = null;
                Pattern pattern = Pattern.compile(mask + ".*");
                Pattern pattern2 = Pattern.compile(mask);
                for (File file : temp) {
                    String filename = file.getName();
                    Matcher matcher = pattern.matcher(filename);
                    if (matcher.matches()) {
                        String end = pattern2.matcher(filename).replaceFirst("");
                        int pos = filename.indexOf(end);
                        if (pos <= 0) {
                            System.err.println("Cannot find : " + end + " in " + filename);
                            continue;
                        }
                        String global = filename.substring(0, pos);
                        if (global.charAt(global.length() - 1) != '_') {
                            global += "_";
                        }
                        global += "all_digests.xml";
                        filesToScan = hashmap.get(global);
                        if (filesToScan == null) {
                            filesToScan = new ArrayList<File>();
                            hashmap.put(global, filesToScan);
                        }
                        filesToScan.add(file);
                    }
                }
                temp.clear();
                int res = 0;
                for (String global : hashmap.keySet()) {
                    File fglobalnew = new File(fglobal, global);
                    res += createDigest(src, dst, ftar, fglobalnew, oneDigestPerFile, hashmap.get(global));
                }
                hashmap.clear();
                return res;
            }
        }
    } catch (CommandExecutionException e1) {
        System.err.println(StaticValues.LBL.error_error.get() + " " + e1.toString());
        return -1;
    }
}

From source file:com.krawler.spring.importFunctionality.ImportUtil.java

/**
 * @param moduleId//from  w w  w  .j  av  a2 s.  co  m
 * @param companyid
 * @param importDao
 * @return
 * @throws ServiceException
 */
public static JSONArray getModuleColumnConfig(String moduleId, String companyid,
        fieldManagerDAO fieldManagerDAOobj) throws ServiceException {
    JSONArray jArr = new JSONArray();
    HashMap<String, Object> requestParams = new HashMap<String, Object>();
    requestParams.put("filter_names", Arrays.asList("dh.Module.id", "dh.allowImport"));
    requestParams.put("filter_values", Arrays.asList(moduleId, true));
    KwlReturnObject kmsg = fieldManagerDAOobj.getDefaultHeader(requestParams);

    try {
        Iterator itr = kmsg.getEntityList().iterator();
        while (itr.hasNext()) {
            DefaultHeader obj = (DefaultHeader) itr.next();
            requestParams.clear();
            requestParams.put("filter_names", Arrays.asList("c.defaultheader.id", "c.company.companyID"));
            requestParams.put("filter_param", Arrays.asList(obj.getId(), companyid));
            kmsg = fieldManagerDAOobj.getColumnHeader(requestParams);
            Iterator ite1 = kmsg.getEntityList().iterator();
            if (ite1.hasNext()) {
                ColumnHeader obj1 = (ColumnHeader) ite1.next();
                JSONObject jtemp = getObject(obj);
                jtemp.put("columnName",
                        StringUtil.isNullOrEmpty(obj1.getNewHeader())
                                ? obj1.getDefaultheader().getDefaultHeader()
                                : obj1.getNewHeader());
                jtemp.put("isMandatory", obj1.isMandotory());
                jArr.put(jtemp);
            } else if (!obj.isCustomflag()) {
                JSONObject jtemp = getObject(obj);
                jArr.put(jtemp);
            }
        }

    } catch (JSONException ex) {
        Logger.getLogger(ImportHandler.class.getName()).log(Level.SEVERE, null, ex);
    }
    return jArr;
}

From source file:org.rhq.enterprise.gui.installer.server.servlet.ServerInstallUtil.java

private static void createNewDatasources_Postgres(ModelControllerClient mcc) throws Exception {
    final HashMap<String, String> props = new HashMap<String, String>(4);
    final DatasourceJBossASClient client = new DatasourceJBossASClient(mcc);

    ModelNode noTxDsRequest = null;//from w w w .j  a  v  a  2 s . c o m
    ModelNode xaDsRequest = null;

    if (!client.isDatasource(RHQ_DATASOURCE_NAME_NOTX)) {
        props.put("char.encoding", "UTF-8");

        noTxDsRequest = client.createNewDatasourceRequest(RHQ_DATASOURCE_NAME_NOTX, 30000,
                "${rhq.server.database.connection-url:jdbc:postgres://127.0.0.1:5432/rhq}",
                JDBC_DRIVER_POSTGRES,
                "org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLExceptionSorter", 15, false, 2, 5,
                75, RHQ_DS_SECURITY_DOMAIN, "-unused-stale-conn-checker-", "TRANSACTION_READ_COMMITTED",
                "org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLValidConnectionChecker", props);
        noTxDsRequest.get("steps").get(0).remove("stale-connection-checker-class-name"); // we don't have one of these for postgres
    } else {
        LOG.info("Postgres datasource [" + RHQ_DATASOURCE_NAME_NOTX + "] already exists");
    }

    if (!client.isXADatasource(RHQ_DATASOURCE_NAME_XA)) {
        props.clear();
        props.put("ServerName", "${rhq.server.database.server-name:127.0.0.1}");
        props.put("PortNumber", "${rhq.server.database.port:5432}");
        props.put("DatabaseName", "${rhq.server.database.db-name:rhq}");

        xaDsRequest = client.createNewXADatasourceRequest(RHQ_DATASOURCE_NAME_XA, 30000, JDBC_DRIVER_POSTGRES,
                "org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLExceptionSorter", 15, 5, 50, 75,
                RHQ_DS_SECURITY_DOMAIN, "-unused-stale-conn-checker-", "TRANSACTION_READ_COMMITTED",
                "org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLValidConnectionChecker", props);
        xaDsRequest.get("steps").get(0).remove("stale-connection-checker-class-name"); // we don't have one of these for postgres
    } else {
        LOG.info("Postgres XA datasource [" + RHQ_DATASOURCE_NAME_XA + "] already exists");
    }

    if (noTxDsRequest != null || xaDsRequest != null) {
        ModelNode batch = DatasourceJBossASClient.createBatchRequest(noTxDsRequest, xaDsRequest);
        ModelNode results = client.execute(batch);
        if (!DatasourceJBossASClient.isSuccess(results)) {
            throw new FailureException(results, "Failed to create Postgres datasources");
        }
    }
}