Logo Search packages:      
Sourcecode: janino version File versions  Download package

static String [] org::codehaus::janino::UnitCompiler::makeUTF8Able ( String  s  )  [inline, static, private]

Only strings that can be UTF8-encoded into 65535 bytes can be stored as constant string infos.

Parameters:
s The string to split into suitable chunks
Returns:
the chunks that can be UTF8-encoded into 65535 bytes

Definition at line 6777 of file UnitCompiler.java.

                                                   {
        if (s.length() < (65536 / 3)) return new String[] { s };

        int sLength = s.length(), uTFLength = 0;
        int from = 0;
        List l = new ArrayList();
        for (int i = 0;; i++) {
            if (i == sLength) {
                l.add(s.substring(from));
                break;
            }
            if (uTFLength >= 65532) {
                l.add(s.substring(from, i));
                if (i + (65536 / 3) > sLength) {
                    l.add(s.substring(i));
                    break;
                }
                from = i;
                uTFLength = 0;
            }
            int c = s.charAt(i);
            if (c >= 0x0001 && c <= 0x007F) {
                ++uTFLength;
            } else
            if (c > 0x07FF) {
                uTFLength += 3;
            } else
            {
                uTFLength += 2;
            }
        }
        return (String[]) l.toArray(new String[l.size()]);

    }


Generated by  Doxygen 1.6.0   Back to index