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;
/*fromwww.java2s.com*/import android.os.Parcel;
import android.os.Parcelable;
import android.util.Log;
import java.io.Serializable;
import java.util.ArrayList;
publicclass UTClass implements Parcelable, Serializable {
privatestaticfinallong serialVersionUID = 1L;
private String courseId, unique, name, semId, color;
private ArrayList<Classtime> classtimes;
publicstatic Parcelable.Creator<UTClass> CREATOR = new Parcelable.Creator<UTClass>() {
@Override
public UTClass createFromParcel(Parcel source) {
returnnew UTClass(source);
}
@Override
public UTClass[] newArray(int size) {
returnnew UTClass[size];
}
};
private UTClass(Parcel in) {
unique = in.readString();
courseId = in.readString();
name = in.readString();
classtimes = new ArrayList<Classtime>();
in.readTypedList(classtimes, Classtime.CREATOR);
semId = in.readString();
color = in.readString();
}
public UTClass(String unique, String courseId, String name, String[] buildingIds,
String[] buildingRooms, String[] days, String[] times, String semId, String color) {
this.unique = unique;
this.courseId = courseId;
this.name = name;
if (buildingIds.length != buildingRooms.length) {
Log.e("UTClass creation", "building/room size inconsistency: b" + buildingIds.length
+ " r" + buildingRooms.length);
}
ArrayList<Building> buildings = new ArrayList<Building>();
for (int i = 0; i < buildingIds.length; i++) {
buildings.add(new Building(buildingIds[i], buildingRooms[i]));
}
/* Class Listing page leaves out building info if there are multiple sections in the same
location at different times. See Chris Roberts Fall 2014 Class Listing. Here we check
to see if location info was absent from a row.
*/if (buildings.size() < days.length) {
buildings.add(new Building(buildings.get(0)));
}
classtimes = new ArrayList<Classtime>();
if (!(days.length == times.length && days.length == buildings.size() && buildings.size() == times.length)) {
Log.e("UTClass creation", "building/day/time size inconsistency: b" + buildings.size()
+ " d" + days.length + " t" + times.length);
}
for (int i = 0; i < days.length && i < times.length && i < buildings.size(); i++) {
String[] dayArray = days[i].split("");
for (int k = 1; k < dayArray.length; k++) {
classtimes.add(new Classtime(dayArray[k], times[i], buildings.get(i), color,
courseId, name, unique));
}
}
this.semId = semId;
this.color = color;
}
@Override
public String toString() {
String out = courseId + " in ";
for (int i = 0; i < classtimes.size(); i++) {
Classtime classtime = classtimes.get(i);
out += classtime.getBuilding().getId() + " in room "
+ classtime.getBuilding().getRoom() + " at "
+ classtime.getStartTime() + "-" + classtime.getEndTime()
+ " on " + classtime.getDay();
if (i != classtimes.size() - 1) {
out += " and in ";
}
}
return out;
}
public ArrayList<Classtime> getClassTimes() {
return classtimes;
}
public String getName() {
return name;
}
public String getId() {
return courseId;
}
public String getUnique() {
return unique;
}
public String getSemId() {
return semId;
}
public String getColor() {
return color;
}
@Override
publicint describeContents() {
return 0;
}
@Override
publicvoid writeToParcel(Parcel out, int flags) {
out.writeString(unique);
out.writeString(courseId);
out.writeString(name);
out.writeTypedList(classtimes);
out.writeString(semId);
out.writeString(color);
}
}