Search in sources :

Example 66 with Entry

use of java.util.Map.Entry in project jersey by jersey.

the class StringKeyIgnoreCaseMultivaluedMapAsHeadersMapTest method testEntrySet.

/**
     * Test of entrySet method, of class HeadersMap.
     */
@Test
public void testEntrySet() {
    List valuesFoo = new ArrayList();
    valuesFoo.add("foo1");
    valuesFoo.add("foo2");
    map.put("foo", valuesFoo);
    List valuesBar = new ArrayList();
    valuesBar.add("bar1");
    valuesBar.add("bar2");
    map.put("bar", valuesBar);
    Set<Entry<String, List<String>>> entrySet = map.entrySet();
    assertEquals(2, entrySet.size());
// TODO - detailed tests for the HeadersEntries methods
}
Also used : Entry(java.util.Map.Entry) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test)

Example 67 with Entry

use of java.util.Map.Entry in project che by eclipse.

the class AnnotationModelImpl method forgetLines.

// TODO evaluate: keep?
private void forgetLines(final int fromLine, final int count, final boolean checkCount) {
    // use an iterator to have remove()
    final Iterator<Entry<Annotation, Position>> iterator = this.annotations.entrySet().iterator();
    while (iterator.hasNext()) {
        final Entry<Annotation, Position> entry = iterator.next();
        final Position position = entry.getValue();
        final TextPosition textPos = docHandle.getDocument().getPositionFromIndex(position.getOffset());
        final int line = textPos.getLine();
        if (line >= fromLine && (!checkCount || line < fromLine + count)) {
            iterator.remove();
        }
    }
}
Also used : Entry(java.util.Map.Entry) TextPosition(org.eclipse.che.ide.api.editor.text.TextPosition) Position(org.eclipse.che.ide.api.editor.text.Position) TypedPosition(org.eclipse.che.ide.api.editor.text.TypedPosition) TextPosition(org.eclipse.che.ide.api.editor.text.TextPosition) Annotation(org.eclipse.che.ide.api.editor.text.annotation.Annotation)

Example 68 with Entry

use of java.util.Map.Entry in project che by eclipse.

the class Resources method makeCommittable.

/**
	 * Makes the given resources committable. Committable means that all
	 * resources are writeable and that the content of the resources hasn't
	 * changed by calling <code>validateEdit</code> for a given file on
	 * <tt>IWorkspace</tt>.
	 *
	 * @param resources the resources to be checked
	 * @param context the context passed to <code>validateEdit</code>
	 * @return IStatus status describing the method's result. If <code>status.
	 * isOK()</code> returns <code>true</code> then the add resources are
	 * committable
	 *
	 * @see org.eclipse.core.resources.IWorkspace#validateEdit(org.eclipse.core.resources.IFile[], java.lang.Object)
	 */
public static IStatus makeCommittable(IResource[] resources, Object context) {
    List readOnlyFiles = new ArrayList();
    for (int i = 0; i < resources.length; i++) {
        IResource resource = resources[i];
        if (resource.getType() == IResource.FILE && isReadOnly(resource))
            readOnlyFiles.add(resource);
    }
    if (readOnlyFiles.size() == 0)
        return Status.OK_STATUS;
    Map oldTimeStamps = createModificationStampMap(readOnlyFiles);
    IStatus status = ResourcesPlugin.getWorkspace().validateEdit((IFile[]) readOnlyFiles.toArray(new IFile[readOnlyFiles.size()]), context);
    if (!status.isOK())
        return status;
    IStatus modified = null;
    Map newTimeStamps = createModificationStampMap(readOnlyFiles);
    for (Iterator iter = oldTimeStamps.entrySet().iterator(); iter.hasNext(); ) {
        Map.Entry entry = (Entry) iter.next();
        if (!entry.getValue().equals(newTimeStamps.get(entry.getKey())))
            modified = addModified(modified, (IFile) entry.getKey());
    }
    if (modified != null)
        return modified;
    return Status.OK_STATUS;
}
Also used : Entry(java.util.Map.Entry) IStatus(org.eclipse.core.runtime.IStatus) Entry(java.util.Map.Entry) IFile(org.eclipse.core.resources.IFile) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) IResource(org.eclipse.core.resources.IResource)

Example 69 with Entry

use of java.util.Map.Entry in project che by eclipse.

the class RefactoringHistoryManager method checkArgumentMap.

/**
	 * Checks whether the argument map is well-formed.
	 * <p>
	 * All arguments contained in the map are checked according to the rules of
	 * {@link RefactoringDescriptor}.
	 * </p>
	 *
	 * @param arguments
	 *            the argument map
	 * @throws CoreException
	 *             if the argument violates any of the constraints
	 */
public static void checkArgumentMap(final Map arguments) throws CoreException {
    Assert.isNotNull(arguments);
    for (final Iterator iterator = arguments.entrySet().iterator(); iterator.hasNext(); ) {
        final Map.Entry entry = (Map.Entry) iterator.next();
        if (entry.getKey() instanceof String) {
            final String string = (String) entry.getKey();
            final char[] characters = string.toCharArray();
            if (characters.length == 0) {
                throw new CoreException(new Status(IStatus.ERROR, RefactoringCore.ID_PLUGIN, IRefactoringCoreStatusCodes.REFACTORING_HISTORY_FORMAT_ERROR, RefactoringCoreMessages.RefactoringHistoryManager_empty_argument, null));
            }
            for (int index = 0; index < characters.length; index++) {
                if (Character.isWhitespace(characters[index]))
                    throw new CoreException(new Status(IStatus.ERROR, RefactoringCore.ID_PLUGIN, IRefactoringCoreStatusCodes.REFACTORING_HISTORY_FORMAT_ERROR, RefactoringCoreMessages.RefactoringHistoryManager_whitespace_argument_key, null));
            }
        } else {
            throw new CoreException(new Status(IStatus.ERROR, RefactoringCore.ID_PLUGIN, IRefactoringCoreStatusCodes.REFACTORING_HISTORY_FORMAT_ERROR, Messages.format(RefactoringCoreMessages.RefactoringHistoryManager_non_string_argument, entry.getKey()), null));
        }
        if (!(entry.getValue() instanceof String)) {
            throw new CoreException(new Status(IStatus.ERROR, RefactoringCore.ID_PLUGIN, IRefactoringCoreStatusCodes.REFACTORING_HISTORY_FORMAT_ERROR, Messages.format(RefactoringCoreMessages.RefactoringHistoryManager_non_string_value, entry.getKey()), null));
        }
    }
}
Also used : Entry(java.util.Map.Entry) MultiStatus(org.eclipse.core.runtime.MultiStatus) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) Entry(java.util.Map.Entry) CoreException(org.eclipse.core.runtime.CoreException) Iterator(java.util.Iterator) Map(java.util.Map) HashMap(java.util.HashMap) NamedNodeMap(org.w3c.dom.NamedNodeMap)

Example 70 with Entry

use of java.util.Map.Entry in project che by eclipse.

the class FileWatcherByPathMatcher method unwatch.

void unwatch(int operationId) {
    LOG.debug("Unwatching matcher operation set with id '{}'", operationId);
    for (Entry<PathMatcher, Set<Integer>> entry : matchers.entrySet()) {
        PathMatcher matcher = entry.getKey();
        Set<Integer> operationsIdList = entry.getValue();
        Iterator<Integer> iterator = operationsIdList.iterator();
        while (iterator.hasNext()) {
            if (iterator.next() == operationId) {
                pathWatchRegistrations.keySet().stream().filter(matcher::matches).flatMap(it -> pathWatchRegistrations.remove(it).stream()).forEach(watcher::unwatch);
                paths.values().forEach(it -> it.removeIf(matcher::matches));
                paths.entrySet().removeIf(it -> it.getValue().isEmpty());
                iterator.remove();
                operations.remove(operationId);
                break;
            }
        }
        if (matchers.get(matcher) == null || matchers.get(matcher).isEmpty()) {
            matchers.remove(matcher);
        }
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) Inject(com.google.inject.Inject) LoggerFactory(org.slf4j.LoggerFactory) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Sets.newConcurrentHashSet(com.google.common.collect.Sets.newConcurrentHashSet) Set(java.util.Set) Singleton(javax.inject.Singleton) Consumer(java.util.function.Consumer) Files.exists(java.nio.file.Files.exists) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Map(java.util.Map) PathMatcher(java.nio.file.PathMatcher) Entry(java.util.Map.Entry) Path(java.nio.file.Path) PathMatcher(java.nio.file.PathMatcher) Sets.newConcurrentHashSet(com.google.common.collect.Sets.newConcurrentHashSet) Set(java.util.Set)

Aggregations

Entry (java.util.Map.Entry)2862 Map (java.util.Map)804 HashMap (java.util.HashMap)786 ArrayList (java.util.ArrayList)749 List (java.util.List)579 IOException (java.io.IOException)314 Iterator (java.util.Iterator)311 Test (org.junit.Test)308 Set (java.util.Set)294 HashSet (java.util.HashSet)271 LinkedHashMap (java.util.LinkedHashMap)194 Collection (java.util.Collection)186 Collectors (java.util.stream.Collectors)179 File (java.io.File)146 TreeMap (java.util.TreeMap)125 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)114 Key (org.apache.accumulo.core.data.Key)112 Value (org.apache.accumulo.core.data.Value)111 Collections (java.util.Collections)104 LinkedList (java.util.LinkedList)103