String.substring(index) 已在调试模式下停止我的线程

发布于 2024-09-01 03:08:09 字数 2347 浏览 5 评论 0原文

我在 eclipse 3.4.2 中使用 j2me Polish 2.0.7,使用 wtk2.5.2_01。 我创建了绘制文本的控件:正常、粗体和斜体。

下面的代码正在解析原始文本,并搜索 * 和 _ 符号,如果找到,则将文本和抽屉添加到绘制向量,并且在第二次到达第 58 行后停止:
String test = new String(raw_text_buff.substring(iter));
它停止在 raw_text_buff.substring(iter) 中,仅在调试模式下..

原始文本是: bla bla bla *1000* bla bla

完整代码:

private String raw_text = "bla bla bla *1000* bla bla";
Vector draw_items = null;

private void prepareText()
{
    char open_char = 0; 
    int open_pos = 0;
    Object []param = null;
    StringBuffer sb = new StringBuffer();
    String raw_text_buff = new String(raw_text);
    int iter = 0;
    boolean was_reset = false; 
    while(true)
    {
        char c = raw_text_buff.charAt(iter);



        if(iter == raw_text_buff.length() || c == '*' || c == '_')
        {
            if(sb.length() > 0) 
            {
                BmFont viewer = null;
                String str = sb.toString();

                if(open_char == '*' && null != bm_strong)
                {
                    viewer = bm_strong.getViewer(str);
                }else
                if(open_char == '_' && null != bm_italic)
                {
                    viewer = bm_italic.getViewer(str);
                }else if(null != bm_normal)
                {
                    viewer = bm_normal.getViewer(str);
                }else
                {

                }

                param = new Object[2];

                param[0] = str;
                param[1] = viewer;

                if(null == draw_items)
                    draw_items = new Vector();

                draw_items.addElement(param);

                sb = new StringBuffer();

                if(open_char == 0 && (c == '*' || c=='_'))
                    open_char = c; 
                else
                    open_char = 0; 

                String test = new String(raw_text_buff.substring(iter)); // stucks here.
                raw_text_buff = test;
                iter = 0;
                was_reset = true;
            }else
            {
                open_char = c;
            }


            if(iter == raw_text_buff.length())
                break;
        }else
        {
            sb.append(c);

        }

        ++iter;
    }


}

我做错了什么?

I work with j2me polish 2.0.7, in eclipse 3.4.2, with wtk2.5.2_01.
I create control which draws text: normal, bold, and italic.

The code below is parsing raw text, and search for * and _ symbols, if found than add to draw vector the text and the drawer, and it's just stops after getting second time to the line 58:
String test = new String(raw_text_buff.substring(iter));
it stops in raw_text_buff.substring(iter), ONLY in debug mode..

raw text is: bla bla bla *1000* bla bla

Full code:

private String raw_text = "bla bla bla *1000* bla bla";
Vector draw_items = null;

private void prepareText()
{
    char open_char = 0; 
    int open_pos = 0;
    Object []param = null;
    StringBuffer sb = new StringBuffer();
    String raw_text_buff = new String(raw_text);
    int iter = 0;
    boolean was_reset = false; 
    while(true)
    {
        char c = raw_text_buff.charAt(iter);



        if(iter == raw_text_buff.length() || c == '*' || c == '_')
        {
            if(sb.length() > 0) 
            {
                BmFont viewer = null;
                String str = sb.toString();

                if(open_char == '*' && null != bm_strong)
                {
                    viewer = bm_strong.getViewer(str);
                }else
                if(open_char == '_' && null != bm_italic)
                {
                    viewer = bm_italic.getViewer(str);
                }else if(null != bm_normal)
                {
                    viewer = bm_normal.getViewer(str);
                }else
                {

                }

                param = new Object[2];

                param[0] = str;
                param[1] = viewer;

                if(null == draw_items)
                    draw_items = new Vector();

                draw_items.addElement(param);

                sb = new StringBuffer();

                if(open_char == 0 && (c == '*' || c=='_'))
                    open_char = c; 
                else
                    open_char = 0; 

                String test = new String(raw_text_buff.substring(iter)); // stucks here.
                raw_text_buff = test;
                iter = 0;
                was_reset = true;
            }else
            {
                open_char = c;
            }


            if(iter == raw_text_buff.length())
                break;
        }else
        {
            sb.append(c);

        }

        ++iter;
    }


}

What I'm doing wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文