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:grails.plugin.freemarker.TagLibToDirectiveAndFunction.java

@SuppressWarnings("serial")
@Override/*from w w  w .ja  v a 2  s .co  m*/
public Object exec(@SuppressWarnings("rawtypes") List arguments) throws TemplateModelException {
    if (log.isDebugEnabled()) {
        log.debug("exec(): @" + namespace + "." + tagName);
    }
    try {
        CharArrayWriter writer = new CharArrayWriter();
        tagInstance.invokeMethod("pushOut", writer);

        Object args = null;
        Object body = null;
        if (arguments != null) {
            if (arguments.size() > 0) {
                args = arguments.get(0);
            }
            if (arguments.size() > 1) {
                body = arguments.get(1);
            }
        }

        Object result = null;
        args = args != null ? unwrapParams((TemplateHashModelEx) args, true)
                : unwrapParams(Collections.EMPTY_MAP, true);

        if (tagInstance.getMaximumNumberOfParameters() == 1) {
            result = tagInstance.call(args);
        } else {
            Closure bodyClosure = EMPTY_BODY;

            if (body != null || hasReturnValue) {
                final Object fBody = body;
                bodyClosure = new Closure(this) {
                    @SuppressWarnings("unused")
                    public Object doCall(Object it) throws IOException, TemplateException {
                        return fBody;
                    }
                };
            }

            result = tagInstance.call(new Object[] { args, bodyClosure });
            if (result == null) {
                // writer.flush();
                result = writer.toString();
            }
        }

        return result;
    } catch (RuntimeException e) {
        throw new TemplateModelException(e);
    } finally {
        tagInstance.invokeMethod("popOut", null);
    }
}

From source file:com.github.jknack.handlebars.internal.Variable.java

/**
 * Creates a new {@link Variable}./*from www. ja va2  s.c o m*/
 *
 * @param handlebars The handlebars instance.
 * @param name The variable's name. Required.
 * @param type The variable's type. Required.
 */
@SuppressWarnings("unchecked")
public Variable(final Handlebars handlebars, final String name, final TagType type) {
    this(handlebars, name, type, Collections.EMPTY_LIST, Collections.EMPTY_MAP);
}

From source file:com.creactiviti.piper.core.Coordinator.java

/**
 * Starts a job instance.//from  ww w .j a  va2  s . com
 * 
 * @param aJobParams
 *          The Key-Value map representing the job
 *          parameters
 * @return Job
 *           The instance of the Job
 */
public Job create(Map<String, Object> aJobParams) {
    Assert.notNull(aJobParams, "request can't be null");
    MapObject jobParams = MapObject.of(aJobParams);
    String pipelineId = jobParams.getRequiredString(PIPELINE_ID);
    Pipeline pipeline = pipelineRepository.findOne(pipelineId);
    Assert.notNull(pipeline, String.format("Unkown pipeline: %s", pipelineId));
    Assert.isNull(pipeline.getError(),
            pipeline.getError() != null ? String.format("%s: %s", pipelineId, pipeline.getError().getMessage())
                    : null);

    validate(jobParams, pipeline);

    MapObject inputs = MapObject.of(jobParams.getMap(INPUTS, Collections.EMPTY_MAP));
    List<Accessor> webhooks = jobParams.getList(WEBHOOKS, MapObject.class, Collections.EMPTY_LIST);
    List<String> tags = (List<String>) aJobParams.get(TAGS);

    SimpleJob job = new SimpleJob();
    job.setId(UUIDGenerator.generate());
    job.setLabel(jobParams.getString(DSL.LABEL, pipeline.getLabel()));
    job.setPriority(jobParams.getInteger(DSL.PRIORITY, Prioritizable.DEFAULT_PRIORITY));
    job.setPipelineId(pipeline.getId());
    job.setStatus(JobStatus.CREATED);
    job.setCreateTime(new Date());
    job.setParentTaskExecutionId((String) aJobParams.get(DSL.PARENT_TASK_EXECUTION_ID));
    job.setTags(tags != null ? tags.toArray(new String[tags.size()]) : new String[0]);
    job.setWebhooks(webhooks != null ? webhooks : Collections.EMPTY_LIST);
    job.setInputs(inputs);
    log.debug("Job {} started", job.getId());
    jobRepository.create(job);

    MapContext context = new MapContext(jobParams.getMap(INPUTS, Collections.EMPTY_MAP));
    contextRepository.push(job.getId(), context);

    eventPublisher
            .publishEvent(PiperEvent.of(Events.JOB_STATUS, "jobId", job.getId(), "status", job.getStatus()));

    messenger.send(Queues.JOBS, job);

    return job;
}

From source file:org.geoserver.wms.wms_1_3.GetFeatureInfoIntegrationTest.java

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

    Map<String, String> namespaces = new HashMap<String, String>();
    namespaces.put("xlink", "http://www.w3.org/1999/xlink");
    namespaces.put("xsi", "http://www.w3.org/2001/XMLSchema-instance");
    namespaces.put("wms", "http://www.opengis.net/wms");
    namespaces.put("ows", "http://www.opengis.net/ows");
    namespaces.put("ogc", "http://www.opengis.net/ogc");
    namespaces.put("wfs", "http://www.opengis.net/wfs");
    namespaces.put("gml", "http://www.opengis.net/gml");
    namespaces.put(WCS_PREFIX, WCS_URI);

    NamespaceContext ctx = new SimpleNamespaceContext(namespaces);
    XMLUnit.setXpathNamespaceContext(ctx);

    Logging.getLogger("org.geoserver.ows").setLevel(Level.OFF);
    WMSInfo wmsInfo = getGeoServer().getService(WMSInfo.class);
    wmsInfo.setMaxBuffer(50);/*w  ww .j a  va  2 s  .c o m*/
    getGeoServer().save(wmsInfo);

    Catalog catalog = getCatalog();

    testData.addStyle("thickStroke", "thickStroke.sld", CapabilitiesTest.class, catalog);
    testData.addStyle("raster", "raster.sld", CapabilitiesTest.class, catalog);
    testData.addStyle("rasterScales", "rasterScales.sld", CapabilitiesTest.class, catalog);
    testData.addStyle("squares", "squares.sld", CapabilitiesTest.class, catalog);
    testData.addStyle("forestsManyRules", "ForestsManyRules.sld", CapabilitiesTest.class, catalog);
    testData.addVectorLayer(SQUARES, Collections.EMPTY_MAP, "squares.properties", CapabilitiesTest.class,
            catalog);
    Map propertyMap = new HashMap();
    propertyMap.put(LayerProperty.STYLE, "raster");
    testData.addRasterLayer(TASMANIA_BM, "tazbm.tiff", "tiff", propertyMap, SystemTestData.class, catalog);
}

From source file:org.apache.solr.cloud.CloudUtil.java

/**Read the list of public keys from ZK
 *///from  w  ww  . j  a va 2  s.  c o  m

public static Map<String, byte[]> getTrustedKeys(SolrZkClient zk, String dir) {
    Map<String, byte[]> result = new HashMap<>();
    try {
        List<String> children = zk.getChildren("/keys/" + dir, null, true);
        for (String key : children) {
            if (key.endsWith(".der"))
                result.put(key, zk.getData("/keys/" + dir + "/" + key, null, null, true));
        }
    } catch (KeeperException.NoNodeException e) {
        log.info("Error fetching key names");
        return Collections.EMPTY_MAP;
    } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
        throw new SolrException(ErrorCode.SERVER_ERROR, "Unable to read crypto keys", e);
    } catch (KeeperException e) {
        throw new SolrException(ErrorCode.SERVER_ERROR, "Unable to read crypto keys", e);
    }
    return result;

}

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

@SuppressWarnings("rawtypes")
public Map getBindingInfo(String ac, RemoteProfile remoteProfile) throws RPCException {
    String url = URL_PAIR + "/getBinding?sid=xmwebui&ac=" + ac;
    try {//  ww  w.  j  a  va2  s  .  c  om
        Object map = RestJsonClient.connect(url);
        if (map instanceof Map) {
            //System.out.println("is map");
            Object result = ((Map) map).get("result");
            if (result instanceof Map) {
                //System.out.println("result is map");
                return (Map) result;
            } else {
                return (Map) map;
            }
        }

        if (AndroidUtils.DEBUG_RPC) {
            Log.d(TAG, "getBindingInfo: empty or invalid reply from pair rpc");
        }

        if (remoteProfile != null) {
            String host = remoteProfile.getHost();
            int port = remoteProfile.getPort();
            String protocol = remoteProfile.getProtocol();
            if (host != null && host.length() > 0) {
                Map lastBindingInfo = new HashMap();
                lastBindingInfo.put("host", host);
                lastBindingInfo.put("port", port);
                lastBindingInfo.put("protocol", protocol == null || protocol.length() == 0 ? "http" : protocol);
                if (AndroidUtils.DEBUG_RPC) {
                    Log.d(TAG, "getBindingInfo: using last bindingInfo");
                }
                return lastBindingInfo;
            }
        }
    } catch (RPCException e) {
        if (remoteProfile != null) {
            String host = remoteProfile.getHost();
            int port = remoteProfile.getPort();
            String protocol = remoteProfile.getProtocol();
            if (host != null && host.length() > 0) {
                Map lastBindingInfo = new HashMap();
                lastBindingInfo.put("host", host);
                lastBindingInfo.put("port", port);
                lastBindingInfo.put("protocol", protocol == null || protocol.length() == 0 ? "http" : protocol);
                if (AndroidUtils.DEBUG_RPC) {
                    Log.d(TAG, "getBindingInfo: using last bindingInfo");
                }
                return lastBindingInfo;
            }
        }
        throw e;
    }
    return Collections.EMPTY_MAP;
}

From source file:com.redhat.rhn.frontend.taglibs.list.helper.ListRhnSetHelper.java

/**
 * Creates a new <code>ListRhnSetHelper</code> that will store its selected items
 * in an <code>RhnSet</code> retrieved from the given <code>RhnSetDecl</code>. Care
 * should be taken in using this call to ensure there will only be one set of data
 * in this list at a time (see//from   w  w  w  .  j a va  2 s.  c o m
 * {@link #ListRhnSetHelper(Listable, HttpServletRequest, RhnSetDecl, Map)} for a
 * use case in which this constructor would not be applicable).
 *
 * @param inp     the listable
 * @param request the servlet request
 * @param declIn  declaration
 */
public ListRhnSetHelper(Listable inp, HttpServletRequest request, RhnSetDecl declIn) {
    this(inp, request, declIn, Collections.EMPTY_MAP);
}

From source file:org.geoserver.jdbcconfig.JDBCConfigTestSupport.java

protected void configureAppContext(WebApplicationContext appContext) {
    expect(appContext.getBeansOfType((Class) anyObject())).andReturn(Collections.EMPTY_MAP).anyTimes();
    expect(appContext.getBeanNamesForType((Class) anyObject())).andReturn(new String[] {}).anyTimes();

    ServletContext servletContext = createNiceMock(ServletContext.class);
    replay(servletContext);//  www  . j a  v a2  s .c  o  m

    expect(appContext.getServletContext()).andReturn(servletContext);
}

From source file:edu.internet2.middleware.psp.shibboleth.ChangeLogDataConnector.java

/** {@inheritDoc} */
public Map<String, BaseAttribute> resolve(ShibbolethResolutionContext resolutionContext)
        throws AttributeResolutionException {

    String principalName = resolutionContext.getAttributeRequestContext().getPrincipalName();

    LOG.debug("ChangeLog data connector '{}' - Resolve principal '{}'", getId(), principalName);
    LOG.trace("ChangeLog data connector '{}' - Resolve principal '{}' requested attributes {}",
            new Object[] { getId(), principalName,
                    resolutionContext.getAttributeRequestContext().getRequestedAttributesIds(), });

    if (DatatypeHelper.isEmpty(principalName)) {
        LOG.debug("ChangeLog data Connector '{}' - No principal name", getId());
        return Collections.EMPTY_MAP;
    }// ww  w .  ja v a  2 s . c  o m

    // parse the change log entry sequence number from the principal name
    long sequenceNumber = sequenceNumber(principalName);

    if (sequenceNumber == -1) {
        LOG.debug("ChangeLog data connector '{}' - Principal name '{}' does not match prefix", getId(),
                principalName);
        return Collections.EMPTY_MAP;
    }

    // query for the change log entry
    ChangeLogEntry changeLogEntry = GrouperDAOFactory.getFactory().getChangeLogEntry()
            .findBySequenceNumber(sequenceNumber, false);

    if (changeLogEntry == null) {
        LOG.debug("ChangeLog data connector '{}' - Changelog sequence '{}' not found", getId(), principalName);
        return Collections.EMPTY_MAP;
    }

    // matcher
    Filter<ChangeLogEntry> matcher = getFilter();
    if (!matcher.matches(changeLogEntry)) {
        LOG.debug("ChangeLog data connector '{}' - Ignoring changelog '{}'", getId(), toString(changeLogEntry));
        return Collections.EMPTY_MAP;
    }

    LOG.debug("ChangeLog data connector '{}' - Found change log entry '{}'", getId(), toString(changeLogEntry));
    LOG.trace("ChangeLog data connector '{}' - Found change log entry '{}'", getId(),
            toStringDeep(changeLogEntry));
    LOG.trace("ChangeLog data connector '{}' - Found change log entry '{}'", getId(),
            changeLogEntry.toStringDeep());

    Map<String, BaseAttribute> attributes = buildAttributes(changeLogEntry);

    LOG.debug("ChangeLog data connector '{}' - Change log entry {} returning {}",
            new Object[] { getId(), toString(changeLogEntry), attributes, });

    if (LOG.isTraceEnabled()) {
        for (String key : attributes.keySet()) {
            for (Object value : attributes.get(key).getValues()) {
                LOG.trace("ChangeLog data connector '{}' - Change log entry {} attribute {} : {}",
                        new Object[] { getId(), toString(changeLogEntry), key, value, });
            }
        }
    }

    return attributes;
}

From source file:org.codehaus.groovy.grails.scaffolding.DefaultScaffoldRequestHandler.java

public Map handleShow(HttpServletRequest request, HttpServletResponse response, ScaffoldCallback callback) {

    Serializable id = getRequestId();
    if (id == null) {
        LOG.debug("[ScaffoldRequestHandler] No ID parameter [" + id + "] for request [show]");
        callback.setInvoked(false);//from  w  w  w .j  a  v a2  s. c  o m
        return Collections.EMPTY_MAP;
    }

    Map model = new HashMap();
    Object domainObject = domain.get(id);
    model.put(domain.getSingularName(), domainObject);
    callback.setInvoked(true);

    return model;
}