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: RoboBuggy-master  File: IsMapContaining.java View source code
@Override
public boolean matchesSafely(Map<? extends K, ? extends V> map) {
    for (Entry<? extends K, ? extends V> entry : map.entrySet()) {
        if (keyMatcher.matches(entry.getKey()) && valueMatcher.matches(entry.getValue())) {
            return true;
        }
    }
    return false;
}
Example 2
Project: hibernate-core-ogm-master  File: CollectionSecondPass.java View source code
public void doSecondPass(java.util.Map persistentClasses) throws MappingException {
    LOG.debugf("Second pass for collection: %s", collection.getRole());
    // using local since the inheritedMetas at this point is not the correct map since it is always the empty map
    secondPass(persistentClasses, localInheritedMetas);
    collection.createAllKeys();
    if (LOG.isDebugEnabled()) {
        String msg = "Mapped collection key: " + columns(collection.getKey());
        if (collection.isIndexed())
            msg += ", index: " + columns(((IndexedCollection) collection).getIndex());
        if (collection.isOneToMany()) {
            msg += ", one-to-many: " + ((OneToMany) collection.getElement()).getReferencedEntityName();
        } else {
            msg += ", element: " + columns(collection.getElement());
        }
        LOG.debugf(msg);
    }
}
Example 3
Project: clinic-softacad-master  File: CollectionSecondPass.java View source code
public void doSecondPass(java.util.Map persistentClasses) throws MappingException {
    LOG.debugf("Second pass for collection: %s", collection.getRole());
    // using local since the inheritedMetas at this point is not the correct map since it is always the empty map
    secondPass(persistentClasses, localInheritedMetas);
    collection.createAllKeys();
    if (LOG.isDebugEnabled()) {
        String msg = "Mapped collection key: " + columns(collection.getKey());
        if (collection.isIndexed())
            msg += ", index: " + columns(((IndexedCollection) collection).getIndex());
        if (collection.isOneToMany()) {
            msg += ", one-to-many: " + ((OneToMany) collection.getElement()).getReferencedEntityName();
        } else {
            msg += ", element: " + columns(collection.getElement());
        }
        LOG.debug(msg);
    }
}
Example 4
Project: eclipselink.runtime-master  File: ClassToolsTests.java View source code
public void testClassNamedIsTopLevel() throws Exception {
    // top-level
    assertTrue(ClassTools.classNamedIsTopLevel(java.util.Map.class.getName()));
    // member
    assertFalse(ClassTools.classNamedIsTopLevel(java.util.Map.Entry.class.getName()));
    // local
    assertFalse(ClassTools.classNamedIsTopLevel(Class.forName(munge(this.getClass().getName() + "$1$LocalClass")).getName()));
    // anonymous
    assertFalse(ClassTools.classNamedIsTopLevel(Class.forName("java.util.Vector$1").getName()));
    // top-level
    Object[] array = new java.util.Map[0];
    assertFalse(ClassTools.classNamedIsTopLevel(array.getClass().getName()));
    // member
    array = new java.util.Map.Entry[0];
    assertFalse(ClassTools.classNamedIsTopLevel(array.getClass().getName()));
    // local
    Class localClass = Class.forName(munge(this.getClass().getName() + "$1$LocalClass"));
    array = (Object[]) Array.newInstance(localClass, 0);
    assertFalse(ClassTools.classNamedIsTopLevel(array.getClass().getName()));
    // local
    Class anonClass = Class.forName("java.util.Vector$1");
    array = (Object[]) Array.newInstance(anonClass, 0);
    assertFalse(ClassTools.classNamedIsTopLevel(array.getClass().getName()));
}
Example 5
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 6
Project: ecms-develop-master  File: CanEditDocFilter.java View source code
/* (non-Javadoc)
   * @see org.exoplatform.webui.ext.filter.UIExtensionFilter#accept(java.util.Map)
   */
@Override
public boolean accept(Map<String, Object> context) throws Exception {
    if (context == null)
        return true;
    Node currentNode = (Node) context.get(Node.class.getName());
    if (!WCMCoreUtils.canAccessParentNode(currentNode))
        return false;
    return PermissionUtil.canAddNode(currentNode.getParent());
}
Example 7
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 8
Project: liferay-apps-content-targeting-master  File: CampaignServiceClpInvoker.java View source code
public Object invokeMethod(String name, String[] parameterTypes, Object[] arguments) throws Throwable {
    if (_methodName48.equals(name) && Arrays.deepEquals(_methodParameterTypes48, parameterTypes)) {
        return CampaignServiceUtil.getBeanIdentifier();
    }
    if (_methodName49.equals(name) && Arrays.deepEquals(_methodParameterTypes49, parameterTypes)) {
        CampaignServiceUtil.setBeanIdentifier((java.lang.String) arguments[0]);
        return null;
    }
    if (_methodName54.equals(name) && Arrays.deepEquals(_methodParameterTypes54, parameterTypes)) {
        return CampaignServiceUtil.addCampaign(((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], (java.util.Date) arguments[3], (java.util.Date) arguments[4], ((Integer) arguments[5]).intValue(), ((Boolean) arguments[6]).booleanValue(), (long[]) arguments[7], (com.liferay.portal.service.ServiceContext) arguments[8]);
    }
    if (_methodName55.equals(name) && Arrays.deepEquals(_methodParameterTypes55, parameterTypes)) {
        return CampaignServiceUtil.deleteCampaign(((Long) arguments[0]).longValue());
    }
    if (_methodName56.equals(name) && Arrays.deepEquals(_methodParameterTypes56, parameterTypes)) {
        return CampaignServiceUtil.fetchCurrentMaxPriorityCampaign((long[]) arguments[0], (long[]) arguments[1]);
    }
    if (_methodName57.equals(name) && Arrays.deepEquals(_methodParameterTypes57, parameterTypes)) {
        return CampaignServiceUtil.getCampaigns(((Long) arguments[0]).longValue());
    }
    if (_methodName58.equals(name) && Arrays.deepEquals(_methodParameterTypes58, parameterTypes)) {
        return CampaignServiceUtil.getCampaignsCount(((Long) arguments[0]).longValue());
    }
    if (_methodName59.equals(name) && Arrays.deepEquals(_methodParameterTypes59, parameterTypes)) {
        return CampaignServiceUtil.updateCampaign(((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], (java.util.Date) arguments[3], (java.util.Date) arguments[4], ((Integer) arguments[5]).intValue(), ((Boolean) arguments[6]).booleanValue(), (long[]) arguments[7], (com.liferay.portal.service.ServiceContext) arguments[8]);
    }
    throw new UnsupportedOperationException();
}
Example 9
Project: aws-sdk-android-master  File: QueryRequestMarshaller.java View source code
public Request<QueryRequest> marshall(QueryRequest queryRequest) {
    if (queryRequest == null) {
        throw new AmazonClientException("Invalid argument passed to marshall(QueryRequest)");
    }
    Request<QueryRequest> request = new DefaultRequest<QueryRequest>(queryRequest, "AmazonDynamoDB");
    String target = "DynamoDB_20120810.Query";
    request.addHeader("X-Amz-Target", target);
    request.setHttpMethod(HttpMethodName.POST);
    String uriResourcePath = "/";
    request.setResourcePath(uriResourcePath);
    try {
        StringWriter stringWriter = new StringWriter();
        AwsJsonWriter jsonWriter = JsonUtils.getJsonWriter(stringWriter);
        jsonWriter.beginObject();
        if (queryRequest.getTableName() != null) {
            String tableName = queryRequest.getTableName();
            jsonWriter.name("TableName");
            jsonWriter.value(tableName);
        }
        if (queryRequest.getIndexName() != null) {
            String indexName = queryRequest.getIndexName();
            jsonWriter.name("IndexName");
            jsonWriter.value(indexName);
        }
        if (queryRequest.getSelect() != null) {
            String select = queryRequest.getSelect();
            jsonWriter.name("Select");
            jsonWriter.value(select);
        }
        if (queryRequest.getAttributesToGet() != null) {
            java.util.List<String> attributesToGet = queryRequest.getAttributesToGet();
            jsonWriter.name("AttributesToGet");
            jsonWriter.beginArray();
            for (String attributesToGetItem : attributesToGet) {
                if (attributesToGetItem != null) {
                    jsonWriter.value(attributesToGetItem);
                }
            }
            jsonWriter.endArray();
        }
        if (queryRequest.getLimit() != null) {
            Integer limit = queryRequest.getLimit();
            jsonWriter.name("Limit");
            jsonWriter.value(limit);
        }
        if (queryRequest.getConsistentRead() != null) {
            Boolean consistentRead = queryRequest.getConsistentRead();
            jsonWriter.name("ConsistentRead");
            jsonWriter.value(consistentRead);
        }
        if (queryRequest.getKeyConditions() != null) {
            java.util.Map<String, Condition> keyConditions = queryRequest.getKeyConditions();
            jsonWriter.name("KeyConditions");
            jsonWriter.beginObject();
            for (java.util.Map.Entry<String, Condition> keyConditionsEntry : keyConditions.entrySet()) {
                Condition keyConditionsValue = keyConditionsEntry.getValue();
                if (keyConditionsValue != null) {
                    jsonWriter.name(keyConditionsEntry.getKey());
                    ConditionJsonMarshaller.getInstance().marshall(keyConditionsValue, jsonWriter);
                }
            }
            jsonWriter.endObject();
        }
        if (queryRequest.getQueryFilter() != null) {
            java.util.Map<String, Condition> queryFilter = queryRequest.getQueryFilter();
            jsonWriter.name("QueryFilter");
            jsonWriter.beginObject();
            for (java.util.Map.Entry<String, Condition> queryFilterEntry : queryFilter.entrySet()) {
                Condition queryFilterValue = queryFilterEntry.getValue();
                if (queryFilterValue != null) {
                    jsonWriter.name(queryFilterEntry.getKey());
                    ConditionJsonMarshaller.getInstance().marshall(queryFilterValue, jsonWriter);
                }
            }
            jsonWriter.endObject();
        }
        if (queryRequest.getConditionalOperator() != null) {
            String conditionalOperator = queryRequest.getConditionalOperator();
            jsonWriter.name("ConditionalOperator");
            jsonWriter.value(conditionalOperator);
        }
        if (queryRequest.getScanIndexForward() != null) {
            Boolean scanIndexForward = queryRequest.getScanIndexForward();
            jsonWriter.name("ScanIndexForward");
            jsonWriter.value(scanIndexForward);
        }
        if (queryRequest.getExclusiveStartKey() != null) {
            java.util.Map<String, AttributeValue> exclusiveStartKey = queryRequest.getExclusiveStartKey();
            jsonWriter.name("ExclusiveStartKey");
            jsonWriter.beginObject();
            for (java.util.Map.Entry<String, AttributeValue> exclusiveStartKeyEntry : exclusiveStartKey.entrySet()) {
                AttributeValue exclusiveStartKeyValue = exclusiveStartKeyEntry.getValue();
                if (exclusiveStartKeyValue != null) {
                    jsonWriter.name(exclusiveStartKeyEntry.getKey());
                    AttributeValueJsonMarshaller.getInstance().marshall(exclusiveStartKeyValue, jsonWriter);
                }
            }
            jsonWriter.endObject();
        }
        if (queryRequest.getReturnConsumedCapacity() != null) {
            String returnConsumedCapacity = queryRequest.getReturnConsumedCapacity();
            jsonWriter.name("ReturnConsumedCapacity");
            jsonWriter.value(returnConsumedCapacity);
        }
        if (queryRequest.getProjectionExpression() != null) {
            String projectionExpression = queryRequest.getProjectionExpression();
            jsonWriter.name("ProjectionExpression");
            jsonWriter.value(projectionExpression);
        }
        if (queryRequest.getFilterExpression() != null) {
            String filterExpression = queryRequest.getFilterExpression();
            jsonWriter.name("FilterExpression");
            jsonWriter.value(filterExpression);
        }
        if (queryRequest.getKeyConditionExpression() != null) {
            String keyConditionExpression = queryRequest.getKeyConditionExpression();
            jsonWriter.name("KeyConditionExpression");
            jsonWriter.value(keyConditionExpression);
        }
        if (queryRequest.getExpressionAttributeNames() != null) {
            java.util.Map<String, String> expressionAttributeNames = queryRequest.getExpressionAttributeNames();
            jsonWriter.name("ExpressionAttributeNames");
            jsonWriter.beginObject();
            for (java.util.Map.Entry<String, String> expressionAttributeNamesEntry : expressionAttributeNames.entrySet()) {
                String expressionAttributeNamesValue = expressionAttributeNamesEntry.getValue();
                if (expressionAttributeNamesValue != null) {
                    jsonWriter.name(expressionAttributeNamesEntry.getKey());
                    jsonWriter.value(expressionAttributeNamesValue);
                }
            }
            jsonWriter.endObject();
        }
        if (queryRequest.getExpressionAttributeValues() != null) {
            java.util.Map<String, AttributeValue> expressionAttributeValues = queryRequest.getExpressionAttributeValues();
            jsonWriter.name("ExpressionAttributeValues");
            jsonWriter.beginObject();
            for (java.util.Map.Entry<String, AttributeValue> expressionAttributeValuesEntry : expressionAttributeValues.entrySet()) {
                AttributeValue expressionAttributeValuesValue = expressionAttributeValuesEntry.getValue();
                if (expressionAttributeValuesValue != null) {
                    jsonWriter.name(expressionAttributeValuesEntry.getKey());
                    AttributeValueJsonMarshaller.getInstance().marshall(expressionAttributeValuesValue, jsonWriter);
                }
            }
            jsonWriter.endObject();
        }
        jsonWriter.endObject();
        jsonWriter.close();
        String snippet = stringWriter.toString();
        byte[] content = snippet.getBytes(UTF8);
        request.setContent(new StringInputStream(snippet));
        request.addHeader("Content-Length", Integer.toString(content.length));
    } catch (Throwable t) {
        throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }
    if (!request.getHeaders().containsKey("Content-Type")) {
        request.addHeader("Content-Type", "application/x-amz-json-1.0");
    }
    return request;
}
Example 10
Project: dcache-master  File: NamedCellUtil.java View source code
public static String findDomainOfUniqueCell(Map<String, List<String>> domains, String cell) {
    String domain = "";
    for (Map.Entry<String, List<String>> entry : domains.entrySet()) {
        if (entry.getValue().contains(cell)) {
            domain = entry.getKey();
            break;
        }
    }
    return domain;
}
Example 11
Project: extFM-Tooling-master  File: MtextMapUtil.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 12
Project: xapi-master  File: TestsFailed.java View source code
private static String serialize(Map<Method, Throwable> result) {
    StringBuilder pass = new StringBuilder();
    StringBuilder fail = new StringBuilder("\n");
    for (Entry<Method, Throwable> e : result.entrySet()) {
        if (e.getValue() == null) {
            pass.append(e.getKey().getName()).append("\n (pass)");
        } else {
            fail.append(e.getKey().getName()).append("\n (FAIL):");
            print(fail, e.getValue());
        }
    }
    return fail.append(pass).toString();
}
Example 13
Project: sosies-generator-master  File: MapAsArrayTypeAdapterTest.java View source code
@Test(timeout = 1000)
public void testSerializeComplexMapWithTypeAdapter_add1210() {
    fr.inria.diversify.testamplification.logger.Logger.writeTestStart(Thread.currentThread(), this, "testSerializeComplexMapWithTypeAdapter_add1210");
    Type type = new TypeToken<java.util.Map<Point, java.lang.String>>() {
    }.getType();
    Gson gson = new GsonBuilder().enableComplexMapKeySerialization().create();
    Map<Point, java.lang.String> original = new LinkedHashMap<Point, java.lang.String>();
    original.put(new Point(5, 5), "a");
    original.put(new Point(8, 8), "b");
    String json = gson.toJson(original, type);
    fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(), 1731, json);
    fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(), 1732, original);
    fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(), 1734, gson, 1733, gson.<java.util.Map<com.google.gson.functional.MapAsArrayTypeAdapterTest.Point, java.lang.String>>fromJson(json, type));
    Map<java.lang.String, java.lang.Boolean> otherMap = new LinkedHashMap<java.lang.String, java.lang.Boolean>();
    otherMap.put("t", true);
    otherMap.put("f", false);
    fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(), 1736, gson, 1735, gson.toJson(otherMap, java.util.Map.class));
    fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(), 1738, gson, 1737, gson.toJson(otherMap, new com.google.gson.reflect.TypeToken<java.util.Map<java.lang.String, java.lang.Boolean>>() {
    }.getType()));
    fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(), 1739, otherMap);
    fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(), 1741, gson, 1740, gson.<java.lang.Object>fromJson("{\"t\":true,\"f\":false}", new com.google.gson.reflect.TypeToken<java.util.Map<java.lang.String, java.lang.Boolean>>() {
    }.getType()));
    fr.inria.diversify.testamplification.logger.Logger.writeTestFinish(Thread.currentThread());
}
Example 14
Project: gatein-portal-master  File: AttributesState.java View source code
public AttributesState.Builder attributes(Map<? extends String, ? extends String> attributes) {
    if (attributes != null) {
        if (attributes.size() > 0) {
            if (map == null) {
                int attributesSize = attributes.size();
                map = new HashMap<String, String>(attributesSize + attributesSize / 2);
            }
            for (Map.Entry<? extends String, ? extends String> en : attributes.entrySet()) {
                if (en.getValue() == null) {
                    /* here we follow what is in SimpleAttributes */
                    map.remove(en.getKey());
                } else {
                    map.put(en.getKey(), en.getValue());
                }
            }
        }
    }
    return this;
}
Example 15
Project: google-web-toolkit-svnmirror-master  File: TreeMapTest.java View source code
/**
   * Verify that two Maps are deeply equivalent.
   * 
   * @param expected
   * @param actual
   */
private static <K, V> void _assertEquals(Map<K, V> expected, Map<K, V> actual) {
    assertEquals(expected.isEmpty(), actual.isEmpty());
    assertEquals(expected.size(), actual.size());
    _assertEquals(expected.keySet(), actual.keySet());
    _assertEquals(expected.entrySet(), actual.entrySet());
    // One might think that the following would true:
    // assertEquals(expected.values(), actual.values());
    // The following verifies what i would perceive as a bug in the jre
    // (rlo). The implementation of the Collection returned by the values method
    // does not implement equals sensibly.
    assertFalse(expected.values().equals(actual.values()));
    _assertEquals(expected.values(), actual.values());
}
Example 16
Project: DrakkarKeel-master  File: AuthenticationPrxHelper.java View source code
private void sendAMID(byte[] request, java.util.Map<String, String> __ctx, boolean __explicitCtx) throws drakkar.oar.slice.error.RequestException {
    if (__explicitCtx && __ctx == null) {
        __ctx = _emptyContext;
    }
    int __cnt = 0;
    while (true) {
        Ice._ObjectDel __delBase = null;
        try {
            __checkTwowayOnly("sendAMID");
            __delBase = __getDelegate(false);
            _AuthenticationDel __del = (_AuthenticationDel) __delBase;
            __del.sendAMID(request, __ctx);
            return;
        } catch (IceInternal.LocalExceptionWrapper __ex) {
            __handleExceptionWrapper(__delBase, __ex);
        } catch (Ice.LocalException __ex) {
            __cnt = __handleException(__delBase, __ex, null, __cnt);
        }
    }
}
Example 17
Project: Magnolia-master  File: NodeMapWrapper.java View source code
/**
     * @see java.util.Map#entrySet()
     */
@Override
public Set entrySet() {
    Collection<NodeData> nodeDataCollection = getWrappedContent().getNodeDataCollection();
    Set<Map.Entry> keys = new HashSet<Map.Entry>();
    for (Iterator<NodeData> iter = nodeDataCollection.iterator(); iter.hasNext(); ) {
        NodeData nd = iter.next();
        final String key = nd.getName();
        final String value = nd.getString();
        keys.add(new Map.Entry() {

            @Override
            public Object getKey() {
                return key;
            }

            @Override
            public Object getValue() {
                return value;
            }

            @Override
            public Object setValue(Object value) {
                return value;
            }
        });
    }
    return keys;
}
Example 18
Project: tdq-studio-se-master  File: DBMap.java View source code
/*
     * (non-Javadoc)
     * 
     * @see org.talend.dataquality.indicators.mapdb.AbstractDB#subList(long, long, java.util.Map,
     * org.talend.cwm.indicator.DataValidation)
     */
@Override
public List<Object[]> subList(long fromIndex, long toIndex, Map<Long, K> indexMap, DataValidation dataValiator) {
    boolean stratToRecord = false;
    List<Object[]> returnList = new ArrayList<Object[]>();
    if (!checkIndex(fromIndex, toIndex)) {
        return returnList;
    }
    K fromKey = null;
    K toKey = null;
    if (indexMap != null) {
        fromKey = indexMap.get(fromIndex);
        toKey = indexMap.get(toIndex);
    }
    Iterator<K> iterator = null;
    long index = 0l;
    if (fromKey == null) {
        iterator = this.iterator();
    } else if (toKey == null) {
        NavigableSet<K> tailSet = tailSet(fromKey, true);
        index = fromIndex;
        iterator = tailSet.iterator();
    } else {
        NavigableSet<K> tailSet = subSet(fromKey, toKey);
        index = fromIndex;
        iterator = tailSet.iterator();
    }
    while (iterator.hasNext()) {
        K next = iterator.next();
        if (dataValiator != null) {
            V v = this.get(next);
            if (!dataValiator.isValid(v)) {
                continue;
            }
        }
        if (index == 0 && fromKey == null && indexMap != null) {
            indexMap.put(0l, next);
        }
        if (index == fromIndex) {
            stratToRecord = true;
        }
        if (index == toIndex) {
            if (toKey == null && indexMap != null) {
                indexMap.put(toIndex, next);
            }
            break;
        }
        if (stratToRecord == true) {
            V v = this.get(next);
            if (v.getClass().isArray()) {
                returnList.add((Object[]) v);
            } else if (List.class.isInstance(v)) {
                returnList.add(((List<?>) v).toArray());
            } else {
                returnList.add(new Object[] { v });
            }
        }
        index++;
    }
    return returnList;
}
Example 19
Project: WS171-development-master  File: ClassSourcerTest.java View source code
@Test
public void testTemplateClassSource() throws Exception {
    StringWriter sw = new StringWriter();
    ClassReader cr = new ClassReader("data/TestTemplateClass");
    ClassSourcer jw = new ClassSourcer(new Output(sw));
    cr.accept(jw, 0);
    assertSourceEquals("package data;\n" + "public class TestTemplateClass<T extends java.io.InputStream, U extends java.lang.Object> extends java.lang.Object {\n" + "    private final java.util.Map<T, U> mMap_T_U;\n" + "    public java.util.Map<java.util.ArrayList<T>, java.util.Map<java.lang.String, java.util.ArrayList<U>>> mMap_T_S_U;\n" + "    public TestTemplateClass() {\n" + "        throw new RuntimeException(\"Stub\");\n" + "    }\n" + "    public java.util.Map<T, U> getMap_T_U() {\n" + "        throw new RuntimeException(\"Stub\");\n" + "    }\n" + "    public java.util.Map<java.util.ArrayList<T>, java.util.Map<java.lang.String, java.util.ArrayList<U>>> getMap_T_S_U() {\n" + "        throw new RuntimeException(\"Stub\");\n" + "    }\n" + "    public void draw(java.util.List<? extends org.w3c.dom.css.Rect> arg0) {\n" + "        throw new RuntimeException(\"Stub\");\n" + "    }\n" + "    public static <T extends java.lang.Comparable<? super T>> void sort(java.util.List<T> arg0) {\n" + "        throw new RuntimeException(\"Stub\");\n" + "    }\n" + "    public <X extends T, Y extends java.lang.Object> void getMap(java.util.List<T> arg0, java.util.Map<T, U> arg1, java.util.Map<X, java.util.Set<? super Y>> arg2) {\n" + "        throw new RuntimeException(\"Stub\");\n" + "    }\n" + "}", sw.toString());
}
Example 20
Project: Restlib-master  File: JSONRestRequest.java View source code
@Override
public boolean setContent(HashMap<String, Object> data) {
    if (this.getMethod() == RestRequest.GET_METHOD)
        buildGetURI(data);
    try {
        JSONStringer holder = new JSONStringer().object();
        Iterator<Entry<String, Object>> it = data.entrySet().iterator();
        while (it.hasNext()) {
            Map.Entry<String, Object> e = it.next();
            holder.key(e.getKey().toString()).value(e.getValue());
        }
        holder.endObject();
        content = holder.toString();
    } catch (Exception e) {
        return false;
    }
    return true;
}
Example 21
Project: dk-master  File: PaginationCallback.java View source code
public Pagination<T> getPage(List<Map<String, Object>> datas, Pagination<T> page) {
    int size = datas.size();
    List<T> results = new ArrayList<T>(size);
    for (int i = 0; i < size; i++) {
        Map<String, Object> data = datas.get(i);
        results.add(toCustomizedBean(data));
    }
    page.setRows(results);
    return page;
}
Example 22
Project: FreeBuilder-master  File: ImportManagerTest.java View source code
@Test
public void testTypeMirrorShortening() {
    ImportManager manager = new ImportManager.Builder().build();
    assertEquals("String", manager.shorten(newTopLevelClass("java.lang.String")));
    assertEquals("List", manager.shorten(newTopLevelClass("java.util.List")));
    assertEquals("java.awt.List", manager.shorten(newTopLevelClass("java.awt.List")));
    ClassTypeImpl mapType = newTopLevelClass("java.util.Map");
    assertEquals("Map", manager.shorten(mapType));
    assertEquals("Map.Entry", manager.shorten(newNestedClass(mapType.asElement(), "Entry")));
    assertThat(manager.getClassImports()).containsExactly("java.util.List", "java.util.Map").inOrder();
}
Example 23
Project: geotools-old-master  File: sldComplexTypes.java View source code
public Object getValue(Element element, ElementValue[] value, Attributes attrs1, Map hints) throws OperationNotSupportedException, SAXException {
    ContrastEnhancement symbol = new ContrastEnhancementImpl();
    for (int i = 0; i < value.length; i++) {
        if ((value[i] == null) || value[i].getElement() == null) {
            continue;
        }
        Element e = value[i].getElement();
        if (elems[NORMALIZE].getName().equals(e.getName()))
            // (Graphic)value[i].getValue()
            symbol.setNormalize();
        if (elems[HISTORGRAM].getName().equals(e.getName()))
            // (Graphic)value[i].getValue()
            symbol.setHistogram();
        if (elems[GAMMAVALUE].getName().equals(e.getName())) {
            symbol.setGammaValue(FilterFactoryFinder.createFilterFactory().createLiteralExpression(((Double) value[i].getValue()).doubleValue()));
        }
    }
    return symbol;
}
Example 24
Project: org.openntf.domino-master  File: DominoDocumentMapAdapter.java View source code
@Override
public Iterator<java.util.Map.Entry<String, Object>> iterator() {
    final Iterator<String> keyIt = keySet().iterator();
    return new Iterator<Map.Entry<String, Object>>() {

        private String currentKey;

        @Override
        public boolean hasNext() {
            return keyIt.hasNext();
        }

        @Override
        public java.util.Map.Entry<String, Object> next() {
            currentKey = keyIt.next();
            final String key = currentKey;
            return new java.util.Map.Entry<String, Object>() {

                @Override
                public String getKey() {
                    return key;
                }

                @Override
                public Object getValue() {
                    return get(key);
                }

                @Override
                public Object setValue(final Object value) {
                    return put(key, value);
                }
            };
        }

        @Override
        public void remove() {
            DominoDocumentMapAdapter.this.remove(currentKey);
        }
    };
}
Example 25
Project: teiid-designer-master  File: PasteContributor.java View source code
// ===========================================================================================================================
// Controller Methods
/**
     * @see org.teiid.designer.core.metamodel.IPasteContributor#contribute(java.util.Map, java.lang.String)
     * @since 4.3.2
     */
@Override
public void contribute(final Map map, final String uri) {
    // Contribute if pasting into an XML Document model
    if (XmlDocumentPackage.eNS_URI.equals(uri)) {
        // Create UUID map for copied objects
        final Map uuidMap = new HashMap(map.size());
        for (final Iterator iter = map.entrySet().iterator(); iter.hasNext(); ) {
            final Entry entry = (Entry) iter.next();
            final Object obj = entry.getKey();
            if (obj instanceof EObject) {
                uuidMap.put(ModelerCore.getObjectIdString((EObject) obj), ModelerCore.getObjectIdString((EObject) entry.getValue()));
            }
        }
        // Replace UUID's of clipboard objects in pasted object choice criteria with UUID's of corresponding pasted objects
        for (final Iterator iter = map.entrySet().iterator(); iter.hasNext(); ) {
            final Entry entry = (Entry) iter.next();
            final Object obj = entry.getValue();
            if (obj instanceof XmlElement) {
                final XmlElement pastedElem = (XmlElement) obj;
                final String criteria = pastedElem.getChoiceCriteria();
                if (criteria != null) {
                    final StringBuffer newCriteria = new StringBuffer();
                    int startNdx = 0;
                    int uuidNdx = criteria.indexOf(UUID.PROTOCOL);
                    while (uuidNdx >= 0) {
                        newCriteria.append(criteria.substring(startNdx, uuidNdx));
                        final int endNdx = uuidNdx + UUID.FQ_LENGTH;
                        final String uuid = criteria.substring(uuidNdx, endNdx);
                        final String pastedUuid = (String) uuidMap.get(uuid);
                        if (pastedUuid == null) {
                            // Must be either not one of the pasted objects or an invalid UUID to begin with
                            newCriteria.append(uuid);
                        } else {
                            newCriteria.append(pastedUuid);
                        }
                        startNdx = endNdx;
                        uuidNdx = criteria.indexOf(UUID.PROTOCOL, startNdx);
                    }
                    newCriteria.append(criteria.substring(startNdx));
                    pastedElem.setChoiceCriteria(newCriteria.toString());
                }
            }
        }
    }
}