Android Open Source - MobileCodeGenerator Java Checks






From Project

Back to project page MobileCodeGenerator.

License

The source code is released under:

GNU General Public License

If you think the Android project MobileCodeGenerator listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/************************************************************************************************************************
 * Copyright 2013 Gregorio Perego, Stefania Pezzetti
 * This file is part of it.polimi.mobilecodegenerator.
 * //from ww w.  j a v a  2s .  c om
 * it.polimi.mobilecodegenerator is free software: 
 * you can redistribute it and/or modify it under the terms of the 
 * GNU General Public License as published by the Free Software Foundation, 
 * either version 3 of the License, or (at your option) any later version.
 * 
 * it.polimi.mobilecodegenerator is distributed in the hope that it will be useful, 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
 * See the GNU General Public License for more details.You should have received a copy of the GNU General Public License
 * along with it.polimi.mobilecodegenerator. If not, see <http://www.gnu.org/licenses/>
 * ***********************************************************************************************************************/

package model_checks;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

public class JavaChecks {
  public static List<String> duplicatedIds(List<String> ids){
    ArrayList<String> duplicates = new ArrayList<String>();
    for(int i=0; i<ids.size(); i++)
      for(int j=0; j<ids.size(); j++){
        if(ids.get(i).equals(ids.get(j)) && i!=j && !duplicates.contains(ids.get(i)))
          duplicates.add(ids.get(i));
      }
    return duplicates;
  }
  
  
  
  public static List<String> invalidFilesNames(){
    String regex = "^[a-z0-9_]+";
    File folder = new File("utils/user_files");
    ArrayList<String> invalidFilesNames = new ArrayList<String>();
    for(File source : folder.listFiles()){
      if(source.isDirectory() || source.getName().length()<1 || source.getName().split("\\.").length!=2 || !source.getName().split("\\.")[0].matches(regex))
        invalidFilesNames.add(source.getName());
    }
    return invalidFilesNames;
  }
  
  public static boolean validAppName(String name){
    String regex = "^[a-zA-Z]+"; //empty string is not valid too
    if(!name.matches(regex))
      return false;
    return true;
  }
  
  public static boolean validCompanyIdentifier(String id){
    String regex = "^[a-z]+(\\.[a-z]+)*";
    if(!id.matches(regex))
      return false;
    return true;
  }
  
  public static List<String> invalidIds(List<String> ids){
    String regex = "^[a-zA-Z][a-zA-Z0-9_]*"; //empty string is not valid too
    ArrayList<String> invalidIds = new ArrayList<String>();
    for(String id : ids){
      if(!id.matches(regex))
        invalidIds.add(id);
    }
    return invalidIds;
  }
  
  public static List<String> invalidFilesExtensions(){
    File folder = new File("utils/user_files");
    ArrayList<String> invalidFilesExtensions = new ArrayList<String>();
    for(File source : folder.listFiles()){
      String sourceFileExtension = source.getName().split("\\.")[1];
      if(!(  sourceFileExtension.equalsIgnoreCase("html") ||
          sourceFileExtension.equalsIgnoreCase("txt") ||
          sourceFileExtension.equalsIgnoreCase("css") ||
          sourceFileExtension.equalsIgnoreCase("png") ||
          sourceFileExtension.equalsIgnoreCase("jpg") ||
          sourceFileExtension.equalsIgnoreCase("gif") ||
          sourceFileExtension.equalsIgnoreCase("mp4") ||
          sourceFileExtension.equalsIgnoreCase("3gp") ||
          sourceFileExtension.equalsIgnoreCase("mp3") )){
        invalidFilesExtensions.add(source.getName());
      }
    }
    return invalidFilesExtensions;
  }
  
  public static List<String> duplicatedFilesNames(){
    File folder = new File("utils/user_files");
    ArrayList<String> duplicatedFilesNames = new ArrayList<String>();
    for(int i=0; i<folder.listFiles().length; i++){
      for(int j=0; j<folder.listFiles().length; j++)
        if(i!=j && folder.listFiles()[i].getName().split("\\.")[0].equals(folder.listFiles()[j].getName().split("\\.")[0]) && !duplicatedFilesNames.contains(folder.listFiles()[i]))
          duplicatedFilesNames.add(folder.listFiles()[i].getName());
    }
    return duplicatedFilesNames;
  }
}




Java Source Code List

android_extensions.AndroidConstants.java
android_extensions.AndroidJavaUtil.java
app_extensions.AppJavaUtil.java
ios_extensions.IOSConstants.java
ios_extensions.IOSJavaUtil.java
it.polimi.multimedia.AudioListActivity.java
it.polimi.multimedia.AudioListActivity.java
it.polimi.multimedia.AudioPlayerActivity.java
it.polimi.multimedia.AudioPlayerActivity.java
it.polimi.multimedia.AudioRecorderActivity.java
it.polimi.multimedia.AudioRecorderActivity.java
it.polimi.multimedia.GalleryActivity.java
it.polimi.multimedia.GalleryActivity.java
it.polimi.multimedia.MenuActivity.java
it.polimi.multimedia.MenuActivity.java
it.polimi.multimedia.PhotoGridActivity.java
it.polimi.multimedia.PhotoGridActivity.java
it.polimi.multimedia.PhotoViewerActivity.java
it.polimi.multimedia.PhotoViewerActivity.java
it.polimi.multimedia.PhotocameraActivity.java
it.polimi.multimedia.PhotocameraActivity.java
it.polimi.multimedia.Utils.java
it.polimi.multimedia.Utils.java
it.polimi.multimedia.VideoListActivity.java
it.polimi.multimedia.VideoListActivity.java
it.polimi.multimedia.VideoViewerActivity.java
it.polimi.multimedia.VideoViewerActivity.java
it.polimi.multimedia.VideocameraActivity.java
it.polimi.multimedia.VideocameraActivity.java
it.polimi.promemoria.HomeActivity.java
it.polimi.promemoria.NoteDetailActivity.java
it.polimi.promemoria.NotesListActivity.java
it.polimi.promemoria.Utils.java
it.polimi.valtellina.DescriptionActivity.java
it.polimi.valtellina.DescriptionActivity.java
it.polimi.valtellina.ImageDownloadingTask.java
it.polimi.valtellina.ImageDownloadingTask.java
it.polimi.valtellina.MenuActivity.java
it.polimi.valtellina.MenuActivity.java
it.polimi.valtellina.TurismLocationDetailActivity.java
it.polimi.valtellina.TurismLocationDetailActivity.java
it.polimi.valtellina.TurismLocationsListActivity.java
it.polimi.valtellina.TurismLocationsListActivity.java
it.polimi.valtellina.Utils.java
it.polimi.valtellina.Utils.java
it.polimi.valtellina.VideoActivity.java
it.polimi.valtellina.VideoActivity.java
model_checks.JavaChecks.java