text:
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

namespace IxMilia.Dxf
{
    internal class DxfBinaryReader : IDxfCodePairReader
    {
        private BinaryReader _reader;
        private bool _returnedCodePairs;
        private bool _isPostR13File;

        public DxfBinaryReader(BinaryReader reader, int readBytes)
        {
            _reader = reader;
            _totalBytesRead = readBytes;
        }

        /// <summary>
        /// Test-only constructor.
        /// </summary>
        internal DxfBinaryReader(BinaryReader reader, bool isPostR13File)
            : this(reader, 0)
        {
            _isPostR13File = isPostR13File;
        }

        public IEnumerable<DxfCodePair> GetCodePairs()
        {
            DxfCodePair pair;
            while ((pair = GetCodePair()) != null)
            {
                _returnedCodePairs = true;
                yield return pair;
            }
        }

        public void SetReaderEncoding(Encoding _encoding)
        {
            // noop
        }

        internal DxfCodePair GetCodePair()
        {
            var codeOffset = _totalBytesRead + _miniBufferStart;
            int code;
            if (!TryReadCode(out code))
            {
                return null;
            }

            var expectedType = DxfCodePair.ExpectedType(code);
            DxfCodePair pair;
            if (expectedType == typeof(short))
            {
                short s;
                if (!TryReadInt16(out s))
                {
                    return null;
                }

                pair = new DxfCodePair(code, s);
            }
            else if (expectedType == typeof(double))
            {
                double d;
                if (!TryReadDouble(out d))
                {
                    return null;
                }

                pair = new DxfCodePair(code, d);
            }
            else if (expectedType == typeof(int))
            {
                int i;
                if (!TryReadInt32(out i))
                {
                    return null;
                }

                pair = new DxfCodePair(code, i);
            }
            else if (expectedType == typeof(long))
            {
                long l;
                if (!TryReadInt64(out l))
                {
                    return null;
                }

                pair = new DxfCodePair(code, l);
            }
            else if (expectedType == typeof(string))
            {
                var sb = new StringBuilder();
                byte b;
                for (; TryReadByte(out b) && b != 0;)
                {
                    sb.Append((char)b);
                }

                pair = new DxfCodePair(code, sb.ToString());
            }
            else if (expectedType == typeof(bool))
            {
                if (_isPostR13File)
                {
                    // after R13 bools are encoded as a single byte
                    if (!TryReadByte(out var value))
                    {
                        return null;
                    }

                    pair = new DxfCodePair(code, value != 0);
                }
                else
                {
                    if (!TryReadInt16(out var value))
                    {
                        return null;
                    }

                    pair = DxfCodePair.IsPotentialShortAsBool(code)
                        ? new DxfCodePair(code, value)
                        : new DxfCodePair(code, value != 0);
                }
            }
            else if (expectedType == typeof(byte[]))
            {
                if (!TryReadByte(out var length))
                {
                    return null;
                }

                if (!TryReadBytes(length, out var data))
                {
                    return null;
                }

                pair = new DxfCodePair(code, data);
            }
            else
            {
                throw new DxfReadException("Unsupported code " + code, codeOffset);
            }

            pair.Offset = codeOffset;
            return pair;
        }

        private bool TryReadCode(out int code)
        {
            // read the first byte
            code = default(int);
            byte b;
            if (!TryReadByte(out b))
            {
                return false;
            }

            code = b;

            if (!_returnedCodePairs && code == 0 && TryPeekByte(out var nextByte) && nextByte == 0x00)
            {
                // The first code/pair in a binary file must be `0/SECTION`; if we're reading the first pair, the code
                // is `0`, and the next byte is NULL (empty string), then this must be a post R13 file where codes are
                // always encoded with 2 bytes.
                _isPostR13File = true;
            }

            // potentially read the second byte of the code
            if (_isPostR13File)
            {
                if (!TryReadByte(out var b2))
                {
                    return false;
                }

                code = CreateShort(b, b2);
            }
            else if (code == 255)
            {
                if (!TryReadInt16(out var extendedCode))
                {
                    return false;
                }

                code = extendedCode;
            }

            return true;
        }

        // Since we can't reliably call `_reader.BaseStream.Position` and `.Length`, we instead use the `Stream.Read(byte[], int, int)`
        // method to continually fill a local buffer.
        byte[] _miniBuffer = new byte[8];
        int _miniBufferStart = 0;
        int _miniBufferEnd = 0;
        int _totalBytesRead = 0;
        byte[] _dataBuffer = new byte[8];

        private bool TryPeekByte(out byte result)
        {
            if (_miniBufferEnd - _miniBufferStart < 1)
            {
                _totalBytesRead += _miniBufferEnd;
                _miniBufferStart = 0;
                _miniBufferEnd = _reader.BaseStream.Read(_miniBuffer, 0, _miniBuffer.Length);
            }

            if (_miniBufferEnd == 0)
            {
                result = default(byte);
                return false;
            }

            result = _miniBuffer[_miniBufferStart];
            return true;
        }

        private bool TryReadByte(out byte result)
        {
            if (TryPeekByte(out result))
            {
                _miniBufferStart++;
                return true;
            }

            return false;
        }

        private bool TryReadBytes(int count, out byte[] result)
        {
            result = new byte[count];
            for (int i = 0; i < count; i++)
            {
                if (!TryReadByte(out var value))
                {
                    return false;
                }

                result[i] = value;
            }

            return true;
        }

        private short CreateShort(byte b1, byte b2)
        {
            _dataBuffer[0] = b1;
            _dataBuffer[1] = b2;
            return BitConverter.ToInt16(_dataBuffer, 0);
        }

        private bool TryReadInt16(out short result)
        {
            if (TryReadByte(out var b1) && TryReadByte(out var b2))
            {
                result = CreateShort(b1, b2);
                return true;
            }

            result = default(short);
            return false;
        }

        private bool TryReadInt32(out int result)
        {
            if (TryReadByte(out _dataBuffer[0]) && TryReadByte(out _dataBuffer[1]) &&
                TryReadByte(out _dataBuffer[2]) && TryReadByte(out _dataBuffer[3]))
            {
                result = BitConverter.ToInt32(_dataBuffer, 0);
                return true;
            }

            result = default(int);
            return false;
        }

        private bool TryReadInt64(out long result)
        {
            if (TryReadByte(out _dataBuffer[0]) && TryReadByte(out _dataBuffer[1]) &&
                TryReadByte(out _dataBuffer[2]) && TryReadByte(out _dataBuffer[3]) &&
                TryReadByte(out _dataBuffer[4]) && TryReadByte(out _dataBuffer[5]) &&
                TryReadByte(out _dataBuffer[6]) && TryReadByte(out _dataBuffer[7]))
            {
                result = BitConverter.ToInt64(_dataBuffer, 0);
                return true;
            }

            result = default(long);
            return false;
        }

        private bool TryReadDouble(out double result)
        {
            if (TryReadByte(out _dataBuffer[0]) && TryReadByte(out _dataBuffer[1]) &&
                TryReadByte(out _dataBuffer[2]) && TryReadByte(out _dataBuffer[3]) &&
                TryReadByte(out _dataBuffer[4]) && TryReadByte(out _dataBuffer[5]) &&
                TryReadByte(out _dataBuffer[6]) && TryReadByte(out _dataBuffer[7]))
            {
                result = BitConverter.ToDouble(_dataBuffer, 0);
                return true;
            }

            result = default(double);
            return false;
        }
    }
}


text:
    This example shows how the random pseudo random number generator module is used.
--]]
local random = assert(require("poco.random"))

-- explicit construction using state_size, and a seed value
-- local prng = assert(random(256, os.time()))

-- explicit construction using just state_size and default internal Poco RandomInputStream seed.
-- local prng = assert(random(256))

-- construction using default state_size of 256 and internal Poco RandomInputStream seed.
local prng = assert(random())

-- generate some random numbers.
for i = 1, 15 do
    print("\ninteger: ", prng:next())
    print("modulo 100: ", prng:next(100))
    print("number: ", prng:nextNumber())
    print("byte: ", prng:nextByte())
    print("bool: ", prng:nextBool())
end

redpajama_set_name: RedPajamaGithub


text:
#ifndef _SCIF_TASK_REQUEST_H_
#define _SCIF_TASK_REQUEST_H_

/**
 * @file
 *
 * @brief This file contains the structures and interface methods that
 *        can be referenced and used by the SCI user for the SCI task
 *        management request object.
 */

#ifdef __cplusplus
extern "C" {
#endif // __cplusplus

#include <dev/isci/scil/sci_types.h>
#include <dev/isci/scil/sci_status.h>

/**
 * @brief This method simply returns the size required to construct an SCI
 *        based task request object (includes core & framework object size).
 *
 * @return Retrun the size of the SCI task request object.
 */
U32 scif_task_request_get_object_size(
   void
);

/**
 * @brief This method is called by the SCIF user to construct a task
 *        management request.  This method will construct a SCIC task request
 *        internally.
 *
 * @note  The SCI framework implementation will create an association between
 *        the user task request object and the framework task request object.
 *
 * @param[in]  scif_controller the handle to the framework controller object
 *             for which to build an IO request.
 * @param[in]  scif_remote_device This parameter specifies the framework
 *             remote device with which this task request is to be associated.
 * @param[in]  io_tag This parameter specifies the IO tag to be associated
 *             with this request.  If SCI_CONTROLLER_INVALID_IO_TAG is
 *             passed, then a copy of the request is built internally.  The
 *             request will be copied into the actual controller request
 *             memory when the IO tag is allocated internally during the
 *             scif_controller_start_task() method.
 * @param[in]  user_task_request_object This parameter specifies the user
 *             task request to be utilized during task construction.  This task
 *             pointer will become the associated object for the framework
 *             task request object.
 * @param[in]  task_request_memory This parameter specifies the memory
 *             to be utilized in the construction of the framework task request.
 * @param[in]  scif_task_request This parameter specifies the handle to be
 *             utilized for all further interactions with this task request
 *             object.
 *
 * @return Indicate if the controller successfully built the task request.
 * @retval SCI_SUCCESS This value is returned if the task request was
 *         successfully built.
 */
SCI_STATUS scif_task_request_construct(
   SCI_CONTROLLER_HANDLE_T      scif_controller,
   SCI_REMOTE_DEVICE_HANDLE_T   scif_remote_device,
   U16                          io_tag,
   void                       * user_task_request_object,
   void                       * task_request_memory,
   SCI_TASK_REQUEST_HANDLE_T  * scif_task_request
);

#ifdef __cplusplus
}
#endif // __cplusplus

#endif // _SCIF_TASK_REQUEST_H_


text:
package com.stvn.nscreen.vod;

import android.app.Activity;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Typeface;
import android.os.Bundle;
import android.app.Fragment;
import android.support.v7.app.AlertDialog;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.TextView;

import com.jjiya.android.common.Constants;
import com.jjiya.android.common.IOnBackPressedListener;
import com.jjiya.android.common.JYSharedPreferences;
import com.stvn.nscreen.MainActivity;
import com.stvn.nscreen.R;
import com.stvn.nscreen.leftmenu.LeftMenuActivity;
import com.stvn.nscreen.search.SearchMainActivity;
import com.stvn.nscreen.setting.CMSettingMainActivity;
import com.stvn.nscreen.util.CMAlertUtil;

/**
 * A simple {@link Fragment} subclass.
 */

public class VodMainBaseFragment extends Fragment implements IOnBackPressedListener {

    //private static VodMainBaseFragment mInstance;
    private static Context             mContext;
    private        JYSharedPreferences mPref;

    private boolean isLeftMenuShow = false;

    // UI
    private int iMyTabNumber;
    public TextView mTab1TextView, textView2, textView3, textView4, textView5;
    View lineview1, lineview2, lineview3, lineview4, lineview5;
    ImageButton leftImageButton, rightImageButton;

    public VodMainBaseFragment() {
        // Required empty public constructor
        iMyTabNumber = 0;
    }

    public void setMyContext(Context c){
        this.mContext = c;
        mPref = new JYSharedPreferences(c);
    }

    public int getiMyTabNumber() {
        return iMyTabNumber;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.fragment_vod_main_base, container, false);

        //mInstance = this;
        //mPref = new JYSharedPreferences(mInstance.getActivity());
        this.isLeftMenuShow = false;
        return view;
    }

    @Override
    public void onAttach(Activity activity) {
        super.onAttach(activity);
        ((MainActivity)activity).setOnBackPressedListener(this);
    }

    @Override
    public void onResume() {
        super.onResume();
        this.isLeftMenuShow = false;
    }

    /**
     * VOD 메인의 공통 화면 UI 설정
     */
    public View initializeBaseView(View view, int iTabNumber) {

        iMyTabNumber = iTabNumber;

        mTab1TextView = (TextView) view.findViewById(R.id.vod_fragment_topmenu_textView1);
        textView2 = (TextView) view.findViewById(R.id.vod_fragment_topmenu_textView2);
        textView3 = (TextView) view.findViewById(R.id.vod_fragment_topmenu_textView3);
        textView4 = (TextView) view.findViewById(R.id.vod_fragment_topmenu_textView4);
        textView5 = (TextView) view.findViewById(R.id.vod_fragment_topmenu_textView5);

        lineview1 = (View) view.findViewById(R.id.vod_fragment_topmenu_lineview1);
        lineview2 = (View) view.findViewById(R.id.vod_fragment_topmenu_lineview2);
        lineview3 = (View) view.findViewById(R.id.vod_fragment_topmenu_lineview3);
        lineview4 = (View) view.findViewById(R.id.vod_fragment_topmenu_lineview4);
        lineview5 = (View) view.findViewById(R.id.vod_fragment_topmenu_lineview5);

        mTab1TextView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                mTab1TextView.setTypeface(null, Typeface.BOLD);
                textView2.setTypeface(null, Typeface.NORMAL);
                textView3.setTypeface(null, Typeface.NORMAL);
                textView4.setTypeface(null, Typeface.NORMAL);
                textView5.setTypeface(null, Typeface.NORMAL);
                mTab1TextView.setTextColor(getResources().getColor(R.color.white));
                textView2.setTextColor(getResources().getColor(R.color.violet_topmenu_unselected));
                textView3.setTextColor(getResources().getColor(R.color.violet_topmenu_unselected));
                textView4.setTextColor(getResources().getColor(R.color.violet_topmenu_unselected));
                textView5.setTextColor(getResources().getColor(R.color.violet_topmenu_unselected));
                lineview1.setBackgroundColor(getResources().getColor(R.color.white));
                lineview2.setBackgroundColor(getResources().getColor(R.color.transparent));
                lineview3.setBackgroundColor(getResources().getColor(R.color.transparent));
                lineview4.setBackgroundColor(getResources().getColor(R.color.transparent));
                lineview5.setBackgroundColor(getResources().getColor(R.color.transparent));

                Bundle param = new Bundle();
                param.putString("tabId", "0");
                FragmentManager fm = getFragmentManager();
                FragmentTransaction ft = fm.beginTransaction();
                VodMainFirstTabFragment df = new VodMainFirstTabFragment();
                df.setArguments(param);
                ft.replace(R.id.fragment_placeholder, df, "CurrentFragment");
                ft.commit();
            }
        });

        textView2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mTab1TextView.setTypeface(null, Typeface.NORMAL);
                textView2.setTypeface(null, Typeface.BOLD);
                textView3.setTypeface(null, Typeface.NORMAL);
                textView4.setTypeface(null, Typeface.NORMAL);
                textView5.setTypeface(null, Typeface.NORMAL);
                mTab1TextView.setTextColor(getResources().getColor(R.color.violet_topmenu_unselected));
                textView2.setTextColor(getResources().getColor(R.color.white));
                textView3.setTextColor(getResources().getColor(R.color.violet_topmenu_unselected));
                textView4.setTextColor(getResources().getColor(R.color.violet_topmenu_unselected));
                textView5.setTextColor(getResources().getColor(R.color.violet_topmenu_unselected));
                lineview1.setBackgroundColor(getResources().getColor(R.color.transparent));
                lineview2.setBackgroundColor(getResources().getColor(R.color.white));
                lineview3.setBackgroundColor(getResources().getColor(R.color.transparent));
                lineview4.setBackgroundColor(getResources().getColor(R.color.transparent));
                lineview5.setBackgroundColor(getResources().getColor(R.color.transparent));

                String categoryId = mPref.getValue(Constants.CATEGORY_ID_TAB2, "");
                String categoryIdFromVodMain = mPref.getValue(JYSharedPreferences.VOD_OTHER_TAB_CATEGORY_ID, "");
                if (categoryIdFromVodMain.length() > 0) {
                    mPref.put(JYSharedPreferences.VOD_OTHER_TAB_CATEGORY_ID, "");
                    categoryId = categoryIdFromVodMain;
                }
                Bundle param = new Bundle();
                param.putString("tabId", "1"); // movie
                param.putString("categoryId", categoryId);
                FragmentManager fm = getFragmentManager();
                FragmentTransaction ft = fm.beginTransaction();
                VodMainOtherTabFragment otherTabFragment = new VodMainOtherTabFragment();
                otherTabFragment.setArguments(param);
                ft.replace(R.id.fragment_placeholder, otherTabFragment, "CurrentFragment");
                ft.commit();
            }
        });
        textView3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mTab1TextView.setTypeface(null, Typeface.NORMAL);
                textView2.setTypeface(null, Typeface.NORMAL);
                textView3.setTypeface(null, Typeface.BOLD);
                textView4.setTypeface(null, Typeface.NORMAL);
                textView5.setTypeface(null, Typeface.NORMAL);
                mTab1TextView.setTextColor(getResources().getColor(R.color.violet_topmenu_unselected));
                textView2.setTextColor(getResources().getColor(R.color.violet_topmenu_unselected));
                textView3.setTextColor(getResources().getColor(R.color.white));
                textView4.setTextColor(getResources().getColor(R.color.violet_topmenu_unselected));
                textView5.setTextColor(getResources().getColor(R.color.violet_topmenu_unselected));
                lineview1.setBackgroundColor(getResources().getColor(R.color.transparent));
                lineview2.setBackgroundColor(getResources().getColor(R.color.transparent));
                lineview3.setBackgroundColor(getResources().getColor(R.color.white));
                lineview4.setBackgroundColor(getResources().getColor(R.color.transparent));
                lineview5.setBackgroundColor(getResources().getColor(R.color.transparent));

                String categoryId = mPref.getValue(Constants.CATEGORY_ID_TAB3, "");
                String categoryIdFromVodMain = mPref.getValue(JYSharedPreferences.VOD_OTHER_TAB_CATEGORY_ID, "");
                if (categoryIdFromVodMain.length() > 0) {
                    mPref.put(JYSharedPreferences.VOD_OTHER_TAB_CATEGORY_ID, "");
                    categoryId = categoryIdFromVodMain;
                }
                Bundle param = new Bundle();
                param.putString("tabId", "2"); // ani
                param.putString("categoryId", categoryId);
                FragmentManager fm = getFragmentManager();
                FragmentTransaction ft = fm.beginTransaction();
                VodMainOtherTabFragment otherTabFragment = new VodMainOtherTabFragment();
                otherTabFragment.setArguments(param);
                ft.replace(R.id.fragment_placeholder, otherTabFragment, "CurrentFragment");
                ft.commit();
            }
        });
        textView4.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mTab1TextView.setTypeface(null, Typeface.NORMAL);
                textView2.setTypeface(null, Typeface.NORMAL);
                textView3.setTypeface(null, Typeface.NORMAL);
                textView4.setTypeface(null, Typeface.BOLD);
                textView5.setTypeface(null, Typeface.NORMAL);
                mTab1TextView.setTextColor(getResources().getColor(R.color.violet_topmenu_unselected));
                textView2.setTextColor(getResources().getColor(R.color.violet_topmenu_unselected));
                textView3.setTextColor(getResources().getColor(R.color.violet_topmenu_unselected));
                textView4.setTextColor(getResources().getColor(R.color.white));
                textView5.setTextColor(getResources().getColor(R.color.violet_topmenu_unselected));
                lineview1.setBackgroundColor(getResources().getColor(R.color.transparent));
                lineview2.setBackgroundColor(getResources().getColor(R.color.transparent));
                lineview3.setBackgroundColor(getResources().getColor(R.color.transparent));
                lineview4.setBackgroundColor(getResources().getColor(R.color.white));
                lineview5.setBackgroundColor(getResources().getColor(R.color.transparent));

                String categoryId = mPref.getValue(Constants.CATEGORY_ID_TAB4, "");
                String categoryIdFromVodMain = mPref.getValue(JYSharedPreferences.VOD_OTHER_TAB_CATEGORY_ID, "");
                if (categoryIdFromVodMain.length() > 0) {
                    mPref.put(JYSharedPreferences.VOD_OTHER_TAB_CATEGORY_ID, "");
                    categoryId = categoryIdFromVodMain;
                }
                Bundle param = new Bundle();
                param.putString("tabId", "3"); // tv
                param.putString("categoryId", categoryId);
                FragmentManager fm = getFragmentManager();
                FragmentTransaction ft = fm.beginTransaction();
                VodMainOtherTabFragment otherTabFragment = new VodMainOtherTabFragment();
                otherTabFragment.setArguments(param);
                ft.replace(R.id.fragment_placeholder, otherTabFragment, "CurrentFragment");
                ft.commit();
            }
        });
        textView5.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                if (mPref.isAdultVerification() == false) {
                    String alertTitle = "성인인증 필요";
                    String alertMsg1 = getString(R.string.error_not_adult1);
                    String alertMsg2 = getString(R.string.error_not_adult2);
                    CMAlertUtil.Alert1(getActivity(), alertTitle, alertMsg1, alertMsg2, false, true, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            Intent intent = new Intent(mContext, CMSettingMainActivity.class);
                            startActivity(intent);
                        }
                    }, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {

                        }
                    });
                } else {

                    mTab1TextView.setTypeface(null, Typeface.NORMAL);
                    textView2.setTypeface(null, Typeface.NORMAL);
                    textView3.setTypeface(null, Typeface.NORMAL);
                    textView4.setTypeface(null, Typeface.NORMAL);
                    textView5.setTypeface(null, Typeface.BOLD);
                    mTab1TextView.setTextColor(getResources().getColor(R.color.violet_topmenu_unselected));
                    textView2.setTextColor(getResources().getColor(R.color.violet_topmenu_unselected));
                    textView3.setTextColor(getResources().getColor(R.color.violet_topmenu_unselected));
                    textView4.setTextColor(getResources().getColor(R.color.violet_topmenu_unselected));
                    textView5.setTextColor(getResources().getColor(R.color.white));
                    lineview1.setBackgroundColor(getResources().getColor(R.color.transparent));
                    lineview2.setBackgroundColor(getResources().getColor(R.color.transparent));
                    lineview3.setBackgroundColor(getResources().getColor(R.color.transparent));
                    lineview4.setBackgroundColor(getResources().getColor(R.color.transparent));
                    lineview5.setBackgroundColor(getResources().getColor(R.color.white));

                    String categoryId = mPref.getValue(Constants.CATEGORY_ID_TAB5, "");
                    String categoryIdFromVodMain = mPref.getValue(JYSharedPreferences.VOD_OTHER_TAB_CATEGORY_ID, "");
                    if ( categoryIdFromVodMain.length() > 0 ) {
                        mPref.put(JYSharedPreferences.VOD_OTHER_TAB_CATEGORY_ID, "");
                        categoryId = categoryIdFromVodMain;
                    }
                    Bundle param = new Bundle();
                    param.putString("tabId", "4"); // adult
                    param.putString("categoryId", categoryId);
                    FragmentManager fm = getFragmentManager();
                    FragmentTransaction ft = fm.beginTransaction();
                    VodMainOtherTabFragment otherTabFragment = new VodMainOtherTabFragment();
                    otherTabFragment.setArguments(param);
                    ft.replace(R.id.fragment_placeholder, otherTabFragment, "CurrentFragment");
                    ft.commit();
                }
            }
        });

        leftImageButton = (ImageButton) view.findViewById(R.id.vod_fragment_topmenu_left_imagebutton);
        leftImageButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (isLeftMenuShow == false) {
                    isLeftMenuShow = true;
                    Intent intent = new Intent(getActivity(), LeftMenuActivity.class);
                    getActivity().startActivityForResult(intent, MainActivity.Result_LeftMenu_Code);
                }
            }
        });

        rightImageButton = (ImageButton) view.findViewById(R.id.vod_fragment_topmenu_right_imagebutton);
        rightImageButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getActivity(), SearchMainActivity.class);
                startActivity(intent);
            }
        });

        changeTabUI();

        return view;
    }

    private void changeTabUI() {
        mTab1TextView.setTypeface(null, Typeface.NORMAL);
        textView2.setTypeface(null, Typeface.NORMAL);
        textView3.setTypeface(null, Typeface.NORMAL);
        textView4.setTypeface(null, Typeface.NORMAL);
        textView5.setTypeface(null, Typeface.NORMAL);
        mTab1TextView.setTextColor(getResources().getColor(R.color.violet_topmenu_unselected));
        textView2.setTextColor(getResources().getColor(R.color.violet_topmenu_unselected));
        textView3.setTextColor(getResources().getColor(R.color.violet_topmenu_unselected));
        textView4.setTextColor(getResources().getColor(R.color.violet_topmenu_unselected));
        textView5.setTextColor(getResources().getColor(R.color.violet_topmenu_unselected));
        lineview1.setBackgroundColor(getResources().getColor(R.color.transparent));
        lineview2.setBackgroundColor(getResources().getColor(R.color.transparent));
        lineview3.setBackgroundColor(getResources().getColor(R.color.transparent));
        lineview4.setBackgroundColor(getResources().getColor(R.color.transparent));
        lineview5.setBackgroundColor(getResources().getColor(R.color.transparent));

        switch ( iMyTabNumber ) {
            case 0: {
                mTab1TextView.setTypeface(null, Typeface.BOLD);
                mTab1TextView.setTextColor(getResources().getColor(R.color.white));
                lineview1.setBackgroundColor(getResources().getColor(R.color.white));
            } break;
            case 1: {
                textView2.setTypeface(null, Typeface.BOLD);
                textView2.setTextColor(getResources().getColor(R.color.white));
                lineview2.setBackgroundColor(getResources().getColor(R.color.white));
            } break;
            case 2: {
                textView3.setTypeface(null, Typeface.BOLD);
                textView3.setTextColor(getResources().getColor(R.color.white));
                lineview3.setBackgroundColor(getResources().getColor(R.color.white));
            } break;
            case 3: {
                textView4.setTypeface(null, Typeface.BOLD);
                textView4.setTextColor(getResources().getColor(R.color.white));
                lineview4.setBackgroundColor(getResources().getColor(R.color.white));
            } break;
            case 4: {
                textView5.setTypeface(null, Typeface.BOLD);
                textView5.setTextColor(getResources().getColor(R.color.white));
                lineview5.setBackgroundColor(getResources().getColor(R.color.white));
            } break;
        }
    }

    @Override
    public void onBackPressedCallback() { }
}


text:
/**
 * {@link org.javasimon.callback.Callback} is an event listener registered with the {@link org.javasimon.Manager},
 * listening for manager or Simon events. Any number of callbacks can be registered on a manager using
 * {@link org.javasimon.Manager#callback()} and {@link org.javasimon.callback.CompositeCallback#addCallback(Callback)}.
 *

 * Non-composite callbacks are used to perform expected actions for particular events.
 * {@link org.javasimon.callback.CallbackSkeleton} can be extended if only selected events are desired to be
 * implemented instead of implementating the whole {@link org.javasimon.callback.Callback} interface.
 *

 * Composite callbacks are used to organize other callbacks in trees and then to delegate all events to them.
 * It is not recommended to mix composite callbacks with functionality, generally it should not be necessary to implement
 * composite callbacks in addition to the following two provided implementations:
 *

 *
{@link org.javasimon.callback.CompositeCallbackImpl} delegates all events to all sub-callbacks
 *     (used in {@link org.javasimon.EnabledManager} for instance);

 *
{@link org.javasimon.callback.CompositeFilterCallback} allows to filter events that should be propagated to the sub-callbacks,
 *     filter rules can be added using
 *     {@link org.javasimon.callback.FilterCallback#addRule(org.javasimon.callback.FilterRule.Type, String, String, org.javasimon.callback.Callback.Event...)}.

 *

 */
package org.javasimon.callback;


text:
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Formatting;
using System;
using System.Collections.Generic;
using System.Linq;

namespace CodeCracker
{
    public static class CSharpAnalyzerExtensions
    {
        public static void RegisterSyntaxNodeAction<TLanguageKindEnum>(this AnalysisContext context, LanguageVersion greaterOrEqualThanLanguageVersion,
        Action<SyntaxNodeAnalysisContext> action, params TLanguageKindEnum[] syntaxKinds) where TLanguageKindEnum : struct =>
            context.RegisterCompilationStartAction(greaterOrEqualThanLanguageVersion, compilationContext => compilationContext.RegisterSyntaxNodeAction(action, syntaxKinds));

        public static void RegisterCompilationStartAction(this AnalysisContext context, LanguageVersion greaterOrEqualThanLanguageVersion, Action<CompilationStartAnalysisContext> registrationAction) =>
            context.RegisterCompilationStartAction(compilationContext => compilationContext.RunIfCSharpVersionOrGreater(greaterOrEqualThanLanguageVersion, () => registrationAction?.Invoke(compilationContext)));
#pragma warning disable RS1012
        private static void RunIfCSharpVersionOrGreater(this CompilationStartAnalysisContext context, LanguageVersion greaterOrEqualThanLanguageVersion, Action action) =>
            context.Compilation.RunIfCSharpVersionOrGreater(action, greaterOrEqualThanLanguageVersion);
#pragma warning restore RS1012
        private static void RunIfCSharpVersionOrGreater(this Compilation compilation, Action action, LanguageVersion greaterOrEqualThanLanguageVersion) =>
            (compilation as CSharpCompilation)?.LanguageVersion.RunIfCSharpVersionGreater(action, greaterOrEqualThanLanguageVersion);

        private static void RunIfCSharpVersionGreater(this LanguageVersion languageVersion, Action action, LanguageVersion greaterOrEqualThanLanguageVersion)
        {
            if (languageVersion >= greaterOrEqualThanLanguageVersion) action?.Invoke();
        }

        public static void RegisterSyntaxNodeActionForVersionLower<TLanguageKindEnum>(this AnalysisContext context, LanguageVersion lowerThanLanguageVersion,
        Action<SyntaxNodeAnalysisContext> action, params TLanguageKindEnum[] syntaxKinds) where TLanguageKindEnum : struct =>
            context.RegisterCompilationStartActionForVersionLower(lowerThanLanguageVersion, compilationContext => compilationContext.RegisterSyntaxNodeAction(action, syntaxKinds));

        public static void RegisterCompilationStartActionForVersionLower(this AnalysisContext context, LanguageVersion lowerThanLanguageVersion, Action<CompilationStartAnalysisContext> registrationAction) =>
            context.RegisterCompilationStartAction(compilationContext => compilationContext.RunIfCSharpVersionLower(lowerThanLanguageVersion, () => registrationAction?.Invoke(compilationContext)));
#pragma warning disable RS1012
        private static void RunIfCSharpVersionLower(this CompilationStartAnalysisContext context, LanguageVersion lowerThanLanguageVersion, Action action) =>
            context.Compilation.RunIfCSharpVersionLower(action, lowerThanLanguageVersion);
#pragma warning restore RS1012
        private static void RunIfCSharpVersionLower(this Compilation compilation, Action action, LanguageVersion lowerThanLanguageVersion) =>
            (compilation as CSharpCompilation)?.LanguageVersion.RunIfCSharpVersionLower(action, lowerThanLanguageVersion);

        private static void RunIfCSharpVersionLower(this LanguageVersion languageVersion, Action action, LanguageVersion lowerThanLanguageVersion)
        {
            if (languageVersion < lowerThanLanguageVersion) action?.Invoke();
        }

        public static ConditionalAccessExpressionSyntax ToConditionalAccessExpression(this MemberAccessExpressionSyntax memberAccess) =>
            SyntaxFactory.ConditionalAccessExpression(memberAccess.Expression, SyntaxFactory.MemberBindingExpression(memberAccess.Name));

        public static StatementSyntax GetSingleStatementFromPossibleBlock(this StatementSyntax statement)
        {
            var block = statement as BlockSyntax;
            if (block != null)
            {
                if (block.Statements.Count != 1) return null;
                return block.Statements.Single();
            }
            else
            {
                return statement;
            }
        }

        public static bool IsEmbeddedStatementOwner(this SyntaxNode node)
        {
            return node is IfStatementSyntax ||
                   node is ElseClauseSyntax ||
                   node is ForStatementSyntax ||
                   node is ForEachStatementSyntax ||
                   node is WhileStatementSyntax ||
                   node is UsingStatementSyntax ||
                   node is DoStatementSyntax ||
                   node is LockStatementSyntax ||
                   node is FixedStatementSyntax;
        }

        public static IEnumerable<TypeDeclarationSyntax> DescendantTypes(this SyntaxNode root)
        {
            return root
                .DescendantNodes(n => !(n.IsKind(
                    SyntaxKind.MethodDeclaration,
                    SyntaxKind.ConstructorDeclaration,
                    SyntaxKind.DelegateDeclaration,
                    SyntaxKind.DestructorDeclaration,
                    SyntaxKind.EnumDeclaration,
                    SyntaxKind.PropertyDeclaration,
                    SyntaxKind.FieldDeclaration,
                    SyntaxKind.InterfaceDeclaration,
                    SyntaxKind.PropertyDeclaration,
                    SyntaxKind.EventDeclaration)))
                .OfType<TypeDeclarationSyntax>();
        }

        public static T GetAncestor<T>(this SyntaxToken token, Func<T, bool> predicate = null)
            where T : SyntaxNode => token.Parent?.FirstAncestorOrSelf(predicate);

        public static bool IsKind(this SyntaxToken token, params SyntaxKind[] kinds)
        {
            foreach (var kind in kinds)
                if (Microsoft.CodeAnalysis.CSharpExtensions.IsKind(token, kind)) return true;
            return false;
        }

        public static bool IsKind(this SyntaxTrivia trivia, params SyntaxKind[] kinds)
        {
            foreach (var kind in kinds)
                if (Microsoft.CodeAnalysis.CSharpExtensions.IsKind(trivia, kind)) return true;
            return false;
        }

        public static bool IsKind(this SyntaxNode node, params SyntaxKind[] kinds)
        {
            foreach (var kind in kinds)
                if (Microsoft.CodeAnalysis.CSharpExtensions.IsKind(node, kind)) return true;
            return false;
        }

        public static bool IsKind(this SyntaxNodeOrToken nodeOrToken, params SyntaxKind[] kinds)
        {
            foreach (var kind in kinds)
                if (Microsoft.CodeAnalysis.CSharpExtensions.IsKind(nodeOrToken, kind)) return true;
            return false;
        }

        public static bool IsNotKind(this SyntaxNode node, params SyntaxKind[] kinds) => !node.IsKind(kinds);

        public static bool Any(this SyntaxTokenList list, SyntaxKind kind1, SyntaxKind kind2) =>
            list.IndexOf(kind1) >= 0 || list.IndexOf(kind2) >= 0;

        public static bool Any(this SyntaxTokenList list, SyntaxKind kind1, SyntaxKind kind2, params SyntaxKind[] kinds)
        {
            if (list.Any(kind1, kind2)) return true;
            for (int i = 0; i < kinds.Length; i++)
                if (list.IndexOf(kinds[i]) >= 0) return true;
            return false;
        }

        public static bool IsAnyKind(this SyntaxNode node, params SyntaxKind[] kinds)
        {
            foreach (var kind in kinds)
            {
                if (node.IsKind(kind)) return true;
            }
            return false;
        }

        public static MemberDeclarationSyntax FirstAncestorOrSelfThatIsAMember(this SyntaxNode node)
        {
            var currentNode = node;
            while (true)
            {
                if (currentNode == null) break;
                if (currentNode.IsAnyKind(
                    SyntaxKind.EnumDeclaration, SyntaxKind.ClassDeclaration,
                    SyntaxKind.InterfaceDeclaration, SyntaxKind.StructDeclaration,
                    SyntaxKind.ConstructorDeclaration, SyntaxKind.DestructorDeclaration,
                    SyntaxKind.MethodDeclaration, SyntaxKind.PropertyDeclaration,
                    SyntaxKind.EventDeclaration, SyntaxKind.DelegateDeclaration,
                    SyntaxKind.EventFieldDeclaration, SyntaxKind.FieldDeclaration,
                    SyntaxKind.ConversionOperatorDeclaration, SyntaxKind.OperatorDeclaration,
                    SyntaxKind.IndexerDeclaration, SyntaxKind.NamespaceDeclaration))
                    return (MemberDeclarationSyntax)currentNode;
                currentNode = currentNode.Parent;
            }
            return null;

        }

        public static StatementSyntax FirstAncestorOrSelfThatIsAStatement(this SyntaxNode node)
        {
            var currentNode = node;
            while (true)
            {
                if (currentNode == null) break;
                if (currentNode.IsAnyKind(SyntaxKind.Block, SyntaxKind.BreakStatement,
                    SyntaxKind.CheckedStatement, SyntaxKind.ContinueStatement,
                    SyntaxKind.DoStatement, SyntaxKind.EmptyStatement,
                    SyntaxKind.ExpressionStatement, SyntaxKind.FixedKeyword,
                    SyntaxKind.ForEachKeyword, SyntaxKind.ForStatement,
                    SyntaxKind.GotoStatement, SyntaxKind.IfStatement,
                    SyntaxKind.LabeledStatement, SyntaxKind.LocalDeclarationStatement,
                    SyntaxKind.LockStatement, SyntaxKind.ReturnStatement,
                    SyntaxKind.SwitchStatement, SyntaxKind.ThrowStatement,
                    SyntaxKind.TryStatement, SyntaxKind.UnsafeStatement,
                    SyntaxKind.UsingStatement, SyntaxKind.WhileStatement,
                    SyntaxKind.YieldBreakStatement, SyntaxKind.YieldReturnStatement))
                    return (StatementSyntax)currentNode;
                currentNode = currentNode.Parent;
            }
            return null;
        }

        public static bool HasAttributeOnAncestorOrSelf(this SyntaxNode node, string attributeName)
        {
            var csharpNode = node as CSharpSyntaxNode;
            if (csharpNode == null) throw new Exception("Node is not a C# node");
            return csharpNode.HasAttributeOnAncestorOrSelf(attributeName);
        }

        public static bool HasAttributeOnAncestorOrSelf(this SyntaxNode node, params string[] attributeNames)
        {
            var csharpNode = node as CSharpSyntaxNode;
            if (csharpNode == null) throw new Exception("Node is not a C# node");
            foreach (var attributeName in attributeNames)
                if (csharpNode.HasAttributeOnAncestorOrSelf(attributeName)) return true;
            return false;
        }

        public static bool HasAttributeOnAncestorOrSelf(this CSharpSyntaxNode node, string attributeName)
        {
            var parentMethod = (BaseMethodDeclarationSyntax)node.FirstAncestorOrSelfOfType(typeof(MethodDeclarationSyntax), typeof(ConstructorDeclarationSyntax));
            if (parentMethod?.AttributeLists.HasAttribute(attributeName) ?? false)
                return true;
            var type = (TypeDeclarationSyntax)node.FirstAncestorOrSelfOfType(typeof(ClassDeclarationSyntax), typeof(StructDeclarationSyntax));
            while (type != null)
            {
                if (type.AttributeLists.HasAttribute(attributeName))
                    return true;
                type = (TypeDeclarationSyntax)type.FirstAncestorOfType(typeof(ClassDeclarationSyntax), typeof(StructDeclarationSyntax));
            }
            var property = node.FirstAncestorOrSelfOfType<PropertyDeclarationSyntax>();
            if (property?.AttributeLists.HasAttribute(attributeName) ?? false)
                return true;
            var accessor = node.FirstAncestorOrSelfOfType<AccessorDeclarationSyntax>();
            if (accessor?.AttributeLists.HasAttribute(attributeName) ?? false)
                return true;
            var anInterface = node.FirstAncestorOrSelfOfType<InterfaceDeclarationSyntax>();
            if (anInterface?.AttributeLists.HasAttribute(attributeName) ?? false)
                return true;
            var anEvent = node.FirstAncestorOrSelfOfType<EventDeclarationSyntax>();
            if (anEvent?.AttributeLists.HasAttribute(attributeName) ?? false)
                return true;
            var anEnum = node.FirstAncestorOrSelfOfType<EnumDeclarationSyntax>();
            if (anEnum?.AttributeLists.HasAttribute(attributeName) ?? false)
                return true;
            var field = node.FirstAncestorOrSelfOfType<FieldDeclarationSyntax>();
            if (field?.AttributeLists.HasAttribute(attributeName) ?? false)
                return true;
            var eventField = node.FirstAncestorOrSelfOfType<EventFieldDeclarationSyntax>();
            if (eventField?.AttributeLists.HasAttribute(attributeName) ?? false)
                return true;
            var parameter = node as ParameterSyntax;
            if (parameter?.AttributeLists.HasAttribute(attributeName) ?? false)
                return true;
            var aDelegate = node as DelegateDeclarationSyntax;
            if (aDelegate?.AttributeLists.HasAttribute(attributeName) ?? false)
                return true;
            return false;
        }

        public static bool HasAttribute(this SyntaxList<AttributeListSyntax> attributeLists, string attributeName) =>
            attributeLists.SelectMany(a => a.Attributes).Any(a => a.Name.ToString().EndsWith(attributeName, StringComparison.OrdinalIgnoreCase));

        public static bool HasAnyAttribute(this SyntaxList<AttributeListSyntax> attributeLists, string[] attributeNames) =>
            attributeLists.SelectMany(a => a.Attributes).Select(a => a.Name.ToString()).Any(name => attributeNames.Any(attributeName =>
            name.EndsWith(attributeName, StringComparison.OrdinalIgnoreCase)
            || name.EndsWith($"{attributeName}Attribute", StringComparison.OrdinalIgnoreCase)));

        public static NameSyntax ToNameSyntax(this INamespaceSymbol namespaceSymbol) =>
            ToNameSyntax(namespaceSymbol.ToDisplayString().Split('.'));

        private static NameSyntax ToNameSyntax(IEnumerable<string> names)
        {
            var count = names.Count();
            if (count == 1)
                return SyntaxFactory.IdentifierName(names.First());
            return SyntaxFactory.QualifiedName(
                ToNameSyntax(names.Take(count - 1)),
                ToNameSyntax(names.Skip(count - 1)) as IdentifierNameSyntax
            );
        }

        public static TypeSyntax FindTypeInParametersList(this SeparatedSyntaxList<ParameterSyntax> parameterList, string typeName)
        {
            TypeSyntax result = null;
            var lastIdentifierOfTypeName = typeName.GetLastIdentifierIfQualiedTypeName();
            foreach (var parameter in parameterList)
            {
                var valueText = GetLastIdentifierValueText(parameter.Type);

                if (!string.IsNullOrEmpty(valueText))
                {
                    if (string.Equals(valueText, lastIdentifierOfTypeName, StringComparison.Ordinal))
                    {
                        result = parameter.Type;
                        break;
                    }
                }
            }

            return result;
        }

        private static string GetLastIdentifierValueText(CSharpSyntaxNode node)
        {
            var result = string.Empty;
            switch (node.Kind())
            {
                case SyntaxKind.IdentifierName:
                    result = ((IdentifierNameSyntax)node).Identifier.ValueText;
                    break;
                case SyntaxKind.QualifiedName:
                    result = GetLastIdentifierValueText(((QualifiedNameSyntax)node).Right);
                    break;
                case SyntaxKind.GenericName:
                    var genericNameSyntax = ((GenericNameSyntax)node);
                    result = $"{genericNameSyntax.Identifier.ValueText}{genericNameSyntax.TypeArgumentList.ToString()}";
                    break;
                case SyntaxKind.AliasQualifiedName:
                    result = ((AliasQualifiedNameSyntax)node).Name.Identifier.ValueText;
                    break;
            }
            return result;
        }

        public static SyntaxToken GetIdentifier(this BaseMethodDeclarationSyntax method)
        {
            var result = default(SyntaxToken);

            switch (method.Kind())
            {
                case SyntaxKind.MethodDeclaration:
                    result = ((MethodDeclarationSyntax)method).Identifier;
                    break;
                case SyntaxKind.ConstructorDeclaration:
                    result = ((ConstructorDeclarationSyntax)method).Identifier;
                    break;
                case SyntaxKind.DestructorDeclaration:
                    result = ((DestructorDeclarationSyntax)method).Identifier;
                    break;
            }

            return result;
        }

        public static MemberDeclarationSyntax WithModifiers(this MemberDeclarationSyntax declaration, SyntaxTokenList newModifiers)
        {
            var result = declaration;

            switch (declaration.Kind())
            {
                case SyntaxKind.ClassDeclaration:
                    result = ((ClassDeclarationSyntax)declaration).WithModifiers(newModifiers);
                    break;
                case SyntaxKind.StructDeclaration:
                    result = ((StructDeclarationSyntax)declaration).WithModifiers(newModifiers);
                    break;
                case SyntaxKind.InterfaceDeclaration:
                    result = ((InterfaceDeclarationSyntax)declaration).WithModifiers(newModifiers);
                    break;
                case SyntaxKind.EnumDeclaration:
                    result = ((EnumDeclarationSyntax)declaration).WithModifiers(newModifiers);
                    break;
                case SyntaxKind.DelegateDeclaration:
                    result = ((DelegateDeclarationSyntax)declaration).WithModifiers(newModifiers);
                    break;
                case SyntaxKind.FieldDeclaration:
                    result = ((FieldDeclarationSyntax)declaration).WithModifiers(newModifiers);
                    break;
                case SyntaxKind.EventFieldDeclaration:
                    result = ((EventFieldDeclarationSyntax)declaration).WithModifiers(newModifiers);
                    break;
                case SyntaxKind.MethodDeclaration:
                    result = ((MethodDeclarationSyntax)declaration).WithModifiers(newModifiers);
                    break;
                case SyntaxKind.OperatorDeclaration:
                    result = ((OperatorDeclarationSyntax)declaration).WithModifiers(newModifiers);
                    break;
                case SyntaxKind.ConversionOperatorDeclaration:
                    result = ((ConversionOperatorDeclarationSyntax)declaration).WithModifiers(newModifiers);
                    break;
                case SyntaxKind.ConstructorDeclaration:
                    result = ((ConstructorDeclarationSyntax)declaration).WithModifiers(newModifiers);
                    break;
                case SyntaxKind.DestructorDeclaration:
                    result = ((DestructorDeclarationSyntax)declaration).WithModifiers(newModifiers);
                    break;
                case SyntaxKind.PropertyDeclaration:
                    result = ((PropertyDeclarationSyntax)declaration).WithModifiers(newModifiers);
                    break;
                case SyntaxKind.IndexerDeclaration:
                    result = ((IndexerDeclarationSyntax)declaration).WithModifiers(newModifiers);
                    break;
                case SyntaxKind.EventDeclaration:
                    result = ((EventDeclarationSyntax)declaration).WithModifiers(newModifiers);
                    break;
            }

            return result;
        }

        public static SyntaxTokenList GetModifiers(this MemberDeclarationSyntax memberDeclaration)
        {
            var result = default(SyntaxTokenList);

            switch (memberDeclaration.Kind())
            {
                case SyntaxKind.ClassDeclaration:
                case SyntaxKind.StructDeclaration:
                case SyntaxKind.InterfaceDeclaration:
                case SyntaxKind.EnumDeclaration:
                    result = ((BaseTypeDeclarationSyntax)memberDeclaration).Modifiers;
                    break;
                case SyntaxKind.DelegateDeclaration:
                    result = ((DelegateDeclarationSyntax)memberDeclaration).Modifiers;
                    break;
                case SyntaxKind.FieldDeclaration:
                case SyntaxKind.EventFieldDeclaration:
                    result = ((BaseFieldDeclarationSyntax)memberDeclaration).Modifiers;
                    break;
                case SyntaxKind.MethodDeclaration:
                case SyntaxKind.OperatorDeclaration:
                case SyntaxKind.ConversionOperatorDeclaration:
                case SyntaxKind.ConstructorDeclaration:
                case SyntaxKind.DestructorDeclaration:
                    result = ((BaseMethodDeclarationSyntax)memberDeclaration).Modifiers;
                    break;
                case SyntaxKind.PropertyDeclaration:
                case SyntaxKind.IndexerDeclaration:
                case SyntaxKind.EventDeclaration:
                    result = ((BasePropertyDeclarationSyntax)memberDeclaration).Modifiers;
                    break;
            }

            return result;
        }

        public static SyntaxTokenList CloneAccessibilityModifiers(this BaseMethodDeclarationSyntax method)
        {
            var modifiers = method.Modifiers;
            if (method.Parent.IsKind(SyntaxKind.InterfaceDeclaration))
            {
                modifiers = ((InterfaceDeclarationSyntax)method.Parent).Modifiers;
            }

            return modifiers.CloneAccessibilityModifiers();
        }

        public static SyntaxTokenList CloneAccessibilityModifiers(this SyntaxTokenList modifiers)
        {
            var accessibilityModifiers = modifiers.Where(token => token.IsKind(SyntaxKind.PublicKeyword) || token.IsKind(SyntaxKind.ProtectedKeyword) || token.IsKind(SyntaxKind.InternalKeyword) || token.IsKind(SyntaxKind.PrivateKeyword)).Select(token => SyntaxFactory.Token(token.Kind()));

            return SyntaxFactory.TokenList(accessibilityModifiers.EnsureProtectedBeforeInternal());
        }

        public static SyntaxNode FirstAncestorOfKind(this SyntaxNode node, params SyntaxKind[] kinds)
        {
            var currentNode = node;
            while (true)
            {
                var parent = currentNode.Parent;
                if (parent == null) break;
                if (parent.IsAnyKind(kinds)) return parent;
                currentNode = parent;
            }
            return null;
        }

        public static TNode FirstAncestorOfKind<TNode>(this SyntaxNode node, params SyntaxKind[] kinds) where TNode : SyntaxNode =>
            (TNode)FirstAncestorOfKind(node, kinds);

        public static IEnumerable<TNode> OfKind<TNode>(this IEnumerable<SyntaxNode> nodes, SyntaxKind kind) where TNode : SyntaxNode
        {
            foreach (var node in nodes)
                if (node.IsKind(kind))
                    yield return (TNode)node;
        }

        public static IEnumerable<TNode> OfKind<TNode>(this IEnumerable<TNode> nodes, SyntaxKind kind) where TNode : SyntaxNode
        {
            foreach (var node in nodes)
                if (node.IsKind(kind))
                    yield return node;
        }

        public static IEnumerable<TNode> OfKind<TNode>(this IEnumerable<TNode> nodes, params SyntaxKind[] kinds) where TNode : SyntaxNode
        {
            foreach (var node in nodes)
                if (node.IsAnyKind(kinds))
                    yield return node;
        }

        public static StatementSyntax GetPreviousStatement(this StatementSyntax statement)
        {
            var parent = statement.Parent;
            SyntaxList<StatementSyntax> statements;
            if (parent.IsKind(SyntaxKind.Block))
            {
                var block = (BlockSyntax)parent;
                statements = block.Statements;
            }
            else if (parent.IsKind(SyntaxKind.SwitchSection))
            {
                var section = (SwitchSectionSyntax)parent;
                statements = section.Statements;
            }
            else return null;
            if (statement.Equals(statements[0])) return null;
            for (int i = 1; i < statements.Count; i++)
            {
                var someStatement = statements[i];
                if (statement.Equals(someStatement))
                    return statements[i - 1];
            }
            return null;
        }

        /// <summary>
        /// Determines whether the specified symbol is a read only field and initialized in the specified context.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="symbol">The symbol.</param>
        /// <returns>
        /// True if the symbol is a read only field that is initialized either on declaration or in all constructors of the containing type; otherwise false.
        /// </returns>
        /// <remarks>
        /// If the symbol is initialized in a block of code of the constructor that might not always be called, the symbol is considered to
        /// not be initialized for certain. For more information <seealso cref="DoesBlockContainDefiniteInitializer(SyntaxNodeAnalysisContext, ISymbol, IEnumerable{StatementSyntax})"/>
        /// </remarks>
        public static bool IsReadOnlyAndInitializedForCertain(this ISymbol symbol, SyntaxNodeAnalysisContext context)
        {
            if (symbol.Kind != SymbolKind.Field) return false;

            var field = (IFieldSymbol)symbol;
            foreach (var declaringSyntaxReference in symbol.DeclaringSyntaxReferences)
            {
                var variableDeclarator = declaringSyntaxReference.GetSyntax(context.CancellationToken) as VariableDeclaratorSyntax;

                if (variableDeclarator != null && variableDeclarator.Initializer != null && field.IsReadOnly &&
                    !variableDeclarator.Initializer.Value.IsKind(SyntaxKind.NullLiteralExpression)) return true;
            }

            foreach (var constructor in symbol.ContainingType.Constructors)
            {
                foreach (var declaringSyntaxReference in constructor.DeclaringSyntaxReferences)
                {
                    var constructorSyntax = declaringSyntaxReference.GetSyntax(context.CancellationToken) as ConstructorDeclarationSyntax;
                    if (constructorSyntax != null)
                        if (field.IsReadOnly && constructorSyntax.Body.Statements.DoesBlockContainCertainInitializer(context, symbol) == InitializerState.Initializer)
                            return true;
                }
            }

            return false;
        }

        private static InitializerState DoesBlockContainCertainInitializer(this StatementSyntax statement, SyntaxNodeAnalysisContext context, ISymbol symbol)
        {
            return new[] { statement }.DoesBlockContainCertainInitializer(context, symbol);
        }

        /// <summary>
        /// This method can be used to determine if the specified block of
        /// statements contains an initializer for the specified symbol.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="symbol">The symbol.</param>
        /// <param name="statements">The statements.</param>
        /// <returns>
        /// The initializer state found
        /// </returns>
        /// <remarks>
        /// Code blocks that might not always be called are:
        /// - An if or else statement.
        /// - The body of a for, while or for-each loop.
        /// - Switch statements
        ///
        /// The following exceptions are taken into account:
        /// - If both if and else statements contain a certain initialization.
        /// - If all cases in a switch contain a certain initialization (this means a default case must exist as well).
        ///
        /// Please note that this is a recursive function so we can check a block of code in an if statement for example.
        /// </remarks>
        private static InitializerState DoesBlockContainCertainInitializer(this IEnumerable<StatementSyntax> statements, SyntaxNodeAnalysisContext context, ISymbol symbol)
        {
            // Keep track of the current initializer state. This can only be None
            // or Initializer, WayToSkipInitializer will always be returned immediately.
            // Only way to go back from Initializer to None is if there is an assignment
            // to null after a previous assignment to a non-null value.
            var currentState = InitializerState.None;

            foreach (var statement in statements)
            {
                if (statement.IsKind(SyntaxKind.ReturnStatement) && currentState == InitializerState.None)
                {
                    return InitializerState.WayToSkipInitializer;
                }
                else if (statement.IsKind(SyntaxKind.Block))
                {
                    var blockResult = ((BlockSyntax)statement).Statements.DoesBlockContainCertainInitializer(context, symbol);
                    if (CanSkipInitializer(blockResult, currentState))
                        return InitializerState.WayToSkipInitializer;
                    if (blockResult == InitializerState.Initializer)
                        currentState = blockResult;
                }
                else if (statement.IsKind(SyntaxKind.UsingStatement))
                {
                    var blockResult = ((UsingStatementSyntax)statement).Statement.DoesBlockContainCertainInitializer(context, symbol);
                    if (CanSkipInitializer(blockResult, currentState))
                        return InitializerState.WayToSkipInitializer;
                    if (blockResult == InitializerState.Initializer)
                        currentState = blockResult;
                }
                else if (statement.IsKind(SyntaxKind.ExpressionStatement))
                {
                    var expression = ((ExpressionStatementSyntax)statement).Expression;
                    if (expression.IsKind(SyntaxKind.SimpleAssignmentExpression))
                    {
                        var assignmentExpression = (AssignmentExpressionSyntax)expression;
                        var identifier = assignmentExpression.Left;
                        if (identifier != null)
                        {
                            var right = assignmentExpression.Right;
                            if (right != null)
                            {
                                if (right.IsKind(SyntaxKind.NullLiteralExpression))
                                    currentState = InitializerState.None;
                                else if (symbol.Equals(context.SemanticModel.GetSymbolInfo(identifier).Symbol))
                                    currentState = InitializerState.Initializer;
                            }
                        }
                    }
                }
                else if (statement.IsKind(SyntaxKind.SwitchStatement))
                {
                    var switchStatement = (SwitchStatementSyntax)statement;
                    if (switchStatement.Sections.Any(s => s.Labels.Any(l => l.IsKind(SyntaxKind.DefaultSwitchLabel))))
                    {
                        var sectionInitializerStates = switchStatement.Sections.Select(s => s.Statements.DoesBlockContainCertainInitializer(context, symbol)).ToList();
                        if (sectionInitializerStates.All(sectionInitializerState => sectionInitializerState == InitializerState.Initializer))
                            currentState = InitializerState.Initializer;
                        else if (sectionInitializerStates.Any(sectionInitializerState => CanSkipInitializer(sectionInitializerState, currentState)))
                            return InitializerState.WayToSkipInitializer;
                    }
                }
                else if (statement.IsKind(SyntaxKind.IfStatement))
                {
                    var ifStatement = (IfStatementSyntax)statement;

                    var ifResult = ifStatement.Statement.DoesBlockContainCertainInitializer(context, symbol);
                    if (ifStatement.Else != null)
                    {
                        var elseResult = ifStatement.Else.Statement .DoesBlockContainCertainInitializer(context, symbol);

                        if (ifResult == InitializerState.Initializer && elseResult == InitializerState.Initializer)
                            currentState = InitializerState.Initializer;
                        if (CanSkipInitializer(elseResult, currentState))
                            return InitializerState.WayToSkipInitializer;
                    }
                    if (CanSkipInitializer(ifResult, currentState))
                    {
                        return InitializerState.WayToSkipInitializer;
                    }
                }
            }
            return currentState;
        }

        private static bool CanSkipInitializer(InitializerState foundState, InitializerState currentState) =>
            foundState == InitializerState.WayToSkipInitializer && currentState == InitializerState.None;

        public static TNode WithoutAllTrivia<TNode>(this TNode node) where TNode : SyntaxNode
        {
            var newNode = node.WithoutTrivia();
            var tokens = newNode.ChildTokens().ToList();
            var newTokens = tokens.ToDictionary(t => t, t => t.WithoutTrivia());
            newNode = newNode.ReplaceTokens(tokens, (o, _) => newTokens[o]);
            var nodes = newNode.ChildNodes().ToList();
            var newNodes = nodes.ToDictionary(n => n, n => n.WithoutAllTrivia());
            newNode = newNode.ReplaceNodes(nodes, (o, _) => newNodes[o]);
            newNode = newNode.WithAdditionalAnnotations(Formatter.Annotation);
            return newNode;
        }

        public static SyntaxToken WithoutTrivia(this SyntaxToken token)
        {
            var trivia = token.GetAllTrivia();
            var newToken = token.ReplaceTrivia(trivia, (o, _) => default(SyntaxTrivia));
            return newToken;
        }

        private static readonly SyntaxTokenList publicToken = SyntaxFactory.TokenList(SyntaxFactory.Token(SyntaxKind.PublicKeyword));
        private static readonly SyntaxTokenList privateToken = SyntaxFactory.TokenList(SyntaxFactory.Token(SyntaxKind.PrivateKeyword));
        private static readonly SyntaxTokenList protectedToken = SyntaxFactory.TokenList(SyntaxFactory.Token(SyntaxKind.ProtectedKeyword));
        private static readonly SyntaxTokenList protectedInternalToken = SyntaxFactory.TokenList(
            SyntaxFactory.Token(SyntaxKind.ProtectedKeyword), SyntaxFactory.Token(SyntaxKind.InternalKeyword));
        private static readonly SyntaxTokenList internalToken = SyntaxFactory.TokenList(SyntaxFactory.Token(SyntaxKind.InternalKeyword));
        public static SyntaxTokenList GetTokens(this Accessibility accessibility)
        {
            switch (accessibility)
            {
                case Accessibility.Public:
                    return publicToken;
                case Accessibility.Private:
                    return privateToken;
                case Accessibility.Protected:
                    return protectedToken;
                case Accessibility.Internal:
                    return internalToken;
                case Accessibility.ProtectedAndInternal:
                    return protectedInternalToken;
                default:
                    throw new NotSupportedException();
            }
        }
    }
}


text:
require 'builder'
require 'uri'
require 'time'
require 'date'

module SitemapGenerator
  module Builder
    # A Hash-like class for holding information about a sitemap URL and
    # generating an XML <url> element suitable for sitemaps.
    class SitemapUrl < Hash

      # Return a new instance with options configured on it.
      #
      # == Arguments
      # * sitemap - a Sitemap instance, or
      # * path, options - a path string and options hash
      #
      # == Options
      # Requires a host to be set.  If passing a sitemap, the sitemap must have a +default_host+
      # configured.  If calling with a path and options, you must include the <tt>:host</tt> option.
      #
      # * +priority+
      # * +changefreq+
      # * +lastmod+
      # * +images+
      # * +video+/+videos+
      # * +geo+
      # * +news+
      def initialize(path, options={})
        options = options.dup
        if sitemap = path.is_a?(SitemapGenerator::Builder::SitemapFile) && path
          SitemapGenerator::Utilities.reverse_merge!(options, :host => sitemap.location.host, :lastmod => sitemap.lastmod)
          path = sitemap.location.path_in_public
        end

        SitemapGenerator::Utilities.assert_valid_keys(options, :priority, :changefreq, :lastmod, :host, :images, :video, :geo, :news, :videos)
        SitemapGenerator::Utilities.reverse_merge!(options, :priority => 0.5, :changefreq => 'weekly', :lastmod => Time.now, :images => [], :news => {}, :videos => [])
        raise "Cannot generate a url without a host" unless SitemapGenerator::Utilities.present?(options[:host])
        if video = options.delete(:video)
          options[:videos] = video.is_a?(Array) ? options[:videos].concat(video) : options[:videos] << video
        end

        path = path.to_s.sub(/^\//, '')
        loc  = path.empty? ? options[:host] : (options[:host].to_s.sub(/\/$/, '') + '/' + path)
        self.merge!(
          :priority   => options[:priority],
          :changefreq => options[:changefreq],
          :lastmod    => options[:lastmod],
          :host       => options[:host],
          :loc        => loc,
          :images     => prepare_images(options[:images], options[:host]),
          :news       => prepare_news(options[:news]),
          :videos     => options[:videos],
          :geo        => options[:geo]
        )
      end

      # Return the URL as XML
      def to_xml(builder=nil)
        builder = ::Builder::XmlMarkup.new if builder.nil?
        builder.url do
          builder.loc        self[:loc]
          builder.lastmod    w3c_date(self[:lastmod])      if self[:lastmod]
          builder.changefreq self[:changefreq]             if self[:changefreq]
          builder.priority   format_float(self[:priority]) if self[:priority]

          unless SitemapGenerator::Utilities.blank?(self[:news])
            news_data = self[:news]
            builder.news:news do
              builder.news:publication do
                builder.news :name, news_data[:publication_name] if news_data[:publication_name]
                builder.news :language, news_data[:publication_language] if news_data[:publication_language]
              end

              builder.news :access, news_data[:access] if news_data[:access]
              builder.news :genres, news_data[:genres] if news_data[:genres]
              builder.news :publication_date, news_data[:publication_date] if news_data[:publication_date]
              builder.news :title, news_data[:title] if news_data[:title]
              builder.news :keywords, news_data[:keywords] if news_data[:keywords]
              builder.news :stock_tickers, news_data[:stock_tickers] if news_data[:stock_tickers]
            end
          end

          self[:images].each do |image|
            builder.image:image do
              builder.image :loc, image[:loc]
              builder.image :caption, image[:caption]             if image[:caption]
              builder.image :geo_location, image[:geo_location]   if image[:geo_location]
              builder.image :title, image[:title]                 if image[:title]
              builder.image :license, image[:license]             if image[:license]
            end
          end

          self[:videos].each do |video|
            builder.video :video do
              builder.video :thumbnail_loc, video[:thumbnail_loc]
              builder.video :title, video[:title]
              builder.video :description, video[:description]
              builder.video :content_loc, video[:content_loc]           if video[:content_loc]
              if video[:player_loc]
                builder.video :player_loc, video[:player_loc], :allow_embed => yes_or_no_with_default(video[:allow_embed], true), :autoplay => video[:autoplay]
              end
              builder.video :duration, video[:duration]                 if video[:duration]
              builder.video :expiration_date,  w3c_date(video[:expiration_date])  if video[:expiration_date]
              builder.video :rating, format_float(video[:rating])       if video[:rating]
              builder.video :view_count, video[:view_count]             if video[:view_count]
              builder.video :publication_date, w3c_date(video[:publication_date]) if video[:publication_date]
              video[:tags].each {|tag| builder.video :tag, tag }        if video[:tags]
              builder.video :tag, video[:tag]                           if video[:tag]
              builder.video :category, video[:category]                 if video[:category]
              builder.video :family_friendly,  yes_or_no_with_default(video[:family_friendly], true) if video.has_key?(:family_friendly)
              builder.video :gallery_loc, video[:gallery_loc], :title => video[:gallery_title] if video[:gallery_loc]
              if video[:uploader]
                builder.video :uploader, video[:uploader], video[:uploader_info] ? { :info => video[:uploader_info] } : {}
              end
            end
          end

          unless SitemapGenerator::Utilities.blank?(self[:geo])
            geo = self[:geo]
            builder.geo :geo do
              builder.geo :format, geo[:format] if geo[:format]
            end
          end
        end
        builder << '' # Force to string
      end

      def news?
        SitemapGenerator::Utilities.present?(self[:news])
      end

      protected

      def prepare_news(news)
        SitemapGenerator::Utilities.assert_valid_keys(news, :publication_name, :publication_language, :publication_date, :genres, :access, :title, :keywords, :stock_tickers) unless news.empty?
        news
      end

      # Return an Array of image option Hashes suitable to be parsed by SitemapGenerator::Builder::SitemapFile
      def prepare_images(images, host)
        images.delete_if { |key,value| key[:loc] == nil }
        images.each do |r|
          SitemapGenerator::Utilities.assert_valid_keys(r, :loc, :caption, :geo_location, :title, :license)
          r[:loc] = URI.join(host, r[:loc]).to_s rescue r[:loc]
        end
        images[0..(SitemapGenerator::MAX_SITEMAP_IMAGES-1)]
      end

      def w3c_date(date)
        if date.is_a?(String)
          date
        elsif date.respond_to?(:iso8601)
          date.iso8601.sub(/Z$/i, '+00:00')
        elsif date.is_a?(Date) && !date.is_a?(DateTime)
          date.strftime("%Y-%m-%d")
        else
          zulutime = if date.is_a?(DateTime)
            date.new_offset(0)
          elsif date.respond_to?(:utc)
            date.utc
          else
            nil
          end

          if zulutime
            zulutime.strftime("%Y-%m-%dT%H:%M:%S+00:00")
          else
            zone = date.strftime('%z').insert(-3, ':')
            date.strftime("%Y-%m-%dT%H:%M:%S") + zone
          end
        end
      end

      # Accept a string or boolean and return 'yes' or 'no'.  If a string, the
      # value must be 'yes' or 'no'.  Pass the default value as a boolean using `default`.
      def yes_or_no(value)
        if value.is_a?(String)
          raise ArgumentError.new("Unrecognized value for yes/no field: #{value.inspect}") unless value =~ /^(yes|no)$/i
          value.downcase
        else
          value ? 'yes' : 'no'
        end
      end

      # If the value is nil, return `default` converted to either 'yes' or 'no'.
      # If the value is set, return its value converted to 'yes' or 'no'.
      def yes_or_no_with_default(value, default)
        yes_or_no(value.nil? ? default : value)
      end

      # Format a float to to one decimal precision.
      # TODO: Use rounding with precision once merged with framework_agnostic.
      def format_float(value)
        value.is_a?(String) ? value : ('%0.1f' % value)
      end
    end
  end
end


text:
package uk.gov.nationalarchives.droid.command.filter;

import java.util.Collection;

import uk.gov.nationalarchives.droid.core.interfaces.filter.CriterionFieldEnum;
import uk.gov.nationalarchives.droid.core.interfaces.filter.CriterionOperator;
import uk.gov.nationalarchives.droid.core.interfaces.filter.FilterCriterion;

/**
 * @param <T> the type of the criterion value
 * @author rflitcroft
 *
 */
public abstract class AbstractFilterCriterion<T> implements FilterCriterion {

    private CriterionOperator operator;
    private CriterionFieldEnum field;
    private Object value;

    /**
     * @param field the field
     * @param operator the operator
     */
    public AbstractFilterCriterion(CriterionFieldEnum field, CriterionOperator operator) {
        this.field = field;
        this.operator = operator;
    }

    /**
     * Converts a string to a typed value.
     * @param s the String representation
     * @return the typed value
     */
    protected abstract T toTypedValue(String s);

    /**
     * {@inheritDoc}
     */
    @Override
    public CriterionFieldEnum getField() {
        return field;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public CriterionOperator getOperator() {
        return operator;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Object getValue() {
        return value;
    }

    /**
     * Sets the value.
     * @param value the value to set
     */
    public void setValue(String value) {
        this.value = toTypedValue(value);
    }

    /**
     * Sets mulitple values.
     * @param values multiple values to set
     */
    public void setValue(Collection<String> values) {
        Object[] typedValues = new Object[values.size()];
        int i = 0;
        for (String v : values) {
            typedValues[i++] = toTypedValue(v);
        }

        value = typedValues;
    }
}


text:
<?php

namespace Magento\AdminNotification\Model;

use Magento\Framework\Notification\MessageInterface;
use Magento\Framework\Notification\NotifierInterface;
use Magento\AdminNotification\Model\InboxInterface;

/**
 * AdminNotification Inbox model
 *
 * @method \Magento\AdminNotification\Model\ResourceModel\Inbox _getResource()
 * @method \Magento\AdminNotification\Model\ResourceModel\Inbox getResource()
 * @method int getSeverity()
 * @method \Magento\AdminNotification\Model\Inbox setSeverity(int $value)
 * @method string getDateAdded()
 * @method \Magento\AdminNotification\Model\Inbox setDateAdded(string $value)
 * @method string getTitle()
 * @method \Magento\AdminNotification\Model\Inbox setTitle(string $value)
 * @method string getDescription()
 * @method \Magento\AdminNotification\Model\Inbox setDescription(string $value)
 * @method string getUrl()
 * @method \Magento\AdminNotification\Model\Inbox setUrl(string $value)
 * @method int getIsRead()
 * @method \Magento\AdminNotification\Model\Inbox setIsRead(int $value)
 * @method int getIsRemove()
 * @method \Magento\AdminNotification\Model\Inbox setIsRemove(int $value)
 *
 * @author      Magento Core Team <core@magentocommerce.com>
 */
class Inbox extends \Magento\Framework\Model\AbstractModel implements NotifierInterface, InboxInterface
{
    /**
     * @return void
     */
    protected function _construct()
    {
        $this->_init('Magento\AdminNotification\Model\ResourceModel\Inbox');
    }

    /**
     * {@inheritdoc}
     */
    public function getSeverities($severity = null)
    {
        $severities = [
            MessageInterface::SEVERITY_CRITICAL => __('critical'),
            MessageInterface::SEVERITY_MAJOR => __('major'),
            MessageInterface::SEVERITY_MINOR => __('minor'),
            MessageInterface::SEVERITY_NOTICE => __('notice'),
        ];

        if ($severity !== null) {
            if (isset($severities[$severity])) {
                return $severities[$severity];
            }
            return null;
        }

        return $severities;
    }

    /**
     * {@inheritdoc}
     */
    public function loadLatestNotice()
    {
        $this->setData([]);
        $this->getResource()->loadLatestNotice($this);
        return $this;
    }

    /**
     * {@inheritdoc}
     */
    public function getNoticeStatus()
    {
        return $this->getResource()->getNoticeStatus($this);
    }

    /**
     * Parse and save new data
     *
     * @param array $data
     * @return $this
     */
    public function parse(array $data)
    {
        $this->getResource()->parse($this, $data);
        return $this;
    }

    /**
     * Add new message
     *
     * @param int $severity
     * @param string $title
     * @param string|string[] $description
     * @param string $url
     * @param bool $isInternal
     * @throws \Magento\Framework\Exception\LocalizedException
     * @return $this
     */
    public function add($severity, $title, $description, $url = '', $isInternal = true)
    {
        if (!$this->getSeverities($severity)) {
            throw new \Magento\Framework\Exception\LocalizedException(__('Wrong message type'));
        }
        if (is_array($description)) {
            $description = '

' . implode('

', $description) . '

';
        }
        $date = date('Y-m-d H:i:s');
        $this->parse(
            [
                [
                    'severity' => $severity,
                    'date_added' => $date,
                    'title' => $title,
                    'description' => $description,
                    'url' => $url,
                    'internal' => $isInternal,
                ],
            ]
        );
        return $this;
    }

    /**
     * Add critical severity message
     *
     * @param string $title
     * @param string|string[] $description
     * @param string $url
     * @param bool $isInternal
     * @return $this
     */
    public function addCritical($title, $description, $url = '', $isInternal = true)
    {
        $this->add(MessageInterface::SEVERITY_CRITICAL, $title, $description, $url, $isInternal);
        return $this;
    }

    /**
     * Add major severity message
     *
     * @param string $title
     * @param string|string[] $description
     * @param string $url
     * @param bool $isInternal
     * @return $this
     */
    public function addMajor($title, $description, $url = '', $isInternal = true)
    {
        $this->add(MessageInterface::SEVERITY_MAJOR, $title, $description, $url, $isInternal);
        return $this;
    }

    /**
     * Add minor severity message
     *
     * @param string $title
     * @param string|string[] $description
     * @param string $url
     * @param bool $isInternal
     * @return $this
     */
    public function addMinor($title, $description, $url = '', $isInternal = true)
    {
        $this->add(MessageInterface::SEVERITY_MINOR, $title, $description, $url, $isInternal);
        return $this;
    }

    /**
     * Add notice
     *
     * @param string $title
     * @param string|string[] $description
     * @param string $url
     * @param bool $isInternal
     * @return $this
     */
    public function addNotice($title, $description, $url = '', $isInternal = true)
    {
        $this->add(MessageInterface::SEVERITY_NOTICE, $title, $description, $url, $isInternal);
        return $this;
    }
}


text:
package org.centerom.almistack.ui.application;

import java.net.URL;

import org.centerom.almistack.core.Constants;
import org.centerom.almistack.ui.contributions.FooterContribution;
import org.centerom.almistack.ui.contributions.SearchContribution;
import org.centerom.almistack.ui.providers.ImageProvider;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.ICoolBarManager;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IStatusLineManager;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.action.ToolBarContributionItem;
import org.eclipse.jface.action.ToolBarManager;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.SWT;
import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.ActionFactory;
import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;
import org.eclipse.ui.application.ActionBarAdvisor;
import org.eclipse.ui.application.IActionBarConfigurer;
import org.eclipse.ui.browser.IWebBrowser;
import org.eclipse.ui.browser.IWorkbenchBrowserSupport;

public class ApplicationActionBarAdvisor extends ActionBarAdvisor {

	// Constants
	// --------
	// TODO: remove when configuration and internationalization is available
	// |
	// v
	private static final String MENU_SEPARATOR  = "menu_separator";

	// For Tool bars
	private static final String ICONS_TOOLBAR_ID  = "icons_toolbar_id";
	private static final String SEARCH_TOOLBAR_ID = "search_toolbar_id";

	// For Actions
	private static final String DUMMY1_ACTION_ID   = "dummy1_action_id";
	private static final String DUMMY2_ACTION_ID   = "dummy2_action_id";
	private static final String DUMMY3_ACTION_ID   = "dummy3_action_id";
	private static final String ALM_SITE_ACTION_ID = "alm_site_action_id";

	private static final String ALM_DIALOG_CAPTION  = "Alm-iStack";
	private static final String ALM_HOME_PAGE_LABEL = "Home Page";
	private static final String ALM_HOME_PAGE_URL   = "https://sites.google.com/a/centeropenmiddleware.com/alm-istack/";
	// ^
	// |
	// TODO: remove when configuration and internationalization is available

	// Member variables
	// ------ ---------
	// Workbench Actions
	private IWorkbenchAction importAction  = null;
	private IWorkbenchAction exportAction  = null;
	private IWorkbenchAction toogleCoolBarAction = null;
	private IWorkbenchAction lockToolBartAction  = null;
	private IWorkbenchAction closePerspectiveAction     = null;
	private IWorkbenchAction closeAllPerspectivesAction = null;

	// Actions
	private Action dummy1Action  = null;
	private Action dummy2Action  = null;
	private Action dummy3Action  = null;
	private Action almSiteAction = null;

	// Browser object
	private IWebBrowser browser = null;

	public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) {
		super(configurer);
	}

	@Override
	protected void makeActions(final IWorkbenchWindow window) {

		// Workbench actions
		// --------- -------
		// File menu
		importAction = ActionFactory.IMPORT.create(window);
		exportAction = ActionFactory.EXPORT.create(window);

		// View menu
		toogleCoolBarAction        = ActionFactory.TOGGLE_COOLBAR.create(window);
		closePerspectiveAction     = ActionFactory.CLOSE_PERSPECTIVE.create(window);
		closePerspectiveAction     = ActionFactory.CLOSE_PERSPECTIVE.create(window);
		closeAllPerspectivesAction = ActionFactory.CLOSE_ALL_PERSPECTIVES.create(window);
		lockToolBartAction         = ActionFactory.LOCK_TOOL_BAR.create(window);

		// Custom actions
		// ------ -------
		// New action Dummy 1 for cool bar
		dummy1Action = new Action() {
			private static final long serialVersionUID = 1L;
			public void run() {
		        MessageDialog.openInformation(window.getShell(),
		        							  ALM_DIALOG_CAPTION,
		                                      "Executing dummy 1 ...");
			}
		};
		dummy1Action.setId(DUMMY1_ACTION_ID);
		dummy1Action.setImageDescriptor(ImageDescriptor.createFromImage(ImageProvider.IMG_DUMMY_1));

		// New action Dummy 2 for cool bar
		dummy2Action = new Action() {
			private static final long serialVersionUID = 1L;
			public void run() {
		        MessageDialog.openInformation(window.getShell(),
		        							  ALM_DIALOG_CAPTION,
		                                      "Executing dummy 2 ...");
			}
		};
		dummy2Action.setId(DUMMY2_ACTION_ID);
		dummy2Action.setImageDescriptor(ImageDescriptor.createFromImage(ImageProvider.IMG_DUMMY_2));

		// New action Dummy 3 for cool bar
		dummy3Action = new Action() {
			private static final long serialVersionUID = 1L;
			public void run() {
		        MessageDialog.openInformation(window.getShell(),
		        							  ALM_DIALOG_CAPTION,
		                                      "Executing dummy 3 ...");
			}
		};
		dummy3Action.setId(DUMMY3_ACTION_ID);
		dummy3Action.setImageDescriptor(ImageDescriptor.createFromImage(ImageProvider.IMG_DUMMY_3));

		// New action for menu bar
		almSiteAction = new Action() {

			private static final long serialVersionUID = 1L;

			public void run() {
				IWorkbenchBrowserSupport browserSupport = PlatformUI.getWorkbench().getBrowserSupport();
		        try {
		        	browser = browserSupport.createBrowser(IWorkbenchBrowserSupport.AS_EXTERNAL,
		        										   almSiteAction.getId(),
		        										   Constants.EMPTY_CHAR,
		        										   Constants.EMPTY_CHAR);
		        	browser.openURL(new URL(ALM_HOME_PAGE_URL));
		        }
		        catch( Exception e ) {
		        	e.printStackTrace();
		        }
			}
		};
		almSiteAction.setText(ALM_HOME_PAGE_LABEL);
		almSiteAction.setId(ALM_SITE_ACTION_ID);

		// Register actions
		register(importAction);
		register(exportAction);
		register(toogleCoolBarAction);
		register(lockToolBartAction);
		register(closePerspectiveAction);
		register(closeAllPerspectivesAction);
		register(dummy1Action);
		register(dummy2Action);
		register(dummy3Action);
		register(almSiteAction);
	}

	@Override
	protected void fillMenuBar(final IMenuManager menuBar) {
		// Locals
		MenuManager fileMenu   = new MenuManager("&File", IWorkbenchActionConstants.M_FILE );
		MenuManager viewMenu   = new MenuManager("View", IWorkbenchActionConstants.VIEW_EXT);
		MenuManager windowMenu = new MenuManager("Window", IWorkbenchActionConstants.M_WINDOW);
		MenuManager helpMenu   = new MenuManager("Help", IWorkbenchActionConstants.M_HELP);

		// File menu items
		fileMenu.add(importAction);
		fileMenu.add(exportAction);

		// View menu items
		viewMenu.add(toogleCoolBarAction);
		viewMenu.add(lockToolBartAction);
		viewMenu.add(new Separator(MENU_SEPARATOR));
		viewMenu.add(closeAllPerspectivesAction);
		viewMenu.add(closeAllPerspectivesAction);

		// Help menu items
		helpMenu.add(almSiteAction );

		// Add menus to menu bar
		menuBar.add(fileMenu);
		menuBar.add(viewMenu);
		menuBar.add(windowMenu);
		menuBar.add(helpMenu);
	}

	@Override
	protected void fillCoolBar(final ICoolBarManager coolBar) {
		//
		IToolBarManager iconsToolBar  = new ToolBarManager(SWT.FLAT | SWT.RIGHT);
		IToolBarManager searchToolBar = new ToolBarManager(SWT.FLAT | SWT.RIGHT);

		coolBar.add(new ToolBarContributionItem(iconsToolBar, ICONS_TOOLBAR_ID));
//		coolBar.add(new ToolBarContributionItem(searchToolBar, SEARCH_TOOLBAR_ID));

		// Add actions
		iconsToolBar.add(dummy1Action);
		iconsToolBar.add(dummy2Action);
		iconsToolBar.add(dummy3Action);
/*
		Action dummy4Action = new Action() {

		};
		dummy4Action.setId("org.eclipse.ui.file.save");

		iconsToolBar.add(dummy4Action);
	*/
		// Add search feature
		searchToolBar.add(new SearchContribution());

		coolBar.add(searchToolBar);

	}

	@Override
	protected void fillStatusLine(final IStatusLineManager statusLine) {
		statusLine.add(new FooterContribution());
//		statusLine.add(new FooterLinkContribution("about_id", "About", ImageProvider.IMG_COPYRIGHT, "http://"));
//		statusLine.add(new FooterLinkContribution("contact_id", "Contact Support", ImageProvider.IMG_COPYRIGHT, "http://"));
//		statusLine.add(new FooterLinkContribution("legal", "Legal", ImageProvider.IMG_COPYRIGHT, "http://"));
	}

}


text:
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2
// See http://java.sun.com/xml/jaxb
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2013.09.16 at 12:27:14 AM PDT
//

package com.crawljax.core.plugin.descriptor.jaxb.generated;

import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;

/**
 *
Java class for parameter-list complex type.
 *
 *
The following schema fragment specifies the expected content contained within this class.
 *
 *

 * <complexType name="parameter-list">
 *   <complexContent>
 *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *       <sequence>
 *         <element name="parameter" type="{}parameter" maxOccurs="unbounded"/>
 *       </sequence>
 *     </restriction>
 *   </complexContent>
 * </complexType>
 *

 *
 *
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "parameter-list", propOrder = {
    "parameter"
})
public class ParameterList {

    @XmlElement(required = true)
    protected List<Parameter> parameter;

    /**
     * Gets the value of the parameter property.
     *
     *

     * This accessor method returns a reference to the live list,
     * not a snapshot. Therefore any modification you make to the
     * returned list will be present inside the JAXB object.
     * This is why there is not a set method for the parameter property.
     *
     *

     * For example, to add a new item, do as follows:
     *

     *    getParameter().add(newItem);
     *

     *
     *
     *

     * Objects of the following type(s) are allowed in the list
     * {@link Parameter }
     *
     *
     */
    public List<Parameter> getParameter() {
        if (parameter == null) {
            parameter = new ArrayList<Parameter>();
        }
        return this.parameter;
    }

}