text:
/*-------------------------------------------------------------------------
 *
 * Created:		H5Pdapl.c
 *              October 27, 2008
 *              Neil Fortner <nfortne2@hdfgroup.org>
 *
 * Purpose:		Dataset access property list class routines
 *
 *-------------------------------------------------------------------------
 */

/****************/
/* Module Setup */
/****************/
#define H5P_PACKAGE		/*suppress error about including H5Ppkg	  */

/***********/
/* Headers */
/***********/
#include "H5private.h"		/* Generic Functions */
#include "H5Dprivate.h"		/* Datasets */
#include "H5Eprivate.h"		/* Error handling */
#include "H5Fprivate.h"		/* Files */
#include "H5Iprivate.h"		/* IDs */
#include "H5Ppkg.h"         /* Property lists */
#include "H5MMprivate.h"	/* Memory management */

/****************/
/* Local Macros */
/****************/

/* ========= Dataset Access properties ============ */
/* Definitions for size of raw data chunk cache(slots) */
#define H5D_ACS_DATA_CACHE_NUM_SLOTS_SIZE       sizeof(size_t)
#define H5D_ACS_DATA_CACHE_NUM_SLOTS_DEF        H5D_CHUNK_CACHE_NSLOTS_DEFAULT
/* Definition for size of raw data chunk cache(bytes) */
#define H5D_ACS_DATA_CACHE_BYTE_SIZE_SIZE       sizeof(size_t)
#define H5D_ACS_DATA_CACHE_BYTE_SIZE_DEF        H5D_CHUNK_CACHE_NBYTES_DEFAULT
/* Definition for preemption read chunks first */
#define H5D_ACS_PREEMPT_READ_CHUNKS_SIZE        sizeof(double)
#define H5D_ACS_PREEMPT_READ_CHUNKS_DEF         H5D_CHUNK_CACHE_W0_DEFAULT
/* Definitions for external file prefix */
#define H5D_ACS_EFILE_PREFIX_SIZE               sizeof(char *)
#define H5D_ACS_EFILE_PREFIX_DEF                NULL /*default is no prefix */
#define H5D_ACS_EFILE_PREFIX_SET                H5P__dapl_efile_pref_set
#define H5D_ACS_EFILE_PREFIX_GET                H5P__dapl_efile_pref_get
#define H5D_ACS_EFILE_PREFIX_DEL                H5P__dapl_efile_pref_del
#define H5D_ACS_EFILE_PREFIX_COPY               H5P__dapl_efile_pref_copy
#define H5D_ACS_EFILE_PREFIX_CMP                H5P__dapl_efile_pref_cmp
#define H5D_ACS_EFILE_PREFIX_CLOSE              H5P__dapl_efile_pref_close

/******************/
/* Local Typedefs */
/******************/

/********************/
/* Package Typedefs */
/********************/

/********************/
/* Local Prototypes */
/********************/

/* Property class callbacks */
static herr_t H5P__dacc_reg_prop(H5P_genclass_t *pclass);

/* Property list callbacks */
static herr_t H5P__dapl_efile_pref_set(hid_t prop_id, const char* name, size_t size, void* value);
static herr_t H5P__dapl_efile_pref_get(hid_t prop_id, const char* name, size_t size, void* value);
static herr_t H5P__dapl_efile_pref_del(hid_t prop_id, const char* name, size_t size, void* value);
static herr_t H5P__dapl_efile_pref_copy(const char* name, size_t size, void* value);
static int H5P__dapl_efile_pref_cmp(const void *value1, const void *value2, size_t size);
static herr_t H5P__dapl_efile_pref_close(const char* name, size_t size, void* value);

/*********************/
/* Package Variables */
/*********************/

/* Dataset access property list class library initialization object */
const H5P_libclass_t H5P_CLS_DACC[1] = {{
    "dataset access",		/* Class name for debugging     */
    H5P_TYPE_DATASET_ACCESS,    /* Class type                   */

    &H5P_CLS_LINK_ACCESS_g,	/* Parent class                 */
    &H5P_CLS_DATASET_ACCESS_g,	/* Pointer to class             */
    &H5P_CLS_DATASET_ACCESS_ID_g,	/* Pointer to class ID          */
    &H5P_LST_DATASET_ACCESS_ID_g,	/* Pointer to default property list ID */
    H5P__dacc_reg_prop,		/* Default property registration routine */

    NULL,		        /* Class creation callback      */
    NULL,		        /* Class creation callback info */
    NULL,		        /* Class copy callback          */
    NULL,		        /* Class copy callback info     */
    NULL,		        /* Class close callback         */
    NULL 		        /* Class close callback info    */
}};

/*****************************/
/* Library Private Variables */
/*****************************/

/*******************/
/* Local Variables */
/*******************/

/* Property value defaults */
static const char *H5D_def_efile_prefix_g = H5D_ACS_EFILE_PREFIX_DEF; /* Default external file prefix string */

/*-------------------------------------------------------------------------
 * Function:    H5P__dacc_reg_prop
 *
 * Purpose:     Register the dataset access property list class's
 *              properties
 *
 * Return:      Non-negative on success/Negative on failure
 *
 * Programmer:  Neil Fortner
 *              October 27, 2008
 *-------------------------------------------------------------------------
 */
static herr_t
H5P__dacc_reg_prop(H5P_genclass_t *pclass)
{
    size_t rdcc_nslots = H5D_ACS_DATA_CACHE_NUM_SLOTS_DEF;      /* Default raw data chunk cache # of slots */
    size_t rdcc_nbytes = H5D_ACS_DATA_CACHE_BYTE_SIZE_DEF;      /* Default raw data chunk cache # of bytes */
    double rdcc_w0 = H5D_ACS_PREEMPT_READ_CHUNKS_DEF;           /* Default raw data chunk cache dirty ratio */
    herr_t ret_value = SUCCEED;         /* Return value */

    FUNC_ENTER_STATIC

    /* Register the size of raw data chunk cache (elements) */
    if(H5P_register_real(pclass, H5D_ACS_DATA_CACHE_NUM_SLOTS_NAME, H5D_ACS_DATA_CACHE_NUM_SLOTS_SIZE, &rdcc_nslots, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0)
         HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")

    /* Register the size of raw data chunk cache(bytes) */
    if(H5P_register_real(pclass, H5D_ACS_DATA_CACHE_BYTE_SIZE_NAME, H5D_ACS_DATA_CACHE_BYTE_SIZE_SIZE, &rdcc_nbytes, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0)
         HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")

    /* Register the preemption for reading chunks */
    if(H5P_register_real(pclass, H5D_ACS_PREEMPT_READ_CHUNKS_NAME, H5D_ACS_PREEMPT_READ_CHUNKS_SIZE, &rdcc_w0, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0)
         HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")

    /* Register property for external file prefix */
    if(H5P_register_real(pclass, H5D_ACS_EFILE_PREFIX_NAME, H5D_ACS_EFILE_PREFIX_SIZE, &H5D_def_efile_prefix_g,
            NULL, H5D_ACS_EFILE_PREFIX_SET, H5D_ACS_EFILE_PREFIX_GET,
            H5D_ACS_EFILE_PREFIX_DEL, H5D_ACS_EFILE_PREFIX_COPY, H5D_ACS_EFILE_PREFIX_CMP, H5D_ACS_EFILE_PREFIX_CLOSE) < 0)
         HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")

done:
    FUNC_LEAVE_NOAPI(ret_value)
} /* end H5P__dacc_reg_prop() */

/*-------------------------------------------------------------------------
 * Function:    H5P__dapl_efile_pref_set
 *
 * Purpose:     Copies an external file prefix property when it's set
 *              for a property list
 *
 * Return:      SUCCEED/FAIL
 *
 *-------------------------------------------------------------------------
 */
static herr_t
H5P__dapl_efile_pref_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name,
    size_t H5_ATTR_UNUSED size, void *value)
{
    FUNC_ENTER_STATIC_NOERR

    /* Sanity check */
    HDassert(value);

    /* Copy the prefix */
    *(char **)value = H5MM_xstrdup(*(const char **)value);

    FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5P__dapl_efile_pref_set() */

/*-------------------------------------------------------------------------
 * Function:    H5P__dapl_efile_pref_get
 *
 * Purpose:     Copies an external file prefix property when it's retrieved
 *              from a property list
 *
 * Return:      SUCCEED/FAIL
 *
 *-------------------------------------------------------------------------
 */
static herr_t
H5P__dapl_efile_pref_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name,
    size_t H5_ATTR_UNUSED size, void *value)
{
    FUNC_ENTER_STATIC_NOERR

    /* Sanity check */
    HDassert(value);

    /* Copy the prefix */
    *(char **)value = H5MM_xstrdup(*(const char **)value);

    FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5P__dapl_efile_pref_get() */

/*-------------------------------------------------------------------------
 * Function:    H5P__dapl_efile_pref_del
 *
 * Purpose:     Frees memory used to store the external file prefix string
 *
 * Return:      SUCCEED (Can't fail)
 *
 *-------------------------------------------------------------------------
 */
static herr_t
H5P__dapl_efile_pref_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name,
    size_t H5_ATTR_UNUSED size, void *value)
{
    FUNC_ENTER_NOAPI_NOINIT_NOERR

    HDassert(value);

    H5MM_xfree(*(void **)value);

    FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5P__dapl_efile_pref_del() */

/*-------------------------------------------------------------------------
 * Function:    H5P__dapl_efile_pref_copy
 *
 * Purpose:     Creates a copy of the external file prefix string
 *
 * Return:      SUCCEED/FAIL
 *
 *-------------------------------------------------------------------------
 */
static herr_t
H5P__dapl_efile_pref_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value)
{
    FUNC_ENTER_NOAPI_NOINIT_NOERR

    HDassert(value);

    *(char **)value = H5MM_xstrdup(*(const char **)value);

    FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5P__dapl_efile_pref_copy() */

/*-------------------------------------------------------------------------
 * Function:       H5P__dapl_efile_pref_cmp
 *
 * Purpose:        Callback routine which is called whenever the efile prefix
 *                 property in the dataset creation property list is
 *                 compared.
 *
 * Return:         zero if VALUE1 and VALUE2 are equal, non zero otherwise.
 *
 *-------------------------------------------------------------------------
 */
static int
H5P__dapl_efile_pref_cmp(const void *value1, const void *value2, size_t H5_ATTR_UNUSED size)
{
    const char *pref1 = *(const char * const *)value1;
    const char *pref2 = *(const char * const *)value2;
    int ret_value = 0;

    FUNC_ENTER_NOAPI_NOINIT_NOERR

    if(NULL == pref1 && NULL != pref2)
        HGOTO_DONE(1);
    if(NULL != pref1 && NULL == pref2)
        HGOTO_DONE(-1);
    if(NULL != pref1 && NULL != pref2)
        ret_value = HDstrcmp(pref1, pref2);

done:
    FUNC_LEAVE_NOAPI(ret_value)
} /* end H5P__dapl_efile_pref_cmp() */

/*-------------------------------------------------------------------------
 * Function:    H5P__dapl_efile_pref_close
 *
 * Purpose:     Frees memory used to store the external file prefix string
 *
 * Return:      SUCCEED/FAIL
 *
 *-------------------------------------------------------------------------
 */
static herr_t
H5P__dapl_efile_pref_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value)
{
    FUNC_ENTER_NOAPI_NOINIT_NOERR

    HDassert(value);

    H5MM_xfree(*(void **)value);

    FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5P__dapl_efile_pref_close() */

/*-------------------------------------------------------------------------
 * Function:	H5Pset_chunk_cache
 *
 * Purpose:	Set the number of objects in the meta data cache and the
 *		maximum number of chunks and bytes in the raw data chunk cache.
 *      Once set, these values will override the values in the file access
 *      property list.  Each of thhese values can be individually unset
 *      (or not set at all) by passing the macros:
 *      H5D_CHUNK_CACHE_NCHUNKS_DEFAULT,
 *      H5D_CHUNK_CACHE_NSLOTS_DEFAULT, and/or
 *      H5D_CHUNK_CACHE_W0_DEFAULT
 *      as appropriate.
 *
 * 		The RDCC_W0 value should be between 0 and 1 inclusive and
 *		indicates how much chunks that have been fully read or fully
 *		written are favored for preemption.  A value of zero means
 *		fully read or written chunks are treated no differently than
 *		other chunks (the preemption is strictly LRU) while a value
 *		of one means fully read chunks are always preempted before
 *		other chunks.
 *
 * Return:	Non-negative on success/Negative on failure
 *
 * Programmer:	Neil Fortner
 *              Monday, October 27, 2008
 *
 * Modifications:
 *
 *-------------------------------------------------------------------------
 */
herr_t
H5Pset_chunk_cache(hid_t dapl_id, size_t rdcc_nslots, size_t rdcc_nbytes, double rdcc_w0)
{
    H5P_genplist_t *plist;      /* Property list pointer */
    herr_t ret_value = SUCCEED; /* return value */

    FUNC_ENTER_API(FAIL)
    H5TRACE4("e", "izzd", dapl_id, rdcc_nslots, rdcc_nbytes, rdcc_w0);

    /* Check arguments.  Note that we allow negative values - they are
     * considered to "unset" the property. */
    if(rdcc_w0 > (double)1.0f)
        HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "raw data cache w0 value must be between 0.0 and 1.0 inclusive, or H5D_CHUNK_CACHE_W0_DEFAULT");

    /* Get the plist structure */
    if(NULL == (plist = H5P_object_verify(dapl_id,H5P_DATASET_ACCESS)))
        HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID");

    /* Set sizes */
    if(H5P_set(plist, H5D_ACS_DATA_CACHE_NUM_SLOTS_NAME, &rdcc_nslots) < 0)
        HGOTO_ERROR(H5E_PLIST, H5E_CANTSET,FAIL, "can't set data cache number of chunks");
    if(H5P_set(plist, H5D_ACS_DATA_CACHE_BYTE_SIZE_NAME, &rdcc_nbytes) < 0)
        HGOTO_ERROR(H5E_PLIST, H5E_CANTSET,FAIL, "can't set data cache byte size");
    if(H5P_set(plist, H5D_ACS_PREEMPT_READ_CHUNKS_NAME, &rdcc_w0) < 0)
        HGOTO_ERROR(H5E_PLIST, H5E_CANTSET,FAIL, "can't set preempt read chunks");

done:
    FUNC_LEAVE_API(ret_value)
} /* end H5Pset_chunk_cache() */

/*-------------------------------------------------------------------------
 * Function:	H5Pget_chunk_cache
 *
 * Purpose:	Retrieves the maximum possible number of elements in the meta
 *		data cache and the maximum possible number of elements and
 *		bytes and the RDCC_W0 value in the raw data chunk cache.  Any
 *		(or all) arguments may be null pointers in which case the
 *		corresponding datum is not returned.  If these properties have
 *      not been set on this property list, the default values for a
 *      file access property list are returned.
 *
 * Return:	Non-negative on success/Negative on failure
 *
 * Programmer:	Neil Fortner
 *              Monday, October 27, 2008
 *
 * Modifications:
 *
 *-------------------------------------------------------------------------
 */
herr_t
H5Pget_chunk_cache(hid_t dapl_id, size_t *rdcc_nslots, size_t *rdcc_nbytes, double *rdcc_w0)
{
    H5P_genplist_t *plist;      /* Property list pointer */
    H5P_genplist_t *def_plist;  /* Default file access property list */
    herr_t ret_value = SUCCEED; /* return value */

    FUNC_ENTER_API(FAIL)
    H5TRACE4("e", "i*z*z*d", dapl_id, rdcc_nslots, rdcc_nbytes, rdcc_w0);

    /* Get the plist structure */
    if (NULL == (plist = H5P_object_verify(dapl_id, H5P_DATASET_ACCESS)))
        HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID");

    /* Get default file access plist */
    if (NULL == (def_plist = (H5P_genplist_t *)H5I_object(H5P_FILE_ACCESS_DEFAULT)))
        HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for default fapl ID");

    /* Get the properties.  If a property is set to the default value, the value
     * from the default fapl is used. */
    if (rdcc_nslots) {
        if (H5P_get(plist, H5D_ACS_DATA_CACHE_NUM_SLOTS_NAME, rdcc_nslots) < 0)
            HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get data cache number of slots");
        if (*rdcc_nslots == H5D_CHUNK_CACHE_NSLOTS_DEFAULT)
            if (H5P_get(def_plist, H5F_ACS_DATA_CACHE_NUM_SLOTS_NAME, rdcc_nslots) < 0)
                HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get default data cache number of slots");
    } /* end if */
    if (rdcc_nbytes) {
        if (H5P_get(plist, H5D_ACS_DATA_CACHE_BYTE_SIZE_NAME, rdcc_nbytes) < 0)
            HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get data cache byte size");
        if (*rdcc_nbytes == H5D_CHUNK_CACHE_NBYTES_DEFAULT)
            if (H5P_get(def_plist, H5F_ACS_DATA_CACHE_BYTE_SIZE_NAME, rdcc_nbytes) < 0)
                HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get default data cache byte size");
    } /* end if */
    if (rdcc_w0) {
        if (H5P_get(plist, H5D_ACS_PREEMPT_READ_CHUNKS_NAME, rdcc_w0) < 0)
            HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get preempt read chunks");
        if (*rdcc_w0 < 0)
            if (H5P_get(def_plist, H5F_ACS_PREEMPT_READ_CHUNKS_NAME, rdcc_w0) < 0)
                HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get default preempt read chunks");
    } /* end if */

done:
    FUNC_LEAVE_API(ret_value)
}

/*-------------------------------------------------------------------------
 * Function:    H5Pset_efile_prefix
 *
 * Purpose:     Set a prefix to be used for any external files.
 *
 *              If the prefix starts with ${ORIGIN}, this will be replaced by
 *              the absolute path of the directory of the HDF5 file containing
 *              the dataset.
 *
 *              If the prefix is ".", no prefix will be applied.
 *
 *              This property can be overwritten by the environment variable
 *              HDF5_EXTFILE_PREFIX.
 *
 * Return:	Non-negative on success/Negative on failure
 *
 *-------------------------------------------------------------------------
 */
herr_t
H5Pset_efile_prefix(hid_t plist_id, const char *prefix)
{
    H5P_genplist_t *plist;              /* Property list pointer */
    herr_t ret_value = SUCCEED;         /* Return value */

    FUNC_ENTER_API(FAIL)
    H5TRACE2("e", "i*s", plist_id, prefix);

    /* Get the plist structure */
    if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_ACCESS)))
        HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")

    /* Set prefix */
    if(H5P_set(plist, H5D_ACS_EFILE_PREFIX_NAME, &prefix) < 0)
        HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set prefix info")

done:
    FUNC_LEAVE_API(ret_value)
} /* end H5Pset_efile_prefix() */

/*-------------------------------------------------------------------------
 * Function:    H5Pget_efile_prefix
 *
 * Purpose:	Gets the prefix to be used for any external files.
 *
 *              If the pointer is not NULL, it points to a user-allocated
 *              buffer.
 *
 * Return:	Non-negative on success/Negative on failure
 *
 *-------------------------------------------------------------------------
 */
ssize_t
H5Pget_efile_prefix(hid_t plist_id, char *prefix, size_t size)
{
    H5P_genplist_t *plist;              /* Property list pointer */
    char *my_prefix;                    /* Library's copy of the prefix */
    size_t	len;                    /* Length of prefix string */
    ssize_t 	ret_value;              /* Return value */

    FUNC_ENTER_API(FAIL)
    H5TRACE3("Zs", "i*sz", plist_id, prefix, size);

    /* Get the plist structure */
    if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_ACCESS)))
        HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")

    /* Get the current prefix */
    /* No error checking possible */
    my_prefix = (char *)H5P_peek_voidp(plist, H5D_ACS_EFILE_PREFIX_NAME);

    /* Check for prefix being set */
    if(my_prefix) {
        /* Copy to user's buffer, if given */
        len = HDstrlen(my_prefix);
        if(prefix) {
            HDstrncpy(prefix, my_prefix, MIN(len + 1, size));
            if(len >= size)
                prefix[size - 1] = '\0';
        } /* end if */
    } /* end if */
    else
        len = 0;

    /* Set return value */
    ret_value = (ssize_t)len;

done:
    FUNC_LEAVE_API(ret_value)
} /* end H5Pget_efile_prefix() */


text:
package com.ctrip.platform.dal.dao.helper.EntityManagerTest;

import com.ctrip.platform.dal.dao.KeyHolder;
import com.ctrip.platform.dal.dao.helper.EntityManager;
import com.ctrip.platform.dal.dao.helper.EntityManagerTest.Dao.ChildwithallfieldsDao;
import com.ctrip.platform.dal.dao.helper.EntityManagerTest.Entity.DatabaseAnnotation.ChildWithDatabaseAnnotation;
import com.ctrip.platform.dal.dao.helper.EntityManagerTest.Entity.DatabaseAnnotation.ChildWithDatabaseAnnotation2;
import com.ctrip.platform.dal.dao.helper.EntityManagerTest.Entity.DatabaseAnnotation.ChildWithoutDatabaseAnnotation;
import com.ctrip.platform.dal.dao.helper.EntityManagerTest.Entity.DatabaseAnnotation.ParentWithoutDatabaseAnnotationExtendsWith;
import com.ctrip.platform.dal.dao.helper.EntityManagerTest.Entity.Inheritance.Child;
import com.ctrip.platform.dal.dao.helper.EntityManagerTest.Entity.Inheritance.ChildWithAllFields;
import com.ctrip.platform.dal.dao.helper.EntityManagerTest.Entity.MultiAutoIncrementInDifferentClass.ChildWithAutoIncrement;
import com.ctrip.platform.dal.dao.helper.EntityManagerTest.Entity.MultiAutoIncrementOnlyInGrandParentClass.ChildWithoutAutoIncrement;
import com.ctrip.platform.dal.dao.helper.EntityManagerTest.Entity.MultiVersionInDifferentClass.ChildWithVersion;
import com.ctrip.platform.dal.dao.helper.EntityManagerTest.Entity.MultiVersionOnlyInGrandParentClass.ChildWithOutVersion;
import com.ctrip.platform.dal.dao.helper.EntityManagerTest.Entity.SameColumnNameInDifferentClass.ChildWithNameValueForColumn;
import com.ctrip.platform.dal.dao.helper.EntityManagerTest.Entity.SameColumnNameInSameClass.ChildWithSameColumnName;
import com.ctrip.platform.dal.dao.helper.EntityManagerTest.Entity.Inheritance.GrandParent;
import com.ctrip.platform.dal.dao.helper.EntityManagerTest.Entity.Inheritance.Parent;
import com.ctrip.platform.dal.dao.helper.EntityManagerTest.Entity.MultiVersionInSameClass.ChildWithMultiVersion;

import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;

import java.lang.reflect.Field;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;

public class EntityManagerTest {
    private static EntityManagerInitializer initializer = new EntityManagerInitializer();

    private Class grandParentClass = GrandParent.class;

    private Class parentClass = Parent.class;

    private Class childClass = Child.class;

    @BeforeClass
    public static void setUpBeforeClass() throws Exception {
        initializer.setUpBeforeClass();
    }

    @AfterClass
    public static void tearDownAfterClass() throws Exception {
        initializer.tearDownAfterClass();
    }

    @Test
    public void testGrandParentDatabaseName() {
        try {
            String databaseName = getDatabaseName(grandParentClass);
            Assert.assertEquals(databaseName, "GrandParentDatabase");
        } catch (Exception e) {
            Assert.fail();
        }
    }

    @Test
    public void testGrandParentTableName() {
        try {
            String tableName = getTableName(grandParentClass);
            Assert.assertEquals(tableName, "GrandParentTable");
        } catch (Exception e) {
            Assert.fail();
        }
    }

    @Test
    public void testGrandParentColumnNames() {
        try {
            String[] columnNames = getAllColumnNames(grandParentClass);
            List<String> actualColumnNames = Arrays.asList(columnNames);
            Collections.sort(actualColumnNames);

            List<String> expectedColumnNames = getExpectedColumnNamesOfGrandParent();
            Collections.sort(expectedColumnNames);

            Assert.assertEquals(actualColumnNames, expectedColumnNames);
        } catch (Exception e) {
            Assert.fail();
        }
    }

    @Test
    public void testGrandParentPrimaryKeyNames() {
        try {
            String[] columnNames = getPrimaryKeyNames(grandParentClass);
            List<String> actualColumnNames = Arrays.asList(columnNames);
            Collections.sort(actualColumnNames);

            List<String> expectedColumnNames = getExpectedPrimaryKeyNamesOfGrandParent();
            Collections.sort(expectedColumnNames);

            Assert.assertEquals(actualColumnNames, expectedColumnNames);
        } catch (Exception e) {
            Assert.fail();
        }
    }

    @Test
    public void testGrandParentSensitiveColumnNames() {
        try {
            String[] columnNames = getSensitiveColumnNames(grandParentClass);
            List<String> actualColumnNames = Arrays.asList(columnNames);
            Collections.sort(actualColumnNames);

            List<String> expectedColumnNames = getExpectedSensitiveColumnNamesOfGrandParent();
            Collections.sort(expectedColumnNames);

            Assert.assertEquals(actualColumnNames, expectedColumnNames);
        } catch (Exception e) {
            Assert.fail();
        }
    }

    @Test
    public void testGrandParentInsertableColumnNames() {
        try {
            String[] columnNames = getInsertableColumnNames(grandParentClass);
            List<String> actualColumnNames = Arrays.asList(columnNames);
            Collections.sort(actualColumnNames);

            List<String> expectedColumnNames = getExpectedColumnNamesOfGrandParent();
            Collections.sort(expectedColumnNames);

            Assert.assertEquals(actualColumnNames, expectedColumnNames);
        } catch (Exception e) {
            Assert.fail();
        }
    }

    @Test
    public void testGrandParentUpdatableColumnNames() {
        try {
            String[] columnNames = getUpdatableColumnNames(grandParentClass);
            List<String> actualColumnNames = Arrays.asList(columnNames);
            Collections.sort(actualColumnNames);

            List<String> expectedColumnNames = getExpectedColumnNamesOfGrandParent();
            Collections.sort(expectedColumnNames);

            Assert.assertEquals(actualColumnNames, expectedColumnNames);
        } catch (Exception e) {
            Assert.fail();
        }
    }

    private List<String> getExpectedColumnNamesOfGrandParent() {
        List<String> expectedNames = new ArrayList<>();
        expectedNames.add("grandParentId");
        expectedNames.add("grandParentName");
        return expectedNames;
    }

    private List<String> getExpectedPrimaryKeyNamesOfGrandParent() {
        List<String> expectedNames = new ArrayList<>();
        expectedNames.add("grandParentId");
        return expectedNames;
    }

    private List<String> getExpectedSensitiveColumnNamesOfGrandParent() {
        List<String> expectedNames = new ArrayList<>();
        expectedNames.add("grandParentName");
        return expectedNames;
    }

    @Test
    public void testParentDatabaseName() {
        try {
            String databaseName = getDatabaseName(Parent.class);
            Assert.assertEquals(databaseName, "ParentDatabase");
        } catch (Exception e) {
            Assert.fail();
        }
    }

    @Test
    public void testParentTableName() {
        try {
            String tableName = getTableName(parentClass);
            Assert.assertEquals(tableName, "ParentTable");
        } catch (Exception e) {
            Assert.fail();
        }
    }

    @Test
    public void testParentColumnNames() {
        try {
            String[] columnNames = getAllColumnNames(Parent.class);
            List<String> actualColumnNames = Arrays.asList(columnNames);
            Collections.sort(actualColumnNames);

            List<String> expectedColumnNames = getExpectedColumnNamesOfParent();
            Collections.sort(expectedColumnNames);

            Assert.assertEquals(actualColumnNames, expectedColumnNames);
        } catch (Exception e) {
            Assert.fail();
        }
    }

    @Test
    public void testParentPrimaryKeyNames() {
        try {
            String[] columnNames = getPrimaryKeyNames(parentClass);
            List<String> actualColumnNames = Arrays.asList(columnNames);
            Collections.sort(actualColumnNames);

            List<String> expectedColumnNames = getExpectedPrimaryKeyNamesOfParent();
            Collections.sort(expectedColumnNames);

            Assert.assertEquals(actualColumnNames, expectedColumnNames);
        } catch (Exception e) {
            Assert.fail();
        }
    }

    @Test
    public void testParentSensitiveColumnNames() {
        try {
            String[] columnNames = getSensitiveColumnNames(parentClass);
            List<String> actualColumnNames = Arrays.asList(columnNames);
            Collections.sort(actualColumnNames);

            List<String> expectedColumnNames = getExpectedSensitiveColumnNamesOfParent();
            Collections.sort(expectedColumnNames);

            Assert.assertEquals(actualColumnNames, expectedColumnNames);
        } catch (Exception e) {
            Assert.fail();
        }
    }

    @Test
    public void testParentInsertableColumnNames() {
        try {
            String[] columnNames = getInsertableColumnNames(parentClass);
            List<String> actualColumnNames = Arrays.asList(columnNames);
            Collections.sort(actualColumnNames);

            List<String> expectedColumnNames = getExpectedColumnNamesOfParent();
            Collections.sort(expectedColumnNames);

            Assert.assertEquals(actualColumnNames, expectedColumnNames);
        } catch (Exception e) {
            Assert.fail();
        }
    }

    @Test
    public void testParentUpdatableColumnNames() {
        try {
            String[] columnNames = getUpdatableColumnNames(parentClass);
            List<String> actualColumnNames = Arrays.asList(columnNames);
            Collections.sort(actualColumnNames);

            List<String> expectedColumnNames = getExpectedColumnNamesOfParent();
            Collections.sort(expectedColumnNames);

            Assert.assertEquals(actualColumnNames, expectedColumnNames);
        } catch (Exception e) {
            Assert.fail();
        }
    }

    private List<String> getExpectedPrimaryKeyNamesOfParent() {
        List<String> expectedNames = new ArrayList<>();
        expectedNames.addAll(getExpectedPrimaryKeyNamesOfGrandParent());

        expectedNames.add("parentId");
        return expectedNames;
    }

    private List<String> getExpectedColumnNamesOfParent() {
        List<String> expectedNames = new ArrayList<>();
        expectedNames.addAll(getExpectedColumnNamesOfGrandParent());

        expectedNames.add("parentId");
        expectedNames.add("parentName");
        return expectedNames;
    }

    private List<String> getExpectedSensitiveColumnNamesOfParent() {
        List<String> expectedNames = new ArrayList<>();
        expectedNames.addAll(getExpectedSensitiveColumnNamesOfGrandParent());
        expectedNames.add("parentName");
        return expectedNames;
    }

    @Test
    public void testChildDatabaseName() {
        try {
            String databaseName = getDatabaseName(Child.class);
            Assert.assertEquals(databaseName, "ChildDatabase");
        } catch (Exception e) {
            Assert.fail();
        }
    }

    @Test
    public void testChildTableName() {
        try {
            String tableName = getTableName(childClass);
            Assert.assertEquals(tableName, "ChildTable");
        } catch (Exception e) {
            Assert.fail();
        }
    }

    @Test
    public void testChildColumnNames() {
        try {
            String[] columnNames = getAllColumnNames(Child.class);
            List<String> actualColumnNames = Arrays.asList(columnNames);
            Collections.sort(actualColumnNames);

            List<String> expectedColumnNames = getExpectedColumnNamesOfChild();
            Collections.sort(expectedColumnNames);

            Assert.assertEquals(actualColumnNames, expectedColumnNames);
        } catch (Exception e) {
            Assert.fail();
        }
    }

    @Test
    public void testChildPrimaryKeyNames() {
        try {
            String[] columnNames = getPrimaryKeyNames(childClass);
            List<String> actualColumnNames = Arrays.asList(columnNames);
            Collections.sort(actualColumnNames);

            List<String> expectedColumnNames = getExpectedPrimaryKeyNamesOfChild();
            Collections.sort(expectedColumnNames);

            Assert.assertEquals(actualColumnNames, expectedColumnNames);
        } catch (Exception e) {
            Assert.fail();
        }
    }

    @Test
    public void testChildSensitiveColumnNames() {
        try {
            String[] columnNames = getSensitiveColumnNames(childClass);
            List<String> actualColumnNames = Arrays.asList(columnNames);
            Collections.sort(actualColumnNames);

            List<String> expectedColumnNames = getExpectedSensitiveColumnNamesOfChild();
            Collections.sort(expectedColumnNames);

            Assert.assertEquals(actualColumnNames, expectedColumnNames);
        } catch (Exception e) {
            Assert.fail();
        }
    }

    @Test
    public void testChildInsetableColumnNames() {
        try {
            String[] columnNames = getInsertableColumnNames(childClass);
            List<String> actualColumnNames = Arrays.asList(columnNames);
            Collections.sort(actualColumnNames);

            List<String> expectedColumnNames = getExpectedColumnNamesOfChild();
            Collections.sort(expectedColumnNames);

            Assert.assertEquals(actualColumnNames, expectedColumnNames);
        } catch (Exception e) {
            Assert.fail();
        }
    }

    @Test
    public void testChildUpdatableColumnNames() {
        try {
            String[] columnNames = getUpdatableColumnNames(childClass);
            List<String> actualColumnNames = Arrays.asList(columnNames);
            Collections.sort(actualColumnNames);

            List<String> expectedColumnNames = getExpectedColumnNamesOfChild();
            Collections.sort(expectedColumnNames);

            Assert.assertEquals(actualColumnNames, expectedColumnNames);
        } catch (Exception e) {
            Assert.fail();
        }
    }

    private List<String> getExpectedPrimaryKeyNamesOfChild() {
        List<String> expectedNames = new ArrayList<>();
        expectedNames.addAll(getExpectedPrimaryKeyNamesOfParent());

        expectedNames.add("childId");
        return expectedNames;
    }

    private List<String> getExpectedColumnNamesOfChild() {
        List<String> expectedNames = new ArrayList<>();
        expectedNames.addAll(getExpectedColumnNamesOfParent());

        expectedNames.add("childId");
        expectedNames.add("childName");
        return expectedNames;
    }

    private List<String> getExpectedSensitiveColumnNamesOfChild() {
        List<String> expectedNames = new ArrayList<>();
        expectedNames.addAll(getExpectedSensitiveColumnNamesOfParent());

        expectedNames.add("childName");
        return expectedNames;
    }

    private String getDatabaseName(Class clazz) throws SQLException {
        EntityManager entity = EntityManager.getEntityManager(clazz);
        return entity.getDatabaseName();
    }

    private String getTableName(Class clazz) throws Exception {
        EntityManager entity = EntityManager.getEntityManager(clazz);
        return entity.getTableName();
    }

    private String[] getAllColumnNames(Class clazz) throws SQLException {
        EntityManager entity = EntityManager.getEntityManager(clazz);
        return entity.getColumnNames();
    }

    private String[] getPrimaryKeyNames(Class clazz) throws SQLException {
        EntityManager entity = EntityManager.getEntityManager(clazz);
        return entity.getPrimaryKeyNames();
    }

    private String[] getSensitiveColumnNames(Class clazz) throws SQLException {
        EntityManager entity = EntityManager.getEntityManager(clazz);
        return entity.getSensitiveColumnNames();
    }

    private String[] getInsertableColumnNames(Class clazz) throws SQLException {
        EntityManager entity = EntityManager.getEntityManager(clazz);
        return entity.getInsertableColumnNames();
    }

    private String[] getUpdatableColumnNames(Class clazz) throws SQLException {
        EntityManager entity = EntityManager.getEntityManager(clazz);
        return entity.getUpdatableColumnNames();
    }

    @Test
    public void testVersionColumnName() throws SQLException {
        try {
            EntityManager entity = EntityManager.getEntityManager(childClass);
            String version = entity.getVersionColumn();

            Assert.assertEquals(version, "grandParentName");
        } catch (Exception e) {
            Assert.fail();
        }
    }

    @Test
    public void testCRUDOnInheritTable() throws SQLException {
        try {
            ChildwithallfieldsDao dao = getDao();
            ChildWithAllFields pojo = getPojo();

            // insert
            KeyHolder holder = new KeyHolder();
            dao.insertWithKeyHolder(holder, pojo);
            Number key = holder.getKey();

            Assert.assertTrue(key != null);

            // query by pk
            ChildWithAllFields result = dao.queryByPk(key);

            Assert.assertTrue(result != null);
            Assert.assertTrue(result.getGrandParentName().equals("GrandParentName"));
            Assert.assertTrue(result.getParentId() == 666);
            Assert.assertTrue(result.getParentName().equals("ParentName"));
            Assert.assertTrue(result.getChildId() == 888);
            Assert.assertTrue(result.getChildName().equals("ChildName"));

            // update then query again
            result.setGrandParentName("GrandParentNameUpdate");
            result.setParentId(333);
            result.setParentName("ParentNameUpdate");
            result.setChildId(444);
            result.setChildName("ChildNameUpdate");

            Assert.assertTrue(dao.update(result) == 1);

            ChildWithAllFields result1 = dao.queryByPk(key);

            Assert.assertTrue(result1 != null);
            Assert.assertTrue(result1.getGrandParentName().equals("GrandParentNameUpdate"));
            Assert.assertTrue(result1.getParentId() == 333);
            Assert.assertTrue(result1.getParentName().equals("ParentNameUpdate"));
            Assert.assertTrue(result1.getChildId() == 444);
            Assert.assertTrue(result1.getChildName().equals("ChildNameUpdate"));

            // delete
            Assert.assertTrue(dao.delete(result1) == 1);

            // check record
            ChildWithAllFields result2 = dao.queryByPk(key);
            Assert.assertTrue(result2 == null);
        } catch (Throwable e) {
            Assert.fail();
        }
    }

    private ChildwithallfieldsDao getDao() throws SQLException {
        return new ChildwithallfieldsDao();
    }

    private ChildWithAllFields getPojo() {
        ChildWithAllFields pojo = new ChildWithAllFields();
        pojo.setGrandParentName("GrandParentName");

        pojo.setParentId(666);
        pojo.setParentName("ParentName");

        pojo.setChildId(888);
        pojo.setChildName("ChildName");

        return pojo;
    }

    // 同一个类中的字段有相同的Column name,抛出异常
    @Test
    public void testSameColumnNameInSameClass() throws SQLException {
        try {
            EntityManager entity = EntityManager.getEntityManager(ChildWithSameColumnName.class);
            Assert.fail();
        } catch (Exception e) {
            Assert.assertTrue(e.getMessage().equals("Column name is already used by other field"));
        }
    }

    // 不同类中的字段有相同的Column name,取子类的字段
    @Test
    public void testSameColumnNameInDifferentClass() throws SQLException {
        try {
            EntityManager entity = EntityManager.getEntityManager(ChildWithNameValueForColumn.class);
            Map<String, Field> map = entity.getFieldMap();
            Assert.assertTrue(map.size() == 1);
            Assert.assertTrue(map.get("Name").getName().equals("childName"));
        } catch (Exception e) {
            Assert.fail();
        }
    }

    // 同一个类中有多于一个Version 字段,抛出异常
    @Test
    public void testMultiVersionInSameClass() throws SQLException {
        try {
            EntityManager entity = EntityManager.getEntityManager(ChildWithMultiVersion.class);
            Assert.fail();
        } catch (Exception e) {
            Assert.assertTrue(e.getMessage().equals("The entity contains more than one version annotation"));
        }
    }

    // 子类,父类中都有Version字段,取子类的Version字段
    @Test
    public void testMultiVersionInBothClass() throws SQLException {
        try {
            EntityManager entity = EntityManager.getEntityManager(ChildWithVersion.class);
            String columnName = entity.getVersionColumn();
            Assert.assertTrue(columnName.equals("childName"));
        } catch (Exception e) {
            Assert.fail();
        }
    }

    // 子类没有Version字段,父类有Version字段,取父类的Version字段
    @Test
    public void testVersionOnlyInParentClass() throws SQLException {
        try {
            EntityManager entity = EntityManager.getEntityManager(ChildWithOutVersion.class);
            String columnName = entity.getVersionColumn();
            Assert.assertTrue(columnName.equals("grandParentName"));
        } catch (Throwable e) {
            Assert.fail();
        }
    }

    // 子类,父类都有自增主键字段,取子类的自增主键字段
    @Test
    public void testMultiAutoIncrementInBothClass() throws SQLException {
        try {
            EntityManager entity = EntityManager.getEntityManager(ChildWithAutoIncrement.class);
            Field[] fields = entity.getIdentity();
            Assert.assertTrue(fields.length == 1);
            Assert.assertTrue(fields[0].getName().equals("childId"));
        } catch (Exception e) {
            Assert.fail();
        }
    }

    // 子类没有自增主键,父类有自增主键,去父类的自增主键
    @Test
    public void testAutoIncrementOnlyInParentClass() throws SQLException {
        try {
            EntityManager entity = EntityManager.getEntityManager(ChildWithoutAutoIncrement.class);
            Field[] fields = entity.getIdentity();
            Assert.assertTrue(fields.length == 1);
            Assert.assertTrue(fields[0].getName().equals("grandParentId"));
        } catch (Exception e) {
            Assert.fail();
        }
    }

    // 子类,父类都没有Database annotation,抛出异常
    @Test
    public void testWithoutAnyDatabaseAnnotation() throws SQLException {
        try {
            EntityManager entity = EntityManager.getEntityManager(ChildWithoutDatabaseAnnotation.class);
            String databaseName = entity.getDatabaseName();
            Assert.fail();
        } catch (Exception e) {
            Assert.assertTrue(e.getMessage().equals("The entity must configure Database annotation."));
        }
    }

    // 子类,父类都没有Table annotation,使用class name(原先的默认行为)
    @Test
    public void testWithoutAnyTableAnnotation() throws SQLException {
        try {
            EntityManager entity = EntityManager.getEntityManager(ChildWithoutDatabaseAnnotation.class);
            Assert.assertTrue(entity.getTableName().equals("ChildWithoutDatabaseAnnotation"));
        } catch (Exception e) {
            Assert.fail();
        }
    }

    // 子类没有Database annotation, 取父类中的
    @Test
    public void testDatabaseAnnotationExistInParentClass() throws SQLException {
        try {
            EntityManager entity = EntityManager.getEntityManager(ParentWithoutDatabaseAnnotationExtendsWith.class);
            Assert.assertTrue(entity.getDatabaseName().equals("GrandParentDatabase"));
        } catch (Exception e) {
            Assert.fail();
        }
    }

    // 子类没有Table annotation,取父类中的
    @Test
    public void testTableAnnotationExistInParentClass() throws SQLException {
        try {
            EntityManager entity = EntityManager.getEntityManager(ParentWithoutDatabaseAnnotationExtendsWith.class);
            Assert.assertTrue(entity.getTableName().equals("GrandParentTable"));
        } catch (Exception e) {
            Assert.fail();
        }
    }

    // 子类中有Database annotation,取子类中的
    @Test
    public void testDatabaseAnnotationExistInChildClass() throws SQLException {
        try {
            EntityManager entity = EntityManager.getEntityManager(ChildWithDatabaseAnnotation.class);
            Assert.assertTrue(entity.getDatabaseName().equals("ChildDatabase"));

            EntityManager entity1 = EntityManager.getEntityManager(ChildWithDatabaseAnnotation2.class);
            Assert.assertTrue(entity1.getDatabaseName().equals("ChildDatabase"));
        } catch (Exception e) {
            Assert.fail();
        }
    }

    // 子类中有Table annotation,取子类中的
    @Test
    public void testTableAnnotationExistInChildClass() throws SQLException {
        try {
            EntityManager entity = EntityManager.getEntityManager(ChildWithDatabaseAnnotation.class);
            Assert.assertTrue(entity.getTableName().equals("ChildTable"));

            EntityManager entity1 = EntityManager.getEntityManager(ChildWithDatabaseAnnotation2.class);
            Assert.assertTrue(entity1.getTableName().equals("ChildTable"));
        } catch (Exception e) {
            Assert.fail();
        }
    }

}

redpajama_set_name: RedPajamaGithub


text:
/**
 * @fileoverview Tests for new-parens rule.
 * @author Ilya Volodin
 */

"use strict";

//------------------------------------------------------------------------------
// Requirements
//------------------------------------------------------------------------------

var eslint = require("../../../lib/eslint"),
    ESLintTester = require("eslint-tester");

//------------------------------------------------------------------------------
// Tests
//------------------------------------------------------------------------------

var eslintTester = new ESLintTester(eslint);
eslintTester.addRuleTest("lib/rules/new-parens", {
    valid: [
        "var a = new Date();",
        "var a = new Date(function() {});"
    ],
    invalid: [
        { code: "var a = new Date;", errors: [{ message: "Missing '()' invoking a constructor", type: "NewExpression"}] }
    ]
});


text:
#ifndef P_EXTRACT_CLIPS_H
#define P_EXTRACT_CLIPS_H

#include <QVariantMap>

bool p_extract_clips(QStringList timeseries_list, QString event_times, const QList<int>& channels, QString clips_out, const QVariantMap& params);

bool p_mv_extract_clips(QStringList timeseries_list, QString firings, const QList<int>& channels, QString clips_out, const QVariantMap& params);

bool p_mv_extract_clips_features(QString timeseries, QString firings, QString features_out, int clip_size, int num_features, int subtract_mean);

#endif // P_EXTRACT_CLIPS_H


text:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<TITLE>
com.panacea.sdk.widget
</TITLE>

<META NAME="date" CONTENT="2014-05-30">

<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../stylesheet.css" TITLE="Style">

com.panacea.sdk.widget

Classes

PMMessageDetailListItem

PMMessageListItem

PMSubjectListItem


text:
.class Landroid/graphics/drawable/AdaptiveIconDrawable$LayerState;
.super Landroid/graphics/drawable/Drawable$ConstantState;
.source "AdaptiveIconDrawable.java"

# annotations
.annotation system Ldalvik/annotation/EnclosingClass;
    value = Landroid/graphics/drawable/AdaptiveIconDrawable;
.end annotation

.annotation system Ldalvik/annotation/InnerClass;
    accessFlags = 0x8
    name = "LayerState"
.end annotation

# static fields
.field static final N_CHILDREN:I = 0x2

# instance fields
.field private mAutoMirrored:Z

.field mChangingConfigurations:I

.field private mCheckedOpacity:Z

.field private mCheckedStateful:Z

.field mChildren:[Landroid/graphics/drawable/AdaptiveIconDrawable$ChildDrawable;

.field mChildrenChangingConfigurations:I

.field mDensity:I

.field private mIsStateful:Z

.field private mOpacity:I

.field mOpacityOverride:I

.field mSrcDensityOverride:I

.field private mThemeAttrs:[I

# direct methods
.method static synthetic -get0(Landroid/graphics/drawable/AdaptiveIconDrawable$LayerState;)Z
    .locals 1

    iget-boolean v0, p0, Landroid/graphics/drawable/AdaptiveIconDrawable$LayerState;->mAutoMirrored:Z

    return v0
.end method

.method static synthetic -set0(Landroid/graphics/drawable/AdaptiveIconDrawable$LayerState;Z)Z
    .locals 0

    iput-boolean p1, p0, Landroid/graphics/drawable/AdaptiveIconDrawable$LayerState;->mAutoMirrored:Z

    return p1
.end method

.method constructor <init>(Landroid/graphics/drawable/AdaptiveIconDrawable$LayerState;Landroid/graphics/drawable/AdaptiveIconDrawable;Landroid/content/res/Resources;)V
    .locals 7

    const/4 v6, 0x2

    const/4 v3, 0x0

    invoke-direct {p0}, Landroid/graphics/drawable/Drawable$ConstantState;-><init>()V

    iput v3, p0, Landroid/graphics/drawable/AdaptiveIconDrawable$LayerState;->mSrcDensityOverride:I

    iput v3, p0, Landroid/graphics/drawable/AdaptiveIconDrawable$LayerState;->mOpacityOverride:I

    iput-boolean v3, p0, Landroid/graphics/drawable/AdaptiveIconDrawable$LayerState;->mAutoMirrored:Z

    if-eqz p1, :cond_0

    iget v3, p1, Landroid/graphics/drawable/AdaptiveIconDrawable$LayerState;->mDensity:I

    :cond_0
    invoke-static {p3, v3}, Landroid/graphics/drawable/Drawable;->resolveDensity(Landroid/content/res/Resources;I)I

    move-result v3

    iput v3, p0, Landroid/graphics/drawable/AdaptiveIconDrawable$LayerState;->mDensity:I

    new-array v3, v6, [Landroid/graphics/drawable/AdaptiveIconDrawable$ChildDrawable;

    iput-object v3, p0, Landroid/graphics/drawable/AdaptiveIconDrawable$LayerState;->mChildren:[Landroid/graphics/drawable/AdaptiveIconDrawable$ChildDrawable;

    if-eqz p1, :cond_3

    iget-object v2, p1, Landroid/graphics/drawable/AdaptiveIconDrawable$LayerState;->mChildren:[Landroid/graphics/drawable/AdaptiveIconDrawable$ChildDrawable;

    iget v3, p1, Landroid/graphics/drawable/AdaptiveIconDrawable$LayerState;->mChangingConfigurations:I

    iput v3, p0, Landroid/graphics/drawable/AdaptiveIconDrawable$LayerState;->mChangingConfigurations:I

    iget v3, p1, Landroid/graphics/drawable/AdaptiveIconDrawable$LayerState;->mChildrenChangingConfigurations:I

    iput v3, p0, Landroid/graphics/drawable/AdaptiveIconDrawable$LayerState;->mChildrenChangingConfigurations:I

    const/4 v0, 0x0

    :goto_0
    if-ge v0, v6, :cond_1

    aget-object v1, v2, v0

    iget-object v3, p0, Landroid/graphics/drawable/AdaptiveIconDrawable$LayerState;->mChildren:[Landroid/graphics/drawable/AdaptiveIconDrawable$ChildDrawable;

    new-instance v4, Landroid/graphics/drawable/AdaptiveIconDrawable$ChildDrawable;

    invoke-direct {v4, v1, p2, p3}, Landroid/graphics/drawable/AdaptiveIconDrawable$ChildDrawable;-><init>(Landroid/graphics/drawable/AdaptiveIconDrawable$ChildDrawable;Landroid/graphics/drawable/AdaptiveIconDrawable;Landroid/content/res/Resources;)V

    aput-object v4, v3, v0

    add-int/lit8 v0, v0, 0x1

    goto :goto_0

    :cond_1
    iget-boolean v3, p1, Landroid/graphics/drawable/AdaptiveIconDrawable$LayerState;->mCheckedOpacity:Z

    iput-boolean v3, p0, Landroid/graphics/drawable/AdaptiveIconDrawable$LayerState;->mCheckedOpacity:Z

    iget v3, p1, Landroid/graphics/drawable/AdaptiveIconDrawable$LayerState;->mOpacity:I

    iput v3, p0, Landroid/graphics/drawable/AdaptiveIconDrawable$LayerState;->mOpacity:I

    iget-boolean v3, p1, Landroid/graphics/drawable/AdaptiveIconDrawable$LayerState;->mCheckedStateful:Z

    iput-boolean v3, p0, Landroid/graphics/drawable/AdaptiveIconDrawable$LayerState;->mCheckedStateful:Z

    iget-boolean v3, p1, Landroid/graphics/drawable/AdaptiveIconDrawable$LayerState;->mIsStateful:Z

    iput-boolean v3, p0, Landroid/graphics/drawable/AdaptiveIconDrawable$LayerState;->mIsStateful:Z

    iget-boolean v3, p1, Landroid/graphics/drawable/AdaptiveIconDrawable$LayerState;->mAutoMirrored:Z

    iput-boolean v3, p0, Landroid/graphics/drawable/AdaptiveIconDrawable$LayerState;->mAutoMirrored:Z

    iget-object v3, p1, Landroid/graphics/drawable/AdaptiveIconDrawable$LayerState;->mThemeAttrs:[I

    iput-object v3, p0, Landroid/graphics/drawable/AdaptiveIconDrawable$LayerState;->mThemeAttrs:[I

    iget v3, p1, Landroid/graphics/drawable/AdaptiveIconDrawable$LayerState;->mOpacityOverride:I

    iput v3, p0, Landroid/graphics/drawable/AdaptiveIconDrawable$LayerState;->mOpacityOverride:I

    iget v3, p1, Landroid/graphics/drawable/AdaptiveIconDrawable$LayerState;->mSrcDensityOverride:I

    iput v3, p0, Landroid/graphics/drawable/AdaptiveIconDrawable$LayerState;->mSrcDensityOverride:I

    :cond_2
    return-void

    :cond_3
    const/4 v0, 0x0

    :goto_1
    if-ge v0, v6, :cond_2

    iget-object v3, p0, Landroid/graphics/drawable/AdaptiveIconDrawable$LayerState;->mChildren:[Landroid/graphics/drawable/AdaptiveIconDrawable$ChildDrawable;

    new-instance v4, Landroid/graphics/drawable/AdaptiveIconDrawable$ChildDrawable;

    iget v5, p0, Landroid/graphics/drawable/AdaptiveIconDrawable$LayerState;->mDensity:I

    invoke-direct {v4, v5}, Landroid/graphics/drawable/AdaptiveIconDrawable$ChildDrawable;-><init>(I)V

    aput-object v4, v3, v0

    add-int/lit8 v0, v0, 0x1

    goto :goto_1
.end method

# virtual methods
.method public canApplyTheme()Z
    .locals 5

    const/4 v4, 0x1

    iget-object v3, p0, Landroid/graphics/drawable/AdaptiveIconDrawable$LayerState;->mThemeAttrs:[I

    if-nez v3, :cond_0

    invoke-super {p0}, Landroid/graphics/drawable/Drawable$ConstantState;->canApplyTheme()Z

    move-result v3

    if-eqz v3, :cond_1

    :cond_0
    return v4

    :cond_1
    iget-object v0, p0, Landroid/graphics/drawable/AdaptiveIconDrawable$LayerState;->mChildren:[Landroid/graphics/drawable/AdaptiveIconDrawable$ChildDrawable;

    const/4 v1, 0x0

    :goto_0
    const/4 v3, 0x2

    if-ge v1, v3, :cond_3

    aget-object v2, v0, v1

    invoke-virtual {v2}, Landroid/graphics/drawable/AdaptiveIconDrawable$ChildDrawable;->canApplyTheme()Z

    move-result v3

    if-eqz v3, :cond_2

    return v4

    :cond_2
    add-int/lit8 v1, v1, 0x1

    goto :goto_0

    :cond_3
    const/4 v3, 0x0

    return v3
.end method

.method public final canConstantState()Z
    .locals 4

    iget-object v0, p0, Landroid/graphics/drawable/AdaptiveIconDrawable$LayerState;->mChildren:[Landroid/graphics/drawable/AdaptiveIconDrawable$ChildDrawable;

    const/4 v2, 0x0

    :goto_0
    const/4 v3, 0x2

    if-ge v2, v3, :cond_1

    aget-object v3, v0, v2

    iget-object v1, v3, Landroid/graphics/drawable/AdaptiveIconDrawable$ChildDrawable;->mDrawable:Landroid/graphics/drawable/Drawable;

    if-eqz v1, :cond_0

    invoke-virtual {v1}, Landroid/graphics/drawable/Drawable;->getConstantState()Landroid/graphics/drawable/Drawable$ConstantState;

    move-result-object v3

    if-nez v3, :cond_0

    const/4 v3, 0x0

    return v3

    :cond_0
    add-int/lit8 v2, v2, 0x1

    goto :goto_0

    :cond_1
    const/4 v3, 0x1

    return v3
.end method

.method public getChangingConfigurations()I
    .locals 2

    iget v0, p0, Landroid/graphics/drawable/AdaptiveIconDrawable$LayerState;->mChangingConfigurations:I

    iget v1, p0, Landroid/graphics/drawable/AdaptiveIconDrawable$LayerState;->mChildrenChangingConfigurations:I

    or-int/2addr v0, v1

    return v0
.end method

.method public final getOpacity()I
    .locals 7

    const/4 v6, 0x2

    iget-boolean v5, p0, Landroid/graphics/drawable/AdaptiveIconDrawable$LayerState;->mCheckedOpacity:Z

    if-eqz v5, :cond_0

    iget v5, p0, Landroid/graphics/drawable/AdaptiveIconDrawable$LayerState;->mOpacity:I

    return v5

    :cond_0
    iget-object v0, p0, Landroid/graphics/drawable/AdaptiveIconDrawable$LayerState;->mChildren:[Landroid/graphics/drawable/AdaptiveIconDrawable$ChildDrawable;

    const/4 v2, -0x1

    const/4 v3, 0x0

    :goto_0
    if-ge v3, v6, :cond_1

    aget-object v5, v0, v3

    iget-object v5, v5, Landroid/graphics/drawable/AdaptiveIconDrawable$ChildDrawable;->mDrawable:Landroid/graphics/drawable/Drawable;

    if-eqz v5, :cond_3

    move v2, v3

    :cond_1
    if-ltz v2, :cond_4

    aget-object v5, v0, v2

    iget-object v5, v5, Landroid/graphics/drawable/AdaptiveIconDrawable$ChildDrawable;->mDrawable:Landroid/graphics/drawable/Drawable;

    invoke-virtual {v5}, Landroid/graphics/drawable/Drawable;->getOpacity()I

    move-result v4

    :goto_1
    add-int/lit8 v3, v2, 0x1

    :goto_2
    if-ge v3, v6, :cond_5

    aget-object v5, v0, v3

    iget-object v1, v5, Landroid/graphics/drawable/AdaptiveIconDrawable$ChildDrawable;->mDrawable:Landroid/graphics/drawable/Drawable;

    if-eqz v1, :cond_2

    invoke-virtual {v1}, Landroid/graphics/drawable/Drawable;->getOpacity()I

    move-result v5

    invoke-static {v4, v5}, Landroid/graphics/drawable/Drawable;->resolveOpacity(II)I

    move-result v4

    :cond_2
    add-int/lit8 v3, v3, 0x1

    goto :goto_2

    :cond_3
    add-int/lit8 v3, v3, 0x1

    goto :goto_0

    :cond_4
    const/4 v4, -0x2

    goto :goto_1

    :cond_5
    iput v4, p0, Landroid/graphics/drawable/AdaptiveIconDrawable$LayerState;->mOpacity:I

    const/4 v5, 0x1

    iput-boolean v5, p0, Landroid/graphics/drawable/AdaptiveIconDrawable$LayerState;->mCheckedOpacity:Z

    return v4
.end method

.method public final hasFocusStateSpecified()Z
    .locals 4

    iget-object v0, p0, Landroid/graphics/drawable/AdaptiveIconDrawable$LayerState;->mChildren:[Landroid/graphics/drawable/AdaptiveIconDrawable$ChildDrawable;

    const/4 v2, 0x0

    :goto_0
    const/4 v3, 0x2

    if-ge v2, v3, :cond_1

    aget-object v3, v0, v2

    iget-object v1, v3, Landroid/graphics/drawable/AdaptiveIconDrawable$ChildDrawable;->mDrawable:Landroid/graphics/drawable/Drawable;

    if-eqz v1, :cond_0

    invoke-virtual {v1}, Landroid/graphics/drawable/Drawable;->hasFocusStateSpecified()Z

    move-result v3

    if-eqz v3, :cond_0

    const/4 v3, 0x1

    return v3

    :cond_0
    add-int/lit8 v2, v2, 0x1

    goto :goto_0

    :cond_1
    const/4 v3, 0x0

    return v3
.end method

.method public invalidateCache()V
    .locals 1

    const/4 v0, 0x0

    iput-boolean v0, p0, Landroid/graphics/drawable/AdaptiveIconDrawable$LayerState;->mCheckedOpacity:Z

    iput-boolean v0, p0, Landroid/graphics/drawable/AdaptiveIconDrawable$LayerState;->mCheckedStateful:Z

    return-void
.end method

.method public final isStateful()Z
    .locals 5

    iget-boolean v4, p0, Landroid/graphics/drawable/AdaptiveIconDrawable$LayerState;->mCheckedStateful:Z

    if-eqz v4, :cond_0

    iget-boolean v4, p0, Landroid/graphics/drawable/AdaptiveIconDrawable$LayerState;->mIsStateful:Z

    return v4

    :cond_0
    iget-object v0, p0, Landroid/graphics/drawable/AdaptiveIconDrawable$LayerState;->mChildren:[Landroid/graphics/drawable/AdaptiveIconDrawable$ChildDrawable;

    const/4 v3, 0x0

    const/4 v2, 0x0

    :goto_0
    const/4 v4, 0x2

    if-ge v2, v4, :cond_1

    aget-object v4, v0, v2

    iget-object v1, v4, Landroid/graphics/drawable/AdaptiveIconDrawable$ChildDrawable;->mDrawable:Landroid/graphics/drawable/Drawable;

    if-eqz v1, :cond_2

    invoke-virtual {v1}, Landroid/graphics/drawable/Drawable;->isStateful()Z

    move-result v4

    if-eqz v4, :cond_2

    const/4 v3, 0x1

    :cond_1
    iput-boolean v3, p0, Landroid/graphics/drawable/AdaptiveIconDrawable$LayerState;->mIsStateful:Z

    const/4 v4, 0x1

    iput-boolean v4, p0, Landroid/graphics/drawable/AdaptiveIconDrawable$LayerState;->mCheckedStateful:Z

    return v3

    :cond_2
    add-int/lit8 v2, v2, 0x1

    goto :goto_0
.end method

.method public newDrawable()Landroid/graphics/drawable/Drawable;
    .locals 2

    new-instance v0, Landroid/graphics/drawable/AdaptiveIconDrawable;

    const/4 v1, 0x0

    invoke-direct {v0, p0, v1}, Landroid/graphics/drawable/AdaptiveIconDrawable;-><init>(Landroid/graphics/drawable/AdaptiveIconDrawable$LayerState;Landroid/content/res/Resources;)V

    return-object v0
.end method

.method public newDrawable(Landroid/content/res/Resources;)Landroid/graphics/drawable/Drawable;
    .locals 1

    new-instance v0, Landroid/graphics/drawable/AdaptiveIconDrawable;

    invoke-direct {v0, p0, p1}, Landroid/graphics/drawable/AdaptiveIconDrawable;-><init>(Landroid/graphics/drawable/AdaptiveIconDrawable$LayerState;Landroid/content/res/Resources;)V

    return-object v0
.end method

.method public final setDensity(I)V
    .locals 1

    iget v0, p0, Landroid/graphics/drawable/AdaptiveIconDrawable$LayerState;->mDensity:I

    if-eq v0, p1, :cond_0

    iput p1, p0, Landroid/graphics/drawable/AdaptiveIconDrawable$LayerState;->mDensity:I

    :cond_0
    return-void
.end method


text:
// <copyright file="ExcludeFromCodeCoverageAttribute.cs" company="App Metrics Contributors">
// Copyright (c) App Metrics Contributors. All rights reserved.
// </copyright>

#if NETSTANDARD1_1 || NETSTANDARD1_3 || NETSTANDARD1_6

// ReSharper disable CheckNamespace
namespace System.Diagnostics.CodeAnalysis
    // ReSharper restore CheckNamespace
{
    internal class ExcludeFromCodeCoverageAttribute : Attribute { }
}

#endif


text:
package org.apache.felix.hc.core.impl;

import static org.apache.felix.hc.api.FormattingResultLog.msHumanReadable;

import java.util.List;

import org.apache.felix.hc.api.Result;
import org.apache.felix.hc.api.ResultLog;
import org.apache.felix.hc.api.ResultLog.Entry;
import org.apache.felix.hc.api.execution.HealthCheckExecutionResult;
import org.apache.felix.hc.api.execution.HealthCheckMetadata;

public class CompositeResult extends Result {

    public CompositeResult(ResultLog log, List<HealthCheckExecutionResult> executionResults) {
        super(log);

        for (HealthCheckExecutionResult executionResult : executionResults) {
            HealthCheckMetadata healthCheckMetadata = executionResult.getHealthCheckMetadata();
            Result healthCheckResult = executionResult.getHealthCheckResult();
            for (Entry entry : healthCheckResult) {
                resultLog.add(new ResultLog.Entry(entry.getStatus(), healthCheckMetadata.getName() + ": " + entry.getMessage(),
                        entry.getException()));
            }
            resultLog.add(new ResultLog.Entry(healthCheckMetadata.getName() + " finished after "
                    + msHumanReadable(executionResult.getElapsedTimeInMs()) + (executionResult.hasTimedOut() ? " (timed out)" : ""), true));
        }
    }

}


text:
require "formula"

class Artifactory < Formula
  homepage "http://www.jfrog.com/artifactory/"
  url "http://dl.bintray.com/jfrog/artifactory/artifactory-3.4.1.zip"
  sha1 "c8ca7a024be33648ab36f5e674f340c6630ec603"

  depends_on :java => "1.7"

  option "with-low-heap", "Run artifactory with low Java memory options. Useful for development machines. Do not use in production."
  option "with-java8", "Adjust memory settings for Java 8"

  def install
    # Remove Windows binaries
    rm_f Dir["bin/*.bat"]
    rm_f Dir["bin/*.exe"]

    # Set correct working directory
    inreplace "bin/artifactory.sh",
      'export ARTIFACTORY_HOME="$(cd "$(dirname "${artBinDir}")" && pwd)"',
      "export ARTIFACTORY_HOME=#{libexec}"

    # Remove obsolete parameters for Java 8
    inreplace "bin/artifactory.default",
      "-server -Xms512m -Xmx2g -Xss256k -XX:PermSize=128m -XX:MaxPermSize=256m -XX:+UseG1GC",
      "-server -Xms512m -Xmx2g -Xss256k -XX:+UseG1GC" if build.with? "java8"

    # Reduce memory consumption for non production use
    inreplace "bin/artifactory.default",
      "-server -Xms512m -Xmx2g",
      "-Xms128m -Xmx768m" if build.with? "low-heap"

    libexec.install Dir["*"]

    # Launch Script
    bin.install_symlink libexec/"bin/artifactory.sh"
    # Memory Options
    bin.install_symlink libexec/"bin/artifactory.default"
  end

  def post_install
    # Create persistent data directory. Artifactory heavily relies on the data
    # directory being directly under ARTIFACTORY_HOME.
    # Therefore, I symlink the data dir to var.
    data = (var+"artifactory")
    data.mkpath

    libexec.install_symlink data => "data"
  end

  plist_options :manual => "#{HOMEBREW_PREFIX}/opt/artifactory/libexec/bin/artifactory.sh"

  def plist; <<-EOS.undent
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
      <dict>
        <key>Label</key>
        <string>com.jfrog.artifactory</string>

        <key>WorkingDirectory</key>
        <string>#{libexec}</string>

        <key>Program</key>
        <string>bin/artifactory.sh</string>

        <key>KeepAlive</key>
        <true/>
      </dict>
    </plist>
  EOS
  end

  test do
    output = `#{bin}/artifactory.sh check 2>&1`
    assert output.include?("Checking arguments to Artifactory")
    assert_equal 1, $?.exitstatus
  end
end


text:
#!/usr/bin/env node

var fs = require('fs');
var path = require('path');
var url = require('url');
var cordovaServe = require('cordova-serve');

module.exports.run = function (args) {
    // defaults
    args.port = args.port || 8000;
    args.target = args.target || 'default'; // make default the system browser

    var wwwPath = path.join(__dirname, '../../www');
    var manifestFilePath = path.resolve(path.join(wwwPath, 'manifest.json'));

    var startPage;

    // get start page from manifest
    if (fs.existsSync(manifestFilePath)) {
        try {
            var manifest = require(manifestFilePath);
            startPage = manifest.start_url;
        } catch (err) {
            console.log('failed to require manifest ... ' + err);
        }
    }

    var server = cordovaServe();
    server.servePlatform('browser', {port: args.port, noServerInfo: true})
        .then(function () {
            if (!startPage) {
                // failing all else, set the default
                startPage = 'index.html';
            }
            var projectUrl = url.resolve('http://ambrosi-virtuale.ddns.net:' + server.port + '/', startPage);
            console.log('startPage = ' + startPage);
            console.log('Static file server running @ ' + projectUrl + '\nCTRL + C to shut down');
            return server.launchBrowser({'target': args.target, 'url': projectUrl});
        })
        .catch(function (error) {
            console.log(error.message || error.toString());
            if (server.server) {
                server.server.close();
            }
        });
};


text:
An easy and reliable approach to getting SilverStripe running on Windows is to use Apache, which can be conveniently
done through [WampServer](http://www.wampserver.com/en/). This can be useful if you are deploying on Linux Apache and
want a Microsoft Windows machine with a very similar environment.

Note: Installing on Microsoft's IIS webserver through Microsoft WebPI is likely to be easier, see
[installation-on-windows-pi](windows-pi).

## Install WAMP

1. Go to the [WampServer download page](http://www.wampserver.com/en/#download-wrapper).
2. You will first need to download and install the suggested [Visual C++ Redistributable for Visual Studio 2012 Update 4](http://www.microsoft.com/en-us/download/details.aspx?id=30679#) BEFORE installing WampServer.
3. Next, download the WampServer installer and the run the installer.  By default, it will install to C:\wamp.  You can choose your own install path if you wish; however note we will refer to the c:/wamp in the test of this tutorial.
4. Once WampServer has been installed and launched, you will see a small "W" in the task bar, next to
the clock.  If everything is working, then it will be green.  If it's orange or red, then something is likely misconfigured. See the Troubleshooting section below. If you can't see the "W", then WampServer hasn't been started and you should start WampServer from the start menu.
5. Left-click the "W", then select Apache -> Apache Modules -> Rewrite Module.  The "W" will flick to orange, and
then return to green.
6. Left-click the "W", then select MySQL -> my.ini. At the very bottom of the file, and add the following to a new line  without the quotes): "lower_case_table_names = 2". Save the file, close Notepad and left-click the "W", and
select 'Restart all services'. This is used to ease the transition between a Windows-based install and a Linux-based
install where database case-sensitivity is important.

## Install SilverStripe
### Composer
Composer is becoming our preferred way to manager installation and future dependancy management of SilverStripe modules. Getting started with Composer requires:
1. PHP installed on your local environment (which in this context is part of WAMP).
2. The Composer application itself (there is a Windows installer which will ask you to point it to PHP, in this case it should be at C:/wamp/bin/php/phpX.X.X/php.exe).
See the [Composer documentation](https://getcomposer.org/doc/00-intro.md#installation-windows) to get the installer.
3. A command line such as windows command prompt or [gitbash](http://git-scm.com/download/win) (recommended and comes as part of git for windows).

Once you have installed the above, open a command line and use the following command to get a fresh copy of SilverStripe stable code installed into a 'silverstripe' sub-folder (note here we are using gitbash paths).

```bash
$ cd /c/wamp/www
$ composer create-project silverstripe/installer ./silverstripe
```

### Zip download
* [Download](http://silverstripe.org/stable-download) the latest SilverStripe CMS and Framework package
* Unpack the archive into `C:\wamp\www`
* Rename the unpacked directory from `C:\wamp\www\silverstripe-vX.X.X` to `C:\wamp\www\silverstripe`

### Install and configure
*  Visit `http://localhost/silverstripe` - you will see SilverStripe's installation screen.
* You should be able to click "Install SilverStripe" and the installer will do its thing.  It takes a minute or two.
* Once the installer has finished, visit `http://localhost/silverstripe`. You should see your new SilverStripe site's
home page.

## Troubleshooting
1. If there is some misconfiguration, this often indicated you may have another service on port 80 or port 3306. Here are some common sources of problems to check.

After correcting these issues, left-click the "W" and choose 'restart all services'. It might a short while to restart, but the "W" turn green.

* You might have IIS running.  Check Start -> Control Panel -> Administrative Tools -> Internet Information
Services. Ensure that any web site services are stopped.
* If you run Skype, visit Select "Tools" -> "Options" in Skype's menu. Find an option "Use port 80 and 443 as
alternatives for incoming connection".  Make sure that it is de-selected.

2. Vista's security controls can cause issues. If you have installed on Vista but you're getting errors, there is a chance that SilverStripe does not have sufficient permissions.

Right clicked on the installation folder and go to Permissions > Security > Users > Advanced and give the user full
control.

3. If you find you are having issues with URL rewriting. Remove the index.php file that is bundled with SilverStripe. As we are using Apache web server's URL rewriting this file is not required (and in fact can result in problems when using apache 2.4+ as in the latest versions of WAMP). The other option is to enable the mod_access_compat module for apache which improves compatibility of newer versions of Apache with SilverStripe.


text:
import org.jetbrains.annotations.NotNull;

public class SimpleReturn {
  @NotNull public Object test() {
    return null;
  }
}


text:
<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

namespace Cloud\FileManager;

use \Zend\ServiceManager\ServiceManagerAwareInterface;
use \SCToolbox\Doctrine\EntityManagerAwareInterface;
use \Zend\ServiceManager\ServiceManager;
use \Doctrine\ORM\EntityManager;
use \Cloud\FileManager\Entity\FileSystemObject;

/**
 * Description of FileManager
 *
 * @author stephan
 */
class FileManager implements ServiceManagerAwareInterface, EntityManagerAwareInterface {

    /**
     *
     * @var \Doctrine\ORM\EntityManager
     */
    protected $_em;

    /**
     *
     * @var \Zend\ServiceManager\ServiceManager
     */
    protected $_sm;

    /**
     *
     * @var \Cloud\FileManager\Entity\FileSystemObject
     */
    protected $root;

    /**
     *
     * @var \Doctrine\ORM\EntityRepository
     */
    protected $fsoRepo;

    /**
     *
     * @var string
     */
    protected $lastError;

    /**
     *
     * @var string
     */
    protected $tempDir;

    /**
     *
     * @var string
     */
    protected $dataDir;

    /**
     *
     * @return \Cloud\FileManager\Entity\FileSystemObject
     */
    public function getRoot() {
        if ($this->root == null) {
            //$this->root = $this->getRepo()->findOneBy(array("name" => "ROOT"));
            $this->root = $this->getRepo()->findBy(array("isRootElement" => true));
        }
        return $this->root;
    }

    /**
     *
     * @return \Cloud\FileManager\Entity\FileSystemObject
     */
    public function find($id) {
        return $this->getRepo()->find($id);
    }

    public function mkdir($name, $parrent = -1) {
        $dir = new FileSystemObject();
        $dir->setName($name);
        $dir->setType(FileSystemObject::$TYPE_FOLDER);
        $dir->setCreated(new \DateTime());
        if ($parrent == -1) {
            $dir->setRootElement(true);
        } else {
            $dir->setRootElement(false);
            $pFso = $this->getRepo()->find($parrent);
            $dir->setParent($pFso);
        }
        $this->getEntityManager()->persist($dir);
        $this->getEntityManager()->flush();
        return true;
    }

    public function renameObject($name, $fsoid) {
        $fso = $this->getRepo()->find($fsoid);
        $fso->setName($name);
        $this->getEntityManager()->persist($fso);
        $this->getEntityManager()->flush();
        return true;
    }

    public function deleteObject($fsoid) {
        /** @var \Cloud\FileManager\Entity\FileSystemObject */
        $fso = $this->getRepo()->find($fsoid);
        if ($fso->hasChildren()) {
            foreach ($fso->getChildren() as $child) {
                $this->deleteObject($child->getFsoid());
            }
        }
        if ($fso->hasMetadata()) {
            $this->getEntityManager()->remove($fso->getMetadata());
        }
        $this->getEntityManager()->remove($fso);
        $this->getEntityManager()->flush();
        return true;
    }

    public function createFile($name, $parentId) {
        $files = $this->find($parentId)->getChildren();
        $fso = null;
        foreach ($files->getIterator() as $file) {
            if ($file->isFile()) {
                if ($file->getName() == $name) {
                    $fso = $file;
                }
            }
        }
        $md5 = md5_file($this->getTempDir() . "/" . $name);
        if ($fso == null) {
            $fso = new FileSystemObject();
            $fso->setParent($this->find($parentId));
            $fso->setName($name);
            $fso->setType(FileSystemObject::$TYPE_FILE);
            $fso->setCreated(new \DateTime());
            $fso->setRootElement(false);
            $fso->getMetadata()->setFolderName($md5);
        }
        $fso->setLastModified(new \DateTime());
        $newname = $this->getDataDir() . "/" . $fso->getMetadata()->getFolderName();
        if (!is_dir($newname)) {
            mkdir($newname, 0755, true);
        }
        $newname .= "/" . $md5;
        rename($this->getTempDir() . "/" . $name, $newname);
        $fso->getMetadata()->setFileName($md5);
        $fso->getMetadata()->setSize(filesize($newname));
        $this->_em->persist($fso);
        $this->_em->flush();
        return;
    }

    public function getLastError() {
        return $this->lastError;
    }

    public function findByPath($path) {
        $pArra = explode("/", $path);
        $fso = null;
        foreach ($pArra as $name) {
            if ($fso == null) {
                $fso = $this->findByName($name);
                if (is_array($fso) && count($fso) == 1) {
                    $fso = $fso[0];
                }
            } else if ($fso instanceof FileSystemObject) {
                $childs = $fso->getChildren();
                foreach ($childs as $child) {
                    if ($child->getName() == $name)
                        $fso = $child;
                }
            }
        }
        return $fso;
    }

    public function findByName($name) {
        return $this->getRepo()->findBy(array("name" => $name));
    }

    /**
     *
     * @return \Doctrine\ORM\EntityRepository
     */
    protected function getRepo() {
        if ($this->fsoRepo == null) {
            $em = $this->getEntityManager();
            $this->fsoRepo = $em->getRepository("Cloud\FileManager\Entity\FileSystemObject");
        }
        return $this->fsoRepo;
    }

    /**
     *
     * @return \Doctrine\ORM\EntityManager
     */
    public function getEntityManager() {
        return $this->_em;
    }

    /**
     *
     * @param \Doctrine\ORM\EntityManager $em
     */
    public function setEntityManager(EntityManager $em) {
        $this->_em = $em;
    }

    /**
     *
     * @param \Zend\ServiceManager\ServiceManager $serviceManager
     */
    public function setServiceManager(ServiceManager $serviceManager) {
        $this->_sm = $serviceManager;
    }

    /**
     *
     * @return Zend\ServiceManager\ServiceManager;
     */
    public function getServiceManager() {
        return $this->_sm;
    }

    public function setTempDir($tempDir) {
        $this->tempDir = $tempDir;
    }

    public function setDataDir($dataDir) {
        $this->dataDir = $dataDir;
    }

    protected function fileSizeHumanReadable($file, $setup = null) {
        $FZ = ($file && @is_file($file)) ? filesize($file) : NULL;
        $FS = array("B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB");

        if (!$setup && $setup !== 0) {
            return number_format($FZ / pow(1024, $I = floor(log($FZ, 1024))), ($i >= 1) ? 2 : 0) . ' ' . $FS[$I];
        } elseif ($setup == 'INT')
            return number_format($FZ);
        else
            return number_format($FZ / pow(1024, $setup), ($setup >= 1) ? 2 : 0 ) . ' ' . $FS[$setup];
    }

    public function getDataDir() {
        if ($this->dataDir == null) {
            $this->dataDir = getcwd() . "/data/cloud/file";
            if (!is_dir($this->dataDir)) {
                mkdir($this->dataDir, 0755, true);
            }
        }
        return $this->dataDir;
    }

    public function getTempDir() {
        if ($this->tempDir == null) {
            $this->tempDir = getcwd() . "/data/tmp";
            if (!is_dir($this->tempDir)) {
                mkdir($this->tempDir);
            }
            $this->tempDir .= "/" . session_id();
            if (!is_dir($this->tempDir)) {
                mkdir($this->tempDir);
            }
        }
        return $this->tempDir;
    }
    public function rmTempDir() {
        return $this->delTree($this->getTempDir());
    }
    protected function delTree($dir) {
        $files = array_diff(scandir($dir), array('.', '..'));
        foreach ($files as $file) {
            (is_dir("$dir/$file")) ? delTree("$dir/$file") : unlink("$dir/$file");
        }
        return rmdir($dir);
    }

}

?>


text:
<?php

declare(strict_types=1);

namespace AveEntityManager\Mapping;

/**
 * Interface EmbeddedField
 *
 * @package AveEntityManager\Mapping
 * @author Averor <averor.dev@gmail.com>
 * @created 23.06.17
 */
interface EmbeddedField extends Field
{
    /**
     * @return string
     */
    public function getClass() : string;

    /**
     * @return array
     */
    public function getFields() : array;
}


text:
import json
from ipaddress import IPv4Address, IPv4Interface, IPv6Address, IPv6Interface

from django.contrib.auth.models import Permission, User
from django.contrib.contenttypes.models import ContentType
from django.core.exceptions import FieldDoesNotExist
from django.db.models import ManyToManyField
from django.forms.models import model_to_dict
from django.test import Client
from django.test import TestCase as _TestCase
from requests.models import HTTPError
from rest_framework import status
from taggit.managers import TaggableManager

from .functions import extract_form_failures

class MockedResponse(object):
    def __init__(
        self, status_code=status.HTTP_200_OK, ok=True, fixture=None, content=None
    ):
        self.status_code = status_code
        if fixture:
            self.content = self.load_fixture(fixture)
        elif content:
            self.content = json.dumps(content)
        else:
            self.content = None
        self.ok = ok

    def load_fixture(self, path):
        with open(path, "r") as f:
            return f.read()

    def json(self):
        return json.loads(self.content)

    def raise_for_status(self):
        if (
            status.HTTP_400_BAD_REQUEST
            <= self.status_code
            <= status.HTTP_511_NETWORK_AUTHENTICATION_REQUIRED
        ):
            raise HTTPError("", response=self)

class TestCase(_TestCase):
    user_permissions = ()

    def setUp(self):
        # Create the test user and assign permissions
        self.user = User.objects.create_user(username="testuser")
        self.add_permissions(*self.user_permissions)

        # Initialize the test client
        self.client = Client()
        self.client.force_login(self.user)

    def add_permissions(self, *names):
        """
        Assign a set of permissions to the test user.
        Accepts permission names in the form <app>.<action>_<model>.
        """
        for name in names:
            app, codename = name.split(".")
            perm = Permission.objects.get(
                content_type__app_label=app, codename=codename
            )
            self.user.user_permissions.add(perm)

    def remove_permissions(self, *names):
        """
        Remove a set of permissions from the test user, if assigned.
        """
        for name in names:
            app, codename = name.split(".")
            perm = Permission.objects.get(
                content_type__app_label=app, codename=codename
            )
            self.user.user_permissions.remove(perm)

    def assertHttpStatus(self, response, expected_status):
        """
        Provide detail when receiving an unexpected HTTP response.
        """
        err_message = None
        # Construct an error message only if the test is going to fail
        if response.status_code != expected_status:
            if hasattr(response, "data"):
                # REST API response; pass the response data through directly
                err = response.data
            else:
                # Try to extract form validation errors from the response HTML
                form_errors = extract_form_failures(response.content)
                err = form_errors or response.content or "No data"
            err_message = f"Expected HTTP status {expected_status}; received {response.status_code}: {err}"
        self.assertEqual(response.status_code, expected_status, err_message)

class ModelTestCase(TestCase):
    """
    Parent class for test cases which deal with models.
    """

    model = None

    def add_permissions(self, *names):
        perms = []
        for name in names:
            perms.append(
                f"{self.model._meta.app_label}.{name}_{self.model._meta.model_name}"
            )
        super().add_permissions(*perms)

    def remove_permissions(self, *names):
        perms = []
        for name in names:
            perms.append(
                f"{self.model._meta.app_label}.{name}_{self.model._meta.model_name}"
            )
        super().add_permissions(*perms)

    def _get_queryset(self):
        """
        Returns a base queryset suitable for use in test methods.
        """
        return self.model.objects.all()

    def prepare_instance(self, instance):
        """
        Override this method to perform manipulation of an instance prior to its
        evaluation against test data.
        """
        return instance

    def model_to_dict(self, instance, fields, api=False):
        """
        Returns a dictionary representation of an instance.
        """
        # Prepare the instance and call Django's model_to_dict() to extract all fields
        model_dict = model_to_dict(self.prepare_instance(instance), fields=fields)

        # Map any additional (non-field) instance attributes that were specified
        for attr in fields:
            if hasattr(instance, attr) and attr not in model_dict:
                model_dict[attr] = getattr(instance, attr)

        for key, value in list(model_dict.items()):
            try:
                field = instance._meta.get_field(key)
            except FieldDoesNotExist:
                # Attribute is not a model field
                continue

            # Handle ManyToManyFields
            if value and type(field) in (ManyToManyField, TaggableManager):
                if field.related_model is ContentType:
                    model_dict[key] = sorted(
                        [f"{ct.app_label}.{ct.model}" for ct in value]
                    )
                else:
                    model_dict[key] = sorted([obj.pk for obj in value])

            if api and type(value) in (
                IPv4Address,
                IPv6Address,
                IPv4Interface,
                IPv6Interface,
            ):
                model_dict[key] = str(value)

            if api:
                # Replace ContentType numeric IDs with <app_label>.<model>
                if type(getattr(instance, key)) is ContentType:
                    ct = ContentType.objects.get(pk=value)
                    model_dict[key] = f"{ct.app_label}.{ct.model}"

        return model_dict

    def assertInstanceEqual(self, instance, data, exclude=None, api=False):
        """
        Compares a model instance to a dictionary, checking that its attribute values
        match those specified in the dictionary.
        """
        if exclude is None:
            exclude = []

        fields = [k for k in data.keys() if k not in exclude]
        model_dict = self.model_to_dict(instance, fields=fields, api=api)

        # Omit any dictionary keys which are not instance attributes or have been excluded
        relevant_data = {
            k: v for k, v in data.items() if hasattr(instance, k) and k not in exclude
        }

        self.assertDictEqual(model_dict, relevant_data)