/******************************************************************************
* Copyright (c) 2007 Savino Sguera. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this
* distribution and is available at http://www.eclipse.org/legal/epl-v10.html.
*
* Contributors:
* Savino Sguera < s.sguera@ieee.org >
******************************************************************************
*/
package org.eclipse.twipse.model;
import java.sql.Timestamp;
import org.apache.commons.codec.EncoderException;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.codec.net.URLCodec;
public class Status implements Comparable{
private User user;
private String text;
private String id;
private String created_at;
private String source;
public Status(){
}
public Status(String text){
this.text=text;
}
public boolean equals(Object b){
if(!(b instanceof Status))throw new ClassCastException();
return id.equals(((Status)b).getId());
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getSource() {
return source;
}
public void setSource(String source) {
this.source = source;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
public String getTextURLEncoded(){
if(text==null)return null;
String s = null;
try {
s = new String(new URLCodec().encode(getText()));
} catch (EncoderException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return s;
}
public String getCreated_at() {
return created_at;
}
public void setCreated_at(String created_at) {
this.created_at = created_at;
}
public String toString(){
return user.getScreen_name()+" is "+text+";// (updated at "+created_at+").";
}
public int compareTo(Object arg0) {
if(!(arg0 instanceof Status)) throw new ClassCastException();
Status t = (Status)arg0;
int a = Integer.parseInt(id);
int b = Integer.parseInt(t.getId());
if(a==b)return 0;
return (a>b)?-1:1;
}
}