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:org.openhie.openempi.nhinadapter.hl7.Utilities.java

public static boolean isNullish(String value) {
    boolean result = false;
    if ((value == null) || (value.contentEquals(""))) {
        result = true;//from  w w w  .  j av a  2s  .  c o  m
    }
    return result;
}

From source file:Main.java

public static String validateSignUpForm(String email, String password, String passwordRpt) {
    if (isEmpty(email) || isEmpty(password) || isEmpty(passwordRpt)) {
        return "All fields are required";
    }/*from   w ww.jav  a 2 s . c  o  m*/

    if (!isValidEmail(email)) {
        return "Email is invalid type";
    }

    if (!isValidPassword(password)) {
        return "Password should begin with letter, be 6-18 characters "
                + "long and must contain only letters, numbers, and underscore";
    }

    if (!password.contentEquals(passwordRpt)) {
        return "Passwords should match";
    }

    return null;
}

From source file:com.hp.test.framework.Utlis.java

public static void getpaths(String path) {
    // log.info("started getting all the documents paths :::" + path);
    File root = new File(path);
    File[] list = root.listFiles();
    if (list == null) {
        return;/*from w ww .ja  va 2s .  co m*/
    }
    for (File f : list) {
        if (f.isDirectory()) {
            getpaths(f.getAbsolutePath());

        } else {

            String filename = f.getName();
            String Abpath = f.getAbsolutePath();
            String extension = "";
            int i = filename.lastIndexOf('.');
            if (i >= 0) {
                extension = filename.substring(i + 1);
                if (extension.contentEquals("html")) {
                    System.out.println("File:" + f.getAbsoluteFile());
                    fileList.add(new File(f.getAbsolutePath()));
                }
            }

        }
    }
}

From source file:nl.knaw.dans.dccd.web.search.SearchResultDataConverter.java

private static String getProjectCategoryString(final DccdSB dccdHit) {
    // NOTE: not normalTridasCategory
    String projectCategoryStr = "";
    if (dccdHit.hasTridasProjectCategory())
        projectCategoryStr = dccdHit.getTridasProjectCategory();

    if (dccdHit.hasTridasProjectCategoryNormal() && !dccdHit.getTridasProjectCategoryNormal().isEmpty()
            && !projectCategoryStr.contentEquals(dccdHit.getTridasProjectCategoryNormal())) {
        if (!projectCategoryStr.isEmpty())// add seperator
            projectCategoryStr += ", ";
        projectCategoryStr += dccdHit.getTridasProjectCategoryNormal();
    }/*from  www .  j  a v a  2s  .  co m*/
    return projectCategoryStr;
}

From source file:com.fpuna.preproceso.PreprocesoTS.java

/**
 * Metodo estatico que lee el archivo y lo carga en una estructura de hash
 *
 * @param Archivo path del archivo//from www .  j  a  va2 s  . co m
 * @return Hash con las sessiones leida del archivo de TrainigSet
 */
public static HashMap<String, SessionTS> leerArchivo(String Archivo, String sensor) {

    HashMap<String, SessionTS> SessionsTotal = new HashMap<String, SessionTS>();
    HashMap<String, String> actividades = new HashMap<String, String>();
    Path file = Paths.get(Archivo);

    if (Files.exists(file) && Files.isReadable(file)) {

        try {
            BufferedReader reader = Files.newBufferedReader(file, Charset.defaultCharset());

            String line;
            int cabecera = 0;

            while ((line = reader.readLine()) != null) {
                if (line.contentEquals("statusId | label")) {

                    //Leo todos las actividades  
                    while ((line = reader.readLine()) != null
                            && !line.contentEquals("statusId|sensorName|value|timestamp")) {
                        String part[] = line.split("\\|");
                        actividades.put(part[0], part[1]);
                        SessionTS s = new SessionTS();
                        s.setActividad(part[1]);
                        SessionsTotal.put(part[0], s);
                    }
                    line = reader.readLine();
                }

                String lecturas[] = line.split("\\|");

                if (lecturas[1].contentEquals(sensor)) {
                    Registro reg = new Registro();
                    reg.setSensor(lecturas[1]);
                    String[] values = lecturas[2].split("\\,");

                    if (values.length == 3) {
                        reg.setValor_x(Double.parseDouble(values[0].substring(1)));
                        reg.setValor_y(Double.parseDouble(values[1]));
                        reg.setValor_z(Double.parseDouble(values[2].substring(0, values[2].length() - 1)));
                    } else if (values.length == 5) {
                        reg.setValor_x(Double.parseDouble(values[0].substring(1)));
                        reg.setValor_y(Double.parseDouble(values[1]));
                        reg.setValor_z(Double.parseDouble(values[2]));
                        reg.setM_1(Double.parseDouble(values[3]));
                        reg.setM_2(Double.parseDouble(values[4].substring(0, values[4].length() - 1)));
                    }

                    reg.setTiempo(new Timestamp(Long.parseLong(lecturas[3])));

                    SessionTS s = SessionsTotal.get(lecturas[0]);
                    s.addRegistro(reg);
                    SessionsTotal.replace(lecturas[0], s);
                }
            }
        } catch (IOException ex) {
            System.err.println("Okapu");
            Logger.getLogger(PreprocesoTS.class.getName()).log(Level.SEVERE, null, ex);
        }

    }

    return SessionsTotal;
}

From source file:com.hp.test.framework.Reporting.Utlis.java

public static void getpaths(String path) {
    log.info("started getting all the documents paths :::" + path);
    File root = new File(path);
    File[] list = root.listFiles();
    if (list == null) {
        return;//  w  w w . ja  v a  2 s  .  com
    }
    for (File f : list) {
        if (f.isDirectory()) {
            getpaths(f.getAbsolutePath());

        } else {

            String filename = f.getName();
            String Abpath = f.getAbsolutePath();
            String extension = "";
            int i = filename.lastIndexOf('.');
            if (i >= 0) {
                extension = filename.substring(i + 1);
                if (extension.contentEquals("html")) {

                    fileList.add(new File(f.getAbsolutePath()));
                }
            }

        }
    }
}

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

/**
 * Create a single vcard from a contact record
 * @param contact_id/* w ww. j a v  a  2s.  c  o m*/
 * @return appended vcard
 */
public static VCard makeVcard(long contact_id) {

    VCard vcard = new VCard();
    try {
        vcard.setKind(Kind.individual());
        vcard.addLanguage("en-US");

        String full_name = NameUtil.getFullName(contact_id);
        vcard.setFormattedName(full_name);
        {
            StructuredName n = new StructuredName();
            String prefix = SqlCipher.getKv(contact_id, KvTab.name_prefix);
            n.addPrefix(prefix);
            String first = SqlCipher.getKv(contact_id, KvTab.name_first);
            n.setGiven(first);
            String last = SqlCipher.getKv(contact_id, KvTab.name_last);
            n.setFamily(last);
            String suffix = SqlCipher.getKv(contact_id, KvTab.name_suffix);
            n.addSuffix(suffix);
            vcard.setStructuredName(n);

            //                if( prefix.isEmpty() && first.isEmpty() && last.isEmpty() && suffix.isEmpty())//TODO remove
            //                    n.setFamily(full_name);
        }
        {
            JSONArray itemArray = new JSONArray(SqlCipher.get(contact_id, DTab.address));
            for (int i = 0; i < itemArray.length(); i++) {

                JSONObject item = itemArray.getJSONObject(i);
                Iterator<?> item_keys = item.keys();
                String item_label = (String) item_keys.next();
                final String item_value = item.getString(item_label);

                Address adr = new Address();
                adr.setStreetAddress(item_value);
                if (item_label.contentEquals("HOME"))
                    adr.addType(AddressType.HOME);
                else if (item_label.contentEquals("WORK"))
                    adr.addType(AddressType.WORK);

                vcard.addAddress(adr);
            }
        }
        {
            JSONArray itemArray = new JSONArray(SqlCipher.get(contact_id, DTab.phone));
            for (int i = 0; i < itemArray.length(); i++) {

                JSONObject item = itemArray.getJSONObject(i);
                Iterator<?> item_keys = item.keys();
                String item_label = (String) item_keys.next();
                final String item_value = item.getString(item_label);

                TelephoneType type = null;
                if (item_label.contentEquals("HOME"))
                    type = TelephoneType.HOME;
                else if (item_label.contentEquals("WORK"))
                    type = TelephoneType.WORK;

                if (type == null)
                    vcard.addTelephoneNumber(item_value);
                else
                    vcard.addTelephoneNumber(item_value, type);
            }
        }
        {
            JSONArray itemArray = new JSONArray(SqlCipher.get(contact_id, DTab.email));
            for (int i = 0; i < itemArray.length(); i++) {

                JSONObject item = itemArray.getJSONObject(i);
                Iterator<?> item_keys = item.keys();
                String item_label = (String) item_keys.next();
                final String item_value = item.getString(item_label);

                EmailType type = null;
                if (item_label.contentEquals("HOME"))
                    type = EmailType.HOME;
                else if (item_label.contentEquals("WORK"))
                    type = EmailType.WORK;

                if (type == null)
                    vcard.addEmail(item_value);
                else
                    vcard.addEmail(item_value, type);
            }
        }
        {
            JSONArray itemArray = new JSONArray(SqlCipher.get(contact_id, DTab.website));
            for (int i = 0; i < itemArray.length(); i++) {

                JSONObject item = itemArray.getJSONObject(i);
                Iterator<?> item_keys = item.keys();
                String item_label = (String) item_keys.next();
                final String item_value = item.getString(item_label);

                vcard.addUrl(item_value);
            }
        }
        {
            String photoStr = SqlCipher.get(contact_id, DTab.photo);
            byte[] b = null;
            b = Base64.decode(photoStr.getBytes(), Base64.DEFAULT);
            Photo photo = new Photo(b, ImageType.PNG);
            vcard.addPhoto(photo);
        }
        {
            String noteStr = SqlCipher.getKv(contact_id, KvTab.note);
            Note note = vcard.addNote(noteStr); // can contain newlines
            note.setLanguage("en-us");
        }
        {
            String organization = SqlCipher.getKv(contact_id, KvTab.organization);
            vcard.setOrganization(organization, "");// second parameter is department
        }
        {
            String title = SqlCipher.getKv(contact_id, KvTab.title);
            vcard.addTitle(title);
        }
        //FUTURE export im
        //FUTURE export dates
        //FUTURE export relation

    } catch (JSONException e) {
        LogUtil.logException(m_act, LogType.EXPORT_VCF, e);
    }
    return vcard;
}

From source file:org.opendaylight.iotdm.onem2m.core.resource.ResourceAccessControlPolicy.java

/**
 * Ensure the create/update parameters follow the rules
 * @param onem2mRequest request/*from   w  w w.  j a v  a  2s .co m*/
 * @param onem2mResponse response
 */
public static void processCreateUpdateAttributes(RequestPrimitive onem2mRequest,
        ResponsePrimitive onem2mResponse) {

    String tempStr;
    Integer tempInt;

    // verify this resource can be created under the target resource
    if (onem2mRequest.isCreate) {
        String rt = onem2mRequest.getOnem2mResource().getResourceType();
        if (rt == null || !(rt.contentEquals(Onem2m.ResourceType.CSE_BASE)
                || rt.contentEquals(Onem2m.ResourceType.AE))) {
            onem2mResponse.setRSC(Onem2m.ResponseStatusCode.OPERATION_NOT_ALLOWED,
                    "Cannot create AccessControlPolicy under this resource type: " + rt);
            return;
        }
    }

    ResourceContent resourceContent = onem2mRequest.getResourceContent();

    //check mandatory privileges and selfPrivileges
    String pv = resourceContent.getInJsonContent().optString(PRIVILIEGES, null);
    if (pv == null) {
        if (onem2mRequest.isCreate) {
            onem2mResponse.setRSC(Onem2m.ResponseStatusCode.BAD_REQUEST, "PRIVILEGES missing parameter");
            return;
        }
    } else {
        // todo: how to check access Control Operations and originators?
        JSONObject pvjsonObject = resourceContent.getInJsonContent().getJSONObject(PRIVILIEGES);
        if (!isContainPVMandatoryAttr(onem2mResponse, pvjsonObject))
            return;
    }

    String pvs = resourceContent.getInJsonContent().optString(SELF_PRIIVLIEGES, null);
    if (pvs == null) {
        if (onem2mRequest.isCreate) {
            onem2mResponse.setRSC(Onem2m.ResponseStatusCode.BAD_REQUEST, "SELF PRIVILEGES missing parameter");
            return;
        }
    } else {
        // todo: how to check access Control Operations and originators?
        JSONObject pvjsonObject = resourceContent.getInJsonContent().getJSONObject(SELF_PRIIVLIEGES);
        if (!isContainPVMandatoryAttr(onem2mResponse, pvjsonObject))
            return;
    }

    // todo: Update ACP needs to check first

    /**
     * The resource has been filled in with any attributes that need to be written to the database
     */
    if (onem2mRequest.isCreate) {
        if (!Onem2mDb.getInstance().createResource(onem2mRequest, onem2mResponse)) {
            onem2mResponse.setRSC(Onem2m.ResponseStatusCode.INTERNAL_SERVER_ERROR,
                    "Cannot create in data store!");
            // TODO: what do we do now ... seems really bad ... keep stats
            return;
        }
    } else {
        if (!Onem2mDb.getInstance().updateResource(onem2mRequest, onem2mResponse)) {
            onem2mResponse.setRSC(Onem2m.ResponseStatusCode.INTERNAL_SERVER_ERROR,
                    "Cannot update the data store!");
            // TODO: what do we do now ... seems really bad ... keep stats
            return;
        }
    }
}

From source file:org.socraticgrid.util.format.DocumentClassCodeParser.java

public static String buildDocumentClassCodeItem(List<String> documentClassCodeList) {
    String buffer = "";

    if ((documentClassCodeList != null) && (documentClassCodeList.size() > 0)) {
        buffer = "(";
        for (String documentClassCode : documentClassCodeList) {
            documentClassCode = documentClassCode.trim();
            if (NullChecker.isNotNullish(buffer)) {
                buffer = buffer + "'" + documentClassCode + "'" + ",";
            }//from  w w  w. j  a  v  a  2 s  .co m
        }
        if (buffer.endsWith(",")) {
            buffer = buffer.substring(0, buffer.length() - 1);
        }
        buffer = buffer + ")";
    }
    if (buffer.contentEquals("()")) {
        buffer = "";
    }
    return buffer;
}

From source file:com.fpuna.preproceso.PreprocesoTS.java

/**
 * Metodo estatico que lee el archivo y lo carga en una estructura de hash
 *
 * @param Archivo path del archivo/*w  w w. j a  v a2  s  .  c o m*/
 * @return Hash con las sessiones leida del archivo de TrainigSet
 */
public static HashMap<String, SessionTS> leerArchivos(String Archivo, String sensor) {

    HashMap<String, SessionTS> SessionsTotal = new HashMap<String, SessionTS>();
    HashMap<String, String> actividades = new HashMap<String, String>();

    String sDirectorio = path;
    File dirList = new File(sDirectorio);

    if (dirList.exists()) { // Directorio existe 
        File[] ficheros = dirList.listFiles();
        for (int x = 0; x < ficheros.length; x++) {
            Path file = Paths.get(path + ficheros[x].getName());

            if (Files.exists(file) && Files.isReadable(file)) {

                try {
                    BufferedReader reader = Files.newBufferedReader(file, Charset.defaultCharset());

                    String line;
                    int cabecera = 0;

                    while ((line = reader.readLine()) != null) {
                        if (line.contentEquals("statusId | label")) {

                            //Leo todos las actividades  
                            while ((line = reader.readLine()) != null
                                    && !line.contentEquals("statusId|sensorName|value|timestamp")) {
                                String part[] = line.split("\\|");
                                actividades.put(part[0], part[1]);
                                SessionTS s = new SessionTS();
                                s.setActividad(part[1]);
                                SessionsTotal.put(part[0], s);
                            }
                            line = reader.readLine();
                        }

                        String lecturas[] = line.split("\\|");

                        if (lecturas[1].contentEquals(sensor)) {
                            Registro reg = new Registro();
                            reg.setSensor(lecturas[1]);
                            String[] values = lecturas[2].split("\\,");

                            if (values.length == 3) {
                                reg.setValor_x(Double.parseDouble(values[0].substring(1)));
                                reg.setValor_y(Double.parseDouble(values[1]));
                                reg.setValor_z(
                                        Double.parseDouble(values[2].substring(0, values[2].length() - 1)));
                            } else if (values.length == 5) {
                                reg.setValor_x(Double.parseDouble(values[0].substring(1)));
                                reg.setValor_y(Double.parseDouble(values[1]));
                                reg.setValor_z(Double.parseDouble(values[2]));
                                reg.setM_1(Double.parseDouble(values[3]));
                                reg.setM_2(Double.parseDouble(values[4].substring(0, values[4].length() - 1)));
                            }

                            reg.setTiempo(new Timestamp(Long.parseLong(lecturas[3])));

                            SessionTS s = SessionsTotal.get(lecturas[0]);
                            s.addRegistro(reg);
                            SessionsTotal.replace(lecturas[0], s);
                        }
                    }
                } catch (IOException ex) {
                    System.err.println("Okapu");
                    Logger.getLogger(PreprocesoTS.class.getName()).log(Level.SEVERE, null, ex);
                }

            }
        }
    } else { //Directorio no existe 

    }

    return SessionsTotal;
}