Android Open Source - utexas-utilities B B Class






From Project

Back to project page utexas-utilities.

License

The source code is released under:

Apache License

If you think the Android project utexas-utilities listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.nasageek.utexasutilities.model;
/*  w w w  . ja  va2s .c  om*/
import android.os.Parcel;
import android.os.Parcelable;
import android.util.Log;

import java.io.Serializable;
import java.util.Locale;

public class BBClass implements Parcelable, Serializable {

    private static final long serialVersionUID = 1L;
    private String name;
    private String bbid;
    private String fullcourseid;
    private String semester;
    private String unique;
    private String courseid;
    private String fullName;

    private boolean courseIdAvailable, fullCourseIdTooShort;

    public static Parcelable.Creator<BBClass> CREATOR = new Parcelable.Creator<BBClass>() {

        @Override
        public BBClass createFromParcel(Parcel source) {
            return new BBClass(source);
        }

        @Override
        public BBClass[] newArray(int size) {
            return new BBClass[size];
        }
    };

    public BBClass(Parcel in) {
        name = in.readString();
        bbid = in.readString();
        fullcourseid = in.readString();
        semester = in.readString();
        unique = in.readString();
        courseid = in.readString();
        boolean[] temp = new boolean[2];
        in.readBooleanArray(temp);
        courseIdAvailable = temp[0];
        fullCourseIdTooShort = temp[1];
    }

    // TODO: move auto-formatting into a separate method?
    public BBClass(String name, String bbid, String fullcourseid) {
        if (!fullcourseid.matches("^\\d{4}_[a-z]+?_\\d{5}_[A-Za-z]+?_\\w+$")) {
            Log.d("BBClass check", "Course ID malformed: " + fullcourseid);
        }
        if (!name.matches("^\\d{2}[A-Z]{1,2} .*?\\(\\d+?\\)$")) {
            Log.d("BBClass check", "Course Name malformed: " + name);
        }

        // names don't always have spaces, be careful!
        if (name.contains(" ")) {
            // TODO: might try this with a split[0] rather than the substring
            // TODO: this might not trim off Summer semester identifier, check
            // Alex's tablet
            // If we've got a date in the front (probably) chop it off
            if (name.substring(0, name.indexOf(" ")).matches("^\\d{2}[A-Z]{1,2}$")) {
                this.name = name.substring(name.indexOf(" ") + 1);
            } else {
                this.name = name;
            }
        } else {
            this.name = name;
        }

        // remove anything in parentheses, it's usually all superfluous
        this.name = this.name.replaceAll("\\(.*?\\)", "");
        // because the stuff in parentheses is generally at the beginning
        // or end, it leaves leading/trailing whitespace when removed
        this.name = this.name.trim();

        // the course ID seems to relatively consistently be the last 2 tokens
        // in the full ID, maybe just pull those out
        this.bbid = bbid;
        this.fullName = name;
        this.fullcourseid = fullcourseid;
        // some courseid's are malformed (ex. 00002), can't pull semester out of
        // that unfortunately
        try {
            // pulls the first section and second section of courseid,
            // capitalizes the first letter of the semester
            this.semester = fullcourseid.split("_")[0] + " "
                    + (fullcourseid.split("_")[1].charAt(0) + "").toUpperCase(Locale.US)
                    + fullcourseid.split("_")[1].substring(1);
        } catch (Exception ex) {
            ex.printStackTrace();
            this.semester = "Unknown";
        }

        if (fullcourseid.split("_").length >= 3) {
            fullCourseIdTooShort = false;
            this.unique = fullcourseid.split("_")[2];
            // assumes Course ID is directly after unique_ and is at the end of
            // the string
            // will fail if unique start is less than 6 characters from the end
            // of the string.
            try {
                courseid = fullcourseid.substring(fullcourseid.indexOf(unique) + 6)
                        .replaceAll("_", " ");
                courseIdAvailable = true;
            } catch (Exception ex) {
                courseIdAvailable = false;
            }
        } else {
            fullCourseIdTooShort = true;
        }
    }

    public boolean isFullCourseIdTooShort() {
        return fullCourseIdTooShort;
    }

    public boolean isCourseIdAvailable() {
        return courseIdAvailable;
    }

    public String getCourseId() {
        return courseid;
    }

    public String getUnique() {
        return unique;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getBbid() {
        return bbid;
    }

    public void setBbid(String bbid) {
        this.bbid = bbid;
    }

    public String getFullCourseid() {
        return fullcourseid;
    }

    public void setFullCourseid(String fullcourseid) {
        this.fullcourseid = fullcourseid;
    }

    public String getSemester() {
        return semester;
    }

    public void setSemester(String semester) {
        this.semester = semester;
    }

    public String getFullName() {
        return fullName;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {

        dest.writeString(name);
        dest.writeString(bbid);
        dest.writeString(fullcourseid);
        dest.writeString(semester);
        dest.writeString(unique);
        dest.writeString(courseid);
        dest.writeBooleanArray(new boolean[] {
                courseIdAvailable, fullCourseIdTooShort
        });

    }
}




Java Source Code List

com.google.maps.android.ui.MyIconGenerator.java
com.mapsaurus.paneslayout.ActivityDelegate.java
com.mapsaurus.paneslayout.FragmentLauncher.java
com.mapsaurus.paneslayout.MenuItemWrapper.java
com.mapsaurus.paneslayout.MySlidingPaneLayout.java
com.mapsaurus.paneslayout.PanesActivity.java
com.mapsaurus.paneslayout.PanesLayout.java
com.mapsaurus.paneslayout.PanesSizer.java
com.mapsaurus.paneslayout.PhoneDelegate.java
com.mapsaurus.paneslayout.SimpleScrollView.java
com.mapsaurus.paneslayout.TabletDelegate.java
com.nasageek.utexasutilities.AsyncTask.java
com.nasageek.utexasutilities.AttachmentDownloadService.java
com.nasageek.utexasutilities.AuthCookie.java
com.nasageek.utexasutilities.BlackboardDashboardXmlParser.java
com.nasageek.utexasutilities.BuildingDatabase.java
com.nasageek.utexasutilities.BuildingProvider.java
com.nasageek.utexasutilities.BuildingSaxHandler.java
com.nasageek.utexasutilities.ChangeLog.java
com.nasageek.utexasutilities.ChangeableContextTask.java
com.nasageek.utexasutilities.CourseMapSaxHandler.java
com.nasageek.utexasutilities.FixedListPreference.java
com.nasageek.utexasutilities.LoginWebViewClient.java
com.nasageek.utexasutilities.MarkerManager.java
com.nasageek.utexasutilities.MyPair.java
com.nasageek.utexasutilities.MyScrollView.java
com.nasageek.utexasutilities.PlacemarkSaxHandler.java
com.nasageek.utexasutilities.PnaAuthCookie.java
com.nasageek.utexasutilities.RouteSaxHandler.java
com.nasageek.utexasutilities.SecurePreferences.java
com.nasageek.utexasutilities.TempLoginException.java
com.nasageek.utexasutilities.UTilitiesApplication.java
com.nasageek.utexasutilities.UtdAuthCookie.java
com.nasageek.utexasutilities.Utility.java
com.nasageek.utexasutilities.WrappedViewPager.java
com.nasageek.utexasutilities.WrappingSlidingDrawer.java
com.nasageek.utexasutilities.activities.AboutMeActivity.java
com.nasageek.utexasutilities.activities.BalanceActivity.java
com.nasageek.utexasutilities.activities.BlackboardPanesActivity.java
com.nasageek.utexasutilities.activities.CampusMapActivity.java
com.nasageek.utexasutilities.activities.DataUsageActivity.java
com.nasageek.utexasutilities.activities.LoginActivity.java
com.nasageek.utexasutilities.activities.MenuActivity.java
com.nasageek.utexasutilities.activities.NutritionInfoActivity.java
com.nasageek.utexasutilities.activities.Preferences.java
com.nasageek.utexasutilities.activities.ScheduleActivity.java
com.nasageek.utexasutilities.activities.UTilitiesActivity.java
com.nasageek.utexasutilities.adapters.BBClassAdapter.java
com.nasageek.utexasutilities.adapters.CourseMapAdapter.java
com.nasageek.utexasutilities.adapters.MultiPanePagerAdapter.java
com.nasageek.utexasutilities.adapters.MyFragmentPagerAdapter.java
com.nasageek.utexasutilities.adapters.ScheduleClassAdapter.java
com.nasageek.utexasutilities.adapters.TransactionAdapter.java
com.nasageek.utexasutilities.fragments.ActionModeFragment.java
com.nasageek.utexasutilities.fragments.BlackboardAnnouncementsFragment.java
com.nasageek.utexasutilities.fragments.BlackboardCourseListFragment.java
com.nasageek.utexasutilities.fragments.BlackboardCourseMapFragment.java
com.nasageek.utexasutilities.fragments.BlackboardDashboardFragment.java
com.nasageek.utexasutilities.fragments.BlackboardDownloadableItemFragment.java
com.nasageek.utexasutilities.fragments.BlackboardExternalItemFragment.java
com.nasageek.utexasutilities.fragments.BlackboardFragment.java
com.nasageek.utexasutilities.fragments.BlackboardGradesFragment.java
com.nasageek.utexasutilities.fragments.BlackboardPagerFragment.java
com.nasageek.utexasutilities.fragments.CourseScheduleFragment.java
com.nasageek.utexasutilities.fragments.DatePickerFragment.java
com.nasageek.utexasutilities.fragments.DoubleDatePickerDialogFragment.java
com.nasageek.utexasutilities.fragments.ExamScheduleFragment.java
com.nasageek.utexasutilities.fragments.MenuFragment.java
com.nasageek.utexasutilities.fragments.NutritionInfoFragment.java
com.nasageek.utexasutilities.fragments.PickCalendarDialogFragment.java
com.nasageek.utexasutilities.fragments.TransactionsFragment.java
com.nasageek.utexasutilities.model.BBClass.java
com.nasageek.utexasutilities.model.Building.java
com.nasageek.utexasutilities.model.Classtime.java
com.nasageek.utexasutilities.model.CourseMapItem.java
com.nasageek.utexasutilities.model.FeedItem.java
com.nasageek.utexasutilities.model.Placemark.java
com.nasageek.utexasutilities.model.Transaction.java
com.nasageek.utexasutilities.model.UTClass.java
com.viewpagerindicator.MyTabPageIndicator.java