FileDocCategorySizeDatePackage
TestSipHeader2.javaAPI DocphoneME MR2 API (J2ME)43580Wed May 02 18:00:40 BST 2007javax.microedition.sip

THeader

public class THeader extends Object
Tests for the SipHeader class. We assume that for a header like
Accept-Language: da, en-gb;q=0.8, en;q=0.7
3 name-headerValue pairs will be generated by the implementation.

Fields Summary
String[]
guts
Constructors Summary
THeader(String[] guts0)

        guts = acopy(guts0);
    
THeader(THeader p)

        guts = acopy(p.guts);
    
Methods Summary
public static java.lang.String[]acopy(java.lang.String[] g)

        String[] res = new String[g.length];
        for (int i = 0; i < g.length; i++) {
            res[i] = new String(g[i]);
        }
        return res;
    
public static java.lang.String[][]acopy(java.lang.String[][] g)

        String[][] res = new String[g.length][];
        for (int i = 0; i < g.length; i++) {
            res[i] = acopy(g[i]);
        }
        return res;
    
public static java.lang.String[][]acopyWithDelimAndPrm(java.lang.String[][] g, java.lang.String[] delim, java.lang.String[] prm)

        String[][] res = new String[g.length+2][];
        int i, j;
        for (i = 0, j = 0; i < g.length-1; i++) {
            res[j++] = acopy(g[i]);
        }
        res[j++] = acopy(delim);
        res[j++] = acopy(prm);
        res[j++] = acopy(g[i++]);
        return res;
    
public static java.lang.String[][]acopyWithoutDelimAndPrm(java.lang.String[][] g, int no)

        String[][] res = new String[g.length-2][];
        if (0 <= no && no < g.length) {
            for (int i = 0, j = 0; i < g.length; i++) {
                if (i != no && i != no - 1) {
                    res[j++] = acopy(g[i]);
                }
            }
            return res;
        } else {
            return acopy(g);
        }
    
public voidappendPrmWhole(java.lang.String[] prm)

        guts = acopyWithDelimAndPrm(guts, 
				    new String[] 
	    { TestSipHeader2.makeDelimiterFor(this) },
				    prm);
    
public static java.lang.Stringconcata(java.lang.String[] a)

        String res = "";
        for (int i = 0; i < a.length; i++) {
            res = res + a[i];
        }
	return res;
    
public static java.lang.Stringconcata(java.lang.String[][] a, int i0, int im)

        String res = "";
        if (a.length < im) {
	    im = a.length;
	}
        for (int i = i0; i < im; i++) {
            res = res + concata(a[i]);
        }
	return res;
    
public intfindPrmNam(java.lang.String name)


        for (int i = 0, imax = guts.length / 2 - 2; i < imax; i++) {
            if (name.equals(getPrmNam(i))) {
                return i;
            }
        }
        return -1;
    
public java.lang.StringgetHeaderValue()

        return concata(guts, 2, guts.length-1);
    
public java.lang.StringgetName()

        return guts[0][0];
    
public java.lang.String[]getParameterNames()

        String[] res = new String [guts.length / 2 - 2];
        for (int i = 0; i < res.length; i++) {
            res[i] = getPrmNam(i);
        }
        return res;
    
public java.lang.StringgetPrmNam(int i)

        /*
	 * myout.println("index: " + i +" => " + ((i + 2) * 2
	 *    +" guts.length: "+guts.length));
	 */
        if ((i + 2) * 2 >= guts.length)
	    return null;
        return guts[(i + 2) * 2][0];
    
public java.lang.StringgetPrmVal(int i)

        return guts[(i + 2) * 2][2];
    
public java.lang.String[]getPrmWhole(int i)

        return guts[(i + 2) *2];
    
public java.lang.StringgetValue()

        return guts[2][0];
    
public voidrmvPrm(int i)

        guts = acopyWithoutDelimAndPrm(guts, (i + 2) * 2);
    
public voidsetName(java.lang.String n)

        guts[0][0] = n;
    
public voidsetOrAddPrmWhole(java.lang.String[] prm)

        int prmN = findPrmNam(prm[0]);
        if (-1 != prmN) {
	    // myout.println("setOrAddPrmWhole: set");
            setPrmWhole(prmN, prm);
        } else {
	    // myout.println("setOrAddPrmWhole: append");
            appendPrmWhole(prm);
        }
    
public voidsetPrmNam(int i, java.lang.String n)

        guts[(i + 2) * 2][0] = n;
    
public voidsetPrmVal(int i, java.lang.String v)

        guts[(i + 2) *2][2] = v;
    
public voidsetPrmWhole(int i, java.lang.String[] p)

        guts[(i + 2) *2] = p;
    
public voidsetValue(java.lang.String v)

        guts[2][0] = v;
    
public java.lang.StringtoString()

        return concata(guts, 0, guts.length);