Java Code Examples for java.util.Iterator

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project activiti-explorer, under directory /src/main/java/org/activiti/explorer/util/.

Source file: StringUtil.java

  35 
vote

@SuppressWarnings("rawtypes") public static String toReadableString(Collection collection){
  Iterator it=collection.iterator();
  StringBuilder strb=new StringBuilder();
  while (it.hasNext()) {
    Object next=it.next();
    strb.append(next.toString() + ", ");
  }
  if (strb.length() > 2) {
    strb.delete(strb.length() - 2,strb.length());
  }
  return strb.toString();
}
 

Example 2

From project amber, under directory /oauth-2.0/common/src/main/java/org/apache/amber/oauth2/common/utils/.

Source file: JSONUtils.java

  34 
vote

public static Map<String,Object> parseJSON(String jsonBody) throws JSONException {
  Map<String,Object> params=new HashMap<String,Object>();
  JSONObject obj=new JSONObject(jsonBody);
  Iterator it=obj.keys();
  while (it.hasNext()) {
    Object o=it.next();
    if (o instanceof String) {
      String key=(String)o;
      params.put(key,obj.get(key));
    }
  }
  return params;
}
 

Example 3

From project AmDroid, under directory /httpclientandroidlib/src/ch/boye/httpclientandroidlib/params/.

Source file: BasicHttpParams.java

  32 
vote

protected void copyParams(HttpParams target){
  Iterator iter=parameters.entrySet().iterator();
  while (iter.hasNext()) {
    Map.Entry me=(Map.Entry)iter.next();
    if (me.getKey() instanceof String)     target.setParameter((String)me.getKey(),me.getValue());
  }
}
 

Example 4

From project Amoeba-for-Aladdin, under directory /src/java/com/meidusa/amoeba/net/poolable/copy/.

Source file: CursorableLinkedList.java

  32 
vote

/** 
 * Appends all of the elements in the specified collection to the end of this list, in the order that they are returned by the specified {@link Collection}'s  {@link Iterator}.  The behavior of this operation is unspecified if the specified collection is modified while the operation is in progress.  (Note that this will occur if the specified collection is this list, and it's nonempty.)
 * @param c collection whose elements are to be added to this list.
 * @return <tt>true</tt> if this list changed as a result of the call.
 * @throws ClassCastException if the class of an element in the specifiedcollection prevents it from being added to this list.
 * @throws IllegalArgumentException if some aspect of an element in thespecified collection prevents it from being added to this list.
 */
public boolean addAll(Collection c){
  if (c.isEmpty()) {
    return false;
  }
  Iterator it=c.iterator();
  while (it.hasNext()) {
    insertListable(_head.prev(),null,it.next());
  }
  return true;
}
 

Example 5

From project accounted4, under directory /accounted4/accounted4-money/src/main/java/com/accounted4/money/.

Source file: Split.java

  31 
vote

/** 
 * The partitions forming the split.
 * @param divideType Determinant of remainder distribution among partitions
 * @return The partitions with the original money "fairly" distributed.
 */
public Collection<Money> getPartitions(final DivideType divideType){
  return new AbstractCollection<Money>(){
    @Override public Iterator<Money> iterator(){
      return new SplitIterator(divideType);
    }
    @Override public int size(){
      return partitions;
    }
  }
;
}
 

Example 6

From project agorava-facebook, under directory /agorava-facebook-cdi/src/main/java/org/agorava/facebook/impl/.

Source file: FeedServiceImpl.java

  31 
vote

private <T>List<T> deserializeList(JsonNode jsonNode,String postType,Class<T> type){
  JsonNode dataNode=jsonNode.get("data");
  List<T> posts=new ArrayList<T>();
  for (Iterator<JsonNode> iterator=dataNode.iterator(); iterator.hasNext(); ) {
    posts.add(deserializePost(postType,type,(ObjectNode)iterator.next()));
  }
  return posts;
}
 

Example 7

From project agorava-twitter, under directory /agorava-twitter-cdi/src/main/java/org/agorava/twitter/jackson/.

Source file: AbstractTrendsList.java

  31 
vote

public AbstractTrendsList(Map<String,List<Trend>> trends,DateFormat dateFormat){
  list=new ArrayList<Trends>(trends.size());
  for (Iterator<Entry<String,List<Trend>>> trendsIt=trends.entrySet().iterator(); trendsIt.hasNext(); ) {
    Entry<String,List<Trend>> entry=trendsIt.next();
    list.add(new Trends(toDate(entry.getKey(),dateFormat),entry.getValue()));
  }
  Collections.sort(list,new Comparator<Trends>(){
    public int compare(    Trends t1,    Trends t2){
      return t1.getTime().getTime() > t2.getTime().getTime() ? -1 : 1;
    }
  }
);
}
 

Example 8

From project Agot-Java, under directory /src/main/java/got/utility/.

Source file: PointFileReaderWriter.java

  31 
vote

public static void writeOneToMany(final OutputStream sink,Map mapping) throws Exception {
  final StringBuilder out=new StringBuilder();
  if (mapping == null) {
    mapping=new HashMap();
  }
  final Iterator keyIter=mapping.keySet().iterator();
  while (keyIter.hasNext()) {
    final String name=(String)keyIter.next();
    out.append(name).append(" ");
    final Collection points=(Collection)mapping.get(name);
    final Iterator pointIter=points.iterator();
    while (pointIter.hasNext()) {
      final Point point=(Point)pointIter.next();
      out.append(" (").append(point.x).append(",").append(point.y).append(")");
      if (pointIter.hasNext())       out.append(" ");
    }
    if (keyIter.hasNext()) {
      out.append("\n");
    }
  }
  write(out,sink);
}
 

Example 9

From project airlift, under directory /bootstrap/src/main/java/io/airlift/bootstrap/.

Source file: ColumnPrinter.java

  31 
vote

/** 
 * Generate the output as a list of string lines
 * @return lines
 */
List<String> generate(){
  List<String> lines=Lists.newArrayList();
  StringBuilder workStr=new StringBuilder();
  List<AtomicInteger> columnWidths=getColumnWidths();
  List<Iterator<String>> dataIterators=getDataIterators();
  Iterator<AtomicInteger> columnWidthIterator=columnWidths.iterator();
  for (  String columnName : columnNames) {
    int thisWidth=columnWidthIterator.next().intValue();
    printValue(workStr,columnName,thisWidth);
  }
  pushLine(lines,workStr);
  boolean done=false;
  while (!done) {
    boolean hadValue=false;
    Iterator<Iterator<String>> rowIterator=dataIterators.iterator();
    for (    AtomicInteger width : columnWidths) {
      Iterator<String> thisDataIterator=rowIterator.next();
      if (thisDataIterator.hasNext()) {
        hadValue=true;
        String value=thisDataIterator.next();
        printValue(workStr,value,width.intValue());
      }
 else {
        printValue(workStr,"",width.intValue());
      }
    }
    pushLine(lines,workStr);
    if (!hadValue) {
      done=true;
    }
  }
  return lines;
}
 

Example 10

From project Aardvark, under directory /aardvark-aether-utils/src/main/java/gw/vark/aether/.

Source file: AetherResolutionResult.java

  30 
vote

public List<File> getFileList(){
  List<File> list=new ArrayList<File>();
  for (Iterator it=iterator(); it.hasNext(); ) {
    FileResource resource=(FileResource)it.next();
    File file=resource.getFile();
    list.add(file);
  }
  return list;
}
 

Example 11

From project AChartEngine, under directory /achartengine/src/org/achartengine/model/.

Source file: XYSeries.java

  30 
vote

/** 
 * Returns submap of x and y values according to the given start and end
 * @param start start x value
 * @param stop stop x value
 * @return
 */
public synchronized SortedMap<Double,Double> getRange(double start,double stop,int beforeAfterPoints){
  SortedMap<Double,Double> headMap=mXY.headMap(start);
  if (!headMap.isEmpty()) {
    start=headMap.lastKey();
  }
  SortedMap<Double,Double> tailMap=mXY.tailMap(stop);
  if (!tailMap.isEmpty()) {
    Iterator<Double> tailIterator=tailMap.keySet().iterator();
    Double next=tailIterator.next();
    if (tailIterator.hasNext()) {
      stop=tailIterator.next();
    }
 else {
      stop+=next;
    }
  }
  return mXY.subMap(start,stop);
}
 

Example 12

From project AdminCmd, under directory /src/main/java/be/Balor/Tools/Files/.

Source file: FileManager.java

  30 
vote

private void importBannedPlayerTXT(final Map<String,Ban> result){
  final Set<OfflinePlayer> banned=ACPluginManager.getServer().getBannedPlayers();
  final Set<String> ipBanned=ACPluginManager.getServer().getIPBans();
  final Iterator<OfflinePlayer> it=banned.iterator();
  while (it.hasNext()) {
    final OfflinePlayer op=it.next();
    final String name=op.getName();
    if (!result.containsKey(name)) {
      final BannedPlayer bp=new BannedPlayer(name,"Import from banned-players.txt");
      result.put(name,bp);
    }
  }
  for (  final String ip : ipBanned) {
    if (result.containsKey(ip)) {
      continue;
    }
    result.put(ip,new BannedIP(ip,"Import from banned-ip.txt"));
  }
}
 

Example 13

From project AdminStuff, under directory /src/main/java/de/minestar/AdminStuff/listener/.

Source file: PlayerListener.java

  30 
vote

@EventHandler public void onPlayerChat(AsyncPlayerChatEvent event){
  MinestarPlayer mPlayer=MinestarCore.getPlayer(event.getPlayer());
  Boolean muted=mPlayer.getBoolean("adminstuff.muted");
  if (muted != null && muted) {
    event.setCancelled(true);
    String message=ChatColor.RED + "[STUMM] " + mPlayer.getNickName()+ ChatColor.WHITE+ ": "+ event.getMessage();
    Player current=null;
    Iterator<Player> i=event.getRecipients().iterator();
    while (i.hasNext()) {
      current=i.next();
      if (UtilPermissions.playerCanUseCommand(current,"adminstuff.chat.read.muted"))       PlayerUtils.sendBlankMessage(current,message);
    }
  }
  Set<String> recs=pManager.getRecipients(event.getPlayer().getName());
  if (recs != null) {
    Iterator<Player> i=event.getRecipients().iterator();
    Player current=null;
    while (i.hasNext()) {
      current=i.next();
      if (!current.equals(event.getPlayer()) && !recs.contains(current.getName().toLowerCase()))       i.remove();
    }
  }
  Boolean afk=mPlayer.getBoolean("adminstuff.afk");
  if (afk != null && afk) {
    mPlayer.removeValue("adminstuff.afk",Boolean.class);
    pManager.updatePrefix(mPlayer);
  }
}
 

Example 14

From project agraph-java-client, under directory /src/com/franz/agraph/jena/.

Source file: AGPrefixMapping.java

  30 
vote

public String toString(int max){
  Map<String,String> map=getNsPrefixMap();
  int size=map.size();
  int count=0;
  Iterator<String> it=map.keySet().iterator();
  StringBuffer b=new StringBuffer(this.getClass().getSimpleName() + "(size: " + size+ "){");
  String gap="";
  for (; it.hasNext() && count < max; count++) {
    b.append(gap);
    gap=", ";
    String key=it.next();
    b.append(key + "=" + map.get(key));
  }
  if (count == max && it.hasNext()) {
    b.append(",...");
  }
  b.append("}");
  return b.toString();
}
 

Example 15

From project ALP, under directory /workspace/alp-utils/src/main/java/com/lohika/alp/utils/json/validator/.

Source file: ALPJSONValidator.java

  30 
vote

/** 
 * This function recursively goes over all elements in JSON and answer if each one is correct.
 * @param feedObj - JsonNode object that currently under verification
 * @param parentName - name of parent of current element
 * @param schemaStack - Linked List that store list of currently read schemas
 * @return true, if successful
 * @throws JsonParseException the json parse exception
 * @throws FileNotFoundException the file not found exception
 * @throws IOException Signals that an I/O exception has occurred.
 */
private boolean validateObject(JsonNode feedObj,String parentName,LinkedList<String> schemaStack) throws JsonParseException, FileNotFoundException, IOException {
  Iterator<JsonNode> Inode=feedObj.getElements();
  Iterator<String> Istring=feedObj.getFieldNames();
  while (Inode.hasNext()) {
    String str=Istring.next();
    JsonNode nod=Inode.next();
    JSONStack.add(str);
    LinkedList<String> t_schemaStack=new LinkedList<String>();
    t_schemaStack.addAll(schemaStack);
    LinkedList<JSONTypes> TypesList=getItemTypeFromSchema(str,parentName,new LinkedList<String>(),t_schemaStack);
    if (TypesList == null)     ErrorsStack.add("'" + GeneratePath() + "' not belongs to '"+ parentName+ "'");
 else {
      JSONTypes realType=detectType(TypesList,nod);
      if (realType == JSONTypes.object) {
        LinkedList<String> t_SchemaStack2=new LinkedList<String>();
        t_SchemaStack2.addAll(t_schemaStack);
        validateObject(nod,str,t_SchemaStack2);
      }
 else       if (realType == JSONTypes.array) {
        LinkedList<String> t_SchemaStack2=new LinkedList<String>();
        t_SchemaStack2.addAll(t_schemaStack);
        validateArray(nod,str,t_SchemaStack2);
      }
 else       if (realType == JSONTypes.string && nod.getTextValue().isEmpty())       ErrorsStack.add("Item '" + GeneratePath() + "' is empty");
    }
    JSONStack.removeLast();
  }
  if (ErrorsStack.isEmpty())   return true;
 else   return false;
}
 

Example 16

From project ambrose, under directory /common/src/test/java/com/twitter/ambrose/service/impl/.

Source file: InMemoryStatsServiceTest.java

  30 
vote

@Test public void testGetAllEvents(){
  for (  WorkflowEvent event : testEvents) {
    service.pushEvent(workflowId,event);
  }
  Collection<WorkflowEvent> events=service.getEventsSinceId(workflowId,-1);
  Iterator<WorkflowEvent> foundEvents=events.iterator();
  assertTrue("No events returned",foundEvents.hasNext());
  for (  WorkflowEvent sentEvent : testEvents) {
    assertEqualWorkflows(sentEvent,foundEvents.next());
  }
  assertFalse("Wrong number of events returned",foundEvents.hasNext());
}
 

Example 17

From project amplafi-sworddance, under directory /src/main/java/com/sworddance/beans/.

Source file: BeanWorker.java

  30 
vote

/** 
 * collects a chain of property methods that are called sequentially to get the final result.
 * @param clazz
 * @param propertyNamesList
 * @param readOnly only look for a getter
 * @return the chain of methods.
 */
protected List<PropertyAdaptor> getMethods(Class<?> clazz,String[] propertyNamesList,boolean readOnly){
  Class<?>[] parameterTypes=new Class<?>[0];
  List<PropertyAdaptor> propertyMethodChain=new ArrayList<PropertyAdaptor>();
  for (Iterator<String> iter=Arrays.asList(propertyNamesList).iterator(); iter.hasNext(); ) {
    String propertyName=iter.next();
    PropertyAdaptor propertyAdaptor=new PropertyAdaptor(propertyName);
    propertyAdaptor.setGetter(clazz,parameterTypes);
    if (!iter.hasNext() && !readOnly) {
      propertyAdaptor.initSetter(clazz);
    }
    if (propertyAdaptor.isExists()) {
      clazz=propertyAdaptor.getReturnType();
      propertyMethodChain.add(propertyAdaptor);
    }
 else {
      throw new IllegalArgumentException(StringUtils.join(propertyNamesList) + " has bad property " + propertyName);
    }
  }
  return propertyMethodChain;
}
 

Example 18

From project 16Blocks, under directory /src/main/java/de/minestar/sixteenblocks/Threads/.

Source file: ChatThread.java

  29 
vote

@Override public void run(){
  long currentTime=System.currentTimeMillis();
  Iterator<Player> iterator=this.channelManager.getChannelByChannelName("Support").getPlayers().iterator();
  Player thisPlayer;
  while (iterator.hasNext()) {
    thisPlayer=iterator.next();
    if (!chatListener.hasWritten(thisPlayer,currentTime)) {
      this.channelManager.updatePlayer(thisPlayer,this.channelManager.getChannelByChannelName("Lobby"));
      TextUtils.sendSuccess(thisPlayer,"You are now in the lobby.");
    }
  }
}
 

Example 19

From project 3Dto2DApplet, under directory /src/java/nl/dannyarends/generic/.

Source file: Utils.java

  29 
vote

protected void finalize() throws Throwable {
synchronized (freeThreads) {
    Iterator<PooledThread> i=freeThreads.iterator();
    while (i.hasNext())     i.next().interrupt();
  }
synchronized (busyThreads) {
    Iterator<PooledThread> i=freeThreads.iterator();
    while (i.hasNext())     i.next().interrupt();
  }
  super.finalize();
}
 

Example 20

From project acceleo-modules, under directory /psm-gen-scala/plugins/com.github.sbegaudeau.acceleo.modules.psm.gen.scala.editor/src-gen/com/github/sbegaudeau/acceleo/modules/psm/gen/scala/model/scala/presentation/.

Source file: ScalaEditor.java

  29 
vote

/** 
 * This deals with how we want selection in the outliner to affect the other views. <!-- begin-user-doc --> <!-- end-user-doc -->
 * @generated
 */
public void handleContentOutlineSelection(ISelection selection){
  if (currentViewerPane != null && !selection.isEmpty() && selection instanceof IStructuredSelection) {
    Iterator<?> selectedElements=((IStructuredSelection)selection).iterator();
    if (selectedElements.hasNext()) {
      Object selectedElement=selectedElements.next();
      if (currentViewerPane.getViewer() == selectionViewer) {
        ArrayList<Object> selectionList=new ArrayList<Object>();
        selectionList.add(selectedElement);
        while (selectedElements.hasNext()) {
          selectionList.add(selectedElements.next());
        }
        selectionViewer.setSelection(new StructuredSelection(selectionList));
      }
 else {
        if (currentViewerPane.getViewer().getInput() != selectedElement) {
          currentViewerPane.getViewer().setInput(selectedElement);
          currentViewerPane.setTitle(selectedElement);
        }
      }
    }
  }
}
 

Example 21

From project acceleo-webapp-generator, under directory /plugins/org.eclipse.acceleo.tutorial.webapp.editor/src-gen/org/eclipse/acceleo/tutorial/webapp/presentation/.

Source file: WebappEditor.java

  29 
vote

/** 
 * This deals with how we want selection in the outliner to affect the other views. <!-- begin-user-doc --> <!-- end-user-doc -->
 * @generated
 */
public void handleContentOutlineSelection(ISelection selection){
  if (currentViewerPane != null && !selection.isEmpty() && selection instanceof IStructuredSelection) {
    Iterator<?> selectedElements=((IStructuredSelection)selection).iterator();
    if (selectedElements.hasNext()) {
      Object selectedElement=selectedElements.next();
      if (currentViewerPane.getViewer() == selectionViewer) {
        ArrayList<Object> selectionList=new ArrayList<Object>();
        selectionList.add(selectedElement);
        while (selectedElements.hasNext()) {
          selectionList.add(selectedElements.next());
        }
        selectionViewer.setSelection(new StructuredSelection(selectionList));
      }
 else {
        if (currentViewerPane.getViewer().getInput() != selectedElement) {
          currentViewerPane.getViewer().setInput(selectedElement);
          currentViewerPane.setTitle(selectedElement);
        }
      }
    }
  }
}
 

Example 22

From project accesointeligente, under directory /src/org/accesointeligente/client/views/.

Source file: RequestStatusView.java

  29 
vote

@Override public void setRequestCategories(Set<RequestCategory> categories){
  requestCategoryPanel.clear();
  Iterator<RequestCategory> iterator=categories.iterator();
  while (iterator.hasNext()) {
    RequestCategory category=iterator.next();
    addRequestCategories(category);
  }
}
 

Example 23

From project action-core, under directory /src/main/java/com/ning/metrics/action/hdfs/data/.

Source file: JsonNodeComparable.java

  29 
vote

@Override public int compareTo(Object o){
  JsonNode thing=(JsonNode)o;
  if (isMissingNode() && !thing.isMissingNode()) {
    return -1;
  }
 else   if (!isMissingNode() && thing.isMissingNode()) {
    return 1;
  }
  int mySize=0;
  Iterator<JsonNode> myIterator=elements();
  while (myIterator.hasNext()) {
    mySize++;
  }
  int hisSize=0;
  Iterator<JsonNode> hisIterator=thing.elements();
  while (hisIterator.hasNext()) {
    hisSize++;
  }
  if (mySize != 0 || hisSize != 0) {
    if (mySize > hisSize) {
      return 1;
    }
 else     if (mySize < hisSize) {
      return -1;
    }
  }
  if (isValueNode() && thing.isValueNode()) {
    return textValue().compareTo(thing.textValue());
  }
 else {
    if (equals(thing)) {
      return 0;
    }
 else {
      return toString().compareTo(thing.toString());
    }
  }
}
 

Example 24

From project activemq-apollo, under directory /apollo-itests/src/test/java/org/apache/activemq/apollo/.

Source file: JmsTestBase.java

  29 
vote

@Override protected void tearDown() throws Exception {
  for (Iterator iter=connections.iterator(); iter.hasNext(); ) {
    Connection conn=(Connection)iter.next();
    try {
      conn.close();
    }
 catch (    Throwable e) {
    }
    iter.remove();
  }
  connection=null;
  stopBroker();
  super.tearDown();
}
 

Example 25

From project adbcj, under directory /api/src/main/java/org/adbcj/support/.

Source file: AbstractDbSession.java

  29 
vote

@SuppressWarnings("unchecked") protected final <E>Request<E> makeNextRequestActive(){
  Request<E> request;
  boolean executePipelining=false;
synchronized (lock) {
    if (activeRequest != null && !activeRequest.isDone()) {
      throw new ActiveRequestIncomplete(this,"Active request is not done: " + activeRequest);
    }
    request=(Request<E>)requestQueue.poll();
    if (pipelined && request != null) {
      if (request.isPipelinable()) {
        executePipelining=!pipelining;
      }
 else {
        pipelining=false;
      }
    }
    activeRequest=request;
  }
  if (request != null) {
    invokeExecuteWithCatch(request);
  }
  if (executePipelining) {
synchronized (lock) {
      Iterator<Request<?>> iterator=requestQueue.iterator();
      while (iterator.hasNext()) {
        Request<?> next=iterator.next();
        if (next.isPipelinable()) {
          invokeExecuteWithCatch(next);
          if (!iterator.hasNext()) {
            pipelining=true;
          }
        }
 else {
          break;
        }
      }
    }
  }
  return request;
}
 

Example 26

From project addis, under directory /application/src/main/java/org/drugis/addis/entities/treatment/.

Source file: TreatmentDefinition.java

  29 
vote

@Override public int compareTo(TreatmentDefinition o){
  Iterator<Category> i1=getContents().iterator();
  Iterator<Category> i2=o.getContents().iterator();
  while (i1.hasNext() && i2.hasNext()) {
    int compVal=i1.next().compareTo(i2.next());
    if (compVal != 0) {
      return compVal;
    }
  }
  if (i1.hasNext()) {
    return 1;
  }
  if (i2.hasNext()) {
    return -1;
  }
  return 0;
}
 

Example 27

From project advanced, under directory /management/src/main/java/org/neo4j/management/impl/jconsole/.

Source file: ManagementAccess.java

  29 
vote

static ManagementAccess[] getAll(MBeanServerConnection server){
  final Set<ObjectName> names;
  try {
    names=server.queryNames(createObjectName("*",KERNEL_BEAN_NAME),null);
  }
 catch (  IOException e) {
    return new ManagementAccess[0];
  }
  ManagementAccess[] proxies=new ManagementAccess[names.size()];
  Iterator<ObjectName> iter=names.iterator();
  for (int i=0; i < proxies.length || iter.hasNext(); i++) {
    proxies[i]=new ManagementAccess(server,iter.next());
  }
  return proxies;
}
 

Example 28

From project AeminiumRuntime, under directory /src/aeminium/runtime/implementations/implicitworkstealing/.

Source file: ImplicitWorkStealingRuntime.java

  29 
vote

@Override public <T>T invokeAny(Collection<? extends Callable<T>> tasks,long timeout,TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
  final long start=System.nanoTime();
  final Iterator<?> it=tasks.iterator();
  Callable<T> current=null;
  while (System.nanoTime() < start + unit.toNanos(timeout)) {
    if (current == null && it.hasNext()) {
      @SuppressWarnings("unchecked") Callable<T> tmp=(Callable<T>)it.next();
      current=tmp;
    }
 else     if (!it.hasNext()) {
      break;
    }
    Future<T> f=submit(current);
    T result=f.get();
    if (result != null && !(result instanceof Exception)) {
      return result;
    }
 else {
      current=null;
    }
  }
  return invokeAny(tasks);
}
 

Example 29

From project aether-core, under directory /aether-api/src/main/java/org/eclipse/aether/collection/.

Source file: UnsolvableVersionConflictException.java

  29 
vote

private static String toPath(List<DependencyNode> path){
  StringBuilder buffer=new StringBuilder(256);
  for (Iterator<DependencyNode> it=path.iterator(); it.hasNext(); ) {
    DependencyNode node=it.next();
    if (node.getDependency() == null) {
      continue;
    }
    Artifact artifact=node.getDependency().getArtifact();
    buffer.append(artifact.getGroupId());
    buffer.append(':').append(artifact.getArtifactId());
    buffer.append(':').append(artifact.getExtension());
    if (artifact.getClassifier().length() > 0) {
      buffer.append(':').append(artifact.getClassifier());
    }
    buffer.append(':').append(node.getVersionConstraint());
    if (it.hasNext()) {
      buffer.append(" -> ");
    }
  }
  return buffer.toString();
}
 

Example 30

From project agile, under directory /agile-apps/agile-app-docs/src/main/java/org/headsupdev/agile/app/docs/.

Source file: ImageList.java

  29 
vote

@Override public IResourceStream getResourceStream(){
  resource.clear();
  resource.append("var ");
  resource.append(getArrayName());
  resource.append(" = new Array(\n");
  String projectStr=getParameters().getString("project");
  String docStr=getParameters().getString("page");
  if (projectStr == null || projectStr.length() == 0 || docStr == null || docStr.length() == 0) {
    return resource;
  }
  Storage storage=Manager.getStorageInstance();
  Project project=storage.getProject(projectStr);
  if (project != null) {
    Document doc=getDocument(docStr,project);
    if (doc != null) {
      Iterator<Attachment> attIter=doc.getAttachments().iterator();
      while (attIter.hasNext()) {
        Attachment attachment=attIter.next();
        String filename=attachment.getFilename();
        if (!acceptFile(filename)) {
          continue;
        }
        resource.append("[\"" + filename + "\", \""+ getFileUrl(filename,project,doc)+ "\"]");
        if (attIter.hasNext()) {
          resource.append(",");
        }
        resource.append("\n");
      }
    }
  }
  resource.append(");\n");
  return resource;
}
 

Example 31

From project agileBase, under directory /gtpb_server/src/com/gtwm/pb/model/manageSchema/.

Source file: ChartDefn.java

  29 
vote

public synchronized ChartGroupingInfo removeGrouping(ReportFieldInfo reportFieldToRemove){
  for (Iterator<ChartGroupingInfo> iterator=this.getGroupingsDirect().iterator(); iterator.hasNext(); ) {
    ChartGroupingInfo grouping=iterator.next();
    if (grouping.getGroupingReportField().equals(reportFieldToRemove)) {
      iterator.remove();
      if (this.persist) {
        HibernateUtil.currentSession().delete(grouping);
      }
      return grouping;
    }
  }
  return null;
}
 

Example 32

From project aio-webos, under directory /webui/webos/src/main/java/org/exoplatform/webos/webui/page/.

Source file: UIAddNewApplication.java

  29 
vote

public List<ApplicationCategory> getApplicationCategories(String remoteUser,ApplicationType[] applicationType) throws Exception {
  ExoContainer container=ExoContainerContext.getCurrentContainer();
  ApplicationRegistryService prService=(ApplicationRegistryService)container.getComponentInstanceOfType(ApplicationRegistryService.class);
  if (applicationType == null) {
    applicationType=new ApplicationType[0];
  }
  List<ApplicationCategory> appCategories=prService.getApplicationCategories(remoteUser,applicationType);
  if (appCategories == null) {
    appCategories=new ArrayList();
  }
 else {
    Iterator<ApplicationCategory> cateItr=appCategories.iterator();
    while (cateItr.hasNext()) {
      ApplicationCategory cate=cateItr.next();
      List<Application> applications=cate.getApplications();
      if (applications.size() < 1) {
        cateItr.remove();
      }
    }
  }
  listAppCategories=appCategories;
  return listAppCategories;
}
 

Example 33

From project Aion-Extreme, under directory /AE-go_DataPack/gameserver/data/scripts/system/handlers/admincommands/.

Source file: Announce.java

  29 
vote

@Override public void executeCommand(Player admin,String... params){
  if (params.length == 0) {
    PacketSendUtility.sendMessage(admin,"//announce <message>");
  }
 else {
    Iterator<Player> iter=admin.getActiveRegion().getWorld().getPlayersIterator();
    StringBuilder sbMessage=new StringBuilder("<Annonce> ");
    for (    String p : params)     sbMessage.append(p + " ");
    String sMessage=sbMessage.toString().trim();
    while (iter.hasNext()) {
      PacketSendUtility.sendMessage(iter.next(),sMessage);
    }
  }
}
 

Example 34

From project AirCastingAndroidClient, under directory /src/main/java/ioio/lib/impl/.

Source file: IOIOProtocol.java

  29 
vote

private void findDelta(int[] newPins){
  removedPins_.clear();
  addedPins_.clear();
  for (  int i : analogFramePins_) {
    removedPins_.add(i);
  }
  for (  int i : newPins) {
    addedPins_.add(i);
  }
  for (Iterator<Integer> it=removedPins_.iterator(); it.hasNext(); ) {
    Integer current=it.next();
    if (addedPins_.contains(current)) {
      it.remove();
      addedPins_.remove(current);
    }
  }
}
 

Example 35

From project Airports, under directory /src/com/nadmm/airports/.

Source file: DownloadActivity.java

  29 
vote

private void processManifest(){
  Time now=new Time();
  now.setToNow();
  Iterator<DataInfo> it=mAvailableData.iterator();
  while (it.hasNext()) {
    DataInfo available=it.next();
    if (now.after(available.end)) {
      Log.i(TAG,"Removing expired " + available.type + ":"+ available.version);
      it.remove();
      continue;
    }
    if (isInstalled(available)) {
      Log.i(TAG,"Removing installed " + available.type + ":"+ available.version);
      it.remove();
      continue;
    }
  }
}
 

Example 36

From project ajah, under directory /ajah-image/src/main/java/com/ajah/image/.

Source file: ImageUtils.java

  29 
vote

/** 
 * Extracts some simple information about an image.
 * @param data The image data.
 * @return The image info bean.
 * @throws IOException If the image could not be accessed.
 * @throws CMMException If the image could not be analyzed.
 */
public static ImageInfo getInfo(final byte[] data) throws IOException, CMMException {
  AjahUtils.requireParam(data,"data");
  final BufferedImage image=ImageIO.read(new ByteArrayInputStream(data));
  if (image == null) {
    throw new IllegalArgumentException("An image could not be constructed from the data");
  }
  final ImageInfo info=new ImageInfo();
  info.setHeight(image.getHeight());
  info.setWidth(image.getWidth());
  final ImageInputStream iis=ImageIO.createImageInputStream(new ByteArrayInputStream(data));
  final Iterator<ImageReader> readers=ImageIO.getImageReaders(iis);
  if (readers.hasNext()) {
    info.setFormat(ImageFormat.from(readers.next().getFormatName()));
  }
 else {
    log.warning("No readers found for image");
  }
  return info;
}
 

Example 37

From project akela, under directory /src/main/java/com/mozilla/hadoop/mapreduce/lib/.

Source file: UniqueIdentityReducer.java

  29 
vote

@Override public void reduce(K key,Iterable<V> values,Context context) throws IOException, InterruptedException {
  Iterator<V> iter=values.iterator();
  if (iter.hasNext()) {
    context.write(key,iter.next());
  }
}
 

Example 38

From project akubra, under directory /akubra-fs/src/test/java/org/akubraproject/fs/.

Source file: TestFSBlobIdIterator.java

  29 
vote

private static Set<URI> getSet(Iterator<URI> iter){
  HashSet<URI> set=new HashSet<URI>();
  while (iter.hasNext()) {
    set.add(iter.next());
  }
  return set;
}
 

Example 39

From project AlarmApp-Android, under directory /src/org/alarmapp/web/json/.

Source file: JsonUtil.java

  29 
vote

public static Alarm parseGetAlarmInformationsResult(String response) throws JSONException {
  JSONObject jobj=new JSONObject(response);
  Date date=DateUtil.parse(jobj.getString("alarmed"));
  AlarmState state=AlarmState.create(jobj.getString("my_status"));
  HashSet<String> noExtras=new HashSet<String>(Arrays.asList("alarmed","my_status","title","text","id"));
  Map<String,String> extras=new HashMap<String,String>();
  for (Iterator<String> iter=jobj.keys(); iter.hasNext(); ) {
    String key=iter.next();
    if (!noExtras.contains(key)) {
      extras.put(key,jobj.getString(key));
    }
  }
  Alarm a=new AlarmData(jobj.getString("id"),date,jobj.getString("title"),jobj.getString("text"),state,extras);
  return a;
}
 

Example 40

From project alljoyn_java, under directory /samples/android/chat/src/org/alljoyn/bus/sample/chat/.

Source file: ChatApplication.java

  29 
vote

/** 
 * Called from the AllJoyn Service when it gets a LostAdvertisedName.  We know by construction that the advertised name will correspond to an chat channel.
 */
public synchronized void removeFoundChannel(String channel){
  Log.i(TAG,"removeFoundChannel(" + channel + ")");
  for (Iterator<String> i=mChannels.iterator(); i.hasNext(); ) {
    String string=i.next();
    if (string.equals(channel)) {
      Log.i(TAG,"removeFoundChannel(): removed " + channel);
      i.remove();
    }
  }
}
 

Example 41

From project almira-sample, under directory /almira-sample-webapp/src/main/java/almira/sample/web/model/.

Source file: AbstractCachingDataProvider.java

  29 
vote

final Iterator<T> searchByName(String query,int startIndex,int fetchSize){
  Iterator<T> result=null;
  try {
    result=service.searchByName(query,startIndex,fetchSize).iterator();
  }
 catch (  ParseException e) {
    LOG.log(Level.SEVERE,"bad query",e);
  }
  return result;
}