/*
Helper methods
544205
@SuppressWarnings("unchecked")
    protected MessageListener createCaseEventReceiver() {
        try {
            Class<MessageListener> caseEventReceiverClass = (Class<MessageListener>) Class.forName("org.jbpm.casemgmt.impl.jms.AsyncCaseInstanceAuditEventReceiver");
            
            return caseEventReceiverClass.getConstructor(EntityManagerFactory.class).newInstance(entityManagerFactory);
        } catch (Exception e) {
            logger.debug("No message listener found for case instance event receiver", e);
            
            return null;
        }
    }
1246583
public static Iterable<String> getParameterNames (HttpServletRequest req)
    {
        List<String> params = new ArrayList<String>();
        Enumeration<?> iter = req.getParameterNames();
        while (iter.hasMoreElements()) {
            params.add((String)iter.nextElement());
        }
        return params;
    }
196430
private ModelAndView buildBizErrors(BindException be, ModelAndView mvc) {
        Map<String, Object> paramErrors = new HashMap<String, Object>();
        Object o = be.getTarget();
        for (Object error : be.getAllErrors()) {
            if (error instanceof FieldError) {
                FieldError fe = (FieldError) error;
                String field = fe.getField();
                Field oField = null;
                try {
                    oField = o.getClass().getField(field);
                } catch (NoSuchFieldException e) {
                    // TODO: omit handle exception
                }
                if (oField == null) {
                    paramErrors.put(field, GlobalResponseStatusMsg.PARAM_BIND_ERROR.getMessage()
                            .getMessage());
                } else if (oField.getType().equals(Integer.class)
                        || oField.getType().equals(Long.class)
                        || oField.getType().equals(Short.class)) {
                    paramErrors.put(field, GlobalResponseStatusMsg.PARAM_BIND_ERROR.getMessage()
                            .getMessage());
                } else if (oField.getType().equals(Float.class)
                        || oField.getType().equals(Double.class)) {
                    paramErrors.put(field, GlobalResponseStatusMsg.PARAM_BIND_ERROR.getMessage()
                            .getMessage());
                } else {
                    paramErrors.put(field, GlobalResponseStatusMsg.PARAM_BIND_ERROR.getMessage()
                            .getMessage());
                }
            }
        }

        return buildBizError(mvc, paramErrors);
    }
525578
function( key /* or array */, callback ) {
            var me = this;
            if ( this.isArray( key ) ) {
                var values = [];
                for ( var i = 0, il = key.length; i < il; i++ ) {
                    me.get( key[i], function( result ) {
                        if ( result ) values.push( result );
                        if ( values.length === il && callback ) {
                            me.lambda( callback ).call( me, values );
                        }
                    });
                }
            } else {
                var error = function(e) { fail( e ); if ( callback ) me.lambda( callback ).call( me ); };
                root( this, function( store ) {
                    store.getFile( key, {create:false}, function( entry ) {
                        entry.file(function( file ) {
                            var reader = new FileReader();

                            reader.onerror = error;

                            reader.onload = function(e) {
                                if ( callback ) me.lambda( callback ).call( me, JSON.parse( e.target.result ) );
                            };

                            reader.readAsText( file );
                        }, error );
                    }, error );
                });
            }
            return this;
        }
292864
function (req, controller) {
        var parameters = [];
        if (controller.conditions && controller.conditions.parameters && controller.conditions.parameters.header) {
            parameters.push(_checkValues(req.headers, controller.conditions.parameters.header, "header"))
        }

        if (controller.conditions && controller.conditions.parameters && controller.conditions.parameters.query) {
            parameters.push(_checkValues(req.query, controller.conditions.parameters.query, "query"))
        }

        if (controller.conditions && controller.conditions.parameters && controller.conditions.parameters.body) {
            parameters.push(_checkValues(req.body, controller.conditions.parameters.body, "body"))
        }

        if (controller.conditions && controller.conditions.parameters && controller.conditions.parameters.path) {
            parameters.push(_checkValues(req.params, controller.conditions.parameters.path, "path"))
        }

        return Q.all(parameters).then(function (results) {
            var validatedData = [];
            var errors = [];
            results.forEach(function (result) {
                if (result.data) {
                    if (!validatedData[result.type]) {
                        validatedData[result.type] = {};
                    }
                    validatedData[result.type] = result.data;
                }

                // Collect validation errors
                if (result.err && result.err.err && result.err.name == "ValidationError") {
                    var resultErrors = result.err.err;
                    resultErrors.forEach(function (error) {
                        error.in = result.type;
                        errors.push(error);
                    });
                }
            });

            return Q({
                validatedData: {
                    name: controller.name,
                    version: controller.version,
                    method: controller.method,
                    function: controller.function,
                    data: validatedData
                },
                errors: errors
            });
        });
    }
1154428
public String[] getAttributes(String key) {
        if (token != null)
            return token.getAttributes(key);
        else
            return null;
    }
51111
@Override
  public int[] columns(String[] names) {
    int[] idxs = new int[_strs.length];
    for (int i = 0; i < _strs.length; i++) {
      int idx = idxs[i] = water.util.ArrayUtils.find(names, _strs[i]);
      if (idx == -1) throw new IllegalArgumentException("Column " + _strs[i] + " not found");
    }
    return idxs;
  }
897726
private static void fillReqAndRes(ServletRequest req, ServletResponse res){
		//-- 填充请求和响应对象到ActionContext本地线程
		Request.init((HttpServletRequest)req);
		Response.init((HttpServletResponse)res);
	}
1006943
@Override
    public void init(NamedList args) {

        Object regex = args.remove(PARAM_REGEX);
        if (null == regex) {
            throw new SolrException(ErrorCode.SERVER_ERROR, "Missing required init parameter: " + PARAM_REGEX);
        }
        try {
            m_regex = Pattern.compile(regex.toString());
        } catch (PatternSyntaxException e) {
            throw new SolrException(ErrorCode.SERVER_ERROR, "Invalid regex: " + regex, e);
        }

        Object replacement = args.remove(PARAM_REPLACEMENT);
        if (null == replacement) {
            throw new SolrException(ErrorCode.SERVER_ERROR, "Missing required init parameter: " + PARAM_REPLACEMENT);
        }
        m_replacement = replacement.toString();

        Object source = args.remove(PARAM_SOURCE);
        if (null == source) {
            throw new SolrException(ErrorCode.SERVER_ERROR, "Missing required init parameter: " + PARAM_SOURCE);
        }
        m_source = source.toString();

        Object target = args.remove(PARAM_TARGET);
        if (null == target) {
            throw new SolrException(ErrorCode.SERVER_ERROR, "Missing required init parameter: " + PARAM_TARGET);
        }
        m_target = target.toString();

    }
171270
private static void generateSQLBuild(SQLiteModelMethod method, MethodSpec.Builder methodBuilder, SplittedSql splittedSql, boolean countQuery) {
		methodBuilder.addStatement("$T _sqlBuilder=sqlBuilder()", StringBuilder.class);
		methodBuilder.addStatement("_sqlBuilder.append($S)", splittedSql.sqlBasic.trim());

		SqlModifyBuilder.generateInitForDynamicWhereVariables(method, methodBuilder, method.dynamicWhereParameterName, method.dynamicWhereArgsParameterName);

		if (method.jql.isOrderBy()) {
			methodBuilder.addStatement("String _sortOrder=$L", method.jql.paramOrderBy);
		}

		SqlBuilderHelper.generateWhereCondition(methodBuilder, method, false);
		SqlSelectBuilder.generateDynamicPartOfQuery(method, methodBuilder, splittedSql, countQuery);
	}
132100
function transformAjvErrors(errors = []) {
  if (errors === null) {
    return [];
  }

  return errors.map(e => {
    const { dataPath, keyword, message, params, schemaPath } = e;
    let property = `${dataPath}`;

    // put data in expected format
    return {
      name: keyword,
      property,
      message,
      params, // specific to ajv
      stack: `${property} ${message}`.trim(),
      schemaPath,
    };
  });
}
1166340
@Override
    public Map<String, Object> getParameters(
            HttpServletRequest request, HttpServletResponse response) {
        final Map<String, Object> mergedParameters = new LinkedHashMap<String, Object>();

        for (final TransformerConfigurationSource source : this.sources) {
            final Map<String, Object> parameters = source.getParameters(request, response);
            if (parameters != null) {
                mergedParameters.putAll(parameters);
            }
        }

        return mergedParameters;
    }
129851
@Override
    public List<MaxOnline> buildConstraint(BtrPlaceTree t, List<BtrpOperand> args) {
        if (checkConformance(t, args)) {
          @SuppressWarnings("unchecked")
          List<Node> ns = (List<Node>) params[0].transform(this, t, args.get(0));
            if (ns == null) {
                return Collections.emptyList();
            }
            Set<Node> s = new HashSet<>(ns);
            if (s.size() != ns.size()) {                //Prevent duplicates
                return Collections.emptyList();
            }

            BtrpNumber n = (BtrpNumber) args.get(1);
            if (!n.isInteger()) {
                t.ignoreError("Parameter '" + params[1].getName() + "' expects an integer");
                return Collections.emptyList();
            }
            int v = n.getIntValue();
            if (v < 0) {
                t.ignoreError("Parameter '" + params[1].getName() + "' expects a positive integer (" + v + " given)");
                return Collections.emptyList();
            }

            return Collections.singletonList(new MaxOnline(new HashSet<>(ns), v, true));
        }
        return Collections.emptyList();
    }
220834
public void process() throws ConstraintException
    {
        ClassDescriptorDef otherClassDef;
        
        for (Iterator it = getDirectBaseTypes(); it.hasNext();)
        {
            otherClassDef = (ClassDescriptorDef)it.next();
            if (!otherClassDef.hasBeenProcessed())
            {
                otherClassDef.process();
            }
        }
        for (Iterator it = getNested(); it.hasNext();)
        {
            otherClassDef = ((NestedDef)it.next()).getNestedType();
            if (!otherClassDef.hasBeenProcessed())
            {
                otherClassDef.process();
            }
        }
        
        ArrayList               newFields      = new ArrayList();
        ArrayList               newReferences  = new ArrayList();
        ArrayList               newCollections = new ArrayList();
        FieldDescriptorDef      newFieldDef;
        ReferenceDescriptorDef  newRefDef;
        CollectionDescriptorDef newCollDef;
        
        // adding base features
        if (getBooleanProperty(PropertyHelper.OJB_PROPERTY_INCLUDE_INHERITED, true))
        {
            ArrayList baseTypes = new ArrayList();
            DefBase   featureDef;
            
            addRelevantBaseTypes(this, baseTypes);
            for (Iterator it = baseTypes.iterator(); it.hasNext();)
            {
                cloneInheritedFeatures((ClassDescriptorDef)it.next(), newFields, newReferences, newCollections);
            }

            for (Iterator it = newFields.iterator(); it.hasNext();)
            {
                newFieldDef = (FieldDescriptorDef)it.next();
                featureDef  = getFeature(newFieldDef.getName());
                if (featureDef != null)
                {    
                    if (!getBooleanProperty(PropertyHelper.OJB_PROPERTY_IGNORE, false))
                    {
                        // we have the implicit constraint that an anonymous field cannot redefine/be redefined
                        // except if it is ignored
                        if ("anonymous".equals(featureDef.getProperty(PropertyHelper.OJB_PROPERTY_ACCESS)))
                        {
                            throw new ConstraintException("The anonymous field "+featureDef.getName()+" in class "+getName()+" overrides an inherited field");
                        }
                        if ("anonymous".equals(newFieldDef.getProperty(PropertyHelper.OJB_PROPERTY_ACCESS)))
                        {
                            throw new ConstraintException("The inherited anonymous field "+newFieldDef.getName()+" is overriden in class "+getName());
                        }
                    }
                    LogHelper.warn(true, ClassDescriptorDef.class, "process", "Class "+getName()+" redefines the inherited field "+newFieldDef.getName());
                    it.remove();
                }
            }
            for (Iterator it = newReferences.iterator(); it.hasNext();)
            {
                newRefDef = (ReferenceDescriptorDef)it.next();
                if ("super".equals(newRefDef.getName()))
                {
                    // we don't inherit super-references
                    it.remove();
                }
                else if (hasFeature(newRefDef.getName()))
                {
                    LogHelper.warn(true, ClassDescriptorDef.class, "process", "Class "+getName()+" redefines the inherited reference "+newRefDef.getName());
                    it.remove();
                }
            }
            for (Iterator it = newCollections.iterator(); it.hasNext();)
            {
                newCollDef = (CollectionDescriptorDef)it.next();
                if (hasFeature(newCollDef.getName()))
                {
                    LogHelper.warn(true, ClassDescriptorDef.class, "process", "Class "+getName()+" redefines the inherited collection "+newCollDef.getName());
                    it.remove();
                }
            }
        }
        // adding nested features
        for (Iterator it = getNested(); it.hasNext();)
        {
            cloneNestedFeatures((NestedDef)it.next(), newFields, newReferences, newCollections);
        }
        _fields.addAll(0, newFields);
        _references.addAll(0, newReferences);
        _collections.addAll(0, newCollections);
        sortFields();
        _hasBeenProcessed = true;
    }
260160
private void fetchSystemAttrIds()
            throws IOException, SAXException, ParserConfigurationException {
        String url = "https://android.googlesource.com/platform/frameworks/base/+/master/core/res/res/values/public.xml";
        String html = getUrl(url);
        String xml = retrieveCode(html);

        if (xml != null) {
            parseAttributeXml(xml);
        }
    }
60390
function () {
    var tmp_0 = this.get(2,2) * this.get(3,3);
    var tmp_1 = this.get(3,2) * this.get(2,3);
    var tmp_2 = this.get(1,2) * this.get(3,3);
    var tmp_3 = this.get(3,2) * this.get(1,3);
    var tmp_4 = this.get(1,2) * this.get(2,3);
    var tmp_5 = this.get(2,2) * this.get(1,3);
    var tmp_6 = this.get(0,2) * this.get(3,3);
    var tmp_7 = this.get(3,2) * this.get(0,3);
    var tmp_8 = this.get(0,2) * this.get(2,3);
    var tmp_9 = this.get(2,2) * this.get(0,3);
    var tmp_10 = this.get(0,2) * this.get(1,3);
    var tmp_11 = this.get(1,2) * this.get(0,3);
    var tmp_12 = this.get(2,0) * this.get(3,1);
    var tmp_13 = this.get(3,0) * this.get(2,1);
    var tmp_14 = this.get(1,0) * this.get(3,1);
    var tmp_15 = this.get(3,0) * this.get(1,1);
    var tmp_16 = this.get(1,0) * this.get(2,1);
    var tmp_17 = this.get(2,0) * this.get(1,1);
    var tmp_18 = this.get(0,0) * this.get(3,1);
    var tmp_19 = this.get(3,0) * this.get(0,1);
    var tmp_20 = this.get(0,0) * this.get(2,1);
    var tmp_21 = this.get(2,0) * this.get(0,1);
    var tmp_22 = this.get(0,0) * this.get(1,1);
    var tmp_23 = this.get(1,0) * this.get(0,1);

    var t0 = ((tmp_0 * this.get(1,1) + tmp_3 * this.get(2,1) + tmp_4 * this.get(3,1)) -
              (tmp_1 * this.get(1,1) + tmp_2 * this.get(2,1) + tmp_5 * this.get(3,1)));
    var t1 = ((tmp_1 * this.get(0,1) + tmp_6 * this.get(2,1) + tmp_9 * this.get(3,1)) -
              (tmp_0 * this.get(0,1) + tmp_7 * this.get(2,1) + tmp_8 * this.get(3,1)));
    var t2 = ((tmp_2 * this.get(0,1) + tmp_7 * this.get(1,1) + tmp_10 * this.get(3,1)) -
              (tmp_3 * this.get(0,1) + tmp_6 * this.get(1,1) + tmp_11 * this.get(3,1)));
    var t3 = ((tmp_5 * this.get(0,1) + tmp_8 * this.get(1,1) + tmp_11 * this.get(2,1)) -
              (tmp_4 * this.get(0,1) + tmp_9 * this.get(1,1) + tmp_10 * this.get(2,1)));

    var d = 1.0 / (this.get(0,0) * t0 + this.get(1,0) * t1 + this.get(2,0) * t2 + this.get(3,0) * t3);

    var out_00 = d * t0;
    var out_01 = d * t1;
    var out_02 = d * t2;
    var out_03 = d * t3;

    var out_10 = d * ((tmp_1 * this.get(1,0) + tmp_2 * this.get(2,0) + tmp_5 * this.get(3,0)) -
                      (tmp_0 * this.get(1,0) + tmp_3 * this.get(2,0) + tmp_4 * this.get(3,0)));
    var out_11 = d * ((tmp_0 * this.get(0,0) + tmp_7 * this.get(2,0) + tmp_8 * this.get(3,0)) -
                      (tmp_1 * this.get(0,0) + tmp_6 * this.get(2,0) + tmp_9 * this.get(3,0)));
    var out_12 = d * ((tmp_3 * this.get(0,0) + tmp_6 * this.get(1,0) + tmp_11 * this.get(3,0)) -
                      (tmp_2 * this.get(0,0) + tmp_7 * this.get(1,0) + tmp_10 * this.get(3,0)));
    var out_13 = d * ((tmp_4 * this.get(0,0) + tmp_9 * this.get(1,0) + tmp_10 * this.get(2,0)) -
                      (tmp_5 * this.get(0,0) + tmp_8 * this.get(1,0) + tmp_11 * this.get(2,0)));

    var out_20 = d * ((tmp_12 * this.get(1,3) + tmp_15 * this.get(2,3) + tmp_16 * this.get(3,3)) -
                      (tmp_13 * this.get(1,3) + tmp_14 * this.get(2,3) + tmp_17 * this.get(3,3)));
    var out_21 = d * ((tmp_13 * this.get(0,3) + tmp_18 * this.get(2,3) + tmp_21 * this.get(3,3)) -
                      (tmp_12 * this.get(0,3) + tmp_19 * this.get(2,3) + tmp_20 * this.get(3,3)));
    var out_22 = d * ((tmp_14 * this.get(0,3) + tmp_19 * this.get(1,3) + tmp_22 * this.get(3,3)) -
                      (tmp_15 * this.get(0,3) + tmp_18 * this.get(1,3) + tmp_23 * this.get(3,3)));
    var out_23 = d * ((tmp_17 * this.get(0,3) + tmp_20 * this.get(1,3) + tmp_23 * this.get(2,3)) -
                      (tmp_16 * this.get(0,3) + tmp_21 * this.get(1,3) + tmp_22 * this.get(2,3)));
    
    var out_30 = d * ((tmp_14 * this.get(2,2) + tmp_17 * this.get(3,2) + tmp_13 * this.get(1,2)) -
                      (tmp_16 * this.get(3,2) + tmp_12 * this.get(1,2) + tmp_15 * this.get(2,2)));
    var out_31 = d * ((tmp_20 * this.get(3,2) + tmp_12 * this.get(0,2) + tmp_19 * this.get(2,2)) -
                      (tmp_18 * this.get(2,2) + tmp_21 * this.get(3,2) + tmp_13 * this.get(0,2)));
    var out_32 = d * ((tmp_18 * this.get(1,2) + tmp_23 * this.get(3,2) + tmp_15 * this.get(0,2)) -
                      (tmp_22 * this.get(3,2) + tmp_14 * this.get(0,2) + tmp_19 * this.get(1,2)));
    var out_33 = d * ((tmp_22 * this.get(2,2) + tmp_16 * this.get(0,2) + tmp_21 * this.get(1,2)) -
                      (tmp_20 * this.get(1,2) + tmp_23 * this.get(2,2) + tmp_17 * this.get(0,2)));

    this.elements[0*4+0] = out_00;
    this.elements[0*4+1] = out_01;
    this.elements[0*4+2] = out_02;
    this.elements[0*4+3] = out_03;
    this.elements[1*4+0] = out_10;
    this.elements[1*4+1] = out_11;
    this.elements[1*4+2] = out_12;
    this.elements[1*4+3] = out_13;
    this.elements[2*4+0] = out_20;
    this.elements[2*4+1] = out_21;
    this.elements[2*4+2] = out_22;
    this.elements[2*4+3] = out_23;
    this.elements[3*4+0] = out_30;
    this.elements[3*4+1] = out_31;
    this.elements[3*4+2] = out_32;
    this.elements[3*4+3] = out_33;
    return this;
  }
1111089
private ParamExistenceChecker[] compileParamExistenceChecker() {

        IfParamExists ifParamExists = method.getAnnotation(IfParamExists.class);
        //没标注IfParamExists或者标注了IfParamExists("")都认为不作检查
        if (ifParamExists == null || ifParamExists.value().trim().length() == 0) {
            return new ParamExistenceChecker[] {};
        }

        List<ParamExistenceChecker> checkers = new ArrayList<ParamExistenceChecker>(); //所有判断条件的列表
        String value = ifParamExists.value();

        //可以写多个判断条件，以这样的形式: type&subtype=value&anothername=value2
        String[] terms = StringUtils.split(value, "&");
        Assert.isTrue(terms.length >= 1); //这个应该永远成立

        //按'&'分割后，每一个term就是一个检查条件
        for (final String term : terms) {
            final int index = term.indexOf('='); //找'='
            if (index == -1) { //没有=说明只有参数名，此时term就是参数名
                checkers.add(new ParamExistenceChecker() {

                    final String paramName = term.trim();

                    @Override
                    public int check(Map<String, String[]> params) {
                        String[] paramValues = params.get(paramName);
                        if (logger.isDebugEnabled()) {
                            logger.debug(this.toString() + " is checking param:" + paramName + "="
                                    + Arrays.toString(paramValues));
                        }

                        //规则中没有约束参数值，所以只要存在就ok
                        if (paramValues != null && paramValues.length > 0) {
                            return 10;
                        } else {
                            return -1;
                        }
                    }
                });
            } else { //term中有'='

                final String paramName = term.substring(0, index).trim(); //参数名
                final String expected = term.substring(index + 1).trim(); //期望的参数值

                if (expected.startsWith(":")) { //expected是正则表达式
                    Pattern tmpPattern = null;
                    try {
                        tmpPattern = Pattern.compile(expected.substring(1));
                    } catch (PatternSyntaxException e) {
                        logger.error("@IfParamExists pattern error, " + controllerClass.getName()
                                + "#" + method.getName(), e);
                    }
                    final Pattern pattern = tmpPattern; //转成final的
                    checkers.add(new ParamExistenceChecker() {

                        @Override
                        public int check(Map<String, String[]> params) {
                            String[] paramValues = params.get(paramName);
                            if (logger.isDebugEnabled()) {
                                logger.debug(this.toString() + " is checking param:" + paramName
                                        + "=" + Arrays.toString(paramValues) + ", pattern="
                                        + pattern.pattern());
                            }
                            if (paramValues == null) { //参数值不能存在就不能通过
                                return -1;
                            }

                            for (String paramValue : paramValues) {
                                if (pattern != null && pattern.matcher(paramValue).matches()) {
                                    return 12;
                                }
                            }
                            return -1;
                        }
                    });
                } else { //expected是常量字符串，包括空串""
                    checkers.add(new ParamExistenceChecker() {

                        @Override
                        public int check(Map<String, String[]> params) {
                            String[] paramValues = params.get(paramName);
                            if (logger.isDebugEnabled()) {
                                logger.debug(this.toString() + " is checking param:" + paramName
                                        + "=" + Arrays.toString(paramValues) + ", expected="
                                        + expected);
                            }
                            if (paramValues == null) { //参数值不能存在就不能通过
                                return -1;
                            }

                            for (String paramValue : paramValues) {
                                if (expected.equals(paramValue)) {
                                    return 13;// 13优先于正则表达式的12
                                }
                            }
                            return -1;
                        }
                    });
                }
            }
        }
        return checkers.toArray(new ParamExistenceChecker[] {});
    }