⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 data.java

📁 一个J2ME Twitter 客户端的NetBeans项目
💻 JAVA
字号:
/*
 ******************************************************************************
    Twitter user data
    Copyright (C) 2007 Timothy Lim Sheng Hwee

    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 2 of the License, or
    (at your option) any later version.

    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, write to the Free Software Foundation, Inc.,
    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

 Author: Timothy Lim Sheng Hwee
 Email : LimShengHwee@gmail.com
******************************************************************************
 */

package Twittering;
import java.util.Vector;

/**
 *
 * @author Administrator
 */
public class Data {
    
    /** Creates a new instance of Data */
    private String user;
    private String pass;
    private Vector friends;
    
    private String tweetMsg;
    private String directMessageUser;
    private String directMessageMsg;
            
    public Data() {
        user = "";
        pass = "";
        friends = new Vector();
    }
    
    public String getUser() { return user; }
    public void setUser(String u) { user = u; }
    public String getPass() { return pass; }
    public void setPass(String p) { pass = p; }
    public Vector getFriends() { return friends; }
    public void setFriends(Vector f) { friends = f; }
    public void addFriend(String str) 
    {
        System.out.println("add: " + str);
        int start, stop, mid;
        start = 0;
        stop = friends.size() - 1;
        mid = (start+stop) /2;
        System.out.println(start + "|" + mid + "|" + stop  +"|"+ friends.size());
        
        if(mid <= stop)
        {
            while(true)
            {
                System.out.println("me : " + str + "\nmid: " + friends.elementAt(mid));
                
                if(str.toLowerCase().compareTo(((String) friends.elementAt(mid)).toLowerCase()) < 0)
                {
                    System.out.println("less");
                    System.out.println(start + "|" + mid + "|" + stop  +"|"+ friends.size());
                    if(mid - 1 >= 0)
                    {
                        if(str.toLowerCase().compareTo(((String) friends.elementAt(mid-1)).toLowerCase()) >= 0)
                        {
                            friends.insertElementAt(str, mid);
                            break;
                        }
                        else
                        {
                            stop = mid;
                            mid = (start+stop) /2;
                        }
                    }
                    else
                    {                    
                        friends.insertElementAt(str, 0);
                        break;
                    }
                }
                else if(str.toLowerCase().compareTo(((String) friends.elementAt(mid)).toLowerCase()) > 0)
                {
                    System.out.println("more");
                    if(mid + 1 <= stop)
                    {
                        if(str.toLowerCase().compareTo(((String) friends.elementAt(mid+1)).toLowerCase()) <= 0)
                        {
                            friends.insertElementAt(str, mid+1);
                            break;
                        }
                        else
                        {
                            start = mid + 1;
                            mid = (start+stop) /2;
                        }
                    }
                    else
                    {
                        friends.insertElementAt(str, mid+1);
                        break;
                    }
                }
                else 
                {
                    friends.insertElementAt(str, mid);
                    break;
                }
            }
        }
        else
            friends.insertElementAt(str, 0);
        
    }
    public void addFriend(String f, int start, int stop) 
    {
        int pos = friends.size() / 2;
        if(f.compareTo((String) friends.elementAt(pos)) < 1)
            addFriend(f, start, pos);
        else
            addFriend(f, pos, stop);
    }


    public String toString()
    {
        String msg = "";

        msg += "User: " + getUser() + "\n";
        msg += "Pass: " + getPass() + "\n";
        if (friends != null)
        {
            for(int i = 0; i < friends.size(); i++)
            msg += "Friends " + (i+1) +": " + friends.elementAt(i) + "\n";
        }
        else
        {
            msg += "Friends: " + friends + "\n";
        }
        
        
        return msg;
    }

    public String getTweetMsg()
    {
        return tweetMsg;
    }

    public void setTweetMsg(String tweetMsg)
    {
        this.tweetMsg = tweetMsg;
    }

    public String getDirectMessageUser()
    {
        return directMessageUser;
    }

    public void setDirectMessageUser(String directMessageUser)
    {
        this.directMessageUser = directMessageUser;
    }

    public String getDirectMessageMsg()
    {
        return directMessageMsg;
    }

    public void setDirectMessageMsg(String directMessageMsg)
    {
        this.directMessageMsg = directMessageMsg;
    }
    
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -