/*******************************************************************************
* Copyright (c) 2011 Michel DAVID mimah35-at-gmail.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package fr.gotorennes.domain;
import fr.gotorennes.util.AsciiUtils;
import android.database.Cursor;
import android.os.Parcel;
import android.os.Parcelable;
public class SensCirculation implements Comparable<SensCirculation>, Parcelable {
public String nom;
public long idLigne;
public int sens;
public SensCirculation() {
nom = "";
}
public SensCirculation(Parcel in) {
nom = in.readString();
idLigne = in.readLong();
sens = in.readInt();
}
public SensCirculation(Cursor cursor) {
nom = cursor.getString(cursor.getColumnIndex("nom"));
idLigne = cursor.getLong(cursor.getColumnIndex("idLigne"));
sens = cursor.getInt(cursor.getColumnIndex("sens"));
}
private String toString = null;
@Override
public String toString() {
if(toString == null) {
toString = nom + " " + AsciiUtils.convertNonAscii(nom);
}
return toString;
}
@Override
public int hashCode() {
return nom.hashCode();
}
@Override
public boolean equals(Object obj) {
SensCirculation autre = (SensCirculation) obj;
return nom.equals(autre.nom);
}
@Override
public int compareTo(SensCirculation paramT) {
return nom.compareTo(paramT.nom);
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel out, int flags) {
out.writeString(nom);
out.writeLong(idLigne);
out.writeInt(sens);
}
public static final Parcelable.Creator<SensCirculation> CREATOR = new Parcelable.Creator<SensCirculation>() {
@Override
public SensCirculation createFromParcel(Parcel in) {
return new SensCirculation(in);
}
@Override
public SensCirculation[] newArray(int size) {
return new SensCirculation[size];
}
};
}