Logo Search packages:      
Sourcecode: icedtea-web version File versions  Download package

String [] net::sourceforge::jnlp::Parser::splitString ( String  source  )  [inline]

Returns an array of substrings seperated by spaces (spaces escaped with backslash do not separate strings). This method splits strings as per the spec except that it does replace escaped other characters with their own value.

Definition at line 824 of file Parser.java.

Referenced by getLocales(), and getResourcesDesc().

                                               {
        if (source == null)
            return new String[0];

        List result = new ArrayList();
        StringTokenizer st = new StringTokenizer(source, " ");
        StringBuffer part = new StringBuffer();
        while (st.hasMoreTokens()) {
            part.setLength(0);

            // tack together tokens joined by backslash
            while (true) {
                part.append(st.nextToken());

                if (st.hasMoreTokens() && part.charAt(part.length()-1) == '\\')
                    part.setCharAt(part.length()-1, ' '); // join with the space
                else
                    break; // bizarre while format gets \ at end of string right (no extra space added at end)
            }

            // delete \ quote chars
            for (int i = part.length(); i-- > 0;) // sweet syntax for reverse loop
                if (part.charAt(i) == '\\')
                    part.deleteCharAt(i--); // and skip previous char so \\ becomes \

            result.add( part.toString() );
        }

        return (String[]) result.toArray(new String[result.size()] );
    }


Generated by  Doxygen 1.6.0   Back to index