text:
%  INTERNAL FUNCTION: inverse gamma distribution
%
%  Note:
%     One would rarely need to call distribution functions directly.
%     Refer to <densities.html> file for list of supported distributions.
%
%

redpajama_set_name: RedPajamaGithub


text:
// TypeScript Version: 2.0

/// <reference types="@stdlib/types"/>

import { Collection } from '@stdlib/types/object';

/**
 * Inteface describing `frexp`.
 */
interface Frexp {
	/**
	* Splits a double-precision floating-point number into a normalized fraction and an integer power of two.
	*
	* ## Notes
	*
	* -   The first element of the returned array is the normalized fraction and the second is the exponent. The normalized fraction and exponent satisfy the relation `x = frac * 2^exp`.
	* -   If provided positive or negative zero, `NaN`, or positive or negative infinity, the function returns a two-element array containing the input value and an exponent equal to zero.
	* -   For all other numeric input values, the absolute value of the normalized fraction resides on the interval [0.5,1).
	*
	* @param x - input value
	* @returns output array
	*
	* @example
	* var out = frexp( 4.0 );
	* // returns [ 0.5, 3 ]
	*
	* @example
	* var out = frexp( 0.0 );
	* // returns [ 0.0, 0 ]
	*
	* @example
	* var out = frexp( -0.0 );
	* // returns [ -0.0, 0 ]
	*
	* @example
	* var out = frexp( NaN );
	* // returns [ NaN, 0 ]
	*
	* @example
	* var out = frexp( Infinity );
	* // returns [ Infinity , 0 ]
	*
	* @example
	* var out = frexp( -Infinity );
	* // returns [ -Infinity , 0 ]
	*/
	( x: number ): Array<number>;

	/**
	* Splits a double-precision floating-point number into a normalized fraction and an integer power of two and assigns results to a provided output array.
	*
	* ## Notes
	*
	* -   The first element of the returned array is the normalized fraction and the second is the exponent. The normalized fraction and exponent satisfy the relation `x = frac * 2^exp`.
	* -   If provided positive or negative zero, `NaN`, or positive or negative infinity, the function returns a two-element array containing the input value and an exponent equal to zero.
	* -   For all other numeric input values, the absolute value of the normalized fraction resides on the interval [0.5,1).
	*
	* @param x - input value
	* @param out - output array
	* @param stride - output array stride
	* @param offset - output array index offset
	* @returns output array
	*
	* @example
	* var Float64Array = require( `@stdlib/array/float64` );
	*
	* var out = new Float64Array( 2 );
	*
	* var y = frexp.assign( 4.0, out, 1, 0 );
	* // returns <Float64Array>[ 0.5, 3 ]
	*
	* var bool = ( y === out );
	* // returns true
	*/
	assign( x: number, out: Collection, stride: number, offset: number ): Collection; // tslint-disable-line max-line-length
}

/**
* Splits a double-precision floating-point number into a normalized fraction and an integer power of two.
*
* ## Notes
*
* -   The first element of the returned array is the normalized fraction and the second is the exponent. The normalized fraction and exponent satisfy the relation `x = frac * 2^exp`.
* -   If provided positive or negative zero, `NaN`, or positive or negative infinity, the function returns a two-element array containing the input value and an exponent equal to zero.
* -   For all other numeric input values, the absolute value of the normalized fraction resides on the interval [0.5,1).
*
* @param x - input value
* @returns output array
*
* @example
* var out = frexp( 4.0 );
* // returns [ 0.5, 3 ]
*
* @example
* var out = frexp( 0.0 );
* // returns [ 0.0, 0 ]
*
* @example
* var out = frexp( -0.0 );
* // returns [ -0.0, 0 ]
*
* @example
* var out = frexp( NaN );
* // returns [ NaN, 0 ]
*
* @example
* var out = frexp( Infinity );
* // returns [ Infinity , 0 ]
*
* @example
* var out = frexp( -Infinity );
* // returns [ -Infinity , 0 ]
*/
declare var frexp: Frexp;

// EXPORTS //

export = frexp;


text:
import {Component} from '@angular/core';
import {Platform} from 'ionic-angular';
import {TranslateService} from '@ngx-translate/core';
import {HomePage} from './home/home';

@Component({
             templateUrl: 'app.html'
           })
export class MyCaveApp {
  selectedTheme = 'ionic-theme';
  rootPage = HomePage;

  constructor(platform: Platform, translate: TranslateService) {
    platform.ready().then(() => {
      // this language will be used as a fallback when a translation isn't found in the current language
      translate.setDefaultLang('fr');

      // the lang to use, if the lang isn't available, it will use the current loader to get them
      translate.use('fr');
    });
  }
}


text:
package gov.nih.nci.cabig.caaers.web.ae;

import gov.nih.nci.cabig.caaers.dao.AdverseEventDao;
import gov.nih.nci.cabig.caaers.dao.AdverseEventReportingPeriodDao;
import gov.nih.nci.cabig.caaers.dao.CtcCategoryDao;
import gov.nih.nci.cabig.caaers.dao.CtcTermDao;
import gov.nih.nci.cabig.caaers.dao.ExpeditedAdverseEventReportDao;
import gov.nih.nci.cabig.caaers.dao.ParticipantDao;
import gov.nih.nci.cabig.caaers.dao.StudyDao;
import gov.nih.nci.cabig.caaers.dao.TreatmentAssignmentDao;
import gov.nih.nci.cabig.caaers.dao.meddra.LowLevelTermDao;
import gov.nih.nci.cabig.caaers.dao.report.ReportDefinitionDao;
import gov.nih.nci.cabig.caaers.domain.AdverseEvent;
import gov.nih.nci.cabig.caaers.domain.AdverseEventReportingPeriod;
import gov.nih.nci.cabig.caaers.domain.Attribution;
import gov.nih.nci.cabig.caaers.domain.ExpeditedAdverseEventReport;
import gov.nih.nci.cabig.caaers.domain.Grade;
import gov.nih.nci.cabig.caaers.domain.Hospitalization;
import gov.nih.nci.cabig.caaers.domain.OutcomeType;
import gov.nih.nci.cabig.caaers.domain.repository.PersonRepository;
import gov.nih.nci.cabig.caaers.domain.repository.ReportRepository;
import gov.nih.nci.cabig.caaers.domain.repository.UserRepository;
import gov.nih.nci.cabig.caaers.service.EvaluationService;
import gov.nih.nci.cabig.caaers.service.RecommendedActionService;
import gov.nih.nci.cabig.caaers.tools.configuration.Configuration;
import gov.nih.nci.cabig.caaers.tools.spring.tabbedflow.AutomaticSaveAjaxableFormController;
import gov.nih.nci.cabig.caaers.validation.CaaersFieldConfigurationManager;
import gov.nih.nci.cabig.caaers.web.ControllerTools;
import gov.nih.nci.cabig.caaers.web.RenderDecisionManager;
import gov.nih.nci.cabig.caaers.web.RenderDecisionManagerFactoryBean;
import gov.nih.nci.cabig.caaers.web.utils.WebUtils;
import gov.nih.nci.cabig.ctms.web.tabs.Flow;
import gov.nih.nci.cabig.ctms.web.tabs.FlowFactory;
import gov.nih.nci.cabig.ctms.web.tabs.Tab;

import java.util.LinkedHashMap;
import java.util.Map;

import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Required;
import org.springframework.ui.ModelMap;
import org.springframework.validation.BindException;
import org.springframework.validation.Errors;
import org.springframework.web.bind.ServletRequestDataBinder;
import org.springframework.web.servlet.ModelAndView;

public class CaptureAdverseEventController extends AutomaticSaveAjaxableFormController<CaptureAdverseEventInputCommand, AdverseEventReportingPeriod, AdverseEventReportingPeriodDao> {

	public static final String AJAX_SUBVIEW_PARAMETER = "subview";

	private static final String SELECTED_STUDY_ID = "pre_selected_study_id";
	private static final String SELECTED_PARTICIPANT_ID = "pre_selected_participant_id";
	private static final String SELECTED_COURSE_ID = "pre_selected_reporting_period_id";

	private ParticipantDao participantDao;
	private StudyDao studyDao;
	private TreatmentAssignmentDao treatmentAssignmentDao;
	private CtcTermDao ctcTermDao;
	private CtcCategoryDao ctcCategoryDao;
	private LowLevelTermDao lowLevelTermDao;
	private AdverseEventDao adverseEventDao;
	private AdverseEventReportingPeriodDao adverseEventReportingPeriodDao;
	private EvaluationService evaluationService;
	private ReportDefinitionDao reportDefinitionDao;
	private ExpeditedAdverseEventReportDao expeditedAdverseEventReportDao;
	private ReportRepository reportRepository;
	private UserRepository userRepository;
	private PersonRepository personRepository;

	public void setUserRepository(UserRepository userRepository) {
		this.userRepository = userRepository;
	}

	public void setPersonRepository(PersonRepository personRepository) {
		this.personRepository = personRepository;
	}

	private RenderDecisionManagerFactoryBean renderDecisionManagerFactoryBean;
	private CaaersFieldConfigurationManager caaersFieldConfigurationManager;

    private RecommendedActionService recommendedActionService;

	private Configuration configuration;

	private Logger log = Logger.getLogger(getClass());

    public boolean getUnidentifiedMode(){
        boolean unidentifiedMode;
        if (configuration.get(Configuration.UNIDENTIFIED_MODE) == null) unidentifiedMode = false;
        else unidentifiedMode =  configuration.get(Configuration.UNIDENTIFIED_MODE);
        return unidentifiedMode;
    }

    public CaptureAdverseEventController(){
		setBindOnNewForm(true);
		setCommandClass(CaptureAdverseEventInputCommand.class);
	}

	@Override
	protected AdverseEventReportingPeriodDao getDao() {
		return null;
	}

	/**
	 * Will return the {@link AdverseEventReportingPeriod}
	 */
	@Override
	protected AdverseEventReportingPeriod getPrimaryDomainObject(CaptureAdverseEventInputCommand cmd) {
		return cmd.getAdverseEventReportingPeriod();
	}

	@SuppressWarnings("unchecked")
	@Override
	protected Map referenceData(HttpServletRequest request, Object o,	Errors errors, int page) throws Exception {
		CaptureAdverseEventInputCommand command  = (CaptureAdverseEventInputCommand) o;
		Map referenceData =  super.referenceData(request, command, errors, page);
		Map<String, String> summary = new LinkedHashMap<String, String>();

		summary.put("Study", (command.getStudy() == null) ? "" : "(" +  command.getStudy().getPrimaryIdentifierValue() + ") " + command.getStudy().getShortTitle());
        if (getUnidentifiedMode()) {
            summary.put("Participant", "(" + (command.getAssignment() == null ? "" : command.getAssignment().getStudySubjectIdentifier()) + ")");
        } else {
            summary.put("Participant", (command.getParticipant() == null) ? "" : "(" + command.getParticipant().getPrimaryIdentifierValue() + ") " + command.getParticipant().getFullName());
        }

        if(command.getAdverseEventReportingPeriod() != null){
        	summary.put("Course", command.getAdverseEventReportingPeriod().getName());
        }

        //put summary only if page is greater than 0
        if(page > 0){
        	referenceData.put("routineAeSummary", summary);
        }

        RenderDecisionManager renderDecisionManager = renderDecisionManagerFactoryBean.getRenderDecisionManager();
        renderDecisionManager.reveal(caaersFieldConfigurationManager.getListOfApplicableFields(AdverseEventCaptureTab.class.getName()));
        renderDecisionManager.conceal(caaersFieldConfigurationManager.getListOfNotApplicableFields(AdverseEventCaptureTab.class.getName()));
        referenceData.put("unidentifiedMode", getUnidentifiedMode());
		return referenceData;
	}

	@Override
	protected ModelAndView processFinish(HttpServletRequest request, HttpServletResponse response, Object oCommand, BindException errors) throws Exception {

		HttpSession session = request.getSession();
		session.removeAttribute("reviewResult");

		CaptureAdverseEventInputCommand command = (CaptureAdverseEventInputCommand) oCommand;

		//populate the base date, associated to each report definition.
		command.getReviewResult().setBaseDateMap(command.findBaseDateMap(command.getReviewResult().getAeReportId()));

		//populate the report-IDs (for withdraw & amend)
		command.populateReportsToAmend();
		command.populateReportsToWithdraw();

		//populate the reports to un-amend
		command.populateReportsToUnAmend();

		command.save(false);

		//create the model to return
		ModelAndView modelAndView = null;

		Map<String, Object> model = new ModelMap("participant", command.getParticipant().getId());
	    model.put("study", command.getStudy().getId());

		//check if this is alone a withdraw ?
		if(command.getReviewResult().isOnlyActionWithdraw()){
			ExpeditedAdverseEventReport aeReport = command.getAdverseEventReportingPeriod().findExpeditedAdverseEventReport(command.getReviewResult().getAeReportId());
			if(aeReport != null){
				expeditedAdverseEventReportDao.lock(aeReport);
				if(CollectionUtils.isNotEmpty(command.getReviewResult().getUnwantedAEList())){

					//remove all the deselected aes.
					for(Integer aeId : command.getReviewResult().getUnwantedAEList()){
						AdverseEvent ae = aeReport.findAdverseEventById(aeId);
						if(ae == null) continue;
						aeReport.getAdverseEvents().remove(ae);
						ae.clearAttributions();
						ae.setReport(null);
					}

					expeditedAdverseEventReportDao.save(aeReport);
				}

				//process the reports.
				reportRepository.processReports(aeReport, null, command.getReviewResult().getReportsToUnAmendList(), command.getReviewResult().getReportsToWithdraw(), null);

				model.put("adverseEventReportingPeriod", command.getAdverseEventReportingPeriod().getId());
				model.put("addReportingPeriodBinder", "true");
				model.put("displayReportingPeriod", "true");
				model.put("_page", "0");
				model.put("_target1", "1");
				modelAndView = new ModelAndView("redirectToCaptureAe", model);
			}

		}else{
			//continuing to expedited flow
		    if(command.getReviewResult().getAeReportId() > 0){
		    	model.put("aeReport", command.getReviewResult().getAeReportId().intValue());
		    }
		    model.put("from", "captureAE");

		    session.setAttribute("reviewResult", command.getReviewResult());
			modelAndView = new ModelAndView("redirectToExpeditedAeEdit", model);
		}

		return modelAndView;
	}

    @Override
    protected Object currentFormObject(HttpServletRequest request, Object oCommand) throws Exception {
        CaptureAdverseEventInputCommand cmd = (CaptureAdverseEventInputCommand) super.currentFormObject(request, oCommand);
        //reuse existing command for Ajax requests
        if(findInRequest(request,AJAX_SUBVIEW_PARAMETER) != null || isAjaxRequest(request)) return cmd;

        if(cmd.getAdverseEventReportingPeriod() != null && cmd.getAdverseEventReportingPeriod().getId() != null){
            cmd.setAdverseEventReportingPeriod(adverseEventReportingPeriodDao.getById(cmd.getAdverseEventReportingPeriod().getId()));
            cmd.setStudy(cmd.getAdverseEventReportingPeriod().getStudy());
            cmd.setParticipant(cmd.getParticipant());
            //initializing the review comments collection
            cmd.getAdverseEventReportingPeriod().getReviewCommentsInternal().size();
        }

        return cmd;
    }

    /**
	 * Will bind editors for this flow
	 */
	@Override
	protected void initBinder(HttpServletRequest request,ServletRequestDataBinder binder) throws Exception {
        super.initBinder(request,binder);
		ControllerTools.registerDomainObjectEditor(binder,  participantDao);
        ControllerTools.registerDomainObjectEditor(binder,  studyDao);
        ControllerTools.registerDomainObjectEditor(binder,  adverseEventReportingPeriodDao);

        ControllerTools.registerDomainObjectEditor(binder, "adverseEvent", adverseEventDao);
        ControllerTools.registerDomainObjectEditor(binder, ctcTermDao);
        ControllerTools.registerDomainObjectEditor(binder, ctcCategoryDao);
        ControllerTools.registerDomainObjectEditor(binder, lowLevelTermDao);
        ControllerTools.registerEnumEditor(binder, Grade.class);
        ControllerTools.registerEnumEditor(binder, Hospitalization.class);
        ControllerTools.registerEnumEditor(binder, Attribution.class);
        ControllerTools.registerEnumEditor(binder, OutcomeType.class);
	}

	@Override
	protected Object formBackingObject(HttpServletRequest request)	throws Exception {
		CaptureAdverseEventInputCommand cmd = new CaptureAdverseEventInputCommand(adverseEventReportingPeriodDao, evaluationService, recommendedActionService,
				reportDefinitionDao, studyDao, expeditedAdverseEventReportDao, personRepository, userRepository);

		cmd.setWorkflowEnabled(configuration.get(Configuration.ENABLE_WORKFLOW));

        if (findInRequest(request, "study") == null) {

            //restore the values from request or session if they are available.
            HttpSession session = request.getSession();

            Integer studyId = null;
            Integer subjectId = null;
            Integer courseId;

            try {
                studyId = WebUtils.getIntParameter(request, "studyId");
                subjectId = WebUtils.getIntParameter(request, "subjectId");
            } catch (NumberFormatException e) {
            }

            if (studyId == null) studyId = (Integer)session.getAttribute(SELECTED_STUDY_ID);
            if (subjectId == null) subjectId = (Integer)session.getAttribute(SELECTED_PARTICIPANT_ID);

            if (studyId != null) cmd.setStudy(studyDao.getById(studyId));
            if (subjectId != null) cmd.setParticipant(participantDao.getById(subjectId));

            courseId = (Integer)session.getAttribute(SELECTED_COURSE_ID);
            if (courseId != null){
            	cmd.setAdverseEventReportingPeriod(adverseEventReportingPeriodDao.getById(courseId));
            	//initializing the review comments collection
                cmd.getAdverseEventReportingPeriod().getReviewCommentsInternal().size();
            }

        }

        return cmd;
	}

	@Override
	protected ModelAndView handleRequestInternal(HttpServletRequest request,HttpServletResponse response) throws Exception {

		//force clear off the session attribute if the request is re-directed (from Manage Report/Review And Report).
		String displayReportingPeriod = WebUtils.getStringParameter(request, "displayReportingPeriod");
		if(StringUtils.isNotEmpty(displayReportingPeriod)){

			String formAttributeName = getFormSessionAttributeName(request);
			HttpSession session = request.getSession();
			if(session != null){
				session.removeAttribute(formAttributeName);
			}
		}

		return super.handleRequestInternal(request, response);
	}

	/**
	 * Will return true if we are entering into capture flow from Manage Reports or through some other redirection.
	 */
	@Override
    protected boolean isFormSubmission(HttpServletRequest request) {
		String displayReportingPeriod = WebUtils.getStringParameter(request, "displayReportingPeriod");
		if(StringUtils.isNotEmpty(displayReportingPeriod)) return true;
		return super.isFormSubmission(request);
    }

	/**
	 * If the entry to capture adverse event is from Manage reports, we need to handle the invalid submit case, as it the isFormSubmission is flaged 'true'.
	 */

	@Override
	protected ModelAndView handleInvalidSubmit(HttpServletRequest request, HttpServletResponse response) throws Exception{
		String displayReportingPeriod = WebUtils.getStringParameter(request, "displayReportingPeriod");
        HttpSession session = request.getSession();
		Integer studyId = (Integer)session.getAttribute(SELECTED_STUDY_ID);
		Integer subjectId = (Integer)session.getAttribute(SELECTED_PARTICIPANT_ID);
		Integer reportingPeriodId = (Integer)session.getAttribute(SELECTED_COURSE_ID);

		if(StringUtils.isEmpty(displayReportingPeriod)) {
			String url = "/pages/ae/captureRoutine?study="+ studyId +"&participant=" +  subjectId + "&adverseEventReportingPeriod=" + reportingPeriodId  +"&_page=0&_target1=1&displayReportingPeriod=true&addReportingPeriodBinder=true";
			return new ModelAndView("redirect:"+url);
		}

		//generate the form, validate , processFormSubmission.
		Object command = formBackingObject(request);
		ServletRequestDataBinder binder = bindAndValidate(request, command);
		BindException errors = new BindException(binder.getBindingResult());

		return processFormSubmission(request, response, command, errors);

    }

    @Override
	public FlowFactory<CaptureAdverseEventInputCommand> getFlowFactory() {
		return new FlowFactory<CaptureAdverseEventInputCommand>() {
			public Flow<CaptureAdverseEventInputCommand> createFlow(CaptureAdverseEventInputCommand cmd) {

            	/**
            	 * Third level tabs are secured now , Any changes in this flow needs to reflect in
            	 * applicationContext-web-security.xml <util:map id="tabObjectPrivilegeMap">
            	 */
				Flow<CaptureAdverseEventInputCommand> flow = new Flow<CaptureAdverseEventInputCommand>("Enter AEs || Select Subject and Study");
				flow.addTab(new BeginTab<CaptureAdverseEventInputCommand>());
				flow.addTab(new AdverseEventCaptureTab());
				flow.addTab(new ReviewAndReportTab());
				return flow;
			}
		};
	}

	/**
	 * Supress the validation in the following cases.
	 *   1 - When we go back
	 *   2 - When it is an Ajax request, which dont has form submission
	 */

	@Override
    protected boolean suppressValidation(final HttpServletRequest request) {

        Object isAjax = findInRequest(request, AJAX_SUBVIEW_PARAMETER);
        if (isAjax != null) return true;

        //check current page and next page
        int currPage = getCurrentPage(request);
    	int targetPage = getTargetPage(request, currPage);
        return targetPage < currPage;

    }

	/**
     * Returns the value associated with the attributeName, if present in
     * HttpRequest parameter, if not available, will check in HttpRequest attribute map.
     */
    protected Object findInRequest(final ServletRequest request, final String attributName) {

        Object attr = request.getParameter(attributName);
        if (attr == null) {
            attr = request.getAttribute(attributName);
        }
        return attr;
    }

    /**
     * Adds ajax sub-page view capability. TODO: factor this into main tabbed flow controller.
     */
    @Override
    protected String getViewName(HttpServletRequest request, Object command, int page) {
        String subviewName = request.getParameter(AJAX_SUBVIEW_PARAMETER);
        if (subviewName != null) {
            // for side-effects:
            super.getViewName(request, command, page);
            return "ae/ajax/" + subviewName;
        } else {
            return super.getViewName(request, command, page);
        }
    }

   @Override
	protected boolean shouldSave(HttpServletRequest request,CaptureAdverseEventInputCommand command,Tab<CaptureAdverseEventInputCommand> tab) {
		Object isAjax = findInRequest(request, AJAX_SUBVIEW_PARAMETER);
        if (isAjax != null || 1 != getCurrentPage(request)) {
            return false;
        }
       return true;
	}

	@Override
	protected CaptureAdverseEventInputCommand save(final CaptureAdverseEventInputCommand command, final Errors errors){

        if (!errors.hasErrors()) {
            log.debug(String.format(">>> Reporting Period has %d reports.", command.getAdverseEventReportingPeriod().getAeReports().size()));
            command.save();
        }

        return command;
	}

	public ParticipantDao getParticipantDao() {
		return participantDao;
	}

	public void setParticipantDao(ParticipantDao participantDao) {
		this.participantDao = participantDao;
	}

	public StudyDao getStudyDao() {
		return studyDao;
	}

	public void setStudyDao(StudyDao studyDao) {
		this.studyDao = studyDao;
	}

	public void setTreatmentAssignmentDao(
			TreatmentAssignmentDao treatmentAssignmentDao) {
		this.treatmentAssignmentDao = treatmentAssignmentDao;
	}

	public TreatmentAssignmentDao getTreatmentAssignmentDao() {
		return treatmentAssignmentDao;
	}

	public CtcTermDao getCtcTermDao() {
		return ctcTermDao;
	}

	public void setCtcTermDao(CtcTermDao ctcTermDao) {
		this.ctcTermDao = ctcTermDao;
	}

	public CtcCategoryDao getCtcCategoryDao() {
		return ctcCategoryDao;
	}

	public void setCtcCategoryDao(CtcCategoryDao ctcCategoryDao) {
		this.ctcCategoryDao = ctcCategoryDao;
	}

	public LowLevelTermDao getLowLevelTermDao() {
		return lowLevelTermDao;
	}

	public void setLowLevelTermDao(LowLevelTermDao lowLevelTermDao) {
		this.lowLevelTermDao = lowLevelTermDao;
	}

	public AdverseEventReportingPeriodDao getAdverseEventReportingPeriodDao() {
		return adverseEventReportingPeriodDao;
	}

	public void setAdverseEventReportingPeriodDao(
			AdverseEventReportingPeriodDao adverseEventReportingPeriodDao) {
		this.adverseEventReportingPeriodDao = adverseEventReportingPeriodDao;
	}

	public void setAdverseEventDao(AdverseEventDao adverseEventDao) {
		this.adverseEventDao = adverseEventDao;
	}

	public AdverseEventDao getAdverseEventDao() {
		return adverseEventDao;
	}

	public EvaluationService getEvaluationService() {
		return evaluationService;
	}

	public void setEvaluationService(EvaluationService evaluationService) {
		this.evaluationService = evaluationService;
	}

	public ReportDefinitionDao getReportDefinitionDao() {
		return reportDefinitionDao;
	}

	public void setReportDefinitionDao(ReportDefinitionDao reportDefinitionDao){
		this.reportDefinitionDao = reportDefinitionDao;
	}

	public void setRenderDecisionManagerFactoryBean(RenderDecisionManagerFactoryBean renderDecisionManagerFactoryBean) {
		this.renderDecisionManagerFactoryBean = renderDecisionManagerFactoryBean;
	}
	@Required
	public Configuration getConfiguration() {
		return configuration;
	}
	public void setConfiguration(Configuration configuration) {
		this.configuration = configuration;
	}

	public void setExpeditedAdverseEventReportDao(
			ExpeditedAdverseEventReportDao expeditedAdverseEventReportDao) {
		this.expeditedAdverseEventReportDao = expeditedAdverseEventReportDao;
	}
	public ExpeditedAdverseEventReportDao getExpeditedAdverseEventReportDao() {
		return expeditedAdverseEventReportDao;
	}

	@Required
	public void setReportRepository(ReportRepository reportRepository) {
		this.reportRepository = reportRepository;
	}

	@Required
	public void setCaaersFieldConfigurationManager(CaaersFieldConfigurationManager caaersFieldConfigurationManager){
		this.caaersFieldConfigurationManager = caaersFieldConfigurationManager;
	}

    public RecommendedActionService getRecommendedActionService() {
        return recommendedActionService;
    }

    public void setRecommendedActionService(RecommendedActionService recommendedActionService) {
        this.recommendedActionService = recommendedActionService;
    }
}


text:
.class Lcom/android/internal/telephony/sip/SipPhone$SipConnection;
.super Lcom/android/internal/telephony/sip/SipConnectionBase;
.source "SipPhone.java"

# annotations
.annotation system Ldalvik/annotation/EnclosingClass;
    value = Lcom/android/internal/telephony/sip/SipPhone;
.end annotation

.annotation system Ldalvik/annotation/InnerClass;
    accessFlags = 0x2
    name = "SipConnection"
.end annotation

# instance fields
.field private mAdapter:Lcom/android/internal/telephony/sip/SipPhone$SipAudioCallAdapter;

.field private mIncoming:Z

.field private mOriginalNumber:Ljava/lang/String;

.field private mOwner:Lcom/android/internal/telephony/sip/SipPhone$SipCall;

.field private mPeer:Landroid/net/sip/SipProfile;

.field private mSipAudioCall:Landroid/net/sip/SipAudioCall;

.field private mState:Lcom/android/internal/telephony/Call$State;

.field final synthetic this$0:Lcom/android/internal/telephony/sip/SipPhone;

# direct methods
.method public constructor <init>(Lcom/android/internal/telephony/sip/SipPhone;Lcom/android/internal/telephony/sip/SipPhone$SipCall;Landroid/net/sip/SipProfile;)V
    .locals 1
    .parameter
    .parameter "owner"
    .parameter "callee"

    .prologue
    .line 699
    #calls: Lcom/android/internal/telephony/sip/SipPhone;->getUriString(Landroid/net/sip/SipProfile;)Ljava/lang/String;
    invoke-static {p1, p3}, Lcom/android/internal/telephony/sip/SipPhone;->access$1300(Lcom/android/internal/telephony/sip/SipPhone;Landroid/net/sip/SipProfile;)Ljava/lang/String;

    move-result-object v0

    invoke-direct {p0, p1, p2, p3, v0}, Lcom/android/internal/telephony/sip/SipPhone$SipConnection;-><init>(Lcom/android/internal/telephony/sip/SipPhone;Lcom/android/internal/telephony/sip/SipPhone$SipCall;Landroid/net/sip/SipProfile;Ljava/lang/String;)V

    .line 700
    return-void
.end method

.method public constructor <init>(Lcom/android/internal/telephony/sip/SipPhone;Lcom/android/internal/telephony/sip/SipPhone$SipCall;Landroid/net/sip/SipProfile;Ljava/lang/String;)V
    .locals 1
    .parameter
    .parameter "owner"
    .parameter "callee"
    .parameter "originalNumber"

    .prologue
    .line 691
    iput-object p1, p0, Lcom/android/internal/telephony/sip/SipPhone$SipConnection;->this$0:Lcom/android/internal/telephony/sip/SipPhone;

    .line 692
    invoke-direct {p0, p4}, Lcom/android/internal/telephony/sip/SipConnectionBase;-><init>(Ljava/lang/String;)V

    .line 612
    sget-object v0, Lcom/android/internal/telephony/Call$State;->IDLE:Lcom/android/internal/telephony/Call$State;

    iput-object v0, p0, Lcom/android/internal/telephony/sip/SipPhone$SipConnection;->mState:Lcom/android/internal/telephony/Call$State;

    .line 615
    const/4 v0, 0x0

    iput-boolean v0, p0, Lcom/android/internal/telephony/sip/SipPhone$SipConnection;->mIncoming:Z

    .line 617
    new-instance v0, Lcom/android/internal/telephony/sip/SipPhone$SipConnection$1;

    invoke-direct {v0, p0}, Lcom/android/internal/telephony/sip/SipPhone$SipConnection$1;-><init>(Lcom/android/internal/telephony/sip/SipPhone$SipConnection;)V

    iput-object v0, p0, Lcom/android/internal/telephony/sip/SipPhone$SipConnection;->mAdapter:Lcom/android/internal/telephony/sip/SipPhone$SipAudioCallAdapter;

    .line 693
    iput-object p2, p0, Lcom/android/internal/telephony/sip/SipPhone$SipConnection;->mOwner:Lcom/android/internal/telephony/sip/SipPhone$SipCall;

    .line 694
    iput-object p3, p0, Lcom/android/internal/telephony/sip/SipPhone$SipConnection;->mPeer:Landroid/net/sip/SipProfile;

    .line 695
    iput-object p4, p0, Lcom/android/internal/telephony/sip/SipPhone$SipConnection;->mOriginalNumber:Ljava/lang/String;

    .line 696
    return-void
.end method

.method static synthetic access$1000(Lcom/android/internal/telephony/sip/SipPhone$SipConnection;)Lcom/android/internal/telephony/Call$State;
    .locals 1
    .parameter "x0"

    .prologue
    .line 609
    iget-object v0, p0, Lcom/android/internal/telephony/sip/SipPhone$SipConnection;->mState:Lcom/android/internal/telephony/Call$State;

    return-object v0
.end method

.method static synthetic access$700(Lcom/android/internal/telephony/sip/SipPhone$SipConnection;)Landroid/net/sip/SipAudioCall;
    .locals 1
    .parameter "x0"

    .prologue
    .line 609
    iget-object v0, p0, Lcom/android/internal/telephony/sip/SipPhone$SipConnection;->mSipAudioCall:Landroid/net/sip/SipAudioCall;

    return-object v0
.end method

.method static synthetic access$702(Lcom/android/internal/telephony/sip/SipPhone$SipConnection;Landroid/net/sip/SipAudioCall;)Landroid/net/sip/SipAudioCall;
    .locals 0
    .parameter "x0"
    .parameter "x1"

    .prologue
    .line 609
    iput-object p1, p0, Lcom/android/internal/telephony/sip/SipPhone$SipConnection;->mSipAudioCall:Landroid/net/sip/SipAudioCall;

    return-object p1
.end method

.method static synthetic access$800(Lcom/android/internal/telephony/sip/SipPhone$SipConnection;)Landroid/net/sip/SipProfile;
    .locals 1
    .parameter "x0"

    .prologue
    .line 609
    iget-object v0, p0, Lcom/android/internal/telephony/sip/SipPhone$SipConnection;->mPeer:Landroid/net/sip/SipProfile;

    return-object v0
.end method

.method static synthetic access$900(Lcom/android/internal/telephony/sip/SipPhone$SipConnection;)Lcom/android/internal/telephony/sip/SipPhone$SipCall;
    .locals 1
    .parameter "x0"

    .prologue
    .line 609
    iget-object v0, p0, Lcom/android/internal/telephony/sip/SipPhone$SipConnection;->mOwner:Lcom/android/internal/telephony/sip/SipPhone$SipCall;

    return-object v0
.end method

# virtual methods
.method acceptCall()V
    .locals 4
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Lcom/android/internal/telephony/CallStateException;
        }
    .end annotation

    .prologue
    .line 723
    :try_start_0
    iget-object v1, p0, Lcom/android/internal/telephony/sip/SipPhone$SipConnection;->mSipAudioCall:Landroid/net/sip/SipAudioCall;

    const/16 v2, 0x8

    invoke-virtual {v1, v2}, Landroid/net/sip/SipAudioCall;->answerCall(I)V
    :try_end_0
    .catch Landroid/net/sip/SipException; {:try_start_0 .. :try_end_0} :catch_0

    .line 727
    return-void

    .line 724
    :catch_0
    move-exception v0

    .line 725
    .local v0, e:Landroid/net/sip/SipException;
    new-instance v1, Lcom/android/internal/telephony/CallStateException;

    new-instance v2, Ljava/lang/StringBuilder;

    invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V

    const-string v3, "acceptCall(): "

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    invoke-direct {v1, v2}, Lcom/android/internal/telephony/CallStateException;-><init>(Ljava/lang/String;)V

    throw v1
.end method

.method changeOwner(Lcom/android/internal/telephony/sip/SipPhone$SipCall;)V
    .locals 0
    .parameter "owner"

    .prologue
    .line 730
    iput-object p1, p0, Lcom/android/internal/telephony/sip/SipPhone$SipConnection;->mOwner:Lcom/android/internal/telephony/sip/SipPhone$SipCall;

    .line 731
    return-void
.end method

.method dial()V
    .locals 5
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Landroid/net/sip/SipException;
        }
    .end annotation

    .prologue
    .line 739
    sget-object v0, Lcom/android/internal/telephony/Call$State;->DIALING:Lcom/android/internal/telephony/Call$State;

    invoke-virtual {p0, v0}, Lcom/android/internal/telephony/sip/SipPhone$SipConnection;->setState(Lcom/android/internal/telephony/Call$State;)V

    .line 740
    iget-object v0, p0, Lcom/android/internal/telephony/sip/SipPhone$SipConnection;->this$0:Lcom/android/internal/telephony/sip/SipPhone;

    #getter for: Lcom/android/internal/telephony/sip/SipPhone;->mSipManager:Landroid/net/sip/SipManager;
    invoke-static {v0}, Lcom/android/internal/telephony/sip/SipPhone;->access$1400(Lcom/android/internal/telephony/sip/SipPhone;)Landroid/net/sip/SipManager;

    move-result-object v0

    iget-object v1, p0, Lcom/android/internal/telephony/sip/SipPhone$SipConnection;->this$0:Lcom/android/internal/telephony/sip/SipPhone;

    #getter for: Lcom/android/internal/telephony/sip/SipPhone;->mProfile:Landroid/net/sip/SipProfile;
    invoke-static {v1}, Lcom/android/internal/telephony/sip/SipPhone;->access$100(Lcom/android/internal/telephony/sip/SipPhone;)Landroid/net/sip/SipProfile;

    move-result-object v1

    iget-object v2, p0, Lcom/android/internal/telephony/sip/SipPhone$SipConnection;->mPeer:Landroid/net/sip/SipProfile;

    const/4 v3, 0x0

    const/16 v4, 0xf

    invoke-virtual {v0, v1, v2, v3, v4}, Landroid/net/sip/SipManager;->makeAudioCall(Landroid/net/sip/SipProfile;Landroid/net/sip/SipProfile;Landroid/net/sip/SipAudioCall$Listener;I)Landroid/net/sip/SipAudioCall;

    move-result-object v0

    iput-object v0, p0, Lcom/android/internal/telephony/sip/SipPhone$SipConnection;->mSipAudioCall:Landroid/net/sip/SipAudioCall;

    .line 742
    iget-object v0, p0, Lcom/android/internal/telephony/sip/SipPhone$SipConnection;->mSipAudioCall:Landroid/net/sip/SipAudioCall;

    iget-object v1, p0, Lcom/android/internal/telephony/sip/SipPhone$SipConnection;->mAdapter:Lcom/android/internal/telephony/sip/SipPhone$SipAudioCallAdapter;

    invoke-virtual {v0, v1}, Landroid/net/sip/SipAudioCall;->setListener(Landroid/net/sip/SipAudioCall$Listener;)V

    .line 743
    return-void
.end method

.method public getAddress()Ljava/lang/String;
    .locals 1

    .prologue
    .line 797
    iget-object v0, p0, Lcom/android/internal/telephony/sip/SipPhone$SipConnection;->mOriginalNumber:Ljava/lang/String;

    return-object v0
.end method

.method getAudioGroup()Landroid/net/rtp/AudioGroup;
    .locals 1

    .prologue
    .line 734
    iget-object v0, p0, Lcom/android/internal/telephony/sip/SipPhone$SipConnection;->mSipAudioCall:Landroid/net/sip/SipAudioCall;

    if-nez v0, :cond_0

    const/4 v0, 0x0

    .line 735
    :goto_0
    return-object v0

    :cond_0
    iget-object v0, p0, Lcom/android/internal/telephony/sip/SipPhone$SipConnection;->mSipAudioCall:Landroid/net/sip/SipAudioCall;

    invoke-virtual {v0}, Landroid/net/sip/SipAudioCall;->getAudioGroup()Landroid/net/rtp/AudioGroup;

    move-result-object v0

    goto :goto_0
.end method

.method public bridge synthetic getCall()Lcom/android/internal/telephony/Call;
    .locals 1

    .prologue
    .line 609
    invoke-virtual {p0}, Lcom/android/internal/telephony/sip/SipPhone$SipConnection;->getCall()Lcom/android/internal/telephony/sip/SipPhone$SipCall;

    move-result-object v0

    return-object v0
.end method

.method public getCall()Lcom/android/internal/telephony/sip/SipPhone$SipCall;
    .locals 1

    .prologue
    .line 802
    iget-object v0, p0, Lcom/android/internal/telephony/sip/SipPhone$SipConnection;->mOwner:Lcom/android/internal/telephony/sip/SipPhone$SipCall;

    return-object v0
.end method

.method public getCnapName()Ljava/lang/String;
    .locals 2

    .prologue
    .line 704
    iget-object v1, p0, Lcom/android/internal/telephony/sip/SipPhone$SipConnection;->mPeer:Landroid/net/sip/SipProfile;

    invoke-virtual {v1}, Landroid/net/sip/SipProfile;->getDisplayName()Ljava/lang/String;

    move-result-object v0

    .line 705
    .local v0, displayName:Ljava/lang/String;
    invoke-static {v0}, Landroid/text/TextUtils;->isEmpty(Ljava/lang/CharSequence;)Z

    move-result v1

    if-eqz v1, :cond_0

    const/4 v0, 0x0

    .end local v0           #displayName:Ljava/lang/String;
    :cond_0
    return-object v0
.end method

.method getMute()Z
    .locals 1

    .prologue
    .line 771
    iget-object v0, p0, Lcom/android/internal/telephony/sip/SipPhone$SipConnection;->mSipAudioCall:Landroid/net/sip/SipAudioCall;

    if-nez v0, :cond_0

    const/4 v0, 0x0

    :goto_0
    return v0

    :cond_0
    iget-object v0, p0, Lcom/android/internal/telephony/sip/SipPhone$SipConnection;->mSipAudioCall:Landroid/net/sip/SipAudioCall;

    invoke-virtual {v0}, Landroid/net/sip/SipAudioCall;->isMuted()Z

    move-result v0

    goto :goto_0
.end method

.method public getNumberPresentation()I
    .locals 1

    .prologue
    .line 711
    sget v0, Lcom/android/internal/telephony/PhoneConstants;->PRESENTATION_ALLOWED:I

    return v0
.end method

.method protected getPhone()Lcom/android/internal/telephony/Phone;
    .locals 1

    .prologue
    .line 807
    iget-object v0, p0, Lcom/android/internal/telephony/sip/SipPhone$SipConnection;->mOwner:Lcom/android/internal/telephony/sip/SipPhone$SipCall;

    invoke-virtual {v0}, Lcom/android/internal/telephony/sip/SipPhone$SipCall;->getPhone()Lcom/android/internal/telephony/Phone;

    move-result-object v0

    return-object v0
.end method

.method public getState()Lcom/android/internal/telephony/Call$State;
    .locals 1

    .prologue
    .line 784
    iget-object v0, p0, Lcom/android/internal/telephony/sip/SipPhone$SipConnection;->mState:Lcom/android/internal/telephony/Call$State;

    return-object v0
.end method

.method public hangup()V
    .locals 7
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Lcom/android/internal/telephony/CallStateException;
        }
    .end annotation

    .prologue
    .line 812
    const-class v4, Lcom/android/internal/telephony/sip/SipPhone;

    monitor-enter v4

    .line 813
    :try_start_0
    const-string v2, "SipPhone"

    new-instance v3, Ljava/lang/StringBuilder;

    invoke-direct {v3}, Ljava/lang/StringBuilder;-><init>()V

    const-string v5, "hangup conn: "

    invoke-virtual {v3, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v3

    iget-object v5, p0, Lcom/android/internal/telephony/sip/SipPhone$SipConnection;->mPeer:Landroid/net/sip/SipProfile;

    invoke-virtual {v5}, Landroid/net/sip/SipProfile;->getUriString()Ljava/lang/String;

    move-result-object v5

    invoke-virtual {v3, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v3

    const-string v5, ": "

    invoke-virtual {v3, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v3

    iget-object v5, p0, Lcom/android/internal/telephony/sip/SipPhone$SipConnection;->mState:Lcom/android/internal/telephony/Call$State;

    invoke-virtual {v3, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;

    move-result-object v3

    const-string v5, ": on phone "

    invoke-virtual {v3, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v3

    invoke-virtual {p0}, Lcom/android/internal/telephony/sip/SipPhone$SipConnection;->getPhone()Lcom/android/internal/telephony/Phone;

    move-result-object v5

    invoke-interface {v5}, Lcom/android/internal/telephony/Phone;->getPhoneName()Ljava/lang/String;

    move-result-object v5

    invoke-virtual {v3, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v3

    invoke-virtual {v3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v3

    invoke-static {v2, v3}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    .line 816
    iget-object v2, p0, Lcom/android/internal/telephony/sip/SipPhone$SipConnection;->mState:Lcom/android/internal/telephony/Call$State;

    invoke-virtual {v2}, Lcom/android/internal/telephony/Call$State;->isAlive()Z

    move-result v2

    if-nez v2, :cond_0

    monitor-exit v4
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    .line 832
    :goto_0
    return-void

    .line 818
    :cond_0
    :try_start_1
    iget-object v1, p0, Lcom/android/internal/telephony/sip/SipPhone$SipConnection;->mSipAudioCall:Landroid/net/sip/SipAudioCall;

    .line 819
    .local v1, sipAudioCall:Landroid/net/sip/SipAudioCall;
    if-eqz v1, :cond_1

    .line 820
    const/4 v2, 0x0

    invoke-virtual {v1, v2}, Landroid/net/sip/SipAudioCall;->setListener(Landroid/net/sip/SipAudioCall$Listener;)V

    .line 821
    invoke-virtual {v1}, Landroid/net/sip/SipAudioCall;->endCall()V
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_1
    .catch Landroid/net/sip/SipException; {:try_start_1 .. :try_end_1} :catch_0

    .line 826
    :cond_1
    :try_start_2
    iget-object v3, p0, Lcom/android/internal/telephony/sip/SipPhone$SipConnection;->mAdapter:Lcom/android/internal/telephony/sip/SipPhone$SipAudioCallAdapter;

    iget-object v2, p0, Lcom/android/internal/telephony/sip/SipPhone$SipConnection;->mState:Lcom/android/internal/telephony/Call$State;

    sget-object v5, Lcom/android/internal/telephony/Call$State;->INCOMING:Lcom/android/internal/telephony/Call$State;

    if-eq v2, v5, :cond_2

    iget-object v2, p0, Lcom/android/internal/telephony/sip/SipPhone$SipConnection;->mState:Lcom/android/internal/telephony/Call$State;

    sget-object v5, Lcom/android/internal/telephony/Call$State;->WAITING:Lcom/android/internal/telephony/Call$State;

    if-ne v2, v5, :cond_5

    :cond_2
    sget-object v2, Lcom/android/internal/telephony/Connection$DisconnectCause;->INCOMING_REJECTED:Lcom/android/internal/telephony/Connection$DisconnectCause;

    :goto_1
    invoke-virtual {v3, v2}, Lcom/android/internal/telephony/sip/SipPhone$SipAudioCallAdapter;->onCallEnded(Lcom/android/internal/telephony/Connection$DisconnectCause;)V

    .line 831
    monitor-exit v4

    goto :goto_0

    .end local v1           #sipAudioCall:Landroid/net/sip/SipAudioCall;
    :catchall_0
    move-exception v2

    monitor-exit v4
    :try_end_2
    .catchall {:try_start_2 .. :try_end_2} :catchall_0

    throw v2

    .line 823
    :catch_0
    move-exception v0

    .line 824
    .local v0, e:Landroid/net/sip/SipException;
    :try_start_3
    new-instance v2, Lcom/android/internal/telephony/CallStateException;

    new-instance v3, Ljava/lang/StringBuilder;

    invoke-direct {v3}, Ljava/lang/StringBuilder;-><init>()V

    const-string v5, "hangup(): "

    invoke-virtual {v3, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v3

    invoke-virtual {v3, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;

    move-result-object v3

    invoke-virtual {v3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v3

    invoke-direct {v2, v3}, Lcom/android/internal/telephony/CallStateException;-><init>(Ljava/lang/String;)V

    throw v2
    :try_end_3
    .catchall {:try_start_3 .. :try_end_3} :catchall_1

    .line 826
    .end local v0           #e:Landroid/net/sip/SipException;
    :catchall_1
    move-exception v2

    :try_start_4
    iget-object v5, p0, Lcom/android/internal/telephony/sip/SipPhone$SipConnection;->mAdapter:Lcom/android/internal/telephony/sip/SipPhone$SipAudioCallAdapter;

    iget-object v3, p0, Lcom/android/internal/telephony/sip/SipPhone$SipConnection;->mState:Lcom/android/internal/telephony/Call$State;

    sget-object v6, Lcom/android/internal/telephony/Call$State;->INCOMING:Lcom/android/internal/telephony/Call$State;

    if-eq v3, v6, :cond_3

    iget-object v3, p0, Lcom/android/internal/telephony/sip/SipPhone$SipConnection;->mState:Lcom/android/internal/telephony/Call$State;

    sget-object v6, Lcom/android/internal/telephony/Call$State;->WAITING:Lcom/android/internal/telephony/Call$State;

    if-ne v3, v6, :cond_4

    :cond_3
    sget-object v3, Lcom/android/internal/telephony/Connection$DisconnectCause;->INCOMING_REJECTED:Lcom/android/internal/telephony/Connection$DisconnectCause;

    :goto_2
    invoke-virtual {v5, v3}, Lcom/android/internal/telephony/sip/SipPhone$SipAudioCallAdapter;->onCallEnded(Lcom/android/internal/telephony/Connection$DisconnectCause;)V

    throw v2

    :cond_4
    sget-object v3, Lcom/android/internal/telephony/Connection$DisconnectCause;->LOCAL:Lcom/android/internal/telephony/Connection$DisconnectCause;

    goto :goto_2

    .restart local v1       #sipAudioCall:Landroid/net/sip/SipAudioCall;
    :cond_5
    sget-object v2, Lcom/android/internal/telephony/Connection$DisconnectCause;->LOCAL:Lcom/android/internal/telephony/Connection$DisconnectCause;
    :try_end_4
    .catchall {:try_start_4 .. :try_end_4} :catchall_0

    goto :goto_1
.end method

.method hold()V
    .locals 4
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Lcom/android/internal/telephony/CallStateException;
        }
    .end annotation

    .prologue
    .line 746
    sget-object v1, Lcom/android/internal/telephony/Call$State;->HOLDING:Lcom/android/internal/telephony/Call$State;

    invoke-virtual {p0, v1}, Lcom/android/internal/telephony/sip/SipPhone$SipConnection;->setState(Lcom/android/internal/telephony/Call$State;)V

    .line 748
    :try_start_0
    iget-object v1, p0, Lcom/android/internal/telephony/sip/SipPhone$SipConnection;->mSipAudioCall:Landroid/net/sip/SipAudioCall;

    const/16 v2, 0xf

    invoke-virtual {v1, v2}, Landroid/net/sip/SipAudioCall;->holdCall(I)V
    :try_end_0
    .catch Landroid/net/sip/SipException; {:try_start_0 .. :try_end_0} :catch_0

    .line 752
    return-void

    .line 749
    :catch_0
    move-exception v0

    .line 750
    .local v0, e:Landroid/net/sip/SipException;
    new-instance v1, Lcom/android/internal/telephony/CallStateException;

    new-instance v2, Ljava/lang/StringBuilder;

    invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V

    const-string v3, "hold(): "

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    invoke-direct {v1, v2}, Lcom/android/internal/telephony/CallStateException;-><init>(Ljava/lang/String;)V

    throw v1
.end method

.method initIncomingCall(Landroid/net/sip/SipAudioCall;Lcom/android/internal/telephony/Call$State;)V
    .locals 1
    .parameter "sipAudioCall"
    .parameter "newState"

    .prologue
    .line 715
    invoke-virtual {p0, p2}, Lcom/android/internal/telephony/sip/SipPhone$SipConnection;->setState(Lcom/android/internal/telephony/Call$State;)V

    .line 716
    iput-object p1, p0, Lcom/android/internal/telephony/sip/SipPhone$SipConnection;->mSipAudioCall:Landroid/net/sip/SipAudioCall;

    .line 717
    iget-object v0, p0, Lcom/android/internal/telephony/sip/SipPhone$SipConnection;->mAdapter:Lcom/android/internal/telephony/sip/SipPhone$SipAudioCallAdapter;

    invoke-virtual {p1, v0}, Landroid/net/sip/SipAudioCall;->setListener(Landroid/net/sip/SipAudioCall$Listener;)V

    .line 718
    const/4 v0, 0x1

    iput-boolean v0, p0, Lcom/android/internal/telephony/sip/SipPhone$SipConnection;->mIncoming:Z

    .line 719
    return-void
.end method

.method public isIncoming()Z
    .locals 1

    .prologue
    .line 789
    iget-boolean v0, p0, Lcom/android/internal/telephony/sip/SipPhone$SipConnection;->mIncoming:Z

    return v0
.end method

.method public separate()V
    .locals 7
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Lcom/android/internal/telephony/CallStateException;
        }
    .end annotation

    .prologue
    .line 836
    const-class v4, Lcom/android/internal/telephony/sip/SipPhone;

    monitor-enter v4

    .line 837
    :try_start_0
    invoke-virtual {p0}, Lcom/android/internal/telephony/sip/SipPhone$SipConnection;->getPhone()Lcom/android/internal/telephony/Phone;

    move-result-object v3

    iget-object v5, p0, Lcom/android/internal/telephony/sip/SipPhone$SipConnection;->this$0:Lcom/android/internal/telephony/sip/SipPhone;

    if-ne v3, v5, :cond_0

    iget-object v3, p0, Lcom/android/internal/telephony/sip/SipPhone$SipConnection;->this$0:Lcom/android/internal/telephony/sip/SipPhone;

    invoke-virtual {v3}, Lcom/android/internal/telephony/sip/SipPhone;->getBackgroundCall()Lcom/android/internal/telephony/Call;

    move-result-object v3

    check-cast v3, Lcom/android/internal/telephony/sip/SipPhone$SipCall;

    move-object v1, v3

    .line 840
    .local v1, call:Lcom/android/internal/telephony/sip/SipPhone$SipCall;
    :goto_0
    invoke-virtual {v1}, Lcom/android/internal/telephony/sip/SipPhone$SipCall;->getState()Lcom/android/internal/telephony/Call$State;

    move-result-object v3

    sget-object v5, Lcom/android/internal/telephony/Call$State;->IDLE:Lcom/android/internal/telephony/Call$State;

    if-eq v3, v5, :cond_1

    .line 841
    new-instance v3, Lcom/android/internal/telephony/CallStateException;

    new-instance v5, Ljava/lang/StringBuilder;

    invoke-direct {v5}, Ljava/lang/StringBuilder;-><init>()V

    const-string v6, "cannot put conn back to a call in non-idle state: "

    invoke-virtual {v5, v6}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v5

    invoke-virtual {v1}, Lcom/android/internal/telephony/sip/SipPhone$SipCall;->getState()Lcom/android/internal/telephony/Call$State;

    move-result-object v6

    invoke-virtual {v5, v6}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;

    move-result-object v5

    invoke-virtual {v5}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v5

    invoke-direct {v3, v5}, Lcom/android/internal/telephony/CallStateException;-><init>(Ljava/lang/String;)V

    throw v3

    .line 863
    .end local v1           #call:Lcom/android/internal/telephony/sip/SipPhone$SipCall;
    :catchall_0
    move-exception v3

    monitor-exit v4
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    throw v3

    .line 837
    :cond_0
    :try_start_1
    iget-object v3, p0, Lcom/android/internal/telephony/sip/SipPhone$SipConnection;->this$0:Lcom/android/internal/telephony/sip/SipPhone;

    invoke-virtual {v3}, Lcom/android/internal/telephony/sip/SipPhone;->getForegroundCall()Lcom/android/internal/telephony/Call;

    move-result-object v3

    check-cast v3, Lcom/android/internal/telephony/sip/SipPhone$SipCall;

    move-object v1, v3

    goto :goto_0

    .line 845
    .restart local v1       #call:Lcom/android/internal/telephony/sip/SipPhone$SipCall;
    :cond_1
    const-string v3, "SipPhone"

    new-instance v5, Ljava/lang/StringBuilder;

    invoke-direct {v5}, Ljava/lang/StringBuilder;-><init>()V

    const-string/jumbo v6, "separate conn: "

    invoke-virtual {v5, v6}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v5

    iget-object v6, p0, Lcom/android/internal/telephony/sip/SipPhone$SipConnection;->mPeer:Landroid/net/sip/SipProfile;

    invoke-virtual {v6}, Landroid/net/sip/SipProfile;->getUriString()Ljava/lang/String;

    move-result-object v6

    invoke-virtual {v5, v6}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v5

    const-string v6, " from "

    invoke-virtual {v5, v6}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v5

    iget-object v6, p0, Lcom/android/internal/telephony/sip/SipPhone$SipConnection;->mOwner:Lcom/android/internal/telephony/sip/SipPhone$SipCall;

    invoke-virtual {v5, v6}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;

    move-result-object v5

    const-string v6, " back to "

    invoke-virtual {v5, v6}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v5

    invoke-virtual {v5, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;

    move-result-object v5

    invoke-virtual {v5}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v5

    invoke-static {v3, v5}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    .line 850
    invoke-virtual {p0}, Lcom/android/internal/telephony/sip/SipPhone$SipConnection;->getPhone()Lcom/android/internal/telephony/Phone;

    move-result-object v2

    .line 851
    .local v2, originalPhone:Lcom/android/internal/telephony/Phone;
    #calls: Lcom/android/internal/telephony/sip/SipPhone$SipCall;->getAudioGroup()Landroid/net/rtp/AudioGroup;
    invoke-static {v1}, Lcom/android/internal/telephony/sip/SipPhone$SipCall;->access$1500(Lcom/android/internal/telephony/sip/SipPhone$SipCall;)Landroid/net/rtp/AudioGroup;

    move-result-object v0

    .line 852
    .local v0, audioGroup:Landroid/net/rtp/AudioGroup;
    #calls: Lcom/android/internal/telephony/sip/SipPhone$SipCall;->add(Lcom/android/internal/telephony/sip/SipPhone$SipConnection;)V
    invoke-static {v1, p0}, Lcom/android/internal/telephony/sip/SipPhone$SipCall;->access$1600(Lcom/android/internal/telephony/sip/SipPhone$SipCall;Lcom/android/internal/telephony/sip/SipPhone$SipConnection;)V

    .line 853
    iget-object v3, p0, Lcom/android/internal/telephony/sip/SipPhone$SipConnection;->mSipAudioCall:Landroid/net/sip/SipAudioCall;

    invoke-virtual {v3, v0}, Landroid/net/sip/SipAudioCall;->setAudioGroup(Landroid/net/rtp/AudioGroup;)V

    .line 857
    invoke-interface {v2}, Lcom/android/internal/telephony/Phone;->switchHoldingAndActive()V

    .line 860
    iget-object v3, p0, Lcom/android/internal/telephony/sip/SipPhone$SipConnection;->this$0:Lcom/android/internal/telephony/sip/SipPhone;

    invoke-virtual {v3}, Lcom/android/internal/telephony/sip/SipPhone;->getForegroundCall()Lcom/android/internal/telephony/Call;

    move-result-object v1

    .end local v1           #call:Lcom/android/internal/telephony/sip/SipPhone$SipCall;
    check-cast v1, Lcom/android/internal/telephony/sip/SipPhone$SipCall;

    .line 861
    .restart local v1       #call:Lcom/android/internal/telephony/sip/SipPhone$SipCall;
    iget-object v3, p0, Lcom/android/internal/telephony/sip/SipPhone$SipConnection;->mSipAudioCall:Landroid/net/sip/SipAudioCall;

    invoke-virtual {v3}, Landroid/net/sip/SipAudioCall;->startAudio()V

    .line 862
    invoke-virtual {v1, p0}, Lcom/android/internal/telephony/sip/SipPhone$SipCall;->onConnectionStateChanged(Lcom/android/internal/telephony/sip/SipPhone$SipConnection;)V

    .line 863
    monitor-exit v4
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_0

    .line 864
    return-void
.end method

.method setMute(Z)V
    .locals 1
    .parameter "muted"

    .prologue
    .line 765
    iget-object v0, p0, Lcom/android/internal/telephony/sip/SipPhone$SipConnection;->mSipAudioCall:Landroid/net/sip/SipAudioCall;

    if-eqz v0, :cond_0

    iget-object v0, p0, Lcom/android/internal/telephony/sip/SipPhone$SipConnection;->mSipAudioCall:Landroid/net/sip/SipAudioCall;

    invoke-virtual {v0}, Landroid/net/sip/SipAudioCall;->isMuted()Z

    move-result v0

    if-eq p1, v0, :cond_0

    .line 766
    iget-object v0, p0, Lcom/android/internal/telephony/sip/SipPhone$SipConnection;->mSipAudioCall:Landroid/net/sip/SipAudioCall;

    invoke-virtual {v0}, Landroid/net/sip/SipAudioCall;->toggleMute()V

    .line 768
    :cond_0
    return-void
.end method

.method protected setState(Lcom/android/internal/telephony/Call$State;)V
    .locals 1
    .parameter "state"

    .prologue
    .line 777
    iget-object v0, p0, Lcom/android/internal/telephony/sip/SipPhone$SipConnection;->mState:Lcom/android/internal/telephony/Call$State;

    if-ne p1, v0, :cond_0

    .line 780
    :goto_0
    return-void

    .line 778
    :cond_0
    invoke-super {p0, p1}, Lcom/android/internal/telephony/sip/SipConnectionBase;->setState(Lcom/android/internal/telephony/Call$State;)V

    .line 779
    iput-object p1, p0, Lcom/android/internal/telephony/sip/SipPhone$SipConnection;->mState:Lcom/android/internal/telephony/Call$State;

    goto :goto_0
.end method

.method unhold(Landroid/net/rtp/AudioGroup;)V
    .locals 4
    .parameter "audioGroup"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Lcom/android/internal/telephony/CallStateException;
        }
    .end annotation

    .prologue
    .line 755
    iget-object v1, p0, Lcom/android/internal/telephony/sip/SipPhone$SipConnection;->mSipAudioCall:Landroid/net/sip/SipAudioCall;

    invoke-virtual {v1, p1}, Landroid/net/sip/SipAudioCall;->setAudioGroup(Landroid/net/rtp/AudioGroup;)V

    .line 756
    sget-object v1, Lcom/android/internal/telephony/Call$State;->ACTIVE:Lcom/android/internal/telephony/Call$State;

    invoke-virtual {p0, v1}, Lcom/android/internal/telephony/sip/SipPhone$SipConnection;->setState(Lcom/android/internal/telephony/Call$State;)V

    .line 758
    :try_start_0
    iget-object v1, p0, Lcom/android/internal/telephony/sip/SipPhone$SipConnection;->mSipAudioCall:Landroid/net/sip/SipAudioCall;

    const/16 v2, 0xf

    invoke-virtual {v1, v2}, Landroid/net/sip/SipAudioCall;->continueCall(I)V
    :try_end_0
    .catch Landroid/net/sip/SipException; {:try_start_0 .. :try_end_0} :catch_0

    .line 762
    return-void

    .line 759
    :catch_0
    move-exception v0

    .line 760
    .local v0, e:Landroid/net/sip/SipException;
    new-instance v1, Lcom/android/internal/telephony/CallStateException;

    new-instance v2, Ljava/lang/StringBuilder;

    invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V

    const-string/jumbo v3, "unhold(): "

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    invoke-direct {v1, v2}, Lcom/android/internal/telephony/CallStateException;-><init>(Ljava/lang/String;)V

    throw v1
.end method


text:
package com.datt.smartroutertest

import akka.actor.ActorSystem
import scala.concurrent.duration._
import akka.util.Timeout
import spray.can.Http
import akka.io.IO
import akka.pattern.ask
import spray.client.pipelining._
import spray.http._
import scala.concurrent.{Await, Future}
import spray.json._
import DefaultJsonProtocol._
import scala.collection.mutable
import spray.http.HttpRequest
import spray.http.HttpResponse
import spray.http.HttpHeaders.`Set-Cookie`

object Main {
  implicit val system = ActorSystem()
  import system.dispatcher // execution context for futures

  val timeoutDuration = 20.seconds

  val cookies = mutable.Map[Integer, List[HttpCookie]]().withDefaultValue(List())

  private def withCookies(client: Integer): HttpRequest => HttpRequest =
    if (cookies(client).size > 0) addHeader(HttpHeaders.Cookie(cookies(client))) else identity

  def extractCookies(res: HttpResponse) = res.headers.collect { case `Set-Cookie`(hc) => hc }
  private def storeCookies(client: Integer): Future[HttpResponse] => Future[HttpResponse] =
    (response) => for (res <- response) yield { cookies(client) = extractCookies(res); res }

  private def issueRequest(client: Integer, hostname: String, port: Integer, req: HttpRequest): Future[HttpResponse] = {
    implicit val timeout = Timeout.durationToTimeout(timeoutDuration)
    val connectedSendReceive = for {
      Http.HostConnectorInfo(connector, _) <-
        IO(Http) ? Http.HostConnectorSetup(hostname, port = port)
    } yield sendReceive(connector)

    val pipeline = for (sendRecv <- connectedSendReceive) yield
        addHeader("Accept", "application/json") ~>
        withCookies(client)                     ~>
        sendRecv                                ~>
        storeCookies(client)                    ~>
        unmarshal[HttpResponse]

    pipeline.flatMap(_(req))
  }

  private def getResponseJson(client: Integer, host: String, port: Integer, req: HttpRequest): JsValue = {
    val response = issueRequest(client, host, port, Get("/"))
    val res = Await.result(response, timeoutDuration)
    assert(res.status == StatusCode.int2StatusCode(200))
    res.entity.asString.asJson
  }

  def main(args: Array[String]): Unit = {
    val Array(host, portStr) = args.head.split(":")

    class RichJsVal(jsVal: JsValue) { def getField(key: String) = jsVal.asJsObject.fields(key) }
    implicit def richJsVal(jsVal: JsValue) = new RichJsVal(jsVal)

    val clients = 0 until 20
    clients.par.foreach { client =>
      val getServerIP = () =>
        getResponseJson(client, host, portStr.toInt, Get("/")).getField("IP").convertTo[String]
      val serverIP = getServerIP()
      for (req <- 0 until 100) assert(serverIP == getServerIP())
    }

    sys.exit(0)
  }
}


text:
import { Injectable } from '@angular/core';
import HtmlHelper from '../Utils/HtmlHelper';

@Injectable()
class ScrollBarMeasureService {
    private height: number = 0;
    private width: number = 0;

    get Height(): number{
        return this.height;
    }

    get Width(): number{
        return this.width;
    }

    constructor(){
        let size = HtmlHelper.getScrollbarSize();
        this.height = size.height;
        this.width = size.width;
    }
}

export { ScrollBarMeasureService };


text:
require 'rails_helper'

module Shopper
  RSpec.describe ShippingAddress, type: :model do
    it { expect(ShippingAddress.new.class.superclass).to eq(Address) }
  end
end


text:
var TODOApp;
(function (TODOApp) {
    var MainHeaderCtrl = (function () {
        function MainHeaderCtrl($localForage, $rootScope) {
            this.$localForage = $localForage;
            this.$rootScope = $rootScope;
            this.$inject = ['$rootScope'];
            var self = this;
            self.filter = "";
            self.activate();
        }
        MainHeaderCtrl.prototype.activate = function () {
            var that = this;
            that.$rootScope.$watch(function () {
                return that.filter;
            }, function (newVal, oldVal) {
                that.search(newVal, oldVal);
            });
        };
        MainHeaderCtrl.prototype.search = function (newVal, oldVal) {
            var that = this;
            if (newVal != oldVal) {
                that.$rootScope.$emit("searchTasks", that.filter);
            }
        };
        return MainHeaderCtrl;
    })();
    TODOApp.TODOAppModule.controller("MainHeaderCtrl", MainHeaderCtrl);
})(TODOApp || (TODOApp = {}));
//# sourceMappingURL=mainHeaderCtrl.js.map


text:
Apache Cordova 4 Programming: Chapter 6
========================================

The files in this folder are some helper files I created to align with the content in the chapter.

Helper Utilities
----------------

The cva-create files (`cva-create.cmd` and `cva-create.sh`) are the example code from Listing 6.1 and 6.2, essentially scripts that automate the Cordova application creation process. I also published a node module to perform this same task; you can read more about it at [https://github.com/johnwargo/cdva-create](https://github.com/johnwargo/cdva-create).

The make-hooks files (`make-hooks.cmd` and `make-hooks.sh`) are simple script files that create the hooks sub-folders for you. After I finished the book, I published a node module to perform this same task; you can read more about it at [https://github.com/johnwargo/cdva-make-hooks](https://github.com/johnwargo/cdva-make-hooks).

To use any of these utilities, copy them to your development folder or place them in a location on your system path so you can execute them from anywhere.

Sample Hooks
------------
The `pause.cmd` file is a simple Windows command file I created to help me test Hooks on Windows. It does nothing except write some text to the terminal window then execute the pause command which causes the command file to wait until a keypress before existing.

The `test.js` file is a simple node application I created to help me test running a node application as a hook. The application simply writes some content to the console and nothing more.

***

You can find information on many different topics on my [personal blog](http://www.johnwargo.com). Learn about all of my publications at [John Wargo Books](http://www.johnwargobooks.com).


text:
package bdv.ui.rangeslider;

import javax.swing.JSlider;

/**
 * An extension of JSlider to select a range of values using two thumb controls.
 * The thumb controls are used to select the lower and upper value of a range
 * with predetermined minimum and maximum values.
 *

 * Note that RangeSlider makes use of the default BoundedRangeModel, which
 * supports an inner range defined by a value and an extent. The upper value
 * returned by RangeSlider is simply the lower value plus the extent.
 *

 * This is copied from https://github.com/ernieyu/Swing-range-slider with the
 * following changes:
 *

 *
The slider thumbs push each other. That is, the upper thumb can be
 * dragged below the lower thumb, and it will drag the lower thumb with it, and
 * vice versa

 *
The {@link #setRange(int, int)} method was added, which sets both the
 * lower and upper values simultaneously.

 *

 *

 *
 *

 * =============================================================================
 *
 * The MIT License Copyright (c) 2010 Ernest Yu. All rights reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 *

 */
public class RangeSlider extends JSlider
{
	private static final long serialVersionUID = 1L;

	/**
	 * Constructs a RangeSlider with default minimum and maximum values of 0 and
	 * 100.
	 */
	public RangeSlider()
	{
		initSlider();
	}

	/**
	 * Constructs a RangeSlider with the specified default minimum and maximum
	 * values.
	 */
	public RangeSlider( final int min, final int max )
	{
		super( min, max );
		initSlider();
	}

	/**
	 * Initializes the slider by setting default properties.
	 */
	private void initSlider()
	{
		setOrientation( HORIZONTAL );
	}

	/**
	 * Overrides the superclass method to install the UI delegate to draw two
	 * thumbs.
	 */
	@Override
	public void updateUI()
	{
		setUI( new RangeSliderUI( this ) );
		// Update UI for slider labels. This must be called after updating the
		// UI of the slider. Refer to JSlider.updateUI().
		updateLabelUIs();
	}

	/**
	 * Returns the lower value in the range.
	 */
	@Override
	public int getValue()
	{
		return super.getValue();
	}

	/**
	 * Sets the lower value in the range.
	 */
	@Override
	public void setValue( final int value )
	{
		final int oldValue = getValue();
		if ( oldValue == value )
		{ return; }

		// Compute new value and extent to maintain upper value.
		final int oldExtent = getExtent();
		final int newValue = Math.min( Math.max( getMinimum(), value ), oldValue + oldExtent );
		final int newExtent = oldExtent + oldValue - newValue;

		// Set new value and extent, and fire a single change event.
		getModel().setRangeProperties( newValue, newExtent, getMinimum(),
				getMaximum(), getValueIsAdjusting() );
	}

	/**
	 * Returns the upper value in the range.
	 */
	public int getUpperValue()
	{
		return getValue() + getExtent();
	}

	/**
	 * Sets the upper value in the range.
	 */
	public void setUpperValue( final int value )
	{
		// Compute new extent.
		final int lowerValue = getValue();
		final int newExtent = Math.min( Math.max( 0, value - lowerValue ), getMaximum() - lowerValue );

		// Set extent to set upper value.
		setExtent( newExtent );
	}

	/**
	 * Sets both the lower and upper values in the range.
	 */
	public void setRange( final int lower, final int upper )
	{
		final int newValue = Math.max( getMinimum(), Math.min( getMaximum(), lower ) );
		final int newUpper = Math.max( newValue, Math.min( getMaximum(), upper ) );
		final int newExtent = newUpper - newValue;

		// Set new value and extent, and fire a single change event.
		getModel().setRangeProperties( newValue, newExtent, getMinimum(),
				getMaximum(), getValueIsAdjusting() );
	}
}


text:
// =============================================================================
// PROJECT CHRONO - http://projectchrono.org
//
// Copyright (c) 2014 projectchrono.org
// All rights reserved.
//
// Use of this source code is governed by a BSD-style license that can be found
// in the LICENSE file at the top level of the distribution and at
// http://projectchrono.org/license-chrono.txt.
//
// =============================================================================
// Authors: Alessandro Tasora
// =============================================================================

#include "chrono/physics/ChLinkMotorRotationDriveline.h"

namespace chrono {

// Register into the object factory, to enable run-time dynamic creation and persistence
CH_FACTORY_REGISTER(ChLinkMotorRotationDriveline)

ChLinkMotorRotationDriveline::ChLinkMotorRotationDriveline() {
    this->c_rz = false;
    SetupLinkMask();

    innershaft1 = chrono_types::make_shared<ChShaft>();
    innershaft2 = chrono_types::make_shared<ChShaft>();
    innerconstraint1 = chrono_types::make_shared<ChShaftsBody>();
    innerconstraint2 = chrono_types::make_shared<ChShaftsBody>();
}

ChLinkMotorRotationDriveline::ChLinkMotorRotationDriveline(const ChLinkMotorRotationDriveline& other)
    : ChLinkMotorRotation(other) {
    innershaft1 = other.innershaft1;
    innershaft2 = other.innershaft2;
    innerconstraint1 = other.innerconstraint1;
    innerconstraint2 = other.innerconstraint2;
}

ChLinkMotorRotationDriveline::~ChLinkMotorRotationDriveline() {}

void ChLinkMotorRotationDriveline::Initialize(std::shared_ptr<ChBodyFrame> mbody1,
                                              std::shared_ptr<ChBodyFrame> mbody2,
                                              ChFrame<> mabsframe) {
    this->Initialize(mbody1, mbody2, false, mabsframe, mabsframe);
}

void ChLinkMotorRotationDriveline::Initialize(std::shared_ptr<ChBodyFrame> mbody1,
                                              std::shared_ptr<ChBodyFrame> mbody2,
                                              bool pos_are_relative,
                                              ChFrame<> mframe1,
                                              ChFrame<> mframe2) {
    ChLinkMotorRotation::Initialize(mbody1, mbody2, pos_are_relative, mframe1, mframe2);
    innerconstraint1->Initialize(innershaft1, mbody1, VECT_Z);
    innerconstraint2->Initialize(innershaft2, mbody2, VECT_Z);
}

void ChLinkMotorRotationDriveline::Initialize(std::shared_ptr<ChBodyFrame> mbody1,
                                              std::shared_ptr<ChBodyFrame> mbody2,
                                              bool pos_are_relative,
                                              ChVector<> mpt1,
                                              ChVector<> mpt2,
                                              ChVector<> mnorm1,
                                              ChVector<> mnorm2) {
    ChLinkMotorRotation::Initialize(mbody1, mbody2, pos_are_relative, mpt1, mpt2, mnorm1, mnorm2);
    innerconstraint1->Initialize(innershaft1, mbody1, VECT_Z);
    innerconstraint2->Initialize(innershaft2, mbody2, VECT_Z);
}

void ChLinkMotorRotationDriveline::Setup() {
	if (innershaft1->IsActive()) {
        innershaft1->SetOffset_x(this->offset_x + 0);
        innershaft1->SetOffset_w(this->offset_w + 0);
	}
    if (innershaft2->IsActive()) {
        innershaft2->SetOffset_x(this->offset_x + 1);
        innershaft2->SetOffset_w(this->offset_w + 1);
    }
    int nc = mask.nconstr;
    innerconstraint1->SetOffset_L(this->offset_L + nc + 0);
    innerconstraint2->SetOffset_L(this->offset_L + nc + 1);
}

void ChLinkMotorRotationDriveline::Update(double mytime, bool update_assets) {
    // Inherit parent class:
    ChLinkMotorRotation::Update(mytime, update_assets);

    // Update the direction of 1D-3D ChShaftBody constraints:
    ChVector<> abs_shaftdir = this->GetLinkAbsoluteCoords().TransformDirectionLocalToParent(VECT_Z);
    ChVector<> shaftdir_b1 = this->Body1->TransformDirectionParentToLocal(abs_shaftdir);
    ChVector<> shaftdir_b2 = this->Body2->TransformDirectionParentToLocal(abs_shaftdir);

    innerconstraint1->SetShaftDirection(shaftdir_b1);
    innerconstraint2->SetShaftDirection(shaftdir_b2);
}

int ChLinkMotorRotationDriveline::GetDOF() {
    return 2 + ChLinkMotorRotation::GetDOF();
}

int ChLinkMotorRotationDriveline::GetDOC() {
    return 2 + ChLinkMotorRotation::GetDOC();
}

int ChLinkMotorRotationDriveline::GetDOC_c() {
    return 2 + ChLinkMotorRotation::GetDOC_c();
}

void ChLinkMotorRotationDriveline::IntStateGather(const unsigned int off_x,
                                  ChState& x,
                                  const unsigned int off_v,
                                  ChStateDelta& v,
                                  double& T) {
    // First, inherit to parent class
    ChLinkMotorRotation::IntStateGather(off_x, x, off_v, v, T);

    innershaft1->IntStateGather(off_x + 0, x, off_v + 0, v, T);
    innershaft2->IntStateGather(off_x + 1, x, off_v + 1, v, T);
}

void ChLinkMotorRotationDriveline::IntStateScatter(const unsigned int off_x,
                                                   const ChState& x,
                                                   const unsigned int off_v,
                                                   const ChStateDelta& v,
                                                   const double T,
                                                   bool full_update) {
    // First, inherit to parent class
    ChLinkMotorRotation::IntStateScatter(off_x, x, off_v, v, T, full_update);

    innershaft1->IntStateScatter(off_x + 0, x, off_v + 0, v, T, full_update);
    innershaft2->IntStateScatter(off_x + 1, x, off_v + 1, v, T, full_update);

    Update(T, full_update);
}

void ChLinkMotorRotationDriveline::IntStateGatherAcceleration(const unsigned int off_a, ChStateDelta& a) {
    // First, inherit to parent class
    ChLinkMotorRotation::IntStateGatherAcceleration(off_a, a);

    innershaft1->IntStateScatterAcceleration(off_a + 0, a);
    innershaft2->IntStateScatterAcceleration(off_a + 1, a);
}

void ChLinkMotorRotationDriveline::IntStateScatterAcceleration(const unsigned int off_a, const ChStateDelta& a) {
    // First, inherit to parent class
    ChLinkMotorRotation::IntStateScatterAcceleration(off_a, a);

    innershaft1->IntStateScatterAcceleration(off_a + 0, a);
    innershaft2->IntStateScatterAcceleration(off_a + 1, a);
}

void ChLinkMotorRotationDriveline::IntStateIncrement(const unsigned int off_x,
                                     ChState& x_new,
                                     const ChState& x,
                                     const unsigned int off_v,
                                     const ChStateDelta& Dv) {
    // First, inherit to parent class
    ChLinkMotorRotation::IntStateIncrement(off_x, x_new, x, off_v, Dv);

    innershaft1->IntStateIncrement(off_x + 0, x_new, x, off_v + 0, Dv);
    innershaft2->IntStateIncrement(off_x + 1, x_new, x, off_v + 1, Dv);
}

void ChLinkMotorRotationDriveline::IntStateGatherReactions(const unsigned int off_L, ChVectorDynamic<>& L) {
    // First, inherit to parent class
    ChLinkMotorRotation::IntStateGatherReactions(off_L, L);

    int nc = mask.nconstr;
    innerconstraint1->IntStateGatherReactions(off_L + nc + 0, L);
    innerconstraint2->IntStateGatherReactions(off_L + nc + 1, L);
}

void ChLinkMotorRotationDriveline::IntStateScatterReactions(const unsigned int off_L, const ChVectorDynamic<>& L) {
    // First, inherit to parent class
    ChLinkMotorRotation::IntStateScatterReactions(off_L, L);

    int nc = mask.nconstr;
    innerconstraint1->IntStateScatterReactions(off_L + nc + 0, L);
    innerconstraint2->IntStateScatterReactions(off_L + nc + 1, L);
}

void ChLinkMotorRotationDriveline::IntLoadResidual_F(const unsigned int off, ChVectorDynamic<>& R, const double c) {
    // First, inherit to parent class
    ChLinkMotorRotation::IntLoadResidual_F(off, R, c);

    innershaft1->IntLoadResidual_F(off + 0, R, c);
    innershaft2->IntLoadResidual_F(off + 1, R, c);
}

void ChLinkMotorRotationDriveline::IntLoadResidual_Mv(const unsigned int off,
                                      ChVectorDynamic<>& R,
                                      const ChVectorDynamic<>& w,
                                      const double c) {
    // First, inherit to parent class
    ChLinkMotorRotation::IntLoadResidual_Mv(off, R, w, c);

    innershaft1->IntLoadResidual_Mv(off + 0, R, w, c);
    innershaft2->IntLoadResidual_Mv(off + 1, R, w, c);
}

void ChLinkMotorRotationDriveline::IntLoadResidual_CqL(const unsigned int off_L,
                                       ChVectorDynamic<>& R,
                                       const ChVectorDynamic<>& L,
                                       const double c) {
    // First, inherit to parent class
    ChLinkMotorRotation::IntLoadResidual_CqL(off_L, R, L, c);

    int nc = mask.nconstr;
    innerconstraint1->IntLoadResidual_CqL(off_L + nc + 0, R, L, c);
    innerconstraint2->IntLoadResidual_CqL(off_L + nc + 1, R, L, c);
}

void ChLinkMotorRotationDriveline::IntLoadConstraint_C(const unsigned int off_L,
                                       ChVectorDynamic<>& Qc,
                                       const double c,
                                       bool do_clamp,
                                       double recovery_clamp) {
    // First, inherit to parent class
    ChLinkMotorRotation::IntLoadConstraint_C(off_L, Qc, c, do_clamp, recovery_clamp);

    int nc = mask.nconstr;
    // the following always set zero C, so skip them ...
    //innerconstraint1->IntLoadConstraint_C(off_L + nc + 0, Qc, c, do_clamp, recovery_clamp);
    //innerconstraint2->IntLoadConstraint_C(off_L + nc + 1, Qc, c, do_clamp, recovery_clamp);
    // ...and compute custom violation C:
    double cnstr_rot_error =  this->GetMotorRot() - (this->innershaft1->GetPos() - this->innershaft2->GetPos());

    double cnstr_violation = c * cnstr_rot_error;

    if (do_clamp)
        cnstr_violation = ChMin(ChMax(cnstr_violation, -recovery_clamp), recovery_clamp);

    // lump violation in the 1st shaft-3D-1D constraints:
    Qc(off_L + nc + 0) += cnstr_violation;

}

void ChLinkMotorRotationDriveline::IntLoadConstraint_Ct(const unsigned int off_L, ChVectorDynamic<>& Qc, const double c) {
    // First, inherit to parent class
    ChLinkMotorRotation::IntLoadConstraint_Ct(off_L, Qc, c);

    int nc = mask.nconstr;
    innerconstraint1->IntLoadConstraint_Ct(off_L + nc + 0, Qc, c);
    innerconstraint2->IntLoadConstraint_Ct(off_L + nc + 1, Qc, c);
}

void ChLinkMotorRotationDriveline::IntToDescriptor(const unsigned int off_v,
                                   const ChStateDelta& v,
                                   const ChVectorDynamic<>& R,
                                   const unsigned int off_L,
                                   const ChVectorDynamic<>& L,
                                   const ChVectorDynamic<>& Qc) {
    // First, inherit to parent class
    ChLinkMotorRotation::IntToDescriptor(off_v, v, R, off_L, L, Qc);

    innershaft1->IntToDescriptor(off_v, v, R, off_L, L, Qc);
    innershaft2->IntToDescriptor(off_v + 1, v, R, off_L, L, Qc);
    int nc = mask.nconstr;
    innerconstraint1->IntToDescriptor(off_v, v, R, off_L + nc + 0, L, Qc);
    innerconstraint2->IntToDescriptor(off_v, v, R, off_L + nc + 1, L, Qc);
}

void ChLinkMotorRotationDriveline::IntFromDescriptor(const unsigned int off_v,
                                     ChStateDelta& v,
                                     const unsigned int off_L,
                                     ChVectorDynamic<>& L) {
    // First, inherit to parent class
    ChLinkMotorRotation::IntFromDescriptor(off_v, v, off_L, L);

    innershaft1->IntFromDescriptor(off_v, v, off_L, L);
    innershaft2->IntFromDescriptor(off_v + 1, v, off_L, L);
    int nc = mask.nconstr;
    innerconstraint1->IntFromDescriptor(off_v, v, off_L + nc + 0, L);
    innerconstraint2->IntFromDescriptor(off_v, v, off_L + nc + 1, L);
}

//
//  SOLVER functions
//

void ChLinkMotorRotationDriveline::InjectConstraints(ChSystemDescriptor& mdescriptor) {
    // First, inherit to parent class
    ChLinkMotorRotation::InjectConstraints(mdescriptor);

    innerconstraint1->InjectConstraints(mdescriptor);
    innerconstraint2->InjectConstraints(mdescriptor);
}

void ChLinkMotorRotationDriveline::ConstraintsBiReset() {
    // First, inherit to parent class
    ChLinkMotorRotation::ConstraintsBiReset();

    innerconstraint1->ConstraintsBiReset();
    innerconstraint2->ConstraintsBiReset();
}

void ChLinkMotorRotationDriveline::ConstraintsBiLoad_C(double factor, double recovery_clamp, bool do_clamp) {
    // First, inherit to parent class
    ChLinkMotorRotation::ConstraintsBiLoad_C(factor, recovery_clamp, do_clamp);

    innerconstraint1->ConstraintsBiLoad_C(factor, recovery_clamp, do_clamp);
    innerconstraint2->ConstraintsBiLoad_C(factor, recovery_clamp, do_clamp);
}

void ChLinkMotorRotationDriveline::ConstraintsBiLoad_Ct(double factor) {
    // First, inherit to parent class
    ChLinkMotorRotation::ConstraintsBiLoad_Ct(factor);

    innerconstraint1->ConstraintsBiLoad_Ct(factor);
    innerconstraint2->ConstraintsBiLoad_Ct(factor);
}

void ChLinkMotorRotationDriveline::ConstraintsLoadJacobians() {
    // First, inherit to parent class
    ChLinkMotorRotation::ConstraintsLoadJacobians();

    innerconstraint1->ConstraintsLoadJacobians();
    innerconstraint2->ConstraintsLoadJacobians();
}

void ChLinkMotorRotationDriveline::ConstraintsFetch_react(double factor) {
    // First, inherit to parent class
    ChLinkMotorRotation::ConstraintsFetch_react(factor);

    innerconstraint1->ConstraintsFetch_react(factor);
    innerconstraint2->ConstraintsFetch_react(factor);
}

void ChLinkMotorRotationDriveline::InjectVariables(ChSystemDescriptor& mdescriptor) {
    // First, inherit to parent class
    ChLinkMotorRotation::InjectVariables(mdescriptor);

    innershaft1->InjectVariables(mdescriptor);
    innershaft2->InjectVariables(mdescriptor);
}

void ChLinkMotorRotationDriveline::VariablesFbReset() {
    // First, inherit to parent class
    ChLinkMotorRotation::VariablesFbReset();

    innershaft1->VariablesFbReset();
    innershaft2->VariablesFbReset();
}

void ChLinkMotorRotationDriveline::VariablesFbLoadForces(double factor) {
    // First, inherit to parent class
    ChLinkMotorRotation::VariablesFbLoadForces(factor);

    innershaft1->VariablesFbLoadForces(factor);
    innershaft2->VariablesFbLoadForces(factor);
}

void ChLinkMotorRotationDriveline::VariablesFbIncrementMq() {
    // inherit parent class
    ChLinkMotorRotation::VariablesFbIncrementMq();

    innershaft1->VariablesFbIncrementMq();
    innershaft2->VariablesFbIncrementMq();
}

void ChLinkMotorRotationDriveline::VariablesQbLoadSpeed() {
    // First, inherit to parent class
    ChLinkMotorRotation::VariablesQbLoadSpeed();

    innershaft1->VariablesQbLoadSpeed();
    innershaft2->VariablesQbLoadSpeed();
}

void ChLinkMotorRotationDriveline::VariablesQbSetSpeed(double step) {
    // First, inherit to parent class
    ChLinkMotorRotation::VariablesQbSetSpeed(step);

    innershaft1->VariablesQbSetSpeed(step);
    innershaft2->VariablesQbSetSpeed(step);
}

void ChLinkMotorRotationDriveline::VariablesQbIncrementPosition(double step) {
    // First, inherit to parent class
    ChLinkMotorRotation::VariablesQbIncrementPosition(step);

    innershaft1->VariablesQbIncrementPosition(step);
    innershaft2->VariablesQbIncrementPosition(step);
}

void ChLinkMotorRotationDriveline::ArchiveOUT(ChArchiveOut& marchive) {
    // version number
    marchive.VersionWrite<ChLinkMotorRotationDriveline>();

    // serialize parent class
    ChLinkMotorRotation::ArchiveOUT(marchive);

    // serialize all member data:
    marchive << CHNVP(innershaft1);
    marchive << CHNVP(innershaft2);
    marchive << CHNVP(innerconstraint1);
    marchive << CHNVP(innerconstraint2);
}

/// Method to allow de serialization of transient data from archives.
void ChLinkMotorRotationDriveline::ArchiveIN(ChArchiveIn& marchive) {
    // version number
    /*int version =*/ marchive.VersionRead<ChLinkMotorRotationDriveline>();

    // deserialize parent class
    ChLinkMotorRotation::ArchiveIN(marchive);

    // deserialize all member data:
    marchive >> CHNVP(innershaft1);
    marchive >> CHNVP(innershaft2);
    marchive >> CHNVP(innerconstraint1);
    marchive >> CHNVP(innerconstraint2);
}

}  // end namespace chrono


text:
#ifndef AAPT_LOGGER_H
#define AAPT_LOGGER_H

#include "Source.h"

#include <memory>
#include <ostream>
#include <string>
#include <utils/String8.h>

namespace aapt {

struct Log {
    Log(std::ostream& out, std::ostream& err);
    Log(const Log& rhs) = delete;

    std::ostream& out;
    std::ostream& err;
};

class Logger {
public:
    static void setLog(const std::shared_ptr<Log>& log);

    static std::ostream& error();
    static std::ostream& error(const Source& source);
    static std::ostream& error(const SourceLine& sourceLine);

    static std::ostream& warn();
    static std::ostream& warn(const Source& source);
    static std::ostream& warn(const SourceLine& sourceLine);

    static std::ostream& note();
    static std::ostream& note(const Source& source);
    static std::ostream& note(const SourceLine& sourceLine);

private:
    static std::shared_ptr<Log> sLog;
};

class SourceLogger {
public:
    SourceLogger(const Source& source);

    std::ostream& error();
    std::ostream& error(size_t line);

    std::ostream& warn();
    std::ostream& warn(size_t line);

    std::ostream& note();
    std::ostream& note(size_t line);

private:
    Source mSource;
};

inline ::std::ostream& operator<<(::std::ostream& out, const std::u16string& str) {
    android::String8 utf8(str.data(), str.size());
    return out.write(utf8.string(), utf8.size());
}

} // namespace aapt

#endif // AAPT_LOGGER_H