Back to project page Go2-Rennes.
The source code is released under:
GNU General Public License
If you think the Android project Go2-Rennes listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
/******************************************************************************* * Copyright (c) 2011 Michel DAVID mimah35-at-gmail.com * /*from w w w . ja va2s.c o m*/ * 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 android.database.Cursor; import android.os.Parcel; import android.os.Parcelable; import fr.gotorennes.util.AsciiUtils; public class Ligne implements Parcelable, Comparable<Ligne> { public long id; public String code; public String longCode; public String nom; public String type; public boolean accessible; public Ligne() { nom = ""; } public Ligne(Cursor cursor) { id = cursor.getLong(cursor.getColumnIndex("_id")); code = cursor.getString(cursor.getColumnIndex("code")); longCode = cursor.getString(cursor.getColumnIndex("longcode")); nom = cursor.getString(cursor.getColumnIndex("nom")); type = cursor.getString(cursor.getColumnIndex("type")); accessible = cursor.getInt(cursor.getColumnIndex("accessible")) == 1; } public Ligne(Parcel in) { id = in.readLong(); code = in.readString(); longCode = in.readString(); nom = in.readString(); type = in.readString(); accessible = in.readInt() == 1; } public boolean isLigneDeNuit() { return code.startsWith("S"); } public boolean isLogoCarre() { return code.matches("^[0-9]$"); } private String toString = null; @Override public String toString() { if(toString == null) { toString = code + " " + nom + " " + AsciiUtils.convertNonAscii(nom); } return toString; } @Override public int describeContents() { return 0; } @Override public void writeToParcel(Parcel out, int flags) { out.writeLong(id); out.writeString(code); out.writeString(longCode); out.writeString(nom); out.writeString(type); out.writeInt(accessible ? 1 : 0); } public static final Parcelable.Creator<Ligne> CREATOR = new Parcelable.Creator<Ligne>() { @Override public Ligne createFromParcel(Parcel in) { return new Ligne(in); } @Override public Ligne[] newArray(int size) { return new Ligne[size]; } }; @Override public int compareTo(Ligne another) { return Integer.valueOf(longCode).compareTo(Integer.valueOf(another.longCode)); } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + (int) (id ^ (id >>> 32)); return result; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Ligne other = (Ligne) obj; if (id != other.id) return false; return true; } }