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

📄 utils.java

📁 goText is a program for mobile phones that allows you to send text messages over GPRS/EDGE/UMTS. It
💻 JAVA
字号:
/**
 * Class : short description
 * @author Natale Vinto ebballon@interfree.it
 * @author Michele 'Miccar' Cardinale miccar@gmail.com
 * @version 1.0
 */


 /*
  *  goText : text messaging over GPRS
  *  Copyright (C) 2006  Natale Vinto <ebballon@interfree.it>
  *  OpenJLab Group www.openjlab.org
  *  Copyright (C) 2006  Michele Cardinale 'Miccar' <miccar@gmail.com>
  *  www.miccar.org
  *
  *  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., 675 Mass Ave, Cambridge, MA 02139, USA.
  */

import java.util.*;
import javax.microedition.lcdui.*;

public class utils {
    
    public static String[] splitString(String text, String token){
        String s=text;
        int fromHere=0;
        int toHere;
        Vector temp=new Vector();
        while(s.indexOf(token, fromHere)!=-1){
            toHere=s.indexOf(token, fromHere);
            String z=s.substring(fromHere, toHere);
            temp.addElement(z);
            fromHere=toHere+token.length();
        }
        toHere=text.length();
        temp.addElement(s.substring(fromHere, toHere));
        if(temp.firstElement().toString().length()==0){
            return new String[0];
        }else{
            String[] splitted_string=new String[temp.size()];
            temp.copyInto(splitted_string);
            return splitted_string;
        }
    }
    
    public static String getTag(String text, String tag){
        int fromHere=text.indexOf("<"+tag+">");
        int toHere=text.indexOf("</"+tag+">");
        if ((fromHere>-1)&&(toHere>fromHere)){
            return text.substring(fromHere+("<"+tag+">").length(), toHere);
        } else {
            return "";
        }
    }
        
    public static void popup(String title,String text,goText gotext,AlertType alerttype){
        Alert alert = new Alert(title,text,null,alerttype);
        alert.setTimeout(alert.FOREVER);
        gotext.display.setCurrent( alert );
    }
    
    /*
    public static int pow(int b, int exp){
        int ris=1;
        if(exp==0){
            return ris;
        } else {
            ris=b;
            for (int i=1;i<exp;i++)
                ris*=b;
            return ris;
        }
    }
     */
    
    public static String checkText(String text){
        //Walkaround momentaneo per il segno %
        //Devo sistemare la funzione replaceString
        String Body=replaceString(text,"%","[[percent]]");
        Body=replaceString(Body,"[[percent]]", "%25");
        Body=replaceString(Body,"+", "%2B");
        Body=replaceString(Body,"&", "%26");
        Body=replaceString(Body, "$", "%24");
        Body=replaceString(Body,"\\", "%2F");
    	Body=replaceString(Body,"/", "%2F");
    	Body=replaceString(Body,"=", "%3D");
        Body=replaceString(Body,"'", "%27");
        Body=replaceString(Body,";", "%3B");
        Body=replaceString(Body,"

⌨️ 快捷键说明

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