Example usage for java.lang CharSequence equals

List of usage examples for java.lang CharSequence equals

Introduction

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

Prototype

public boolean equals(Object obj) 

Source Link

Document

Indicates whether some other object is "equal to" this one.

Usage

From source file:org.chromium.chrome.browser.toolbar.ToolbarPhone.java

private void updateVisualsForToolbarState() {
    final boolean isIncognito = isIncognito();

    // These are important for setting visual state while the entering or leaving the tab
    // switcher.//from  ww w  .  j  a v  a 2s  .  com
    boolean inOrEnteringStaticTab = mTabSwitcherState == STATIC_TAB
            || mTabSwitcherState == EXITING_TAB_SWITCHER;
    boolean inOrEnteringTabSwitcher = !inOrEnteringStaticTab;

    VisualState newVisualState = computeVisualState(inOrEnteringTabSwitcher);

    // If we are navigating to or from a brand color, allow the transition animation
    // to run to completion as it will handle the triggering this path again and committing
    // the proper visual state when it finishes.  Brand color transitions are only valid
    // between normal non-incognito pages and brand color pages, so if the visual states
    // do not match then cancel the animation below.
    if (mBrandColorTransitionActive && isVisualStateValidForBrandColorTransition(mVisualState)
            && isVisualStateValidForBrandColorTransition(newVisualState)) {
        return;
    } else if (mBrandColorTransitionAnimation != null && mBrandColorTransitionAnimation.isRunning()) {
        mBrandColorTransitionAnimation.cancel();
    }

    boolean visualStateChanged = mVisualState != newVisualState;

    int currentPrimaryColor = getToolbarDataProvider().getPrimaryColor();
    int themeColorForProgressBar = currentPrimaryColor;

    // If The page is native force the use of the standard theme for the progress bar.
    if (getToolbarDataProvider() != null && getToolbarDataProvider().getTab() != null
            && getToolbarDataProvider().getTab().isNativePage()) {
        VisualState visualState = isIncognito() ? VisualState.INCOGNITO : VisualState.NORMAL;
        themeColorForProgressBar = getToolbarColorForVisualState(visualState);
    }

    if (mVisualState == VisualState.BRAND_COLOR && !visualStateChanged) {
        boolean useLightToolbarDrawables = ColorUtils.shouldUseLightForegroundOnBackground(currentPrimaryColor);
        boolean unfocusedLocationBarUsesTransparentBg = !ColorUtils
                .shouldUseOpaqueTextboxBackground(currentPrimaryColor);
        if (useLightToolbarDrawables != mUseLightToolbarDrawables
                || unfocusedLocationBarUsesTransparentBg != mUnfocusedLocationBarUsesTransparentBg) {
            visualStateChanged = true;
        } else {
            updateToolbarBackground(VisualState.BRAND_COLOR);
            getProgressBar().setThemeColor(themeColorForProgressBar, isIncognito());
        }
    }

    mVisualState = newVisualState;

    updateOverlayDrawables();
    updateShadowVisibility();
    updateUrlExpansionAnimation();
    if (!visualStateChanged) {
        if (mVisualState == VisualState.NEW_TAB_NORMAL) {
            updateNtpTransitionAnimation();
        } else {
            resetNtpAnimationValues();
        }
        return;
    }

    mUseLightToolbarDrawables = false;
    mUnfocusedLocationBarUsesTransparentBg = false;
    mLocationBarBackgroundAlpha = 255;
    updateToolbarBackground(mVisualState);
    getProgressBar().setThemeColor(themeColorForProgressBar, isIncognito());

    if (inOrEnteringTabSwitcher) {
        mUseLightToolbarDrawables = true;
        mLocationBarBackgroundAlpha = LOCATION_BAR_TRANSPARENT_BACKGROUND_ALPHA;
        getProgressBar().setBackgroundColor(mProgressBackBackgroundColorWhite);
        getProgressBar().setForegroundColor(
                ApiCompatibilityUtils.getColor(getResources(), R.color.progress_bar_foreground_white));
    } else if (isIncognito()) {
        mUseLightToolbarDrawables = true;
        mLocationBarBackgroundAlpha = LOCATION_BAR_TRANSPARENT_BACKGROUND_ALPHA;
    } else if (mVisualState == VisualState.BRAND_COLOR) {
        mUseLightToolbarDrawables = ColorUtils.shouldUseLightForegroundOnBackground(currentPrimaryColor);
        mUnfocusedLocationBarUsesTransparentBg = !ColorUtils
                .shouldUseOpaqueTextboxBackground(currentPrimaryColor);
        mLocationBarBackgroundAlpha = mUnfocusedLocationBarUsesTransparentBg
                ? LOCATION_BAR_TRANSPARENT_BACKGROUND_ALPHA
                : 255;
    }

    if (mToggleTabStackButton != null) {
        mToggleTabStackButton.setImageDrawable(
                mUseLightToolbarDrawables ? mTabSwitcherButtonDrawableLight : mTabSwitcherButtonDrawable);
        if (mTabSwitcherAnimationTabStackDrawable != null) {
            mTabSwitcherAnimationTabStackDrawable
                    .setTint(mUseLightToolbarDrawables ? mLightModeTint : mDarkModeTint);
        }
    }

    mMenuButton.setTint(mUseLightToolbarDrawables ? mLightModeTint : mDarkModeTint);

    if (mShowMenuBadge && inOrEnteringStaticTab) {
        setAppMenuUpdateBadgeDrawable(mUseLightToolbarDrawables);
    }
    ColorStateList tint = mUseLightToolbarDrawables ? mLightModeTint : mDarkModeTint;
    if (mIsHomeButtonEnabled)
        mHomeButton.setTint(tint);

    mLocationBar.updateVisualsForState();
    // Remove the side padding for incognito to ensure the badge icon aligns correctly with the
    // background of the location bar.
    if (isIncognito) {
        mLocationBar.setPadding(0, mLocationBarBackgroundPadding.top, 0, mLocationBarBackgroundPadding.bottom);
    } else {
        mLocationBar.setPadding(mLocationBarBackgroundPadding.left, mLocationBarBackgroundPadding.top,
                mLocationBarBackgroundPadding.right, mLocationBarBackgroundPadding.bottom);
    }

    // We update the alpha before comparing the visual state as we need to change
    // its value when entering and exiting TabSwitcher mode.
    if (isLocationBarShownInNTP() && inOrEnteringStaticTab) {
        updateNtpTransitionAnimation();
    }

    mNewTabButton.setIsIncognito(isIncognito);

    CharSequence newTabContentDescription = getResources()
            .getText(isIncognito ? R.string.accessibility_toolbar_btn_new_incognito_tab
                    : R.string.accessibility_toolbar_btn_new_tab);
    if (mNewTabButton != null && !newTabContentDescription.equals(mNewTabButton.getContentDescription())) {
        mNewTabButton.setContentDescription(newTabContentDescription);
    }

    getMenuButtonWrapper().setVisibility(View.VISIBLE);
}

From source file:cgeo.geocaching.CacheDetailActivity.java

@Override
public void addContextMenu(final View view) {
    view.setOnLongClickListener(new OnLongClickListener() {

        @Override// w  ww .  j a  v  a 2  s .co m
        public boolean onLongClick(final View v) {
            if (view.getId() == R.id.description || view.getId() == R.id.hint) {
                selectedTextView = (IndexOutOfBoundsAvoidingTextView) view;
                mSelectionModeActive = true;
                return false;
            }
            currentActionMode = startSupportActionMode(new ActionMode.Callback() {

                @Override
                public boolean onPrepareActionMode(final ActionMode actionMode, final Menu menu) {
                    return prepareClipboardActionMode(view, actionMode, menu);
                }

                private boolean prepareClipboardActionMode(final View view, final ActionMode actionMode,
                        final Menu menu) {
                    switch (view.getId()) {
                    case R.id.value: // coordinates, gc-code, name
                        clickedItemText = ((TextView) view).getText();
                        final CharSequence itemTitle = ((TextView) ((View) view.getParent())
                                .findViewById(R.id.name)).getText();
                        if (itemTitle.equals(res.getText(R.string.cache_coordinates))) {
                            clickedItemText = GeopointFormatter.reformatForClipboard(clickedItemText);
                        }
                        buildDetailsContextMenu(actionMode, menu, itemTitle, true);
                        return true;
                    case R.id.description:
                        // combine short and long description
                        final String shortDesc = cache.getShortDescription();
                        if (StringUtils.isBlank(shortDesc)) {
                            clickedItemText = cache.getDescription();
                        } else {
                            clickedItemText = shortDesc + "\n\n" + cache.getDescription();
                        }
                        buildDetailsContextMenu(actionMode, menu, res.getString(R.string.cache_description),
                                false);
                        return true;
                    case R.id.personalnote:
                        clickedItemText = cache.getPersonalNote();
                        buildDetailsContextMenu(actionMode, menu, res.getString(R.string.cache_personal_note),
                                true);
                        return true;
                    case R.id.hint:
                        clickedItemText = cache.getHint();
                        buildDetailsContextMenu(actionMode, menu, res.getString(R.string.cache_hint), false);
                        return true;
                    case R.id.log:
                        clickedItemText = ((TextView) view).getText();
                        buildDetailsContextMenu(actionMode, menu, res.getString(R.string.cache_logs), false);
                        return true;
                    case R.id.date: // event date
                        clickedItemText = Formatter.formatHiddenDate(cache);
                        buildDetailsContextMenu(actionMode, menu, res.getString(R.string.cache_event), true);
                        menu.findItem(R.id.menu_calendar).setVisible(cache.canBeAddedToCalendar());
                        return true;
                    }
                    return false;
                }

                @Override
                public void onDestroyActionMode(final ActionMode actionMode) {
                    currentActionMode = null;
                }

                @Override
                public boolean onCreateActionMode(final ActionMode actionMode, final Menu menu) {
                    actionMode.getMenuInflater().inflate(R.menu.details_context, menu);
                    prepareClipboardActionMode(view, actionMode, menu);
                    // Return true so that the action mode is shown
                    return true;
                }

                @Override
                public boolean onActionItemClicked(final ActionMode actionMode, final MenuItem menuItem) {
                    switch (menuItem.getItemId()) {
                    // detail fields
                    case R.id.menu_calendar:
                        CalendarAdder.addToCalendar(CacheDetailActivity.this, cache);
                        actionMode.finish();
                        return true;
                    // handle clipboard actions in base
                    default:
                        return onClipboardItemSelected(actionMode, menuItem, clickedItemText, cache);
                    }
                }
            });
            return true;
        }
    });
}

From source file:com.android.music.TrackBrowserFragment.java

private void setTitle() {

    CharSequence fancyName = null;
    if (mAlbumId != null) {
        int numresults = mTrackCursor != null ? mTrackCursor.getCount() : 0;
        if (numresults > 0) {
            mTrackCursor.moveToFirst();//ww  w.j a v a 2s  .c  o m
            int idx = mTrackCursor.getColumnIndexOrThrow(MediaStore.Audio.Media.ALBUM);
            fancyName = mTrackCursor.getString(idx);
            // For compilation albums show only the album title,
            // but for regular albums show "artist - album".
            // To determine whether something is a compilation
            // album, do a query for the artist + album of the
            // first item, and see if it returns the same number
            // of results as the album query.
            String where = MediaStore.Audio.Media.ALBUM_ID + "='" + mAlbumId + "' AND "
                    + MediaStore.Audio.Media.ARTIST_ID + "=" + mTrackCursor
                            .getLong(mTrackCursor.getColumnIndexOrThrow(MediaStore.Audio.Media.ARTIST_ID));
            Cursor cursor = MusicUtils.query(getActivity(), MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
                    new String[] { MediaStore.Audio.Media.ALBUM }, where, null, null);
            if (cursor != null) {
                if (cursor.getCount() != numresults) {
                    // compilation album
                    fancyName = mTrackCursor.getString(idx);
                }
                cursor.deactivate();
            }
            if (fancyName == null || fancyName.equals(MediaStore.UNKNOWN_STRING)) {
                fancyName = getString(R.string.unknown_album_name);
            }
        }
    } else if (mPlaylist != null) {
        if (mPlaylist.equals("nowplaying")) {
            if (MusicUtils.getCurrentShuffleMode() == MediaPlaybackService.SHUFFLE_AUTO) {
                fancyName = getText(R.string.partyshuffle_title);
            } else {
                fancyName = getText(R.string.nowplaying_title);
            }
        } else if (mPlaylist.equals("podcasts")) {
            fancyName = getText(R.string.podcasts_title);
        } else if (mPlaylist.equals("recentlyadded")) {
            fancyName = getText(R.string.recentlyadded_title);
        } else {
            String[] cols = new String[] { MediaStore.Audio.Playlists.NAME };
            Cursor cursor = MusicUtils.query(getActivity(),
                    ContentUris.withAppendedId(Playlists.EXTERNAL_CONTENT_URI, Long.valueOf(mPlaylist)), cols,
                    null, null, null);
            if (cursor != null) {
                if (cursor.getCount() != 0) {
                    cursor.moveToFirst();
                    fancyName = cursor.getString(0);
                }
                cursor.deactivate();
            }
        }
    } else if (mGenre != null) {
        String[] cols = new String[] { MediaStore.Audio.Genres.NAME };
        Cursor cursor = MusicUtils.query(getActivity(),
                ContentUris.withAppendedId(MediaStore.Audio.Genres.EXTERNAL_CONTENT_URI, Long.valueOf(mGenre)),
                cols, null, null, null);
        if (cursor != null) {
            if (cursor.getCount() != 0) {
                cursor.moveToFirst();
                fancyName = cursor.getString(0);
            }
            cursor.deactivate();
        }
    }

    if (fancyName != null) {
        getActivity().setTitle(fancyName);
    } else {
        getActivity().setTitle(R.string.tracks_title);
    }
}

From source file:eu.webtoolkit.jwt.WApplication.java

/**
 * Sets the message for the user to confirm closing of the application
 * window/tab.//from  w  ww . j  a v a 2  s.c o m
 * <p>
 * If the message is empty, then the user may navigate away from the page
 * without confirmation.
 * <p>
 * Otherwise the user will be prompted with a browser-specific dialog asking
 * him to confirm leaving the page. This <code>message</code> is added to
 * the page.
 * <p>
 * 
 * @see WApplication#unload()
 */
public void setConfirmCloseMessage(final CharSequence message) {
    if (!message.equals(this.closeMessage_)) {
        this.closeMessage_ = WString.toWString(message);
        this.closeMessageChanged_ = true;
    }
}

From source file:com.anysoftkeyboard.AnySoftKeyboard.java

private boolean pickDefaultSuggestion(boolean autoCorrectToPreferred) {
    // Complete any pending candidate query first
    if (mKeyboardHandler.hasMessages(KeyboardUIStateHandler.MSG_UPDATE_SUGGESTIONS)) {
        performUpdateSuggestions();/*from  w  w w.  j a va2  s .c  o m*/
    }

    final CharSequence typedWord = mWord.getTypedWord();
    final CharSequence actualWordToOutput = autoCorrectToPreferred ? mWord.getPreferredWord() : typedWord;
    Logger.d(TAG, "pickDefaultSuggestion: actualWordToOutput: %s, since mAutoCorrectOn is %s",
            actualWordToOutput, mAutoCorrectOn);

    if (!TextUtils.isEmpty(actualWordToOutput)) {
        TextEntryState.acceptedDefault(typedWord);
        final boolean fixed = !typedWord.equals(actualWordToOutput);
        commitWordToInput(actualWordToOutput, fixed);
        if (!fixed) {//if the word typed was auto-replaced, we should not learn it.
            // Add the word to the auto dictionary if it's not a known word
            // this is "typed" if the auto-correction is off, or "picked" if it is on or momentarily off.
            checkAddToDictionaryWithAutoDictionary(mWord,
                    mAutoComplete ? AutoDictionary.AdditionType.Picked : AutoDictionary.AdditionType.Typed);
        }
        return true;
    }
    return false;
}

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   www  . jav  a2  s . com*/
    }
    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:nuclei.ui.view.media.PlayerControlsView.java

void onTimerSelected(View v) {
    final CharSequence off = ResourceProvider.getInstance().getString(ResourceProvider.OFF);
    final PopupMenu menu = new PopupMenu(v.getContext(), v,
            ResourceProvider.getInstance().getString(ResourceProvider.TIMER));
    menu.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override//from ww w. ja  v  a  2 s .c  o  m
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (position == 0)
                return;
            long timer = -1;
            switch (position) {
            case POS_OFF:
                ((TextView) findViewById(R.id.btn_timer)).setText(off);
                break;
            case POS_FIVE_MIN:
                timer = PlaybackManager.FIVE_MINUTES;
                break;
            case POS_TEN_MIN:
                timer = PlaybackManager.TEN_MINUTES;
                break;
            case POS_FIFTEEN_MIN:
                timer = PlaybackManager.FIFTEEN_MINUTES;
                break;
            case POS_THIRTY_MIN:
                timer = PlaybackManager.THIRY_MINUTES;
                break;
            case POS_ONE_HOUR:
                timer = PlaybackManager.ONE_HOUR;
                break;
            case POS_TWO_HOUR:
                timer = PlaybackManager.TWO_HOUR;
                break;
            default:
                break;
            }
            if (mMediaInterface != null) {
                mMediaInterface.setTimer(timer);
            }
            menu.dismiss();
            menu.setOnItemClickListener(null);
        }
    });
    menu.setAdapter(new ArrayAdapter<CharSequence>(v.getContext(), R.layout.cyto_view_dropdown_item_checkable,
            android.R.id.text1,
            Arrays.asList(off, ResourceProvider.getInstance().getQuantityString(ResourceProvider.MINUTES, FIVE),
                    ResourceProvider.getInstance().getQuantityString(ResourceProvider.MINUTES, TEN),
                    ResourceProvider.getInstance().getQuantityString(ResourceProvider.MINUTES, FIFTEEN),
                    ResourceProvider.getInstance().getQuantityString(ResourceProvider.MINUTES, THIRTY),
                    ResourceProvider.getInstance().getQuantityString(ResourceProvider.HOURS, ONE),
                    ResourceProvider.getInstance().getQuantityString(ResourceProvider.HOURS, TWO))) {
        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            View view = super.getView(position, convertView, parent);
            TextView v = (TextView) view.findViewById(android.R.id.text1);
            CharSequence text = getItem(position);
            if (mTimer == -1 && off.equals(text)) {
                v.setTextColor(ViewUtil.getThemeAttrColor(v.getContext(), R.attr.colorAccent));
                view.findViewById(R.id.checked).setVisibility(View.VISIBLE);
            } else {
                v.setTextColor(ViewUtil.getThemeAttrColor(v.getContext(), android.R.attr.textColorPrimary));
                view.findViewById(R.id.checked).setVisibility(View.GONE);
            }
            return view;
        }
    });
    menu.show();
}

From source file:org.uguess.android.sysinfo.SiragonManager.java

String generateHtmlReport(boolean[] items) {
    StringBuffer sb = new StringBuffer();

    createHtmlHeader(getActivity(), sb, escapeHtml("Android System Report - " + new Date().toLocaleString())); //$NON-NLS-1$

    if (items[BASIC_INFO]) {
        sb.append(openHeaderRow).append(getString(R.string.tab_infoCPU)).append(closeHeaderRow);

        sb.append(openRow).append(getString(R.string.sd_storage)).append(nextColumn4);

        String[] info = getExternalStorageInfo();
        if (info == null) {
            sb.append(getString(R.string.info_not_available));
        } else {// w  w w.  j  a v  a  2s . co m
            sb.append(getString(R.string.storage_summary, info[0], info[1]));
        }
        sb.append(closeRow);

        ///////////////////////////UCLIDES//////////////////////////
        sb.append(openHeaderRow).append(getString(R.string.tab_info)).append(closeHeaderRow);

        sb.append(openRow).append(getString(R.string.sd_storage)).append(nextColumn4);

        info = getExternalStorageInfo();
        if (info == null) {
            sb.append(getString(R.string.info_not_available));
        } else {
            sb.append(getString(R.string.storage_summary, info[0], info[1]));
        }
        sb.append(closeRow);
        ///////////////////////////////////////////////////////////

        sb.append(openRow).append(getString(R.string.a2sd_storage)).append(nextColumn4);

        info = getA2SDStorageInfo();
        if (info == null) {
            sb.append(getString(R.string.info_not_available));
        } else {
            sb.append(getString(R.string.storage_summary, info[0], info[1]));
        }
        sb.append(closeRow);

        sb.append(openRow).append(getString(R.string.internal_storage)).append(nextColumn4);

        info = getInternalStorageInfo();
        if (info == null) {
            sb.append(getString(R.string.info_not_available));
        } else {
            sb.append(getString(R.string.storage_summary, info[0], info[1]));
        }
        sb.append(closeRow);

        sb.append(openRow).append(getString(R.string.system_storage)).append(nextColumn4);

        info = getSystemStorageInfo();
        if (info == null) {
            sb.append(getString(R.string.info_not_available));
        } else {
            sb.append(getString(R.string.storage_summary, info[0], info[1]));
        }
        sb.append(closeRow);

        sb.append(openRow).append(getString(R.string.cache_storage)).append(nextColumn4);

        info = getCacheStorageInfo();
        if (info == null) {
            sb.append(getString(R.string.info_not_available));
        } else {
            sb.append(getString(R.string.storage_summary, info[0], info[1]));
        }
        sb.append(closeRow);

        sb.append(openRow).append(getString(R.string.memory)).append(nextColumn4);

        info = getMemInfo();
        if (info == null) {
            sb.append(getString(R.string.info_not_available));
        } else {
            sb.append(getString(R.string.storage_summary, info[0], info[2])
                    + getString(R.string.idle_info, info[1]));
        }
        sb.append(closeRow);

        sb.append(openRow).append(getString(R.string.processor)).append(nextColumn4)
                .append(escapeHtml(getCpuInfo())).append(closeRow);

        String nInfo = getNetAddressInfo();
        sb.append(openRow).append(getString(R.string.net_address)).append(nextColumn4)
                .append(nInfo == null ? getString(R.string.info_not_available) : nInfo).append(closeRow);

        sb.append(emptyRow);

        try {
            File f = new File(F_SCALE_FREQ);
            if (f.exists()) {
                sb.append(openFullRow).append(getString(R.string.sc_freq));

                readRawText(sb, new FileInputStream(f));

                sb.append(closeRow);
            } else {
                sb.append(openFullRow).append(getString(R.string.no_sc_freq_info)).append(closeRow);
            }

            sb.append(emptyRow);

            f = new File(F_CPU_INFO);
            if (f.exists()) {
                readRawHTML(sb, new FileInputStream(f));
            } else {
                sb.append(openFullRow).append(getString(R.string.no_cpu_info)).append(closeRow);
            }

            sb.append(emptyRow);

            f = new File(F_MEM_INFO);
            if (f.exists()) {
                readRawHTML(sb, new FileInputStream(f));
            } else {
                sb.append(openFullRow).append(getString(R.string.no_mem_info)).append(closeRow);
            }

            sb.append(emptyRow);

            f = new File(F_MOUNT_INFO);
            if (f.exists()) {
                readRawHTML(sb, new FileInputStream(f));
            } else {
                sb.append(openFullRow).append(getString(R.string.no_mount_info)).append(closeRow);
            }

            sb.append(emptyRow);
        } catch (Exception e) {
            Log.e(SiragonManager.class.getName(), e.getLocalizedMessage(), e);
        }
    }

    if (items[APPLICATIONS]) {
        sb.append(openHeaderRow).append(getString(R.string.tab_apps)).append(closeHeaderRow);

        sb.append(openTitleRow).append("<b>") //$NON-NLS-1$
                .append(getString(R.string.pkg_name)).append("</b>") //$NON-NLS-1$
                .append(nextColumn).append("<b>") //$NON-NLS-1$
                .append(getString(R.string.version)).append("</b>") //$NON-NLS-1$
                .append(nextColumn).append("<b>") //$NON-NLS-1$
                .append(getString(R.string.app_label)).append("</b>") //$NON-NLS-1$
                .append(nextColumn).append("<b>") //$NON-NLS-1$
                .append(getString(R.string.flags)).append("</b>") //$NON-NLS-1$
                .append(nextColumn).append("<b>") //$NON-NLS-1$
                .append(getString(R.string.source)).append("</b>") //$NON-NLS-1$
                .append(closeRow);

        PackageManager pm = getActivity().getPackageManager();
        List<PackageInfo> pkgs = pm.getInstalledPackages(0);

        if (pkgs != null) {
            for (int i = 0, size = pkgs.size(); i < size; i++) {
                PackageInfo pkg = pkgs.get(i);

                sb.append(openRow).append(escapeHtml(pkg.packageName)).append(nextColumn)
                        .append(escapeHtml(pkg.versionName)).append(" (") //$NON-NLS-1$
                        .append(pkg.versionCode).append(')');

                if (pkg.applicationInfo != null) {
                    sb.append(nextColumn).append(escapeHtml(pkg.applicationInfo.loadLabel(pm).toString()))
                            .append(nextColumn).append(pkg.applicationInfo.flags).append(nextColumn)
                            .append(escapeHtml(pkg.applicationInfo.sourceDir));
                }

                sb.append(closeRow);
            }
        }

        sb.append(emptyRow);
    }

    if (items[PROCESSES]) {
        sb.append(openHeaderRow).append(getString(R.string.tab_procs)).append(closeHeaderRow);

        sb.append(openTitleRow).append("<b>") //$NON-NLS-1$
                .append(getString(R.string.importance)).append("</b>") //$NON-NLS-1$
                .append(nextColumn).append("<b>") //$NON-NLS-1$
                .append(getString(R.string.pid)).append("</b>") //$NON-NLS-1$
                .append(nextColumn).append("<b>") //$NON-NLS-1$
                .append(getString(R.string.proc_name)).append("</b>") //$NON-NLS-1$
                .append(nextColumn).append("<b>") //$NON-NLS-1$
                .append(getString(R.string.app_label)).append("</b>") //$NON-NLS-1$
                .append(closeRow);

        ActivityManager am = (ActivityManager) getActivity().getSystemService(Context.ACTIVITY_SERVICE);
        List<RunningAppProcessInfo> procs = am.getRunningAppProcesses();

        if (procs != null) {
            PackageManager pm = getActivity().getPackageManager();

            for (int i = 0, size = procs.size(); i < size; i++) {
                RunningAppProcessInfo proc = procs.get(i);

                sb.append(openRow).append(getImportance(proc)).append(nextColumn).append(proc.pid)
                        .append(nextColumn).append(escapeHtml(proc.processName));

                try {
                    ApplicationInfo ai = pm.getApplicationInfo(proc.processName, 0);

                    if (ai != null) {
                        CharSequence label = pm.getApplicationLabel(ai);

                        if (label != null && !label.equals(proc.processName)) {
                            sb.append(nextColumn).append(escapeHtml(label.toString()));
                        }
                    }
                } catch (NameNotFoundException e) {
                    // ignore this error
                }

                sb.append(closeRow);
            }
        }

        sb.append(emptyRow);
    }

    if (items[NETSTATES]) {
        sb.append(openHeaderRow).append(getString(R.string.tab_netstat)).append(closeHeaderRow);

        try {
            readRawHTML(sb, new FileInputStream("/proc/net/tcp")); //$NON-NLS-1$

            sb.append(emptyRow);

            readRawHTML(sb, new FileInputStream("/proc/net/udp")); //$NON-NLS-1$
        } catch (Exception e) {
            Log.e(SiragonManager.class.getName(), e.getLocalizedMessage(), e);
        }

        sb.append(emptyRow);
    }

    if (items[DMESG_LOG]) {
        sb.append(openHeaderRow).append("Dmesg " //$NON-NLS-1$
                + getString(R.string.log)).append(closeHeaderRow);

        try {
            Process proc = Runtime.getRuntime().exec("dmesg"); //$NON-NLS-1$

            readRawHTML(sb, proc.getInputStream());
        } catch (Exception e) {
            Log.e(SiragonManager.class.getName(), e.getLocalizedMessage(), e);
        }

        sb.append(emptyRow);
    }

    if (items[LOGCAT_LOG]) {
        sb.append(openHeaderRow).append("Logcat " //$NON-NLS-1$
                + getString(R.string.log)).append(closeHeaderRow);

        try {
            Process proc = Runtime.getRuntime().exec("logcat -d -v time *:V"); //$NON-NLS-1$

            readRawHTML(sb, proc.getInputStream());
        } catch (Exception e) {
            Log.e(SiragonManager.class.getName(), e.getLocalizedMessage(), e);
        }

        sb.append(emptyRow);
    }

    sb.append("</table></font></body></html>"); //$NON-NLS-1$

    return sb.toString();
}

From source file:org.uguess.android.sysinfo.SiragonManager.java

String generateTextReport(boolean[] items) {
    StringBuffer sb = new StringBuffer();

    createTextHeader(getActivity(), sb, "Android Sragon Report - I&D " //$NON-NLS-1$
            + new Date().toLocaleString());

    if (items[BASIC_INFO]) {
        sb.append("####################\n");
        sb.append(getString(R.string.tab_info)).append('\n');
        sb.append(HEADER_SPLIT);/*from   ww  w.j a va2  s  .  co m*/

        sb.append("* ") //$NON-NLS-1$
                .append(getString(R.string.sd_storage)).append(":\n"); //$NON-NLS-1$

        String[] info = getExternalStorageInfo();
        if (info == null) {
            sb.append(getString(R.string.info_not_available));
        } else {
            sb.append(getString(R.string.storage_external, info[0], info[1]) + "\n");
        }
        sb.append("####################\n"); //$NON-NLS-1$

        sb.append("* ") //$NON-NLS-1$
                .append(getString(R.string.a2sd_storage) + ":").append("\n"); //$NON-NLS-2$
        info = getA2SDStorageInfo();
        if (info == null) {
            sb.append(getString(R.string.info_not_available));
            sb.append("\n");
        } else {
            sb.append(getString(R.string.storage_summary, info[0], info[1]));
            sb.append("\n");

        }
        sb.append("####################\n"); //$NON-NLS-1$

        sb.append("* ") //$NON-NLS-1$
                .append(getString(R.string.display) + ":").append("\n"); //$NON-NLS-2$

        String[] info2 = getInfoDisplay();

        if (info2 == null) {
            sb.append(getString(R.string.info_not_available));

        } else {
            for (int i = 0; i < info2.length; i++) {
                sb.append(getString(R.string.info_display, info2[i])).append("\n");
            }
        }
        sb.append("####################\n"); //$NON-NLS-1$
        sb.append("* ") //$NON-NLS-1$
                .append(getString(R.string.camera_back_img_support)).append("\n"); //$NON-NLS-1$

        info2 = getSupportedPreviewSizes(0);

        if (info2 == null) {
            sb.append(getString(R.string.info_not_available));

        } else {
            for (int i = 0; i < info2.length; i++) {
                sb.append(getString(R.string.support_image_back, info2[i])).append("\n");
            }
        }
        sb.append("####################\n"); //$NON-NLS-1$
        sb.append("* ") //$NON-NLS-1$
                .append(getString(R.string.camera_back_vid_support)).append("\n"); //$NON-NLS-1$

        info2 = getSupportedPreviewSizesVideo(0);

        if (info2 == null) {
            sb.append(getString(R.string.info_not_available));

        } else {
            for (int i = 0; i < info2.length; i++) {
                sb.append(getString(R.string.support_video_back, info2[i])).append("\n");
            }
        }
        sb.append("####################\n"); //$NON-NLS-1$
        //////////////////////////////////////////////////////////////////////////////////
        sb.append("* ") //$NON-NLS-1$
                .append(getString(R.string.camera_other_feature) + ":").append("\n"); //$NON-NLS-2$

        info2 = getSupportedOtherCamera(0);

        if (info2 == null) {
            sb.append(getString(R.string.info_not_available));

        } else {
            for (int i = 0; i < info2.length; i++) {
                sb.append(getString(R.string.camera_des_feature, info2[i])).append("\n");
            }
        }
        sb.append("####################\n"); //$NON-NLS-1$
        sb.append("* ") //$NON-NLS-1$
                .append(getString(R.string.camera_front_img_support)).append("\n"); //$NON-NLS-1$

        info2 = getSupportedPreviewSizes(1);

        if (info2 == null) {
            sb.append(getString(R.string.info_not_available));

        } else {
            for (int i = 0; i < info2.length; i++) {
                sb.append(getString(R.string.support_image_front, info2[i])).append("\n");
            }
        }
        sb.append("####################\n"); //$NON-NLS-1$
        sb.append("* ") //$NON-NLS-1$
                .append(getString(R.string.camera_front_vid_support)).append("\n"); //$NON-NLS-1$

        info2 = getSupportedPreviewSizesVideo(1);

        if (info2 == null) {
            sb.append(getString(R.string.info_not_available));

        } else {
            for (int i = 0; i < info2.length; i++) {
                sb.append(getString(R.string.support_video_front, info2[i])).append("\n");
            }
        }
        sb.append("####################\n"); //$NON-NLS-1$
        sb.append("* ") //$NON-NLS-1$
                .append(getString(R.string.camera_feature)).append("\n"); //$NON-NLS-1$}

        info2 = getAvailableFeatureCamera();
        if (info2 == null) {
            sb.append(getString(R.string.info_not_available));
        } else {
            for (int i = 0; i < info2.length; i++) {
                sb.append(getString(R.string.camera_all_feature, info2[i])).append("\n");
            }
        }
        sb.append("####################\n"); //$NON-NLS-1$*/
        sb.append("* ") //$NON-NLS-1$
                .append(getString(R.string.camera_back_available)).append(":").append("\n"); //$NON-NLS-2$

        int cams = getNumberCamera();
        if (cams == 0) {
            sb.append(getString(R.string.info_not_available));
        } else {
            sb.append(getString(R.string.number_cams, cams) + "\n");
        }
        sb.append("####################\n"); //$NON-NLS-1$

        sb.append("* ") //$NON-NLS-1$
                .append(getString(R.string.camera_flash_available) + ":").append("\n"); //$NON-NLS-2$}

        boolean flash = getAvailableFlash();
        if (flash == false) {
            sb.append(getString(R.string.info_not_available) + "\n");
        } else {
            sb.append(getString(R.string.flash_available, flash) + "\n");
        }

        sb.append("####################\n"); //$NON-NLS-1$
        //////////////////////////////////////////////////////////////////////////////////////7

        sb.append("* ") //$NON-NLS-1$
                .append(getString(R.string.internal_storage) + ":").append("\n"); //$NON-NLS-2$

        info = getInternalStorageInfo();
        if (info == null) {
            sb.append(getString(R.string.info_not_available) + "\n");
        } else {
            sb.append(getString(R.string.storage_summary, info[0], info[1]) + "\n");
        }
        sb.append("####################\n"); //$NON-NLS-1$

        sb.append("* ") //$NON-NLS-1$
                .append(getString(R.string.system_storage)).append(":\n"); //$NON-NLS-1$

        info = getSystemStorageInfo();
        if (info == null) {
            sb.append(getString(R.string.info_not_available) + "\n");
        } else {
            sb.append(getString(R.string.storage_summary, info[0], info[1]) + "\n");
        }
        sb.append("####################\n"); //$NON-NLS-1$

        sb.append("* ") //$NON-NLS-1$
                .append(getString(R.string.cache_storage)).append(":\n"); //$NON-NLS-1$

        info = getCacheStorageInfo();
        if (info == null) {
            sb.append(getString(R.string.info_not_available) + "\n");
        } else {
            sb.append(getString(R.string.storage_summary, info[0], info[1]) + "\n");
        }
        sb.append("####################\n"); //$NON-NLS-1$

        sb.append("* ") //$NON-NLS-1$
                .append(getString(R.string.memory)).append(":\n"); //$NON-NLS-1$

        info = getMemInfo();
        if (info == null) {
            sb.append(getString(R.string.info_not_available) + "\n");
        } else {
            sb.append(getString(R.string.storage_summary, info[0], info[2])
                    + getString(R.string.idle_info, info[1]) + "\n");
        }
        sb.append("####################\n"); //$NON-NLS-1$

        sb.append("* ") //$NON-NLS-1$
                .append(getString(R.string.processor) + ":").append("\n") //$NON-NLS-2$
                .append(getCpuInfo() + "\n").append("####################\n"); //$NON-NLS-2$

        String nInfo = getNetAddressInfo();
        sb.append("* ") //$NON-NLS-1$
                .append(getString(R.string.net_address) + ":").append("\n") //$NON-NLS-2$
                .append(nInfo == null ? getString(R.string.info_not_available) + "\n" : nInfo + "\n")
                .append("####################\n"); //$NON-NLS-1$

        //sb.append( '\n' );

        try {
            File f = new File(F_SCALE_FREQ);
            if (f.exists()) {
                sb.append(getString(R.string.sc_freq));

                readRawText(sb, new FileInputStream(f));
            } else {
                sb.append(getString(R.string.no_sc_freq_info)).append('\n');
            }

            sb.append("####################\n");

            f = new File(F_CPU_INFO);
            if (f.exists()) {
                readRawText(sb, new FileInputStream(f));
            } else {
                sb.append(getString(R.string.no_cpu_info)).append('\n');
            }

            sb.append("####################\n");

            f = new File(F_MEM_INFO);
            if (f.exists()) {
                readRawText(sb, new FileInputStream(f));
            } else {
                sb.append(getString(R.string.no_mem_info)).append('\n');
            }

            sb.append("####################\n");

            f = new File(F_MOUNT_INFO);
            if (f.exists()) {
                readRawText(sb, new FileInputStream(f));
            } else {
                sb.append(getString(R.string.no_mount_info)).append('\n');
            }

            sb.append("####################\n");
        } catch (Exception e) {
            Log.e(SiragonManager.class.getName(), e.getLocalizedMessage(), e);
        }
    }

    if (items[APPLICATIONS]) {
        sb.append(HEADER_SPLIT);
        sb.append(getString(R.string.tab_apps) + ":").append('\n');
        PackageManager pm = getActivity().getPackageManager();
        List<PackageInfo> pkgs = pm.getInstalledPackages(0);

        if (pkgs != null) {
            for (int i = 0, size = pkgs.size(); i < size; i++) {
                PackageInfo pkg = pkgs.get(i);

                sb.append(pkg.packageName).append(" <") //$NON-NLS-1$
                        .append(pkg.versionName).append(" (") //$NON-NLS-1$
                        .append(pkg.versionCode).append(")>"); //$NON-NLS-1$

                if (pkg.applicationInfo != null) {
                    sb.append("\t: ") //$NON-NLS-1$
                            .append(pkg.applicationInfo.loadLabel(pm)).append(" | ") //$NON-NLS-1$
                            .append(pkg.applicationInfo.flags).append(" | ") //$NON-NLS-1$
                            .append(pkg.applicationInfo.sourceDir);
                }

                sb.append('\n');
            }
        }

        sb.append("####################\n");
    }

    if (items[PROCESSES]) {
        sb.append(HEADER_SPLIT);
        sb.append(getString(R.string.tab_procs) + ":").append('\n');

        ActivityManager am = (ActivityManager) getActivity().getSystemService(Context.ACTIVITY_SERVICE);
        List<RunningAppProcessInfo> procs = am.getRunningAppProcesses();

        if (procs != null) {
            PackageManager pm = getActivity().getPackageManager();

            for (int i = 0, size = procs.size(); i < size; i++) {
                RunningAppProcessInfo proc = procs.get(i);

                sb.append('<').append(getImportance(proc)).append("> [") //$NON-NLS-1$
                        .append(proc.pid).append("]\t:\t"); //$NON-NLS-1$

                sb.append(proc.processName);

                try {
                    ApplicationInfo ai = pm.getApplicationInfo(proc.processName, 0);

                    if (ai != null) {
                        CharSequence label = pm.getApplicationLabel(ai);

                        if (label != null && !label.equals(proc.processName)) {
                            sb.append(" ( ") //$NON-NLS-1$
                                    .append(label).append(" )"); //$NON-NLS-1$
                        }
                    }
                } catch (NameNotFoundException e) {
                    // ignore this error
                }

                sb.append('\n');
            }
        }

        sb.append("####################\n");
    }

    if (items[NETSTATES]) {
        sb.append(HEADER_SPLIT);
        sb.append(getString(R.string.tab_netstat) + ":").append('\n');

        try {
            readRawText(sb, new FileInputStream("/proc/net/tcp")); //$NON-NLS-1$

            sb.append('\n');

            readRawText(sb, new FileInputStream("/proc/net/udp")); //$NON-NLS-1$
        } catch (Exception e) {
            Log.e(SiragonManager.class.getName(), e.getLocalizedMessage(), e);
        }

        sb.append("####################\n");
    }

    if (items[DMESG_LOG]) {
        sb.append(HEADER_SPLIT);
        sb.append("Dmesg " + getString(R.string.log) + ":").append('\n'); //$NON-NLS-1$

        try {
            Process proc = Runtime.getRuntime().exec("dmesg"); //$NON-NLS-1$

            readRawText(sb, proc.getInputStream());
        } catch (Exception e) {
            Log.e(SiragonManager.class.getName(), e.getLocalizedMessage(), e);
        }

        sb.append("####################\n");
    }

    if (items[LOGCAT_LOG]) {
        sb.append(HEADER_SPLIT);
        sb.append("Logcat " + getString(R.string.log) + ":").append('\n'); //$NON-NLS-1$

        try {
            Process proc = Runtime.getRuntime().exec("logcat -d -v time *:V"); //$NON-NLS-1$

            readRawText(sb, proc.getInputStream());
        } catch (Exception e) {
            Log.e(SiragonManager.class.getName(), e.getLocalizedMessage(), e);
        }

        sb.append("####################\n");
    }

    return sb.toString();
}

From source file:org.apache.hadoop.hive.cli.CliDriver.java

public static Completer[] getCommandCompleter() {
    // StringsCompleter matches against a pre-defined wordlist
    // We start with an empty wordlist and build it up
    List<String> candidateStrings = new ArrayList<String>();

    // We add Hive function names
    // For functions that aren't infix operators, we add an open
    // parenthesis at the end.
    for (String s : FunctionRegistry.getFunctionNames()) {
        if (s.matches("[a-z_]+")) {
            candidateStrings.add(s + "(");
        } else {/* w w w.  jav  a  2  s  .co  m*/
            candidateStrings.add(s);
        }
    }

    // We add Hive keywords, including lower-cased versions
    for (String s : HiveParser.getKeywords()) {
        candidateStrings.add(s);
        candidateStrings.add(s.toLowerCase());
    }

    StringsCompleter strCompleter = new StringsCompleter(candidateStrings);

    // Because we use parentheses in addition to whitespace
    // as a keyword delimiter, we need to define a new ArgumentDelimiter
    // that recognizes parenthesis as a delimiter.
    ArgumentDelimiter delim = new AbstractArgumentDelimiter() {
        @Override
        public boolean isDelimiterChar(CharSequence buffer, int pos) {
            char c = buffer.charAt(pos);
            return (Character.isWhitespace(c) || c == '(' || c == ')' || c == '[' || c == ']');
        }
    };

    // The ArgumentCompletor allows us to match multiple tokens
    // in the same line.
    final ArgumentCompleter argCompleter = new ArgumentCompleter(delim, strCompleter);
    // By default ArgumentCompletor is in "strict" mode meaning
    // a token is only auto-completed if all prior tokens
    // match. We don't want that since there are valid tokens
    // that are not in our wordlist (eg. table and column names)
    argCompleter.setStrict(false);

    // ArgumentCompletor always adds a space after a matched token.
    // This is undesirable for function names because a space after
    // the opening parenthesis is unnecessary (and uncommon) in Hive.
    // We stack a custom Completor on top of our ArgumentCompletor
    // to reverse this.
    Completer customCompletor = new Completer() {
        @Override
        public int complete(String buffer, int offset, List completions) {
            List<String> comp = completions;
            int ret = argCompleter.complete(buffer, offset, completions);
            // ConsoleReader will do the substitution if and only if there
            // is exactly one valid completion, so we ignore other cases.
            if (completions.size() == 1) {
                if (comp.get(0).endsWith("( ")) {
                    comp.set(0, comp.get(0).trim());
                }
            }
            return ret;
        }
    };

    List<String> vars = new ArrayList<String>();
    for (HiveConf.ConfVars conf : HiveConf.ConfVars.values()) {
        vars.add(conf.varname);
    }

    StringsCompleter confCompleter = new StringsCompleter(vars) {
        @Override
        public int complete(final String buffer, final int cursor, final List<CharSequence> clist) {
            int result = super.complete(buffer, cursor, clist);
            if (clist.isEmpty() && cursor > 1 && buffer.charAt(cursor - 1) == '=') {
                HiveConf.ConfVars var = HiveConf.getConfVars(buffer.substring(0, cursor - 1));
                if (var == null) {
                    return result;
                }
                if (var.getValidator() instanceof Validator.StringSet) {
                    Validator.StringSet validator = (Validator.StringSet) var.getValidator();
                    clist.addAll(validator.getExpected());
                } else if (var.getValidator() != null) {
                    clist.addAll(Arrays.asList(var.getValidator().toDescription(), ""));
                } else {
                    clist.addAll(Arrays.asList("Expects " + var.typeString() + " type value", ""));
                }
                return cursor;
            }
            if (clist.size() > DELIMITED_CANDIDATE_THRESHOLD) {
                Set<CharSequence> delimited = new LinkedHashSet<CharSequence>();
                for (CharSequence candidate : clist) {
                    Iterator<String> it = Splitter.on(".")
                            .split(candidate.subSequence(cursor, candidate.length())).iterator();
                    if (it.hasNext()) {
                        String next = it.next();
                        if (next.isEmpty()) {
                            next = ".";
                        }
                        candidate = buffer != null ? buffer.substring(0, cursor) + next : next;
                    }
                    delimited.add(candidate);
                }
                clist.clear();
                clist.addAll(delimited);
            }
            return result;
        }
    };

    StringsCompleter setCompleter = new StringsCompleter("set") {
        @Override
        public int complete(String buffer, int cursor, List<CharSequence> clist) {
            return buffer != null && buffer.equals("set") ? super.complete(buffer, cursor, clist) : -1;
        }
    };

    ArgumentCompleter propCompleter = new ArgumentCompleter(setCompleter, confCompleter) {
        @Override
        public int complete(String buffer, int offset, List<CharSequence> completions) {
            int ret = super.complete(buffer, offset, completions);
            if (completions.size() == 1) {
                completions.set(0, ((String) completions.get(0)).trim());
            }
            return ret;
        }
    };
    return new Completer[] { propCompleter, customCompletor };
}