Example usage for java.util ArrayList contains

List of usage examples for java.util ArrayList contains

Introduction

In this page you can find the example usage for java.util ArrayList contains.

Prototype

public boolean contains(Object o) 

Source Link

Document

Returns true if this list contains the specified element.

Usage

From source file:com.globalsight.util.edit.SegmentUtil.java

public static String restoreEntity(String str, ArrayList arrayList) {
    if (arrayList.contains("<")) {
        str = str.replaceAll("_xliff_lt_tag", "<");
    }//from  w  w w .j a  v  a 2 s  .c om

    if (arrayList.contains(">")) {
        str = str.replaceAll("_xliff_gt_tag", ">");
    }

    if (arrayList.contains("&")) {
        str = str.replaceAll("_xliff_amp_tag", "&");
    }

    if (arrayList.contains(""")) {
        str = str.replaceAll("_xliff_quot_tag", """);
    }

    if (arrayList.contains("'")) {
        str = str.replaceAll("_xliff_apos_tag", "'");
    }

    if (arrayList.contains("
")) {
        str = str.replaceAll("_xliff_xa_tag", "
");
    }

    if (arrayList.contains("
")) {
        str = str.replaceAll("_xliff_xd_tag", "
");
    }

    if (arrayList.contains("	")) {
        str = str.replaceAll("_xliff_x9_tag", "	");
    }

    return str;
}

From source file:css.variable.converter.CSSVariableConverter.java

/**
 * Go through existing CSS Files and replace variable access with variable
 * values//from   www  .  j  a v a2 s. c  o m
 *
 * @param rootCSSVars All css variables you want to convert from name to value
 */
private static void editForRelease(ArrayList<CSSVar> rootCSSVars) {
    for (File cssFile : theCSSList) {

        ArrayList<CSSVar> localCSSVars = getCSSVars(cssFile, ":local");
        for (CSSVar cssVar : rootCSSVars) {
            if (!localCSSVars.contains(cssVar)) {
                localCSSVars.add((CSSVar) (cssVar.clone()));
            }
        }

        // This will store info the new text for the file we will write below
        ArrayList<String> filesNewInfo = new ArrayList<String>();
        try {

            Scanner fileReader = new Scanner(cssFile);
            while (fileReader.hasNextLine()) {

                String currentLine = fileReader.nextLine();

                // If we find variables, replace them, with their value
                if (currentLine.contains("var(")) {
                    for (CSSVar var : localCSSVars) {
                        while (currentLine.contains(var.getName())) {
                            currentLine = currentLine.replace("var(" + var.getName() + ")", var.getValue());
                        }
                    }
                }
                // Add new currentLine to be written
                filesNewInfo.add(currentLine);
            }
            fileReader.close();
        } catch (FileNotFoundException ex) {
            Logger.getLogger(CSSVariableConverter.class.getName()).log(Level.SEVERE, null, ex);
        }

        // Write the new files below
        try {
            BufferedWriter writer = new BufferedWriter(new FileWriter(cssFile.getPath()));

            while (!filesNewInfo.isEmpty()) {
                writer.write(filesNewInfo.get(0));
                writer.newLine();
                filesNewInfo.remove(0);
            }
            writer.close();
        } catch (IOException ex) {
            Logger.getLogger(CSSVariableConverter.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}

From source file:com.data2semantics.yasgui.server.db.ConnectionFactory.java

private static void applyDeltas(Connection connect, File configDir)
        throws UnsupportedEncodingException, IOException, SQLException {
    @SuppressWarnings("unchecked")
    ArrayList<File> listFiles = new ArrayList<File>(
            FileUtils.listFiles(new File(configDir.getAbsolutePath() + "/config"),
                    FileFilterUtils.prefixFileFilter("delta_"), null));

    TreeMap<Integer, File> files = new TreeMap<Integer, File>();
    for (File file : listFiles) {
        String basename = file.getName();
        basename = basename.substring("delta_".length());
        basename = basename.substring(0, basename.length() - ".sql".length());
        int index = Integer.parseInt(basename);
        files.put(index, file);/*w  w w. j av  a  2 s  .  com*/
    }
    ArrayList<Integer> currentDeltas = getDeltas(connect);
    //treemap is naturally sorted, so just iterate through them
    for (Entry<Integer, File> entry : files.entrySet()) {
        if (!currentDeltas.contains(entry.getKey())) {
            ScriptRunner runner = new ScriptRunner(connect, false, true);
            FileInputStream fileStream = new FileInputStream(entry.getValue());
            runner.runScript(new BufferedReader(new InputStreamReader(fileStream, "UTF-8")));
            fileStream.close();
            setDeltaApplied(connect, entry.getKey());
        }

    }
}

From source file:Main.java

public static boolean hasImageCaptureBug() {

    // list of known devices that have the bug
    ArrayList<String> devices = new ArrayList<String>();
    devices.add("android-devphone1/dream_devphone/dream");
    devices.add("generic/sdk/generic");
    devices.add("vodafone/vfpioneer/sapphire");
    devices.add("tmobile/kila/dream");
    devices.add("verizon/voles/sholes");
    devices.add("google_ion/google_ion/sapphire");

    return devices
            .contains(android.os.Build.BRAND + "/" + android.os.Build.PRODUCT + "/" + android.os.Build.DEVICE);

}

From source file:Main.java

public static void removeUnusedTiles(Context mContext, final ArrayList<String> usedTiles) {
    // remove all files are stored in the tile path but are not used
    File folder = new File(mContext.getFilesDir(), TILE_PATH);
    File[] unused = folder.listFiles(new FilenameFilter() {

        @Override/*  www .ja  v a 2  s . c  om*/
        public boolean accept(File dir, String filename) {
            return !usedTiles.contains(filename);
        }
    });

    if (unused != null) {
        for (File f : unused) {
            f.delete();
        }
    }
}

From source file:com.lucidtechnics.blackboard.util.Utility.java

public static ArrayList getAllTypes(ArrayList _searchDomainList, ArrayList _allTypesList) {
    for (int i = 0; i < _searchDomainList.size(); i++) {
        Class searchClass = (Class) _searchDomainList.get(i);
        _searchDomainList.remove(searchClass);

        Class superClass = searchClass.getSuperclass();

        if (superClass != null && (_allTypesList.contains(superClass) == false)) {
            _searchDomainList.add(superClass);
            _allTypesList.add(superClass);
        }/*from  w  ww. ja v  a  2s.c  o  m*/

        Class[] interfaceArray = searchClass.getInterfaces();

        if (interfaceArray != null) {
            for (int j = 0; j < interfaceArray.length; j++) {
                if (interfaceArray[j] != null && (_allTypesList.contains(interfaceArray[j]) == false)) {
                    _searchDomainList.add(interfaceArray[j]);
                    _allTypesList.add(interfaceArray[j]);
                }
            }
        }
    }

    if (_searchDomainList.isEmpty() == false) {
        _allTypesList = getAllTypes(_searchDomainList, _allTypesList);
    }

    return _allTypesList;
}

From source file:com.sp.Parser.Utils.java

public static SolrDocumentList DedupByBookId(SolrDocumentList SolrDocList) {

    SolrDocumentList TempList = new SolrDocumentList();
    ArrayList<String> TempStringList = new ArrayList<>();

    String doc_book_id;/*ww  w.jav  a  2s.co m*/
    for (SolrDocument doc : SolrDocList) {
        doc_book_id = doc.getFieldValue("book_id").toString();
        if (!TempStringList.contains(doc_book_id)) {
            //System.out.println("doc_book_id " + doc_book_id);
            TempStringList.add(doc_book_id);
            TempList.add(doc);
        }
    }
    System.out.println("Templist size " + TempList.size());
    return TempList;
}

From source file:com.dastardlylabs.ti.ocrdroid.OcrdroidModule.java

private static boolean tessDataExists() {
    ArrayList<String> dataFiles = new ArrayList<String>();
    Collections.addAll(dataFiles, getTessDataDirectory().list());

    JSONArray fred = new JSONArray(dataFiles);

    Log.d(LCAT, "DataFiles list: " + fred.toString());

    return dataFiles.contains((Object) "tessdata");
}

From source file:kilim.tools.FlowAnalyzer.java

private static String uniqueItems(BasicBlock bb, Frame f, Usage u, int nStack) {
    StringBuffer sb = new StringBuffer(80);
    int numNonConstants = 0;
    int numLive = 0;
    ArrayList<Value> set = new ArrayList<Value>(10);
    for (int i = 0; i < f.getMaxLocals(); i++) {
        if (u.isLiveIn(i)) {
            numLive++;//from  www.j a  v a2  s .  c  o  m
            Value v = f.getLocal(i);
            if (!set.contains(v))
                set.add(v);
        }
    }
    nStack = f.getStackLen() - nStack;
    for (int i = 0; i < nStack; i++) {
        Value v = f.getStack(i);
        if (!set.contains(v))
            set.add(v);
    }
    char[] sig = new char[set.size()];
    // create canonical sig. Convert types to one of 'O', 'I', 'F', 'L', 'D' and
    // put in sorted order
    // Also count non constants while we are iterating anyway.
    for (int i = 0; i < set.size(); i++) {
        Value v = set.get(i);
        char c = v.getTypeDesc().charAt(0);
        switch (c) {
        case 'L':
        case '[':
        case 'N':
            c = 'O';
            break;
        case 'I':
        case 'B':
        case 'S':
        case 'Z':
        case 'C':
            c = 'I';
            break;
        case 'J':
            c = 'J';
            break;
        case 'F':
            c = 'F';
            break;
        case 'U':
        default: {
            c = 'U';
            log.error("***************************************");
            log.error("Undefined/unrecognized value " + v);
            log.error("BasicBlock:\n" + bb);
            break;
        }
        }
        sig[i] = c;
        if (v.getConstVal() == Value.NO_VAL) {
            numNonConstants++;
        }
    }
    Arrays.sort(sig);
    numLive += nStack;
    sb.append("avail: ").append(nStack + f.getMaxLocals());
    sb.append(", live: " + numLive);
    sb.append(", unique: ").append(set.size());
    sb.append(", unique non-const: ").append(numNonConstants);
    sb.append("\nState signature: ").append(set.size() == 0 ? "None" : new String(sig));
    return sb.toString();
}

From source file:Main.java

public static boolean hasImageCaptureBug() {
    // list of known devices that have the bug
    ArrayList<String> devices = new ArrayList<String>();
    devices.add("android-devphone1/dream_devphone/dream");
    devices.add("generic/sdk/generic");
    devices.add("vodafone/vfpioneer/sapphire");
    devices.add("tmobile/kila/dream");
    devices.add("verizon/voles/sholes");
    devices.add("google_ion/google_ion/sapphire");
    devices.add("SEMC/X10i_1232-9897/X10i");

    return devices
            .contains(android.os.Build.BRAND + "/" + android.os.Build.PRODUCT + "/" + android.os.Build.DEVICE);
}