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
}
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();
}
}
}
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;
}
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));
}
}
}
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);
}
}
}
Aggregations