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:net.hgw4.hal.WebCamClientComm.java

/**
 * check if input 1 is pressed == 1 ring button
 * @param port/*from w  ww  . ja va2  s .  co  m*/
 * @return
 */
public int checkPortStatus(int port) {

    try {
        String curport = Integer.toString(port);
        URL url = new URL("http://" + ip + "/axis-cgi/io/input.cgi?check=" + curport.toString()); //reply with input1=1 o 0
        String userPassword = "<user>" + ":" + "<passwd>";
        String encoding = new sun.misc.BASE64Encoder().encode(userPassword.getBytes());
        URLConnection uc = url.openConnection();
        uc.setRequestProperty("Authorization", "Basic " + encoding);
        InputStream content = (InputStream) uc.getInputStream();
        BufferedReader in = new BufferedReader(new InputStreamReader(content));

        String str;
        str = in.readLine();
        if (str.contentEquals("input1=1")) {
            return 1; //high
        } else if (str.contentEquals("input1=0")) {

            return 0; //low
        }
        in.close();

    } catch (MalformedURLException ex) {
        WebCamClientCommLogger.error(ex);
    } catch (IOException ex) {
        WebCamClientCommLogger.error(ex);
    }
    return -1;
}

From source file:org.jtrfp.trcl.dbg.PropertyDumpSupport.java

public void dumpProperties(Map<String, PropertyDumpElement> dest) {
    PropertyDescriptor[] props = PropertyUtils.getPropertyDescriptors(delegator.getClass());
    // Try to get a stacktrace.
    final HashMap<String, StackTraceElement[]> stackTraces = new HashMap<String, StackTraceElement[]>();
    try {/*w ww  . j a va  2  s  .c  o  m*/
        final Method sm = delegator.getClass().getDeclaredMethod("getStackTracingPropertyChangeSupport");
        ((StackTracingPropertyChangeSupport) sm.invoke(delegator)).getStackTraces(stackTraces);
    } catch (NoSuchMethodException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    } catch (InvocationTargetException e) {
        e.printStackTrace();
    }
    for (PropertyDescriptor pd : props) {
        final Method rm = pd.getReadMethod();
        if (rm != null) {
            final String name = pd.getName();
            final boolean irrelevantProperty = rm.getDeclaringClass() == Object.class
                    || name.contentEquals("class") || name.contentEquals("propertyChangeListeners");
            if (!irrelevantProperty) {
                try {
                    Object val = rm.invoke(delegator);
                    try {
                        final Method sm = rm.getReturnType().getMethod("dumpProperties", Map.class);
                        final HashMap<String, Object> subDest = new HashMap<String, Object>();
                        sm.invoke(val, subDest);
                        val = subDest;
                    } catch (NoSuchMethodException e) {
                    }
                    StackTraceElement[] stackTrace = stackTraces.get(pd.getName());
                    PropertyDumpElement gsp = new PropertyDumpElement(val, stackTrace);
                    dest.put(pd.getName(), gsp);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            } //end if(!irrelevant)
        } //end if(readMethod)
    } //end for(props)
}

From source file:com.money.manager.ex.notifications.SmsReceiverTransactions.java

private static String extractTransAmount(String smsMsg, String fromAccCurrencySymbl) {
    String reqMatch = "";
    smsMsg = smsMsg.replace(",", "");
    String searchFor = "((\\s)?##SEARCH4CURRENCY##(.)?(\\s)?((\\d+)(\\.\\d+)?))";
    int[] getGroup = { 5 };

    //Handle multiple symbol for currency
    String[] searchCurrency;/*from   w w  w  . j  a v  a  2 s .  c om*/

    if (fromAccCurrencySymbl.contentEquals("INR")) {
        searchCurrency = new String[] { "INR", "Rs" };
    } else {
        searchCurrency = new String[] { fromAccCurrencySymbl };
    }

    try {
        for (int i = 0; i <= searchCurrency.length - 1; i++) {
            Pattern p = Pattern.compile(searchFor.replace("##SEARCH4CURRENCY##", searchCurrency[i]));
            Matcher m = p.matcher(smsMsg);

            if (m != null && reqMatch.isEmpty()) {
                while (m.find()) {
                    reqMatch = m.group(getGroup[0]).trim();
                    break;
                }
            }
        }

    } catch (Exception e) {
        Timber.e(e, "extractTransAmount");
    }

    return reqMatch;
}

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

private List<ChallanDetails> filter(List<ChallanDetails> models, String query) {
    if (query.contentEquals("")) {
        final List<ChallanDetails> filteredChallan = new ArrayList<>();
        filteredChallan.addAll(models);/* w  w  w . jav a  2 s  .  c  om*/
        return filteredChallan;
    }
    query = query.toLowerCase();

    final List<ChallanDetails> filteredModelList = new ArrayList<>();
    for (ChallanDetails model : models) {
        if (model.getVehicle_number() != null && model.getViolator_name() != null
                && model.getLicense_number() != null && model.getViolator_number() != null
                && model.getPolice_officer_name() != null) {
            final String text1 = model.getVehicle_number().replace("/", "").replace("-", "").toLowerCase();
            final String text2 = model.getViolator_name().toLowerCase();
            final String text3 = model.getLicense_number().replace("/", "").replace("-", "").toLowerCase();
            final String text4 = model.getViolator_number().toLowerCase();
            final String text5 = model.getPolice_officer_name().toLowerCase();
            final String text6 = model.getChallanID().toLowerCase();

            if (text1.contains(query) || text2.contains(query) || text3.contains(query) || text4.contains(query)
                    || text5.contains(query) || text6.contains(query)) {
                filteredModelList.add(model);
            }
        }
    }
    return filteredModelList;
}

From source file:com.smash.revolance.ui.model.application.ApplicationFactory.java

private void loadApplication(String appDir, String appId, String impl, String version) throws IOException {
    if (!appDir.isEmpty() && new File(appDir).isDirectory()) {
        Collection<File> files = FileUtils.listFiles(new File(appDir), new String[] { "jar" }, false);

        for (File file : files) {
            JarFile jar = new JarFile(file);
            Manifest manifest = jar.getManifest();
            Attributes attributes = manifest.getMainAttributes();

            String implAttr = attributes.getValue("revolance-ui-explorer-applicationImpl");
            String versionAttr = attributes.getValue("revolance-ui-explorer-applicationVersion");

            if (implAttr.contentEquals(impl) && (versionAttr.contentEquals(version) || version == null)) {
                applicationLoaders.put(getKey(appId, impl, version), new JarClassLoader(file.toURI().toURL()));
            }/* w  w  w .  j av a 2 s.com*/
        }

    }
}

From source file:com.nuvolect.securesuite.data.SqlIncSync.java

/**
 * Save password related crypdata for synchronization
 *
 * @param ctx/*from   www. jav  a2s  .c  o  m*/
 * @param key
 */
public void crypSync(Context ctx, String key) {

    if (mSyncEnabled) {
        if (key.contentEquals(Passphrase.PASSWORD_GEN_HISTORY))
            SqlCipher.putIncSync(INC_SYNC_TYPE.PASSWORD_GEN_HISTORY.ordinal(), 0);
        if (key.contentEquals(Passphrase.PASSWORD_TARGET))
            SqlCipher.putIncSync(INC_SYNC_TYPE.PASSWORD_TARGET.ordinal(), 0);
        if (key.contentEquals(Passphrase.PASSWORD_LENGTH))
            SqlCipher.putIncSync(INC_SYNC_TYPE.PASSWORD_LENGTH.ordinal(), 0);
        if (key.contentEquals(Passphrase.PASSWORD_GEN_MODE))
            SqlCipher.putIncSync(INC_SYNC_TYPE.PASSWORD_GEN_MODE.ordinal(), 0);

        if (!mSyncSuspended)
            setSyncTimer(ctx);
    }
}

From source file:org.jenkinsci.testinprogress.server.messages.TestMessagesParser.java

private void processMessage(JSONObject jsonMsg) {
    String msgId = getValue(jsonMsg, "messageId", "").toString().trim();

    if (msgId.contentEquals(MessageIds.TEST_RUN_START.trim())) {
        fVersion = getValue(jsonMsg, "fVersion", "v3").toString();
        notifyTestRunStarted(jsonMsg);//from   w  w w.  j av  a  2s. c  o  m
    } else if (msgId.contentEquals(MessageIds.TEST_START.trim())) {
        notifyTestStarted(jsonMsg);

    } else if (msgId.contentEquals(MessageIds.TEST_END.trim())) {
        notifyTestEnded(jsonMsg);

    } else if (msgId.contentEquals(MessageIds.TEST_ERROR.trim())) {
        notifyTestFailed(jsonMsg, ITestRunListener.STATUS_ERROR);

    } else if (msgId.contentEquals(MessageIds.TEST_FAILED.trim())) {
        notifyTestFailed(jsonMsg, ITestRunListener.STATUS_FAILURE);

    } else if (msgId.contentEquals(MessageIds.TEST_RUN_END.trim())) {
        String elTime = getValue(jsonMsg, "elapsedTime", "").toString();

        long elapsedTime = Long.parseLong(elTime);
        testRunEnded(jsonMsg, elapsedTime);

    } else if (msgId.contentEquals(MessageIds.TEST_TREE.trim())) {
        notifyTestTreeEntry(jsonMsg);
    }
}

From source file:csv2docxconverter.DocumentGenerator.java

/**
 * Get number of column from column list
 * @param name name for look//from  ww w  .  j  a  va 2  s .  co  m
 * @param columnNames columns list
 */
private int getColumnNumber(String name, String[] columnNames) {
    for (int i = 0; i < columnNames.length; i++) {
        String name2 = columnNames[i].trim().toLowerCase();
        if (name.contentEquals(name2)) {
            return i;
        }
    }
    return -1;
}

From source file:gephi.spade.panel.FCSOperations.java

public List<AttributeValuePair> computeTStat() {
    ArrayList<AttributeValuePair> stats = new ArrayList<AttributeValuePair>();
    for (int i = 0; i < fcsInputFile.getNumChannels(); i++) {
        String name = fcsInputFile.getChannelShortName(i);
        if (name.contentEquals("Time") || name.contentEquals("time") || name.contentEquals("cluster")
                || name.contentEquals("density")) {
            continue;
        }//from   w  ww . j av  a2s. c  om
        stats.add(new AttributeValuePair(name, tTest(eventsSlctd, eventsInitl, i)));
    }
    Collections.sort(stats);
    Collections.reverse(stats);
    return stats;
}

From source file:org.lockss.extractor.RisMetadataExtractor.java

/**
 * Extract metadata from the content of the cu, which should be an RIS file.
 * Reads line by line inserting the 2 character code and value into the raw map.
 * The first line should be a material type witch if it is book or journal will 
 * determine if we interpret the SN tag as IS beltSN or ISBN.
 * @param target/*from   w  ww  .  j a  va2 s .  c om*/
 * @param cu
 */
public final ArticleMetadata extract(MetadataTarget target, CachedUrl cu) throws IOException, PluginException {
    if (cu == null) {
        throw new IllegalArgumentException();
    }
    ArticleMetadata md = new ArticleMetadata();
    BufferedReader bReader = new BufferedReader(cu.openForReading());
    String line;
    String refType = null;
    try {
        if (!containsRisTag("TY")) {
            while (refType == null && (line = bReader.readLine()) != null) {
                if (line.trim().toUpperCase().startsWith("TY") && line.contains(delimiter)
                        && !line.endsWith(delimiter)) {
                    String value = line.substring(line.indexOf(delimiter) + 1).trim().toUpperCase();
                    if (value.contentEquals("JOUR")) {
                        refType = REFTYPE_JOURNAL;
                    } else if (value.contentEquals("BOOK")) {
                        refType = REFTYPE_BOOK;
                    } else {
                        refType = REFTYPE_OTHER;
                    }
                }
            }
            if (refType == null) {
                return md;
            }
        }
        while ((line = bReader.readLine()) != null) {
            line = line.trim();
            if (!line.contentEquals("") && line.contains(delimiter) && !line.endsWith(delimiter)) {
                String value = line.substring(line.indexOf(delimiter) + 1);
                String key = line.substring(0, line.indexOf(delimiter) - 1);
                key = key.trim().toUpperCase();
                md.putRaw(key, value.trim());
                if (!containsRisTag("SN") && key.contentEquals("SN")) {
                    if (refType.contentEquals(REFTYPE_BOOK)) {
                        addRisTag("SN", MetadataField.FIELD_ISBN);
                    } else {
                        addRisTag("SN", MetadataField.FIELD_ISSN);
                    }
                }
            }
        }
    } finally {
        IOUtil.safeClose(bReader);
    }
    md.cook(risTagToMetadataField);
    return md;
}