text:
package com.yahala.ui;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.internal.view.SupportMenuItem;
import android.support.v4.view.MenuItemCompat;
import android.support.v7.app.ActionBar;
import android.support.v7.widget.SearchView;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

import com.yahala.android.OSUtilities;
import com.yahala.messenger.R;
import com.yahala.messenger.ContactsController;
import com.yahala.messenger.FileLog;
import com.yahala.android.LocaleController;
import com.yahala.messenger.MessagesController;
import com.yahala.messenger.NotificationCenter;
import com.yahala.messenger.TLObject;
import com.yahala.messenger.TLRPC;
import com.yahala.messenger.UserConfig;
import com.yahala.ui.Rows.ChatOrUserCell;
import com.yahala.ui.Rows.DialogCell;
import com.yahala.ui.Views.BaseFragment;

import com.yahala.messenger.Utilities;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Timer;
import java.util.TimerTask;

public class MessagesActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
    private static boolean dialogsLoaded = false;
    public int selectAlertString = 0;
    public String selectAlertStringDesc = null;
    public ArrayList<TLObject> searchResult;
    public ArrayList<CharSequence> searchResultNames;
    public MessagesActivityDelegate delegate;
    private ListView messagesListView;
    private MessagesAdapter messagesListViewAdapter;
    private TextView searchEmptyView;
    private View progressView;
    private View empryView;
    private SupportMenuItem searchItem;
    private SearchView searchView;
    private boolean serverOnly = false;
    private boolean searching = false;
    private boolean searchWas = false;
    private boolean onlySelect = false;
    private int activityToken = (int) (MessagesController.random.nextDouble() * Integer.MAX_VALUE);
    private long selectedDialog;
    private Timer searchTimer;

    @Override
    public boolean onFragmentCreate() {
        super.onFragmentCreate();
        NotificationCenter.getInstance().addObserver(this, MessagesController.dialogsNeedReload);
        NotificationCenter.getInstance().addObserver(this, 999);
        NotificationCenter.getInstance().addObserver(this, MessagesController.updateInterfaces);
        NotificationCenter.getInstance().addObserver(this, MessagesController.reloadSearchResults);
        NotificationCenter.getInstance().addObserver(this, MessagesController.encryptedChatUpdated);
        NotificationCenter.getInstance().addObserver(this, MessagesController.contactsDidLoaded);
        NotificationCenter.getInstance().addObserver(this, 1234);
        if (getArguments() != null) {
            onlySelect = getArguments().getBoolean("onlySelect", false);
            serverOnly = getArguments().getBoolean("serverOnly", false);
        }
        if (!dialogsLoaded) {
            MessagesController.getInstance().loadDialogs(0, 0, 100, true);
            ContactsController.getInstance().checkAppAccount();
            dialogsLoaded = true;
        }
        return true;
    }

    @Override
    public void onFragmentDestroy() {
        super.onFragmentDestroy();
        NotificationCenter.getInstance().removeObserver(this, MessagesController.dialogsNeedReload);
        NotificationCenter.getInstance().removeObserver(this, 999);
        NotificationCenter.getInstance().removeObserver(this, MessagesController.updateInterfaces);
        NotificationCenter.getInstance().removeObserver(this, MessagesController.reloadSearchResults);
        NotificationCenter.getInstance().removeObserver(this, MessagesController.encryptedChatUpdated);
        NotificationCenter.getInstance().removeObserver(this, MessagesController.contactsDidLoaded);
        NotificationCenter.getInstance().removeObserver(this, 1234);
        delegate = null;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setHasOptionsMenu(true);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

        if (fragmentView == null) {
            searching = false;
            searchWas = false;

            fragmentView = inflater.inflate(R.layout.messages_list, container, false);

            messagesListViewAdapter = new MessagesAdapter(parentActivity);

            messagesListView = (ListView) fragmentView.findViewById(R.id.messages_list_view);
            messagesListView.setAdapter(messagesListViewAdapter);

            progressView = fragmentView.findViewById(R.id.progressLayout);
            messagesListViewAdapter.notifyDataSetChanged();
            searchEmptyView = (TextView) fragmentView.findViewById(R.id.searchEmptyView);
            searchEmptyView.setText(LocaleController.getString("NoResult", R.string.NoResult));
            empryView = fragmentView.findViewById(R.id.list_empty_view);
            TextView textView = (TextView) fragmentView.findViewById(R.id.list_empty_view_text1);
            textView.setText(LocaleController.getString("NoChats", R.string.NoChats));
            textView = (TextView) fragmentView.findViewById(R.id.list_empty_view_text2);
            textView.setText(LocaleController.getString("NoChats", R.string.NoChatsHelp));

            if (MessagesController.getInstance().loadingDialogs && MessagesController.getInstance().dialogs.isEmpty()) {
                messagesListView.setEmptyView(null);
                searchEmptyView.setVisibility(View.GONE);
                empryView.setVisibility(View.GONE);
                progressView.setVisibility(View.VISIBLE);
            } else {
                if (searching && searchWas) {
                    messagesListView.setEmptyView(searchEmptyView);
                    empryView.setVisibility(View.GONE);
                } else {
                    messagesListView.setEmptyView(empryView);
                    searchEmptyView.setVisibility(View.GONE);
                }
                progressView.setVisibility(View.GONE);
            }

            messagesListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                @Override
                public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                    long dialog_id = 0;
                    if (searching && searchWas) {
                        if (i >= searchResult.size()) {
                            return;
                        }
                        TLObject obj = searchResult.get(i);
                        if (obj instanceof TLRPC.User) {
                            dialog_id = ((TLRPC.User) obj).id;
                        } else if (obj instanceof TLRPC.Chat) {
                            dialog_id = -((TLRPC.Chat) obj).id;
                        } else if (obj instanceof TLRPC.EncryptedChat) {
                            dialog_id = ((long) ((TLRPC.EncryptedChat) obj).id) << 32;
                        }
                    } else {
                        if (serverOnly) {
                            if (i >= MessagesController.getInstance().dialogsServerOnly.size()) {
                                return;
                            }
                            TLRPC.TL_dialog dialog = MessagesController.getInstance().dialogsServerOnly.get(i);
                            dialog_id = dialog.id;
                        } else {
                            if (i >= MessagesController.getInstance().dialogs.size()) {
                                return;
                            }
                            TLRPC.TL_dialog dialog = MessagesController.getInstance().dialogs.get(i);
                            dialog_id = dialog.id;
                        }
                    }
                    if (onlySelect) {
                        didSelectResult(dialog_id, true);
                    } else {
                        ChatActivity fragment = new ChatActivity();
                        Bundle bundle = new Bundle();
                        int lower_part = (int) dialog_id;
                        if (lower_part != 0) {
                            if (lower_part > 0) {
                                bundle.putInt("user_id", lower_part);
                                fragment.setArguments(bundle);
                                ((LaunchActivity) parentActivity).presentFragment(fragment, "chat" + Math.random(), false);
                            } else if (lower_part < 0) {
                                bundle.putInt("chat_id", -lower_part);
                                fragment.setArguments(bundle);
                                ((LaunchActivity) parentActivity).presentFragment(fragment, "chat" + Math.random(), false);
                            }
                        } else {
                            int id = (int) (dialog_id >> 32);
                            bundle.putInt("enc_id", id);
                            fragment.setArguments(bundle);
                            ((LaunchActivity) parentActivity).presentFragment(fragment, "chat" + Math.random(), false);

                        }
                    }
                }
            });

            messagesListView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
                @Override
                public boolean onItemLongClick(AdapterView<?> adapterView, View view, int i, long l) {
                    if (onlySelect || searching && searchWas) {
                        return false;
                    }
                    TLRPC.TL_dialog dialog;
                    if (serverOnly) {
                        if (i >= MessagesController.getInstance().dialogsServerOnly.size()) {
                            return false;
                        }
                        dialog = MessagesController.getInstance().dialogsServerOnly.get(i);
                    } else {
                        if (i >= MessagesController.getInstance().dialogs.size()) {
                            return false;
                        }
                        dialog = MessagesController.getInstance().dialogs.get(i);
                    }
                    selectedDialog = dialog.id;

                    AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
                    builder.setTitle(LocaleController.getString("AppName", R.string.AppName));

                    if ((int) selectedDialog < 0) {
                        builder.setItems(new CharSequence[]{LocaleController.getString("ClearHistory", R.string.ClearHistory), LocaleController.getString("DeleteChat", R.string.DeleteChat)}, new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                if (which == 0) {
                                    MessagesController.getInstance().deleteDialog(selectedDialog, 0, true);
                                } else if (which == 1) {
                                    MessagesController.getInstance().deleteUserFromChat((int) -selectedDialog, MessagesController.getInstance().users.get(UserConfig.clientUserId), null);
                                    MessagesController.getInstance().deleteDialog(selectedDialog, 0, false);
                                }
                            }
                        });
                    } else {
                        builder.setItems(new CharSequence[]{LocaleController.getString("ClearHistory", R.string.ClearHistory), LocaleController.getString("Delete", R.string.Delete)}, new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                MessagesController.getInstance().deleteDialog(selectedDialog, 0, which == 0);
                            }
                        });
                    }
                    builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
                    builder.show().setCanceledOnTouchOutside(true);
                    return true;
                }
            });

            messagesListView.setOnScrollListener(new AbsListView.OnScrollListener() {
                @Override
                public void onScrollStateChanged(AbsListView absListView, int i) {

                }

                @Override
                public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
                    if (searching && searchWas) {
                        return;
                    }
                    if (visibleItemCount > 0) {
                        if (absListView.getLastVisiblePosition() == MessagesController.getInstance().dialogs.size() && !serverOnly || absListView.getLastVisiblePosition() == MessagesController.getInstance().dialogsServerOnly.size() && serverOnly) {
                            MessagesController.getInstance().loadDialogs(MessagesController.getInstance().dialogs.size(), MessagesController.getInstance().dialogsServerOnly.size(), 100, true);
                        }
                    }
                }
            });

            if (MessagesController.getInstance().loadingDialogs) {
                progressView.setVisibility(View.VISIBLE);
            }

        } else {
            ViewGroup parent = (ViewGroup) fragmentView.getParent();
            if (parent != null) {
                parent.removeView(fragmentView);
            }
        }
        return fragmentView;
    }

    @Override
    public void applySelfActionBar() {
        if (parentActivity == null) {
            return;
        }
        final ActionBar actionBar = parentActivity.getSupportActionBar();
        if (onlySelect) {
            actionBar.setDisplayShowTitleEnabled(true);
            actionBar.setDisplayShowHomeEnabled(false);
            actionBar.setDisplayHomeAsUpEnabled(true);
            actionBar.setDisplayUseLogoEnabled(false);
            actionBar.setDisplayShowCustomEnabled(false);
            actionBar.setSubtitle(null);
            actionBar.setCustomView(null);
            actionBar.setTitle(LocaleController.getString("SelectChat", R.string.SelectChat));
            ((LaunchActivity) parentActivity).fixBackButton();
        } else {
            ImageView view = (ImageView) parentActivity.findViewById(16908332);
            if (view == null) {
                view = (ImageView) parentActivity.findViewById(R.id.home);
            }
            if (view != null) {
                view.setPadding(OSUtilities.dp(6), 0, OSUtilities.dp(6), 0);
            }
            actionBar.setHomeButtonEnabled(false);
            actionBar.setDisplayShowTitleEnabled(true);
            actionBar.setDisplayShowHomeEnabled(true);
            actionBar.setDisplayHomeAsUpEnabled(false);
            actionBar.setDisplayUseLogoEnabled(true);
            actionBar.setDisplayShowCustomEnabled(false);
            actionBar.setCustomView(null);
            actionBar.setSubtitle(null);
            actionBar.setTitle(LocaleController.getString("AppName", R.string.AppName));
        }

        TextView title = (TextView) parentActivity.findViewById(R.id.action_bar_title);
        if (title == null) {
            final int subtitleId = parentActivity.getResources().getIdentifier("action_bar_title", "id", "android");
            title = (TextView) parentActivity.findViewById(subtitleId);
        }
        if (title != null) {
            title.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
            title.setCompoundDrawablePadding(0);
        }
    }

    @Override
    public void onResume() {
        super.onResume();
        if (isFinish) {
            return;
        }
        if (getActivity() == null) {
            return;
        }
        if (messagesListViewAdapter != null) {
            messagesListViewAdapter.notifyDataSetChanged();
        }
        ((LaunchActivity) parentActivity).showActionBar();
        ((LaunchActivity) parentActivity).updateActionBar();
    }

    @Override
    @SuppressWarnings("unchecked")
    public void didReceivedNotification(int id, Object... args) {
        if (id == MessagesController.dialogsNeedReload) {
            if (messagesListViewAdapter != null) {
                messagesListViewAdapter.notifyDataSetChanged();
            }
            if (messagesListView != null) {
                if (MessagesController.getInstance().loadingDialogs && MessagesController.getInstance().dialogs.isEmpty()) {
                    if (messagesListView.getEmptyView() != null) {
                        messagesListView.setEmptyView(null);
                    }
                    searchEmptyView.setVisibility(View.GONE);
                    empryView.setVisibility(View.GONE);
                    progressView.setVisibility(View.VISIBLE);
                } else {
                    if (messagesListView.getEmptyView() == null) {
                        if (searching && searchWas) {
                            messagesListView.setEmptyView(searchEmptyView);
                            empryView.setVisibility(View.GONE);
                        } else {
                            messagesListView.setEmptyView(empryView);
                            searchEmptyView.setVisibility(View.GONE);
                        }
                    }
                    progressView.setVisibility(View.GONE);
                }
            }
        } else if (id == 999) {
            if (messagesListView != null) {
                updateVisibleRows(0);
            }
        } else if (id == MessagesController.updateInterfaces) {
            updateVisibleRows((Integer) args[0]);
        } else if (id == MessagesController.reloadSearchResults) {
            int token = (Integer) args[0];
            if (token == activityToken) {
                updateSearchResults((ArrayList<TLObject>) args[1], (ArrayList<CharSequence>) args[2], (ArrayList<TLRPC.User>) args[3]);
            }
        } else if (id == 1234) {
            dialogsLoaded = false;
        } else if (id == MessagesController.encryptedChatUpdated) {
            updateVisibleRows(0);
        } else if (id == MessagesController.contactsDidLoaded) {
            updateVisibleRows(0);
        }
    }

    private void updateVisibleRows(int mask) {
        if (messagesListView == null) {
            return;
        }
        int count = messagesListView.getChildCount();
        for (int a = 0; a < count; a++) {
            View child = messagesListView.getChildAt(a);
            if (child instanceof DialogCell) {
                ((DialogCell) child).update(mask);
            } else if (child instanceof ChatOrUserCell) {
                ((ChatOrUserCell) child).update(mask);
            }
        }
    }

    @Override
    public void willBeHidden() {
        if (searchItem != null) {
            if (searchItem.isActionViewExpanded()) {
                searchItem.collapseActionView();
            }
        }
    }

    private void didSelectResult(final long dialog_id, boolean useAlert) {
        if (useAlert && selectAlertString != 0) {
            AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
            builder.setTitle(R.string.AppName);
            int lower_part = (int) dialog_id;
            if (lower_part != 0) {
                if (lower_part > 0) {
                    TLRPC.User user = MessagesController.getInstance().users.get(lower_part);
                    if (user == null) {
                        return;
                    }
                    builder.setMessage(LocaleController.formatString(selectAlertStringDesc, selectAlertString, Utilities.formatName(user.first_name, user.last_name)));
                } else if (lower_part < 0) {
                    TLRPC.Chat chat = MessagesController.getInstance().chats.get(-lower_part);
                    if (chat == null) {
                        return;
                    }
                    builder.setMessage(LocaleController.formatString(selectAlertStringDesc, selectAlertString, chat.title));
                }
            } else {
                int chat_id = (int) (dialog_id >> 32);
                TLRPC.EncryptedChat chat = MessagesController.getInstance().encryptedChats.get(chat_id);
                TLRPC.User user = MessagesController.getInstance().users.get(chat.user_id);
                if (user == null) {
                    return;
                }
                builder.setMessage(LocaleController.formatString(selectAlertStringDesc, selectAlertString, Utilities.formatName(user.first_name, user.last_name)));
            }
            builder.setPositiveButton(R.string.OK, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    didSelectResult(dialog_id, false);
                }
            });
            builder.setNegativeButton(R.string.Cancel, null);
            builder.show().setCanceledOnTouchOutside(true);
        } else {
            if (delegate != null) {
                delegate.didSelectDialog(MessagesActivity.this, dialog_id);
                delegate = null;
            } else {
                finishFragment();
            }
        }
    }

    public void updateSearchResults(final ArrayList<TLObject> result, final ArrayList<CharSequence> names, final ArrayList<TLRPC.User> encUsers) {
        Utilities.RunOnUIThread(new Runnable() {
            @Override
            public void run() {
                for (TLObject obj : result) {
                    if (obj instanceof TLRPC.User) {
                        TLRPC.User user = (TLRPC.User) obj;
                        MessagesController.getInstance().users.putIfAbsent(user.jid, user);
                    } else if (obj instanceof TLRPC.Chat) {
                        TLRPC.Chat chat = (TLRPC.Chat) obj;
                        MessagesController.getInstance().chats.putIfAbsent(chat.id, chat);
                    } else if (obj instanceof TLRPC.EncryptedChat) {
                        TLRPC.EncryptedChat chat = (TLRPC.EncryptedChat) obj;
                        MessagesController.getInstance().encryptedChats.putIfAbsent(chat.id, chat);
                    }
                }
                for (TLRPC.User user : encUsers) {
                    MessagesController.getInstance().users.putIfAbsent(user.jid, user);
                }
                searchResult = result;
                searchResultNames = names;
                if (searching) {
                    messagesListViewAdapter.notifyDataSetChanged();
                }
            }
        });
    }

    public void searchDialogs(final String query) {
        if (query == null) {
            searchResult = null;
            searchResultNames = null;
        } else {
            try {
                if (searchTimer != null) {
                    searchTimer.cancel();
                }
            } catch (Exception e) {
                FileLog.e("tmessages", e);
            }
            searchTimer = new Timer();
            searchTimer.schedule(new TimerTask() {
                @Override
                public void run() {
                    try {
                        searchTimer.cancel();
                        searchTimer = null;
                    } catch (Exception e) {
                        FileLog.e("tmessages", e);
                    }
                    //o]   MessagesStorage.getInstance().searchDialogs(activityToken, query, !serverOnly);
                }
            }, 100, 300);
        }
    }

    @Override
    public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
        if (onlySelect) {
            inflater.inflate(R.menu.messages_list_select_menu, menu);
        } else {
            inflater.inflate(R.menu.messages_list_menu, menu);
        }
        searchItem = (SupportMenuItem) menu.findItem(R.id.messages_list_menu_search);
        searchView = (SearchView) searchItem.getActionView();

        TextView textView = (TextView) searchView.findViewById(R.id.search_src_text);
        if (textView != null) {
            textView.setTextColor(0xffffffff);
            try {
                Field mCursorDrawableRes = TextView.class.getDeclaredField("mCursorDrawableRes");
                mCursorDrawableRes.setAccessible(true);
                mCursorDrawableRes.set(textView, R.drawable.search_carret);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        ImageView img = (ImageView) searchView.findViewById(R.id.search_close_btn);
        if (img != null) {
            img.setImageResource(R.drawable.ic_msg_btn_cross_custom);
        }

        searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
            @Override
            public boolean onQueryTextSubmit(String s) {
                return true;
            }

            @Override
            public boolean onQueryTextChange(String s) {
                searchDialogs(s);
                if (s.length() != 0) {
                    searchWas = true;
                    if (messagesListViewAdapter != null) {
                        messagesListViewAdapter.notifyDataSetChanged();
                    }
                    if (searchEmptyView != null) {
                        messagesListView.setEmptyView(searchEmptyView);
                        empryView.setVisibility(View.GONE);
                    }
                }
                return true;
            }
        });

        searchItem.setSupportOnActionExpandListener(new MenuItemCompat.OnActionExpandListener() {
            @Override
            public boolean onMenuItemActionExpand(MenuItem menuItem) {
                if (parentActivity != null) {
                    parentActivity.getSupportActionBar().setIcon(R.drawable.ic_ab_logo);
                }
                searching = true;
                if (messagesListView != null) {
                    messagesListView.setEmptyView(searchEmptyView);
                }
                if (empryView != null) {
                    empryView.setVisibility(View.GONE);
                }
                return true;
            }

            @Override
            public boolean onMenuItemActionCollapse(MenuItem menuItem) {
                searchView.setQuery("", false);
                searchDialogs(null);
                searching = false;
                searchWas = false;
                if (messagesListView != null) {
                    messagesListView.setEmptyView(empryView);
                    searchEmptyView.setVisibility(View.GONE);
                }
                if (messagesListViewAdapter != null) {
                    messagesListViewAdapter.notifyDataSetChanged();
                }
                if (onlySelect) {
                    ((LaunchActivity) parentActivity).fixBackButton();
                }
                return true;
            }
        });

        super.onCreateOptionsMenu(menu, inflater);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        int itemId = item.getItemId();
        FragmentActivity inflaterActivity = parentActivity;
        if (inflaterActivity == null) {
            inflaterActivity = getActivity();
        }
        if (inflaterActivity == null) {
            return true;
        }
        switch (itemId) {

            case R.id.messages_list_menu_settings: {
                ((LaunchActivity) inflaterActivity).presentFragment(new SettingsActivity(), "settings", false);
                break;
            }
            case R.id.messages_list_menu_contacts: {
                ((LaunchActivity) inflaterActivity).presentFragment(new ContactsActivity(), "contacts", false);
                break;
            }
            case R.id.messages_list_menu_new_messages: {
                BaseFragment fragment = new ContactsActivity();
                Bundle bundle = new Bundle();
                bundle.putBoolean("onlyUsers", true);
                bundle.putBoolean("destroyAfterSelect", true);
                bundle.putBoolean("usersAsSections", true);
                fragment.animationType = 1;
                fragment.setArguments(bundle);
                ((LaunchActivity) inflaterActivity).presentFragment(fragment, "contacts_chat", false);
                break;
            }
            case R.id.messages_list_menu_new_secret_chat: {
                BaseFragment fragment = new ContactsActivity();
                Bundle bundle = new Bundle();
                bundle.putBoolean("onlyUsers", true);
                bundle.putBoolean("destroyAfterSelect", true);
                bundle.putBoolean("usersAsSections", true);
                bundle.putBoolean("createSecretChat", true);
                fragment.animationType = 1;
                fragment.setArguments(bundle);
                ((LaunchActivity) inflaterActivity).presentFragment(fragment, "contacts_chat", false);
                break;
            }
            case R.id.messages_list_menu_new_chat: {
                ((LaunchActivity) inflaterActivity).presentFragment(new GroupCreateActivity(), "group_create", false);
                break;
            }
            case android.R.id.home:
                if (onlySelect) {
                    finishFragment();
                }
                break;
        }
        return true;
    }

    public static interface MessagesActivityDelegate {
        public abstract void didSelectDialog(MessagesActivity fragment, long dialog_id);
    }

    private class MessagesAdapter extends BaseAdapter {
        private Context mContext;

        public MessagesAdapter(Context context) {
            mContext = context;
        }

        @Override
        public boolean areAllItemsEnabled() {
            return true;
        }

        @Override
        public boolean isEnabled(int i) {
            return true;
        }

        @Override
        public int getCount() {
            if (searching && searchWas) {
                if (searchResult == null) {
                    return 0;
                }
                return searchResult.size();
            }
            int count;
            if (serverOnly) {
                count = MessagesController.getInstance().dialogsServerOnly.size();
            } else {
                count = MessagesController.getInstance().dialogs.size();
            }
            if (count == 0 && MessagesController.getInstance().loadingDialogs) {
                return 0;
            }
            if (!MessagesController.getInstance().dialogsEndReached) {
                count++;
            }
            return count;
        }

        @Override
        public Object getItem(int i) {
            return null;
        }

        @Override
        public long getItemId(int i) {
            return i;
        }

        @Override
        public boolean hasStableIds() {
            return false;
        }

        @Override
        public View getView(int i, View view, ViewGroup viewGroup) {
            if (searching && searchWas) {
                if (view == null) {
                    view = new ChatOrUserCell(mContext);
                }
                TLRPC.User user = null;
                TLRPC.Chat chat = null;
                TLRPC.EncryptedChat encryptedChat = null;

                TLObject obj = searchResult.get(i);
                if (obj instanceof TLRPC.User) {
                    user = MessagesController.getInstance().users.get(((TLRPC.User) obj).id);
                } else if (obj instanceof TLRPC.Chat) {
                    chat = MessagesController.getInstance().chats.get(((TLRPC.Chat) obj).id);
                } else if (obj instanceof TLRPC.EncryptedChat) {
                    encryptedChat = MessagesController.getInstance().encryptedChats.get(((TLRPC.EncryptedChat) obj).id);
                    user = MessagesController.getInstance().users.get(encryptedChat.user_id);
                }

                ((ChatOrUserCell) view).setData(user, chat, encryptedChat, searchResultNames.get(i), null);

                return view;
            }
            int type = getItemViewType(i);
            if (type == 1) {
                if (view == null) {
                    LayoutInflater li = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                    view = li.inflate(R.layout.loading_more_layout, viewGroup, false);
                }
                return view;
            }

            if (view == null) {
                view = new DialogCell(mContext);
            }
            if (serverOnly) {
                ((DialogCell) view).setDialog(MessagesController.getInstance().dialogsServerOnly.get(i));
            } else {
                ((DialogCell) view).setDialog(MessagesController.getInstance().dialogs.get(i));
            }

            return view;
        }

        @Override
        public int getItemViewType(int i) {
            if (searching && searchWas) {
                TLObject obj = searchResult.get(i);
                if (obj instanceof TLRPC.User || obj instanceof TLRPC.EncryptedChat) {
                    return 2;
                } else {
                    return 3;
                }
            }
            if (serverOnly && i == MessagesController.getInstance().dialogsServerOnly.size() || !serverOnly && i == MessagesController.getInstance().dialogs.size()) {
                return 1;
            }
            return 0;
        }

        @Override
        public int getViewTypeCount() {
            return 4;
        }

        @Override
        public boolean isEmpty() {
            if (searching && searchWas) {
                return searchResult == null || searchResult.size() == 0;
            }
            if (MessagesController.getInstance().loadingDialogs && MessagesController.getInstance().dialogs.isEmpty()) {
                return false;
            }
            int count;
            if (serverOnly) {
                count = MessagesController.getInstance().dialogsServerOnly.size();
            } else {
                count = MessagesController.getInstance().dialogs.size();
            }
            if (count == 0 && MessagesController.getInstance().loadingDialogs) {
                return true;
            }
            if (!MessagesController.getInstance().dialogsEndReached) {
                count++;
            }
            return count == 0;
        }

    }
}


text:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="CoreNLP-to-HTML.xsl" type="text/xsl"?>
<root>
  <document>
    <sentences>
      <sentence id="1">
        <tokens>
          <token id="1">
            <word>im</word>
            <lemma>im</lemma>
            <CharacterOffsetBegin>0</CharacterOffsetBegin>
            <CharacterOffsetEnd>2</CharacterOffsetEnd>
            <POS>NN</POS>
          </token>
          <token id="2">
            <word>on</word>
            <lemma>on</lemma>
            <CharacterOffsetBegin>3</CharacterOffsetBegin>
            <CharacterOffsetEnd>5</CharacterOffsetEnd>
            <POS>IN</POS>
          </token>
          <token id="3">
            <word>a</word>
            <lemma>a</lemma>
            <CharacterOffsetBegin>6</CharacterOffsetBegin>
            <CharacterOffsetEnd>7</CharacterOffsetEnd>
            <POS>DT</POS>
          </token>
          <token id="4">
            <word>mac</word>
            <lemma>mac</lemma>
            <CharacterOffsetBegin>8</CharacterOffsetBegin>
            <CharacterOffsetEnd>11</CharacterOffsetEnd>
            <POS>NN</POS>
          </token>
          <token id="5">
            <word>running</word>
            <lemma>run</lemma>
            <CharacterOffsetBegin>12</CharacterOffsetBegin>
            <CharacterOffsetEnd>19</CharacterOffsetEnd>
            <POS>VBG</POS>
          </token>
          <token id="6">
            <word>snow</word>
            <lemma>snow</lemma>
            <CharacterOffsetBegin>20</CharacterOffsetBegin>
            <CharacterOffsetEnd>24</CharacterOffsetEnd>
            <POS>NN</POS>
          </token>
          <token id="7">
            <word>leopard</word>
            <lemma>leopard</lemma>
            <CharacterOffsetBegin>25</CharacterOffsetBegin>
            <CharacterOffsetEnd>32</CharacterOffsetEnd>
            <POS>NN</POS>
          </token>
          <token id="8">
            <word>-LRB-</word>
            <lemma>-lrb-</lemma>
            <CharacterOffsetBegin>33</CharacterOffsetBegin>
            <CharacterOffsetEnd>34</CharacterOffsetEnd>
            <POS>-LRB-</POS>
          </token>
          <token id="9">
            <word>10.6</word>
            <lemma>10.6</lemma>
            <CharacterOffsetBegin>34</CharacterOffsetBegin>
            <CharacterOffsetEnd>38</CharacterOffsetEnd>
            <POS>CD</POS>
          </token>
          <token id="10">
            <word>-RRB-</word>
            <lemma>-rrb-</lemma>
            <CharacterOffsetBegin>38</CharacterOffsetBegin>
            <CharacterOffsetEnd>39</CharacterOffsetEnd>
            <POS>-RRB-</POS>
          </token>
          <token id="11">
            <word>and</word>
            <lemma>and</lemma>
            <CharacterOffsetBegin>40</CharacterOffsetBegin>
            <CharacterOffsetEnd>43</CharacterOffsetEnd>
            <POS>CC</POS>
          </token>
          <token id="12">
            <word>sometimes</word>
            <lemma>sometimes</lemma>
            <CharacterOffsetBegin>44</CharacterOffsetBegin>
            <CharacterOffsetEnd>53</CharacterOffsetEnd>
            <POS>RB</POS>
          </token>
          <token id="13">
            <word>have</word>
            <lemma>have</lemma>
            <CharacterOffsetBegin>54</CharacterOffsetBegin>
            <CharacterOffsetEnd>58</CharacterOffsetEnd>
            <POS>VBP</POS>
          </token>
          <token id="14">
            <word>minor</word>
            <lemma>minor</lemma>
            <CharacterOffsetBegin>59</CharacterOffsetBegin>
            <CharacterOffsetEnd>64</CharacterOffsetEnd>
            <POS>JJ</POS>
          </token>
          <token id="15">
            <word>problems</word>
            <lemma>problem</lemma>
            <CharacterOffsetBegin>65</CharacterOffsetBegin>
            <CharacterOffsetEnd>73</CharacterOffsetEnd>
            <POS>NNS</POS>
          </token>
          <token id="16">
            <word>with</word>
            <lemma>with</lemma>
            <CharacterOffsetBegin>74</CharacterOffsetBegin>
            <CharacterOffsetEnd>78</CharacterOffsetEnd>
            <POS>IN</POS>
          </token>
          <token id="17">
            <word>safari</word>
            <lemma>safari</lemma>
            <CharacterOffsetBegin>79</CharacterOffsetBegin>
            <CharacterOffsetEnd>85</CharacterOffsetEnd>
            <POS>JJ</POS>
          </token>
          <token id="18">
            <word>so</word>
            <lemma>so</lemma>
            <CharacterOffsetBegin>86</CharacterOffsetBegin>
            <CharacterOffsetEnd>88</CharacterOffsetEnd>
            <POS>RB</POS>
          </token>
          <token id="19">
            <word>im</word>
            <lemma>im</lemma>
            <CharacterOffsetBegin>89</CharacterOffsetBegin>
            <CharacterOffsetEnd>91</CharacterOffsetEnd>
            <POS>JJ</POS>
          </token>
          <token id="20">
            <word>looking</word>
            <lemma>look</lemma>
            <CharacterOffsetBegin>92</CharacterOffsetBegin>
            <CharacterOffsetEnd>99</CharacterOffsetEnd>
            <POS>VBG</POS>
          </token>
          <token id="21">
            <word>to</word>
            <lemma>to</lemma>
            <CharacterOffsetBegin>100</CharacterOffsetBegin>
            <CharacterOffsetEnd>102</CharacterOffsetEnd>
            <POS>TO</POS>
          </token>
          <token id="22">
            <word>download</word>
            <lemma>download</lemma>
            <CharacterOffsetBegin>103</CharacterOffsetBegin>
            <CharacterOffsetEnd>111</CharacterOffsetEnd>
            <POS>VB</POS>
          </token>
          <token id="23">
            <word>a</word>
            <lemma>a</lemma>
            <CharacterOffsetBegin>112</CharacterOffsetBegin>
            <CharacterOffsetEnd>113</CharacterOffsetEnd>
            <POS>DT</POS>
          </token>
          <token id="24">
            <word>secondary</word>
            <lemma>secondary</lemma>
            <CharacterOffsetBegin>114</CharacterOffsetBegin>
            <CharacterOffsetEnd>123</CharacterOffsetEnd>
            <POS>JJ</POS>
          </token>
          <token id="25">
            <word>browser</word>
            <lemma>browser</lemma>
            <CharacterOffsetBegin>124</CharacterOffsetBegin>
            <CharacterOffsetEnd>131</CharacterOffsetEnd>
            <POS>NN</POS>
          </token>
          <token id="26">
            <word>.</word>
            <lemma>.</lemma>
            <CharacterOffsetBegin>131</CharacterOffsetBegin>
            <CharacterOffsetEnd>132</CharacterOffsetEnd>
            <POS>.</POS>
          </token>
        </tokens>
        <parse>(ROOT (S (NP (NP (NN im)) (PP (IN on) (NP (NP (DT a) (NN mac)) (VP (VBG running) (NP (NP (NP (NN snow) (NN leopard)) (PRN (-LRB- -LRB-) (NP (CD 10.6)) (-RRB- -RRB-))) (CC and) (RB sometimes)))))) (VP (VBP have) (NP (NP (JJ minor) (NNS problems)) (PP (IN with) (NP (NP (JJ safari)) (ADJP (RB so) (JJ im)))) (VP (VBG looking) (S (VP (TO to) (VP (VB download) (NP (DT a) (JJ secondary) (NN browser)))))))) (. .))) </parse>
        <dependencies type="basic-dependencies">
          <dep type="root">
            <governor idx="0">ROOT</governor>
            <dependent idx="13">have</dependent>
          </dep>
          <dep type="nsubj">
            <governor idx="13">have</governor>
            <dependent idx="1">im</dependent>
          </dep>
          <dep type="prep">
            <governor idx="1">im</governor>
            <dependent idx="2">on</dependent>
          </dep>
          <dep type="det">
            <governor idx="4">mac</governor>
            <dependent idx="3">a</dependent>
          </dep>
          <dep type="pobj">
            <governor idx="2">on</governor>
            <dependent idx="4">mac</dependent>
          </dep>
          <dep type="vmod">
            <governor idx="4">mac</governor>
            <dependent idx="5">running</dependent>
          </dep>
          <dep type="nn">
            <governor idx="7">leopard</governor>
            <dependent idx="6">snow</dependent>
          </dep>
          <dep type="dobj">
            <governor idx="5">running</governor>
            <dependent idx="7">leopard</dependent>
          </dep>
          <dep type="appos">
            <governor idx="7">leopard</governor>
            <dependent idx="9">10.6</dependent>
          </dep>
          <dep type="cc">
            <governor idx="7">leopard</governor>
            <dependent idx="11">and</dependent>
          </dep>
          <dep type="advmod">
            <governor idx="7">leopard</governor>
            <dependent idx="12">sometimes</dependent>
          </dep>
          <dep type="amod">
            <governor idx="15">problems</governor>
            <dependent idx="14">minor</dependent>
          </dep>
          <dep type="dobj">
            <governor idx="13">have</governor>
            <dependent idx="15">problems</dependent>
          </dep>
          <dep type="prep">
            <governor idx="15">problems</governor>
            <dependent idx="16">with</dependent>
          </dep>
          <dep type="pobj">
            <governor idx="16">with</governor>
            <dependent idx="17">safari</dependent>
          </dep>
          <dep type="advmod">
            <governor idx="19">im</governor>
            <dependent idx="18">so</dependent>
          </dep>
          <dep type="amod">
            <governor idx="17">safari</governor>
            <dependent idx="19">im</dependent>
          </dep>
          <dep type="vmod">
            <governor idx="15">problems</governor>
            <dependent idx="20">looking</dependent>
          </dep>
          <dep type="aux">
            <governor idx="22">download</governor>
            <dependent idx="21">to</dependent>
          </dep>
          <dep type="xcomp">
            <governor idx="20">looking</governor>
            <dependent idx="22">download</dependent>
          </dep>
          <dep type="det">
            <governor idx="25">browser</governor>
            <dependent idx="23">a</dependent>
          </dep>
          <dep type="amod">
            <governor idx="25">browser</governor>
            <dependent idx="24">secondary</dependent>
          </dep>
          <dep type="dobj">
            <governor idx="22">download</governor>
            <dependent idx="25">browser</dependent>
          </dep>
        </dependencies>
        <dependencies type="collapsed-dependencies">
          <dep type="root">
            <governor idx="0">ROOT</governor>
            <dependent idx="13">have</dependent>
          </dep>
          <dep type="nsubj">
            <governor idx="13">have</governor>
            <dependent idx="1">im</dependent>
          </dep>
          <dep type="det">
            <governor idx="4">mac</governor>
            <dependent idx="3">a</dependent>
          </dep>
          <dep type="prep_on">
            <governor idx="1">im</governor>
            <dependent idx="4">mac</dependent>
          </dep>
          <dep type="vmod">
            <governor idx="4">mac</governor>
            <dependent idx="5">running</dependent>
          </dep>
          <dep type="nn">
            <governor idx="7">leopard</governor>
            <dependent idx="6">snow</dependent>
          </dep>
          <dep type="dobj">
            <governor idx="5">running</governor>
            <dependent idx="7">leopard</dependent>
          </dep>
          <dep type="appos">
            <governor idx="7">leopard</governor>
            <dependent idx="9">10.6</dependent>
          </dep>
          <dep type="cc">
            <governor idx="7">leopard</governor>
            <dependent idx="11">and</dependent>
          </dep>
          <dep type="advmod">
            <governor idx="7">leopard</governor>
            <dependent idx="12">sometimes</dependent>
          </dep>
          <dep type="amod">
            <governor idx="15">problems</governor>
            <dependent idx="14">minor</dependent>
          </dep>
          <dep type="dobj">
            <governor idx="13">have</governor>
            <dependent idx="15">problems</dependent>
          </dep>
          <dep type="prep_with">
            <governor idx="15">problems</governor>
            <dependent idx="17">safari</dependent>
          </dep>
          <dep type="advmod">
            <governor idx="19">im</governor>
            <dependent idx="18">so</dependent>
          </dep>
          <dep type="amod">
            <governor idx="17">safari</governor>
            <dependent idx="19">im</dependent>
          </dep>
          <dep type="vmod">
            <governor idx="15">problems</governor>
            <dependent idx="20">looking</dependent>
          </dep>
          <dep type="aux">
            <governor idx="22">download</governor>
            <dependent idx="21">to</dependent>
          </dep>
          <dep type="xcomp">
            <governor idx="20">looking</governor>
            <dependent idx="22">download</dependent>
          </dep>
          <dep type="det">
            <governor idx="25">browser</governor>
            <dependent idx="23">a</dependent>
          </dep>
          <dep type="amod">
            <governor idx="25">browser</governor>
            <dependent idx="24">secondary</dependent>
          </dep>
          <dep type="dobj">
            <governor idx="22">download</governor>
            <dependent idx="25">browser</dependent>
          </dep>
        </dependencies>
        <dependencies type="collapsed-ccprocessed-dependencies">
          <dep type="root">
            <governor idx="0">ROOT</governor>
            <dependent idx="13">have</dependent>
          </dep>
          <dep type="nsubj">
            <governor idx="13">have</governor>
            <dependent idx="1">im</dependent>
          </dep>
          <dep type="det">
            <governor idx="4">mac</governor>
            <dependent idx="3">a</dependent>
          </dep>
          <dep type="prep_on">
            <governor idx="1">im</governor>
            <dependent idx="4">mac</dependent>
          </dep>
          <dep type="vmod">
            <governor idx="4">mac</governor>
            <dependent idx="5">running</dependent>
          </dep>
          <dep type="nn">
            <governor idx="7">leopard</governor>
            <dependent idx="6">snow</dependent>
          </dep>
          <dep type="dobj">
            <governor idx="5">running</governor>
            <dependent idx="7">leopard</dependent>
          </dep>
          <dep type="appos">
            <governor idx="7">leopard</governor>
            <dependent idx="9">10.6</dependent>
          </dep>
          <dep type="cc">
            <governor idx="7">leopard</governor>
            <dependent idx="11">and</dependent>
          </dep>
          <dep type="advmod">
            <governor idx="7">leopard</governor>
            <dependent idx="12">sometimes</dependent>
          </dep>
          <dep type="amod">
            <governor idx="15">problems</governor>
            <dependent idx="14">minor</dependent>
          </dep>
          <dep type="dobj">
            <governor idx="13">have</governor>
            <dependent idx="15">problems</dependent>
          </dep>
          <dep type="prep_with">
            <governor idx="15">problems</governor>
            <dependent idx="17">safari</dependent>
          </dep>
          <dep type="advmod">
            <governor idx="19">im</governor>
            <dependent idx="18">so</dependent>
          </dep>
          <dep type="amod">
            <governor idx="17">safari</governor>
            <dependent idx="19">im</dependent>
          </dep>
          <dep type="vmod">
            <governor idx="15">problems</governor>
            <dependent idx="20">looking</dependent>
          </dep>
          <dep type="aux">
            <governor idx="22">download</governor>
            <dependent idx="21">to</dependent>
          </dep>
          <dep type="xcomp">
            <governor idx="20">looking</governor>
            <dependent idx="22">download</dependent>
          </dep>
          <dep type="det">
            <governor idx="25">browser</governor>
            <dependent idx="23">a</dependent>
          </dep>
          <dep type="amod">
            <governor idx="25">browser</governor>
            <dependent idx="24">secondary</dependent>
          </dep>
          <dep type="dobj">
            <governor idx="22">download</governor>
            <dependent idx="25">browser</dependent>
          </dep>
        </dependencies>
      </sentence>
      <sentence id="2">
        <tokens>
          <token id="1">
            <word>ive</word>
            <lemma>ive</lemma>
            <CharacterOffsetBegin>133</CharacterOffsetBegin>
            <CharacterOffsetEnd>136</CharacterOffsetEnd>
            <POS>NN</POS>
          </token>
          <token id="2">
            <word>used</word>
            <lemma>use</lemma>
            <CharacterOffsetBegin>137</CharacterOffsetBegin>
            <CharacterOffsetEnd>141</CharacterOffsetEnd>
            <POS>VBD</POS>
          </token>
          <token id="3">
            <word>firefox</word>
            <lemma>firefox</lemma>
            <CharacterOffsetBegin>142</CharacterOffsetBegin>
            <CharacterOffsetEnd>149</CharacterOffsetEnd>
            <POS>NN</POS>
          </token>
          <token id="4">
            <word>before</word>
            <lemma>before</lemma>
            <CharacterOffsetBegin>150</CharacterOffsetBegin>
            <CharacterOffsetEnd>156</CharacterOffsetEnd>
            <POS>IN</POS>
          </token>
          <token id="5">
            <word>and</word>
            <lemma>and</lemma>
            <CharacterOffsetBegin>157</CharacterOffsetBegin>
            <CharacterOffsetEnd>160</CharacterOffsetEnd>
            <POS>CC</POS>
          </token>
          <token id="6">
            <word>thought</word>
            <lemma>think</lemma>
            <CharacterOffsetBegin>161</CharacterOffsetBegin>
            <CharacterOffsetEnd>168</CharacterOffsetEnd>
            <POS>VBD</POS>
          </token>
          <token id="7">
            <word>it</word>
            <lemma>it</lemma>
            <CharacterOffsetBegin>169</CharacterOffsetBegin>
            <CharacterOffsetEnd>171</CharacterOffsetEnd>
            <POS>PRP</POS>
          </token>
          <token id="8">
            <word>was</word>
            <lemma>be</lemma>
            <CharacterOffsetBegin>172</CharacterOffsetBegin>
            <CharacterOffsetEnd>175</CharacterOffsetEnd>
            <POS>VBD</POS>
          </token>
          <token id="9">
            <word>fine</word>
            <lemma>fine</lemma>
            <CharacterOffsetBegin>176</CharacterOffsetBegin>
            <CharacterOffsetEnd>180</CharacterOffsetEnd>
            <POS>JJ</POS>
          </token>
          <token id="10">
            <word>but</word>
            <lemma>but</lemma>
            <CharacterOffsetBegin>181</CharacterOffsetBegin>
            <CharacterOffsetEnd>184</CharacterOffsetEnd>
            <POS>CC</POS>
          </token>
          <token id="11">
            <word>never</word>
            <lemma>never</lemma>
            <CharacterOffsetBegin>185</CharacterOffsetBegin>
            <CharacterOffsetEnd>190</CharacterOffsetEnd>
            <POS>RB</POS>
          </token>
          <token id="12">
            <word>used</word>
            <lemma>use</lemma>
            <CharacterOffsetBegin>191</CharacterOffsetBegin>
            <CharacterOffsetEnd>195</CharacterOffsetEnd>
            <POS>VBN</POS>
          </token>
          <token id="13">
            <word>chrome</word>
            <lemma>chrome</lemma>
            <CharacterOffsetBegin>196</CharacterOffsetBegin>
            <CharacterOffsetEnd>202</CharacterOffsetEnd>
            <POS>NN</POS>
          </token>
          <token id="14">
            <word>can</word>
            <lemma>can</lemma>
            <CharacterOffsetBegin>203</CharacterOffsetBegin>
            <CharacterOffsetEnd>206</CharacterOffsetEnd>
            <POS>MD</POS>
          </token>
          <token id="15">
            <word>someone</word>
            <lemma>someone</lemma>
            <CharacterOffsetBegin>207</CharacterOffsetBegin>
            <CharacterOffsetEnd>214</CharacterOffsetEnd>
            <POS>NN</POS>
          </token>
          <token id="16">
            <word>with</word>
            <lemma>with</lemma>
            <CharacterOffsetBegin>215</CharacterOffsetBegin>
            <CharacterOffsetEnd>219</CharacterOffsetEnd>
            <POS>IN</POS>
          </token>
          <token id="17">
            <word>experience</word>
            <lemma>experience</lemma>
            <CharacterOffsetBegin>220</CharacterOffsetBegin>
            <CharacterOffsetEnd>230</CharacterOffsetEnd>
            <POS>NN</POS>
          </token>
          <token id="18">
            <word>on</word>
            <lemma>on</lemma>
            <CharacterOffsetBegin>231</CharacterOffsetBegin>
            <CharacterOffsetEnd>233</CharacterOffsetEnd>
            <POS>IN</POS>
          </token>
          <token id="19">
            <word>either</word>
            <lemma>either</lemma>
            <CharacterOffsetBegin>234</CharacterOffsetBegin>
            <CharacterOffsetEnd>240</CharacterOffsetEnd>
            <POS>DT</POS>
          </token>
          <token id="20">
            <word>of</word>
            <lemma>of</lemma>
            <CharacterOffsetBegin>241</CharacterOffsetBegin>
            <CharacterOffsetEnd>243</CharacterOffsetEnd>
            <POS>IN</POS>
          </token>
          <token id="21">
            <word>these</word>
            <lemma>these</lemma>
            <CharacterOffsetBegin>244</CharacterOffsetBegin>
            <CharacterOffsetEnd>249</CharacterOffsetEnd>
            <POS>DT</POS>
          </token>
          <token id="22">
            <word>browsers</word>
            <lemma>browser</lemma>
            <CharacterOffsetBegin>250</CharacterOffsetBegin>
            <CharacterOffsetEnd>258</CharacterOffsetEnd>
            <POS>NNS</POS>
          </token>
          <token id="23">
            <word>on</word>
            <lemma>on</lemma>
            <CharacterOffsetBegin>259</CharacterOffsetBegin>
            <CharacterOffsetEnd>261</CharacterOffsetEnd>
            <POS>IN</POS>
          </token>
          <token id="24">
            <word>a</word>
            <lemma>a</lemma>
            <CharacterOffsetBegin>262</CharacterOffsetBegin>
            <CharacterOffsetEnd>263</CharacterOffsetEnd>
            <POS>DT</POS>
          </token>
          <token id="25">
            <word>mac</word>
            <lemma>mac</lemma>
            <CharacterOffsetBegin>264</CharacterOffsetBegin>
            <CharacterOffsetEnd>267</CharacterOffsetEnd>
            <POS>NN</POS>
          </token>
          <token id="26">
            <word>tell</word>
            <lemma>tell</lemma>
            <CharacterOffsetBegin>268</CharacterOffsetBegin>
            <CharacterOffsetEnd>272</CharacterOffsetEnd>
            <POS>VB</POS>
          </token>
          <token id="27">
            <word>me</word>
            <lemma>I</lemma>
            <CharacterOffsetBegin>273</CharacterOffsetBegin>
            <CharacterOffsetEnd>275</CharacterOffsetEnd>
            <POS>PRP</POS>
          </token>
          <token id="28">
            <word>the</word>
            <lemma>the</lemma>
            <CharacterOffsetBegin>276</CharacterOffsetBegin>
            <CharacterOffsetEnd>279</CharacterOffsetEnd>
            <POS>DT</POS>
          </token>
          <token id="29">
            <word>ups</word>
            <lemma>up</lemma>
            <CharacterOffsetBegin>280</CharacterOffsetBegin>
            <CharacterOffsetEnd>283</CharacterOffsetEnd>
            <POS>NNS</POS>
          </token>
          <token id="30">
            <word>and</word>
            <lemma>and</lemma>
            <CharacterOffsetBegin>284</CharacterOffsetBegin>
            <CharacterOffsetEnd>287</CharacterOffsetEnd>
            <POS>CC</POS>
          </token>
          <token id="31">
            <word>downs</word>
            <lemma>downs</lemma>
            <CharacterOffsetBegin>288</CharacterOffsetBegin>
            <CharacterOffsetEnd>293</CharacterOffsetEnd>
            <POS>NNS</POS>
          </token>
          <token id="32">
            <word>of</word>
            <lemma>of</lemma>
            <CharacterOffsetBegin>294</CharacterOffsetBegin>
            <CharacterOffsetEnd>296</CharacterOffsetEnd>
            <POS>IN</POS>
          </token>
          <token id="33">
            <word>them</word>
            <lemma>they</lemma>
            <CharacterOffsetBegin>297</CharacterOffsetBegin>
            <CharacterOffsetEnd>301</CharacterOffsetEnd>
            <POS>PRP</POS>
          </token>
          <token id="34">
            <word>?</word>
            <lemma>?</lemma>
            <CharacterOffsetBegin>301</CharacterOffsetBegin>
            <CharacterOffsetEnd>302</CharacterOffsetEnd>
            <POS>.</POS>
          </token>
        </tokens>
        <parse>(ROOT (S (NP (NN ive)) (VP (VP (VBD used) (NP (NN firefox)) (PP (IN before))) (CC and) (VP (VBD thought) (SBAR (S (NP (PRP it)) (VP (VBD was) (ADJP (ADJP (JJ fine)) (CC but) (VP (ADVP (RB never)) (VBN used) (SBAR (S (NP (NN chrome)) (VP (MD can) (PP (NP (NN someone)) (IN with) (NP (NP (NN experience)) (PP (IN on) (NP (NP (DT either)) (PP (IN of) (NP (NP (DT these) (NNS browsers)) (PP (IN on) (NP (DT a) (NN mac))))))))) (VP (VB tell) (NP (PRP me)) (NP (NP (DT the) (NNS ups) (CC and) (NNS downs)) (PP (IN of) (NP (PRP them))))))))))))))) (. ?))) </parse>
        <dependencies type="basic-dependencies">
          <dep type="root">
            <governor idx="0">ROOT</governor>
            <dependent idx="2">used</dependent>
          </dep>
          <dep type="nsubj">
            <governor idx="2">used</governor>
            <dependent idx="1">ive</dependent>
          </dep>
          <dep type="dobj">
            <governor idx="2">used</governor>
            <dependent idx="3">firefox</dependent>
          </dep>
          <dep type="prep">
            <governor idx="2">used</governor>
            <dependent idx="4">before</dependent>
          </dep>
          <dep type="cc">
            <governor idx="2">used</governor>
            <dependent idx="5">and</dependent>
          </dep>
          <dep type="conj">
            <governor idx="2">used</governor>
            <dependent idx="6">thought</dependent>
          </dep>
          <dep type="nsubjpass">
            <governor idx="9">fine</governor>
            <dependent idx="7">it</dependent>
          </dep>
          <dep type="auxpass">
            <governor idx="9">fine</governor>
            <dependent idx="8">was</dependent>
          </dep>
          <dep type="ccomp">
            <governor idx="6">thought</governor>
            <dependent idx="9">fine</dependent>
          </dep>
          <dep type="cc">
            <governor idx="9">fine</governor>
            <dependent idx="10">but</dependent>
          </dep>
          <dep type="neg">
            <governor idx="12">used</governor>
            <dependent idx="11">never</dependent>
          </dep>
          <dep type="conj">
            <governor idx="9">fine</governor>
            <dependent idx="12">used</dependent>
          </dep>
          <dep type="nsubj">
            <governor idx="26">tell</governor>
            <dependent idx="13">chrome</dependent>
          </dep>
          <dep type="aux">
            <governor idx="26">tell</governor>
            <dependent idx="14">can</dependent>
          </dep>
          <dep type="npadvmod">
            <governor idx="16">with</governor>
            <dependent idx="15">someone</dependent>
          </dep>
          <dep type="prep">
            <governor idx="26">tell</governor>
            <dependent idx="16">with</dependent>
          </dep>
          <dep type="pobj">
            <governor idx="16">with</governor>
            <dependent idx="17">experience</dependent>
          </dep>
          <dep type="prep">
            <governor idx="17">experience</governor>
            <dependent idx="18">on</dependent>
          </dep>
          <dep type="pobj">
            <governor idx="18">on</governor>
            <dependent idx="19">either</dependent>
          </dep>
          <dep type="prep">
            <governor idx="19">either</governor>
            <dependent idx="20">of</dependent>
          </dep>
          <dep type="det">
            <governor idx="22">browsers</governor>
            <dependent idx="21">these</dependent>
          </dep>
          <dep type="pobj">
            <governor idx="20">of</governor>
            <dependent idx="22">browsers</dependent>
          </dep>
          <dep type="prep">
            <governor idx="22">browsers</governor>
            <dependent idx="23">on</dependent>
          </dep>
          <dep type="det">
            <governor idx="25">mac</governor>
            <dependent idx="24">a</dependent>
          </dep>
          <dep type="pobj">
            <governor idx="23">on</governor>
            <dependent idx="25">mac</dependent>
          </dep>
          <dep type="ccomp">
            <governor idx="12">used</governor>
            <dependent idx="26">tell</dependent>
          </dep>
          <dep type="iobj">
            <governor idx="26">tell</governor>
            <dependent idx="27">me</dependent>
          </dep>
          <dep type="det">
            <governor idx="29">ups</governor>
            <dependent idx="28">the</dependent>
          </dep>
          <dep type="dobj">
            <governor idx="26">tell</governor>
            <dependent idx="29">ups</dependent>
          </dep>
          <dep type="cc">
            <governor idx="29">ups</governor>
            <dependent idx="30">and</dependent>
          </dep>
          <dep type="conj">
            <governor idx="29">ups</governor>
            <dependent idx="31">downs</dependent>
          </dep>
          <dep type="prep">
            <governor idx="29">ups</governor>
            <dependent idx="32">of</dependent>
          </dep>
          <dep type="pobj">
            <governor idx="32">of</governor>
            <dependent idx="33">them</dependent>
          </dep>
        </dependencies>
        <dependencies type="collapsed-dependencies">
          <dep type="root">
            <governor idx="0">ROOT</governor>
            <dependent idx="2">used</dependent>
          </dep>
          <dep type="nsubj">
            <governor idx="2">used</governor>
            <dependent idx="1">ive</dependent>
          </dep>
          <dep type="dobj">
            <governor idx="2">used</governor>
            <dependent idx="3">firefox</dependent>
          </dep>
          <dep type="prep">
            <governor idx="2">used</governor>
            <dependent idx="4">before</dependent>
          </dep>
          <dep type="conj_and">
            <governor idx="2">used</governor>
            <dependent idx="6">thought</dependent>
          </dep>
          <dep type="nsubjpass">
            <governor idx="9">fine</governor>
            <dependent idx="7">it</dependent>
          </dep>
          <dep type="auxpass">
            <governor idx="9">fine</governor>
            <dependent idx="8">was</dependent>
          </dep>
          <dep type="ccomp">
            <governor idx="6">thought</governor>
            <dependent idx="9">fine</dependent>
          </dep>
          <dep type="neg">
            <governor idx="12">used</governor>
            <dependent idx="11">never</dependent>
          </dep>
          <dep type="conj_but">
            <governor idx="9">fine</governor>
            <dependent idx="12">used</dependent>
          </dep>
          <dep type="nsubj">
            <governor idx="26">tell</governor>
            <dependent idx="13">chrome</dependent>
          </dep>
          <dep type="aux">
            <governor idx="26">tell</governor>
            <dependent idx="14">can</dependent>
          </dep>
          <dep type="npadvmod">
            <governor idx="26">tell</governor>
            <dependent idx="15">someone</dependent>
          </dep>
          <dep type="prep_with">
            <governor idx="26">tell</governor>
            <dependent idx="17">experience</dependent>
          </dep>
          <dep type="prep_on">
            <governor idx="17">experience</governor>
            <dependent idx="19">either</dependent>
          </dep>
          <dep type="det">
            <governor idx="22">browsers</governor>
            <dependent idx="21">these</dependent>
          </dep>
          <dep type="prep_of">
            <governor idx="19">either</governor>
            <dependent idx="22">browsers</dependent>
          </dep>
          <dep type="det">
            <governor idx="25">mac</governor>
            <dependent idx="24">a</dependent>
          </dep>
          <dep type="prep_on">
            <governor idx="22">browsers</governor>
            <dependent idx="25">mac</dependent>
          </dep>
          <dep type="ccomp">
            <governor idx="12">used</governor>
            <dependent idx="26">tell</dependent>
          </dep>
          <dep type="iobj">
            <governor idx="26">tell</governor>
            <dependent idx="27">me</dependent>
          </dep>
          <dep type="det">
            <governor idx="29">ups</governor>
            <dependent idx="28">the</dependent>
          </dep>
          <dep type="dobj">
            <governor idx="26">tell</governor>
            <dependent idx="29">ups</dependent>
          </dep>
          <dep type="conj_and">
            <governor idx="29">ups</governor>
            <dependent idx="31">downs</dependent>
          </dep>
          <dep type="prep_of">
            <governor idx="29">ups</governor>
            <dependent idx="33">them</dependent>
          </dep>
        </dependencies>
        <dependencies type="collapsed-ccprocessed-dependencies">
          <dep type="root">
            <governor idx="0">ROOT</governor>
            <dependent idx="2">used</dependent>
          </dep>
          <dep type="nsubj">
            <governor idx="2">used</governor>
            <dependent idx="1">ive</dependent>
          </dep>
          <dep type="nsubj">
            <governor idx="6">thought</governor>
            <dependent idx="1">ive</dependent>
          </dep>
          <dep type="dobj">
            <governor idx="2">used</governor>
            <dependent idx="3">firefox</dependent>
          </dep>
          <dep type="prep">
            <governor idx="2">used</governor>
            <dependent idx="4">before</dependent>
          </dep>
          <dep type="conj_and">
            <governor idx="2">used</governor>
            <dependent idx="6">thought</dependent>
          </dep>
          <dep type="nsubjpass">
            <governor idx="9">fine</governor>
            <dependent idx="7">it</dependent>
          </dep>
          <dep type="nsubjpass">
            <governor idx="12">used</governor>
            <dependent idx="7">it</dependent>
          </dep>
          <dep type="auxpass">
            <governor idx="9">fine</governor>
            <dependent idx="8">was</dependent>
          </dep>
          <dep type="ccomp">
            <governor idx="6">thought</governor>
            <dependent idx="9">fine</dependent>
          </dep>
          <dep type="neg">
            <governor idx="12">used</governor>
            <dependent idx="11">never</dependent>
          </dep>
          <dep type="ccomp">
            <governor idx="6">thought</governor>
            <dependent idx="12">used</dependent>
          </dep>
          <dep type="conj_but">
            <governor idx="9">fine</governor>
            <dependent idx="12">used</dependent>
          </dep>
          <dep type="nsubj">
            <governor idx="26">tell</governor>
            <dependent idx="13">chrome</dependent>
          </dep>
          <dep type="aux">
            <governor idx="26">tell</governor>
            <dependent idx="14">can</dependent>
          </dep>
          <dep type="npadvmod">
            <governor idx="26">tell</governor>
            <dependent idx="15">someone</dependent>
          </dep>
          <dep type="prep_with">
            <governor idx="26">tell</governor>
            <dependent idx="17">experience</dependent>
          </dep>
          <dep type="prep_on">
            <governor idx="17">experience</governor>
            <dependent idx="19">either</dependent>
          </dep>
          <dep type="det">
            <governor idx="22">browsers</governor>
            <dependent idx="21">these</dependent>
          </dep>
          <dep type="prep_of">
            <governor idx="19">either</governor>
            <dependent idx="22">browsers</dependent>
          </dep>
          <dep type="det">
            <governor idx="25">mac</governor>
            <dependent idx="24">a</dependent>
          </dep>
          <dep type="prep_on">
            <governor idx="22">browsers</governor>
            <dependent idx="25">mac</dependent>
          </dep>
          <dep type="ccomp">
            <governor idx="12">used</governor>
            <dependent idx="26">tell</dependent>
          </dep>
          <dep type="iobj">
            <governor idx="26">tell</governor>
            <dependent idx="27">me</dependent>
          </dep>
          <dep type="det">
            <governor idx="29">ups</governor>
            <dependent idx="28">the</dependent>
          </dep>
          <dep type="dobj">
            <governor idx="26">tell</governor>
            <dependent idx="29">ups</dependent>
          </dep>
          <dep type="dobj">
            <governor idx="26">tell</governor>
            <dependent idx="31">downs</dependent>
          </dep>
          <dep type="conj_and">
            <governor idx="29">ups</governor>
            <dependent idx="31">downs</dependent>
          </dep>
          <dep type="prep_of">
            <governor idx="29">ups</governor>
            <dependent idx="33">them</dependent>
          </dep>
        </dependencies>
      </sentence>
      <sentence id="3">
        <tokens>
          <token id="1">
            <word>Does</word>
            <lemma>do</lemma>
            <CharacterOffsetBegin>303</CharacterOffsetBegin>
            <CharacterOffsetEnd>307</CharacterOffsetEnd>
            <POS>VBZ</POS>
          </token>
          <token id="2">
            <word>Chrome</word>
            <lemma>Chrome</lemma>
            <CharacterOffsetBegin>308</CharacterOffsetBegin>
            <CharacterOffsetEnd>314</CharacterOffsetEnd>
            <POS>NNP</POS>
          </token>
          <token id="3">
            <word>work</word>
            <lemma>work</lemma>
            <CharacterOffsetBegin>315</CharacterOffsetBegin>
            <CharacterOffsetEnd>319</CharacterOffsetEnd>
            <POS>VB</POS>
          </token>
          <token id="4">
            <word>better</word>
            <lemma>better</lemma>
            <CharacterOffsetBegin>320</CharacterOffsetBegin>
            <CharacterOffsetEnd>326</CharacterOffsetEnd>
            <POS>JJR</POS>
          </token>
          <token id="5">
            <word>than</word>
            <lemma>than</lemma>
            <CharacterOffsetBegin>327</CharacterOffsetBegin>
            <CharacterOffsetEnd>331</CharacterOffsetEnd>
            <POS>IN</POS>
          </token>
          <token id="6">
            <word>Safari</word>
            <lemma>Safari</lemma>
            <CharacterOffsetBegin>332</CharacterOffsetBegin>
            <CharacterOffsetEnd>338</CharacterOffsetEnd>
            <POS>NNP</POS>
          </token>
          <token id="7">
            <word>on</word>
            <lemma>on</lemma>
            <CharacterOffsetBegin>339</CharacterOffsetBegin>
            <CharacterOffsetEnd>341</CharacterOffsetEnd>
            <POS>IN</POS>
          </token>
          <token id="8">
            <word>a</word>
            <lemma>a</lemma>
            <CharacterOffsetBegin>342</CharacterOffsetBegin>
            <CharacterOffsetEnd>343</CharacterOffsetEnd>
            <POS>DT</POS>
          </token>
          <token id="9">
            <word>mac</word>
            <lemma>mac</lemma>
            <CharacterOffsetBegin>344</CharacterOffsetBegin>
            <CharacterOffsetEnd>347</CharacterOffsetEnd>
            <POS>NN</POS>
          </token>
          <token id="10">
            <word>?</word>
            <lemma>?</lemma>
            <CharacterOffsetBegin>347</CharacterOffsetBegin>
            <CharacterOffsetEnd>348</CharacterOffsetEnd>
            <POS>.</POS>
          </token>
        </tokens>
        <parse>(ROOT (SQ (VBZ Does) (NP (NNP Chrome)) (VP (VB work) (NP (JJR better)) (PP (IN than) (NP (NP (NNP Safari)) (PP (IN on) (NP (DT a) (NN mac)))))) (. ?))) </parse>
        <dependencies type="basic-dependencies">
          <dep type="root">
            <governor idx="0">ROOT</governor>
            <dependent idx="3">work</dependent>
          </dep>
          <dep type="aux">
            <governor idx="3">work</governor>
            <dependent idx="1">Does</dependent>
          </dep>
          <dep type="nsubj">
            <governor idx="3">work</governor>
            <dependent idx="2">Chrome</dependent>
          </dep>
          <dep type="dobj">
            <governor idx="3">work</governor>
            <dependent idx="4">better</dependent>
          </dep>
          <dep type="prep">
            <governor idx="3">work</governor>
            <dependent idx="5">than</dependent>
          </dep>
          <dep type="pobj">
            <governor idx="5">than</governor>
            <dependent idx="6">Safari</dependent>
          </dep>
          <dep type="prep">
            <governor idx="6">Safari</governor>
            <dependent idx="7">on</dependent>
          </dep>
          <dep type="det">
            <governor idx="9">mac</governor>
            <dependent idx="8">a</dependent>
          </dep>
          <dep type="pobj">
            <governor idx="7">on</governor>
            <dependent idx="9">mac</dependent>
          </dep>
        </dependencies>
        <dependencies type="collapsed-dependencies">
          <dep type="root">
            <governor idx="0">ROOT</governor>
            <dependent idx="3">work</dependent>
          </dep>
          <dep type="aux">
            <governor idx="3">work</governor>
            <dependent idx="1">Does</dependent>
          </dep>
          <dep type="nsubj">
            <governor idx="3">work</governor>
            <dependent idx="2">Chrome</dependent>
          </dep>
          <dep type="dobj">
            <governor idx="3">work</governor>
            <dependent idx="4">better</dependent>
          </dep>
          <dep type="prep_than">
            <governor idx="3">work</governor>
            <dependent idx="6">Safari</dependent>
          </dep>
          <dep type="det">
            <governor idx="9">mac</governor>
            <dependent idx="8">a</dependent>
          </dep>
          <dep type="prep_on">
            <governor idx="6">Safari</governor>
            <dependent idx="9">mac</dependent>
          </dep>
        </dependencies>
        <dependencies type="collapsed-ccprocessed-dependencies">
          <dep type="root">
            <governor idx="0">ROOT</governor>
            <dependent idx="3">work</dependent>
          </dep>
          <dep type="aux">
            <governor idx="3">work</governor>
            <dependent idx="1">Does</dependent>
          </dep>
          <dep type="nsubj">
            <governor idx="3">work</governor>
            <dependent idx="2">Chrome</dependent>
          </dep>
          <dep type="dobj">
            <governor idx="3">work</governor>
            <dependent idx="4">better</dependent>
          </dep>
          <dep type="prep_than">
            <governor idx="3">work</governor>
            <dependent idx="6">Safari</dependent>
          </dep>
          <dep type="det">
            <governor idx="9">mac</governor>
            <dependent idx="8">a</dependent>
          </dep>
          <dep type="prep_on">
            <governor idx="6">Safari</governor>
            <dependent idx="9">mac</dependent>
          </dep>
        </dependencies>
      </sentence>
    </sentences>
  </document>
</root>

redpajama_set_name: RedPajamaGithub


text:
package msdingfield.easyflow.reflect;

import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;

import msdingfield.easyflow.annotations.Input;
import msdingfield.easyflow.annotations.Operation;
import msdingfield.easyflow.annotations.Output;
import msdingfield.easyflow.reflect.support.InvalidOperationBindingException;

/** Builds a ClassOperation for an annotated class. */
public final class AnnotationClassOperationBuilder {

	/**
	 * Creates a ClassOperation for the given class.
	 *
	 * @param type A class with appropriate annotations.
	 * @return ClassOperation bound to the given class.
	 */
	public static ClassOperation fromClass(final Class<?> type) {
		if (type == null) {
			throw new InvalidOperationBindingException("Failed to build ClassOperation.  Class reference is null.");
		}

		final ClassOperation operation = new ClassOperation();
		operation.setOperationClass(type);

		operation.setConstructor(findNoArgConstructor(type));

		operation.setOperationMethod(findOperationAnnotatedMethod(type));

		for (final Field field : type.getFields()) {
			if (field.isAnnotationPresent(Input.class)) {
				operation.addInput(field);
			} else if (field.isAnnotationPresent(Output.class)) {
				operation.addOutput(field);
			}
		}

		return operation;
	}

	private static Method findOperationAnnotatedMethod(final Class<?> type) {
		for (final Method method : type.getMethods()) {
			if (method.isAnnotationPresent(Operation.class)) {
				return method;
			}
		}
		throw new InvalidOperationBindingException(String.format("Failed to build ClassOperation.  %s does not have a method annotated with @Operation.", type.getSimpleName()));
	}

	private static Constructor<?> findNoArgConstructor(final Class<?> type) {
		for (final Constructor<?> c : type.getConstructors()) {
			if (c.getParameterTypes().length == 0) {
				return c;
			}
		}
		throw new InvalidOperationBindingException(String.format("Failed to build ClassOperation.  %s does not have a default (no arg) constructor.", type.getSimpleName()));
	}

	private AnnotationClassOperationBuilder() {}
}


text:
#ifndef XLOG_DEFS_H
#define XLOG_DEFS_H

#include <fcntl.h>				/* need open() flags */

/*
 * Pointer to a location in the XLOG.  These pointers are 64 bits wide,
 * because we don't want them ever to overflow.
 */
typedef uint64 XLogRecPtr;

/*
 * Zero is used indicate an invalid pointer. Bootstrap skips the first possible
 * WAL segment, initializing the first WAL page at XLOG_SEG_SIZE, so no XLOG
 * record can begin at zero.
 */
#define InvalidXLogRecPtr	0
#define XLogRecPtrIsInvalid(r)	((r) == InvalidXLogRecPtr)

/*
 * XLogSegNo - physical log file sequence number.
 */
typedef uint64 XLogSegNo;

/*
 * TimeLineID (TLI) - identifies different database histories to prevent
 * confusion after restoring a prior state of a database installation.
 * TLI does not change in a normal stop/restart of the database (including
 * crash-and-recover cases); but we must assign a new TLI after doing
 * a recovery to a prior state, a/k/a point-in-time recovery.  This makes
 * the new WAL logfile sequence we generate distinguishable from the
 * sequence that was generated in the previous incarnation.
 */
typedef uint32 TimeLineID;

/*
 * Replication origin id - this is located in this file to avoid having to
 * include origin.h in a bunch of xlog related places.
 */
typedef uint16 RepOriginId;

/*
 *	Because O_DIRECT bypasses the kernel buffers, and because we never
 *	read those buffers except during crash recovery or if wal_level != minimal,
 *	it is a win to use it in all cases where we sync on each write().  We could
 *	allow O_DIRECT with fsync(), but it is unclear if fsync() could process
 *	writes not buffered in the kernel.  Also, O_DIRECT is never enough to force
 *	data to the drives, it merely tries to bypass the kernel cache, so we still
 *	need O_SYNC/O_DSYNC.
 */
#ifdef O_DIRECT
#define PG_O_DIRECT				O_DIRECT
#else
#define PG_O_DIRECT				0
#endif

/*
 * This chunk of hackery attempts to determine which file sync methods
 * are available on the current platform, and to choose an appropriate
 * default method.  We assume that fsync() is always available, and that
 * configure determined whether fdatasync() is.
 */
#if defined(O_SYNC)
#define OPEN_SYNC_FLAG		O_SYNC
#elif defined(O_FSYNC)
#define OPEN_SYNC_FLAG		O_FSYNC
#endif

#if defined(O_DSYNC)
#if defined(OPEN_SYNC_FLAG)
/* O_DSYNC is distinct? */
#if O_DSYNC != OPEN_SYNC_FLAG
#define OPEN_DATASYNC_FLAG		O_DSYNC
#endif
#else							/* !defined(OPEN_SYNC_FLAG) */
/* Win32 only has O_DSYNC */
#define OPEN_DATASYNC_FLAG		O_DSYNC
#endif
#endif

#if defined(PLATFORM_DEFAULT_SYNC_METHOD)
#define DEFAULT_SYNC_METHOD		PLATFORM_DEFAULT_SYNC_METHOD
#elif defined(OPEN_DATASYNC_FLAG)
#define DEFAULT_SYNC_METHOD		SYNC_METHOD_OPEN_DSYNC
#elif defined(HAVE_FDATASYNC)
#define DEFAULT_SYNC_METHOD		SYNC_METHOD_FDATASYNC
#else
#define DEFAULT_SYNC_METHOD		SYNC_METHOD_FSYNC
#endif

#endif   /* XLOG_DEFS_H */


text:
package com.ibm.ws.repository.strategies.writeable;

import java.util.List;

import com.ibm.ws.repository.common.enums.State;
import com.ibm.ws.repository.exceptions.RepositoryBackendException;
import com.ibm.ws.repository.exceptions.RepositoryBadDataException;
import com.ibm.ws.repository.exceptions.RepositoryResourceException;
import com.ibm.ws.repository.exceptions.RepositoryResourceValidationException;
import com.ibm.ws.repository.resources.internal.RepositoryResourceImpl;
import com.ibm.ws.repository.resources.internal.RepositoryResourceImpl.AttachmentResourceImpl;

/**
 * This strategy will add a new resource to the repository. It does not care if an equivalent resource exists, it will
 * always create a new (potentially duplicate) resource.
 */
public class AddNewStrategy extends BaseStrategy {

    /**
     * Delegate to super class for states
     */
    public AddNewStrategy() {}

    /**
     * Sets the desired state of the asset after uploading it
     *
     * @param desiredStateIfMatchingFound This is not used by this strategy but can be used by derived strategies
     * @param desiredStateIfNoMatchingFound Set the resource to this state after uploading. This behaviour can
     *            be changed by derived classes
     */
    public AddNewStrategy(State desiredStateIfMatchingFound, State desiredStateIfNoMatchingFound) {
        super(desiredStateIfMatchingFound, desiredStateIfNoMatchingFound);
    }

    /** {@inheritDoc} */
    @Override
    public void uploadAsset(RepositoryResourceImpl resource, List<RepositoryResourceImpl> matchingResources) throws RepositoryBackendException, RepositoryResourceException {
        // Add the asset
        resource.addAsset();

        // ... and the attachments
        for (AttachmentResourceImpl attachment : resource.getAttachmentImpls()) {
            resource.addAttachment(attachment);
        }

        // read back any fields massive added during upload
        resource.refreshFromMassive();

        // Move the resource to the desired state, use the noMatching state as matching will be null by default
        RepositoryResourceImpl firstMatch = (matchingResources == null || matchingResources.isEmpty()) ? null : matchingResources.get(0);
        resource.moveToState(getTargetState(firstMatch));
    }

    /**
     * Get the state that the resource being added should be set to once it's been uploaded
     *
     * @param matchingResource
     * @return
     */
    protected State getTargetState(RepositoryResourceImpl matchingResource) {
        return _desiredStateIfNoMatchingFound;
    }

    @Override
    public List<RepositoryResourceImpl> findMatchingResources(RepositoryResourceImpl resource) throws RepositoryResourceValidationException,
                    RepositoryBackendException, RepositoryBadDataException {
        return null;
    }
}


text:
package com.jaquadro.minecraft.storagedrawers.inventory;

import com.jaquadro.minecraft.storagedrawers.core.ModItems;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;

public class SlotUpgrade extends Slot
{
    public SlotUpgrade (IInventory inventory, int index, int x, int y) {
        super(inventory, index, x, y);
    }

    @Override
    public boolean canTakeStack (EntityPlayer player) {
        if (inventory instanceof InventoryUpgrade) {
            ItemStack stack = getStack();
            if (stack != null && stack.getItem() == ModItems.upgradeStorage)
                return ((InventoryUpgrade) inventory).canRemoveStorageUpgrade(stack.getItemDamage());
            if (player != null) {
                if (stack != null && stack.getItem() == ModItems.upgradeCreative && !player.capabilities.isCreativeMode)
                    return false;
            }
        }

        return true;
    }

    public boolean canTakeStack () {
        return canTakeStack(null);
    }
}


text:
<?php

namespace Swap\Tests\Provider;

use Swap\Model\CurrencyPair;
use Swap\Model\Rate;
use Swap\Provider\ArrayProvider;

class ArrayProviderTest extends \PHPUnit_Framework_TestCase
{
    /**
     * @test
     * @expectedException \Swap\Exception\Exception
     */
    public function it_throws_an_exception_when_rate_not_supported()
    {
        $arrayProvider = new ArrayProvider([]);
        $arrayProvider->fetchRate(CurrencyPair::createFromString('EUR/USD'));
    }

    /**
     * @test
     * @expectedException \Swap\Exception\InternalException
     * @expectedExceptionMessage Rates passed to the ArrayProvider must be Rate instances or scalars "array" given.
     */
    public function it_throws_an_exception_when_fetching_invalid_rate()
    {
        $arrayProvider = new ArrayProvider([
            'EUR/USD' => array()
        ]);

        $arrayProvider->fetchRate(CurrencyPair::createFromString('EUR/USD'));
    }

    /**
     * @test
     */
    public function it_fetches_a_rate_from_rates()
    {
        $arrayProvider = new ArrayProvider([
            'EUR/USD' => $rate = new Rate('1.50')
        ]);

        $this->assertSame($rate, $arrayProvider->fetchRate(CurrencyPair::createFromString('EUR/USD')));
    }

    /**
     * @test
     */
    public function it_fetches_a_rate_from_scalars()
    {
        $arrayProvider = new ArrayProvider([
            'EUR/USD' => 1.50,
            'USD/GBP'=> '1.25',
            'JPY/GBP' => 1
        ]);

        $eurUsd = $arrayProvider->fetchRate(CurrencyPair::createFromString('EUR/USD'));
        $usdGbp = $arrayProvider->fetchRate(CurrencyPair::createFromString('USD/GBP'));
        $jpyGbp = $arrayProvider->fetchRate(CurrencyPair::createFromString('JPY/GBP'));

        $this->assertEquals('1.50', $eurUsd->getValue());
        $this->assertEquals('1.25', $usdGbp->getValue());
        $this->assertEquals('1', $jpyGbp->getValue());
    }
}


text:
export MAVEN_REPO=$HOME/.m2/repository

export CLASS_PATH=target/sharedmq-1.0.0.jar
export CLASS_PATH=$CLASS_PATH:$MAVEN_REPO/com/google/guava/guava/19.0/guava-19.0.jar
export CLASS_PATH=$CLASS_PATH:$MAVEN_REPO/org/slf4j/slf4j-api/1.7.20/slf4j-api-1.7.20.jar
export CLASS_PATH=$CLASS_PATH:$MAVEN_REPO/ch/qos/logback/logback-core/1.1.7/logback-core-1.1.7.jar
export CLASS_PATH=$CLASS_PATH:$MAVEN_REPO/ch/qos/logback/logback-classic/1.1.7/logback-classic-1.1.7.jar

java -classpath "$CLASS_PATH" org.sharedmq.QueueTester "$@"


text:
import os
from twilio.rest import Client

# Your Account Sid and Auth Token from twilio.com/user/account
# To set up environmental variables, see http://twil.io/secure
account_sid = os.environ['TWILIO_ACCOUNT_SID']
auth_token = os.environ['TWILIO_AUTH_TOKEN']
client = Client(account_sid, auth_token)

document_permission = client.sync \
    .services("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX") \
    .documents("MyFirstDocument") \
    .document_permissions("bob") \
    .fetch()

print(document_permission.read)
print(document_permission.url)


text:
package org.elasticsearch.xpack.watcher.input.transform;

import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.xpack.core.watcher.input.Input;
import org.elasticsearch.xpack.core.watcher.transform.Transform;
import org.elasticsearch.xpack.core.watcher.watch.Payload;

import java.io.IOException;
import java.util.Objects;

/**
 * The Transform Input allows to configure a transformation, that should be
 * put between two other inputs in a chained input in order to support easy
 * data transformations
 *
 * This class does not have a builder, as it just consists of a single
 * transform
 */
public class TransformInput implements Input {

    public static final String TYPE = "transform";

    private final Transform transform;

    public TransformInput(Transform transform) {
        this.transform = transform;
    }

    public Transform getTransform() {
        return transform;
    }

    @Override
    public String type() {
        return TYPE;
    }

    @Override
    public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
        builder.startObject().field(transform.type(), transform, params).endObject();
        return builder;
    }

    @Override
    public int hashCode() {
        return transform.hashCode();
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        TransformInput that = (TransformInput) o;

        return Objects.equals(transform, that.transform);
    }

    static class Result extends Input.Result {

        Result(Payload payload) {
            super(TYPE, payload);
        }

        @Override
        protected XContentBuilder typeXContent(XContentBuilder builder, Params params) throws IOException {
            return builder;
        }
    }
}


text:
namespace riakboost{} namespace boost = riakboost; namespace riakboost{

//
//  shared_array
//
//  shared_array extends shared_ptr to arrays.
//  The array pointed to is deleted when the last shared_array pointing to it
//  is destroyed or reset.
//

template<class T> class shared_array
{
private:

    // Borland 5.5.1 specific workarounds
    typedef checked_array_deleter<T> deleter;
    typedef shared_array<T> this_type;

public:

    typedef T element_type;

    explicit shared_array(T * p = 0): px(p), pn(p, deleter())
    {
    }

    //
    // Requirements: D's copy constructor must not throw
    //
    // shared_array will release p by calling d(p)
    //

    template<class D> shared_array(T * p, D d): px(p), pn(p, d)
    {
    }

//  generated copy constructor, assignment, destructor are fine

    void reset(T * p = 0)
    {
        BOOST_ASSERT(p == 0 || p != px);
        this_type(p).swap(*this);
    }

    template <class D> void reset(T * p, D d)
    {
        this_type(p, d).swap(*this);
    }

    T & operator[] (std::ptrdiff_t i) const // never throws
    {
        BOOST_ASSERT(px != 0);
        BOOST_ASSERT(i >= 0);
        return px[i];
    }

    T * get() const // never throws
    {
        return px;
    }

// implicit conversion to "bool"
#include <boost/smart_ptr/detail/operator_bool.hpp>

    bool unique() const // never throws
    {
        return pn.unique();
    }

    long use_count() const // never throws
    {
        return pn.use_count();
    }

    void swap(shared_array<T> & other) // never throws
    {
        std::swap(px, other.px);
        pn.swap(other.pn);
    }

private:

    T * px;                     // contained pointer
    detail::shared_count pn;    // reference counter

};  // shared_array

template<class T> inline bool operator==(shared_array<T> const & a, shared_array<T> const & b) // never throws
{
    return a.get() == b.get();
}

template<class T> inline bool operator!=(shared_array<T> const & a, shared_array<T> const & b) // never throws
{
    return a.get() != b.get();
}

template<class T> inline bool operator<(shared_array<T> const & a, shared_array<T> const & b) // never throws
{
    return std::less<T*>()(a.get(), b.get());
}

template<class T> void swap(shared_array<T> & a, shared_array<T> & b) // never throws
{
    a.swap(b);
}

} // namespace riakboost

#endif  // #if defined(BOOST_NO_MEMBER_TEMPLATES) && !defined(BOOST_MSVC6_MEMBER_TEMPLATES)

#endif  // #ifndef BOOST_SMART_PTR_SHARED_ARRAY_HPP_INCLUDED


text:
<!DOCTYPE html>

  <link rel="preload" href="/lib/font-awesome/webfonts/fa-brands-400.woff2" as="font" type="font/woff2" crossorigin="anonymous">
  <link rel="preload" href="/lib/font-awesome/webfonts/fa-regular-400.woff2" as="font" type="font/woff2" crossorigin="anonymous">
  <link rel="preload" href="/lib/font-awesome/webfonts/fa-solid-900.woff2" as="font" type="font/woff2" crossorigin="anonymous">
  <link rel="preload" href="/lib/JetBrainsMono/web/woff2/JetBrainsMono-Regular.woff2" as="font" type="font/woff2" crossorigin="anonymous">

  <link rel="stylesheet" href="https://latest.cactus.chat/style.css" type="text/css">
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>Blake Boswell</title>
  <link rel = 'canonical' href = 'https://blakeboswell.github.io/categories/'>
  <meta name="description" content="Portfolio of data and computing projects.">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta name="robots" content="all,follow">
  <meta name="googlebot" content="index,follow,snippet,archive">
  <meta property="og:title" content="Categories" />
<meta property="og:description" content="Portfolio of data and computing projects." />
<meta property="og:type" content="website" />
<meta property="og:url" content="https://blakeboswell.github.io/categories/" />

  <meta name="twitter:card" content="summary"/>
<meta name="twitter:title" content="Categories"/>
<meta name="twitter:description" content="Portfolio of data and computing projects."/>

  <link rel="stylesheet" href="https://blakeboswell.github.io/css/styles.632620e059692bffaf78827d1f53cc67e7fef686a40c28942bd5410aa83e01ad246a9137dc56c64461047231f5670974e1e662d76f4c93ad48a8983af8845bc5.css" integrity="sha512-YyYg4FlpK/+veIJ9H1PMZ+f+9oakDCiUK9VBCqg+Aa0kapE33FbGRGEEcjH1Zwl04eZi129Mk61IqJg6+IRbxQ==">

<link rel="icon" type="image/png" href="https://blakeboswell.github.io/images/favicon.ico" />

Blake Boswell

          No categories

    Copyright  © 2021  Blake Boswell

<link rel="stylesheet" href=/lib/font-awesome/css/all.min.css>