Example usage for java.lang String contentEquals

List of usage examples for java.lang String contentEquals

Introduction

In this page you can find the example usage for java.lang String contentEquals.

Prototype

public boolean contentEquals(CharSequence cs) 

Source Link

Document

Compares this string to the specified CharSequence .

Usage

From source file:marytts.tools.dbselection.DatabaseSelector.java

/***
 * Manual selection of wanted/unwanted selected sentences
 *
 *//*  w  w w . j  ava  2 s . c om*/
private static void checkSelectedSentences() {
    InputStreamReader isr = new InputStreamReader(System.in);
    BufferedReader br = new BufferedReader(isr);

    try {
        System.out.println("\nChecking selected sentences whether they are wanted or not.");
        System.out.println(" selected sentences will be saved in ./selected.log");
        PrintWriter selectedLog = new PrintWriter(new FileWriter(new File("./selected.log")));

        System.out.println(
                " selected sentences and transcriptions will be saved in  ./selected_text_transcription.log");
        PrintWriter selected_tra_Log = new PrintWriter(
                new FileWriter(new File("./selected_text_transcription.log")));

        System.out.println(" unwanted sentences will be saved in ./unwanted.log");
        PrintWriter unwantedLog = new PrintWriter(new FileWriter(new File("./unwanted.log")));

        int sel[] = wikiToDB.getIdListOfType("dbselection", "selected=true and unwanted=false");

        if (sel != null) {
            // checking selected sentences
            System.out.println(
                    " Select \"y\" for marking sentence as \"wanted\" otherwise \"n\" . Press any other key to finish: \n");
            String str;
            for (int i = 0; i < sel.length; i++) {
                str = wikiToDB.getSelectedSentence(wikiToDB.getSelectedSentencesTableName(), sel[i]);
                System.out.print("id=" + sel[i] + ":  " + str + "\n  Wanted?(y/n):");

                String s = br.readLine();
                if (s.contentEquals("n")) {
                    wikiToDB.setSentenceRecord(sel[i], "unwanted", true);
                    unwantedLog.println(sel[i] + " " + str);
                } else if (s.contentEquals("y")) {
                    selectedLog.println(sel[i] + " " + str);

                    selected_tra_Log.println(sel[i] + " " + str);
                    selected_tra_Log.println(sel[i] + " <" + SelectionFunction.transcribe(str, locale) + ">");
                } else {
                    unwantedLog.close();
                    selectedLog.close();

                    selected_tra_Log.close();

                    break;
                }
            }
        } else
            System.out.println("There is no selected sentences in the DB.");

    } catch (Exception e) {
        System.out.println(e);
    }

}

From source file:org.ebayopensource.turmeric.eclipse.test.utils.TLUtil.java

/**
 * Import action.//from w ww  .  j a  v a2  s  .  co m
 *
 * @param importType the import type
 * @param projectName the project name
 * @param typeName the type name
 * @param importTypeName the import type name
 * @param importTypeNS the import type ns
 * @return true, if successful
 */
public static boolean importAction(String importType, String projectName, String typeName,
        String importTypeName, String importTypeNS) {
    IFile xsdFile, wsdlFile = null;

    IEditorPart editorPart;

    try {
        if (importType.contentEquals("TYPELIB")) {
            IProject typeLibProject = ProjectUtil.getProject(projectName);
            xsdFile = typeLibProject.getFile(File.separator + "meta-src" + File.separator + "types"
                    + File.separator + projectName + File.separator + typeName);
            WorkspaceUtil.refresh(xsdFile);
            System.out.println("Type Name --- " + xsdFile.getFullPath().toString());

            IDE.openEditor(UIUtil.getActiveWorkBenchWindow().getActivePage(), xsdFile);

            editorPart = UIUtil.getActiveEditor();
            LibraryType type = SOAGlobalRegistryAdapter.getInstance().getGlobalRegistry()
                    .getType(new QName(importTypeNS, importTypeName));

            LibraryType[] selectedTypes = new LibraryType[1];
            selectedTypes[0] = type;
            System.out.println("SelectedType[0] -- " + selectedTypes[0].getName());
            Object adaptedObject = TypeLibraryUtil.getAdapterClassFromWTPEditors(editorPart);

            ImportTypeFromTypeLibrary.performImportTasksForXSDEditor((XSDSchema) adaptedObject, selectedTypes,
                    xsdFile);

            editorPart.doSave(ProgressUtil.getDefaultMonitor(null));
            UIUtil.getActivePage().closeAllEditors(true);
            WorkspaceUtil.refresh(xsdFile);

        } else {
            // IProject typeLibProject =
            // ProjectUtil.getProject(projectName);
            wsdlFile = SOAServiceUtil.getWsdlFile(projectName);
            if (wsdlFile == null) {
                System.out.println("WSDL file does not exist.Hence returning false");
                return false;
            }
            WorkspaceUtil.refresh(wsdlFile);

            System.out.println("Wsdl File --- " + wsdlFile.getFullPath().toString() + "Wsdl Exists -- "
                    + wsdlFile.exists());
            IDE.openEditor(UIUtil.getActiveWorkBenchWindow().getActivePage(), wsdlFile);

            editorPart = UIUtil.getActiveEditor();
            // TypeLibraryType typeLibInfo = SOAGlobalRegistryAdapter
            // .getGlobalRegistry().getTypeLibrary("HardwareTypeLibrary");
            // LibraryType type =
            // TypeLibraryUtil.getLibraryType(importTypeName, "1.0.0",
            // typeLibInfo);

            LibraryType type = SOAGlobalRegistryAdapter.getInstance().getGlobalRegistry()
                    .getType(new QName(importTypeNS, importTypeName));

            LibraryType[] selectedTypes = new LibraryType[1];
            selectedTypes[0] = type;
            System.out.println("SelectedType[0] -- " + selectedTypes[0].getName());
            Object adaptedObject = TypeLibraryUtil.getAdapterClassFromWTPEditors(editorPart);

            // Import from wsdl
            ImportTypeFromTypeLibrary.performInlineOperationsForWSDLEditor((Definition) adaptedObject,
                    selectedTypes, wsdlFile);
            editorPart.doSave(ProgressUtil.getDefaultMonitor(null));
            WorkspaceUtil.refresh(wsdlFile);
        }
        return true;
    } catch (Exception e) {
        e.printStackTrace();
        return false;
    }
}

From source file:org.yaoha.ApiConnector.java

public static List<URI> getRequestUriXapi(String longitudeLow, String latitudeLow, String longitudeHigh,
        String latitudeHigh, String name, String amenity, String shop, boolean edit_mode) {
    String requestString = "node[bbox=" + longitudeLow + "," + latitudeLow + "," + longitudeHigh + ","
            + latitudeHigh + "]";
    if (name != null)
        requestString += "[name=*" + name + "*]";
    else/*from  w  ww  . j a  va2  s  . com*/
        requestString += "[name=*]";

    if (!edit_mode)
        requestString += "[opening_hours=*]";

    String requestStringAmenity = requestString;
    String requestStringShop = requestString;
    if (edit_mode) {
        if (amenity != null)
            requestStringAmenity += "[amenity=*" + amenity + "*]";
        else
            requestStringAmenity += "[amenity=*]";
        if (shop != null)
            requestStringShop += "[shop=*" + shop + "*]";
        else
            requestStringShop += "[shop=*]";
    }

    List<URI> requestStrings = new ArrayList<URI>();
    try {
        URI uri = new URI("http", xapiUrl, "/api/xapi", requestStringAmenity, null);
        requestStrings.add(uri);
    } catch (URISyntaxException e) {
        Log.d(ApiConnector.class.getSimpleName(), e.getMessage());
    }

    if (!requestStringAmenity.contentEquals(requestStringShop)) {
        try {
            URI uri = new URI("http", xapiUrl, "/api/xapi", requestStringShop, null);
            requestStrings.add(uri);
        } catch (URISyntaxException e) {
            Log.d(ApiConnector.class.getSimpleName(), e.getMessage());
        }
    }

    return requestStrings;
}

From source file:com.eislab.af.translator.Translator_hub_i.java

private static String findOutgoingIpForGivenAdress(String remoteIP) {

    if (System.getProperty("os.name").contains("Windows")) {
        final String COMMAND = "route print -4";
        List<RouteInfo> routes = new ArrayList<>();
        try {/*from  w w  w . j  a  va2  s . c  o  m*/
            Process exec = Runtime.getRuntime().exec(COMMAND);
            BufferedReader reader = new BufferedReader(new InputStreamReader(exec.getInputStream()));

            System.out.println(System.getProperty("os.name"));
            String line;
            /* examples:
              0.0.0.0          0.0.0.0     10.172.180.1    10.172.180.36     20
              0.0.0.0          0.0.0.0      10.187.20.1    10.187.20.225     25
               10.172.180.0    255.255.255.0         On-link     10.172.180.36    276
              10.172.180.36  255.255.255.255         On-link     10.172.180.36    276
            */
            Pattern p = Pattern.compile(
                    "^\\s*(\\d+\\.\\d+\\.\\d+\\.\\d+)\\s+(\\d+\\.\\d+\\.\\d+\\.\\d+)\\s+\\S+?\\s+(\\d+\\.\\d+\\.\\d+\\.\\d+)\\s+(\\d+)\\s*$");
            while ((line = reader.readLine()) != null) {
                Matcher match = p.matcher(line);
                if (match.matches()) {
                    String network = match.group(1);
                    String mask = match.group(2);
                    String address = match.group(3);
                    short maskLength = 0;
                    boolean networkMatch = network.contentEquals("0.0.0.0");

                    if (!networkMatch) {
                        SubnetUtils subnet = new SubnetUtils(network, mask);
                        SubnetUtils.SubnetInfo info = subnet.getInfo();
                        networkMatch = info.isInRange(remoteIP);
                        maskLength = Short.valueOf(info.getCidrSignature().split("/")[1]);
                    }

                    if (networkMatch) {
                        short metric = Short.valueOf(match.group(4));
                        routes.add(new RouteInfo(address, (short) 0, maskLength, metric));
                    }

                }
            }
            Collections.sort(routes);
            for (RouteInfo route : routes) {
            }

            if (!routes.isEmpty())
                return routes.get(0).source;

        } catch (Exception ex) {
            ex.printStackTrace();
        }
    } else if (System.getProperty("os.name").contains("Linux")) {

        List<RouteInfo> routes = new ArrayList<>();
        try {
            //ipv6 ^(.+)/(\d+)\s+(.+)\s(\d+)\s+(\d+)\s+(\d)\s+(.+)$
            //ipv4 ^\s+inet\s\addr:(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\s+Bcast:(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\s+Mask:(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$
            //linux route get command parsing: ipv4 ^.*via.*\s+dev\s+.*\s+src\s((?:[0-9\.]{1,3})+)
            //linux route get comand parsing: ipv6 ^.*\sfrom\s::\svia.*\sdev\s.*\ssrc\s((?:[:]{1,2}|[0-9|a|b|c|d|e|f]{1,4})+)
            //final String COMMAND = "/sbin/ifconfig";
            final String COMMAND = "ip route get " + remoteIP;

            Process exec = Runtime.getRuntime().exec(COMMAND);
            BufferedReader reader = new BufferedReader(new InputStreamReader(exec.getInputStream()));

            System.out.println(System.getProperty("os.name"));
            String line;
            /* examples:
             * 10.10.2.130 via 10.0.2.2 dev eth0  src 10.0.2.255
            */
            Pattern p = Pattern.compile("^.*via.*\\s+dev\\s+.*\\s+src\\s((?:[0-9|\\.]{1,3})+)");

            while ((line = reader.readLine()) != null) {
                Matcher match = p.matcher(line);
                if (match.matches()) {

                    String address = match.group(1);

                    routes.add(new RouteInfo(address, (short) 0, (short) 0, (short) 0));//metric is always 0, because we do not extract it from the ifconfig command.

                }
            }
            Collections.sort(routes);

            if (!routes.isEmpty())
                return routes.get(0).source;

        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
    return null;
}

From source file:com.cloud.hypervisor.ovm3.objects.XmlTestResultTest.java

public String simpleResponseWrap(String type, String s) {
    if (type.contentEquals(NULL)) {
        s = NULL;/*from w ww . jav  a 2s .co  m*/
    } else {
        s = brack(type, s);
    }
    return simpleResponseWrapWrapper(s);
}

From source file:com.grepsound.model.Playlist.java

public Playlist(JSONObject obj) throws JSONException {
    info = new HashMap<>();

    Iterator ite = obj.keys();/*from   w ww  .j  a va2 s  .  co m*/
    for (int i = 0; i < obj.length(); ++i) {
        String key = ite.next().toString();
        if (key.contentEquals("tracks")) {
            JSONArray tracksJSON = new JSONArray(obj.get(key).toString());
            set = new Tracks(tracksJSON);
        } else
            info.put(key, obj.get(key).toString());
    }
}

From source file:pranav.apps.amazing.hppoliceassistant.OfflineChallan.java

private List<ChallanDetails> filter(List<ChallanDetails> models, String query) {
    if (query.contentEquals("")) {
        final List<ChallanDetails> filteredChallan = new ArrayList<>();
        filteredChallan.addAll(models);/*from  w w w  . j  a v a2  s. c  o  m*/
        return filteredChallan;
    }
    query = query.toLowerCase();

    final List<ChallanDetails> filteredModelList = new ArrayList<>();
    for (ChallanDetails model : models) {
        final String text1 = model.getVehicle_number().toLowerCase();
        final String text2 = model.getViolator_name().toLowerCase();
        final String text3 = model.getLicense_number().toLowerCase();
        final String text4 = model.getViolator_number().toLowerCase();
        final String text5 = model.getPolice_officer_name().toLowerCase();
        if (text1.contains(query) || text2.contains(query) || text3.contains(query) || text4.contains(query)
                || text5.contains(query)) {
            filteredModelList.add(model);
        }
    }
    return filteredModelList;
}

From source file:org.wso2.carbon.cassandra.cluster.mgt.registry.RegistryStore.java

private void deleteEntry(String entry) throws ClusterDataAdminException {
    Resource resource = null;/*  w  w w  . j a  v  a 2  s.c  om*/
    String[] contents;
    try {
        String filePath = REG_FILE_LOCATION + SNAPSHOT_FILE_NAME;
        if (registry.resourceExists(filePath)) {
            resource = registry.get(filePath);
            String content = new String((byte[]) resource.getContent());
            contents = content.split(DELIMITER_SNAPSHOT);
            StringBuffer stringBuffer = new StringBuffer();
            for (String s : contents) {
                if (s.contentEquals(entry)) {
                    continue;
                }
                stringBuffer.append(s + DELIMITER_SNAPSHOT);
            }

            registry.delete(filePath);
            resource = registry.newResource();
            resource.setContent(stringBuffer.toString());
            registry.put(filePath, resource);
        }
    } catch (RegistryException e) {
        throw new ClusterDataAdminException("Error while deleting the snapshot tag from registry", e, log);
    }
}

From source file:com.smash.revolance.ui.materials.mock.webdriver.MockedWebElement.java

public void setBg(String bg) {
    if (bg != null && !bg.contentEquals("none"))
        this.bg = bg;
}

From source file:org.wso2.am.integration.tests.throttling.APITierManagementTestCase.java

@Test(groups = { "wso2.am" }, description = "Delete tier through admin-dashboard")
public void deleteTierTestCase() throws Exception {
    HttpResponse addTierResponse = adminDashboard.deleteTier(tierName);
    verifyResponse(addTierResponse);/*  w ww . j av  a 2 s.  co  m*/

    String getTiersResponse = adminDashboard.getAllTiers().getData();
    log.info(getTiersResponse);
    Assert.assertTrue(!getTiersResponse.contentEquals(tierName), "Tier not deleted");

}