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:com.osfans.trime.DictionaryHelper.java

private boolean importDict(InputStream is) {
    boolean success = false;
    SQLiteDatabase db = getWritableDatabase();
    db.beginTransaction();/*from   w  w w. j  av a2s .c o  m*/
    try {
        String line;
        StringBuilder content = new StringBuilder();
        InputStreamReader ir = new InputStreamReader(is);
        BufferedReader br = new BufferedReader(ir);
        while ((line = br.readLine()) != null && !line.contentEquals(fs)) {
            content.append(line);
            content.append(newline);
        }

        Yaml yaml = new Yaml();
        Map<String, Object> y = (Map<String, Object>) (yaml.load(content.toString()));
        String table = (String) y.get("name");

        db.execSQL("DROP TABLE IF EXISTS " + table);
        db.execSQL(String.format("CREATE VIRTUAL TABLE %s USING fts3(hz, py)", table));

        ContentValues initialValues = new ContentValues(2);
        int max = is.available();
        int progress = 0;
        int count = 0;
        while ((line = br.readLine()) != null) {
            if (line.startsWith(comment))
                continue;
            String[] s = line.split("\t");
            if (s.length < 2)
                continue;
            initialValues.put("hz", s[0]);
            initialValues.put("py", s[1]);
            db.insert(table, null, initialValues);
            initialValues.clear();
            count++;
            if ((count % 1000) == 0) {
                progress = max - is.available();
                mBuilder.setProgress(max, progress, false)
                        .setContentText(String.format("%d / 100", progress * 100 / max));
                mNotifyManager.notify(notify_id, mBuilder.build());
            }
        }
        is.close();
        db.setTransactionSuccessful();
        success = true;
    } catch (Exception e) {
        throw new RuntimeException("Error import dict", e);
    } finally {
        db.endTransaction();
        mNotifyManager.cancel(notify_id);
    }
    return success;
}

From source file:test.SemanticConverter2.java

public void createJenaModel(RegisterContextRequest rcr) {

    OntModel ontModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
    Model entityOnt = FileManager.get().loadModel(ONT_FILE);
    ontModel.addSubModel(entityOnt);/*from  w ww.  ja  v a  2 s  .  c  o  m*/
    ontModel.setNsPrefixes(entityOnt.getNsPrefixMap());
    //        ontModel.loadImports();
    ontModel.setStrictMode(true);

    ExtendedIterator<OntProperty> iter = ontModel.listAllOntProperties();
    while (iter.hasNext()) {
        OntProperty ontProp = iter.next();
        System.out.println(ontProp.getLocalName());
    }

    OntClass entityGroup = (OntClass) ontModel.getOntClass(ONT_URL + "EntityGroup");
    OntClass entity = (OntClass) ontModel.getOntClass(ONT_URL + "Entity");
    OntClass attribute = (OntClass) ontModel.getOntClass(ONT_URL + "Attribute");
    OntClass metadata = (OntClass) ontModel.getOntClass(ONT_URL + "Metadata");
    OntClass location = (OntClass) ontModel.getOntClass(entityOnt.getNsPrefixURI("geo") + "Point");

    String ngsiValue = "";
    ngsiValue = rcr.getRegistrationId();
    Individual entityGroupIndiv = ontModel.createIndividual(ONT_URL + ngsiValue, entityGroup);
    entityGroupIndiv.setPropertyValue(ontModel.getProperty(ONT_URL + "registrationId"),
            ontModel.createLiteral(ngsiValue));
    ngsiValue = rcr.getTimestamp().toString();
    entityGroupIndiv.setPropertyValue(ontModel.getProperty(ONT_URL + "regTimeStamp"),
            ontModel.createLiteral(ngsiValue));
    ngsiValue = rcr.getDuration();
    entityGroupIndiv.setPropertyValue(ontModel.getProperty(ONT_URL + "duration"),
            ontModel.createLiteral(ngsiValue));

    int contRegListSize = rcr.getContextRegistration().size();
    for (int i = 0; i < contRegListSize; i++) {

        rcr.getContextRegistration().get(i).getContextMetadata().size();
        for (int z = 0; z < contRegListSize; z++) {

            String regMeta = rcr.getContextRegistration().get(i).getContextMetadata().get(z).getName();
            boolean regMetaValue = Boolean.getBoolean(
                    rcr.getContextRegistration().get(i).getContextMetadata().get(z).getValue().toString());
            if (regMeta.contentEquals("linked-data") && regMetaValue) {

                int entityListSize = rcr.getContextRegistration().get(i).getEntityId().size();
                for (int j = 0; j < entityListSize; j++) {
                    ngsiValue = rcr.getContextRegistration().get(i).getEntityId().get(j).getId();
                    Individual entityInstance = ontModel.createIndividual(ONT_URL + ngsiValue, entity);
                    entityGroupIndiv.addProperty(ontModel.getProperty(ONT_URL + "hasEntity"), entityInstance);

                    int attrListSize = rcr.getContextRegistration().get(i).getContextRegistrationAttribute()
                            .size();
                    for (int k = 0; k < attrListSize; k++) {
                        ngsiValue = rcr.getContextRegistration().get(i).getContextRegistrationAttribute().get(k)
                                .getName();
                        if (ngsiValue.isEmpty()) {
                            continue;
                        }
                        Individual attrInstance = ontModel.createIndividual(ONT_URL + ngsiValue, attribute);
                        entityInstance.addProperty(ontModel.getProperty(ONT_URL + "hasAttribute"),
                                attrInstance);
                        ngsiValue = rcr.getContextRegistration().get(i).getContextRegistrationAttribute().get(k)
                                .getType();
                        attrInstance.setPropertyValue(ontModel.getProperty(ONT_URL + "type"),
                                ontModel.createLiteral(ngsiValue));

                        int mdListSize = rcr.getContextRegistration().get(i).getContextRegistrationAttribute()
                                .get(k).getContextMetadata().size();
                        for (int l = 0; l < mdListSize; l++) {
                            ngsiValue = rcr.getContextRegistration().get(i).getContextRegistrationAttribute()
                                    .get(k).getContextMetadata().get(l).getName();
                            Individual mdataInstance = ontModel.createIndividual(ONT_URL + ngsiValue, metadata);
                            attrInstance.addProperty(ontModel.getProperty(ONT_URL + "hasMetadata"),
                                    mdataInstance);

                            ngsiValue = rcr.getContextRegistration().get(i).getContextRegistrationAttribute()
                                    .get(k).getContextMetadata().get(l).getType();
                            mdataInstance.setPropertyValue(ontModel.getProperty(ONT_URL + "type"),
                                    ontModel.createLiteral(ngsiValue));
                            ngsiValue = rcr.getContextRegistration().get(i).getContextRegistrationAttribute()
                                    .get(k).getContextMetadata().get(l).getValue().toString();
                            mdataInstance.setPropertyValue(ontModel.getProperty(ONT_URL + "value"),
                                    ontModel.createLiteral(ngsiValue));
                        }
                    }

                }

            }

        }

    }
    //        ngsiValue = rcr.getContextRegistration().get(0).getEntityId().get(0).getId();
    //        Individual entity1 = ontModel.createIndividual(ONT_URL + ngsiValue, entity);
    //        entityGroupIndiv.addProperty(ontModel.getProperty(ONT_URL + "hasEntity"), entity1);
    //        ngsiValue = rcr.getContextRegistration().get(0).getEntityId().get(0).getId();
    //        entity1.setPropertyValue(ontModel.getProperty(ONT_URL + "id"), ontModel.createLiteral(ngsiValue));        
    //        ngsiValue = rcr.getContextRegistration().get(0).getEntityId().get(0).getType();
    //        entity1.setPropertyValue(ontModel.getProperty(ONT_URL + "type"), ontModel.createLiteral(ngsiValue));        

    //        ngsiValue = rcr.getContextRegistration().get(0).getContextRegistrationAttribute().get(0).getName();
    //        Individual attribute1 = ontModel.createIndividual(ONT_URL + ngsiValue, attribute);
    //        entity1.setPropertyValue(ontModel.getProperty(ONT_URL + "hasAttribute"), attribute1);
    //        
    //        ngsiValue = rcr.getContextRegistration().get(0).getContextRegistrationAttribute().get(0).getType();
    //        attribute1.setPropertyValue(ontModel.getProperty(ONT_URL + "type"), ontModel.createLiteral(ngsiValue));
    //        
    //        ngsiValue = rcr.getContextRegistration().get(0).getContextRegistrationAttribute().get(0).getContextMetadata().get(0).getName();
    //        Individual metadata1 = ontModel.createIndividual(ONT_URL + ngsiValue, metadata);
    //        attribute1.setPropertyValue(ontModel.getProperty(ONT_URL + "hasMetadata"), metadata1);
    //        
    //        ngsiValue = rcr.getContextRegistration().get(0).getContextRegistrationAttribute().get(0).getContextMetadata().get(0).getType();
    //        metadata1.setPropertyValue(ontModel.getProperty(ONT_URL + "type"), ontModel.createLiteral(ngsiValue));
    //        ngsiValue = rcr.getContextRegistration().get(0).getContextRegistrationAttribute().get(0).getContextMetadata().get(0).getValue().toString();
    //        metadata1.setPropertyValue(ontModel.getProperty(ONT_URL + "value"), ontModel.createLiteral(ngsiValue));
    //        
    //        ngsiValue = rcr.getContextRegistration().get(0).getContextRegistrationAttribute().get(0).getContextMetadata().get(1).getName();
    //        Individual metadata2 = ontModel.createIndividual(ONT_URL + ngsiValue, metadata);
    //        attribute1.addProperty(ontModel.getProperty(ONT_URL + "hasMetadata"), metadata2);
    //        
    //        ngsiValue = rcr.getContextRegistration().get(0).getContextRegistrationAttribute().get(0).getContextMetadata().get(1).getType();
    //        metadata2.setPropertyValue(ontModel.getProperty(ONT_URL + "type"), ontModel.createLiteral(ngsiValue));
    //        ngsiValue = rcr.getContextRegistration().get(0).getContextRegistrationAttribute().get(0).getContextMetadata().get(1).getValue().toString();
    //        metadata2.setPropertyValue(ontModel.getProperty(ONT_URL + "value"), ontModel.createLiteral(ngsiValue));
    ontModel.write(System.out, "TURTLE");
    //        ontModel.write(System.out, "RDF/XML");
    //        ontModel.write(System.out, "JSON-LD");

}

From source file:cx.ring.service.LocalService.java

private static void lookupDetails(@NonNull ContentResolver res, @NonNull CallContact c) {
    //Log.w(TAG, "lookupDetails " + c.getKey());
    try {/*from  w  w  w . j  a  v a 2s .c  o m*/
        Cursor cPhones = res.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
                CONTACTS_PHONES_PROJECTION, ID_SELECTION, new String[] { String.valueOf(c.getId()) }, null);
        if (cPhones != null) {
            final int iNum = cPhones.getColumnIndex(Phone.NUMBER);
            final int iType = cPhones.getColumnIndex(Phone.TYPE);
            final int iLabel = cPhones.getColumnIndex(Phone.LABEL);
            while (cPhones.moveToNext()) {
                c.addNumber(cPhones.getString(iNum), cPhones.getInt(iType), cPhones.getString(iLabel),
                        CallContact.NumberType.TEL);
                Log.w(TAG, "Phone:" + cPhones.getString(cPhones.getColumnIndex(Phone.NUMBER)));
            }
            cPhones.close();
        }

        Uri baseUri = ContentUris.withAppendedId(ContactsContract.Contacts.CONTENT_URI, c.getId());
        Uri targetUri = Uri.withAppendedPath(baseUri, ContactsContract.Contacts.Data.CONTENT_DIRECTORY);
        Cursor cSip = res.query(targetUri, CONTACTS_SIP_PROJECTION,
                ContactsContract.Data.MIMETYPE + "=? OR " + ContactsContract.Data.MIMETYPE + " =?",
                new String[] { SipAddress.CONTENT_ITEM_TYPE, Im.CONTENT_ITEM_TYPE }, null);
        if (cSip != null) {
            final int iMime = cSip.getColumnIndex(ContactsContract.Data.MIMETYPE);
            final int iSip = cSip.getColumnIndex(SipAddress.SIP_ADDRESS);
            final int iType = cSip.getColumnIndex(SipAddress.TYPE);
            final int iLabel = cSip.getColumnIndex(SipAddress.LABEL);
            while (cSip.moveToNext()) {
                String mime = cSip.getString(iMime);
                String number = cSip.getString(iSip);
                if (!mime.contentEquals(Im.CONTENT_ITEM_TYPE) || new SipUri(number).isRingId()
                        || "ring".equalsIgnoreCase(cSip.getString(iLabel)))
                    c.addNumber(number, cSip.getInt(iType), cSip.getString(iLabel), CallContact.NumberType.SIP);
                Log.w(TAG, "SIP phone:" + number + " " + mime + " ");
            }
            cSip.close();
        }
    } catch (Exception e) {
        Log.w(TAG, e);
    }
}

From source file:test.SemanticConverter3.java

public void createJenaModel(RegisterContextRequest rcr) {

    OntModel ontModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
    Model entityOnt = FileManager.get().loadModel(ONT_FILE);
    ontModel.addSubModel(entityOnt);//from  w w  w .ja v  a2  s  .c  o m
    ontModel.setNsPrefixes(entityOnt.getNsPrefixMap());
    //        ontModel.loadImports();
    ontModel.setStrictMode(true);

    ExtendedIterator<OntProperty> iter = ontModel.listAllOntProperties();
    while (iter.hasNext()) {
        OntProperty ontProp = iter.next();
        System.out.println(ontProp.getLocalName());
    }

    OntClass entityGroup = (OntClass) ontModel.getOntClass(MAIN_ONT_URL + "EntityGroup");
    OntClass entity = (OntClass) ontModel.getOntClass(MAIN_ONT_URL + "Entity");

    OntClass metadata = (OntClass) ontModel.getOntClass(MAIN_ONT_URL + "Metadata");
    OntClass location = (OntClass) ontModel.getOntClass(entityOnt.getNsPrefixURI("geo") + "Point");

    OntClass sensingDevice = (OntClass) ontModel.getOntClass(SSN_ONT_URL + "SensingDevice");
    OntClass iotObject = (OntClass) ontModel.getOntClass(MAIN_ONT_URL + "Object");
    OntClass attribute = (OntClass) ontModel.getOntClass(MAIN_ONT_URL + "Attribute");

    String ngsiValue = "";
    ngsiValue = rcr.getRegistrationId();
    Individual entityGroupIndiv = ontModel.createIndividual(MAIN_ONT_URL + ngsiValue, entityGroup);
    entityGroupIndiv.setPropertyValue(ontModel.getProperty(MAIN_ONT_URL + "registrationId"),
            ontModel.createLiteral(ngsiValue));
    ngsiValue = rcr.getTimestamp().toString();
    entityGroupIndiv.setPropertyValue(ontModel.getProperty(MAIN_ONT_URL + "regTimeStamp"),
            ontModel.createLiteral(ngsiValue));
    ngsiValue = rcr.getDuration();
    entityGroupIndiv.setPropertyValue(ontModel.getProperty(MAIN_ONT_URL + "duration"),
            ontModel.createLiteral(ngsiValue));

    int contRegListSize = rcr.getContextRegistration().size();
    for (int i = 0; i < contRegListSize; i++) {

        rcr.getContextRegistration().get(i).getContextMetadata().size();
        for (int z = 0; z < contRegListSize; z++) {

            String regMeta = rcr.getContextRegistration().get(i).getContextMetadata().get(z).getName();
            boolean regMetaValue = Boolean.getBoolean(
                    rcr.getContextRegistration().get(i).getContextMetadata().get(z).getValue().toString());
            if (regMeta.contentEquals("linked-data") && regMetaValue) {

                int entityListSize = rcr.getContextRegistration().get(i).getEntityId().size();
                for (int j = 0; j < entityListSize; j++) {
                    ngsiValue = rcr.getContextRegistration().get(i).getEntityId().get(j).getId();
                    Individual entityInstance = ontModel.createIndividual(MAIN_ONT_URL + ngsiValue, entity);
                    entityGroupIndiv.addProperty(ontModel.getProperty(MAIN_ONT_URL + "hasEntity"),
                            entityInstance);

                    int attrListSize = rcr.getContextRegistration().get(i).getContextRegistrationAttribute()
                            .size();
                    for (int k = 0; k < attrListSize; k++) {
                        ngsiValue = rcr.getContextRegistration().get(i).getContextRegistrationAttribute().get(k)
                                .getName();
                        if (ngsiValue.isEmpty()) {
                            continue;
                        }
                        Individual attrInstance = ontModel.createIndividual(MAIN_ONT_URL + ngsiValue,
                                attribute);
                        entityInstance.addProperty(ontModel.getProperty(MAIN_ONT_URL + "hasAttribute"),
                                attrInstance);
                        ngsiValue = rcr.getContextRegistration().get(i).getContextRegistrationAttribute().get(k)
                                .getType();
                        attrInstance.setPropertyValue(ontModel.getProperty(MAIN_ONT_URL + "type"),
                                ontModel.createLiteral(ngsiValue));

                        int mdListSize = rcr.getContextRegistration().get(i).getContextRegistrationAttribute()
                                .get(k).getContextMetadata().size();
                        for (int l = 0; l < mdListSize; l++) {
                            ngsiValue = rcr.getContextRegistration().get(i).getContextRegistrationAttribute()
                                    .get(k).getContextMetadata().get(l).getName();
                            Individual mdataInstance = ontModel.createIndividual(MAIN_ONT_URL + ngsiValue,
                                    metadata);
                            attrInstance.addProperty(ontModel.getProperty(MAIN_ONT_URL + "hasMetadata"),
                                    mdataInstance);

                            ngsiValue = rcr.getContextRegistration().get(i).getContextRegistrationAttribute()
                                    .get(k).getContextMetadata().get(l).getType();
                            mdataInstance.setPropertyValue(ontModel.getProperty(MAIN_ONT_URL + "type"),
                                    ontModel.createLiteral(ngsiValue));
                            ngsiValue = rcr.getContextRegistration().get(i).getContextRegistrationAttribute()
                                    .get(k).getContextMetadata().get(l).getValue().toString();
                            mdataInstance.setPropertyValue(ontModel.getProperty(MAIN_ONT_URL + "value"),
                                    ontModel.createLiteral(ngsiValue));
                        }
                    }

                }

            }

        }

    }
    //        ngsiValue = rcr.getContextRegistration().get(0).getEntityId().get(0).getId();
    //        Individual entity1 = ontModel.createIndividual(ONT_URL + ngsiValue, entity);
    //        entityGroupIndiv.addProperty(ontModel.getProperty(ONT_URL + "hasEntity"), entity1);
    //        ngsiValue = rcr.getContextRegistration().get(0).getEntityId().get(0).getId();
    //        entity1.setPropertyValue(ontModel.getProperty(ONT_URL + "id"), ontModel.createLiteral(ngsiValue));        
    //        ngsiValue = rcr.getContextRegistration().get(0).getEntityId().get(0).getType();
    //        entity1.setPropertyValue(ontModel.getProperty(ONT_URL + "type"), ontModel.createLiteral(ngsiValue));        

    //        ngsiValue = rcr.getContextRegistration().get(0).getContextRegistrationAttribute().get(0).getName();
    //        Individual attribute1 = ontModel.createIndividual(ONT_URL + ngsiValue, attribute);
    //        entity1.setPropertyValue(ontModel.getProperty(ONT_URL + "hasAttribute"), attribute1);
    //        
    //        ngsiValue = rcr.getContextRegistration().get(0).getContextRegistrationAttribute().get(0).getType();
    //        attribute1.setPropertyValue(ontModel.getProperty(ONT_URL + "type"), ontModel.createLiteral(ngsiValue));
    //        
    //        ngsiValue = rcr.getContextRegistration().get(0).getContextRegistrationAttribute().get(0).getContextMetadata().get(0).getName();
    //        Individual metadata1 = ontModel.createIndividual(ONT_URL + ngsiValue, metadata);
    //        attribute1.setPropertyValue(ontModel.getProperty(ONT_URL + "hasMetadata"), metadata1);
    //        
    //        ngsiValue = rcr.getContextRegistration().get(0).getContextRegistrationAttribute().get(0).getContextMetadata().get(0).getType();
    //        metadata1.setPropertyValue(ontModel.getProperty(ONT_URL + "type"), ontModel.createLiteral(ngsiValue));
    //        ngsiValue = rcr.getContextRegistration().get(0).getContextRegistrationAttribute().get(0).getContextMetadata().get(0).getValue().toString();
    //        metadata1.setPropertyValue(ontModel.getProperty(ONT_URL + "value"), ontModel.createLiteral(ngsiValue));
    //        
    //        ngsiValue = rcr.getContextRegistration().get(0).getContextRegistrationAttribute().get(0).getContextMetadata().get(1).getName();
    //        Individual metadata2 = ontModel.createIndividual(ONT_URL + ngsiValue, metadata);
    //        attribute1.addProperty(ontModel.getProperty(ONT_URL + "hasMetadata"), metadata2);
    //        
    //        ngsiValue = rcr.getContextRegistration().get(0).getContextRegistrationAttribute().get(0).getContextMetadata().get(1).getType();
    //        metadata2.setPropertyValue(ontModel.getProperty(ONT_URL + "type"), ontModel.createLiteral(ngsiValue));
    //        ngsiValue = rcr.getContextRegistration().get(0).getContextRegistrationAttribute().get(0).getContextMetadata().get(1).getValue().toString();
    //        metadata2.setPropertyValue(ontModel.getProperty(ONT_URL + "value"), ontModel.createLiteral(ngsiValue));
    ontModel.write(System.out, "TURTLE");
    //        ontModel.write(System.out, "RDF/XML");
    //        ontModel.write(System.out, "JSON-LD");

}

From source file:com.microsoft.azure.servicebus.samples.duplicatedetection.DuplicateDetection.java

void receive(String connectionString) throws Exception {
    IMessageReceiver receiver = ClientFactory.createMessageReceiverFromConnectionStringBuilder(
            new ConnectionStringBuilder(connectionString, "DupdetectQueue"), ReceiveMode.PEEKLOCK);

    // receive messages from queue
    String receivedMessageId = "";

    System.out.printf("\n\tWaiting up to 5 seconds for messages from %s ...\n", receiver.getEntityPath());
    while (true) {
        IMessage receivedMessage = receiver.receive(Duration.ofSeconds(5));

        if (receivedMessage == null) {
            break;
        }//from w ww.  java 2  s.  co m
        System.out.printf("\t<= Received a message with messageId %s\n", receivedMessage.getMessageId());
        receiver.complete(receivedMessage.getLockToken());
        if (receivedMessageId.contentEquals(receivedMessage.getMessageId())) {
            throw new Exception("Received a duplicate message!");
        }
        receivedMessageId = receivedMessage.getMessageId();
    }
    System.out.printf("\tDone receiving messages from %s\n", receiver.getEntityPath());

    receiver.close();
}

From source file:com.wwidesigner.gui.StudyView.java

/**
 * Set the study model to a specified object.
 *///from  w  w w  . j a  v  a  2s  .  c  om
public void setStudyModel(String studyClassName) {
    if (studyClassName.contentEquals(OptimizationPreferences.NAF_STUDY_NAME)) {
        setStudyModel(
                new NafStudyModel(getApplication().getApplicationUIManager().getWindowsUI().getDialogParent()));
    } else if (studyClassName.contentEquals(OptimizationPreferences.WHISTLE_STUDY_NAME)) {
        setStudyModel(new WhistleStudyModel());
    } else if (studyClassName.contentEquals(OptimizationPreferences.FLUTE_STUDY_NAME)) {
        setStudyModel(new FluteStudyModel());
    } else if (studyClassName.contentEquals(OptimizationPreferences.REED_STUDY_NAME)) {
        setStudyModel(new ReedStudyModel());
    } else {
        // Default study model.
        setStudyModel(new WhistleStudyModel());
    }
}

From source file:org.noorganization.instalistsynch.controller.synch.impl.UnitSynch.java

@Override
public void indexLocal(int _groupId, Date _lastIndexTime) {
    String lastIndexTime = ISO8601Utils.format(_lastIndexTime, false, TimeZone.getTimeZone("GMT+0000"));
    Cursor changeLog = mLocalLogController.getLogsSince(lastIndexTime, eModelType.UNIT);

    while (changeLog.moveToNext()) {
        int actionId = changeLog.getInt(changeLog.getColumnIndex(LogInfo.COLUMN.ACTION));
        eActionType actionType = eActionType.getTypeById(actionId);

        String uuid = changeLog.getString(changeLog.getColumnIndex(LogInfo.COLUMN.ITEM_UUID));
        if (uuid.contentEquals("-"))
            continue;

        List<ModelMapping> existingMappings = mMappingController.get(
                ModelMapping.COLUMN.CLIENT_SIDE_UUID + " = ? AND " + ModelMapping.COLUMN.GROUP_ID + " = ?",
                new String[] { uuid, String.valueOf(_groupId) });
        ModelMapping existingMapping = (existingMappings.size() == 0 ? null : existingMappings.get(0));

        if (actionType == null) {
            Log.w(TAG, "Changelog contains entry without action.");
            continue;
        }//from   w ww .  j ava  2  s  .c o  m

        switch (actionType) {
        case INSERT: {
            if (existingMapping == null) {
                ModelMapping newMapping = new ModelMapping(null, _groupId, null, uuid,
                        new Date(Constants.INITIAL_DATE), new Date(), false);
                mMappingController.insert(newMapping);
            }
            break;
        }
        case UPDATE: {
            if (existingMapping == null) {
                Log.e(TAG, "Changelog contains update, but mapping does not exist. " + "Ignoring.");
                continue;
            }
            try {
                Date clientDate = ISO8601Utils.parse(
                        changeLog.getString(changeLog.getColumnIndex(LogInfo.COLUMN.ACTION_DATE)),
                        new ParsePosition(0));
                existingMapping.setLastClientChange(clientDate);
                mMappingController.update(existingMapping);
            } catch (ParseException e) {
                Log.e(TAG, "Change log contains invalid date: " + e.getMessage());
                continue;
            }
            break;
        }
        case DELETE: {
            if (existingMapping == null) {
                Log.e(TAG, "Changelog contains deletion, but mapping does not exist. " + "Ignoring.");
                continue;
            }
            try {
                Date clientDate = ISO8601Utils.parse(
                        changeLog.getString(changeLog.getColumnIndex(LogInfo.COLUMN.ACTION_DATE)),
                        new ParsePosition(0));
                existingMapping.setLastClientChange(clientDate);
                existingMapping.setDeleted(true);
                mMappingController.update(existingMapping);
            } catch (ParseException e) {
                Log.e(TAG, "Change log contains invalid date: " + e.getMessage());
                continue;
            }
            break;
        }
        }
    }
    changeLog.close();
}

From source file:de.enlightened.peris.ForumSettingsFragment.java

private void setupHomeButton(final SharedPreferences appPreferences) {
    //Home Page button
    final LinearLayout forumSettingHome = (LinearLayout) getActivity().findViewById(R.id.forum_setting_home);
    forumSettingHome.setOnClickListener(new View.OnClickListener() {
        @Override//  ww w. j  a  va 2s  . c  om
        @SuppressWarnings("checkstyle:requirethis")
        public void onClick(final View v) {
            final PopupMenu popup = new PopupMenu(getActivity(), v);
            final MenuInflater inflater = popup.getMenuInflater();
            inflater.inflate(R.menu.home_page_selection, popup.getMenu());
            popup.setOnMenuItemClickListener(forumHomeSelectedListener);
            popup.show();
        }
    });

    //Home Page Display Text
    final String currentServerId = this.application.getSession().getServer().serverId;
    final String keyName = currentServerId + "_home_page";
    String valueName = getString(R.string.subforum_id);
    String displayName = "Forum Index";

    valueName = appPreferences.getString(keyName, getString(R.string.subforum_id));

    if (valueName.contentEquals(getString(R.string.subforum_id))) {
        displayName = "Forum Index";
    }
    if (valueName.contentEquals("forum_favs")) {
        displayName = "Favorites";
    }
    if (valueName.contentEquals("timeline")) {
        displayName = "Timeline";
    }
    if (valueName.contentEquals("participated")) {
        displayName = "Participated Topics";
    }
    if (valueName.contentEquals("favs")) {
        displayName = "Subscribed Topics";
    }
    if (valueName.contentEquals("unread")) {
        displayName = "Unread Topics";
    }

    final TextView forumSettingHomeCurrent = (TextView) this.getActivity()
            .findViewById(R.id.forum_setting_home_current);
    forumSettingHomeCurrent.setText(displayName);
}

From source file:com.emuneee.nctrafficcams.ui.activities.MainActivity.java

/**
 * Initializes image quality//  w w  w  .j av  a 2  s. c om
 */
private void setImageQuality() {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    String value = prefs.getString(getString(R.string.image_quality), getString(R.string.medium_quality));
    String[] values = getResources().getStringArray(R.array.image_quality_settings);
    // hi - med - low
    if (value.contentEquals(values[0])) {
        mCacheParams.compressQuality = ImageWorker.HIGH;
    } else if (value.contentEquals(values[1])) {
        mCacheParams.compressQuality = ImageWorker.MEDIUM;
    } else if (value.contentEquals(values[2])) {
        mCacheParams.compressQuality = ImageWorker.LOW;
    }
}

From source file:de.enlightened.peris.SettingsFragment.java

private void juiceUpMenu() {
    this.setupUserCard();

    if (this.getActivity() == null) {
        return;//w  w w  .j  a  va 2  s . com
    }

    this.lvMain = (ListView) getActivity().findViewById(R.id.settings_list);
    this.lvMain.setDivider(null);

    final Bundle bundle = getArguments();
    if (bundle.containsKey("background")) {
        this.background = bundle.getString("background");
    }

    this.serverAddress = this.application.getSession().getServer().serverAddress;

    if (getString(R.string.server_location).contentEquals("0")) {
        this.storagePrefix = this.serverAddress + "_";
    }

    final String userid = this.application.getSession().getServer().serverUserId;
    this.settingsOptions = this.createSettingsOptions(userid);
    this.lvMain.setAdapter(new SettingsAdapter(this.settingsOptions, getActivity()));

    this.lvMain.setTextFilterEnabled(true);
    this.lvMain.setOnItemClickListener(new OnItemClickListener() {
        @SuppressWarnings("checkstyle:requirethis")
        public void onItemClick(final AdapterView<?> parent, final View view, final int position,
                final long id) {
            if (settingsOptions == null) {
                return;
            }
            final String theResult = settingsOptions.get(position).settingName;

            if (theResult.contentEquals("Unread Topics")) {
                final Category category = Category.builder().name("Unread Topics").id("unread")
                        //todo: color?
                        .build();
                //category.subforumId = "0";
                //category.color = background;

                if (categorySelected != null) {
                    categorySelected.onCategorySelected(category);
                }
            } else if (theResult.contentEquals("Participated Topics")) {
                final Category category = Category.builder().name("Participated Topics").id("participated")
                        .build();
                //category.subforumId = "0";
                //category.color = background;

                if (categorySelected != null) {
                    categorySelected.onCategorySelected(category);
                }
            } else if (theResult.contentEquals("Subscribed Topics")) {
                final Category category = Category.builder().name("Subscribed Topics").id("favs").build();
                //category.subforumId = "0";
                //category.color = background;

                if (categorySelected != null) {
                    categorySelected.onCategorySelected(category);
                }
            } else if (theResult.contentEquals("Favorites")) {
                final Category category = Category.builder().name("Favorites").id("forum_favs").build();
                //category.subforumId = "0";
                //category.color = background;

                if (categorySelected != null) {
                    categorySelected.onCategorySelected(category);
                }
            } else if (theResult.contentEquals("Timeline")) {
                final Category ca = Category.builder().name("Timeline").id("timeline").build();
                //ca.subforumId = "0";
                //ca.color = background;

                if (categorySelected != null) {
                    categorySelected.onCategorySelected(ca);
                }
            } else if (theResult.contentEquals("Inbox")) {
                final Intent myIntent = new Intent(getActivity(), Mail.class);
                startActivity(myIntent);
            } else if (theResult.contentEquals("My Profile")) {
                loadMyWall();
            } else if (theResult.contentEquals("Edit Signature")) {
                taglineEditor();
            } else if (theResult.contentEquals("Active Users")) {
                launchUsersList();
            } else if (theResult.contentEquals("Toggle Theme")) {
                themeChanger();
            } else if (theResult.contentEquals("Change Theme Color")) {
                setAccentColor();
            } else if (theResult.contentEquals("License Agreement")) {
                Eula.showDisclaimer(getActivity());
            } else if (theResult.contentEquals("Clear Cache")) {
                clearCache();
            } else if (theResult.contentEquals("Logout")) {
                doLogout();
            } else if (theResult.contentEquals("Text Options")) {
                changeTextSettings();
            } else if (theResult.contentEquals("Close Forum")) {
                getActivity().finish();
            } else if (theResult.contentEquals("About")) {
                final Intent aboutIntent = new Intent(getActivity(), About.class);
                startActivity(aboutIntent);
            } else if (theResult.contentEquals("Forum Index")) {
                if (indexRequested != null) {
                    indexRequested.onIndexRequested();
                }
            } else if (theResult.contentEquals("Settings")) {
                if (settingsRequested != null) {
                    settingsRequested.onSettingsRequested();
                }
            }
        }
    });
}