Example usage for java.lang CharSequence subSequence

List of usage examples for java.lang CharSequence subSequence

Introduction

In this page you can find the example usage for java.lang CharSequence subSequence.

Prototype

CharSequence subSequence(int start, int end);

Source Link

Document

Returns a CharSequence that is a subsequence of this sequence.

Usage

From source file:org.archive.modules.extractor.ExtractorHTML.java

/**
 * Run extractor.//  w  ww  .ja va  2s  .c o m
 * This method is package visible to ease testing.
 * @param curi CrawlURI we're processing.
 * @param cs Sequence from underlying ReplayCharSequence. This
 * is TRANSIENT data. Make a copy if you want the data to live outside
 * of this extractors' lifetime.
 */
protected void extract(CrawlURI curi, CharSequence cs) {
    Matcher tags = TextUtils.getMatcher(relevantTagPattern, cs);
    while (tags.find()) {
        if (Thread.interrupted()) {
            break;
        }
        if (tags.start(8) > 0) {
            // comment match
            // for now do nothing
        } else if (tags.start(7) > 0) {
            // <meta> match
            int start = tags.start(5);
            int end = tags.end(5);
            assert start >= 0 : "Start is: " + start + ", " + curi;
            assert end >= 0 : "End is :" + end + ", " + curi;
            if (processMeta(curi, cs.subSequence(start, end))) {

                // meta tag included NOFOLLOW; abort processing
                break;
            }
        } else if (tags.start(5) > 0) {
            // generic <whatever> match
            int start5 = tags.start(5);
            int end5 = tags.end(5);
            assert start5 >= 0 : "Start is: " + start5 + ", " + curi;
            assert end5 >= 0 : "End is :" + end5 + ", " + curi;
            int start6 = tags.start(6);
            int end6 = tags.end(6);
            assert start6 >= 0 : "Start is: " + start6 + ", " + curi;
            assert end6 >= 0 : "End is :" + end6 + ", " + curi;
            String element = cs.subSequence(start6, end6).toString();
            CharSequence attributes = cs.subSequence(start5, end5);
            processGeneralTag(curi, element, attributes);
            // remember FORM to help later extra processing
            if ("form".equalsIgnoreCase(element)) {
                curi.getDataList(A_FORM_OFFSETS).add((Integer) (start6 - 1));
            }

        } else if (tags.start(1) > 0) {
            // <script> match
            int start = tags.start(1);
            int end = tags.end(1);
            assert start >= 0 : "Start is: " + start + ", " + curi;
            assert end >= 0 : "End is :" + end + ", " + curi;
            assert tags.end(2) >= 0 : "Tags.end(2) illegal " + tags.end(2) + ", " + curi;
            processScript(curi, cs.subSequence(start, end), tags.end(2) - start);

        } else if (tags.start(3) > 0) {
            // <style... match
            int start = tags.start(3);
            int end = tags.end(3);
            assert start >= 0 : "Start is: " + start + ", " + curi;
            assert end >= 0 : "End is :" + end + ", " + curi;
            assert tags.end(4) >= 0 : "Tags.end(4) illegal " + tags.end(4) + ", " + curi;
            processStyle(curi, cs.subSequence(start, end), tags.end(4) - start);
        }
    }
    TextUtils.recycleMatcher(tags);
}

From source file:com.servoy.j2db.util.Utils.java

public static CharSequence stringLimitLenght(final CharSequence str, int length) {
    if (str == null)
        return null;
    return (str.length() > length ? str.subSequence(0, length) : str);
}

From source file:com.github.irshulx.Components.InputExtensions.java

public CustomEditText getNewEditTextInst(final String hint, CharSequence text) {
    final CustomEditText editText = new CustomEditText(
            new ContextThemeWrapper(this.editorCore.getContext(), R.style.WysiwygEditText));
    addEditableStyling(editText);/*from w  w w.j a  v  a 2  s  .co  m*/
    editText.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    if (hint != null) {
        editText.setHint(hint);
    }
    if (text != null) {
        setText(editText, text);
    }

    /**
     * create tag for the editor
     */

    EditorControl editorTag = editorCore.createTag(EditorType.INPUT);
    editorTag.textSettings = new TextSettings(this.DEFAULT_TEXT_COLOR);
    editText.setTag(editorTag);
    editText.setBackgroundDrawable(
            ContextCompat.getDrawable(this.editorCore.getContext(), R.drawable.invisible_edit_text));
    editText.setOnKeyListener(new View.OnKeyListener() {
        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            return editorCore.onKey(v, keyCode, event, editText);
        }
    });
    editText.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (!hasFocus) {
                editText.clearFocus();
            } else {
                editorCore.setActiveView(v);
            }
        }
    });
    editText.addTextChangedListener(new TextWatcher() {
        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void afterTextChanged(Editable s) {

            String text = Html.toHtml(editText.getText());
            Object tag = editText.getTag(R.id.control_tag);
            if (s.length() == 0 && tag != null)
                editText.setHint(tag.toString());
            if (s.length() > 0) {
                /*
                 * if user had pressed enter, replace it with br
                 */
                for (int i = 0; i < s.length(); i++) {
                    if (s.charAt(i) == '\n') {
                        CharSequence subChars = s.subSequence(0, i);
                        SpannableStringBuilder ssb = new SpannableStringBuilder(subChars);
                        text = Html.toHtml(ssb);
                        if (text.length() > 0)
                            setText(editText, text);

                        if (i + 1 == s.length()) {
                            s.clear();
                        }

                        int index = editorCore.getParentView().indexOfChild(editText);
                        /* if the index was 0, set the placeholder to empty, behaviour happens when the user just press enter
                         */
                        if (index == 0) {
                            editText.setHint(null);
                            editText.setTag(R.id.control_tag, hint);
                        }
                        int position = index + 1;
                        CharSequence newText = null;
                        SpannableStringBuilder editable = new SpannableStringBuilder();
                        int lastIndex = s.length();
                        int nextIndex = i + 1;
                        if (nextIndex < lastIndex) {
                            newText = s.subSequence(nextIndex, lastIndex);
                            for (int j = 0; j < newText.length(); j++) {
                                editable.append(newText.charAt(j));
                                if (newText.charAt(j) == '\n') {
                                    editable.append('\n');
                                }
                            }
                        }
                        insertEditText(position, hint, editable);
                        break;
                    }
                }
            }
            if (editorCore.getEditorListener() != null) {
                editorCore.getEditorListener().onTextChanged(editText, s);
            }
        }
    });
    if (this.lineSpacing != -1) {
        setLineSpacing(editText, this.lineSpacing);
    }
    return editText;
}

From source file:wicket.protocol.http.request.CryptedUrlWebRequestCodingStrategy.java

/**
 * Try to shorten the querystring without loosing information. Note:
 * WebRequestWithCryptedUrl must implement exactly the opposite logic.
 * //from w w  w  .  j  a  v  a 2 s . c  o  m
 * @param queryString
 *            The original query string
 * @return The shortened querystring
 */
protected CharSequence shortenUrl(CharSequence queryString) {
    queryString = Strings.replaceAll(queryString, WebRequestCodingStrategy.BEHAVIOR_ID_PARAMETER_NAME + "=",
            "1-");
    queryString = Strings.replaceAll(queryString,
            WebRequestCodingStrategy.INTERFACE_PARAMETER_NAME + "=IRedirectListener", "2-");
    queryString = Strings.replaceAll(queryString,
            WebRequestCodingStrategy.INTERFACE_PARAMETER_NAME + "=IFormSubmitListener", "3-");
    queryString = Strings.replaceAll(queryString,
            WebRequestCodingStrategy.INTERFACE_PARAMETER_NAME + "=IOnChangeListener", "4-");
    queryString = Strings.replaceAll(queryString,
            WebRequestCodingStrategy.INTERFACE_PARAMETER_NAME + "=ILinkListener", "5-");
    queryString = Strings.replaceAll(queryString, WebRequestCodingStrategy.INTERFACE_PARAMETER_NAME + "=",
            "6-");
    queryString = Strings.replaceAll(queryString,
            WebRequestCodingStrategy.BOOKMARKABLE_PAGE_PARAMETER_NAME + "=", "7-");

    // For debugging only: determine possibilities to further shorten
    // the query string
    if (log.isDebugEnabled()) {
        // Every word with at least 3 letters
        Pattern words = Pattern.compile("\\w\\w\\w+");
        Matcher matcher = words.matcher(queryString);
        while (matcher.find()) {
            CharSequence word = queryString.subSequence(matcher.start(), matcher.end());
            log.debug("URL pattern NOT shortened: '" + word + "' - '" + queryString + "'");
        }
    }

    return queryString;
}

From source file:net.kidlogger.kidlogger.KLService.java

private void doScanClipboard() {
    ClipboardManager cm = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
    String content = "";
    int cSize = 0;
    if (cm.hasText()) {
        CharSequence tmp = cm.getText();
        cSize = tmp.length();/*from  w  ww.ja v  a  2s .c o m*/
        if ((prevClipSize != cSize) && (cSize != 0)) {
            if (cSize > 30)
                content = tmp.subSequence(0, 30).toString();
            else
                content = tmp.toString();

            prevClipSize = cSize;

            // Log clipboard content
            final String cnt = new String(content);
            new Thread(new Runnable() {
                public void run() {
                    sync.writeLog(".htm", Templates.getClipboardLog(cnt));
                }
            }).start();
            //WriteThread wcb = new WriteThread(sync, ".htm",
            //      Templates.getClipboardLog(content));
        }
    }
}

From source file:com.cyberway.issue.crawler.extractor.ExtractorHTML.java

protected void processGeneralTag(CrawlURI curi, CharSequence element, CharSequence cs) {

    Matcher attr = TextUtils.getMatcher(EACH_ATTRIBUTE_EXTRACTOR, cs);

    // Just in case it's an OBJECT or APPLET tag
    String codebase = null;//from w w w  .  j  a  v  a 2s . co  m
    ArrayList<String> resources = null;

    // Just in case it's a FORM
    CharSequence action = null;
    CharSequence actionContext = null;
    CharSequence method = null;

    final boolean framesAsEmbeds = ((Boolean) getUncheckedAttribute(curi, ATTR_TREAT_FRAMES_AS_EMBED_LINKS))
            .booleanValue();

    final boolean ignoreFormActions = ((Boolean) getUncheckedAttribute(curi, ATTR_IGNORE_FORM_ACTION_URLS))
            .booleanValue();

    final boolean extractValueAttributes = ((Boolean) getUncheckedAttribute(curi, EXTRACT_VALUE_ATTRIBUTES))
            .booleanValue();

    final String elementStr = element.toString();

    while (attr.find()) {
        int valueGroup = (attr.start(14) > -1) ? 14 : (attr.start(15) > -1) ? 15 : 16;
        int start = attr.start(valueGroup);
        int end = attr.end(valueGroup);
        assert start >= 0 : "Start is: " + start + ", " + curi;
        assert end >= 0 : "End is :" + end + ", " + curi;
        CharSequence value = cs.subSequence(start, end);
        value = TextUtils.unescapeHtml(value);
        if (attr.start(2) > -1) {
            // HREF
            CharSequence context = Link.elementContext(element, attr.group(2));
            if (elementStr.equalsIgnoreCase(LINK)) {
                // <LINK> elements treated as embeds (css, ico, etc)
                processEmbed(curi, value, context);
            } else {
                // other HREFs treated as links
                if (value.toString().indexOf("java") != -1)
                    System.out.println(value + "--------javascript--------");
                processLink(curi, value, context);
            }
            if (elementStr.equalsIgnoreCase(BASE)) {
                try {
                    curi.setBaseURI(value.toString());
                } catch (URIException e) {
                    if (getController() != null) {
                        // Controller can be null: e.g. when running
                        // ExtractorTool.
                        getController().logUriError(e, curi.getUURI(), value.toString());
                    } else {
                        logger.info("Failed set base uri: " + curi + ", " + value.toString() + ": "
                                + e.getMessage());
                    }
                }
            }
        } else if (attr.start(3) > -1) {
            // ACTION
            if (!ignoreFormActions) {
                action = value;
                actionContext = Link.elementContext(element, attr.group(3));
                // handling finished only at end (after METHOD also collected)
            }
        } else if (attr.start(4) > -1) {
            // ON____
            processScriptCode(curi, value); // TODO: context?
        } else if (attr.start(5) > -1) {
            // SRC etc.
            CharSequence context = Link.elementContext(element, attr.group(5));

            // true, if we expect another HTML page instead of an image etc.
            final char hopType;

            if (!framesAsEmbeds
                    && (elementStr.equalsIgnoreCase(FRAME) || elementStr.equalsIgnoreCase(IFRAME))) {
                hopType = Link.NAVLINK_HOP;
            } else {
                hopType = Link.EMBED_HOP;
            }
            processEmbed(curi, value, context, hopType);
        } else if (attr.start(6) > -1) {
            // CODEBASE
            codebase = (value instanceof String) ? (String) value : value.toString();
            CharSequence context = Link.elementContext(element, attr.group(6));
            processEmbed(curi, codebase, context);
        } else if (attr.start(7) > -1) {
            // CLASSID, DATA
            if (resources == null) {
                resources = new ArrayList<String>();
            }
            resources.add(value.toString());
        } else if (attr.start(8) > -1) {
            // ARCHIVE
            if (resources == null) {
                resources = new ArrayList<String>();
            }
            String[] multi = TextUtils.split(WHITESPACE, value);
            for (int i = 0; i < multi.length; i++) {
                resources.add(multi[i]);
            }
        } else if (attr.start(9) > -1) {
            // CODE
            if (resources == null) {
                resources = new ArrayList<String>();
            }
            // If element is applet and code value does not end with
            // '.class' then append '.class' to the code value.
            if (elementStr.equalsIgnoreCase(APPLET) && !value.toString().toLowerCase().endsWith(CLASSEXT)) {
                resources.add(value.toString() + CLASSEXT);
            } else {
                resources.add(value.toString());
            }
        } else if (attr.start(10) > -1) {
            // VALUE, with possibility of URI
            if (extractValueAttributes && TextUtils.matches(LIKELY_URI_PATH, value)) {
                CharSequence context = Link.elementContext(element, attr.group(10));
                processLink(curi, value, context);
            }

        } else if (attr.start(11) > -1) {
            // STYLE inline attribute
            // then, parse for URIs
            this.numberOfLinksExtracted += ExtractorCSS.processStyleCode(curi, value, getController());

        } else if (attr.start(12) > -1) {
            // METHOD
            method = value;
            // form processing finished at end (after ACTION also collected)
        } else if (attr.start(13) > -1) {
            // any other attribute
            // ignore for now
            // could probe for path- or script-looking strings, but
            // those should be vanishingly rare in other attributes,
            // and/or symptomatic of page bugs
        }
    }
    TextUtils.recycleMatcher(attr);

    // finish handling codebase/resources now that all available
    if (resources != null) {
        Iterator iter = resources.iterator();
        UURI codebaseURI = null;
        String res = null;
        try {
            if (codebase != null) {
                // TODO: Pass in the charset.
                codebaseURI = UURIFactory.getInstance(curi.getUURI(), codebase);
            }
            while (iter.hasNext()) {
                res = iter.next().toString();
                res = (String) TextUtils.unescapeHtml(res);
                if (codebaseURI != null) {
                    res = codebaseURI.resolve(res).toString();
                }
                processEmbed(curi, res, element); // TODO: include attribute too
            }
        } catch (URIException e) {
            curi.addLocalizedError(getName(), e, "BAD CODEBASE " + codebase);
        } catch (IllegalArgumentException e) {
            DevUtils.logger.log(Level.WARNING, "processGeneralTag()\n" + "codebase=" + codebase + " res=" + res
                    + "\n" + DevUtils.extraInfo(), e);
        }
    }

    // finish handling form action, now method is available
    if (action != null) {
        if (method == null || "GET".equalsIgnoreCase(method.toString())
                || !((Boolean) getUncheckedAttribute(curi, ATTR_EXTRACT_ONLY_FORM_GETS)).booleanValue()) {
            processLink(curi, action, actionContext);
        }
    }
}

From source file:org.apache.noggit.JSONParser.java

public Appendable append(CharSequence csq, int start, int end) throws IOException {
        write(csq.subSequence(start, end).toString());
        return null;
    }// w  w w .  java2  s. co m

From source file:org.minig.imap.EncodedWord.java

/**
 * Takes a text in form of a CharSequence encoded in the given charset (e.g.
 * ISO-8859-1) and makes it US-ASCII compatible and RFC822 compatible for
 * the use as e.g. subject with special characters. <br>
 * This algorithm tries to achieve several goals when decoding: <li>never
 * encode a single character but try to encode whole words</li> <li>if two
 * words must be encoded and there a no more than 3 characters inbetween,
 * encode everything in one single encoded word</li> <li>an encoded word
 * must never be longer than 76 characters in total</li> <li>ensure that no
 * encodedWord is in a line-wrap (RFC822 advices to no have more than 78
 * characters in a headerline)</li>
 * //from w w w  . j  a v a  2  s.  c  om
 * @param input
 *            the headerline
 * @param charset
 *            the used charset (e.g. ISO-8859-1)
 * @param type
 *            the encoding to be used
 * @return input encoded in EncodedWords
 */
public static StringBuilder encode(CharSequence input, Charset charset, int type) {
    StringBuilder result = new StringBuilder(input.length());
    LinkedList<int[]> words = new LinkedList<int[]>();
    String encodedWordPrototype;

    int maxLength;
    if (type == QUOTED_PRINTABLE) {
        encodedWordPrototype = "=?" + charset.displayName() + "?q?";
        maxLength = 75 - encodedWordPrototype.length() - 2;
    } else {
        encodedWordPrototype = "=?" + charset.displayName() + "?b?";
        maxLength = 75 - encodedWordPrototype.length() - 6;
    }

    // First find words which need to be encoded
    Matcher matcher = wordTokenizerPattern.matcher(input);
    float encodedChar = type == QUOTED_PRINTABLE ? 3.0f : 4.0f / 3.0f;
    float normalChar = type == QUOTED_PRINTABLE ? 1.0f : 4.0f / 3.0f;

    while (matcher.find()) {
        String word = matcher.group(1);
        float encodedLength = 0.0f;
        int start = matcher.start();
        int end = matcher.end();
        boolean mustEncode = false;

        for (int i = 0; i < word.length(); i++) {
            if (word.charAt(i) > 127) {
                encodedLength += encodedChar;
                mustEncode = true;
            } else {
                encodedLength += normalChar;
            }

            // Split if too long
            if (Math.ceil(encodedLength) > maxLength) {
                words.add(new int[] { start, start + i, maxLength });
                word = word.substring(i);

                start += i;
                i = 0;
                encodedLength = 0.0f;
                mustEncode = false;
            }
        }
        if (mustEncode)
            words.add(new int[] { start, end, (int) Math.ceil(encodedLength) });
    }

    // No need to create encodedWords
    if (words.isEmpty()) {
        return result.append(input);
    }

    // Second group them together if possible (see goals above)
    int[] last = null;
    for (int i = 0; i < words.size(); i++) {
        int[] act = words.get(i);
        if (last != null && (last[2] + act[2] + (act[0] - last[1]) * normalChar < maxLength)
                && (act[0] - last[1]) < 10) {
            words.remove(i--);
            last[1] = act[1];
            last[2] += act[2] + (act[0] - last[1]) * normalChar;
        } else {
            last = act;
        }
    }

    // Create encodedWords
    Iterator<int[]> it = words.iterator();
    int lastWordEnd = 0;
    while (it.hasNext()) {
        int[] act = it.next();

        // create encoded part
        CharSequence rawWord = input.subSequence(act[0], act[1]);
        CharSequence encodedPart;
        if (type == QUOTED_PRINTABLE) {
            // Replace <space> with _
            Matcher wsMatcher = whitespacePattern.matcher(rawWord);
            rawWord = wsMatcher.replaceAll("_");

            encodedPart = QuotedPrintable.encode(rawWord, charset);
        } else {
            encodedPart = Base64.encodeBase64String(charset.encode(CharBuffer.wrap(rawWord)).array());
        }

        result.append(input.subSequence(lastWordEnd, act[0]));
        result.append(encodedWordPrototype);
        result.append(encodedPart);
        result.append("?=");

        lastWordEnd = act[1];
    }
    result.append(input.subSequence(lastWordEnd, input.length()));

    return result;
}

From source file:com.vuze.android.remote.fragment.TorrentListFragment.java

private void setupSideFilter(View view) {
    listSideFilter = (RecyclerView) view.findViewById(R.id.sidefilter_list);
    if (listSideFilter == null) {
        return;//from w  ww  . ja v  a 2s  .  co m
    }
    if (torrentListAdapter != null) {
        torrentListAdapter.getFilter().setBuildLetters(true);
    }

    tvSideFilterText = (TextView) view.findViewById(R.id.sidefilter_text);

    tvSideFilterText.addTextChangedListener(new TextWatcher() {

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            Filter filter = torrentListAdapter.getFilter();
            filter.filter(s);
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    });

    listSideFilter.setLayoutManager(new PreCachingLayoutManager(getContext()));

    sideFilterAdapter = new SideFilterAdapter(getContext(),
            new FlexibleRecyclerSelectionListener<SideFilterAdapter, SideFilterAdapter.SideFilterInfo>() {
                @Override
                public void onItemCheckedChanged(SideFilterAdapter adapter,
                        SideFilterAdapter.SideFilterInfo item, boolean isChecked) {
                    if (!isChecked) {
                        return;
                    }
                    adapter.setItemChecked(item, false);

                    String s = item.letters;
                    if (s.equals(LETTERS_NUMBERS)) {
                        TorrentFilter filter = torrentListAdapter.getFilter();
                        filter.setCompactDigits(false);
                        filter.refilter();
                        return;
                    }
                    if (s.equals(LETTERS_NON)) {
                        TorrentFilter filter = torrentListAdapter.getFilter();
                        filter.setCompactOther(false);
                        filter.refilter();
                        return;
                    }
                    if (s.equals(LETTERS_PUNCTUATION)) {
                        TorrentFilter filter = torrentListAdapter.getFilter();
                        filter.setCompactPunctuation(false);
                        filter.refilter();
                        return;
                    }
                    if (s.equals(LETTERS_BS)) {
                        CharSequence text = tvSideFilterText.getText();
                        if (text.length() > 0) {
                            text = text.subSequence(0, text.length() - 1);
                            tvSideFilterText.setText(text);
                        } else {
                            TorrentFilter filter = torrentListAdapter.getFilter();
                            filter.setCompactPunctuation(true);
                            filter.setCompactDigits(true);
                            filter.setCompactOther(true);
                            filter.refilter();
                        }
                        return;
                    }
                    s = tvSideFilterText.getText() + s;
                    tvSideFilterText.setText(s);
                }

                @Override
                public boolean onItemLongClick(SideFilterAdapter adapter, int position) {
                    return false;
                }

                @Override
                public void onItemSelected(SideFilterAdapter adapter, int position, boolean isChecked) {

                }

                @Override
                public void onItemClick(SideFilterAdapter adapter, int position) {

                }
            });
    listSideFilter.setAdapter(sideFilterAdapter);

}

From source file:org.zywx.wbpalmstar.plugin.chatkeyboard.ACEChatKeyboardView.java

@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
    try {/* ww w  . j  a  va 2 s  . com*/
        mBtnSend.setVisibility(mEditText.getText().length() != 0 ? View.VISIBLE : View.GONE);
        mBtnAdd.setVisibility(mEditText.getText().length() == 0 ? View.VISIBLE : View.GONE);
        if (before > 0 && count == 0) {
            //delete or replace
            return;
        }
        int size = keywords.size();
        int keywordStart = start;
        String keyword = null;
        for (int i = 0; i < size; i++) {
            String keywordTemp = keywords.get(i);
            int keywordlength = keywordTemp.length();
            int startTemp = start + count - keywordlength;
            if (startTemp < 0 || s.length() < keywordlength) {
                continue;
            }
            String edit = s.subSequence(startTemp, startTemp + keywordlength).toString();
            if (keywordTemp.equals(edit)) {
                keywordStart = startTemp;
                keyword = keywordTemp;
                break;
            }
        }
        if (keyword == null) {
            return;
        }
        mLastAtPosition = keywordStart;
        JSONObject json = new JSONObject();
        json.put(EChatKeyboardUtils.CHATKEYBOARD_PARAMS_JSON_KEY_KEYWORD, keyword);
        String js = EUExChatKeyboard.SCRIPT_HEADER + "if("
                + EChatKeyboardUtils.CHATKEYBOARD_FUN_ON_INPUT_KEYWORD + "){"
                + EChatKeyboardUtils.CHATKEYBOARD_FUN_ON_INPUT_KEYWORD + "(" + json.toString() + ");}";
        mUexBaseObj.onCallback(js);
    } catch (Exception e) {
        e.printStackTrace();
    }
}