Example usage for java.util Collections EMPTY_MAP

List of usage examples for java.util Collections EMPTY_MAP

Introduction

In this page you can find the example usage for java.util Collections EMPTY_MAP.

Prototype

Map EMPTY_MAP

To view the source code for java.util Collections EMPTY_MAP.

Click Source Link

Document

The empty map (immutable).

Usage

From source file:fr.inria.atlanmod.neoemf.map.datastore.MapPersistenceBackendFactoryTest.java

@Test
public void testCreatePersistentEStoreDirectWriteWithListsOption() throws InvalidDataStoreException,
        NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
    storeOptions.add(MapResourceOptions.EStoreMapOption.DIRECT_WRITE_WITH_LISTS);
    PersistenceBackend persistentBackend = persistenceBackendFactory.createPersistentBackend(testFile,
            Collections.EMPTY_MAP);
    SearcheableResourceEStore eStore = persistenceBackendFactory.createPersistentEStore(null, persistentBackend,
            options);//  w ww. j  a va 2s  .c o m
    assert eStore instanceof DirectWriteMapResourceWithListsEStoreImpl : "Invalid EStore created";
    PersistenceBackend innerBackend = getInnerBackend((DirectWriteMapResourceWithListsEStoreImpl) eStore);
    assert innerBackend == persistentBackend : "The backend in the EStore is not the created one";
}

From source file:org.ajax4jsf.webapp.BaseFilter.java

private Map<String, String> parseQueryString(String queryString) {
    if (queryString != null) {
        Map<String, String> parameters = new HashMap<String, String>();

        String[] nvPairs = AMPERSAND.split(queryString);
        for (String nvPair : nvPairs) {
            if (nvPair.length() == 0) {
                continue;
            }/*from   w w w .  jav a 2  s. com*/

            int eqIdx = nvPair.indexOf('=');
            if (eqIdx >= 0) {
                try {
                    String name = URLDecoder.decode(nvPair.substring(0, eqIdx), "UTF-8");
                    if (!parameters.containsKey(name)) {
                        String value = URLDecoder.decode(nvPair.substring(eqIdx + 1), "UTF-8");

                        parameters.put(name, value);
                    }
                } catch (UnsupportedEncodingException e) {
                    //log warning and skip this parameter
                    log.warn(e.getLocalizedMessage(), e);
                }
            }
        }

        return parameters;
    } else {

        return Collections.EMPTY_MAP;
    }
}

From source file:de.hybris.platform.configurablebundleservices.bundle.impl.DefaultBundleCommerceCartServiceIntegrationTest.java

@Override
@Before//from   w  w  w . j  a  va 2 s.  com
public void setUp() throws Exception {
    // final Create data for tests
    LOG.info("Creating data for DefaultBundleCommerceCartServiceIntegrationTest ...");
    userService.setCurrentUser(userService.getAdminUser());
    final long startTime = System.currentTimeMillis();
    new CoreBasicDataCreator().createEssentialData(Collections.EMPTY_MAP, null);

    // importing test csv
    final String legacyModeBackup = Config.getParameter(ImpExConstants.Params.LEGACY_MODE_KEY);
    LOG.info("Existing value for " + ImpExConstants.Params.LEGACY_MODE_KEY + " :" + legacyModeBackup);
    Config.setParameter(ImpExConstants.Params.LEGACY_MODE_KEY, "true");
    importCsv("/commerceservices/test/testCommerceCart.csv", "utf-8");
    Config.setParameter(ImpExConstants.Params.LEGACY_MODE_KEY, "false");
    importCsv("/subscriptionservices/test/testSubscriptionCommerceCartService.impex", "utf-8");
    importCsv("/configurablebundleservices/test/testBundleCommerceCartService.impex", "utf-8");
    importCsv("/configurablebundleservices/test/testApproveAllBundleTemplates.impex", "utf-8");
    Config.setParameter(ImpExConstants.Params.LEGACY_MODE_KEY, legacyModeBackup);

    LOG.info("Finished data for DefaultBundleCommerceCartServiceIntegrationTest "
            + (System.currentTimeMillis() - startTime) + "ms");

    baseSiteService.setCurrentBaseSite(baseSiteService.getBaseSiteForUID(TEST_BASESITE_UID), false);
    catalogVersionService.setSessionCatalogVersion("testCatalog", "Online");

    setupProducts();
    setupBundleTemplates();
    unitModel = productModelGalaxyNexus.getUnit();
    final UserModel telco = userService.getUserForUID("telco");
    final Collection<CartModel> cartModels = telco.getCarts();
    assertEquals(1, cartModels.size());
    telcoMasterCart = cartModels.iterator().next();

    modelService.detachAll();
}

From source file:org.apache.geode.management.internal.cli.commands.ConfigCommandsDUnitTest.java

@Test
public void testDescribeConfig() throws Exception {
    setUpJmxManagerOnVm0ThenConnect(null);
    final String controllerName = "Member2";

    /*//from w  w  w  .j  ava  2s.c  o m
     * Create properties for the controller VM
     */
    final Properties localProps = new Properties();
    localProps.setProperty(MCAST_PORT, "0");
    localProps.setProperty(LOG_LEVEL, "info");
    localProps.setProperty(STATISTIC_SAMPLING_ENABLED, "true");
    localProps.setProperty(ENABLE_TIME_STATISTICS, "true");
    localProps.setProperty(NAME, controllerName);
    localProps.setProperty(GROUPS, "G1");
    getSystem(localProps);
    Cache cache = getCache();

    int ports[] = getRandomAvailableTCPPorts(1);
    CacheServer cs = getCache().addCacheServer();
    cs.setPort(ports[0]);
    cs.setMaxThreads(10);
    cs.setMaxConnections(9);
    cs.start();
    try {

        RuntimeMXBean runtimeBean = ManagementFactory.getRuntimeMXBean();
        List<String> jvmArgs = runtimeBean.getInputArguments();

        getLogWriter().info("#SB Actual JVM Args : ");

        for (String jvmArg : jvmArgs) {
            getLogWriter().info("#SB JVM " + jvmArg);
        }

        InternalDistributedSystem system = (InternalDistributedSystem) cache.getDistributedSystem();
        DistributionConfig config = system.getConfig();
        config.setArchiveFileSizeLimit(1000);

        String command = CliStrings.DESCRIBE_CONFIG + " --member=" + controllerName;
        CommandProcessor cmdProcessor = new CommandProcessor();
        cmdProcessor.createCommandStatement(command, Collections.EMPTY_MAP).process();

        CommandResult cmdResult = executeCommand(command);

        String resultStr = commandResultToString(cmdResult);
        getLogWriter().info("#SB Hiding the defaults\n" + resultStr);

        assertEquals(true, cmdResult.getStatus().equals(Status.OK));
        assertEquals(true, resultStr.contains("G1"));
        assertEquals(true, resultStr.contains(controllerName));
        assertEquals(true, resultStr.contains(ARCHIVE_FILE_SIZE_LIMIT));
        assertEquals(true, !resultStr.contains("copy-on-read"));

        cmdResult = executeCommand(command + " --" + CliStrings.DESCRIBE_CONFIG__HIDE__DEFAULTS + "=false");
        resultStr = commandResultToString(cmdResult);

        getLogWriter().info("#SB No hiding of defaults\n" + resultStr);

        assertEquals(true, cmdResult.getStatus().equals(Status.OK));
        assertEquals(true, resultStr.contains("is-server"));
        assertEquals(true, resultStr.contains(controllerName));
        assertEquals(true, resultStr.contains("copy-on-read"));

    } finally {
        cs.stop();
    }
}

From source file:org.eclipse.wst.xsl.jaxp.debug.invoker.internal.JAXPSAXProcessorInvoker.java

/**
 * Transform using an InputSource rather than a URL
 * /*  www.  ja v a 2 s .  c  om*/
 * @param inputsource the InputSource to use
 * @param res the Result
 * @throws TransformationException if an error occurred during transformation
 */
public void transform(InputSource inputsource, Result res) throws TransformationException {
    try {
        if (th == null) {// no stylesheets have been added, so try to use embedded...
            SAXSource saxSource = new SAXSource(inputsource);
            Source src = saxSource;
            String media = null, title = null, charset = null;
            src = tFactory.getAssociatedStylesheet(src, media, title, charset);
            if (src != null) {
                addStylesheet(src, null, Collections.EMPTY_MAP, new Properties());
            } else {
                throw new TransformationException(
                        Messages.getString("JAXPSAXProcessorInvoker.7") + inputsource.getSystemId()); //$NON-NLS-1$
            }
        }
        th.setResult(res);
        log.info(Messages.getString("JAXPSAXProcessorInvoker.8")); //$NON-NLS-1$
        reader.parse(inputsource);
        log.info(Messages.getString("JAXPSAXProcessorInvoker.9")); //$NON-NLS-1$
    } catch (Exception e) {
        throw new TransformationException(e.getMessage(), e);
    }
}

From source file:de.hybris.platform.cissubscriptionatddtests.keywords.CisSubscriptionKeywordLibrary.java

public void createDefaultPaymentMethod() {
    try {/*  ww w .  j a v a 2  s.  c  o  m*/
        final SubscriptionPaymentData initResult = subscriptionFacade.initializeTransaction("127.0.0.1",
                "http://localhost:9090", "http://localhost:9090", Collections.EMPTY_MAP);

        final Map<String, String> paymentParameters = new HashMap<>();

        paymentParameters.put("cardNumber", "************1234");
        paymentParameters.put("cardType", "visa");
        paymentParameters.put("expiryMonth", "10");
        paymentParameters.put("expiryYear", "2030");
        paymentParameters.put("issueNumber", null);
        paymentParameters.put("nameOnCard", "John Doe");
        paymentParameters.put("startMonth", null);
        paymentParameters.put("startYear", null);
        paymentParameters.put("billingAddress_countryIso", "US");
        paymentParameters.put("billingAddress_firstName", "John");
        paymentParameters.put("billingAddress_lastName", "Doe");
        paymentParameters.put("billingAddress_line1", "Default Street 1");
        paymentParameters.put("billingAddress_line2", StringUtils.EMPTY);
        paymentParameters.put("billingAddress_postcode", "12345");
        paymentParameters.put("billingAddress_townCity", "Default Town");

        final SubscriptionPaymentData finalizeResult = subscriptionFacade.finalizeTransaction("127.0.0.1",
                initResult.getParameters().get("sessionTransactionToken"), paymentParameters);

        final CCPaymentInfoData paymentInfo = subscriptionFacade
                .createPaymentSubscription(finalizeResult.getParameters());

        userFacade.setDefaultPaymentInfo(paymentInfo);
        checkoutFacade.setPaymentDetails(paymentInfo.getId());
    } catch (final SubscriptionFacadeException e) {
        LOG.error("Payment method creation failed", e);
        fail(e.getMessage());
    }
}

From source file:org.eclipse.php.internal.ui.actions.PHPToggleLineCommentHandler.java

/**
 * @see org.eclipse.wst.sse.ui.internal.handlers.AbstractCommentHandler#processAction(org.eclipse.ui.texteditor.ITextEditor,
 *      org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument,
 *      org.eclipse.jface.text.ITextSelection)
 *//*from   w  ww. ja va 2 s  .  c o m*/
protected void processAction(final ITextEditor textEditor, final IStructuredDocument document,
        ITextSelection textSelection) {

    IStructuredModel model = null;
    DocumentRewriteSession session = null;
    boolean changed = false;

    try {
        // TODO this will be remove soon,just to see if this method is
        // executed in Zend Studio.
        Logger.log(Logger.ERROR, "PHP Toggle Line Comment is starting."); //$NON-NLS-1$
        // get text selection lines info
        int selectionStartLine = textSelection.getStartLine();
        int selectionEndLine = textSelection.getEndLine();
        boolean isSingleLine = false;
        if (selectionStartLine == selectionEndLine) {
            isSingleLine = true;
        }

        int selectionEndLineOffset = document.getLineOffset(selectionEndLine);
        int selectionEndOffset = textSelection.getOffset() + textSelection.getLength();

        // adjust selection end line
        if ((selectionEndLine > selectionStartLine) && (selectionEndLineOffset == selectionEndOffset)) {
            selectionEndLine--;
            selectionEndLineOffset = document.getLineInformation(selectionEndLine).getOffset();
        }

        int selectionStartLineOffset = document.getLineOffset(selectionStartLine);
        if (selectionEndLineOffset == selectionStartLineOffset) {
            selectionEndLineOffset = document.getLineInformation(selectionEndLine).getOffset()
                    + document.getLineInformation(selectionEndLine).getLength();
        }
        ITypedRegion[] lineTypedRegions = document.computePartitioning(selectionStartLineOffset,
                selectionEndLineOffset - selectionStartLineOffset);
        if (lineTypedRegions != null && lineTypedRegions.length == 1
                && lineTypedRegions[0].getType().equals("org.eclipse.php.PHP_DEFAULT")) { //$NON-NLS-1$

            // save the selection position since it will be changing
            Position selectionPosition = null;
            selectionPosition = new Position(textSelection.getOffset(), textSelection.getLength());
            document.addPosition(selectionPosition);

            model = StructuredModelManager.getModelManager().getModelForEdit(document);
            if (model != null) {
                // makes it so one undo will undo all the edits to the
                // document
                model.beginRecording(this, SSEUIMessages.ToggleComment_label,
                        SSEUIMessages.ToggleComment_description);

                // keeps listeners from doing anything until updates are all
                // done
                model.aboutToChangeModel();
                if (document instanceof IDocumentExtension4) {
                    session = ((IDocumentExtension4) document)
                            .startRewriteSession(DocumentRewriteSessionType.UNRESTRICTED);
                }
                changed = true;

                // get the display for the editor if we can
                Display display = null;
                if (textEditor instanceof StructuredTextEditor) {
                    StructuredTextViewer viewer = ((StructuredTextEditor) textEditor).getTextViewer();
                    if (viewer != null) {
                        display = viewer.getControl().getDisplay();
                    }
                }

                // create the toggling operation
                IRunnableWithProgress toggleCommentsRunnable = new ToggleLinesRunnable(
                        model.getContentTypeIdentifier(), document, selectionStartLine, selectionEndLine,
                        display, isSingleLine);

                // if toggling lots of lines then use progress monitor else
                // just
                // run the operation
                if ((selectionEndLine - selectionStartLine) > TOGGLE_LINES_MAX_NO_BUSY_INDICATOR
                        && display != null) {
                    ProgressMonitorDialog dialog = new ProgressMonitorDialog(display.getActiveShell());
                    dialog.run(false, true, toggleCommentsRunnable);
                } else {
                    toggleCommentsRunnable.run(new NullProgressMonitor());
                }
            }
        } else {
            org.eclipse.core.expressions.EvaluationContext evaluationContext = new org.eclipse.core.expressions.EvaluationContext(
                    null, "") { //$NON-NLS-1$
                @Override
                public Object getVariable(String name) {
                    if (ISources.ACTIVE_EDITOR_NAME.equals(name)) {
                        return textEditor;
                    }
                    return null;
                }
            };
            org.eclipse.core.commands.ExecutionEvent executionEvent = new org.eclipse.core.commands.ExecutionEvent(
                    null, Collections.EMPTY_MAP, new Event(), evaluationContext);
            toggleLineCommentHandler.execute(executionEvent);
        }

    } catch (InvocationTargetException e) {
        Logger.logException("Problem running toggle comment progess dialog.", e); //$NON-NLS-1$
    } catch (InterruptedException e) {
        Logger.logException("Problem running toggle comment progess dialog.", e); //$NON-NLS-1$
    } catch (BadLocationException e) {
        Logger.logException("The given selection " + textSelection + " must be invalid", e); //$NON-NLS-1$ //$NON-NLS-2$
    } catch (ExecutionException e) {
    } finally {
        // clean everything up
        if (session != null && document instanceof IDocumentExtension4) {
            ((IDocumentExtension4) document).stopRewriteSession(session);
        }

        if (model != null) {
            model.endRecording(this);
            if (changed) {
                model.changedModel();
            }
            model.releaseFromEdit();
        }
    }
}

From source file:org.chiba.xml.xforms.CustomElementFactory.java

private static Map getCustomActionElementsConfig() {

    try {/*from  w w w .j a  v  a  2s  .  com*/
        Map elementClassNames = Config.getInstance().getCustomActionsElements();
        Map elementClassRefs = new HashMap(elementClassNames.size());

        Iterator itr = elementClassNames.entrySet().iterator();

        //converts class names into the class references
        while (itr.hasNext()) {

            Map.Entry entry = (Entry) itr.next();

            String key = (String) entry.getKey();
            String className = (String) entry.getValue();
            Class classRef = Class.forName(className);

            elementClassRefs.put(key, classRef);
        }

        //return the configuration
        return elementClassRefs;

    } catch (XFormsConfigException xfce) {
        LOGGER.error("could not load custom-elements config: " + xfce.getMessage());

    } catch (ClassNotFoundException cnfe) {
        LOGGER.error("class configured for custom-element not found: " + cnfe.getMessage());
    }

    //returns an empty map (no custom elements)
    return Collections.EMPTY_MAP;
}

From source file:com.idealista.solrmeter.view.statistic.CacheHistoryPanel.java

/**
 * Creates the controlers to select hit ratio or caches
 * @return/*from   ww w .  j  av a2s. com*/
 */
private List<Component> createControlPanel() {
    List<Component> components = new LinkedList<Component>();
    whatToShowBoxCache = new JComboBox();
    whatToShowBoxCache.addItem(I18n.get("statistic.cacheStatistic.showHitRatio"));
    whatToShowBoxCache.addItem(I18n.get("statistic.cacheStatistic.showSpecificData"));
    whatToShowBoxCache.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {
            setShowingSpecificData(!whatToShowBoxCache.getSelectedItem()
                    .equals(I18n.get("statistic.cacheStatistic.showHitRatio")));
            refreshView();
        }

    });
    components.add(whatToShowBoxCache);
    components.add(Box.createRigidArea(new Dimension(3, 3)));

    comboBoxCache = new JComboBox();
    comboBoxCache.addItem("documentCache");
    comboBoxCache.addItem("fieldValueCache");
    comboBoxCache.addItem("filterCache");
    comboBoxCache.addItem("queryResultCache");
    comboBoxCache.addActionListener(new ActionListener() {

        @SuppressWarnings("unchecked")
        @Override
        public void actionPerformed(ActionEvent arg0) {
            changeChartTitle("title" + comboBoxCache.getSelectedItem().toString());
            refreshSeries(Collections.EMPTY_MAP);
            refreshView();
        }

    });
    components.add(comboBoxCache);
    return components;
}

From source file:org.codehaus.groovy.grails.commons.GrailsDomainConfigurationUtil.java

/**
 * Retrieves the mappedBy map for the specified class.
 *
 * @param domainClass The domain class/*from   ww  w . j  a  va  2s.  com*/
 * @return The mappedBy map
 */
public static Map<?, ?> getMappedByMap(Class<?> domainClass) {
    ClassPropertyFetcher cpf = ClassPropertyFetcher.forClass(domainClass);

    Map<?, ?> mappedByMap = cpf.getPropertyValue(GrailsDomainClassProperty.MAPPED_BY, Map.class);
    if (mappedByMap == null) {
        return Collections.EMPTY_MAP;
    }
    return mappedByMap;
}