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:com.espertech.esper.epl.core.eval.EvalInsertNoWildcardSingleColCoercionRevisionBeanWrap.java

public EventBean processFirstCol(Object result) {
    EventBean wrappedEvent = super.getEventAdapterService().adapterForBean(result);
    return vaeProcessor.getValueAddEventBean(super.getEventAdapterService().adapterForTypedWrapper(wrappedEvent,
            Collections.EMPTY_MAP, vaeInnerEventType));
}

From source file:org.geotools.data.wfs.internal.v1_1.MapServerTest.java

private WFSDataStore getWFSDataStore(HTTPClient httpClient) throws IOException, ServiceException {
    URL capabilitiesUrl = new URL(
            "http://127.0.0.1:8888/mapserver?service=WFS&version=1.1.0&REQUEST=GetCapabilities");

    WFSDataStore wfs = new WFSDataStore(
            new WFSClient(capabilitiesUrl, httpClient, WFSConfig.fromParams(Collections.EMPTY_MAP)));

    return wfs;// w  w  w .ja  v  a2  s  . c  o  m
}

From source file:org.geoserver.wms.wms_1_1_1.GetLegendGraphicTest.java

@Override
protected void onSetUp(SystemTestData testData) throws Exception {
    super.onSetUp(testData);

    Catalog catalog = getCatalog();//  w ww. j  a  va 2 s  .  c  om
    testData.addStyle("paramFill", "paramFill.sld", getClass(), catalog);
    testData.addStyle("paramStroke", "paramStroke.sld", getClass(), catalog);
    testData.addStyle("raster", "raster.sld", getClass(), catalog);
    testData.addStyle("rasterScales", "rasterScales.sld", getClass(), catalog);
    testData.addStyle("Population", "Population.sld", getClass(), catalog);
    testData.addStyle("uom", "uomStroke.sld", getClass(), catalog);

    testData.addVectorLayer(new QName(MockData.SF_URI, "states", MockData.SF_PREFIX), Collections.EMPTY_MAP,
            "states.properties", getClass(), catalog);

    LegendInfo legend = new LegendInfoImpl();
    legend.setWidth(22);
    legend.setHeight(22);
    legend.setFormat("image/png");
    legend.setOnlineResource("legend.png");
    File file = getResourceLoader().createFile("styles", "legend.png");
    getResourceLoader().copyFromClassPath("../legend.png", file, getClass());
    testData.addStyle(null, "custom", "point_test.sld", getClass(), catalog, legend);
}

From source file:de.betterform.xml.xforms.CustomElementFactory.java

/**
 * Loads the configuration for custom elements.
 * /*from w w  w.j av a 2s  . co m*/
 * @return A Map where the keys are in the format namespace-uri:element-name
 *         and the value is the reference to the class that implements the
 *         custom element, or an empty map if the configuration could not be
 *         loaded for some reason.
 */
private static Map getCustomElementsConfig() {

    try {
        Map elementClassNames = Config.getInstance().getCustomElements();
        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, true, CustomElementFactory.class.getClassLoader());

            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.espertech.esper.epl.core.eval.EvalInsertNoWildcardSingleColCoercionRevisionMap.java

public EventBean processFirstCol(Object result) {
    EventBean wrappedEvent = super.getEventAdapterService().adapterForTypedMap((Map) result,
            super.getResultEventType());
    return vaeProcessor.getValueAddEventBean(super.getEventAdapterService().adapterForTypedWrapper(wrappedEvent,
            Collections.EMPTY_MAP, vaeInnerEventType));
}

From source file:org.geoserver.wfs.notification.TriggerFileWatcher.java

@Override
protected Map<QName, List<Trigger>> doLoad(URLConnection conn) {
    Triggers triggers = null;//from   www.jav a  2s. c o m
    InputStream inputStream = null;
    try {
        Unmarshaller unm = CTX.createUnmarshaller();
        try {
            unm.setProperty("com.sun.xml.bind.ObjectFactory", new ObjectFactoryEx());
        } catch (PropertyException pe) {
            try {
                unm.setProperty("com.sun.xml.internal.bind.ObjectFactory", new ObjectFactoryEx());
            } catch (PropertyException pe2) {

            }
        }
        inputStream = conn.getInputStream();
        triggers = unm.unmarshal(new StreamSource(inputStream), Triggers.class).getValue();
    } catch (JAXBException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        IOUtils.closeQuietly(inputStream);
    }

    if (triggers == null)
        return Collections.EMPTY_MAP;

    final HashMap<QName, List<Trigger>> map = new HashMap<QName, List<Trigger>>(triggers.getFeature().size());
    for (Feature f : triggers.getFeature())
        map.put(f.getType(), f.getTrigger());
    return Collections.unmodifiableMap(map);
}

From source file:com.epam.training.core.services.impl.DefaultCompatibilityServiceIntegrationTest.java

@Before
public void setUp() throws Exception {
    LOG.info("Creating data for DefaultCompatibilityServiceIntegrationTest ..");
    final long startTime = System.currentTimeMillis();
    new CoreBasicDataCreator().createEssentialData(Collections.EMPTY_MAP, null);
    importCsv("/test/impex/test_feature-compatibility.impex", "utf-8");
    LOG.info("Finished data for DefaultCompatibilityServiceIntegrationTest "
            + (System.currentTimeMillis() - startTime) + "ms");
}

From source file:com.espertech.esper.epl.core.eval.EvalInsertNoWildcardSingleColCoercionRevisionObjectArray.java

public EventBean processFirstCol(Object result) {
    EventBean wrappedEvent = super.getEventAdapterService().adapterForTypedObjectArray((Object[]) result,
            super.getResultEventType());
    return vaeProcessor.getValueAddEventBean(super.getEventAdapterService().adapterForTypedWrapper(wrappedEvent,
            Collections.EMPTY_MAP, vaeInnerEventType));
}

From source file:net.sf.commons.ssh.directory.Directory.java

@SuppressWarnings("unchecked")
Directory() {/*from  w w  w  .j  ava  2s  . c  om*/
    Map<String, Description> descriptions;
    Map<String, String> oldClassNames;

    try {
        descriptions = Collections.unmodifiableMap(load());
    } catch (Exception exc) {
        descriptions = Collections.EMPTY_MAP;

        log.error("Unable to load factories directory: " + exc.getMessage(), exc);
    }

    try {
        oldClassNames = Collections.unmodifiableMap(loadOldClassNames());
    } catch (Exception e) {
        oldClassNames = Collections.EMPTY_MAP;
        log.error("Unable to load old class names of factories: " + e.getMessage(), e);
    }

    this.descriptions = descriptions;
    this.oldClassNames = oldClassNames;
}

From source file:com.vuze.android.remote.rpc.RestJsonClient.java

public static Map<?, ?> connect(String id, String url, Map<?, ?> jsonPost, Header[] headers,
        UsernamePasswordCredentials creds, boolean sendGzip) throws RPCException {
    long readTime = 0;
    long connSetupTime = 0;
    long connTime = 0;
    int bytesRead = 0;
    if (DEBUG_DETAILED) {
        Log.d(TAG, id + "] Execute " + url);
    }//from   ww w .  ja  v a 2  s  . c om
    long now = System.currentTimeMillis();
    long then;

    Map<?, ?> json = Collections.EMPTY_MAP;

    try {

        URI uri = new URI(url);
        int port = uri.getPort();

        BasicHttpParams basicHttpParams = new BasicHttpParams();
        HttpProtocolParams.setUserAgent(basicHttpParams, "Vuze Android Remote");

        DefaultHttpClient httpclient;
        if ("https".equals(uri.getScheme())) {
            httpclient = MySSLSocketFactory.getNewHttpClient(port);
        } else {
            httpclient = new DefaultHttpClient(basicHttpParams);
        }

        //AndroidHttpClient.newInstance("Vuze Android Remote");

        // This doesn't set the "Authorization" header!?
        httpclient.getCredentialsProvider().setCredentials(new AuthScope(null, -1), creds);

        // Prepare a request object
        HttpRequestBase httpRequest = jsonPost == null ? new HttpGet(uri) : new HttpPost(uri); // IllegalArgumentException

        if (creds != null) {
            byte[] toEncode = (creds.getUserName() + ":" + creds.getPassword()).getBytes();
            String encoding = Base64Encode.encodeToString(toEncode, 0, toEncode.length);
            httpRequest.setHeader("Authorization", "Basic " + encoding);
        }

        if (jsonPost != null) {
            HttpPost post = (HttpPost) httpRequest;
            String postString = JSONUtils.encodeToJSON(jsonPost);
            if (AndroidUtils.DEBUG_RPC) {
                Log.d(TAG, id + "]  Post: " + postString);
            }

            AbstractHttpEntity entity = (sendGzip && Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO)
                    ? getCompressedEntity(postString)
                    : new StringEntity(postString);
            post.setEntity(entity);

            post.setHeader("Accept", "application/json");
            post.setHeader("Content-type", "application/x-www-form-urlencoded; charset=UTF-8");
        }

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO) {
            setupRequestFroyo(httpRequest);
        }

        if (headers != null) {
            for (Header header : headers) {
                httpRequest.setHeader(header);
            }
        }

        // Execute the request
        HttpResponse response;

        then = System.currentTimeMillis();
        if (AndroidUtils.DEBUG_RPC) {
            connSetupTime = (then - now);
            now = then;
        }

        httpclient.setHttpRequestRetryHandler(new HttpRequestRetryHandler() {
            @Override
            public boolean retryRequest(IOException e, int i, HttpContext httpContext) {
                if (i < 2) {
                    return true;
                }
                return false;
            }
        });
        response = httpclient.execute(httpRequest);

        then = System.currentTimeMillis();
        if (AndroidUtils.DEBUG_RPC) {
            connTime = (then - now);
            now = then;
        }

        HttpEntity entity = response.getEntity();

        // XXX STATUSCODE!

        StatusLine statusLine = response.getStatusLine();
        if (AndroidUtils.DEBUG_RPC) {
            Log.d(TAG, "StatusCode: " + statusLine.getStatusCode());
        }

        if (entity != null) {

            long contentLength = entity.getContentLength();
            if (contentLength >= Integer.MAX_VALUE - 2) {
                throw new RPCException("JSON response too large");
            }

            // A Simple JSON Response Read
            InputStream instream = (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO)
                    ? getUngzippedContent(entity)
                    : entity.getContent();
            InputStreamReader isr = new InputStreamReader(instream, "utf8");

            StringBuilder sb = null;
            BufferedReader br = null;
            // JSONReader is 10x slower, plus I get more OOM errors.. :(
            //            final boolean useStringBuffer = contentLength > (4 * 1024 * 1024) ? false
            //                  : DEFAULT_USE_STRINGBUFFER;
            final boolean useStringBuffer = DEFAULT_USE_STRINGBUFFER;

            if (useStringBuffer) {
                // Setting capacity saves StringBuffer from going through many
                // enlargeBuffers, and hopefully allows toString to not make a copy
                sb = new StringBuilder(contentLength > 512 ? (int) contentLength + 2 : 512);
            } else {
                if (AndroidUtils.DEBUG_RPC) {
                    Log.d(TAG, "Using BR. ContentLength = " + contentLength);
                }
                br = new BufferedReader(isr, 8192);
                br.mark(32767);
            }

            try {

                // 9775 files on Nexus 7 (~2,258,731 bytes)
                // fastjson 1.1.46 (String)       :  527- 624ms
                // fastjson 1.1.39 (String)       :  924-1054ms
                // fastjson 1.1.39 (StringBuilder): 1227-1463ms
                // fastjson 1.1.39 (BR)           : 2233-2260ms
                // fastjson 1.1.39 (isr)          :      2312ms
                // GSON 2.2.4 (String)            : 1539-1760ms
                // GSON 2.2.4 (BufferedReader)    : 2646-3060ms
                // JSON-SMART 1.3.1 (String)      :  572- 744ms (OOMs more often than fastjson)

                if (useStringBuffer) {
                    char c[] = new char[8192];
                    while (true) {
                        int read = isr.read(c);
                        if (read < 0) {
                            break;
                        }
                        sb.append(c, 0, read);
                    }

                    if (AndroidUtils.DEBUG_RPC) {
                        then = System.currentTimeMillis();
                        if (DEBUG_DETAILED) {
                            if (sb.length() > 2000) {
                                Log.d(TAG, id + "] " + sb.substring(0, 2000) + "...");
                            } else {
                                Log.d(TAG, id + "] " + sb.toString());
                            }
                        }
                        bytesRead = sb.length();
                        readTime = (then - now);
                        now = then;
                    }

                    json = JSONUtils.decodeJSON(sb.toString());
                    //json = JSONUtilsGSON.decodeJSON(sb.toString());
                } else {

                    //json = JSONUtils.decodeJSON(isr);
                    json = JSONUtils.decodeJSON(br);
                    //json = JSONUtilsGSON.decodeJSON(br);
                }

            } catch (Exception pe) {

                //               StatusLine statusLine = response.getStatusLine();
                if (statusLine != null && statusLine.getStatusCode() == 409) {
                    throw new RPCException(response, "409");
                }

                try {
                    String line;
                    if (useStringBuffer) {
                        line = sb.subSequence(0, Math.min(128, sb.length())).toString();
                    } else {
                        br.reset();
                        line = br.readLine().trim();
                    }

                    isr.close();

                    if (AndroidUtils.DEBUG_RPC) {
                        Log.d(TAG, id + "]line: " + line);
                    }
                    Header contentType = entity.getContentType();
                    if (line.startsWith("<") || line.contains("<html")
                            || (contentType != null && contentType.getValue().startsWith("text/html"))) {
                        // TODO: use android strings.xml
                        throw new RPCException(response,
                                "Could not retrieve remote client location information.  The most common cause is being on a guest wifi that requires login before using the internet.");
                    }
                } catch (IOException ignore) {

                }

                Log.e(TAG, id, pe);
                if (statusLine != null) {
                    String msg = statusLine.getStatusCode() + ": " + statusLine.getReasonPhrase() + "\n"
                            + pe.getMessage();
                    throw new RPCException(msg, pe);
                }
                throw new RPCException(pe);
            } finally {
                closeOnNewThread(useStringBuffer ? isr : br);
            }

            if (AndroidUtils.DEBUG_RPC) {
                //               Log.d(TAG, id + "]JSON Result: " + json);
            }

        }
    } catch (RPCException e) {
        throw e;
    } catch (Throwable e) {
        Log.e(TAG, id, e);
        throw new RPCException(e);
    }

    if (AndroidUtils.DEBUG_RPC) {
        then = System.currentTimeMillis();
        Log.d(TAG, id + "] conn " + connSetupTime + "/" + connTime + "ms. Read " + bytesRead + " in " + readTime
                + "ms, parsed in " + (then - now) + "ms");
    }
    return json;
}