Java Code Examples for java.util.ArrayList

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 Aardvark, under directory /aardvark-aether-utils/src/main/java/gw/vark/aether/.

Source file: AetherUtil.java

  43 
vote

private static List<RemoteRepository> extractRemoteReposFromPom(Pom pom){
  try {
    List<RemoteRepository> remoteRepos=new ArrayList<RemoteRepository>();
    Model model=pom.getModel(pom);
    Object o=ReflectionValueExtractor.evaluate("project.repositories",model);
    if (o != null) {
      ArrayList pomRepos=(ArrayList)o;
      for (      Object pomRepoObj : pomRepos) {
        Repository pomRepo=(Repository)pomRepoObj;
        RemoteRepository remoteRepo=new RemoteRepository();
        remoteRepo.setId(pomRepo.getId());
        remoteRepo.setUrl(pomRepo.getUrl());
        remoteRepos.add(remoteRepo);
      }
    }
    return remoteRepos;
  }
 catch (  Exception e) {
    throw new RuntimeException(e);
  }
}
 

Example 2

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

Source file: AreaDatabaseManager.java

  18 
vote

public ArrayList<SkinArea> createNotExistingAreas(){
  List<SkinArea> currentZones=this.loadZones();
  ZoneXZ thisZone;
  int maxRow=Integer.MIN_VALUE;
  for (  SkinArea thisArea : currentZones) {
    thisZone=thisArea.getZoneXZ();
    if (thisZone.getZ() > maxRow)     maxRow=thisZone.getZ();
  }
  ArrayList<SkinArea> newSkins=new ArrayList<SkinArea>();
  for (int row=0; row <= maxRow; row++) {
    System.out.println("Extending row in DB: " + row);
    for (int x=-Settings.getSkinsRight() + (row % 2 == 0 ? 0 : 1); x <= Settings.getSkinsLeft(); x++) {
      if (!this.areaExists(x,row)) {
        SkinArea newArea=new SkinArea(x,row,"");
        this.saveZone(newArea);
        newSkins.add(newArea);
      }
    }
  }
  return newSkins;
}
 

Example 3

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

Source file: AetherResolutionResult.java

  18 
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 4

From project accounted4, under directory /accounted4/stock-quote/stock-quote-yahoo/src/main/java/com/accounted4/stockquote/yahoo/.

Source file: YahooQuoteService.java

  18 
vote

private List<HashMap<QuoteAttribute,String>> processResponse(String response,List<QuoteAttribute> quoteAttributes){
  List<HashMap<QuoteAttribute,String>> result=new ArrayList<>();
  String[] lines=response.split("\n");
  for (  String line : lines) {
    String[] items=line.split(ATTRIBUTE_SEPARATOR);
    HashMap<QuoteAttribute,String> lineItem=new HashMap<>();
    int i=0;
    for (    String item : items) {
      lineItem.put(quoteAttributes.get(i++),item);
    }
    result.add(lineItem);
  }
  return result;
}
 

Example 5

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

Source file: AreaManager.java

  17 
vote

public ArrayList<StructureBlock> getChangedBlocks(ZoneXZ thisZone){
  ArrayList<StructureBlock> blockList=new ArrayList<StructureBlock>();
  int baseX=thisZone.getBaseX();
  int baseZ=thisZone.getBaseZ();
  World world=Bukkit.getWorlds().get(0);
  for (int y=Settings.getMaximumBuildY(); y >= Settings.getMinimumBuildY(); y--) {
    for (int x=0; x < Settings.getAreaSizeX(); x++) {
      for (int z=0; z < Settings.getAreaSizeZ(); z++) {
        if (world.getBlockTypeIdAt(baseX + x,y,baseZ + z) != Material.AIR.getId()) {
          blockList.add(new StructureBlock(x,y,z,0));
        }
      }
    }
  }
  return blockList;
}
 

Example 6

From project 2Degrees-Toolbox, under directory /ActionBarSherlock/src/android/support/v4/app/.

Source file: _ActionBarSherlockTrojanHorse.java

  16 
vote

@Override public boolean onCreatePanelMenu(int featureId,Menu menu){
  if (DEBUG)   Log.d(TAG,"[onCreatePanelMenu] featureId: " + featureId + ", menu: "+ menu);
  if (featureId == Window.FEATURE_OPTIONS_PANEL) {
    boolean result=onCreateOptionsMenu(menu);
    if (DEBUG)     Log.d(TAG,"[onCreatePanelMenu] activity create result: " + result);
    MenuInflater inflater=getSupportMenuInflater();
    boolean show=false;
    ArrayList<Fragment> newMenus=null;
    if (mFragments.mActive != null) {
      for (int i=0; i < mFragments.mAdded.size(); i++) {
        Fragment f=mFragments.mAdded.get(i);
        if (f != null && !f.mHidden && f.mHasMenu && f.mMenuVisible && f instanceof OnCreateOptionsMenuListener) {
          show=true;
          ((OnCreateOptionsMenuListener)f).onCreateOptionsMenu(menu,inflater);
          if (newMenus == null) {
            newMenus=new ArrayList<Fragment>();
          }
          newMenus.add(f);
        }
      }
    }
    if (mCreatedMenus != null) {
      for (int i=0; i < mCreatedMenus.size(); i++) {
        Fragment f=mCreatedMenus.get(i);
        if (newMenus == null || !newMenus.contains(f)) {
          f.onDestroyOptionsMenu();
        }
      }
    }
    mCreatedMenus=newMenus;
    if (DEBUG)     Log.d(TAG,"[onCreatePanelMenu] fragments create result: " + show);
    result|=show;
    if (DEBUG)     Log.d(TAG,"[onCreatePanelMenu] returning " + result);
    return result;
  }
  return false;
}
 

Example 7

From project 2Degrees-Toolbox, under directory /ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/.

Source file: Animator.java

  16 
vote

/** 
 * Adds a listener to the set of listeners that are sent events through the life of an animation, such as start, repeat, and end.
 * @param listener the listener to be added to the current set of listeners for this animation.
 */
public void addListener(AnimatorListener listener){
  if (mListeners == null) {
    mListeners=new ArrayList<AnimatorListener>();
  }
  mListeners.add(listener);
}
 

Example 8

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

Source file: Path.java

  16 
vote

public void prependStep(int x,int y){
  ArrayList<Step> t=new ArrayList<Step>();
  t.add(new Step(x,y));
  t.addAll(steps);
  steps=t;
}
 

Example 9

From project 4308Cirrus, under directory /Extras/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/.

Source file: Animator.java

  16 
vote

/** 
 * Adds a listener to the set of listeners that are sent events through the life of an animation, such as start, repeat, and end.
 * @param listener the listener to be added to the current set of listeners for this animation.
 */
public void addListener(AnimatorListener listener){
  if (mListeners == null) {
    mListeners=new ArrayList<AnimatorListener>();
  }
  mListeners.add(listener);
}
 

Example 10

From project 4308Cirrus, under directory /Extras/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/animation/.

Source file: Animator.java

  16 
vote

@Override public Animator clone(){
  try {
    final Animator anim=(Animator)super.clone();
    if (mListeners != null) {
      ArrayList<AnimatorListener> oldListeners=mListeners;
      anim.mListeners=new ArrayList<AnimatorListener>();
      int numListeners=oldListeners.size();
      for (int i=0; i < numListeners; ++i) {
        anim.mListeners.add(oldListeners.get(i));
      }
    }
    return anim;
  }
 catch (  CloneNotSupportedException e) {
    throw new AssertionError();
  }
}
 

Example 11

From project abalone-android, under directory /src/com/bytopia/abalone/.

Source file: BoardRenderer.java

  16 
vote

/** 
 * Updates sizes according to the given board diameter.
 * @param boardDiameter distance between two opposite corners of the board
 */
public void rescale(int boardDiameter,int size){
  Log.d("rescale","Rescaling the board");
  boardRect=new RectF(boardDiameter / 4f - 1,1,3f * boardDiameter / 4f + 1,boardDiameter / 2);
  balls=new ArrayList<RenderBall>();
  ballSize=((float)size - 2 * borderSize) / 9f;
  view.postInvalidate();
}
 

Example 12

From project Absolute-Android-RSS, under directory /src/com/AA/Activities/.

Source file: AAMain.java

  16 
vote

/** 
 * Called when the activity is created and put into memory. This is where all GUI elements should be set up and any other member variables that is used throughout the class
 */
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);
  articles=new ArrayList<Article>();
  settings=this.getSharedPreferences("settings",0);
  AlarmReceiver.stopAlarm(this);
  adapter=new ArticleAdapter(this);
  this.setListAdapter(adapter);
  ib_refresh=(ImageButton)findViewById(R.id.ib_refresh);
  TextView tv=(TextView)findViewById(R.id.AATitle);
  Typeface face=Typeface.createFromAsset(getAssets(),"fonts/WREXHAM_.TTF");
  tv.setTypeface(face);
  finishReceiver=new BroadcastReceiver(){
    @Override public void onReceive(    Context context,    Intent intent){
      articles.clear();
      Bundle articleBundle=intent.getBundleExtra("articles");
      ArrayList<String> titles=articleBundle.getStringArrayList("titles");
      for (      String title : titles)       articles.add((Article)articleBundle.getSerializable(title));
      progressDialog.cancel();
      refresh();
    }
  }
;
  this.registerReceiver(finishReceiver,new IntentFilter("RSSFinish"));
  ib_refresh.setOnClickListener(new OnClickListener(){
    /** 
 * Handles when the user clicks the refresh button
 * @param v - view that was clicked
 */
    @Override public void onClick(    View v){
      runService();
    }
  }
);
  runService();
}
 

Example 13

From project Absolute-Android-RSS, under directory /src/com/AA/Other/.

Source file: RSSParse.java

  16 
vote

/** 
 * Get the list of articles currently contained in the RSS feed.
 * @param isBackground if the request is being run in the background
 * @param callingContext current application context
 * @return List of articles contained in the RSS on success. On failure returns null
 */
public static List<Article> getArticles(boolean isBackground,Context callingContext){
  if (!isNetworkAvailable(isBackground,callingContext))   return null;
  Document doc=getDocument();
  if (doc == null)   return null;
  try {
    ArrayList<Article> articles=new ArrayList<Article>();
    NodeList items=doc.getElementsByTagName("item");
    for (int i=0; i < items.getLength(); i++) {
      Element el=(Element)items.item(i);
      String title=el.getElementsByTagName("title").item(0).getFirstChild().getNodeValue();
      String date=el.getElementsByTagName("pubDate").item(0).getFirstChild().getNodeValue();
      String url=el.getElementsByTagName("link").item(0).getFirstChild().getNodeValue();
      String desc=el.getElementsByTagName("description").item(0).getFirstChild().getNodeValue();
      articles.add(new Article(desc,title,date,url));
    }
    return articles;
  }
 catch (  Exception e) {
    Log.e("AARSS","Error Parsing RSS",e);
    return null;
  }
}
 

Example 14

From project acceleo-modules, under directory /ecore-gen-scala/plugins/com.github.sbegaudeau.acceleo.modules.ecore.gen.scala/src/com/github/sbegaudeau/acceleo/modules/ecore/gen/scala/main/.

Source file: EcoreGenScala.java

  16 
vote

/** 
 * This can be used to launch the generation from a standalone application.
 * @param args Arguments of the generation.
 * @generated
 */
public static void main(String[] args){
  try {
    if (args.length < 2) {
      System.out.println("Arguments not valid : {model, folder}.");
    }
 else {
      URI modelURI=URI.createFileURI(args[0]);
      File folder=new File(args[1]);
      List<String> arguments=new ArrayList<String>();
      EcoreGenScala generator=new EcoreGenScala(modelURI,folder,arguments);
      for (int i=2; i < args.length; i++) {
        generator.addPropertiesFile(args[i]);
      }
      generator.doGenerate(new BasicMonitor());
    }
  }
 catch (  IOException e) {
    e.printStackTrace();
  }
}
 

Example 15

From project AceWiki, under directory /src/ch/uzh/ifi/attempto/aceeditor/.

Source file: LexiconHandler.java

  16 
vote

/** 
 * Adds the word to the lexicon.
 * @param word The word to be added.
 */
public void addWord(Word word){
  if (word == null)   return;
  String w=word.getWordForm();
  if (w == null)   return;
  String catName=word.getCategory().getName();
  lexicon.addEntry(LexiconEntry.createEntry(word.getEntry()));
  if (categoryMap.get(catName) == null) {
    categoryMap.put(catName,new ArrayList<Word>());
  }
  categoryMap.get(catName).add(word);
  if (textMap.get(w) == null) {
    textMap.put(w,new ArrayList<Word>());
  }
  textMap.get(w).add(word);
}
 

Example 16

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

Source file: Generator.java

  15 
vote

public ArrayList<File> getTemplates(File path){
  ArrayList<File> r=new ArrayList<File>();
  if (path.exists()) {
    File[] files=path.listFiles();
    for (int i=0; i < files.length; i++) {
      if (files[i].isDirectory()) {
        r.addAll(getTemplates(files[i]));
      }
 else {
        r.add(files[i]);
      }
    }
  }
  return r;
}
 

Example 17

From project abalone-android, under directory /src/com/bytopia/abalone/.

Source file: BoardRenderer.java

  15 
vote

/** 
 * Notifies the renderer that the board was updated.
 * @param b board that was updated
 */
public void updateBoard(Board b){
  this.board=b;
  Log.d("update","BoardDrawer.UpdateBoard at " + System.nanoTime());
  balls=new ArrayList<RenderBall>();
  for (int i=1; i <= 9; i++) {
    float shift=(5f - i) * ballSize / 2f;
    float x, y;
    for (int j=1; j <= 9; j++) {
      int state=b.getState(i,j);
      if (state != Layout.N) {
        x=borderSize + shift + (j - 1) * ballSize + ballSize / 2f;
        y=(float)(borderSize + (i - 1) * ballSize * SQRT3_2) + ballSize / 2f;
        balls.add(new RenderBall(x,y,state));
      }
    }
  }
  if (animBalls != null) {
    animBalls=null;
  }
  if (emptyBalls != null) {
    emptyBalls=null;
  }
  animation=false;
  view.postInvalidate();
}
 

Example 18

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

Source file: Workflow.java

  15 
vote

/** 
 * This can be used to launch the generation from a standalone application.
 * @param args Arguments of the generation.
 * @generated
 */
public static void main(String[] args){
  try {
    if (args.length < 2) {
      System.out.println("Arguments not valid : {model, folder}.");
    }
 else {
      URI modelURI=URI.createFileURI(args[0]);
      File folder=new File(args[1]);
      List<String> arguments=new ArrayList<String>();
      Workflow generator=new Workflow(modelURI,folder,arguments);
      for (int i=2; i < args.length; i++) {
        generator.addPropertiesFile(args[i]);
      }
      generator.doGenerate(new BasicMonitor());
    }
  }
 catch (  IOException e) {
    e.printStackTrace();
  }
}
 

Example 19

From project acceleo-webapp-generator, under directory /plugins/org.eclipse.acceleo.tutorial.extension/src/org/eclipse/acceleo/tutorial/extension/main/.

Source file: Extension.java

  15 
vote

/** 
 * This can be used to launch the generation from a standalone application.
 * @param args Arguments of the generation.
 * @generated
 */
public static void main(String[] args){
  try {
    if (args.length < 2) {
      System.out.println("Arguments not valid : {model, folder}.");
    }
 else {
      URI modelURI=URI.createFileURI(args[0]);
      File folder=new File(args[1]);
      List<String> arguments=new ArrayList<String>();
      Extension generator=new Extension(modelURI,folder,arguments);
      for (int i=2; i < args.length; i++) {
        generator.addPropertiesFile(args[i]);
      }
      generator.doGenerate(new BasicMonitor());
    }
  }
 catch (  IOException e) {
    e.printStackTrace();
  }
}
 

Example 20

From project acceleo-webapp-generator, under directory /plugins/org.eclipse.acceleo.tutorial.extension.ui/src/org/eclipse/acceleo/tutorial/extension/ui/common/.

Source file: GenerateAll.java

  15 
vote

/** 
 * Launches the generation.
 * @param monitor This will be used to display progress information to the user.
 * @throws IOException Thrown when the output cannot be saved.
 * @generated
 */
public void doGenerate(IProgressMonitor monitor) throws IOException {
  if (!targetFolder.getLocation().toFile().exists()) {
    targetFolder.getLocation().toFile().mkdirs();
  }
  monitor.subTask("Loading...");
  org.eclipse.acceleo.tutorial.extension.main.Extension gen0=new org.eclipse.acceleo.tutorial.extension.main.Extension(modelURI,targetFolder.getLocation().toFile(),arguments);
  monitor.worked(1);
  String generationID=org.eclipse.acceleo.engine.utils.AcceleoLaunchingUtil.computeUIProjectID("org.eclipse.acceleo.tutorial.extension","org.eclipse.acceleo.tutorial.extension.main.Extension",modelURI.toString(),targetFolder.getFullPath().toString(),new ArrayList<String>());
  gen0.setGenerationID(generationID);
  gen0.doGenerate(BasicMonitor.toMonitor(monitor));
}
 

Example 21

From project accent, under directory /src/main/java/net/lshift/accent/.

Source file: AccentConfirmPublisher.java

  15 
vote

private void applyResult(FeedbackResult result,long seqNo,boolean multiple){
synchronized (waiting) {
    List<FeedbackHandle> toRemove=new ArrayList<FeedbackHandle>();
    for (    FeedbackHandle handle : waiting) {
      if (handle.ackApplies(seqNo,multiple)) {
        handle.setResult(result);
        toRemove.add(handle);
      }
    }
    waiting.removeAll(toRemove);
  }
}
 

Example 22

From project accesointeligente, under directory /src/org/accesointeligente/server/robots/.

Source file: SIAC.java

  15 
vote

@Override public void login() throws Exception {
  if (characterEncoding == null) {
    detectCharacterEncoding();
  }
  List<NameValuePair> formParams;
  HttpPost post;
  HttpResponse response;
  TagNode document, hiddenUser;
  try {
    formParams=new ArrayList<NameValuePair>();
    formParams.add(new BasicNameValuePair("usuario",username));
    formParams.add(new BasicNameValuePair("clave",password));
    formParams.add(new BasicNameValuePair("accion","login"));
    post=new HttpPost(baseUrl + "/formulario.gov");
    post.addHeader("Referer",baseUrl + "/formulario.gov?accion=ingresa");
    post.setEntity(new UrlEncodedFormEntity(formParams,characterEncoding));
    response=client.execute(post);
    document=cleaner.clean(new InputStreamReader(response.getEntity().getContent(),characterEncoding));
    hiddenUser=document.findElementByAttValue("id","user",true,true);
    if (hiddenUser == null || !hiddenUser.hasAttribute("value") || hiddenUser.getAttributeByName("value").equals("0")) {
      throw new RobotException("Invalid user id field");
    }
    userId=hiddenUser.getAttributeByName("value");
    loggedIn=true;
  }
 catch (  Exception ex) {
    logger.error(ex.getMessage(),ex);
    throw ex;
  }
}
 

Example 23

From project accesointeligente, under directory /src/org/accesointeligente/server/services/.

Source file: RequestServiceImpl.java

  15 
vote

@Override public Page<Request> getUserFavoriteRequestList(Integer offset,Integer limit) throws ServiceException {
  Session hibernate=HibernateUtil.getSession();
  hibernate.beginTransaction();
  try {
    User user=SessionUtil.getUser(getThreadLocalRequest().getSession());
    Criteria criteria=hibernate.createCriteria(UserFavoriteRequest.class);
    criteria.add(Restrictions.eq("user",user));
    criteria.setProjection(Projections.countDistinct("request"));
    Long totalResults=(Long)criteria.uniqueResult();
    List<Request> requests=new ArrayList<Request>(0);
    if (totalResults > 0) {
      criteria=hibernate.createCriteria(UserFavoriteRequest.class);
      criteria.add(Restrictions.eq("user",user));
      criteria.setProjection(Projections.distinct(Projections.property("request.id")));
      criteria.setFirstResult(offset);
      criteria.setMaxResults(limit);
      List<Long> ids=criteria.list();
      if (!ids.isEmpty()) {
        criteria=hibernate.createCriteria(Request.class);
        criteria.add(Restrictions.in("id",ids));
        criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
        criteria.setFetchMode("institution",FetchMode.JOIN);
        criteria.setFetchMode("favorites",FetchMode.JOIN);
        criteria.setFetchMode("responses",FetchMode.JOIN);
        requests=(List<Request>)persistentBeanManager.clone(criteria.list());
      }
    }
    hibernate.getTransaction().commit();
    Page<Request> page=new Page<Request>();
    page.setStart(offset.longValue());
    page.setDataCount(totalResults);
    page.setData(requests);
    return page;
  }
 catch (  Throwable ex) {
    hibernate.getTransaction().rollback();
    throw new ServiceException();
  }
}
 

Example 24

From project accounted4, under directory /accounted4/stock-quote/stock-quote-yahoo/src/main/java/com/accounted4/stockquote/yahoo/.

Source file: YahooQuoteService.java

  15 
vote

@Override public List<HashMap<QuoteAttribute,String>> executeQuery(List<String> securityList,List<QuoteAttribute> quoteAttributes){
  String tickerList=securityListToString(securityList);
  String attributeList=attributeListToString(quoteAttributes);
  HttpClient httpclient=new DefaultHttpClient();
  String urlString=BASE_URL + "?" + "s="+ tickerList+ "&"+ "f="+ attributeList;
  System.out.println("Query url: " + urlString);
  HttpGet httpGet=new HttpGet(urlString);
  try {
    HttpResponse response=httpclient.execute(httpGet);
    HttpEntity entity=response.getEntity();
    if (entity != null) {
      String stringResponse=EntityUtils.toString(entity);
      return processResponse(stringResponse,quoteAttributes);
    }
  }
 catch (  IOException ex) {
    System.out.println("Error " + ex);
  }
  List<HashMap<QuoteAttribute,String>> result=new ArrayList<>();
  return result;
}
 

Example 25

From project AceWiki, under directory /src/ch/uzh/ifi/attempto/aceeditor/.

Source file: ACEEditorMenuCreator.java

  15 
vote

public List<SpecialMenuItem> createSpecialMenuItems(NextTokenOptions options){
  List<SpecialMenuItem> items=new ArrayList<SpecialMenuItem>();
  Map<String,String> m=new HashMap<String,String>();
  for (  String s : extCats) {
    if (options.containsCategory(s)) {
      String menuGroup=cats.get(s);
      if (m.containsKey(menuGroup)) {
        m.put(menuGroup,m.get(menuGroup) + s + ":");
      }
 else {
        m.put(menuGroup,"new:" + s + ":");
      }
    }
  }
  if (!editor.isLexiconImmutable()) {
    for (    String menuGroup : m.keySet()) {
      items.add(new SpecialMenuItem("new...",menuGroup,m.get(menuGroup),this));
    }
  }
  return items;
}