Java Examples for java.util.Map

The following java examples will help you to understand the usage of java.util.Map. These source code samples are taken from different open source projects.

Example 1
Project: iterator-master  File: Object.java View source code
public static void encode_(java.lang.Object obj, com.jsoniter.output.JsonStream stream) throws java.io.IOException {
    if (obj == null) {
        stream.writeNull();
        return;
    }
    java.util.Map map = (java.util.Map) obj;
    java.util.Iterator iter = map.entrySet().iterator();
    if (!iter.hasNext()) {
        return;
    }
    java.util.Map.Entry entry = (java.util.Map.Entry) iter.next();
    stream.writeVal((String) entry.getKey());
    stream.write((byte) ':');
    if (entry.getValue() == null) {
        stream.writeNull();
    } else {
        stream.writeVal((java.lang.Object) entry.getValue());
    }
    while (iter.hasNext()) {
        entry = (java.util.Map.Entry) iter.next();
        stream.write((byte) ',');
        stream.writeObjectField((String) entry.getKey());
        if (entry.getValue() == null) {
            stream.writeNull();
        } else {
            stream.writeVal((java.lang.Object) entry.getValue());
        }
    }
}
Example 2
Project: vebugger-master  File: MapTemplate.java View source code
@Override
public void render(StringBuilder sb, Object obj) {
    sb.append("<style>");
    sb.append("table.java-util-Map {border-collapse: collapse; font-size: 12px;}");
    sb.append("table.java-util-Map > * > tr > * {padding: 4px;}");
    sb.append("table.java-util-Map > thead > tr {border-bottom: 2px solid black;}");
    sb.append("table.java-util-Map > * > tr > *:first-child:not(:last-child) {border-right: 1px dotted silver;}");
    sb.append("table.java-util-Map > tbody > tr > * {border-bottom: 1px dotted silver;}");
    sb.append("table.java-util-Map > tbody > tr:last-child > * {border-bottom: none;}");
    sb.append("</style>");
    sb.append("<table class=\"java-util-Map\"><thead><tr><th>Key</th><th>Value</th></tr></thead><tbody>");
    for (Entry<?, ?> entry : ((Map<?, ?>) obj).entrySet()) {
        sb.append("<tr><td>").append(VisualDebuggerAid.toString(entry.getKey(), false)).append("</td><td>").append(VisualDebuggerAid.toString(entry.getValue(), false)).append("</tr>");
    }
    sb.append("</tbody></table>");
}
Example 3
Project: kraken-master  File: ServiceObserverPrxHelper.java View source code
private void servicesStarted(String[] services, java.util.Map<String, String> __ctx, boolean __explicitCtx) {
    if (__explicitCtx && __ctx == null) {
        __ctx = _emptyContext;
    }
    int __cnt = 0;
    while (true) {
        Ice._ObjectDel __delBase = null;
        try {
            __delBase = __getDelegate(false);
            _ServiceObserverDel __del = (_ServiceObserverDel) __delBase;
            __del.servicesStarted(services, __ctx);
            return;
        } catch (IceInternal.LocalExceptionWrapper __ex) {
            __handleExceptionWrapper(__delBase, __ex);
        } catch (Ice.LocalException __ex) {
            __cnt = __handleException(__delBase, __ex, null, __cnt);
        }
    }
}
Example 4
Project: EMF-IncQuery-Addons-master  File: HPPCHashMap.java View source code
/*
     * (non-Javadoc)
     * 
     * @see java.util.Map#entrySet()
     */
@Override
public Set<java.util.Map.Entry<K, V>> entrySet() {
    //HPPCHashSet<java.util.Map.Entry<K, V>> r = new HPPCHashSet<Map.Entry<K,V>>();
    Set<java.util.Map.Entry<K, V>> r = CollectionsFactory.getSet();
    Iterator<ObjectObjectCursor<K, V>> it = internal.iterator();
    while (it.hasNext()) {
        final ObjectObjectCursor<K, V> c = it.next();
        r.add(new Entry<K, V>() {

            @Override
            public K getKey() {
                return c.key;
            }

            @Override
            public V getValue() {
                return c.value;
            }

            @Override
            public V setValue(V value) {
                System.out.println("Unsupported entrySet::entry::setValue() called on HPPCHashMap");
                return value;
            }
        });
    }
    return r;
}
Example 5
Project: Fudan-Sakai-master  File: HidePresentationController.java View source code
/* (non-Javadoc)
    * @see org.sakaiproject.metaobj.utils.mvc.intf.Controller#handleRequest(java.lang.Object, java.util.Map, java.util.Map, java.util.Map, org.springframework.validation.Errors)
    */
public ModelAndView handleRequest(Object requestModel, Map request, Map session, Map application, Errors errors) {
    Agent current = getAuthManager().getAgent();
    String hideAction = (String) request.get("hideAction");
    String id = (String) request.get("id");
    if ("hide".equals(hideAction)) {
        getAuthzManager().createAuthorization(current, PresentationFunctionConstants.HIDE_PRESENTATION, getIdManager().getId(id));
    } else {
        getAuthzManager().deleteAuthorization(current, PresentationFunctionConstants.HIDE_PRESENTATION, getIdManager().getId(id));
    }
    return super.handleRequest(requestModel, request, session, application, errors);
}
Example 6
Project: generator-master  File: FullyQualifiedJavaTypeTest.java View source code
@Test
public void testGenericType2() {
    FullyQualifiedJavaType fqjt = //$NON-NLS-1$
    new FullyQualifiedJavaType("java.util.Map<java.lang.String, java.util.List<java.lang.String>>");
    assertTrue(fqjt.isExplicitlyImported());
    //$NON-NLS-1$
    assertEquals("Map<String, List<String>>", fqjt.getShortName());
    //$NON-NLS-1$
    assertEquals("java.util.Map<java.lang.String, java.util.List<java.lang.String>>", fqjt.getFullyQualifiedName());
    //$NON-NLS-1$
    assertEquals("java.util", fqjt.getPackageName());
    assertEquals(2, fqjt.getImportList().size());
    //$NON-NLS-1$
    assertEquals("java.util.Map", fqjt.getFullyQualifiedNameWithoutTypeParameters());
}
Example 7
Project: mybatis-generator-master  File: FullyQualifiedJavaTypeTest.java View source code
@Test
public void testGenericType2() {
    FullyQualifiedJavaType fqjt = //$NON-NLS-1$
    new FullyQualifiedJavaType("java.util.Map<java.lang.String, java.util.List<java.lang.String>>");
    assertTrue(fqjt.isExplicitlyImported());
    //$NON-NLS-1$
    assertEquals("Map<String, List<String>>", fqjt.getShortName());
    //$NON-NLS-1$
    assertEquals("java.util.Map<java.lang.String, java.util.List<java.lang.String>>", fqjt.getFullyQualifiedName());
    //$NON-NLS-1$
    assertEquals("java.util", fqjt.getPackageName());
    assertEquals(2, fqjt.getImportList().size());
    //$NON-NLS-1$
    assertEquals("java.util.Map", fqjt.getFullyQualifiedNameWithoutTypeParameters());
}
Example 8
Project: sakai-cle-master  File: HidePresentationController.java View source code
/* (non-Javadoc)
    * @see org.sakaiproject.metaobj.utils.mvc.intf.Controller#handleRequest(java.lang.Object, java.util.Map, java.util.Map, java.util.Map, org.springframework.validation.Errors)
    */
public ModelAndView handleRequest(Object requestModel, Map request, Map session, Map application, Errors errors) {
    Agent current = getAuthManager().getAgent();
    String hideAction = (String) request.get("hideAction");
    String id = (String) request.get("id");
    if ("hide".equals(hideAction)) {
        getAuthzManager().createAuthorization(current, PresentationFunctionConstants.HIDE_PRESENTATION, getIdManager().getId(id));
    } else {
        getAuthzManager().deleteAuthorization(current, PresentationFunctionConstants.HIDE_PRESENTATION, getIdManager().getId(id));
    }
    return super.handleRequest(requestModel, request, session, application, errors);
}
Example 9
Project: gft-master  File: ThreadUtil.java View source code
public String dumpAllThreads() {
    StringBuilder result = new StringBuilder();
    Map<Thread, StackTraceElement[]> m = Thread.getAllStackTraces();
    for (Entry<Thread, StackTraceElement[]> e : m.entrySet()) {
        if (e.getKey().isDaemon())
            result.append("Daemon ");
        result.append("Thread " + e.getKey() + "\n");
        for (StackTraceElement elm : e.getValue()) result.append("\t" + elm);
    }
    return result.toString();
}
Example 10
Project: li-old-master  File: RegexActionLoaderTest.java View source code
@Test
public void getActions() {
    ActionLoader actionLoader = new RegexActionLoader();
    Reflect.set(actionLoader, "typeRegex", "li.people.action.*");
    Reflect.set(actionLoader, "methodRegex", ".*(list|add|save|edit|update|delete).*");
    Map<String, Action> actions = actionLoader.getActions();
    for (Entry<String, Action> entry : actions.entrySet()) {
        System.err.println(entry.getKey() + "\t" + entry.getValue().actionMethod);
    }
}
Example 11
Project: richfaces-sandbox-master  File: BootstrapRenderKitUtils.java View source code
public static String toEventMap(Map<String, Object> attributeMap) {
    Map<String, Object> eventMap = Maps.newHashMap();
    for (Entry<String, Object> entry : attributeMap.entrySet()) {
        if (entry.getKey().startsWith("on")) {
            String eventName = entry.getKey().substring(2) + RICHFACES_BOOTSTRAP_EVENT_NAMESPACE;
            eventMap.put(eventName, entry.getValue());
        }
    }
    return RenderKitUtils.toScriptArgs(eventMap);
}
Example 12
Project: zstack-master  File: MapDSL.java View source code
public static <T> T findValue(Map target, String key) {
    Iterator<Entry> it = target.entrySet().iterator();
    while (it.hasNext()) {
        Map.Entry entry = it.next();
        Object value = entry.getValue();
        if (!entry.getKey().equals(key)) {
            if (Map.class.isAssignableFrom(value.getClass())) {
                Object ret = findValue((Map) value, key);
                if (ret != null) {
                    return (T) ret;
                }
            }
        } else {
            return (T) value;
        }
    }
    return null;
}
Example 13
Project: Flume-Hive-master  File: AvroFlumeReport.java View source code
// Used by DatumReader.  Applications should not call. 
@SuppressWarnings(value = "unchecked")
public void put(int field$, java.lang.Object value$) {
    switch(field$) {
        case 0:
            stringMetrics = (java.util.Map<java.lang.CharSequence, java.lang.CharSequence>) value$;
            break;
        case 1:
            longMetrics = (java.util.Map<java.lang.CharSequence, java.lang.Long>) value$;
            break;
        case 2:
            doubleMetrics = (java.util.Map<java.lang.CharSequence, java.lang.Double>) value$;
            break;
        default:
            throw new org.apache.avro.AvroRuntimeException("Bad index");
    }
}
Example 14
Project: restx-master  File: TypeHelperTest.java View source code
@Test
public void should_produce_type_expression() throws Exception {
    assertThat(TypeHelper.getTypeExpressionFor("java.lang.String")).isEqualTo("java.lang.String.class");
    assertThat(TypeHelper.getTypeExpressionFor("java.util.List<java.lang.String>")).isEqualTo("Types.newParameterizedType(java.util.List.class, java.lang.String.class)");
    assertThat(TypeHelper.getTypeExpressionFor("java.util.Map<java.lang.String, java.lang.Integer>")).isEqualTo("Types.newParameterizedType(java.util.Map.class, java.lang.String.class, java.lang.Integer.class)");
    assertThat(TypeHelper.getTypeExpressionFor("java.util.List<java.util.List<java.lang.String>>")).isEqualTo("Types.newParameterizedType(java.util.List.class, Types.newParameterizedType(java.util.List.class, java.lang.String.class))");
    assertThat(TypeHelper.getTypeExpressionFor("java.util.List<java.util.Map<java.lang.String, java.lang.Integer>>")).isEqualTo("Types.newParameterizedType(java.util.List.class, Types.newParameterizedType(java.util.Map.class, java.lang.String.class, java.lang.Integer.class))");
    assertThat(TypeHelper.getTypeExpressionFor("java.util.List<java.util.Map<java.util.Set<java.lang.String>, java.lang.Integer>>")).isEqualTo("Types.newParameterizedType(java.util.List.class, Types.newParameterizedType(java.util.Map.class, Types.newParameterizedType(java.util.Set.class, java.lang.String.class), java.lang.Integer.class))");
}
Example 15
Project: Reuseware-master  File: AsMapUtil.java View source code
public static java.util.Map<Object, Object> copySafelyToObjectToObjectMap(java.util.Map<?, ?> map) {
    java.util.Map<Object, Object> castedCopy = new java.util.LinkedHashMap<Object, Object>();
    if (map == null) {
        return castedCopy;
    }
    java.util.Iterator<?> it = map.keySet().iterator();
    while (it.hasNext()) {
        Object nextKey = it.next();
        castedCopy.put(nextKey, map.get(nextKey));
    }
    return castedCopy;
}
Example 16
Project: ttc2011-master  File: SslMapUtil.java View source code
public static java.util.Map<Object, Object> copySafelyToObjectToObjectMap(java.util.Map<?, ?> map) {
    java.util.Map<Object, Object> castedCopy = new java.util.LinkedHashMap<Object, Object>();
    if (map == null) {
        return castedCopy;
    }
    java.util.Iterator<?> it = map.keySet().iterator();
    while (it.hasNext()) {
        Object nextKey = it.next();
        castedCopy.put(nextKey, map.get(nextKey));
    }
    return castedCopy;
}
Example 17
Project: db4o-android-master  File: ArrayMap4.java View source code
/**
	 * java.util.Map implementation but transparently 
	 * activates the members as required.
	 * 
	 * @see java.util.Map 
	 * @see com.db4o.ta.Activatable
	 * 
	 * @sharpen.ignore
	 */
@SuppressWarnings("unchecked")
public boolean equals(Object obj) {
    if (this == obj) {
        return true;
    }
    if (!(obj instanceof Map)) {
        return false;
    }
    Map<K, V> other = (Map<K, V>) obj;
    if (size() != other.size()) {
        return false;
    }
    Set<K> otherKeySet = other.keySet();
    for (Map.Entry<K, V> entry : entrySet()) {
        K key = entry.getKey();
        if (!otherKeySet.contains(key)) {
            return false;
        }
        V value = entry.getValue();
        if (!(value == null ? other.get(key) == null : value.equals(other.get(key)))) {
            return false;
        }
    }
    return true;
}
Example 18
Project: HexScape-master  File: Map.java View source code
@JsonIgnore
private void setTile(Tile tile) {
    int x = tile.getX();
    int y = tile.getY();
    int z = tile.getZ();
    java.util.Map<Integer, java.util.Map<Integer, Tile>> byZ = tilesMap.get(z);
    if (byZ == null) {
        byZ = new HashMap<Integer, java.util.Map<Integer, Tile>>();
        tilesMap.put(z, byZ);
    }
    java.util.Map<Integer, Tile> byY = byZ.get(y);
    if (byY == null) {
        byY = new HashMap<Integer, Tile>();
        byZ.put(y, byY);
    }
    byY.put(x, tile);
}
Example 19
Project: AnalyzerBeans-master  File: ProvidedPropertyDescriptorImplTest.java View source code
public void testDiscovery() throws Exception {
    SimpleComponentDescriptor<ProvidedPropertyDescriptorImplTest> desc = new SimpleComponentDescriptor<ProvidedPropertyDescriptorImplTest>(ProvidedPropertyDescriptorImplTest.class, true);
    Set<ProvidedPropertyDescriptor> properties = desc.getProvidedProperties();
    assertEquals(3, properties.size());
    assertEquals("[ProvidedPropertyDescriptorImpl[field=dateMap,baseType=interface java.util.Map], " + "ProvidedPropertyDescriptorImpl[field=intMap,baseType=interface java.util.Map], " + "ProvidedPropertyDescriptorImpl[field=stringMap,baseType=interface java.util.Map]]", properties.toString());
}
Example 20
Project: DataCleaner-master  File: ProvidedPropertyDescriptorImplTest.java View source code
public void testDiscovery() throws Exception {
    final SimpleComponentDescriptor<ProvidedPropertyDescriptorImplTest> desc = new SimpleComponentDescriptor<>(ProvidedPropertyDescriptorImplTest.class, true);
    final Set<ProvidedPropertyDescriptor> properties = desc.getProvidedProperties();
    assertEquals(3, properties.size());
    assertEquals("[ProvidedPropertyDescriptorImpl[field=dateMap,baseType=interface java.util.Map], " + "ProvidedPropertyDescriptorImpl[field=intMap,baseType=interface java.util.Map], " + "ProvidedPropertyDescriptorImpl[field=stringMap,baseType=interface java.util.Map]]", properties.toString());
}
Example 21
Project: AribaWeb-Framework-master  File: FieldValue_JavaHashtable.java View source code
// Note: Below we reverse the sense of which is a primitive -- the String
// versions become the primitives and the FieldPath versions call the string versions.
/**
     Recursively calls getFieldValuePrimitive() with the head of the fieldPath
     list up to the last fieldPath node and then calls setFieldValuePrimitive().
     Each time the recursion iterates, the receiver is the value of the
     previous getFieldValuePrimitive().

     * Unlike the base implementation, if a dotted path assigment is made to a missing
       property, the intermediate Map is created on-demand (i.e. a set to "a.b" where
       there is no "a" defined will create a map for a, then recurse.

    @param target a java.util.Map into which the value will be put at key
    @param fieldPath the key used to put value into receiver (a java.util.Map)
    @param value the value to put into the receiver (a java.util.Map)
    */
public void setFieldValue(Object target, FieldPath fieldPath, Object value) {
    FieldPath fieldPathCdr = fieldPath._nextFieldPath;
    if (fieldPathCdr == null) {
        setFieldValuePrimitive(target, fieldPath, value);
    } else {
        Object nextTargetObject = getFieldValuePrimitive(target, fieldPath);
        if (nextTargetObject == null) {
            nextTargetObject = ClassUtil.newInstance(target.getClass());
            ((Map) target).put(fieldPath.car(), nextTargetObject);
        }
        fieldPathCdr.setFieldValue(nextTargetObject, value);
    }
}
Example 22
Project: clinic-softacad-master  File: MapType.java View source code
public Object replaceElements(final Object original, final Object target, final Object owner, final java.util.Map copyCache, final SessionImplementor session) throws HibernateException {
    CollectionPersister cp = session.getFactory().getCollectionPersister(getRole());
    java.util.Map result = (java.util.Map) target;
    result.clear();
    Iterator iter = ((java.util.Map) original).entrySet().iterator();
    while (iter.hasNext()) {
        java.util.Map.Entry me = (java.util.Map.Entry) iter.next();
        Object key = cp.getIndexType().replace(me.getKey(), null, session, owner, copyCache);
        Object value = cp.getElementType().replace(me.getValue(), null, session, owner, copyCache);
        result.put(key, value);
    }
    return result;
}
Example 23
Project: Hibernate-Core-3.5.6-Final-patched-with--True-Coalesce--enhancement-master  File: MapType.java View source code
public Object replaceElements(final Object original, final Object target, final Object owner, final java.util.Map copyCache, final SessionImplementor session) throws HibernateException {
    CollectionPersister cp = session.getFactory().getCollectionPersister(getRole());
    java.util.Map result = (java.util.Map) target;
    result.clear();
    Iterator iter = ((java.util.Map) original).entrySet().iterator();
    while (iter.hasNext()) {
        java.util.Map.Entry me = (java.util.Map.Entry) iter.next();
        Object key = cp.getIndexType().replace(me.getKey(), null, session, owner, copyCache);
        Object value = cp.getElementType().replace(me.getValue(), null, session, owner, copyCache);
        result.put(key, value);
    }
    return result;
}
Example 24
Project: hibernate-core-3.6.x-mod-master  File: MapType.java View source code
public Object replaceElements(final Object original, final Object target, final Object owner, final java.util.Map copyCache, final SessionImplementor session) throws HibernateException {
    CollectionPersister cp = session.getFactory().getCollectionPersister(getRole());
    java.util.Map result = (java.util.Map) target;
    result.clear();
    Iterator iter = ((java.util.Map) original).entrySet().iterator();
    while (iter.hasNext()) {
        java.util.Map.Entry me = (java.util.Map.Entry) iter.next();
        Object key = cp.getIndexType().replace(me.getKey(), null, session, owner, copyCache);
        Object value = cp.getElementType().replace(me.getValue(), null, session, owner, copyCache);
        result.put(key, value);
    }
    return result;
}
Example 25
Project: hibernate-core-ogm-master  File: MapType.java View source code
public Object replaceElements(final Object original, final Object target, final Object owner, final java.util.Map copyCache, final SessionImplementor session) throws HibernateException {
    CollectionPersister cp = session.getFactory().getCollectionPersister(getRole());
    java.util.Map result = (java.util.Map) target;
    result.clear();
    Iterator iter = ((java.util.Map) original).entrySet().iterator();
    while (iter.hasNext()) {
        java.util.Map.Entry me = (java.util.Map.Entry) iter.next();
        Object key = cp.getIndexType().replace(me.getKey(), null, session, owner, copyCache);
        Object value = cp.getElementType().replace(me.getValue(), null, session, owner, copyCache);
        result.put(key, value);
    }
    return result;
}
Example 26
Project: netbeans-mongodb-master  File: GenericChildren.java View source code
@Override
@SuppressWarnings("unchecked")
protected Node[] createNodes(String t) {
    Object o = map.get(t);
    if (o instanceof java.util.Map) {
        java.util.Map<String, Object> childMap = (java.util.Map<String, Object>) map.get(t);
        Node result = new GenericNode(lkp, t, childMap);
        return new Node[] { result };
    } else if (o instanceof List<?>) {
        List<?> list = (List<?>) o;
        GenericNode nue = new GenericNode(lkp, t, listToMap(list, t));
        return new Node[] { nue };
    } else {
        //            }
        return new Node[0];
    }
}
Example 27
Project: activemq-artemis-master  File: SoftValueHashMap.java View source code
/**
    * @see java.util.Map#entrySet()
    */
@Override
public Set<java.util.Map.Entry<K, V>> entrySet() {
    processQueue();
    HashSet<Map.Entry<K, V>> set = new HashSet<>();
    for (Map.Entry<K, AggregatedSoftReference> pair : mapDelegate.entrySet()) {
        V value = pair.getValue().get();
        if (value != null) {
            set.add(new EntryElement<>(pair.getKey(), value));
        }
    }
    return set;
}
Example 28
Project: hapi-fhir-master  File: Map.java View source code
/*
     * map(input, property)
     *
     * map/collect on a given property
     */
@Override
public Object apply(Object value, Object... params) {
    if (value == null) {
        return "";
    }
    List<Object> list = new ArrayList<Object>();
    Object[] array = super.asArray(value);
    String key = super.asString(super.get(0, params));
    for (Object obj : array) {
        java.util.Map map = (java.util.Map) obj;
        Object val = map.get(key);
        if (val != null) {
            list.add(val);
        }
    }
    return list.toArray(new Object[list.size()]);
}
Example 29
Project: eclipselink.runtime-master  File: ClassToolsTests.java View source code
public void testNestedName() {
    Map map = new HashMap();
    map.put("foo", "bar");
    Entry entry = (Entry) map.entrySet().iterator().next();
    if (JDK8 || JDK9) {
        // Node instead of Entry since JDK 7
        assertEquals("Node", ClassTools.nestedClassNameForObject(entry));
    } else {
        assertEquals("Entry", ClassTools.nestedClassNameForObject(entry));
    }
    assertEquals("Entry", ClassTools.nestedNameFor(java.util.Map.Entry.class));
}
Example 30
Project: eclipse.jdt.core-master  File: InnerEmulationTest_1_5.java View source code
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=275381
public void test1() throws Exception {
    this.runConformTest(new String[] { "X.java", "import java.util.Collection;\n" + "import java.util.Map;\n" + "public class X {\n" + "	public void foo(Collection<? extends Map.Entry> args) { /* dummy */ }\n" + "}" });
    String expectedOutput = "  Inner classes:\n" + "    [inner class info: #25 java/util/Map$Entry, outer class info: #27 java/util/Map\n" + "     inner name: #29 Entry, accessflags: 1545 public abstract static]\n";
    checkDisassembledClassFile(OUTPUT_DIR + File.separator + "X.class", "X", expectedOutput);
}
Example 31
Project: highway-to-urhell-master  File: JmsQueueTransformer.java View source code
@Override
protected void doTransform(CtClass cc) throws Exception {
    CtMethod c = cc.getMethod("init", "(Ljava.util.Hashtable;)V");
    String h2hHookCode = "" + "List listEntryPath = new ArrayList();" + "Iterator iter = myProps.entrySet().iterator();" + "while (iter.hasNext()) {" + "   java.util.Map.Entry element = (java.util.Map.Entry) iter.next();" + "   String key = (String) element.getValue();" + "   Object obj = lookup(key);" + "   if (obj instanceof javax.jms.Queue) {" + "       javax.jms.Queue queueTmp = (Queue) obj;" + "       EntryPathData entry = new EntryPathData();" + "       entry.setMethodName(\"no-method\");" + "       entry.setClassName(\"queue-jms\");" + "       entry.setTypePath(TypePath.DYNAMIC);" + "       entry.setAudit(false);" + "       try {" + "           entry.setUri(queueTmp.getQueueName());" + "       } catch (JMSException e) {" + "           entry.setUri(\"queue\");" + "           e.printStackTrace();" + "       }" + "       listEntryPath.add(entry);" + "    }" + "}" + "CoreEngine.getInstance().getFramework(\"JMS_11_CTX\").receiveData(listEntryPath);";
    c.insertAfter(h2hHookCode);
}
Example 32
Project: IsoMsgActionLib-master  File: ISOMsgActionUserCustomizedTest.java View source code
public void testSimple() throws ISOException {
    isoAction = new ISOMsgActionUserCustomized();
    final AtomicBoolean called = new AtomicBoolean();
    isoAction.setIsoAction(new IISOMsgAction() {

        /* (non-Javadoc)
			 * @see org.jpos.jposext.isomsgaction.service.IISOMsgAction#process(org.jpos.iso.ISOMsg, java.util.Map)
			 */
        public void process(ISOMsg msg, Map<String, Object> ctx) throws ISOException {
            called.set(true);
        }

        /* (non-Javadoc)
			 * @see org.jpos.jposext.isomsgaction.service.IISOMsgAction#process(org.jpos.iso.ISOMsg[], java.util.Map)
			 */
        public void process(ISOMsg[] msg, Map<String, Object> ctx) throws ISOException {
            called.set(true);
        }
    });
    called.set(false);
    isoAction.process((ISOMsg) null, null);
    assertTrue(called.get());
    called.set(false);
    isoAction.process((ISOMsg[]) null, null);
    assertTrue(called.get());
}
Example 33
Project: jframe-master  File: ToString.java View source code
public static final String toString(Map<?, ?> map) {
    if (map == null || map.isEmpty())
        return "";
    StringBuilder buf = new StringBuilder();
    buf.append("\nbegin\n");
    for (Object o : map.keySet()) {
        buf.append(String.valueOf(o) + "->" + String.valueOf(map.get(o)) + ",");
    }
    buf.append("\nend\n");
    return buf.toString();
}
Example 34
Project: MiBandDecompiled-master  File: AdditionEvent.java View source code
public boolean onEncode(JSONObject jsonobject) {
    StatCommonHelper.jsonPut(jsonobject, "qq", StatConfig.getQQ());
    if (a != null && a.size() > 0) {
        java.util.Map.Entry entry;
        for (Iterator iterator = a.entrySet().iterator(); iterator.hasNext(); jsonobject.put((String) entry.getKey(), entry.getValue())) {
            entry = (java.util.Map.Entry) iterator.next();
        }
    }
    return true;
}
Example 35
Project: wala-mirror-master  File: BimodalMap.java View source code
/*
   * @see java.util.Map#putAll(java.util.Map)
   */
@Override
@SuppressWarnings("unchecked")
public void putAll(Map<? extends K, ? extends V> t) throws UnsupportedOperationException {
    if (t == null) {
        throw new IllegalArgumentException("null t");
    }
    if (backingStore == null) {
        int size = t.size();
        if (size > cutOff) {
            backingStore = HashMapFactory.make();
        } else {
            backingStore = new SmallMap<K, V>();
        }
        backingStore.putAll(t);
        return;
    } else {
        if (backingStore instanceof SmallMap) {
            if (t.size() > cutOff) {
                Map<K, V> old = backingStore;
                backingStore = (Map<K, V>) HashMapFactory.make(t);
                backingStore.putAll(old);
            } else {
                backingStore.putAll(t);
                if (backingStore.size() > cutOff) {
                    transferBackingStore();
                }
                return;
            }
        } else {
            backingStore.putAll(t);
        }
    }
}
Example 36
Project: hibernate-orm-master  File: MapType.java View source code
@Override
public Object replaceElements(final Object original, final Object target, final Object owner, final java.util.Map copyCache, final SharedSessionContractImplementor session) throws HibernateException {
    CollectionPersister cp = session.getFactory().getMetamodel().collectionPersister(getRole());
    java.util.Map result = (java.util.Map) target;
    result.clear();
    for (Object o : ((Map) original).entrySet()) {
        Map.Entry me = (Map.Entry) o;
        Object key = cp.getIndexType().replace(me.getKey(), null, session, owner, copyCache);
        Object value = cp.getElementType().replace(me.getValue(), null, session, owner, copyCache);
        result.put(key, value);
    }
    return result;
}
Example 37
Project: maul-master  File: NgramsForOrderIterableWrapper.java View source code
@Override
protected Entry<List<W>, V> transform(final edu.berkeley.nlp.lm.map.NgramMap.Entry<V> next) {
    return new java.util.Map.Entry<List<W>, V>() {

        @Override
        public List<W> getKey() {
            final List<W> ngram = WordIndexer.StaticMethods.toList(wordIndexer, next.key);
            return ngram;
        }

        @Override
        public V getValue() {
            return next.value;
        }

        @Override
        public V setValue(final V arg0) {
            throw new UnsupportedOperationException("Method not yet implemented");
        }
    };
}
Example 38
Project: SlipStreamServer-master  File: ConcurrentHashMapType.java View source code
@SuppressWarnings({ "rawtypes", "unchecked" })
public Object replaceElements(Object original, Object target, CollectionPersister persister, Object owner, Map copyCache, SessionImplementor session) throws HibernateException {
    java.util.Map result = (java.util.Map) target;
    result.clear();
    Iterator iter = ((java.util.Map) original).entrySet().iterator();
    while (iter.hasNext()) {
        java.util.Map.Entry me = (java.util.Map.Entry) iter.next();
        Object key = persister.getIndexType().replace(me.getKey(), null, session, owner, copyCache);
        Object value = persister.getElementType().replace(me.getValue(), null, session, owner, copyCache);
        result.put(key, value);
    }
    return result;
}
Example 39
Project: AbuseJet-master  File: RequestHandler.java View source code
public HashSet<String> MemcacheStore() {
    Map<String, String[]> map = req.getParameterMap();
    for (Entry<String, String[]> entry : map.entrySet()) {
        String name = entry.getKey();
        String[] values = entry.getValue();
        for (int i = 0; i < values.length; i++) {
            storKeyVal(name, values[i]);
        }
    }
    return actions;
}
Example 40
Project: airship-master  File: ResourcesUtil.java View source code
public static void writeResources(Map<String, Integer> resources, File resourcesFile) throws IOException {
    Properties properties = new Properties();
    for (Entry<String, Integer> entry : resources.entrySet()) {
        properties.setProperty(entry.getKey(), String.valueOf(entry.getValue()));
    }
    resourcesFile.getParentFile().mkdirs();
    FileOutputStream out = new FileOutputStream(resourcesFile);
    try {
        properties.store(out, "");
    } finally {
        out.close();
    }
}
Example 41
Project: bndtools-master  File: CollectionUtil.java View source code
public static <K, V> Map<V, Set<K>> invertMapOfCollection(Map<K, ? extends Collection<V>> mapOfCollection) {
    Map<V, Set<K>> result = new TreeMap<V, Set<K>>();
    for (Entry<K, ? extends Collection<V>> inputEntry : mapOfCollection.entrySet()) {
        K inputKey = inputEntry.getKey();
        Collection<V> inputCollection = inputEntry.getValue();
        for (V inputValue : inputCollection) {
            Set<K> resultSet = result.get(inputValue);
            if (resultSet == null) {
                resultSet = new TreeSet<K>();
                result.put(inputValue, resultSet);
            }
            resultSet.add(inputKey);
        }
    }
    return result;
}
Example 42
Project: cachecloud-master  File: InstanceDaoTest.java View source code
@Test
public void testGetMachineInstanceCountMap() throws Exception {
    System.out.println("================testGetMachineInstanceCountMap start================");
    List<Map<String, Object>> mapList = instanceDao.getMachineInstanceCountMap();
    for (Map<String, Object> map : mapList) {
        System.out.println(map.get("ip"));
        System.out.println(map.get("count"));
    }
    System.out.println("================testGetMachineInstanceCountMap start================");
}
Example 43
Project: easyStor-master  File: HadoopRestOprate.java View source code
/**
	 * ·­ÒëÁ¬½ÓÖеĻúÆ÷ÃûΪIPµØÖ·
	 * @param datanodePutuRL master ·µ»Øʵ¼Ê´æ´¢Â·¾¶
	 * @return ʵ¼ÊÌá½»µØÖ·
	 */
public String transDataNodePutUrl(String datanodePutuRL) {
    for (Iterator it = EasystorConstants.hostIPMap.entrySet().iterator(); it.hasNext(); ) {
        Map.Entry<String, String> en = (Entry<String, String>) it.next();
        String hostName = en.getKey();
        String ip = en.getValue();
        datanodePutuRL = datanodePutuRL.replace(hostName, ip);
    }
    return datanodePutuRL;
}
Example 44
Project: ecologylabFundamental-master  File: ObjectOrHashMap.java View source code
/**
     * @see java.util.Map#entrySet()
     */
@Override
public Set<java.util.Map.Entry<K, V>> entrySet() {
    if (singleValue != null) {
        // just one; we need to make the set
        Set<Map.Entry<K, V>> set = new LinkedHashSet<Map.Entry<K, V>>(1);
        set.add(new OOHMEntry(singleKey, singleValue, this));
        return set;
    } else {
        return mappings().entrySet();
    }
}
Example 45
Project: grails-ide-master  File: ControllerReturnTypeInferencingTests.java View source code
public void testReturnType1() throws Exception {
    createControllerClass("FlarController", "class FlarController {\n" + "  def list = { [first : [''], second : 9 ] }\n" + "}");
    String contents = "new FlarController().list().first\n" + "new FlarController().list().second";
    int start = contents.indexOf("first");
    int end = start + "first".length();
    assertTypeInDomainClass(contents, start, end, "java.util.List<java.lang.String>");
    start = contents.indexOf("second");
    end = start + "second".length();
    assertTypeInDomainClass(contents, start, end, "java.lang.Integer");
    start = contents.indexOf("list");
    end = start + "list".length();
    assertTypeInDomainClass(contents, start, end, "java.util.Map");
}
Example 46
Project: jabox-master  File: SettingsModifier.java View source code
public static String parseInputStream(final InputStream is, Map<String, String> values) throws IOException {
    StringWriter writer = new StringWriter();
    IOUtils.copy(is, writer);
    String theString = writer.toString();
    String replace = theString;
    for (Entry<String, String> pair : values.entrySet()) {
        if (pair.getValue() == null) {
            pair.setValue("");
        }
        replace = replace.replace(pair.getKey(), pair.getValue());
        LOGGER.debug("Settings.xml variable: {}={}", pair.getKey(), pair.getValue());
    }
    return replace;
}
Example 47
Project: JavaStudy-master  File: MapTest.java View source code
public static void main(String[] args) {
    Map<StringBuilder, String> m = new WeakHashMap<StringBuilder, String>();
    StringBuilder a = new StringBuilder("123");
    StringBuilder b = new StringBuilder("456");
    m.put(a, "good");
    m.put(b, "okok");
    m.put(null, "ccc");
    m.put(null, "ddd");
    a.append("4");
    b.append("7");
    a = null;
    b = null;
    System.gc();
    Set<Entry<StringBuilder, String>> set = m.entrySet();
    for (Entry<StringBuilder, String> e : set) {
        System.out.println(e);
    }
}
Example 48
Project: jayhorn-master  File: PrettyPrinter.java View source code
public static String ppCfgBlockMapSet(Map<CfgBlock, Set<CfgBlock>> ms) {
    // sort the map for easy use
    TreeMap<String, String> sortedMap = new TreeMap<String, String>();
    for (Entry<CfgBlock, Set<CfgBlock>> entry : ms.entrySet()) {
        sortedMap.put(entry.getKey().getLabel(), ppCfgBlockSet(entry.getValue()));
    }
    return sortedMap.toString().replace("],", "],\n");
}
Example 49
Project: jbehave-core-master  File: ChainedRow.java View source code
/**
     * Returns values aggregated from all the delegates, without overriding
     * values that already exist.
     * 
     * @return The Map of aggregated values
     */
@Override
public Map<String, String> values() {
    Map<String, String> values = new LinkedHashMap<String, String>();
    for (Row each : delegates) {
        for (Entry<String, String> entry : each.values().entrySet()) {
            String name = entry.getKey();
            if (!values.containsKey(name)) {
                values.put(name, entry.getValue());
            }
        }
    }
    return values;
}
Example 50
Project: jdroid-master  File: DefaultMarshaller.java View source code
/**
	 * @see com.jdroid.java.marshaller.Marshaller#marshall(java.lang.Object, com.jdroid.java.marshaller.MarshallerMode,
	 *      java.util.Map)
	 */
@Override
public Object marshall(Object object, MarshallerMode mode, Map<String, String> extras) {
    Object marshalled = null;
    if (object != null) {
        if (object instanceof Boolean) {
            marshalled = object;
        } else if (object instanceof Date) {
            marshalled = DateUtils.format((Date) object, DateUtils.DEFAULT_DATE_TIME_FORMAT);
        } else if (object instanceof Number) {
            marshalled = object;
        } else {
            marshalled = StringUtils.getNotEmptyString(object.toString());
        }
    }
    return marshalled;
}
Example 51
Project: liferay-apps-content-targeting-master  File: UserSegmentServiceClpInvoker.java View source code
public Object invokeMethod(String name, String[] parameterTypes, Object[] arguments) throws Throwable {
    if (_methodName48.equals(name) && Arrays.deepEquals(_methodParameterTypes48, parameterTypes)) {
        return UserSegmentServiceUtil.getBeanIdentifier();
    }
    if (_methodName49.equals(name) && Arrays.deepEquals(_methodParameterTypes49, parameterTypes)) {
        UserSegmentServiceUtil.setBeanIdentifier((java.lang.String) arguments[0]);
        return null;
    }
    if (_methodName54.equals(name) && Arrays.deepEquals(_methodParameterTypes54, parameterTypes)) {
        return UserSegmentServiceUtil.addUserSegment(((Long) arguments[0]).longValue(), (java.util.Map<java.util.Locale, java.lang.String>) arguments[1], (java.util.Map<java.util.Locale, java.lang.String>) arguments[2], (com.liferay.portal.service.ServiceContext) arguments[3]);
    }
    if (_methodName55.equals(name) && Arrays.deepEquals(_methodParameterTypes55, parameterTypes)) {
        return UserSegmentServiceUtil.deleteUserSegment(((Long) arguments[0]).longValue());
    }
    if (_methodName56.equals(name) && Arrays.deepEquals(_methodParameterTypes56, parameterTypes)) {
        return UserSegmentServiceUtil.getUserSegments(((Long) arguments[0]).longValue());
    }
    if (_methodName57.equals(name) && Arrays.deepEquals(_methodParameterTypes57, parameterTypes)) {
        return UserSegmentServiceUtil.getUserSegments((long[]) arguments[0]);
    }
    if (_methodName58.equals(name) && Arrays.deepEquals(_methodParameterTypes58, parameterTypes)) {
        return UserSegmentServiceUtil.getUserSegmentsCount(((Long) arguments[0]).longValue());
    }
    if (_methodName59.equals(name) && Arrays.deepEquals(_methodParameterTypes59, parameterTypes)) {
        return UserSegmentServiceUtil.getUserSegmentsCount((long[]) arguments[0]);
    }
    if (_methodName60.equals(name) && Arrays.deepEquals(_methodParameterTypes60, parameterTypes)) {
        return UserSegmentServiceUtil.updateUserSegment(((Long) arguments[0]).longValue(), (java.util.Map<java.util.Locale, java.lang.String>) arguments[1], (java.util.Map<java.util.Locale, java.lang.String>) arguments[2], (com.liferay.portal.service.ServiceContext) arguments[3]);
    }
    throw new UnsupportedOperationException();
}
Example 52
Project: mdrill-master  File: IncValMerger.java View source code
@SuppressWarnings("unchecked")
@Override
public <T> Object execute(T... args) {
    Map<Object, Long> result = null;
    if (args != null && args.length > 0) {
        List<Map<Object, Long>> list = (List<Map<Object, Long>>) args[0];
        result = new HashMap<Object, Long>();
        for (Map<Object, Long> each : list) {
            for (Entry<Object, Long> e : each.entrySet()) {
                Object key = e.getKey();
                Long val = e.getValue();
                if (result.containsKey(key)) {
                    val += result.get(key);
                }
                result.put(key, val);
            }
        }
    }
    return result;
}
Example 53
Project: MVCHelper-master  File: PutMethod.java View source code
@Override
protected Request.Builder buildRequset(String url, Map<String, Object> params) {
    FormBody.Builder builder = new FormBody.Builder();
    if (params != null) {
        for (Entry<String, ?> entry : params.entrySet()) {
            builder.add(entry.getKey(), String.valueOf(entry.getValue()));
        }
    }
    RequestBody formBody = builder.build();
    return new Request.Builder().url(url).put(formBody);
}
Example 54
Project: openwayback-master  File: ContentTypeHeaderSniffer.java View source code
@Override
public String sniff(Resource resource) {
    Map<String, String> httpHeaders = resource.getHttpHeaders();
    for (Entry<String, String> e : httpHeaders.entrySet()) {
        String headerKey = e.getKey();
        if (headerKey.equalsIgnoreCase(HTTP_CONTENT_TYPE_HEADER)) {
            String ctype = e.getValue();
            String charsetName = contentTypeToCharset(ctype);
            return charsetName;
        }
    }
    return null;
}
Example 55
Project: rewrite-master  File: ParametersBean.java View source code
public List<String> getList() {
    List<String> result = new ArrayList<String>();
    HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
    Map<String, String[]> parameterMap = request.getParameterMap();
    if (!parameterMap.isEmpty()) {
        for (Entry<String, String[]> param : parameterMap.entrySet()) {
            String values = Strings.join(Arrays.asList(param.getValue()), ", ");
            result.add(param.getKey() + ": " + values);
        }
    }
    return result;
}
Example 56
Project: rt-analytics-master  File: TweetParserTest.java View source code
@Test
public void tokenize() {
    String text = //
    "Twitter is an online social networking service and microblogging service" + //
    " that enables its users to send and read text-based posts of up to 140 characters," + " known as \"tweets\". You can signup and test it yourself.";
    Map<String, Integer> tokenMap = new TweetParser().tokenize(text);
    assertThat(tokenMap).hasSize(25);
    assertThat(tokenMap.get("microblogging")).isEqualTo(1);
    assertThat(tokenMap.get("and")).isEqualTo(3);
    assertThat(tokenMap.get("unknown")).isNull();
    for (Entry<String, Integer> e : tokenMap.entrySet()) {
        System.out.println(e.getKey() + ": " + e.getValue());
    }
}
Example 57
Project: rtgov-master  File: MaintainServiceDefinitionsMvelTest.java View source code
@Test
public void testMaintainServiceDescriptions() {
    Object expression = null;
    try {
        java.io.InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(SCRIPT);
        if (is == null) {
            fail("Unable to locate '" + SCRIPT + "'");
        } else {
            byte[] b = new byte[is.available()];
            is.read(b);
            is.close();
            // Compile expression
            expression = MVEL.compileExpression(new String(b));
        }
    } catch (Exception e) {
        fail("Failed to test script: " + e);
    }
    java.util.Map<String, Object> vars = new java.util.HashMap<String, Object>();
    java.util.Map<String, Object> internalVariables = new java.util.HashMap<String, Object>();
    ActiveCollectionSource acs = new ActiveCollectionSource();
    acs.getProperties().put("maxSnapshots", 3);
    ActiveMap map = new ActiveMap("TestMap");
    acs.setActiveCollection(map);
    // Add some service definitions
    ServiceDefinition sd1 = new ServiceDefinition();
    sd1.setServiceType("sd1");
    acs.insert(sd1.getServiceType(), sd1);
    vars.put("value", sd1);
    vars.put("acs", acs);
    vars.put("variables", internalVariables);
    MVEL.executeExpression(expression, vars);
    java.util.Map<?, ?> snapshots = (java.util.Map<?, ?>) internalVariables.get("currentSnapshot");
    if (snapshots == null) {
        fail("No snapshots recorded");
    }
    if (snapshots.size() != 1) {
        fail("Expecting 1 current snapshot: " + snapshots.size());
    }
}
Example 58
Project: smooks-editor-master  File: SmooksResourceImpl.java View source code
/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.emf.ecore.resource.impl.ResourceImpl#save(java.util.Map)
	 */
@Override
public void save(Map<?, ?> options) throws IOException {
    // IResource resource = getResource(this);
    // if (resource != null && resource.exists() && (resource instanceof
    // IFile)) {
    // ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    // doSave(outputStream, options);
    //			
    // try {
    // ((IFile) resource).setContents(new
    // ByteArrayInputStream(outputStream.toByteArray()), true, false, null);
    // } catch (CoreException e) {
    // throw new IOException(e.getMessage());
    // }
    // } else {
    super.save(options);
// }
}
Example 59
Project: TechnologyReadinessTool-master  File: AjaxHandler.java View source code
@Override
public void start(String name, Attributes attributes) throws IOException {
    Map<String, Object> dynamicAttributes = (Map<String, Object>) context.getParameters().get("dynamicAttributes");
    for (Entry<String, Object> attribute : dynamicAttributes.entrySet()) {
        if (attribute.getKey().startsWith("ajax")) {
            attributes.add(String.format("data-%s", attribute.getKey()), ObjectUtils.toString(attribute.getValue()));
        }
    }
    super.start(name, attributes);
}
Example 60
Project: TestNG-master  File: XmlUtils.java View source code
public static void dumpParameters(XMLStringBuffer xsb, Map<String, String> parameters) {
    // parameters
    if (!parameters.isEmpty()) {
        for (Map.Entry<String, String> para : parameters.entrySet()) {
            Properties paramProps = new Properties();
            paramProps.setProperty("name", para.getKey());
            paramProps.setProperty("value", para.getValue());
            // BUGFIX: TESTNG-27
            xsb.addEmptyElement("parameter", paramProps);
        }
    }
}
Example 61
Project: triple-master  File: ResourceLoaderTest.java View source code
@Test
public void testMapNameNormalization() {
    final Map<String, String> testPairs = Maps.newHashMap();
    testPairs.put("same.zip", "same.zip");
    testPairs.put("camelCase.zip", "camel_case.zip");
    testPairs.put("spaces removed.zip", "spaces_removed.zip");
    testPairs.put("LowerCased.zip", "lower_cased.zip");
    testPairs.put("LOWER.zip", "lower.zip");
    for (final Entry<String, String> testPair : testPairs.entrySet()) {
        assertThat(ResourceLoader.normalizeMapZipName(testPair.getKey()), is(testPair.getValue()));
    }
}
Example 62
Project: vertx-examples-master  File: ProcessorService_GroovyExtension.java View source code
public static void process(io.vertx.examples.service.ProcessorService j_receiver, java.util.Map<String, Object> document, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.Map<String, Object>>> resultHandler) {
    j_receiver.process(document != null ? io.vertx.core.impl.ConversionHelper.toJsonObject(document) : null, resultHandler != null ? new io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.core.json.JsonObject>>() {

        public void handle(io.vertx.core.AsyncResult<io.vertx.core.json.JsonObject> ar) {
            resultHandler.handle(ar.map( event -> io.vertx.core.impl.ConversionHelper.fromJsonObject(event)));
        }
    } : null);
}
Example 63
Project: zdal-master  File: GroovyRuleUtils.java View source code
protected static String buildArgumentsOutput(Map<Object, Object> var) {
    StringBuilder sb = new StringBuilder();
    if (var == null) {
        return "do not have variable";
    }
    for (Entry<Object, Object> entry : var.entrySet()) {
        sb.append("[").append(entry.getKey()).append("=").append(entry.getValue()).append("|type:").append(entry.getValue() == null ? null : entry.getValue().getClass()).append("]");
    }
    return sb.toString();
}
Example 64
Project: gemini.blueprint-master  File: PropertiesUtil.java View source code
/**
	 * Apply placeholder expansion to the given properties object.
	 * 
	 * Will return a new properties object, containing the expanded entries. Note that both keys and values will be
	 * expanded.
	 * 
	 * @param props
	 * @return
	 */
public static Properties expandProperties(Properties props) {
    Assert.notNull(props);
    Set entrySet = props.entrySet();
    Properties newProps = (props instanceof OrderedProperties ? new OrderedProperties() : new Properties());
    for (Iterator iter = entrySet.iterator(); iter.hasNext(); ) {
        // first expand the keys
        Map.Entry entry = (Map.Entry) iter.next();
        String key = (String) entry.getKey();
        String value = (String) entry.getValue();
        String resultKey = expandProperty(key, props);
        String resultValue = expandProperty(value, props);
        // replace old entry
        newProps.put(resultKey, resultValue);
    }
    return newProps;
}
Example 65
Project: lombok-intellij-plugin-master  File: SingularMapHandler.java View source code
protected String getAllMethodBody(@NotNull String singularName, @NotNull PsiType psiFieldType, @NotNull PsiManager psiManager, boolean fluentBuilder) {
    final String codeBlockTemplate = "if (this.{0}" + LOMBOK_KEY + " == null) '{' \n" + "this.{0}" + LOMBOK_KEY + " = new java.util.ArrayList<{2}>(); \n" + "this.{0}" + LOMBOK_VALUE + " = new java.util.ArrayList<{3}>(); \n" + "'}' \n" + "for (final java.util.Map.Entry<{4},{5}> $lombokEntry : {0}.entrySet()) '{'\n" + "this.{0}" + LOMBOK_KEY + ".add($lombokEntry.getKey());\n" + "this.{0}" + LOMBOK_VALUE + ".add($lombokEntry.getValue());\n" + "'}'{1}";
    final PsiType keyType = PsiTypeUtil.extractOneElementType(psiFieldType, psiManager, CommonClassNames.JAVA_UTIL_MAP, 0);
    final PsiType valueType = PsiTypeUtil.extractOneElementType(psiFieldType, psiManager, CommonClassNames.JAVA_UTIL_MAP, 1);
    final PsiType keyIterType = PsiTypeUtil.extractAllElementType(psiFieldType, psiManager, CommonClassNames.JAVA_UTIL_MAP, 0);
    final PsiType valueIterType = PsiTypeUtil.extractAllElementType(psiFieldType, psiManager, CommonClassNames.JAVA_UTIL_MAP, 1);
    return MessageFormat.format(codeBlockTemplate, singularName, fluentBuilder ? "\nreturn this;" : "", keyType.getCanonicalText(false), valueType.getCanonicalText(false), keyIterType.getCanonicalText(false), valueIterType.getCanonicalText(false));
}
Example 66
Project: appverse-web-master  File: RestPersistenceService.java View source code
/* (non-Javadoc)
     * @see org.appverse.web.framework.backend.rest.services.integration.IRestPersistenceService#retrieve(javax.ws.rs.client.WebTarget, java.lang.String, java.lang.Long, java.util.Map, java.util.Map, java.util.Map)
     */
@Override
public T retrieve(WebTarget webClient, final String idName, final Long id, final Map<String, Object> pathParams, final Map<String, Object> queryParams, final Map<String, Object> builderProperties) throws Exception {
    if (queryParams != null)
        webClient = applyQuery(webClient, queryParams);
    GenericType<T> genericType = new GenericType<T>(getClassP()) {
    };
    if (id != null && idName != null)
        webClient = webClient.resolveTemplate(idName, id);
    if (pathParams != null)
        webClient = webClient.resolveTemplates(pathParams);
    Builder builder = acceptMediaType(webClient.request());
    if (builderProperties != null) {
        addBuilderProperties(builder, builderProperties);
    }
    Method methodGet = Builder.class.getMethod("get", GenericType.class);
    T object = null;
    if (restCachingManager != null)
        object = restCachingManager.manageRestCaching(builder, methodGet, genericType, this, getKey(webClient));
    else
        object = builder.get(genericType);
    return object;
}
Example 67
Project: aq2o-master  File: MapToObject.java View source code
public Object[][] convert(Map<String, Object> mapIn) {
    Object[][] out = new Object[mapIn.size()][2];
    Iterator<String> keyIterator = mapIn.keySet().iterator();
    Iterator<Object> valueIterator = mapIn.values().iterator();
    int row = 0;
    while (keyIterator.hasNext()) {
        //
        String key = keyIterator.next();
        Object value = valueIterator.next();
        out[row][0] = key;
        out[row][1] = value;
        row++;
    }
    return out;
}
Example 68
Project: arinc_838-master  File: Crc64GeneratorTest.java View source code
@Test
public void calculateCrcTest() throws Exception {
    Crc64Generator generator = new Crc64Generator();
    Map<BigInteger, byte[]> expectedCrcs = CrcCalculatorTestCommon.getExpectedCrcs("crc64");
    for (BigInteger expectedCrc : expectedCrcs.keySet()) {
        long crc = generator.calculateCrc(expectedCrcs.get(expectedCrc));
        assertEquals(crc, expectedCrc.longValue());
    }
}
Example 69
Project: aws-sdk-android-master  File: PredictionJsonMarshaller.java View source code
public void marshall(Prediction prediction, AwsJsonWriter jsonWriter) throws Exception {
    jsonWriter.beginObject();
    if (prediction.getPredictedLabel() != null) {
        String predictedLabel = prediction.getPredictedLabel();
        jsonWriter.name("predictedLabel");
        jsonWriter.value(predictedLabel);
    }
    if (prediction.getPredictedValue() != null) {
        Float predictedValue = prediction.getPredictedValue();
        jsonWriter.name("predictedValue");
        jsonWriter.value(predictedValue);
    }
    if (prediction.getPredictedScores() != null) {
        java.util.Map<String, Float> predictedScores = prediction.getPredictedScores();
        jsonWriter.name("predictedScores");
        jsonWriter.beginObject();
        for (java.util.Map.Entry<String, Float> predictedScoresEntry : predictedScores.entrySet()) {
            Float predictedScoresValue = predictedScoresEntry.getValue();
            if (predictedScoresValue != null) {
                jsonWriter.name(predictedScoresEntry.getKey());
                jsonWriter.value(predictedScoresValue);
            }
        }
        jsonWriter.endObject();
    }
    if (prediction.getDetails() != null) {
        java.util.Map<String, String> details = prediction.getDetails();
        jsonWriter.name("details");
        jsonWriter.beginObject();
        for (java.util.Map.Entry<String, String> detailsEntry : details.entrySet()) {
            String detailsValue = detailsEntry.getValue();
            if (detailsValue != null) {
                jsonWriter.name(detailsEntry.getKey());
                jsonWriter.value(detailsValue);
            }
        }
        jsonWriter.endObject();
    }
    jsonWriter.endObject();
}
Example 70
Project: baas.io-sdk-android-master  File: ObjectUtils.java View source code
public static boolean isEmpty(Object s) {
    if (s == null) {
        return true;
    }
    if ((s instanceof String) && (((String) s).trim().length() == 0)) {
        return true;
    }
    if (s instanceof Map) {
        return ((Map<?, ?>) s).isEmpty();
    }
    if (s instanceof List) {
        return ((List<?>) s).isEmpty();
    }
    if (s instanceof Object[]) {
        return (((Object[]) s).length == 0);
    }
    return false;
}
Example 71
Project: bayeux4netty-master  File: BayeuxMessageFacotryTest.java View source code
@Test
public void testCreateFromJSON() {
    String json = "{\"clientId\":123,    \"id\":1}";
    JSONParser parser = new JSONParser();
    Map map = (Map) parser.parse(json);
    BayeuxMessage bayeux = BayeuxMessageFactory.getInstance().create(map);
    BayeuxMessage expect = new BayeuxMessage();
    expect.clientId = "123";
    expect.id = "1";
    assertEquals(expect, bayeux);
}
Example 72
Project: codeine-master  File: UrlUtils.java View source code
public static String buildUrl(String uri, Map<String, String> queryParams) {
    StringBuilder $ = new StringBuilder(uri);
    if (queryParams != null && queryParams.size() > 0) {
        $.append("?");
        for (String parameter : queryParams.keySet()) {
            $.append(parameter + "=" + HttpUtils.encodeURL(queryParams.get(parameter)) + "&");
        }
        $.deleteCharAt($.length() - 1);
    }
    return $.toString();
}
Example 73
Project: coding2017-master  File: xmlTest.java View source code
/**
	 * @param args
	 */
public static void main(String[] args) {
    // TODO Auto-generated method stub
    String actionName = "login";
    Map<String, String> params = new HashMap<String, String>();
    params.put("name", "test");
    params.put("password", "1234");
    View view = Struts.runAction(actionName, params);
    String str = view.getJsp();
    System.out.println(str);
}
Example 74
Project: docbookx-tools-master  File: ExpressionUtilsTest.java View source code
public void testCreateTreeTest() {
    Properties properties = new Properties();
    properties.setProperty("foo.1", "bar");
    properties.setProperty("foo.2", "foo");
    Map tree = ExpressionUtils.createTree(properties);
    assertEquals(1, tree.size());
    assertTrue(tree.containsKey("foo"));
    Map subtree = (Map) tree.get("foo");
    assertEquals(2, subtree.size());
    assertTrue(subtree.containsKey("1"));
    assertTrue(subtree.containsKey("2"));
}
Example 75
Project: FastOmiai-master  File: NetworkUtil.java View source code
public static String getUrl(String url, Map<String, String> params) {
    if (!url.endsWith("&"))
        url += "&";
    StringBuilder builder = new StringBuilder(url);
    for (Map.Entry<String, String> entry : params.entrySet()) {
        builder.append(entry.getKey());
        builder.append('=');
        builder.append(entry.getValue());
        builder.append('&');
    }
    String result = builder.toString();
    return result.substring(0, result.length() - 1);
}
Example 76
Project: FloreantPos-master  File: ReportUtil.java View source code
public static void populateRestaurantProperties(Map map) {
    RestaurantDAO dao = new RestaurantDAO();
    Restaurant restaurant = dao.get(Integer.valueOf(1));
    map.put("restaurantName", restaurant.getName());
    map.put("addressLine1", restaurant.getAddressLine1());
    map.put("addressLine2", restaurant.getAddressLine2());
    map.put("addressLine3", restaurant.getAddressLine3());
    map.put("phone", restaurant.getTelephone());
}
Example 77
Project: ggp-base-master  File: SentenceDomainModelFactory.java View source code
public static ImmutableSentenceDomainModel createWithCartesianDomains(List<Gdl> description) throws InterruptedException {
    ImmutableSentenceFormModel formModel = SentenceFormModelFactory.create(description);
    SentenceFormsFinder sentenceFormsFinder = new SentenceFormsFinder(formModel.getDescription());
    Map<SentenceForm, SentenceFormDomain> domains = sentenceFormsFinder.findCartesianDomains();
    return ImmutableSentenceDomainModel.create(formModel, domains);
}
Example 78
Project: gluster-ovirt-poc-master  File: XmlRpcUtilsTest.java View source code
@Test
public void testGetHttpConnection() {
// String hostName = "10.35.16.31";
// int port = 54321;
// int clientTimeOut = 10*1000;
// VdsServerConnector connector =
// XmlRpcUtils.getHttpConnection(hostName, port, clientTimeOut,
// VdsServerConnector.class);
// Map<String,Object> result = connector.list();
// System.out.println("the result size"+result.size());
}
Example 79
Project: hazelcast-code-samples-master  File: Member.java View source code
public static void main(String[] args) {
    HazelcastInstance hz = Hazelcast.newHazelcastInstance();
    Map<String, Person> map = hz.getMap("map");
    map.put("foo", new Person("foo"));
    System.out.println("finished writing");
    System.out.println(map.get("foo"));
    System.out.println("finished reading");
    Hazelcast.shutdownAll();
}
Example 80
Project: HazelcastShowAndTell-master  File: AverageCollator.java View source code
@Override
public Double collate(Iterable<Map.Entry<Integer, NumberReductionResult>> values) {
    double sumOfAllNumbersAfterOp = 0;
    double countOfAllNumbers = 0;
    for (Map.Entry<Integer, NumberReductionResult> entry : values) {
        Integer count = entry.getValue().getCount();
        Integer opResultOnNumber = entry.getValue().getOpResult();
        sumOfAllNumbersAfterOp += opResultOnNumber * count;
        countOfAllNumbers += count;
    }
    return sumOfAllNumbersAfterOp / countOfAllNumbers;
}
Example 81
Project: intellij-community-master  File: beforeFindFirstReAssignment.java View source code
public void testMap(Map<String, List<String>> map) throws Exception {
    int firstSize = 10;
    System.out.println(firstSize);
    firstSize = getInitialSize();
    // loop
    for (List<String> list : map.valu < caret > es()) {
        if (list != null) {
            firstSize = list.size();
            // comment
            break;
        }
    }
    System.out.println(firstSize);
}
Example 82
Project: intravert-ug-master  File: FilterFactory.java View source code
public static Filter createFilter(final Object object) {
    if (object instanceof Filter) {
        return (Filter) object;
    } else if (object instanceof Closure) {
        return new Filter() {

            public Map filter(Map m) {
                return ((Closure<Map>) object).call(m);
            }
        };
    } else {
        throw new RuntimeException("Do not know what to do with " + object);
    }
}
Example 83
Project: jadice-webtoolkit-master  File: SimpleConsoleAdapter.java View source code
@Override
public void publish(DataObject<?> data) {
    String labels = "";
    for (Map.Entry<String, String> entry : data.getLabels().entrySet()) {
        labels += entry.getKey() + "=\"" + entry.getValue() + "\" ";
    }
    labels = labels.trim();
    System.out.println("SimpleConsoleAdapter: [metric: " + data.getMetricName() + "{" + labels + "}, value: " + data.getValue() + "]");
}
Example 84
Project: java-tool-master  File: MapTest.java View source code
@Test
public void testSerialize() throws Exception {
    Map map = C.map("foo", 1, "bar", 0);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream(baos);
    oos.writeObject(map);
    ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));
    Map map2 = (Map) ois.readObject();
    eq(map, map2);
}
Example 85
Project: jblog-master  File: ArrayUtils.java View source code
public static PostParameter[] mapToArray(Map<String, String> map) {
    PostParameter[] parList = new PostParameter[map.size()];
    Iterator<String> iter = map.keySet().iterator();
    int i = 0;
    while (iter.hasNext()) {
        String key = iter.next();
        String value = map.get(key);
        parList[i++] = new PostParameter(key, value);
    }
    return parList;
}
Example 86
Project: JSON-RPC-master  File: VarArgsUtil.java View source code
public static Map<String, Object> convertArgs(Object[] params) {
    final Map<String, Object> unsafeMap = new HashMap<>();
    for (int i = 0; i < params.length; i += 2) {
        if (params[i] instanceof String && params[i] != null && !params[i].toString().isEmpty()) {
            unsafeMap.put(params[i].toString(), params[i + 1]);
        }
    }
    return unsafeMap;
}
Example 87
Project: jsonrpc4j-master  File: VarArgsUtil.java View source code
public static Map<String, Object> convertArgs(Object[] params) {
    final Map<String, Object> unsafeMap = new HashMap<>();
    for (int i = 0; i < params.length; i += 2) {
        if (params[i] instanceof String && params[i] != null && !params[i].toString().isEmpty()) {
            unsafeMap.put(params[i].toString(), params[i + 1]);
        }
    }
    return unsafeMap;
}
Example 88
Project: kanqiu_letv-master  File: NativeCMD.java View source code
public static Map<String, Object> runCmd(String cmd) {
    Map<String, Object> map = new HashMap<String, Object>();
    try {
        Process process = Runtime.getRuntime().exec(cmd);
        map.put("input", process.getInputStream());
        map.put("error", process.getErrorStream());
        return map;
    } catch (Exception e) {
        return null;
    }
}
Example 89
Project: kotlin-master  File: overMapEntries.java View source code
public static void main(String[] args) {
    Map<String, String> resultMap = new HashMap<String, String>();
    for (final Map.Entry<String, String> entry : resultMap.entrySet()) {
        String key = entry.getKey();
        String type = entry.getValue();
        if (key.equals("myKey")) {
            System.out.println(type);
        }
    }
}
Example 90
Project: luajava-master  File: TestLuaMap.java View source code
public void testMap() throws ClassNotFoundException, LuaException {
    Map table = new HashMap();
    table.put("testTable2-1", "testTable2Value");
    table.put("testTable2-2", new Object());
    // test using a java accessed table.
    Map luaMap = new LuaMap();
    luaMap.put("test", "testValue");
    luaMap.putAll(table);
    assertTrue(luaMap.containsKey("test"));
    assertTrue(luaMap.containsKey("testTable2-1"));
    System.out.println(luaMap.get("testTable2-2"));
    assertTrue(luaMap.containsValue("testValue"));
    assertEquals(3, luaMap.size());
    luaMap.remove("test");
    assertNull(luaMap.get("test"));
    luaMap.clear();
    assertEquals(luaMap.size(), 0);
    // test using a lua table
    LuaState L = LuaStateFactory.newLuaState();
    L.openLibs();
    int err = L.LdoFile("testMap.lua");
    if (err != 0) {
        switch(err) {
            case 1:
                System.out.println("Runtime error. " + L.toString(-1));
                break;
            case 2:
                System.out.println("File not found. " + L.toString(-1));
                break;
            case 3:
                System.out.println("Syntax error. " + L.toString(-1));
                break;
            case 4:
                System.out.println("Memory error. " + L.toString(-1));
                break;
            default:
                System.out.println("Error. " + L.toString(-1));
                break;
        }
    }
    L.getGlobal("map");
    luaMap = (Map) L.getLuaObject(-1).createProxy("java.util.Map");
    L.pop(1);
    luaMap.put("test", "testValue");
    luaMap.putAll(table);
    assertTrue(luaMap.containsKey("test"));
    assertTrue(luaMap.containsKey("testTable2-1"));
    System.out.println(luaMap.get("testTable2-2"));
    assertTrue(luaMap.containsValue("testValue"));
    assertEquals(3, luaMap.size());
    luaMap.remove("test");
    assertNull(luaMap.get("test"));
    luaMap.clear();
    assertEquals(luaMap.size(), 0);
}
Example 91
Project: lumify-master  File: ConfigurationHelper.java View source code
public static org.apache.hadoop.conf.Configuration createHadoopConfigurationFromMap(Map map) {
    org.apache.hadoop.conf.Configuration configuration = new org.apache.hadoop.conf.Configuration();
    for (Object entrySetObject : map.entrySet()) {
        Map.Entry entrySet = (Map.Entry) entrySetObject;
        configuration.set("" + entrySet.getKey(), "" + entrySet.getValue());
    }
    return configuration;
}
Example 92
Project: nate-master  File: NateTransformers.java View source code
@SuppressWarnings("unchecked")
public static NateTransformer from(Object data) {
    if (data instanceof Iterable) {
        return TransformationSequence.fromObjectSequence((Iterable) data);
    }
    if (data instanceof Map) {
        return TransformationMap.fromObjectMap((Map) data);
    }
    if (data instanceof NateDocumentBackedEngine) {
        return new EngineInjector((NateDocumentBackedEngine) data);
    }
    if (data == null) {
        return new NullDataInjector();
    }
    return new TextInjector(data.toString());
}
Example 93
Project: oauth-master  File: MapUtils.java View source code
public static <K, V> String toString(Map<K, V> map) {
    if (map == null) {
        return "";
    }
    if (map.isEmpty()) {
        return "{}";
    }
    final StringBuilder result = new StringBuilder();
    for (Map.Entry<K, V> entry : map.entrySet()) {
        result.append(", ").append(entry.getKey().toString()).append(" -> ").append(entry.getValue().toString()).append(' ');
    }
    return "{" + result.append('}').substring(1);
}
Example 94
Project: old-gosu-repo-master  File: SimplifyTypeTest.java View source code
public void testSimplifiedCollected() {
    String type = "java.util.Map<java.awt.List, java.util.List<String>>";
    Map<String, String> simplified = new LinkedHashMap<>();
    type = simplifyTypes(type, parse("import java.util.List"), simplified);
    assertEqualsNoSpaces("Map<java.awt.List, List<String>>", type);
    assertEquals(2, simplified.size());
    List<String> simple = new ArrayList<>(simplified.keySet());
    List<String> fqn = new ArrayList<>(simplified.values());
    assertEquals("List", simple.get(0));
    assertEquals("Map", simple.get(1));
    assertEquals("java.util.List", fqn.get(0));
    assertEquals("java.util.Map", fqn.get(1));
}
Example 95
Project: openpixi-master  File: Print.java View source code
public static void testResults(Map<String, Boolean> resultsMap) {
    System.out.println();
    for (String testName : resultsMap.keySet()) {
        String result = null;
        if (resultsMap.get(testName)) {
            result = "PASS";
        } else {
            result = "FAIL";
        }
        System.out.println(result + " ..... " + testName);
    }
}
Example 96
Project: otm-android-master  File: SpeciesContainer.java View source code
@Override
public Map<Integer, Species> getAll() throws JSONException {
    LinkedHashMap<Integer, Species> speciesList = new LinkedHashMap<>(data.length());
    for (int i = 0; i < data.length(); i++) {
        Species species = new Species();
        species.setData(data.getJSONObject(i));
        speciesList.put(species.getId(), species);
    }
    return speciesList;
}
Example 97
Project: parameterized-scheduler-master  File: ParameterizedTimerTriggerCauseTest.java View source code
@Test
public void happyPath() {
    Map<String, String> parameters = Maps.newHashMap();
    parameters.put("o", "v");
    ParameterizedTimerTriggerCause testObject = new ParameterizedTimerTriggerCause(parameters);
    assertEquals(Messages.ParameterizedTimerTrigger_TimerTriggerCause_ShortDescription("{o=v}"), testObject.getShortDescription());
}
Example 98
Project: Prendamigo-master  File: VerifyFactoryWithInstanceInfoTest.java View source code
@Test(dependsOnGroups = { "first" })
public void mainCheck() {
    Map<Integer, Integer> numbers = FactoryWithInstanceInfoTest2.getNumbers();
    assert null != numbers.get(new Integer(42)) : "Didn't find 42";
    assert null != numbers.get(new Integer(43)) : "Didn't find 43";
    assert 2 == numbers.size() : "Expected 2 numbers, found " + (numbers.size());
}
Example 99
Project: scribe-master  File: MapUtils.java View source code
public static <K, V> String toString(Map<K, V> map) {
    if (map == null) {
        return "";
    }
    if (map.isEmpty()) {
        return "{}";
    }
    final StringBuilder result = new StringBuilder();
    for (Map.Entry<K, V> entry : map.entrySet()) {
        result.append(", ").append(entry.getKey().toString()).append(" -> ").append(entry.getValue().toString()).append(' ');
    }
    return "{" + result.append('}').substring(1);
}
Example 100
Project: scribejava-master  File: MapUtils.java View source code
public static <K, V> String toString(Map<K, V> map) {
    if (map == null) {
        return "";
    }
    if (map.isEmpty()) {
        return "{}";
    }
    final StringBuilder result = new StringBuilder();
    for (Map.Entry<K, V> entry : map.entrySet()) {
        result.append(", ").append(entry.getKey().toString()).append(" -> ").append(entry.getValue().toString()).append(' ');
    }
    return "{" + result.append('}').substring(1);
}
Example 101
Project: SeanMovieManager-master  File: ScriptUtilitiesTest.java View source code
@Test
public void testGetScriptListByTriggerType() throws Exception {
    Map<String, Script> scriptMap = ScriptUtilities.getScriptsByTriggerType(ScriptTriggerType.OnAppStart);
    for (String name : scriptMap.keySet()) {
        System.out.println("name = " + name);
        System.out.println("scriptContent = " + scriptMap.get(name).getScriptContent());
    }
}