Java Code Examples for java.util.List.iterator()

The following are Jave code examples for showing how to use iterator() of the java.util.List class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: Flubber   File: MainActivity.java   View Source Code Vote up 9 votes
private AnimatorSet buildSetForBodies(List<CustomAnimationBody> animations, View view) {
    final AnimatorSet animatorSet = new AnimatorSet();

    if (animations.size() > 0) {
        final Iterator<CustomAnimationBody> iterator = animations.iterator();

        final AnimatorSet.Builder builder =
                animatorSet.play(iterator.next().createFor(view));

        while (iterator.hasNext()) {
            builder.with(iterator.next().createFor(view));
        }
    }

    return animatorSet;
}
 
Example 2
Project: incubator-netbeans   File: NbCollections.java   View Source Code Vote up 7 votes
/**
 * Create a typesafe copy of a raw list.
 * @param rawList an unchecked list
 * @param type the desired supertype of the entries
 * @param strict true to throw a <code>ClassCastException</code> if the raw list has an invalid entry,
 *               false to skip over such entries (warnings may be logged)
 * @return a typed list guaranteed to contain only entries assignable
 *         to the named type (or they may be null)
 * @throws ClassCastException if some entry in the raw list was not well-typed, and only if <code>strict</code> was true
 */
public static <E> List<E> checkedListByCopy(List rawList, Class<E> type, boolean strict) throws ClassCastException {
    List<E> l = (rawList instanceof RandomAccess) ? new ArrayList<E>(rawList.size()) : new LinkedList<E>();
    Iterator it = rawList.iterator();
    while (it.hasNext()) {
        Object e = it.next();
        try {
            l.add(type.cast(e));
        } catch (ClassCastException x) {
            if (strict) {
                throw x;
            } else {
                LOG.log(Level.WARNING, "Element {0} not assignable to {1}", new Object[] {e, type});
            }
        }
    }
    return l;
}
 
Example 3
Project: lams   File: Handshake.java   View Source Code Vote up 6 votes
protected final void selectExtensions(final WebSocketHttpExchange exchange) {
    List<WebSocketExtension> requestedExtensions = WebSocketExtension.parse(exchange.getRequestHeader(Headers.SEC_WEB_SOCKET_EXTENSIONS_STRING));
    List<WebSocketExtension> extensions = selectedExtension(requestedExtensions);
    if (extensions != null && !extensions.isEmpty()) {
        StringBuilder sb = new StringBuilder();
        Iterator<WebSocketExtension> it = extensions.iterator();
        while (it.hasNext()) {
            WebSocketExtension next = it.next();
            sb.append(next.getName());
            for (WebSocketExtension.Parameter param : next.getParameters()) {
                sb.append("; ");
                sb.append(param.getName());
                sb.append("=");
                sb.append(param.getValue());
            }
            if (it.hasNext()) {
                sb.append(", ");
            }
        }
        exchange.setResponseHeader(Headers.SEC_WEB_SOCKET_EXTENSIONS_STRING, sb.toString());
    }

}
 
Example 4
Project: tomcat7   File: JspDocumentParser.java   View Source Code Vote up 6 votes
private void addInclude(Node parent, List<String> files) throws SAXException {
    if (files != null) {
        Iterator<String> iter = files.iterator();
        while (iter.hasNext()) {
            String file = iter.next();
            AttributesImpl attrs = new AttributesImpl();
            attrs.addAttribute("", "file", "file", "CDATA", file);

            // Create a dummy Include directive node
                Node includeDir =
                    new Node.IncludeDirective(attrs, null, // XXX
parent);
            processIncludeDirective(file, includeDir);
        }
    }
}
 
Example 5
Project: Auts_Assert_manager   File: AuthBeatResponseModelServiceImpl.java   View Source Code Vote up 6 votes
@Override
public List<ItemAuthResultModel> download4PassAuthorizationApi(RequestAuthBodyModel requestAuthBodyModel){
    if(null == requestAuthBodyModel){return null;}

    /** 通过router_mac查询device_mac,找到order_id */
    if(null == requestAuthBodyModel.getRouterMac()){return null;}

    List<Guest4RouterModel> guest4RouterModelList = routerGuestModelJpaGerepository.findByRouterMac(requestAuthBodyModel.getRouterMac());
    if(null == guest4RouterModelList){return null;}
    List<ItemAuthResultModel> itemAuthResultModelList = new ArrayList<>();
    Iterator iterator = guest4RouterModelList.iterator();
    while(iterator.hasNext())
    {
        Guest4RouterModel guest4RouterModel = (Guest4RouterModel)(iterator.next());

        List<GuestOrder> guestOrderList = routerGuestOrderModelJpaGerepository.findPassAuthorizationByGuestIdAndOrderStatus(guest4RouterModel.getId(), Const.OrderStatusInterfaces.ORDER_STATUS_PAIDINCOMMON);
        if((null != guestOrderList)&&(guestOrderList.size()>0))
        {
            itemAuthResultModelList.add(new ItemAuthResultModel(Const.GuestAuthorityResultInterfaces.AUTHORITY_RESULT_OK,
                    guest4RouterModel.getDeviceMac(),
                    guestOrderList.get(0).getOrderId()));
        }
    }

    return itemAuthResultModelList;
}
 
Example 6
Project: lams   File: SimpleRepository.java   View Source Code Vote up 6 votes
@Override
   public SortedMap getNodeList(ITicket ticket) throws AccessDeniedException {

Long workspaceId = ticket.getWorkspaceId();
List nodes = workspaceDAO.findWorkspaceNodes(workspaceId);

if (log.isDebugEnabled()) {
    log.debug("Workspace " + workspaceId + " has " + nodes.size() + " nodes.");
}

TreeMap map = new TreeMap();
Iterator iter = nodes.iterator();
while (iter.hasNext()) {
    CrNode node = (CrNode) iter.next();
    map.put(node.getNodeId(), node.getVersionHistory());
}

return map;
   }
 
Example 7
Project: incubator-netbeans   File: DefaultTabbedContainerUI.java   View Source Code Vote up 6 votes
/**
 * Fills contentDisplayer container with components retrieved from model.
 */
protected void initDisplayer() {
    if (container.getContentPolicy() == TabbedContainer.CONTENT_POLICY_ADD_ALL) {
        List tabs = container.getModel().getTabs();
        Component curC = null;
        for (Iterator iter = tabs.iterator(); iter.hasNext();) {
            curC = toComp ((TabData) iter.next());
            // string parameter is needed for StackLayout to kick in correctly
            contentDisplayer.add(curC, "");
        }
    } else {
        int i = tabDisplayer.getSelectionModel().getSelectedIndex();
        if (i != -1) {
            TabData td = container.getModel().getTab(i);
            contentDisplayer.add(toComp(td), "");
        }
    }
    updateActiveState();
}
 
Example 8
Project: ctsms   File: WebUtil.java   View Source Code Vote up 6 votes
public static String escapeJSStringArray(List<String> valueList, boolean brackets, boolean quotes) {
	StringBuilder sb;
	if (brackets) {
		sb = new StringBuilder("[");
	} else {
		sb = new StringBuilder();
	}
	if (valueList != null && valueList.size() > 0) {
		Iterator<String> it = valueList.iterator();
		while (it.hasNext()) {
			sb.append(quoteJSString(it.next(), brackets || quotes));
			if (it.hasNext()) {
				sb.append(",");
			}
		}
	}
	if (brackets) {
		sb.append("]");
	}
	return sb.toString();
}
 
Example 9
Project: openjdk-jdk10   File: LocaleData.java   View Source Code Vote up 5 votes
@Override
public List<Locale> getCandidateLocales(String baseName, Locale locale) {
    String key = baseName + '-' + locale.toLanguageTag();
    List<Locale> candidates = CANDIDATES_MAP.get(key);
    if (candidates == null) {
        LocaleProviderAdapter.Type type = baseName.contains(DOTCLDR) ? CLDR : JRE;
        LocaleProviderAdapter adapter = LocaleProviderAdapter.forType(type);
        candidates = adapter instanceof ResourceBundleBasedAdapter ?
            ((ResourceBundleBasedAdapter)adapter).getCandidateLocales(baseName, locale) :
            defaultControl.getCandidateLocales(baseName, locale);

        // Weed out Locales which are known to have no resource bundles
        int lastDot = baseName.lastIndexOf('.');
        String category = (lastDot >= 0) ? baseName.substring(lastDot + 1) : baseName;
        Set<String> langtags = ((JRELocaleProviderAdapter)adapter).getLanguageTagSet(category);
        if (!langtags.isEmpty()) {
            for (Iterator<Locale> itr = candidates.iterator(); itr.hasNext();) {
                if (!adapter.isSupportedProviderLocale(itr.next(), langtags)) {
                    itr.remove();
                }
            }
        }
        // Force fallback to Locale.ENGLISH for CLDR time zone names support
        if (locale.getLanguage() != "en"
                && type == CLDR && category.equals("TimeZoneNames")) {
            candidates.add(candidates.size() - 1, Locale.ENGLISH);
        }
        CANDIDATES_MAP.putIfAbsent(key, candidates);
    }
    return candidates;
}
 
Example 10
Project: incubator-netbeans   File: AnalyserTest.java   View Source Code Vote up 5 votes
private void print (List l, String indent) {
    Iterator it = l.iterator ();
    while (it.hasNext ()) {
        Object next = it.next ();
        System.out.println (indent + next);
        if (next instanceof ASTToken) continue;
        print ((List) it.next (), indent + "  ");
    }
}
 
Example 11
Project: lams   File: ExclusiveAnnotationFilter.java   View Source Code Vote up 5 votes
@Override
protected void overrideIndexedAnnotationMap(DotName annName, AnnotationInstance annotationInstance, Map<DotName, List<AnnotationInstance>> map) {
	ExclusiveGroup group = getExclusiveGroup( annName );
	if ( group == null ) {
		return;
	}
	AnnotationTarget target = annotationInstance.target();
	for ( DotName entityAnnName : group ) {
		if ( !map.containsKey( entityAnnName ) ) {
			continue;
		}
		switch ( group.scope ) {
			case TYPE:
				map.put( entityAnnName, Collections.<AnnotationInstance>emptyList() );
				break;
			case ATTRIBUTE:
				List<AnnotationInstance> indexedAnnotationInstanceList = map.get( entityAnnName );
				Iterator<AnnotationInstance> iter = indexedAnnotationInstanceList.iterator();
				while ( iter.hasNext() ) {
					AnnotationInstance ann = iter.next();
					if ( MockHelper.targetEquals( target, ann.target() ) ) {
						iter.remove();
					}
				}
				break;
		}
	}
}
 
Example 12
Project: openjdk-jdk10   File: GetObjectLockCount.java   View Source Code Vote up 5 votes
/**
 * Find a com.sun.jdi.CommandLineLaunch connector
 */
static LaunchingConnector findLaunchingConnector() {
    List <Connector> connectors = Bootstrap.virtualMachineManager().allConnectors();
    Iterator <Connector> iter = connectors.iterator();
    while (iter.hasNext()) {
        Connector connector = iter.next();
        if (connector.name().equals("com.sun.jdi.CommandLineLaunch")) {
            return (LaunchingConnector)connector;
        }
    }
    throw new Error("No launching connector");
}
 
Example 13
Project: googles-monorepo-demo   File: IteratorsTest.java   View Source Code Vote up 5 votes
public void testAdvance_illegalArgument() {
  List<String> list = newArrayList("a", "b", "c");
  Iterator<String> iterator = list.iterator();
  try {
    advance(iterator, -1);
    fail();
  } catch (IllegalArgumentException expected) {}
}
 
Example 14
Project: KeYExperienceReport   File: Server.java   View Source Code Vote up 5 votes
private static void filterListForMe(List<Job> joblist) {
	for (Iterator<Job> iterator = joblist.iterator(); iterator.hasNext();) {
		Job job = iterator.next();
		if(job.getCode().equals("Basic"))
			iterator.remove();
		else if(!job.getMethod().equals("max"))
			iterator.remove();
		else if(job.getContractNumber() != 0)
			iterator.remove();
	}
}
 
Example 15
Project: oxygen-dita-translation-package-builder   File: FileSystemResourceBuilder.java   View Source Code Vote up 5 votes
/**
 * @see com.oxygenxml.translation.support.core.resource.IResource#iterator()
 */
public Iterator<IResource> iterator() {
  if (logger.isDebugEnabled()) {
    logger.debug("Get iterator for: " + file);
  }
  Iterator<IResource> toReturn = null;
  File[] listFiles = file.listFiles();
  if (listFiles != null) {
    List<IResource>  children = new ArrayList<IResource>(listFiles.length);
    StringBuilder b = new StringBuilder();
    for (int i = 0; i < listFiles.length; i++) {
      File child = listFiles[i];
      if (!child.getName().contains(MilestoneUtil.MILESTONE_FILE_NAME)) {
        // The milestone must not be added in the package.
        b.setLength(0);
        if (relativePath.length() > 0) {
          b.append(relativePath).append("/");
        }
        b.append(child.getName());
        if (logger.isDebugEnabled()) {
          logger.debug("  Child: " + child);
        }
        children.add(wrap(child, b.toString()));
      }
    }
    
    toReturn = children.iterator();
  }
  
  return toReturn;
}
 
Example 16
Project: rapidminer   File: UpdateDialog.java   View Source Code Vote up 5 votes
private static HashSet<Dependency> collectDependency(PackageDescriptor desc, HashSet<String> pluginsSelectedForDownload, PackageDescriptorCache packageDescriptorCache) {
    HashSet dependencySet = new HashSet();
    List dependencies = Dependency.parse(desc.getDependencies());
    Iterator var5 = dependencies.iterator();

    while(var5.hasNext()) {
        Dependency dependency = (Dependency)var5.next();
        String packageId = dependency.getPluginExtensionId();
        PackageDescriptor packageInfo = packageDescriptorCache.getPackageInfo(packageId);
        if(packageInfo != null) {
            boolean upToDate = false;
            ManagedExtension ext = ManagedExtension.get(packageId);
            if(ext != null) {
                String installed = ext.getLatestInstalledVersion();
                if(installed != null) {
                    upToDate = installed.compareTo(packageInfo.getVersion()) >= 0;
                }
            }

            if(!dependencySet.contains(dependency) && !pluginsSelectedForDownload.contains(packageId) && !upToDate) {
                dependencySet.add(dependency);
                dependencySet.addAll(collectDependency(packageInfo, pluginsSelectedForDownload, packageDescriptorCache));
            }
        }
    }

    return dependencySet;
}
 
Example 17
Project: GxIconAndroid   File: LatestIconsGetter.java   View Source Code Vote up 5 votes
private void filterNotNew(@NonNull Context context, @NonNull List<IconBean> iconList) {
    String[] names = context.getResources().getStringArray(R.array.latest_icons);
    Set<String> nameSet = new HashSet<>();
    nameSet.addAll(Arrays.asList(names));
    Iterator<IconBean> iterator = iconList.iterator();
    while (iterator.hasNext()) {
        if (!nameSet.contains(iterator.next().getName())) {
            iterator.remove();
        }
    }
}
 
Example 18
Project: openjdk-jdk10   File: CollectionsUtil.java   View Source Code Vote up 5 votes
/**
 * Concatenates multiple iterables into a single iterable. The iterator exposed by the returned
 * iterable does not support {@link Iterator#remove()} even if the input iterables do.
 *
 * @throws NullPointerException if {@code iterables} or any of its elements are {@code null}
 */
public static <T> Iterable<T> concat(List<Iterable<T>> iterables) {
    for (Iterable<T> iterable : iterables) {
        Objects.requireNonNull(iterable);
    }
    return new Iterable<T>() {
        @Override
        public Iterator<T> iterator() {
            if (iterables.size() == 0) {
                return Collections.emptyIterator();
            }
            return new Iterator<T>() {
                Iterator<Iterable<T>> cursor = iterables.iterator();
                Iterator<T> currentIterator = cursor.next().iterator();

                private void advance() {
                    while (!currentIterator.hasNext() && cursor.hasNext()) {
                        currentIterator = cursor.next().iterator();
                    }
                }

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

                @Override
                public T next() {
                    advance();
                    return currentIterator.next();
                }
            };
        }

    };
}
 
Example 19
Project: uDetective   File: ServiceNowRetriever.java   View Source Code Vote up 4 votes
@Override
   public Object retrieve(IDataSource snDataSource, Object object) throws RetrieverException {
                               
       HttpClient client = (HttpClient)snDataSource.connect();
       
       // We should use an encoded query in this case because URL parameters do not support the full semantics of a filter.        
       String serviceUrl     = AppProperties.getProperty("service_url");
       String restPath       = AppProperties.getProperty("rest_path");
       String resultLimit    = AppProperties.getProperty("result_limit");
       String period_of_time = AppProperties.getProperty("period_of_time");
       String url1           = "?sysparm_query=active%3Dtrue%5Estate!%3D6%5Esys_created_onRELATIVEGE%40hour%40ago%40" + period_of_time;
       String url2           = "%5Eassignment_group%3D81db147e2b5c79444dde23f119da153b&sysparm_display_value=true&sysparm_fields=sys_id%2Cnumber%2Cshort_description%2Cdescription&sysparm_limit=" + resultLimit;
       
       String finalUrl = serviceUrl + restPath + url1 + url2;
       
       HttpMethod method = new GetMethod(finalUrl);
       method.addRequestHeader("Accept", "application/json");
       String message = "";
       try {
           int status = client.executeMethod(method);
           log.info("Status:" + status);
           BufferedReader rd = new BufferedReader(new InputStreamReader(method.getResponseBodyAsStream()));     
           message = org.apache.commons.io.IOUtils.toString(rd);
       } catch (IOException ioe) {
           throw new RetrieverException(ioe.toString());
       }
       
       // remove leading and ending "{"
       int index = message.indexOf("\"result\":");
       message = message.substring(index+9, message.length()-1);
       
Gson gson = new Gson(); 
       ServiceNowTicket[] wrapper = null;
       try {
           wrapper = gson.fromJson(message, ServiceNowTicket[].class);   
       } catch (Exception e) {
           log.error(e.toString());
       }
       
       if (wrapper == null) {
           log.error("Problem retrieving information from ServiceNow");
           return null;
       }
       log.info("number of fetched tickets: " + wrapper.length);
       List<ServiceNowTicket> ticketList = Arrays.asList(wrapper);  
       
       for (Iterator<ServiceNowTicket> it = ticketList.iterator(); it.hasNext();) {
           ServiceNowTicket ticket = it.next();
           log.info("Fetching IP address and date");
           String source    = StringUtils.substringBetween(ticket.getDescription(), "<Source>", "</Source>");
           String timeStamp = StringUtils.substringBetween(source, "<TimeStamp>", "</TimeStamp>");
           String ipAddress = StringUtils.substringBetween(source, "<IP_Address>", "</IP_Address>");
           log.info("--------------------------");
           log.info("Sys_Id:    " + ticket.getSysId());
           log.info("Number:    " + ticket.getNumber());
           log.info("Timestamp: " + timeStamp);
           log.info("IPAddress: " + ipAddress);      
           log.info("--------------------------");
           log.info("");
           ClaimService service = new ClaimService();
           try {
               // fixing timestamp
               timeStamp = fixTimeStampFormat(timeStamp);
               
               // Sends data to ElasticSearch to find CWL
               IDataSource esDataSource = new ElasticSearchDataSource();
               esDataSource.connect();
               
               // Sends data to CWL database to find email address, first and last name
               
               
               
               
               // save data in the database
               service.addTicket(ticket.getNumber(), ticket.getDescription(), java.sql.Timestamp.valueOf(timeStamp), ipAddress);
           } catch (Exception de) {
               log.error(de.toString());
           }
       }
       return null;
   }
 
Example 20
Project: Lagerta   File: LinearTransactionDataIterator.java   View Source Code Vote up 4 votes
public LinearTransactionDataIterator(TransactionScopeIterator scopeIterator, List<List> values) {
    this.scopeIterator = scopeIterator;
    valuesIterator = values.iterator();
}