text:
package org.orekit.files.ccsds.ndm.cdm;

import org.hipparchus.linear.MatrixUtils;
import org.hipparchus.linear.RealMatrix;
import org.orekit.errors.OrekitException;
import org.orekit.errors.OrekitMessages;
import org.orekit.files.ccsds.section.CommentsContainer;

/**
 * Container for XYZ covariance matrix data. This class as a RealMatrix as
 * attribute which can be acces with getXYZCovariaxMatrix method. Beware that
 * there are thus 2 ways to modify the XYZ covariance : setC... ( setCxx,
 * setCyx ...) which should be prioritized and getXYZCovariaxMatrix.setEntry(row, col, value).
 *
 The XYZ Covariance Matrix is only provided if {@link CdmMetadataKey#ALT_COV_TYPE} is {@link AltCovarianceType#XYZ}, otherwise
 * its terms will return NaN.

 *
 When available, the matrix is given in the 9×9 Lower Triangular Form. All parameters of the 6×6 position/velocity submatrix
 * are mandatory. The remaining elements will return NaN if not provided.

 */
public class XYZCovariance extends CommentsContainer {

    /** XYZ covariance matrix. */
    private RealMatrix covarianceMatrix;

    /** Flag indicating whether the alternate covariance type set in the CDM Object metadata section is XYZ. */
    private boolean covXYZset;

    /** Simple constructor. To update matrix value there are 2 ways to modify the XYZ
     * covariance : setC... ( setCxx, setCyx ...) which should be prioritized and
     * getXYZCovariaxMatrix.setEntry(row, col, value).
     *
 The XYZ Covariance Matrix is only provided if {@link CdmMetadataKey#ALT_COV_TYPE} is {@link AltCovarianceType#XYZ}, otherwise
     * its terms will return NaN.

     *
 When available, the matrix is given in the 9×9 Lower Triangular Form. All parameters of the 6×6 position/velocity submatrix
     * are mandatory. The remaining elements will return NaN if not provided.

     * @param covXYZset Flag indicating whether the alternate covariance type set in the CDM Object metadata section is XYZ.
     */
    public XYZCovariance(final boolean covXYZset) {
        this.covXYZset = covXYZset;
        covarianceMatrix = MatrixUtils.createRealMatrix(9, 9);
        for (int i = 0; i < covarianceMatrix.getRowDimension(); ++i) {
            for (int j = 0; j <= i; ++j) {
                covarianceMatrix.setEntry(i, j, Double.NaN);
            }
        }

    }

    /** {@inheritDoc} */
    @Override
    public void validate(final double version) {
        super.validate(version);

        // Conditional on ALT_COV_TYPE = XYZ
        if (!isCovXYZset()) {
            throw new OrekitException(OrekitMessages.CCSDS_DATE_INVALID_PREAMBLE_FIELD, CdmMetadataKey.ALT_COV_TYPE);
        }

        // We only check values that are mandatory in a cdm file
        checkNotNaN(getCxx(),              XYZCovarianceKey.CX_X);
        checkNotNaN(getCyx(),              XYZCovarianceKey.CY_X);
        checkNotNaN(getCyy(),              XYZCovarianceKey.CY_Y);
        checkNotNaN(getCzx(),              XYZCovarianceKey.CZ_X);
        checkNotNaN(getCzy(),              XYZCovarianceKey.CZ_Y);
        checkNotNaN(getCzz(),              XYZCovarianceKey.CZ_Z);
        checkNotNaN(getCxdotx(),           XYZCovarianceKey.CXDOT_X);
        checkNotNaN(getCxdoty(),           XYZCovarianceKey.CXDOT_Y);
        checkNotNaN(getCxdotz(),           XYZCovarianceKey.CXDOT_Z);
        checkNotNaN(getCxdotxdot(),        XYZCovarianceKey.CXDOT_XDOT);
        checkNotNaN(getCydotx(),           XYZCovarianceKey.CYDOT_X);
        checkNotNaN(getCydoty(),           XYZCovarianceKey.CYDOT_Y);
        checkNotNaN(getCydotz(),           XYZCovarianceKey.CYDOT_Z);
        checkNotNaN(getCydotxdot(),        XYZCovarianceKey.CYDOT_XDOT);
        checkNotNaN(getCydotydot(),        XYZCovarianceKey.CYDOT_YDOT);
        checkNotNaN(getCzdotx(),           XYZCovarianceKey.CZDOT_X);
        checkNotNaN(getCzdoty(),           XYZCovarianceKey.CZDOT_Y);
        checkNotNaN(getCzdotz(),           XYZCovarianceKey.CZDOT_Z);
        checkNotNaN(getCzdotxdot(),        XYZCovarianceKey.CZDOT_XDOT);
        checkNotNaN(getCzdotydot(),        XYZCovarianceKey.CZDOT_YDOT);
        checkNotNaN(getCzdotzdot(),        XYZCovarianceKey.CZDOT_ZDOT);
    }

    /** Set an entry in the XYZ covariance matrix.
     *

     * Both m(j, k) and m(k, j) are set.
     *

     * @param j row index (must be between 0 and 5 (inclusive)
     * @param k column index (must be between 0 and 5 (inclusive)
     * @param entry value of the matrix entry
     */
    public void setCovarianceMatrixEntry(final int j, final int k, final double entry) {
        covarianceMatrix.setEntry(j, k, entry);
        covarianceMatrix.setEntry(k, j, entry);
    }

    /**
     * Get the XYZ covariance matrix.
     *
 The XYZ Covariance Matrix is only provided if {@link CdmMetadataKey#ALT_COV_TYPE} is {@link AltCovarianceType#XYZ}, otherwise
     * its terms will return NaN.

     *
 When available, the matrix is given in the 9×9 Lower Triangular Form. All parameters of the 6×6 position/velocity submatrix
     * are mandatory. The remaining elements will return NaN if not provided.

     * @return the XYZ covariance matrix
     */
    public RealMatrix getXYZCovarianceMatrix() {
        return covarianceMatrix;
    }

    /**
     * Get the object [1,1] in covariance matrix (with index starting at 1).
     * @return the object [1,1] in covariance matrix (in m²)
     */
    public double getCxx() {
        return covarianceMatrix.getEntry(0, 0);
    }

    /**
     * Set the object [1,1] in covariance matrix (with index starting at 1).
     * @param CXX = object [1,1] in covariance matrix (in m²)
     */
    public void setCxx(final double CXX) {
        refuseFurtherComments();

        // Conditional on ALT_COV_TYPE = XYZ
        if (!isCovXYZset()) {
            throw new OrekitException(OrekitMessages.CCSDS_DATE_INVALID_PREAMBLE_FIELD, CdmMetadataKey.ALT_COV_TYPE);
        }

        setCovarianceMatrixEntry(0, 0, CXX);
    }

    /**
     * Get the object [2,1] in covariance matrix (with index starting at 1).
     * @return the object [2,1] in covariance matrix (in m²)
     */
    public double getCyx() {
        return covarianceMatrix.getEntry(1, 0);
    }

    /**
     * Set the object [2,1] in covariance matrix (with index starting at 1).
     * @param CYX = object [2,1] in covariance matrix (in m²)
     */
    public void setCyx(final double CYX) {
        refuseFurtherComments();
        setCovarianceMatrixEntry(1, 0, CYX);
    }

    /**
     * Get the object [2,2] in covariance matrix (with index starting at 1).
     * @return the object [2,2] in covariance matrix (in m²)
     */
    public double getCyy() {
        return covarianceMatrix.getEntry(1, 1);
    }

    /**
     * Set the object [2,2] in covariance matrix (with index starting at 1).
     * @param CYY = object [2,2] in covariance matrix (in m²)
     */
    public void setCyy(final double CYY) {
        refuseFurtherComments();
        setCovarianceMatrixEntry(1, 1, CYY);
    }

    /**
     * Get the object [3,1] in covariance matrix (with index starting at 1).
     * @return the object [3,1] in covariance matrix (in m²)
     */
    public double getCzx() {
        return covarianceMatrix.getEntry(2, 0);
    }

    /**
     * Set the object [3,1] in covariance matrix (with index starting at 1).
     * @param CZX = object [3,1] in covariance matrix (in m²)
     */
    public void setCzx(final double CZX) {
        refuseFurtherComments();
        setCovarianceMatrixEntry(2, 0, CZX);
    }

    /**
     * Get the object [3,2] in covariance matrix (with index starting at 1).
     * @return the object [3,2] in covariance matrix (in m²)
     */
    public double getCzy() {
        return covarianceMatrix.getEntry(2, 1);
    }

    /**
     * Set the object [3,2] in covariance matrix (with index starting at 1).
     * @param CZY = object [3,2] in covariance matrix (in m²)
     */
    public void setCzy(final double CZY) {
        refuseFurtherComments();
        setCovarianceMatrixEntry(2, 1, CZY);
    }

    /**
     * Get the object [3,3] in covariance matrix (with index starting at 1).
     * @return the object [3,3] in covariance matrix (in m²)
     */
    public double getCzz() {
        return covarianceMatrix.getEntry(2, 2);
    }

    /**
     * Set the object [3,3] in covariance matrix (with index starting at 1).
     * @param CZZ = object [3,3] in covariance matrix (in m²)
     */
    public void setCzz(final double CZZ) {
        refuseFurtherComments();
        setCovarianceMatrixEntry(2, 2, CZZ);
    }

    /**
     * Get the object [4,1] in covariance matrix (with index starting at 1).
     * @return the object [4,1] in covariance matrix (in m²/s)
     */
    public double getCxdotx() {
        return covarianceMatrix.getEntry(3, 0);
    }

    /**
     * Set the object [4,1] in covariance matrix (with index starting at 1).
     * @param CXdotX = object [4,1] in covariance matrix (in m²/s)
     */
    public void setCxdotx(final double CXdotX) {
        refuseFurtherComments();
        setCovarianceMatrixEntry(3, 0, CXdotX);
    }

    /**
     * Get the object [4,2] in covariance matrix (with index starting at 1).
     * @return the object [4,2] in covariance matrix (in m²/s)
     */
    public double getCxdoty() {
        return covarianceMatrix.getEntry(3, 1);
    }

    /**
     * Set the object [4, 2] in covariance matrix (with index starting at 1).
     * @param CXdotY = object [4, 2] in covariance matrix (in m²/s)
     */
    public void setCxdoty(final double CXdotY) {
        refuseFurtherComments();
        setCovarianceMatrixEntry(3, 1, CXdotY);
    }

    /**
     * Get the object [4, 3] in covariance matrix (with index starting at 1) .
     * @return the object [4, 3] in covariance matrix (in m²/s)
     */
    public double getCxdotz() {
        return covarianceMatrix.getEntry(3, 2);
    }

    /**
     * Set the object [4, 3] in covariance matrix (with index starting at 1).
     * @param CXdotZ = object [4,3] in covariance matrix (in m²/s)
     */
    public void setCxdotz(final double CXdotZ) {
        refuseFurtherComments();
        setCovarianceMatrixEntry(3, 2, CXdotZ);
    }

    /**
     * Get the object [4, 4] in covariance matrix (with index starting at 1).
     * @return the object [4, 4] in covariance matrix (in m²/s²)
     */
    public double getCxdotxdot() {
        return covarianceMatrix.getEntry(3, 3);
    }

    /**
     * Set the object [4, 4] in covariance matrix (with index starting at 1).
     * @param CXdotXdot = object [4, 4] in covariance matrix (in m²/s²)
     */
    public void setCxdotxdot(final double CXdotXdot) {
        refuseFurtherComments();
        setCovarianceMatrixEntry(3, 3, CXdotXdot);
    }

    /**
     * Get the object [5, 1] in covariance matrix (with index starting at 1).
     * @return the object [5, 1] in covariance matrix (in m²/s)
     */
    public double getCydotx() {
        return covarianceMatrix.getEntry(4, 0);
    }

    /**
     * Set the object [5,1] in covariance matrix (with index starting at 1).
     * @param CYdotX = object [5,1] in covariance matrix (in m²/s)
     */
    public void setCydotx(final double CYdotX) {
        refuseFurtherComments();
        setCovarianceMatrixEntry(4, 0, CYdotX);
    }

    /**
     * Get the object [5,2] in covariance matrix (with index starting at 1).
     * @return the object [5,2] in covariance matrix (in m²/s)
     */
    public double getCydoty() {
        return covarianceMatrix.getEntry(4, 1);
    }

    /**
     * Set the object [5,2] in covariance matrix (with index starting at 1).
     * @param CYdotY = object [5,2] in covariance matrix (in m²/s)
     */
    public void setCydoty(final double CYdotY) {
        refuseFurtherComments();
        setCovarianceMatrixEntry(4, 1, CYdotY);
    }

    /**
     * Get the object [5,3] in covariance matrix (with index starting at 1).
     * @return the object [5,3] in covariance matrix (in m²/s)
     */
    public double getCydotz() {
        return covarianceMatrix.getEntry(4, 2);
    }

    /**
     * Set the object [5,3] in covariance matrix (with index starting at 1).
     * @param CYdotZ = object [5,3] in covariance matrix (in m²/s)
     */
    public void setCydotz(final double CYdotZ) {
        refuseFurtherComments();
        setCovarianceMatrixEntry(4, 2, CYdotZ);
    }

    /**
     * Get the object [5,4] in covariance matrix (with index starting at 1).
     * @return the object [5,4] in covariance matrix (in m²/s²)
     */
    public double getCydotxdot() {
        return covarianceMatrix.getEntry(4, 3);
    }

    /**
     * Set the object [5,4] in covariance matrix (with index starting at 1).
     * @param CYdotXdot = object [5,4] in covariance matrix (in m²/s²)
     */
    public void setCydotxdot(final double CYdotXdot) {
        refuseFurtherComments();
        setCovarianceMatrixEntry(4, 3, CYdotXdot);
    }

    /**
     * Get the object [5,5] in covariance matrix (with index starting at 1).
     * @return the object [5,5] in covariance matrix (in m²/s²)
     */
    public double getCydotydot() {
        return covarianceMatrix.getEntry(4, 4);
    }

    /**
     * Set the object [5,5] in covariance matrix (with index starting at 1).
     * @param CYdotYdot = object [5,5] in covariance matrix (in m²/s²)
     */
    public void setCydotydot(final double CYdotYdot) {
        refuseFurtherComments();
        setCovarianceMatrixEntry(4, 4, CYdotYdot);
    }

    /**
     * Get the object [6,1] in covariance matrix (with index starting at 1).
     * @return the object [6,1] in covariance matrix (in m²/s)
     */
    public double getCzdotx() {
        return covarianceMatrix.getEntry(5, 0);
    }

    /**
     * Set the object [6,1] in covariance matrix (with index starting at 1).
     * @param CZdotX = object [6,1] in covariance matrix (in m²/s)
     */
    public void setCzdotx(final double CZdotX) {
        refuseFurtherComments();
        setCovarianceMatrixEntry(5, 0, CZdotX);
    }

    /**
     * Get the object [6,2] in covariance matrix (with index starting at 1).
     * @return the object [6,2] in covariance matrix (in m²/s)
     */
    public double getCzdoty() {
        return covarianceMatrix.getEntry(5, 1);
    }

    /**
     * Set the object [6,2] in covariance matrix (with index starting at 1).
     * @param CZdotY = object [6,2] in covariance matrix (in m²/s)
     */
    public void setCzdoty(final double CZdotY) {
        refuseFurtherComments();
        setCovarianceMatrixEntry(5, 1, CZdotY);
    }

    /**
     * Get the object [6,3] in covariance matrix (with index starting at 1).
     * @return the object [6,3] in covariance matrix (in m²/s)
     */
    public double getCzdotz() {
        return covarianceMatrix.getEntry(5, 2);
    }

    /**
     * Set the object [6,3] in covariance matrix (with index starting at 1).
     * @param CZdotZ = object [6,3] in covariance matrix (in m²/s)
     */
    public void setCzdotz(final double CZdotZ) {
        refuseFurtherComments();
        setCovarianceMatrixEntry(5, 2, CZdotZ);
    }

    /**
     * Get the object [6,4] in covariance matrix (with index starting at 1).
     * @return the object [6,4] in covariance matrix (in m²/s²)
     */
    public double getCzdotxdot() {
        return covarianceMatrix.getEntry(5, 3);
    }

    /**
     * Set the object [6,4] in covariance matrix (with index starting at 1).
     * @param CZdotXdot = object [6,4] in covariance matrix (in m²/s²)
     */
    public void setCzdotxdot(final double CZdotXdot) {
        refuseFurtherComments();
        setCovarianceMatrixEntry(5, 3, CZdotXdot);
    }

    /**
     * Get the object [6,5] in covariance matrix (with index starting at 1).
     * @return the object [6,5] in covariance matrix (in m²/s²)
     */
    public double getCzdotydot() {
        return covarianceMatrix.getEntry(5, 4);
    }

    /**
     * Set the object [6,5] in covariance matrix (with index starting at 1).
     * @param CZdotYdot = object [6,5] in covariance matrix (in m²/s²)
     */
    public void setCzdotydot(final double CZdotYdot) {
        refuseFurtherComments();
        setCovarianceMatrixEntry(5, 4, CZdotYdot);
    }

    /**
     * Get the object [6,6] in covariance matrix (with index starting at 1).
     * @return the object [6,6] in covariance matrix (in m²/s²)
     */
    public double getCzdotzdot() {
        return covarianceMatrix.getEntry(5, 5);
    }

    /**
     * Set the object [6,6] in covariance matrix (with index starting at 1).
     * @param CZdotZdot = object [6,6] in covariance matrix (in m²/s²)
     */
    public void setCzdotzdot(final double CZdotZdot) {
        refuseFurtherComments();
        setCovarianceMatrixEntry(5, 5, CZdotZdot);
    }

    /**
     * Get the object [7,1] in covariance matrix (with index starting at 1).
     * @return the object [7,1] in covariance matrix (in m³/kg)
     */
    public double getCdrgx() {
        return covarianceMatrix.getEntry(6, 0);
    }

    /**
     * Set the object [7,1] in covariance matrix (with index starting at 1).
     * @param CDRGX = object [7,1] in covariance matrix (in m³/kg)
     */
    public void setCdrgx(final double CDRGX) {
        refuseFurtherComments();
        setCovarianceMatrixEntry(6, 0, CDRGX);
    }

    /**
     * Get the object [7,2] in covariance matrix.
     * @return the object [7,2] in covariance matrix (in m³/kg)
     */
    public double getCdrgy() {
        return covarianceMatrix.getEntry(6, 1);
    }

    /**
     * Set the object [7,2] in covariance matrix (with index starting at 1).
     * @param CDRGY = object [7,2] in covariance matrix (in m³/kg)
     */
    public void setCdrgy(final double CDRGY) {
        refuseFurtherComments();
        setCovarianceMatrixEntry(6, 1, CDRGY);
    }

    /**
     * Get the object [7,3] in covariance matrix (with index starting at 1).
     * @return the object [7,3] in covariance matrix (in m³/kg)
     */
    public double getCdrgz() {
        return covarianceMatrix.getEntry(6, 2);
    }

    /**
     * Set the object [7,3] in covariance matrix (with index starting at 1).
     * @param CDRGZ = object [7,3] in covariance matrix (in m³/kg)
     */
    public void setCdrgz(final double CDRGZ) {
        refuseFurtherComments();
        setCovarianceMatrixEntry(6, 2, CDRGZ);
    }

    /**
     * Get the object [7,4] in covariance matrix (with index starting at 1).
     * @return the object [7,4] in covariance matrix (in m³/(kg.s))
     */
    public double getCdrgxdot() {
        return covarianceMatrix.getEntry(6, 3);
    }

    /**
     * Set the object [7,4] in covariance matrix (with index starting at 1).
     * @param CDRGXdot = object [7,4] in covariance matrix (in m³/(kg.s))
     */
    public void setCdrgxdot(final double CDRGXdot) {
        refuseFurtherComments();
        setCovarianceMatrixEntry(6, 3, CDRGXdot);
    }

    /**
     * Get the object [7,5] in covariance matrix (with index starting at 1).
     * @return the object [7,5] in covariance matrix (in m³/(kg.s))
     */
    public double getCdrgydot() {
        return covarianceMatrix.getEntry(6, 4);
    }

    /**
     * Set the object [7,5] in covariance matrix (with index starting at 1).
     * @param CDRGYdot = object [7,5] in covariance matrix (in m³/(kg.s))
     */
    public void setCdrgydot(final double CDRGYdot) {
        refuseFurtherComments();
        setCovarianceMatrixEntry(6, 4, CDRGYdot);
    }

    /**
     * Get the object [7,6] in covariance matrix (with index starting at 1).
     * @return the object [7,6] in covariance matrix (in m³/(kg.s))
     */
    public double getCdrgzdot() {
        return covarianceMatrix.getEntry(6, 5);
    }

    /**
     * Set the object [7,6] in covariance matrix (with index starting at 1).
     * @param CDRGZdot = object [7,6] in covariance matrix (in m³/(kg.s))
     */
    public void setCdrgzdot(final double CDRGZdot) {
        refuseFurtherComments();
        setCovarianceMatrixEntry(6, 5, CDRGZdot);
    }

    /**
     * Get the object [7,7] in covariance matrix (with index starting at 1).
     * @return the object [7,7] in covariance matrix (in m⁴/kg²)
     */
    public double getCdrgdrg() {
        return covarianceMatrix.getEntry(6, 6);
    }

    /**
     * Set the object [7,7] in covariance matrix (with index starting at 1).
     * @param CDRGDRG = object [7,7] in covariance matrix (in m⁴/kg²)
     */
    public void setCdrgdrg(final double CDRGDRG) {
        refuseFurtherComments();
        setCovarianceMatrixEntry(6, 6, CDRGDRG);
    }

    /**
     * Get the object [8,1] in covariance matrix (with index starting at 1).
     * @return the object [8,1] in covariance matrix (in m³/kg)
     */
    public double getCsrpx() {
        return covarianceMatrix.getEntry(7, 0);
    }

    /**
     * Set the object [8,1] in covariance matrix (with index starting at 1).
     * @param CSRPX = object [8,1] in covariance matrix (in m³/kg)
     */
    public void setCsrpx(final double CSRPX) {
        refuseFurtherComments();
        setCovarianceMatrixEntry(7, 0, CSRPX);
    }

    /**
     * Get the object [8,2] in covariance matrix (with index starting at 1).
     * @return the object [8,2] in covariance matrix (in m³/kg)
     */
    public double getCsrpy() {
        return covarianceMatrix.getEntry(7, 1);
    }

    /**
     * Set the object [8,2] in covariance matrix (with index starting at 1).
     * @param CSRPY = object [8,2] in covariance matrix (in m³/kg)
     */
    public void setCsrpy(final double CSRPY) {
        refuseFurtherComments();
        setCovarianceMatrixEntry(7, 1, CSRPY);
    }

    /**
     * Get the object [8,3] in covariance matrix (with index starting at 1).
     * @return the object [8,3] in covariance matrix (in m³/kg)
     */
    public double getCsrpz() {
        return covarianceMatrix.getEntry(7, 2);
    }

    /**
     * Set the object [8,3] in covariance matrix (with index starting at 1).
     * @param CSRPZ = object [8,3] in covariance matrix (in m³/kg)
     */
    public void setCsrpz(final double CSRPZ) {
        refuseFurtherComments();
        setCovarianceMatrixEntry(7, 2, CSRPZ);
    }

    /**
     * Get the object [8,4] in covariance matrix (with index starting at 1).
     * @return the object [8,4] in covariance matrix (in m³/(kg.s))
     */
    public double getCsrpxdot() {
        return covarianceMatrix.getEntry(7, 3);
    }

    /**
     * Set the object [8,4] in covariance matrix (with index starting at 1).
     * @param CSRPXdot = object [8,4] in covariance matrix (in m³/(kg.s))
     */
    public void setCsrpxdot(final double CSRPXdot) {
        refuseFurtherComments();
        setCovarianceMatrixEntry(7, 3, CSRPXdot);
    }

    /**
     * Get the object [8,5] in covariance matrix (with index starting at 1).
     * @return the object [8,5] in covariance matrix (in m³/(kg.s))
     */
    public double getCsrpydot() {
        return covarianceMatrix.getEntry(7, 4);
    }

    /**
     * Set the object [8,5] in covariance matrix (with index starting at 1).
     * @param CSRPYdot = object [8,5] in covariance matrix (in m³/(kg.s))
     */
    public void setCsrpydot(final double CSRPYdot) {
        refuseFurtherComments();
        setCovarianceMatrixEntry(7, 4, CSRPYdot);
    }

    /**
     * Get the object [8,6] in covariance matrix (with index starting at 1).
     * @return the object [8,6] in covariance matrix (in m³/(kg.s))
     */
    public double getCsrpzdot() {
        return covarianceMatrix.getEntry(7, 5);
    }

    /**
     * Set the object [8,6] in covariance matrix (with index starting at 1).
     * @param CSRPZdot = object [8,6] in covariance matrix (in m³/(kg.s))
     */
    public void setCsrpzdot(final double CSRPZdot) {
        refuseFurtherComments();
        setCovarianceMatrixEntry(7, 5, CSRPZdot);
    }

    /**
     * Get the object [8,7] in covariance matrix (with index starting at 1).
     * @return the object [8,7] in covariance matrix (in m⁴/kg²)
     */
    public double getCsrpdrg() {
        return covarianceMatrix.getEntry(7, 6);
    }

    /**
     * Set the object [8,7] in covariance matrix (with index starting at 1).
     * @param CSRPDRG = object [8,7] in covariance matrix (in m⁴/kg²)
     */
    public void setCsrpdrg(final double CSRPDRG) {
        refuseFurtherComments();
        setCovarianceMatrixEntry(7, 6, CSRPDRG);
    }

    /**
     * Get the object [8,8] in covariance matrix (with index starting at 1).
     * @return the object [8,8] in covariance matrix (in m⁴/kg²)
     */
    public double getCsrpsrp() {
        return covarianceMatrix.getEntry(7, 7);
    }

    /**
     * Set the object [8,8] in covariance matrix (with index starting at 1).
     * @param CSRPSRP = object [8,8] in covariance matrix (in m⁴/kg²)
     */
    public void setCsrpsrp(final double CSRPSRP) {
        refuseFurtherComments();
        setCovarianceMatrixEntry(7, 7, CSRPSRP);
    }

    /**
     * Get the object [9,1] in covariance matrix (with index starting at 1).
     * @return the object [9,1] in covariance matrix (in m²/s²)
     */
    public double getCthrx() {
        return covarianceMatrix.getEntry(8, 0);
    }

    /**
     * Set the object [9,1] in covariance matrix (with index starting at 1).
     * @param CTHRX = object [9,1] in covariance matrix (in m²/s²)
     */
    public void setCthrx(final double CTHRX) {
        refuseFurtherComments();
        setCovarianceMatrixEntry(8, 0, CTHRX);
    }

    /**
     * Get the object [9,2] in covariance matrix (with index starting at 1).
     * @return the object [9,2] in covariance matrix (in m²/s²)
     */
    public double getCthry() {
        return covarianceMatrix.getEntry(8, 1);
    }

    /**
     * Set the object [9,2] in covariance matrix (with index starting at 1).
     * @param CTHRY = object [9,2] in covariance matrix (in m²/s²)
     */
    public void setCthry(final double CTHRY) {
        refuseFurtherComments();
        setCovarianceMatrixEntry(8, 1, CTHRY);
    }

    /**
     * Get the object [9,3] in covariance matrix (with index starting at 1).
     * @return the object [9,3] in covariance matrix (in m²/s²)
     */
    public double getCthrz() {
        return covarianceMatrix.getEntry(8, 2);
    }

    /**
     * Set the object [9,3] in covariance matrix (with index starting at 1).
     * @param CTHRZ = object [9,3] in covariance matrix (in m²/s²)
     */
    public void setCthrz(final double CTHRZ) {
        refuseFurtherComments();
        setCovarianceMatrixEntry(8, 2, CTHRZ);
    }

    /**
     * Get the object [9,4] in covariance matrix (with index starting at 1).
     * @return the object [9,4] in covariance matrix (in m²/s³)
     */
    public double getCthrxdot() {
        return covarianceMatrix.getEntry(8, 3);
    }

    /**
     * Set the object [9,4] in covariance matrix (with index starting at 1).
     * @param CTHRXdot = object [9,4] in covariance matrix (in m²/s³)
     */
    public void setCthrxdot(final double CTHRXdot) {
        refuseFurtherComments();
        setCovarianceMatrixEntry(8, 3, CTHRXdot);
    }

    /**
     * Get the object [9,5] in covariance matrix (with index starting at 1).
     * @return the object [9,5] in covariance matrix (in m²/s³)
     */
    public double getCthrydot() {
        return covarianceMatrix.getEntry(8, 4);
    }

    /**
     * Set the object [9,5] in covariance matrix (with index starting at 1).
     * @param CTHRYdot = object [9,5] in covariance matrix (in m²/s³)
     */
    public void setCthrydot(final double CTHRYdot) {
        refuseFurtherComments();
        setCovarianceMatrixEntry(8, 4, CTHRYdot);
    }

    /**
     * Get the object [9,6] in covariance matrix (with index starting at 1).
     * @return the object [9,6] in covariance matrix (in m²/s³)
     */
    public double getCthrzdot() {
        return covarianceMatrix.getEntry(8, 5);
    }

    /**
     * Set the object [9,6] in covariance matrix (with index starting at 1).
     * @param CTHRZdot = object [9,6] in covariance matrix (in m²/s³)
     */
    public void setCthrzdot(final double CTHRZdot) {
        refuseFurtherComments();
        setCovarianceMatrixEntry(8, 5, CTHRZdot);
    }

    /**
     * Get the object [9,7] in covariance matrix (with index starting at 1).
     * @return the object [9,7] in covariance matrix (in m³/(kg.s²))
     */
    public double getCthrdrg() {
        return covarianceMatrix.getEntry(8, 6);
    }

    /**
     * Set the object [9,7] in covariance matrix (with index starting at 1).
     * @param CTHRDRG = object [9,7] in covariance matrix (in m³/(kg.s²))
     */
    public void setCthrdrg(final double CTHRDRG) {
        refuseFurtherComments();
        setCovarianceMatrixEntry(8, 6, CTHRDRG);
    }

    /**
     * Get the object [9,8] in covariance matrix (with index starting at 1).
     * @return the object [9,8] in covariance matrix (in m³/(kg.s²))
     */
    public double getCthrsrp() {
        return covarianceMatrix.getEntry(8, 7);
    }

    /**
     * Set the object [9,8] in covariance matrix (with index starting at 1).
     * @param CTHRSRP = object [9,8] in covariance matrix (in m³/(kg.s²))
     */
    public void setCthrsrp(final double CTHRSRP) {
        refuseFurtherComments();
        setCovarianceMatrixEntry(8, 7, CTHRSRP);
    }

    /**
     * Get the object [9,9] in covariance matrix (with index starting at 1).
     * @return the object [9,9] in covariance matrix (in m²/s⁴)
     */
    public double getCthrthr() {
        return covarianceMatrix.getEntry(8, 8);
    }

    /**
     * Set the object [9,9] in covariance matrix (with index starting at 1).
     * @param CTHRTHR = object [9,9] in covariance matrix (in m²/s⁴)
     */
    public void setCthrthr(final double CTHRTHR) {
        refuseFurtherComments();
        setCovarianceMatrixEntry(8, 8, CTHRTHR);
    }

    /** Get the flag indicating whether the alternate covariance type set in the CDM Object metadata section is XYZ.
     * @return the covXYZset
     */
    public boolean isCovXYZset() {
        return covXYZset;
    }
}


text:
package org.openksavi.sponge.jython;

import org.openksavi.sponge.type.value.OutputStreamProducer;
import org.openksavi.sponge.type.value.OutputStreamValue;

public class JythonOutputStreamValue extends OutputStreamValue {

    protected JythonOutputStreamValue() {
    }

    public JythonOutputStreamValue(OutputStreamProducer outputProducer) {
        super(new JythonOutputStreamProducerDecorator(outputProducer));
    }

    @Override
    public void setOutputProducer(OutputStreamProducer outputProducer) {
        super.setOutputProducer(outputProducer instanceof JythonOutputStreamProducerDecorator ? outputProducer
                : new JythonOutputStreamProducerDecorator(outputProducer));
    }
}

redpajama_set_name: RedPajamaGithub


text:
### Working with Paths

Programs should not depend on quirks of your operating system. They will be harder to read, and need to be ported for other systems.  The worst of course is hardcoding paths like 'c:\\' in programs, and wondering why Vista complains so much. But even something like `dir..'\\'..file` is a problem, since Unix can't understand backslashes in this way. `dir..'/'..file` is _usually_ portable, but it's best to put this all into a simple function, `path.join`. If you consistently use `path.join`, then it's much easier to write cross-platform code, since it handles the directory separator for you.

`pl.path` provides the same functionality as Python's `os.path` module (11.1).

    > p = 'c:\\bonzo\\DOG.txt'
    > = path.normcase (p)  ---> only makes sense on Windows
    c:\bonzo\dog.txt
    > = path.splitext (p)
    c:\bonzo\DOG    .txt
    > = path.extension (p)
    .txt
    > = path.basename (p)
    DOG.txt
    > = path.exists(p)
    false
    > = path.join ('fred','alice.txt')
    fred\alice.txt
    > = path.exists 'pretty.lua'
    true
    > = path.getsize 'pretty.lua'
    2125
    > = path.isfile 'pretty.lua'
    true
    > = path.isdir 'pretty.lua'
    false

It is very important for all programmers, not just on Unix, to only write to where they are allowed to write. `path.expanduser` will expand '~' (tilde) into the home directory. Depending on your OS, this will be a guaranteed place where you can create files:

    > = path.expanduser '~/mydata.txt'
    'C:\Documents and Settings\SJDonova/mydata.txt'

    > = path.expanduser '~/mydata.txt'
    /home/sdonovan/mydata.txt

Under Windows, `os.tmpname` returns a path which leads to your drive root full of temporary files. (And increasingly, you do not have access to this root folder.) This is corrected by `path.tmpname`, which uses the environment variable TMP:

    > os.tmpname()  -- not a good place to put temporary files!
    '\s25g.'
    > path.tmpname()
    'C:\DOCUME~1\SJDonova\LOCALS~1\Temp\s25g.1'

A useful extra function is `pl.path.package_path`, which will tell you the path of a particular Lua module.  So on my system, `package_path('pl.path')` returns 'C:\Program Files\Lua\5.1\lualibs\pl\path.lua', and `package_path('ifs')` returns 'C:\Program Files\Lua\5.1\clibs\lfs.dll'. It is implemented in terms of `package.searchpath`, which is a new function in Lua 5.2 which has been implemented for Lua 5.1 in Penlight.

### File Operations

`pl.file` is a new module that provides more sensible names for common file operations. For instance, `file.read` and `file.write` are aliases for `utils.readfile` and `utils.writefile`.

Smaller files can be efficiently read and written in one operation. `file.read` is passed a filename and returns the contents as a string, if successful; if not, then it returns `nil` and the actual error message. There is an optional boolean parameter if you want the file to be read in binary mode (this makes no difference on Unix but remains important with Windows.)

In previous versions of Penlight, `utils.readfile` would read standard input if the file was not specified, but this can lead to nasty bugs; use `io.read '*a'` to grab all of standard input.

Similarly, `file.write` takes a filename and a string which will be written to that file.

For example, this little script converts a file into upper case:

    require 'pl'
	assert(#arg == 2, 'supply two filenames')
	text = assert(file.read(arg[1]))
    assert(file.write(arg[2],text:upper()))

Copying files is suprisingly tricky. `file.copy` and `file.move` attempt to use the best implementation possible. On Windows, they link to the API functions `CopyFile` and `MoveFile`, but only if the `alien` package is installed (this is true for Lua for Windows.) Otherwise, the system copy command is used. This can be ugly when writing Windows GUI applications, because of the dreaded flashing black-box problem with launching processes.

### Directory Operations

`pl.dir` provides some useful functions for working with directories. `fnmatch` will match a filename against a shell pattern, and `filter` will return any files in the supplied list which match the given pattern, which correspond to the functions in the Python `fnmatch` module. `getdirectories` will return all directories contained in a directory, and `getfiles` will return all files in a directory which match a shell pattern. These functions return the files as a table, unlike `lfs.dir` which returns an iterator.)

`dir.makepath` can create a full path, creating subdirectories as necessary; `rmtree` is the Nuclear Option of file deleting functions, since it will recursively clear out and delete all directories found begining at a path (there is a similar function with this name in the Python `shutils` module.)

    > = dir.makepath 't\\temp\\bonzo'
    > = path.isdir 't\\temp\\bonzo'
    true
    > = dir.rmtree 't'

`dir.rmtree` depends on `dir.walk`, which is a powerful tool for scanning a whole directory tree. Here is the implementation of `dir.rmtree`:

    --- remove a whole directory tree.
    -- @param path A directory path
    function dir.rmtree(fullpath)
        for root,dirs,files in dir.walk(fullpath) do
            for i,f in ipairs(files) do
                os.remove(path.join(root,f))
            end
            lfs.rmdir(root)
        end
    end

`dir.clonetree` clones directory trees. The first argument is a path that must exist, and the second path is the path to be cloned. (Note that this path cannot be _inside_ the first path, since this leads to madness.)  By default, it will then just recreate the directory structure. You can in addition provide a function, which will be applied for all files found.

    -- make a copy of my libs folder
    require 'pl'
    p1 = [[d:\dev\lua\libs]]
    p2 = [[D:\dev\lua\libs\..\tests]]
    dir.clonetree(p1,p2,dir.copyfile)

A more sophisticated version, which only copies files which have been modified:

    -- p1 and p2 as before, or from arg[1] and arg[2]
    dir.clonetree(p1,p2,function(f1,f2)
      local res
      local t1,t2 = path.getmtime(f1),path.getmtime(f2)
	  -- f2 might not exist, so be careful about t2
      if not t2 or t1 > t2 then
        res = dir.copyfile(f1,f2)
      end
      return res -- indicates successful operation
    end)

`dir.clonetree` uses `path.common_prefix`. With `p1` and `p2` defined above, the common path is 'd:\dev\lua'. So 'd:\dev\lua\libs\testfunc.lua' is copied to 'd:\dev\lua\test\testfunc.lua', etc.

If you need to find the common path of list of files, then `tablex.reduce` will do the job:

    > p3 = [[d:\dev]]
    > = tablex.reduce(path.common_prefix,{p1,p2,p3})
    'd:\dev'


text:
package nz.co.doltech.gwtls.client.debug;

public class SliderEntryPoint extends nz.co.doltech.gwtls.client.SliderEntryPoint {

    @Override
    public void onModuleLoad() {
        inject(SliderClientBundle.INSTANCE.lightSliderDebug(), false, true);
    }
}


text:
<?php
namespace Elastica\Aggregation;

/**
 * Class AbstractTermsAggergation.
 */
abstract class AbstractTermsAggregation extends AbstractSimpleAggregation
{
    /**
     * Set the minimum number of documents in which a term must appear in order to be returned in a bucket.
     *
     * @param int $count
     *
     * @return $this
     */
    public function setMinimumDocumentCount($count)
    {
        return $this->setParam('min_doc_count', $count);
    }

    /**
     * Filter documents to include based on a regular expression.
     *
     * @param string $pattern a regular expression
     * @param string $flags   Java Pattern flags
     *
     * @return $this
     */
    public function setInclude($pattern, $flags = null)
    {
        if (is_null($flags)) {
            return $this->setParam('include', $pattern);
        }

        return $this->setParam('include', array(
            'pattern' => $pattern,
            'flags' => $flags,
        ));
    }

    /**
     * Filter documents to exclude based on a regular expression.
     *
     * @param string $pattern a regular expression
     * @param string $flags   Java Pattern flags
     *
     * @return $this
     */
    public function setExclude($pattern, $flags = null)
    {
        if (is_null($flags)) {
            return $this->setParam('exclude', $pattern);
        }

        return $this->setParam('exclude', array(
            'pattern' => $pattern,
            'flags' => $flags,
        ));
    }

    /**
     * Sets the amount of terms to be returned.
     *
     * @param int $size The amount of terms to be returned.
     *
     * @return $this
     */
    public function setSize($size)
    {
        return $this->setParam('size', $size);
    }

    /**
     * Sets how many terms the coordinating node will request from each shard.
     *
     * @param int $shard_size The amount of terms to be returned.
     *
     * @return $this
     */
    public function setShardSize($shard_size)
    {
        return $this->setParam('shard_size', $shard_size);
    }

    /**
     * Instruct Elasticsearch to use direct field data or ordinals of the field values to execute this aggregation.
     * The execution hint will be ignored if it is not applicable.
     *
     * @param string $hint map or ordinals
     *
     * @return $this
     */
    public function setExecutionHint($hint)
    {
        return $this->setParam('execution_hint', $hint);
    }
}


text:
using System;
using System.IO;

namespace TriggerSol.JStore
{
    public class DataStoreConfiguration : IDataStoreConfiguration
    {
        public DataStoreConfiguration(string dataStorePath)
        {
            InitStore(dataStorePath);
        }
        public string DataStoreLocation { get; private set; }
        public string DocumentStoreLocation { get; private set; }

        void InitStore(string dataStorePath)
        {
            DataStoreLocation = Path.Combine(dataStorePath, "DATA");
            DocumentStoreLocation = Path.Combine(dataStorePath, "DOC");

            if (!Directory.Exists(DataStoreLocation))
                Directory.CreateDirectory(DataStoreLocation);

            if (!Directory.Exists(DocumentStoreLocation))
                Directory.CreateDirectory(DocumentStoreLocation);
        }
    }
}


text:
package org.ggp.base.apps.kiosk.games;

import java.awt.Color;
import java.awt.Graphics;
import java.util.Set;

import org.ggp.base.apps.kiosk.templates.CommonGraphics;
import org.ggp.base.apps.kiosk.templates.GameCanvas_FancyGrid;

public class CephalopodCanvas extends GameCanvas_FancyGrid {
    private static final long serialVersionUID = 1L;

    @Override
	public String getGameName() { return "Cephalopod"; }
    @Override
	protected String getGameKey() { return "cephalopodMicro"; }
    @Override
	protected int getGridHeight() { return 3; }
    @Override
	protected int getGridWidth() { return 3; }

    @Override
    protected Set<String> getFactsAboutCell(int xCell, int yCell) {
        return gameStateHasFactsMatching("\\( cell " + xCell + " " + yCell + " (.*) \\)");
    }

    @Override
    protected Set<String> getLegalMovesForCell(int xCell, int yCell) {
        return gameStateHasLegalMovesMatching("\\( play " + xCell + " " + yCell + " (.*) \\)");
    }

    @Override
    protected void renderCellContent(Graphics g, String theFact) {
        String[] cellFacts = theFact.split(" ");

        int cellValue = Integer.parseInt(cellFacts[4]);
        String cellPlayer = cellFacts[5];

        if (cellPlayer.equals("red")) {
            g.setColor(Color.RED);
        } else if (cellPlayer.equals("black")) {
            g.setColor(Color.BLACK);
        }

        CommonGraphics.fillWithString(g, "" + cellValue, 1.2);
    }

    @Override
    protected void renderMoveSelectionForCell(Graphics g, int xCell, int yCell, String theMove) {
        if(isSelectedCell(xCell, yCell)) {
            String[] moveParts = theMove.split(" ");
            int captureMask = Integer.parseInt(moveParts[5]);
            renderCaptureMask(g, captureMask);
        }
    }

    private void renderCaptureMask(Graphics g, int c) {
        boolean leftBit = (c == 3 || c == 5 || c == 7 || c == 9 || c == 11 || c == 13 || c == 15);
        boolean rightBit = (c >= 9);
        boolean topBit = (c == 3 || c == 6 || c == 7 || c == 10 || c == 11 || c == 14 || c == 15);
        boolean bottomBit = (c == 5 || c == 6 || c == 7 || c >= 12);

        int width = g.getClipBounds().width;
        int height = g.getClipBounds().height;

        g.setColor(Color.GREEN);
        if(leftBit) g.drawRect(width/10, 3*height/10, width/20, 4*height/10);
        if(rightBit) g.drawRect(17*width/20, 3*height/10, width/20, 4*height/10);
        if(topBit) g.drawRect(3*width/10, height/10, 4*width/10, height/20);
        if(bottomBit) g.drawRect(3*width/10, 17*height/20, 4*width/10, height/20);
    }
}


text:
;(function(){

	module("Event Handlers");

	// a simple re-usable test harness object
	var obj = {
		init: function( opts ){
			obj.$div = 	$('<div />')
				.css({
					position: 'absolute',
					top: 0,
					left: 0,
					height: 100,
					width: 100
				})
				.append('<div class="child" />')
				.appendTo( document.body )
				.bind("lingerstart linger lingerend", opts || {}, function( event ){
					obj[ event.type ] += 1;
					return obj.returned[ event.type ];
				});
			$.extend( obj, { lingerstart:0, linger:0, lingerend:0 });
			obj.returned = {};
		},
		done: function(){
			obj.$div.remove();
			start();
		}
	};

	asyncTest('"lingerstart" return false',function(){

		expect( 3 );

		// prep interaction
		obj.init();
		// set the return value
		obj.returned['lingerstart'] = false;
		// simulate interaction
		obj.$div
			.fire("mouseover",{ pageX:50, pageY:50 })
			.fire("mousemove",{ pageX:56, pageY:58 }); // move <= 10 pixels (default speed)
		// wait 100 ms (default delay)
		setTimeout(function(){
			obj.$div.fire("mouseout",{ pageX:51, pageY:51 });
			// wait 100 ms (persist)
			setTimeout(function(){
				// inspect results
				equals( obj.lingerstart, 1, "lingerstart");
				equals( obj.linger, 0, "linger");
				equals( obj.lingerend, 0, "lingerend");
				obj.done();
			}, 100 );
		}, 100 );

	});

	asyncTest('"linger" return false',function(){

		expect( 3 );

		// prep interaction
		obj.init({ persist:100 });
		// set the return value
		obj.returned['linger'] = false;
		// simulate interaction
		obj.$div
			.fire("mouseover",{ pageX:50, pageY:50 })
			.fire("mousemove",{ pageX:56, pageY:58 }); // move <= 10 pixels (default speed)
		// wait 300 ms (3x default delay)
		setTimeout(function(){
			obj.$div.fire("mouseout",{ pageX:51, pageY:51 });
			// wait 100 ms (persist)
			setTimeout(function(){
				// inspect results
				equals( obj.lingerstart, 1, "lingerstart");
				equals( obj.linger, 3, "linger");
				equals( obj.lingerend, 0, "lingerend");
				obj.done();
			}, 100 );
		}, 350 );

	});

	asyncTest('"lingerend" return false',function(){

		expect( 3 );

		// prep interaction
		obj.init({ persist:100 });
		// set the return value
		obj.returned['lingerend'] = false;
		// simulate interaction
		obj.$div
			.fire("mouseover",{ pageX:50, pageY:50 })
			.fire("mousemove",{ pageX:56, pageY:58 }); // move <= 10 pixels (default speed)
		// wait 100 ms (default delay)
		setTimeout(function(){
			obj.$div.fire("mouseout",{ pageX:51, pageY:51 });
			// wait 300 ms (3x persist)
			setTimeout(function(){
				// inspect results
				equals( obj.lingerstart, 1, "lingerstart");
				equals( obj.linger, 1, "linger");
				equals( obj.lingerend, 3, "lingerend");
				obj.done();
			}, 350 );
		}, 300 );
	});

})();


text:
using System;
using System.Text.Json;
using Azure.Core;

namespace Azure.ResourceManager.DataProtectionBackup.Models
{
    public partial class RestoreJobRecoveryPointDetails
    {
        internal static RestoreJobRecoveryPointDetails DeserializeRestoreJobRecoveryPointDetails(JsonElement element)
        {
            Optional<string> recoveryPointId = default;
            Optional<DateTimeOffset> recoveryPointTime = default;
            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("recoveryPointID"))
                {
                    recoveryPointId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("recoveryPointTime"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    recoveryPointTime = property.Value.GetDateTimeOffset("O");
                    continue;
                }
            }
            return new RestoreJobRecoveryPointDetails(recoveryPointId.Value, Optional.ToNullable(recoveryPointTime));
        }
    }
}


text:
using System;
using System.Collections.Generic;
using System.Linq;
using Elasticsearch.Net;
using FluentAssertions;
using Nest;
using Tests.Framework;
using Tests.Framework.Integration;
using Tests.Framework.ManagedElasticsearch.Clusters;
using Tests.Framework.MockData;
using Xunit;
using static Nest.Infer;

namespace Tests.Document.Multiple.UpdateByQuery
{
	[SkipVersion("<2.3.0", "")]
	public class UpdateByQueryApiTests : ApiIntegrationTestBase<IntrusiveOperationCluster, IUpdateByQueryResponse, IUpdateByQueryRequest, UpdateByQueryDescriptor<UpdateByQueryApiTests.Test>, UpdateByQueryRequest>
	{
		public class Test
		{
			public string Text { get; set; }
			public string Flag { get; set; }
		}

		public UpdateByQueryApiTests(IntrusiveOperationCluster cluster, EndpointUsage usage) : base(cluster, usage) { }

		protected override void IntegrationSetup(IElasticClient client, CallUniqueValues values)
		{
			foreach (var index in values.Values)
			{
				this.Client.CreateIndex(index, c => c
					.Mappings(m => m
						.Map<Test>(map => map
							.Dynamic(false)
							.Properties(props => props
								.Text(s => s.Name(p => p.Text))
							)
						)
					)
				);
				this.Client.Index(new Test { Text = "words words", Flag = "bar" }, i => i.Index(index).Refresh(Refresh.True));
				this.Client.Index(new Test { Text = "words words", Flag = "foo" }, i => i.Index(index).Refresh(Refresh.True));
				this.Client.Map<Test>(m => m
					.Index(index)
					.Properties(props => props
						.Text(s => s.Name(p => p.Text))
						.Keyword(s => s.Name(p => p.Flag))
					)
				);

				var searchResults = this.SearchFlags(index);
				searchResults.Total.Should().Be(0);
			}
		}
		protected override LazyResponses ClientUsage() => Calls(
			fluent: (client, f) => client.UpdateByQuery(f),
			fluentAsync: (client, f) => client.UpdateByQueryAsync(f),
			request: (client, r) => client.UpdateByQuery(r),
			requestAsync: (client, r) => client.UpdateByQueryAsync(r)
		);
		protected override void OnAfterCall(IElasticClient client) => client.Refresh(CallIsolatedValue);

		protected override bool ExpectIsValid => true;
		protected override int ExpectStatusCode => 200;
		protected override HttpMethod HttpMethod => HttpMethod.POST;

		protected override string UrlPath => $"/{CallIsolatedValue}/test/_update_by_query?refresh=true&conflicts=proceed";

		protected override bool SupportsDeserialization => false;

		protected override object ExpectJson { get; } = new { query = new { match_all = new { } } };

		protected override UpdateByQueryDescriptor<Test> NewDescriptor() => new UpdateByQueryDescriptor<Test>(CallIsolatedValue).Type<Test>();

		protected override Func<UpdateByQueryDescriptor<Test>, IUpdateByQueryRequest> Fluent => d => d
			.Index(CallIsolatedValue)
			.Query(q=>q.MatchAll())
			.Refresh()
			.Conflicts(Conflicts.Proceed);

		protected override UpdateByQueryRequest Initializer => new UpdateByQueryRequest(CallIsolatedValue, Type<Test>())
		{
			Query = new MatchAllQuery(),
			Refresh = true,
			Conflicts = Conflicts.Proceed
		};

		private ISearchResponse<Test> SearchFlags(string index) =>
			this.Client.Search<Test>(s => s
				.Index(index)
				.Query(q => q.Match(m => m.Field(p => p.Flag).Query("foo")))
			);

		protected override void ExpectResponse(IUpdateByQueryResponse response)
		{
			response.Task.Should().BeNull();
			response.Took.Should().BeGreaterThan(0);
			response.Total.Should().Be(2);
			response.Updated.Should().Be(2);
			response.Batches.Should().Be(1);

			var searchResponse = this.SearchFlags(CallIsolatedValue);
			searchResponse.Total.Should().Be(1);
		}
	}

	[SkipVersion("<2.3.0", "")]
	public class UpdateByQueryWaitForCompletionApiTests : UpdateByQueryApiTests
	{
		public UpdateByQueryWaitForCompletionApiTests(IntrusiveOperationCluster cluster, EndpointUsage usage) : base(cluster, usage) { }

		protected override string UrlPath => $"/{CallIsolatedValue}/test/_update_by_query?wait_for_completion=false&conflicts=proceed";

		protected override Func<UpdateByQueryDescriptor<Test>, IUpdateByQueryRequest> Fluent => d => d
			.Query(q=>q.MatchAll())
			.Index(CallIsolatedValue)
			.WaitForCompletion(false)
			.Conflicts(Conflicts.Proceed);

		protected override UpdateByQueryRequest Initializer => new UpdateByQueryRequest(CallIsolatedValue, Type<Test>())
		{
			Query = new MatchAllQuery(),
			WaitForCompletion = false,
			Conflicts = Conflicts.Proceed
		};

		protected override void ExpectResponse(IUpdateByQueryResponse response)
		{
			response.Task.Should().NotBeNull();
			response.Task.TaskNumber.Should().BeGreaterThan(0);
			response.Task.NodeId.Should().NotBeNullOrWhiteSpace();
			response.Task.FullyQualifiedId.Should().NotBeNullOrWhiteSpace();
		}
	}

	[SkipVersion("<2.3.0", "")]
	public class UpdateByQueryWithFailuresApiTests : UpdateByQueryApiTests
	{
		public UpdateByQueryWithFailuresApiTests(IntrusiveOperationCluster cluster, EndpointUsage usage) : base(cluster, usage) { }

		protected override void IntegrationSetup(IElasticClient client, CallUniqueValues values)
		{
			foreach (var index in values.Values)
			{
				this.Client.CreateIndex(index, c => c
					.Settings(s => s
						.RefreshInterval(-1)
					)
				);
				this.Client.Index(new Test { Text = "test1", Flag = "bar" }, i => i.Index(index).Id(1).Refresh(Refresh.True));
				this.Client.Index(new Test { Text = "test2", Flag = "bar" }, i => i.Index(index).Id(1));
			}
		}
		private static string _script = "ctx._source.text = 'x'";

		protected override bool ExpectIsValid => false;
		protected override int ExpectStatusCode => 409;

		protected override string UrlPath => $"/{CallIsolatedValue}/test/_update_by_query";
		protected override object ExpectJson { get; } =
			new
			{
				query = new { match = new { flag = new { query = "bar" } } },
				script = new { inline = "ctx._source.text = 'x'" }
			};

		protected override Func<UpdateByQueryDescriptor<Test>, IUpdateByQueryRequest> Fluent => d => d
			.Index(CallIsolatedValue)
			.Query(q => q.Match(m => m.Field(p => p.Flag).Query("bar")))
			.Script(ss => ss.Inline(_script))
			;

		protected override UpdateByQueryRequest Initializer => new UpdateByQueryRequest(CallIsolatedValue, Type<Test>())
		{
			Query = new MatchQuery
			{
				Field = Field<Test>(p => p.Flag),
				Query = "bar"
			},
			Script = new InlineScript(_script),
		};

		protected override void ExpectResponse(IUpdateByQueryResponse response)
		{
			response.VersionConflicts.Should().Be(1);
			response.Failures.Should().NotBeEmpty();
			var failure = response.Failures.First();

			failure.Index.Should().NotBeNullOrWhiteSpace();
			failure.Type.Should().NotBeNullOrWhiteSpace();
			failure.Status.Should().Be(409);
			failure.Id.Should().NotBeNullOrWhiteSpace();

			failure.Cause.Should().NotBeNull();
			failure.Cause.IndexUniqueId.Should().NotBeNullOrWhiteSpace();
			failure.Cause.Reason.Should().NotBeNullOrWhiteSpace();
			failure.Cause.Index.Should().NotBeNullOrWhiteSpace();
			failure.Cause.Shard.Should().NotBeNullOrWhiteSpace();
			failure.Cause.Type.Should().NotBeNullOrWhiteSpace();
		}
	}
}


text:
// Singh Ravinder Pal
// Battle In Space

var game = new Phaser.Game(1200, 700, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render });

function preload() {

  game.load.image('space', 'assets/deep-space.jpg');
  game.load.image('bullet', 'assets/bullets.png');
  game.load.image('ship', 'assets/ship.png');
  game.load.image('asteroid1', 'assets/asteroid1.png');
  game.load.image('asteroid2', 'assets/asteroid2.png');
  game.load.image('asteroid3', 'assets/asteroid3.png');
  game.load.spritesheet('explosion', 'assets/explode.png', 128, 128, 10);
  game.load.image('fullscreen', 'assets/fsIcon.jpg');
  game.load.image('restart', 'assets/restart.png');

  //gamepad buttons
  game.load.spritesheet('buttonhorizontal', 'assets/buttons-big/button-horizontal.png',96,64);
  game.load.spritesheet('buttonvertical', 'assets/buttons-big/button-vertical.png',64,64)
  game.load.spritesheet('buttonfire', 'assets/buttons-big/button-round-a.png',96,96);

  // AUDIO SYSTEM
  game.load.audio('spaceMusic', 'assets/spaceMusic.mp3');
  game.load.audio('shipExplosion', 'assets/explode1.wav');
  game.load.audio('shot', 'assets/pistol.wav');

  //SCREEN SETTINGS
  game.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL;
  game.scale.pageAlignHorizontally = true;
  game.scale.pageAlignVertically = true;
  game.scale.setScreenSize(true);
  game.scale.fullScreenScaleMode = Phaser.ScaleManager.SHOW_ALL;

}

var score=0, spaceshipHealth = totHealth = 100;
var aMaxSize=1, nAsteroids=30, aSpeed=300;
var spaceHeight = 1500, spaceWidth = 1500;
var bulletTime = 0;
var left=false, right=false, up=false, fire=false;

function create() {

  background = game.add.tileSprite(0, 0, spaceHeight, spaceWidth, 'space');
  game.world.setBounds(0, 0, spaceHeight, spaceWidth);
  game.physics.startSystem(Phaser.Physics.ARCADE);
  //  This will run in Canvas mode, so let's gain a little speed and display
  game.renderer.clearBeforeRender = false;
  game.renderer.roundPixels = true;

  //  PLAYER'S SHIP
  generateSpaceship();

  //  SHIP BULLETS
  bullets = game.add.group();
  bullets.enableBody = true;
  bullets.physicsBodyType = Phaser.Physics.ARCADE;
  bullets.createMultiple(40, 'bullet');
  bullets.setAll('anchor.x', 0.5);
  bullets.setAll('anchor.y', 0.5);

  // ASTEROIDS
  generateAsteroids();

  // SCORE, HEALTH, AND ASTEROIDS-ALIVE TEXTS
  scoreText = game.add.text(100, 60, 'Score: 0', { fontSize: '32px', fill: '#d8137e' });
  scoreText.fixedToCamera = true;
  healthText = game.add.text(100, 20, 'Health: ' + spaceshipHealth, { fontSize: '32px', fill: '#d8137e'});
  healthText.fixedToCamera = true;
  aAlive = game.add.text(100, 100, 'Asteroids left: ', { fontSize: '32px', fill: '#d8137e'});
  aAlive.fixedToCamera = true;

  //  GAME INPUT
  cursors = game.input.keyboard.createCursorKeys();
  game.input.keyboard.addKeyCapture([ Phaser.Keyboard.SPACEBAR ]);

  // AUDIO SYSTEM
  shipExplosion = game.add.audio('shipExplosion', 1);
  shipShot = game.add.audio('shot', 1);
  music = game.add.audio('spaceMusic', 1, true);
  music.play('', 0, 1, true);
  music.loop = true;

  // BUTTONS
  btFullscreen = game.add.button(20, 20, 'fullscreen', actionOnClick);
  btFullscreen.fixedToCamera = true;
  btRestart = game.add.button(1100, 20, 'restart', restartGame);
  btRestart.fixedToCamera = true;
  if(!game.device.desktop){
    game.scale.scaleMode = Phaser.ScaleManager.EXACT_FIT;
  game.input.onDown.add(gofull, this);
  // create our virtual GAME CONTROL BUTTONS
  buttonleft = game.add.button(20, 472, 'buttonhorizontal', null, this, 0, 1, 0, 1);
  buttonleft.scale.setTo(2, 2);
  buttonleft.fixedToCamera = true;
  buttonleft.events.onInputOver.add(function(){left=true;});
  buttonleft.events.onInputOut.add(function(){left=false;});
  buttonleft.events.onInputDown.add(function(){left=true;});
  buttonleft.events.onInputUp.add(function(){left=false;});

  buttonright = game.add.button(360, 472, 'buttonhorizontal', null, this, 0, 1, 0, 1);
  buttonright.scale.setTo(2, 2);
  buttonright.fixedToCamera = true;
  buttonright.events.onInputOver.add(function(){right=true;});
  buttonright.events.onInputOut.add(function(){right=false;});
  buttonright.events.onInputDown.add(function(){right=true;});
  buttonright.events.onInputUp.add(function(){right=false;});

  buttonup = game.add.button(222, 400, 'buttonvertical', null, this, 0, 1, 0, 1);
  buttonup.scale.setTo(2, 2);
  buttonup.fixedToCamera = true;
  buttonup.events.onInputOver.add(function(){up=true;});
  buttonup.events.onInputOut.add(function(){up=false;});
  buttonup.events.onInputDown.add(function(){up=true;});
  buttonup.events.onInputUp.add(function(){up=false;});

  buttonfire = game.add.button(1000, 500, 'buttonfire', null, this, 0, 1, 0, 1);
  buttonfire.scale.setTo(2,2);
  buttonfire.fixedToCamera = true;
  buttonfire.events.onInputOver.add(function(){fire=true;});
  buttonfire.events.onInputOut.add(function(){fire=false;});
  buttonfire.events.onInputDown.add(function(){fire=true;});
  buttonfire.events.onInputUp.add(function(){fire=false;});
  }
}

function update() {
  aAlive.text = "Asteroids left: "+asteroids.total;
  if(spaceship.alive === true){
    if (cursors.up.isDown || up)
    {
      game.physics.arcade.accelerationFromRotation(spaceship.rotation, 200, spaceship.body.acceleration);
    }
    else
    {
      spaceship.body.acceleration.set(0);
    }

    if (cursors.left.isDown || left)
    {
      spaceship.body.angularVelocity = -200;
    }
    else if (cursors.right.isDown || right)
    {
      spaceship.body.angularVelocity = 200;
    }
    else
    {
      spaceship.body.angularVelocity = 0;
    }

    if (game.input.keyboard.isDown(Phaser.Keyboard.SPACEBAR) || fire)
    {
      fireBullet();
      if(!shipShot.isPlaying)
        shipShot.play('', 0, 0.3);
    }
    if (game.input.keyboard.justReleased(Phaser.Keyboard.SPACEBAR))
    {
      shipShot.stop();
    }
  }

  healthText.text = 'Health: ' + spaceshipHealth.toFixed(0);
  scoreText.text = 'Score: ' + score.toFixed(0);
  //overlap(object1, object2, overlapCallback, processCallback, callbackContext) → {boolean}
  game.physics.arcade.overlap(asteroids, bullets, asteroidHit, null, this);
  game.physics.arcade.collide(asteroids, spaceship, spaceshipHit, null, this);

  /*
  screenWrap(spaceship);
  bullets.forEachExists(screenWrap, this);
  asteroids.forEachExists(screenWrap, this);
  */
}

function generateSpaceship(){
  spaceship = game.add.sprite(game.world.centerX, game.world.centerY, 'ship');
  //spaceship.scale.setTo(2,2);
  spaceship.anchor.set(0.5);
  game.physics.enable(spaceship, Phaser.Physics.ARCADE);
  spaceship.body.collideWorldBounds = true;
  spaceship.body.bounce.set(0.2);
  spaceship.body.maxVelocity.set(200);
  game.camera.follow(spaceship);
}

function generateAsteroids(){
  asteroids = game.add.group();
  asteroids.enableBody = true;
  for(i=0, x=0; i<nAsteroids; i++, x++){
    x%=3;
    if(x===0)a = asteroids.create(game.world.randomX, game.world.randomY, 'asteroid1');
    if(x===1)a = asteroids.create(game.world.randomX, game.world.randomY, 'asteroid2');
    if(x===2)a = asteroids.create(game.world.randomX, game.world.randomY, 'asteroid3');
    a.body.bounce.set(0.7);
    a.body.collideWorldBounds = true;
    a.body.velocity.setTo(Math.random() * aSpeed, Math.random() * aSpeed);
    dim=(Math.random() * aMaxSize) + 0.5; //asteroid's dimension
    a.scale.setTo(dim, dim);
    a.health = dim * 2;
  }
}

function asteroidHit(asteroid, bullet){
  bullet.kill();
  asteroid.damage(1);
  if(asteroid.health <= 0){
    score += 10;
  }
}

function spaceshipHit(spaceship, asteroid){
  spaceshipHealth -= asteroid.health * 5;
  score -= asteroid.health * 2;
  asteroid.damage(1);
  if(spaceshipHealth <=0){
    spaceshipHealth=0;
    spaceship.loadTexture('explosion', 0);
    spaceship.animations.add('explode');
    //                   play(name, frameRate, loop, killOnComplete)
    spaceship.animations.play('explode', 20, false, true);
    shipShot.loop=false;
    shipExplosion.play('', 0, 1, false);
  }
}

function fireBullet () {

  if (game.time.now > bulletTime)
  {
    bullet = bullets.getFirstExists(false);

    if (bullet)
    {
      bullet.reset(spaceship.body.x + 16, spaceship.body.y + 16);
      bullet.lifespan = 2000;
      bullet.rotation = spaceship.rotation;
      game.physics.arcade.velocityFromRotation(spaceship.rotation, 400, bullet.body.velocity);
      bulletTime = game.time.now + 120;
    }
  }

}

function screenWrap (sprite) {

  if (sprite.x < 0)
  {
    sprite.x = game.width;
  }
  else if (sprite.x > game.width)
  {
    sprite.x = 0;
  }

  if (sprite.y < 0)
  {
    sprite.y = game.height;
  }
  else if (sprite.y > game.height)
  {
    sprite.y = 0;
  }

}

function actionOnClick() {
if (game.scale.isFullScreen)
  {
    game.scale.stopFullScreen();
  }
  else
  {
    game.scale.startFullScreen();
  }
}

function gofull() { game.scale.startFullScreen(false);}

function restartGame(){
  score = 0;
  spaceshipHealth = totHealth;
  asteroids.destroy();
  generateAsteroids();
  spaceship.destroy();
  generateSpaceship();
}

function render() {
  //game.debug.bodyInfo(asteroids, 32, 32);
  //game.debug.quadTree(game.physics.arcade.quadTree);
  //game.debug.cameraInfo(game.camera, 32, 500);
  //game.debug.text('Click / Tap to go fullscreen', 270, 16);
}


text:
require 'rails/generators'

module Hancock::News
  class ViewsGenerator < Rails::Generators::Base
    source_root File.expand_path('../../../../../../app/views/hancock/news', __FILE__)
    argument :views_args, type: :array, default: []

    desc 'Hancock::News Config generator'
    def views
      (views_args == ['all'] ? permitted_file_views : ((views_args & permitted_path_views).map { |v| permitted_file_views(v) }.flatten)).each do |v|
        copy_file "#{v}.html.slim", "app/views/hancock/news/#{v}.html.slim"
      end
    end

    private
    def permitted_views
      [
        'categories', 'news',
        'categories/index', 'categories/_list', 'categories/show',
        'news/index',       'news/_list',       'news/show'
      ]
    end

    def permitted_file_views(path = '')
      permitted_views.reject { |v| v.index("#{path}/").nil? }
    end

    def permitted_path_views
      permitted_views.select { |v| v.index('/').nil? }
    end

  end
end


text:
(function() {
  var ASObject, AggregatedStatsPacket, AuthPacket, ConnectPacket, Decoder, Encoder, SummonerNamesPacket, GetSummonerDataPacket, GetTeamById, GetTeamForSummoner, HeartbeatPacket, LoginPacket, LookupPacket, Packet, PlayerStatsPacket, RecentGames, GetAllLeaguesForPlayer, uuid, _ref, _ref1, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9,
    __hasProp = {}.hasOwnProperty,
    __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };

  uuid = require('node-uuid');

  Encoder = require('namf/amf0').Encoder;

  Decoder = require('namf/amf0').Decoder;

  ASObject = require('namf/messaging').ASObject;

  Packet = (function() {
    function Packet(options) {
      this.options = options;
    }

    return Packet;

  })();

  ConnectPacket = (function(_super) {
    __extends(ConnectPacket, _super);

    function ConnectPacket() {
      _ref = ConnectPacket.__super__.constructor.apply(this, arguments);
      return _ref;
    }

    ConnectPacket.prototype.appObject = function() {
      var object;
      object = {
        app: '',
        flashVer: 'WIN 10,1,85,3',
        swfUrl: 'app:/mod_ser.dat',
        tcUrl: 'rtmps://beta.lol.riotgames.com:2099',
        fpad: false,
        capabilities: 239,
        audioCodecs: 3191,
        videoCodecs: 252,
        videoFunction: 1,
        pageUrl: void 0,
        objectEncoding: 3
      };
      return object;
    };

    ConnectPacket.prototype.commandObject = function() {
      var object;
      object = new ASObject();
      object.name = 'flex.messaging.messages.CommandMessage';
      object.object = {
        operation: 5,
        correlationId: '',
        timestamp: 0,
        clientId: null,
        timeToLive: 0,
        messageId: '9DC6600E-8F54-604F-AB39-1515B4CBE8AA',
        destination: '',
        headers: {
          DSMessagingVersion: 1,
          DSId: 'my-rtmps'
        },
        body: {}
      };
      return object;
    };

    return ConnectPacket;

  })(Packet);

  LoginPacket = (function(_super) {
    __extends(LoginPacket, _super);

    function LoginPacket() {
      LoginPacket.__super__.constructor.apply(this, arguments);
      console.log(this.options);
    }

    LoginPacket.prototype.generate = function(clientVersion) {
      var object;
      object = new ASObject();
      object.name = 'flex.messaging.messages.RemotingMessage';
      object.object = {
        operation: 'login',
        source: null,
        timestamp: 0,
        clientId: null,
        timeToLive: 0,
        messageId: uuid().toUpperCase(),
        destination: 'loginService',
        headers: this.generateHeaders(),
        body: [this.generateBody(clientVersion)]
      };
      object.encoding = 0;
      return object;
    };

    LoginPacket.prototype.generateHeaders = function() {
      var headers;
      headers = new ASObject();
      headers.name = '';
      headers.object = {
        DSId: this.options.dsid,
        DSRequestTimeout: 60,
        DSEndpoint: 'my-rtmps'
      };
      headers.encoding = 2;
      return headers;
    };

    LoginPacket.prototype.generateBody = function(clientVersion) {
      var body;
      if (clientVersion === null) {
        clientVersion = '3.9.13_07_01_27';
      }
      body = new ASObject();
      body.name = 'com.riotgames.platform.login.AuthenticationCredentials';
      body.object = {
        oldPassword: null,
        password: this.options.password,
        authToken: this.options.queueToken,
        locale: 'en_GB',
        partnerCredentials: null,
        ipAddress: '203.59.95.218',
        domain: 'lolclient.lol.riotgames.com',
        username: this.options.username,
        clientVersion: clientVersion,
        securityAnswer: null
      };
      body.encoding = 0;
      return body;
    };

    return LoginPacket;

  })(Packet);

  AuthPacket = (function(_super) {
    __extends(AuthPacket, _super);

    function AuthPacket() {
      _ref1 = AuthPacket.__super__.constructor.apply(this, arguments);
      return _ref1;
    }

    AuthPacket.prototype.generate = function() {
      var object;
      object = new ASObject();
      object.name = 'flex.messaging.messages.CommandMessage';
      object.object = {
        operation: 8,
        correlationId: '',
        timestamp: 0,
        clientId: null,
        timeToLive: 0,
        messageId: uuid().toUpperCase(),
        destination: 'auth',
        headers: this.generateHeaders(),
        body: new Buffer("" + this.options.username + ":" + this.options.authToken, 'utf8').toString('base64')
      };
      object.encoding = 0;
      return object;
    };

    AuthPacket.prototype.generateHeaders = function() {
      var headers;
      headers = new ASObject();
      headers.name = '';
      headers.object = {
        DSId: this.options.dsid,
        DSRequestTimeout: 60,
        DSEndpoint: 'my-rtmps'
      };
      headers.encoding = 2;
      return headers;
    };

    return AuthPacket;

  })(Packet);

  HeartbeatPacket = (function(_super) {
    __extends(HeartbeatPacket, _super);

    function HeartbeatPacket() {
      _ref2 = HeartbeatPacket.__super__.constructor.apply(this, arguments);
      return _ref2;
    }

    HeartbeatPacket.prototype.counter = 1;

    HeartbeatPacket.prototype.generate = function() {
      var object;
      object = new ASObject();
      object.name = 'flex.messaging.messages.RemotingMessage';
      object.object = {
        operation: 'performLCDSHeartBeat',
        source: null,
        timestamp: 0,
        clientId: null,
        timeToLive: 0,
        messageId: uuid().toUpperCase(),
        destination: 'loginService',
        headers: this.generateHeaders(),
        body: [this.options.acctId, this.options.authToken, this.counter, new Date().toString().slice(0, -6)]
      };
      object.encoding = 0;
      this.counter += 1;
      return object;
    };

    HeartbeatPacket.prototype.generateHeaders = function() {
      var headers;
      headers = new ASObject();
      headers.name = '';
      headers.object = {
        DSId: this.options.dsid,
        DSRequestTimeout: 60,
        DSEndpoint: 'my-rtmps'
      };
      headers.encoding = 2;
      return headers;
    };

    return HeartbeatPacket;

  })(Packet);

  LookupPacket = (function(_super) {
    __extends(LookupPacket, _super);

    function LookupPacket() {
      _ref3 = LookupPacket.__super__.constructor.apply(this, arguments);
      return _ref3;
    }

    LookupPacket.prototype.generate = function(name) {
      var object;
      object = new ASObject();
      object.name = 'flex.messaging.messages.RemotingMessage';
      object.object = {
        operation: 'getSummonerByName',
        source: null,
        timestamp: 0,
        clientId: null,
        timeToLive: 0,
        messageId: uuid().toUpperCase(),
        destination: 'summonerService',
        headers: this.generateHeaders(),
        body: [name]
      };
      object.encoding = 0;
      return object;
    };

    LookupPacket.prototype.generateHeaders = function() {
      var headers;
      headers = new ASObject();
      headers.name = '';
      headers.object = {
        DSId: this.options.dsid,
        DSRequestTimeout: 60,
        DSEndpoint: 'my-rtmps'
      };
      headers.encoding = 2;
      return headers;
    };

    return LookupPacket;

  })(Packet);

  SummonerNamesPacket = (function(_super) {
    __extends(SummonerNamesPacket, _super);

    function SummonerNamesPacket() {
      _ref3 = SummonerNamesPacket.__super__.constructor.apply(this, arguments);
      return _ref3;
    }

    SummonerNamesPacket.prototype.generate = function(ids) {
      var object;
      object = new ASObject();
      object.name = 'flex.messaging.messages.RemotingMessage';
      object.object = {
        operation: 'getSummonerNames',
        source: null,
        timestamp: 0,
        clientId: null,
        timeToLive: 0,
        messageId: uuid().toUpperCase(),
        destination: 'summonerService',
        headers: this.generateHeaders(),
        body: [ids]
      };
      object.encoding = 0;
      return object;
    };

    SummonerNamesPacket.prototype.generateHeaders = function() {
      var headers;
      headers = new ASObject();
      headers.name = '';
      headers.object = {
        DSId: this.options.dsid,
        DSRequestTimeout: 60,
        DSEndpoint: 'my-rtmps'
      };
      headers.encoding = 2;
      return headers;
    };

    return SummonerNamesPacket;

  })(Packet);

  GetSummonerDataPacket = (function(_super) {
    __extends(GetSummonerDataPacket, _super);

    function GetSummonerDataPacket() {
      _ref4 = GetSummonerDataPacket.__super__.constructor.apply(this, arguments);
      return _ref4;
    }

    GetSummonerDataPacket.prototype.generate = function(acctId) {
      var object;
      object = new ASObject();
      object.name = 'flex.messaging.messages.RemotingMessage';
      object.object = {
        operation: 'getAllPublicSummonerDataByAccount',
        source: null,
        timestamp: 0,
        clientId: null,
        timeToLive: 0,
        messageId: uuid().toUpperCase(),
        destination: 'summonerService',
        headers: this.generateHeaders(),
        body: [acctId]
      };
      object.encoding = 0;
      return object;
    };

    GetSummonerDataPacket.prototype.generateHeaders = function() {
      var headers;
      headers = new ASObject();
      headers.name = '';
      headers.object = {
        DSId: this.options.dsid,
        DSRequestTimeout: 60,
        DSEndpoint: 'my-rtmps'
      };
      headers.encoding = 2;
      return headers;
    };

    return GetSummonerDataPacket;

  })(Packet);

  AggregatedStatsPacket = (function(_super) {
    __extends(AggregatedStatsPacket, _super);

    function AggregatedStatsPacket() {
      _ref5 = AggregatedStatsPacket.__super__.constructor.apply(this, arguments);
      return _ref5;
    }

    AggregatedStatsPacket.prototype.generate = function(acctId) {
      var object;
      object = new ASObject();
      object.name = 'flex.messaging.messages.RemotingMessage';
      object.object = {
        operation: 'getAggregatedStats',
        source: null,
        timestamp: 0,
        clientId: null,
        timeToLive: 0,
        messageId: uuid().toUpperCase(),
        destination: 'playerStatsService',
        headers: this.generateHeaders(),
        body: [acctId, 'CLASSIC', 'CURRENT']
      };
      object.encoding = 0;
      return object;
    };

    AggregatedStatsPacket.prototype.generateHeaders = function() {
      var headers;
      headers = new ASObject();
      headers.name = '';
      headers.object = {
        DSId: this.options.dsid,
        DSRequestTimeout: 60,
        DSEndpoint: 'my-rtmps'
      };
      headers.encoding = 2;
      return headers;
    };

    return AggregatedStatsPacket;

  })(Packet);

  PlayerStatsPacket = (function(_super) {
    __extends(PlayerStatsPacket, _super);

    function PlayerStatsPacket() {
      _ref6 = PlayerStatsPacket.__super__.constructor.apply(this, arguments);
      return _ref6;
    }

    PlayerStatsPacket.prototype.generate = function(acctId) {
      var object;
      object = new ASObject();
      object.name = 'flex.messaging.messages.RemotingMessage';
      object.object = {
        operation: 'retrievePlayerStatsByAccountId',
        source: null,
        timestamp: 0,
        clientId: null,
        timeToLive: 0,
        messageId: uuid().toUpperCase(),
        destination: 'playerStatsService',
        headers: this.generateHeaders(),
        body: [acctId, 'CURRENT']
      };
      object.encoding = 0;
      return object;
    };

    PlayerStatsPacket.prototype.generateHeaders = function() {
      var headers;
      headers = new ASObject();
      headers.name = '';
      headers.object = {
        DSId: this.options.dsid,
        DSRequestTimeout: 60,
        DSEndpoint: 'my-rtmps'
      };
      headers.encoding = 2;
      return headers;
    };

    return PlayerStatsPacket;

  })(Packet);

  RecentGames = (function(_super) {
    __extends(RecentGames, _super);

    function RecentGames() {
      _ref7 = RecentGames.__super__.constructor.apply(this, arguments);
      return _ref7;
    }

    RecentGames.prototype.generate = function(acctId) {
      var object;
      object = new ASObject();
      object.name = 'flex.messaging.messages.RemotingMessage';
      object.object = {
        operation: 'getRecentGames',
        source: null,
        timestamp: 0,
        clientId: null,
        timeToLive: 0,
        messageId: uuid().toUpperCase(),
        destination: 'playerStatsService',
        headers: this.generateHeaders(),
        body: [acctId]
      };
      object.encoding = 0;
      return object;
    };

    RecentGames.prototype.generateHeaders = function() {
      var headers;
      headers = new ASObject();
      headers.name = '';
      headers.object = {
        DSId: this.options.dsid,
        DSRequestTimeout: 60,
        DSEndpoint: 'my-rtmps'
      };
      headers.encoding = 2;
      return headers;
    };

    return RecentGames;

  })(Packet);

  GetTeamForSummoner = (function(_super) {
    __extends(GetTeamForSummoner, _super);

    function GetTeamForSummoner() {
      _ref8 = GetTeamForSummoner.__super__.constructor.apply(this, arguments);
      return _ref8;
    }

    GetTeamForSummoner.prototype.generate = function(summonerId) {
      var object;
      object = new ASObject();
      object.name = 'flex.messaging.messages.RemotingMessage';
      object.object = {
        operation: 'findPlayer',
        source: null,
        timestamp: 0,
        clientId: null,
        timeToLive: 0,
        messageId: uuid().toUpperCase(),
        destination: 'summonerTeamService',
        headers: this.generateHeaders(),
        body: [summonerId]
      };
      object.encoding = 0;
      return object;
    };

    GetTeamForSummoner.prototype.generateHeaders = function() {
      var headers;
      headers = new ASObject();
      headers.name = '';
      headers.object = {
        DSId: this.options.dsid,
        DSRequestTimeout: 60,
        DSEndpoint: 'my-rtmps'
      };
      headers.encoding = 2;
      return headers;
    };

    return GetTeamForSummoner;

  })(Packet);

// OWN CODE. retrieveInProgressSpectatorGameInfo

  GetInProgressMatch = (function(_super) {
    __extends(GetInProgressMatch, _super);

    function GetInProgressMatch() {
      _ref8 = GetInProgressMatch.__super__.constructor.apply(this, arguments);
      return _ref8;
    }

    GetInProgressMatch.prototype.generate = function(summonerId) {
      var object;
      object = new ASObject();
      object.name = 'flex.messaging.messages.RemotingMessage';
      object.object = {
        operation: 'retrieveInProgressSpectatorGameInfo',
        source: null,
        timestamp: 0,
        clientId: null,
        timeToLive: 0,
        messageId: uuid().toUpperCase(),
        destination: 'gameService',
        headers: this.generateHeaders(),
        body: [summonerId]
      };
      object.encoding = 0;
      return object;
    };

    GetInProgressMatch.prototype.generateHeaders = function() {
      var headers;
      headers = new ASObject();
      headers.name = '';
      headers.object = {
        DSId: this.options.dsid,
        DSRequestTimeout: 60,
        DSEndpoint: 'my-rtmps'
      };
      headers.encoding = 2;
      return headers;
    };

    return GetInProgressMatch;

  })(Packet);

  //retrieveInProgressSpectatorGameInfo end

  GetTeamById = (function(_super) {
    __extends(GetTeamById, _super);

    function GetTeamById() {
      _ref9 = GetTeamById.__super__.constructor.apply(this, arguments);
      return _ref9;
    }

    GetTeamById.prototype.generate = function(teamId) {
      var object;
      object = new ASObject();
      object.name = 'flex.messaging.messages.RemotingMessage';
      object.object = {
        operation: 'findTeamById',
        source: null,
        timestamp: 0,
        clientId: null,
        timeToLive: 0,
        messageId: uuid().toUpperCase(),
        destination: 'summonerTeamService',
        headers: this.generateHeaders(),
        body: [this.generateBody(teamId)]
      };
      object.encoding = 0;
      return object;
    };

    GetTeamById.prototype.generateBody = function(teamId) {
      var body;
      body = new ASObject();
      body.name = 'com.riotgames.team.TeamId';
      body.object = {
        dataVersion: null,
        fullId: teamId,
        futureData: null
      };
      body.encoding = 0;
      return body;
    };

    GetTeamById.prototype.generateHeaders = function() {
      var headers;
      headers = new ASObject();
      headers.name = '';
      headers.object = {
        DSId: this.options.dsid,
        DSRequestTimeout: 60,
        DSEndpoint: 'my-rtmps'
      };
      headers.encoding = 2;
      return headers;
    };

    return GetTeamById;

  })(Packet);

  GetAllLeaguesForPlayer = (function(_super) {
    __extends(GetAllLeaguesForPlayer, _super);

    function GetAllLeaguesForPlayer() {
      _ref9 = GetAllLeaguesForPlayer.__super__.constructor.apply(this, arguments);
      return _ref9;
    }

    GetAllLeaguesForPlayer.prototype.generate = function(summonerId) {
      var object;
      object = new ASObject();
      object.name = 'flex.messaging.messages.RemotingMessage';
      object.object = {
        operation: 'getAllLeaguesForPlayer',
        source: null,
        timestamp: 0,
        clientId: null,
        timeToLive: 0,
        messageId: uuid().toUpperCase(),
        destination: 'leaguesServiceProxy',
        headers: this.generateHeaders(),
        body: [summonerId]
      };
      object.encoding = 0;
      return object;
    };

    GetAllLeaguesForPlayer.prototype.generateHeaders = function() {
      var headers;
      headers = new ASObject();
      headers.name = '';
      headers.object = {
        DSId: this.options.dsid,
        DSRequestTimeout: 60,
        DSEndpoint: 'my-rtmps'
      };
      headers.encoding = 2;
      return headers;
    };

    return GetAllLeaguesForPlayer;

  })(Packet);

  exports.ConnectPacket = ConnectPacket;

  exports.LoginPacket = LoginPacket;

  exports.AuthPacket = AuthPacket;

  exports.HeartbeatPacket = HeartbeatPacket;

  exports.LookupPacket = LookupPacket;

  exports.SummonerNamesPacket = SummonerNamesPacket;

  exports.GetSummonerDataPacket = GetSummonerDataPacket;

  exports.AggregatedStatsPacket = AggregatedStatsPacket;

  exports.PlayerStatsPacket = PlayerStatsPacket;

  exports.RecentGames = RecentGames;

  exports.GetTeamForSummoner = GetTeamForSummoner;

  exports.GetTeamById = GetTeamById;

  exports.GetInProgressMatch = GetInProgressMatch;

  exports.GetAllLeaguesForPlayer = GetAllLeaguesForPlayer;

}).call(this);


text:
<?php

class __UrlBuilderFactory {

    /**
     * Creates and returns an __UrlBuilder instance for an specific route
     *
     * @param __Route $route The route to use to create the __UrlBuilder instance
     * @return __UrlBuilder The __UrlBuilder instance
     *
     * @see __UrlBuilder
     *
     */
    static public function createUrlBuilder(__Route $route) {
        //create the UrlBuilder
        $return_value  = new __UrlBuilder();
        //and populate it according to the selected route:
        $return_value->setUrlPattern($route->getUrlPattern());

        $var_patterns = $route->getVariablePatterns();
        foreach($var_patterns as $var_name => $var_pattern) {
            $return_value->addVariablePattern($var_name, $var_pattern);
        }

        $parameters = $route->getFixedParameters();
        foreach($parameters as $parameter_name => $parameter_value) {
            if(preg_match('/^\$(.+)$/', trim($parameter_value))) {
                $variable_name = trim($parameter_value);
                $return_value->addVariable($parameter_name, $variable_name);
            }
        }

        $if_isset_conditions = $route->getIfIssetConditions();
        foreach($if_isset_conditions as $variable_name => $parameters) {
            foreach($parameters as $parameter_name => $parameter_value) {
                //If the parameter has a value, will set a variable instead of it:
                $return_value->addVariableIfParameterEquals($parameter_name, $parameter_value, $variable_name);
            }
        }
        $if_equals_conditions = $route->getIfEqualsConditions();
        foreach($if_equals_conditions as $variable_name => $variable_values) {
            foreach($variable_values as $variable_value => $parameters) {
                foreach($parameters as $parameter_name => $parameter_value) {
                    $return_value->addVariableIfParameterEquals($parameter_name, $parameter_value, $variable_name, $variable_value);
                }
            }
        }

        $return_value->setAllowQueryParameters($route->getAllowQueryParameters());

        $action_identity = $route->getActionIdentity();
        if($action_identity != null) {
            if($action_identity->getActionCode() != null && preg_match('/^\$(.+)$/', $action_identity->getActionCode())) {
                $return_value->setVariableForActionCode($action_identity->getActionCode());
            }
            if(preg_match('/^\$(.+)$/', $action_identity->getControllerCode())) {
                $return_value->setVariableForControllerCode($action_identity->getControllerCode());
            }
        }
        return $return_value;
    }

}


text:
require 'singleton'
require 'thread'

module Thrifty ; class Signals

  include Singleton

  class << self
    def register(fn)
      instance.install
      instance.register(fn)
    end

    def register_after(fn)
      instance.install
      instance.register_after(fn)
    end
  end

  def initialize
    @handlers  = []
    @after     = []
    @mutex     = Mutex.new
    @resource  = ConditionVariable.new
    @installed = false
  end

  def install
    unless @installed
      %w{INT TERM}.each do |sig|
        trap sig do
          Thread.new{ shutdown }.join
        end
      end
      @installed = true
    end
  end

  def wait
    begin
      @mutex.synchronize do
        @resource.wait(@mutex)
      end
    rescue ::Interrupt
      shutdown
    end
  end

  def register(fn)
    @handlers << fn
  end

  def register_after(fn)
    @after << fn
  end

  def shutdown(sig = nil)
    @handlers.each {|fn| fn.call }
    @after.each {|fn| fn.call }

    @mutex.synchronize do
      @resource.signal
    end
  end

end ; end


text:
"""
Image_fft
part of pycroscopy

author: Gerd Duscher, UTK

"""

import numpy as np
from scipy import ndimage
from skimage.feature import peak_local_max, blob_log
import sys
import sidpy

get_slope = sidpy.base.num_utils.get_slope

def power_spectrum(dset, smoothing=3):
    """
    Calculate power spectrum

    Parameters
    ----------
    dset: sidpy.Dataset
        image
    smoothing: int
        Gaussian smoothing

    Returns
    -------
    power_spec: sidpy.Dataset
        power spectrum with correct dimensions

    """
    assert isinstance(dset, sidpy.Dataset)
    smoothing = int(smoothing)
    fft_transform = dset.fft()
    fft_mag = np.abs(fft_transform)
    fft_mag2 = ndimage.gaussian_filter(fft_mag, sigma=(smoothing, smoothing), order=0)

    power_spec = fft_transform.like_data(np.log(1.+fft_mag2))

    # prepare mask
    x, y = np.meshgrid(power_spec.v.values, power_spec.u.values)
    mask = np.zeros(power_spec.shape)

    mask_spot = x ** 2 + y ** 2 > 1 ** 2
    mask = mask + mask_spot
    mask_spot = x ** 2 + y ** 2 < 11 ** 2
    mask = mask + mask_spot

    mask[np.where(mask == 1)] = 0  # just in case of overlapping disks

    minimum_intensity = np.array(power_spec)[np.where(mask == 2)].min() * 0.95
    maximum_intensity = np.array(power_spec)[np.where(mask == 2)].max() * 1.05
    power_spec.metadata = {'fft': {'smoothing': smoothing,
                                   'minimum_intensity': minimum_intensity, 'maximum_intensity': maximum_intensity}}
    power_spec.title = 'power spectrum ' + power_spec.source

    return power_spec

def diffractogram_spots(dset, spot_threshold):
    """Find spots in diffractogram and sort them by distance from center

    Uses blob_log from scipy.spatial

    Parameters
    ----------
    dset: sidpy.Dataset
        diffractogram
    spot_threshold: float
        threshold for blob finder

    Returns
    -------
    spots: numpy array
        sorted position (x,y) and radius (r) of all spots
    """

    # spot detection (for future reference there is no symmetry assumed here)
    data = np.array(np.log(1+np.abs(dset)))
    data = (data - data.min())
    data = data/data.max()
    # some images are strange and blob_log does not work on the power spectrum
    try:
        spots_random = blob_log(data, max_sigma=5, threshold=spot_threshold)
    except ValueError:
        spots_random = peak_local_max(np.array(data.T), min_distance=3, threshold_rel=spot_threshold)
        spots_random = np.hstack(spots_random, np.zeros((spots_random.shape[0], 1)))

    print(f'Found {spots_random.shape[0]} reflections')

    # Needed for conversion from pixel to Reciprocal space

    rec_scale = np.array([get_slope(dset.u.values), get_slope(dset.v.values)])

    spots_random[:, :2] = spots_random[:, :2]*rec_scale+[dset.u.values[0], dset.v.values[0]]
    # sort reflections
    spots_random[:, 2] = np.linalg.norm(spots_random[:, 0:2], axis=1)
    spots_index = np.argsort(spots_random[:, 2])
    spots = spots_random[spots_index]
    # third row is angles
    spots[:, 2] = np.arctan2(spots[:, 0], spots[:, 1])
    return spots

def adaptive_fourier_filter(dset, spots, low_pass=3, reflection_radius=0.3):
    """
    Use spots in diffractogram for a Fourier Filter

    Parameters:
    -----------
    dset: sidpu.Dataset
        image to be filtered
    spots: np.ndarray(N,2)
        sorted spots in diffractogram in 1/nm
    low_pass:  float
        low pass filter in center of diffractogram in 1/nm
    reflection_radius:  float
        radius of masked reflections in 1/nm

    Output:
    -------
            Fourier filtered image
    """

    if not isinstance(dset, sidpy.Dataset):
        raise TypeError('We need a sidpy.Dataset')
    fft_transform = dset.fft()

    # prepare mask
    x, y = np.meshgrid(fft_transform.u.values, fft_transform.v.values)
    mask = np.zeros(dset.shape)

    # mask reflections
    for spot in spots:
        mask_spot = (x - spot[1]) ** 2 + (y - spot[0]) ** 2 < reflection_radius ** 2  # make a spot
        mask = mask + mask_spot  # add spot to mask

    # mask zero region larger (low-pass filter = intensity variations)
    mask_spot = x ** 2 + y ** 2 < low_pass ** 2
    mask = mask + mask_spot
    mask[np.where(mask > 1)] = 1
    fft_filtered = np.array(fft_transform * mask)

    filtered_image = dset.like_data(np.fft.ifft2(np.fft.fftshift(fft_filtered)).real)
    filtered_image.title = 'Fourier filtered ' + dset.title
    filtered_image.source = dset.title
    filtered_image.metadata = {'analysis': 'adaptive fourier filtered', 'spots': spots,
                               'low_pass': low_pass, 'reflection_radius': reflection_radius}
    return filtered_image


text:
using System;
using System.IO;

using MatterHackers.Agg.PlatformAbstract;
using Newtonsoft.Json;

namespace MatterHackers.MatterControl
{
	public sealed class VersionInfo
	{
		public readonly static VersionInfo Instance = DeserializeFromDisk();

		// Prevent external construction and limit to singleton Instance above
		private VersionInfo()
		{
		}

		public string ReleaseVersion { get; set; }

		public string BuildVersion { get; set; }

		public string BuildToken { get; set; }

		public string ProjectToken { get; set; }

		private static VersionInfo DeserializeFromDisk()
		{
			string content = StaticData.Instance.ReadAllText("BuildInfo.txt");
			return JsonConvert.DeserializeObject<VersionInfo>(content);
		}
	}
}


text:
//
// JQuery Namespace (Cross-Browser Extension)
//
// By Ciccio Ceras
//

/*

usage example:

//sample xml:
<wps:Capabilities xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:wps="http://www.opengis.net/wps/1.0.0" xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" service="WPS" version="1.0.0" xml:lang="en-US" xsi:schemaLocation="http://www.opengis.net/wps/1.0.0 http://schemas.opengis.net/wps/1.0.0/wpsGetCapabilities_response.xsd" updateSequence="1">
	<ows:ServiceIdentification>
	<ows:Title>i-Marine Web Processing Server</ows:Title>
	<ows:Abstract>
		iMarine (283644) is funded by the European Commission under Framework Programme 7
	</ows:Abstract>
	<wps:ProcessOfferings>
		<wps:Process wps:processVersion="1.0.0">
			<ows:Identifier>
				com.terradue.wps_hadoop.processes.fao.spread.Spread
			</ows:Identifier>
			<ows:Title>Spread</ows:Title>
		</wps:Process>
		<wps:Process wps:processVersion="1.0.0">
			<ows:Identifier>
				com.terradue.wps_hadoop.processes.ird.indicator.IndicatorI6
			</ows:Identifier>
			<ows:Title>IRD Tuna Atlas Indicator i6</ows:Title>
		</wps:Process>
		<wps:Process wps:processVersion="1.0.0">
			<ows:Identifier>
				com.terradue.wps_hadoop.processes.ird.indicator.IndicatorI1
			</ows:Identifier>
			<ows:Title>IRD Tuna Atlas Indicator i1</ows:Title>
		</wps:Process>
	</wps:ProcessOfferings>
</wps:Capabilities>

// 1) usage with namespace URI
var ns={
	wps: "http://www.opengis.net/wps/1.0.0",
	ows:"http://www.opengis.net/ows/1.1"
}
$xml.findNsURI(ns.wps, "Process").findNsURI(ns.ows, "Identifier").each( function(){console.log($(this).text())}  )

// 2) usage with only namespace
$xml.findNs("wps", "Process").findNs("ows", "Identifier").each( function(){console.log($(this).text())}  )

// 3) usage with only namespace, simplified in an unique tagname
$xml.findNs("wps:Process").findNs("ows:Identifier").each( function(){console.log($(this).text())}  )

// all the three statements produce this output:
com.terradue.wps_hadoop.processes.fao.spread.Spread
com.terradue.wps_hadoop.processes.ird.indicator.IndicatorI6
com.terradue.wps_hadoop.processes.ird.indicator.IndicatorI1

 */

;(function($){

	$.fn.findNsURI = function(namespaceURI, tagName){
		return $(this).find("*").filter(function(){
			return (this.localName==tagName && this.namespaceURI==namespaceURI);
		});
	};

	$.fn.findNs = function(namespace, tagName){
		if (tagName==null){
			var ar = namespace.split(":");
			if (ar.length==0) return;
			tagName=ar[1];
			namespace=ar[0];
		}

		var $xml = $(this);

		// check if the browser is chrome
		if (navigator.userAgent.toLowerCase().indexOf('chrome') > -1){
			return $xml.find("*").filter(function() {
				// check the tagName (tagName===<ns>:<tag>
				return (this.tagName == namespace+":"+tagName);
			});
		}

		// other browsers: only jquery works good
		else
			return $xml.find(namespace+"\\:"+tagName);

	};

	$.fn.childrenNsURI = function(namespaceURI, tagName){
		var $xml = $(this);

		return $xml.children().filter(function(){
			return (this.localName==tagName && this.namespaceURI==namespaceURI);
		});

	};

	$.fn.childrenNs = function(namespace, tagName){
		if (tagName==null){
			var ar = namespace.split(":");
			if (ar.length==0) return;
			tagName=ar[1];
			namespace=ar[0];
		}

		var $xml = $(this);

		return $xml.children(namespace+"\\:"+tagName);

	};

})(jQuery);


text:
package com.twosigma.beakerx.jvm.threads;

import com.twosigma.beakerx.kernel.msg.JupyterMessages;
import com.twosigma.beakerx.message.Header;
import com.twosigma.beakerx.message.Message;
import org.junit.Before;
import org.junit.Test;

import java.util.Arrays;
import java.util.List;

import static com.twosigma.beakerx.kernel.msg.JupyterMessages.EXECUTE_REQUEST;
import static org.assertj.core.api.Assertions.assertThat;

public class InputRequestMessageFactoryImplTest {

  private InputRequestMessageFactoryImpl inputRequestMessageFactory;

  @Before
  public void setUp() throws Exception {
    inputRequestMessageFactory = new InputRequestMessageFactoryImpl();
  }

  @Test
  public void inputRequestMessage() {
    //given
    Message parent = new Message(new Header(EXECUTE_REQUEST, "session1"));
    List<byte[]> identities = Arrays.asList("MessageIdentities123".getBytes());
    parent.setIdentities(identities);
    //when
    Message message = inputRequestMessageFactory.create(parent);
    //then
    assertThat(message.getIdentities()).isEqualTo(identities);
    assertThat(message.type()).isEqualTo(JupyterMessages.INPUT_REQUEST);
  }
}