/*
/////////////////////////////////////////////////////////////////////
Public API, generic StAX config methods
/////////////////////////////////////////////////////////////////////
506256
public Object getProperty(String propName)
    {
        /* Related to [WSTX-243]; would be nice to not to have to throw an
         * exception; but Stax spec suggests that we do need to indicate
         * unrecognized property by exception.
         */
        int id = findPropertyId(propName);
        if (id >= 0) {
            return getProperty(id);
        }
        id = findStdPropertyId(propName);
        if (id < 0) {
            reportUnknownProperty(propName);
            return null;
        }
        return getStdProperty(id);
    }
71418
function _fnAjaxParameters( oSettings )
		{
			var iColumns = oSettings.aoColumns.length;
			var aoData = [], mDataProp, aaSort, aDataSort;
			var i, j;
			
			aoData.push( { "name": "sEcho",          "value": oSettings.iDraw } );
			aoData.push( { "name": "iColumns",       "value": iColumns } );
			aoData.push( { "name": "sColumns",       "value": _fnColumnOrdering(oSettings) } );
			aoData.push( { "name": "iDisplayStart",  "value": oSettings._iDisplayStart } );
			aoData.push( { "name": "iDisplayLength", "value": oSettings.oFeatures.bPaginate !== false ?
				oSettings._iDisplayLength : -1 } );
				
			for ( i=0 ; i<iColumns ; i++ )
			{
			  mDataProp = oSettings.aoColumns[i].mDataProp;
				aoData.push( { "name": "mDataProp_"+i, "value": typeof(mDataProp)==="function" ? 'function' : mDataProp } );
			}
			
			/* Filtering */
			if ( oSettings.oFeatures.bFilter !== false )
			{
				aoData.push( { "name": "sSearch", "value": oSettings.oPreviousSearch.sSearch } );
				aoData.push( { "name": "bRegex",  "value": oSettings.oPreviousSearch.bRegex } );
				for ( i=0 ; i<iColumns ; i++ )
				{
					aoData.push( { "name": "sSearch_"+i,     "value": oSettings.aoPreSearchCols[i].sSearch } );
					aoData.push( { "name": "bRegex_"+i,      "value": oSettings.aoPreSearchCols[i].bRegex } );
					aoData.push( { "name": "bSearchable_"+i, "value": oSettings.aoColumns[i].bSearchable } );
				}
			}
			
			/* Sorting */
			if ( oSettings.oFeatures.bSort !== false )
			{
				var iCounter = 0;
		
				aaSort = ( oSettings.aaSortingFixed !== null ) ?
					oSettings.aaSortingFixed.concat( oSettings.aaSorting ) :
					oSettings.aaSorting.slice();
				
				for ( i=0 ; i<aaSort.length ; i++ )
				{
					aDataSort = oSettings.aoColumns[ aaSort[i][0] ].aDataSort;
					
					for ( j=0 ; j<aDataSort.length ; j++ )
					{
						aoData.push( { "name": "iSortCol_"+iCounter,  "value": aDataSort[j] } );
						aoData.push( { "name": "sSortDir_"+iCounter,  "value": aaSort[i][1] } );
						iCounter++;
					}
				}
				aoData.push( { "name": "iSortingCols",   "value": iCounter } );
				
				for ( i=0 ; i<iColumns ; i++ )
				{
					aoData.push( { "name": "bSortable_"+i,  "value": oSettings.aoColumns[i].bSortable } );
				}
			}
			
			return aoData;
		}
17398
static ConfigObject fromBasename(NameSource source, String name, ConfigParseOptions options) {
        ConfigObject obj;
        if (name.endsWith(".conf") || name.endsWith(".json") || name.endsWith(".properties")) {
            ConfigParseable p = source.nameToParseable(name, options);

            obj = p.parse(p.options().setAllowMissing(options.getAllowMissing()));
        } else {
            ConfigParseable confHandle = source.nameToParseable(name + ".conf", options);
            ConfigParseable jsonHandle = source.nameToParseable(name + ".json", options);
            ConfigParseable propsHandle = source.nameToParseable(name + ".properties", options);
            boolean gotSomething = false;
            List<ConfigException.IO> fails = new ArrayList<ConfigException.IO>();

            ConfigSyntax syntax = options.getSyntax();

            obj = SimpleConfigObject.empty(SimpleConfigOrigin.newSimple(name));
            if (syntax == null || syntax == ConfigSyntax.CONF) {
                try {
                    obj = confHandle.parse(confHandle.options().setAllowMissing(false)
                            .setSyntax(ConfigSyntax.CONF));
                    gotSomething = true;
                } catch (ConfigException.IO e) {
                    fails.add(e);
                }
            }

            if (syntax == null || syntax == ConfigSyntax.JSON) {
                try {
                    ConfigObject parsed = jsonHandle.parse(jsonHandle.options()
                            .setAllowMissing(false).setSyntax(ConfigSyntax.JSON));
                    obj = obj.withFallback(parsed);
                    gotSomething = true;
                } catch (ConfigException.IO e) {
                    fails.add(e);
                }
            }

            if (syntax == null || syntax == ConfigSyntax.PROPERTIES) {
                try {
                    ConfigObject parsed = propsHandle.parse(propsHandle.options()
                            .setAllowMissing(false).setSyntax(ConfigSyntax.PROPERTIES));
                    obj = obj.withFallback(parsed);
                    gotSomething = true;
                } catch (ConfigException.IO e) {
                    fails.add(e);
                }
            }

            if (!options.getAllowMissing() && !gotSomething) {
                if (ConfigImpl.traceLoadsEnabled()) {
                    // the individual exceptions should have been logged already
                    // with tracing enabled
                    ConfigImpl.trace("Did not find '" + name
                            + "' with any extension (.conf, .json, .properties); "
                            + "exceptions should have been logged above.");
                }

                if (fails.isEmpty()) {
                    // this should not happen
                    throw new ConfigException.BugOrBroken(
                            "should not be reached: nothing found but no exceptions thrown");
                } else {
                    StringBuilder sb = new StringBuilder();
                    for (Throwable t : fails) {
                        sb.append(t.getMessage());
                        sb.append(", ");
                    }
                    sb.setLength(sb.length() - 2);
                    throw new ConfigException.IO(SimpleConfigOrigin.newSimple(name), sb.toString(),
                            fails.get(0));
                }
            } else if (!gotSomething) {
                if (ConfigImpl.traceLoadsEnabled()) {
                    ConfigImpl.trace("Did not find '" + name
                            + "' with any extension (.conf, .json, .properties); but '" + name
                                    + "' is allowed to be missing. Exceptions from load attempts should have been logged above.");
                }
            }
        }

        return obj;
    }
858424
@Override
	public CQVariables getVariables(Bindings bindings) {
		CQVariablesImpl variables = new CQVariablesImpl();

		// Add all of the sling bindings
		SlingHttpServletRequest request = (SlingHttpServletRequest) bindings
				.get("request");
		variables.putAll(bindings);

		// Add all of the CQ stuff
		Resource resource = request.getResource();
		ResourceResolver resolver = request.getResourceResolver();
		XSSAPI xssAPI = xssApi.getRequestSpecificAPI(request);
		ComponentContext componentContext = WCMUtils
				.getComponentContext(request);
		EditContext editContext = componentContext != null ? componentContext
				.getEditContext() : null;
		ValueMap properties = ResourceUtil.getValueMap(resource);
		PageManager pageManager = (PageManager) resolver
				.adaptTo(PageManager.class);
		ValueMap pageProperties = null;
		Page currentPage = null;
		Page resourcePage = null;
		if (pageManager != null) {
			resourcePage = pageManager.getContainingPage(resource);
			currentPage = componentContext != null ? componentContext.getPage()
					: null;
			if (currentPage == null) {
				currentPage = resourcePage;
			}
			if (currentPage == null) {
				pageProperties = null;
			} else {
				pageProperties = new HierarchyNodeInheritanceValueMap(
						currentPage.getContentResource());
			}
		}
		com.day.cq.wcm.api.components.Component component = WCMUtils
				.getComponent(resource);
		Designer designer = (Designer) request.getResourceResolver().adaptTo(
				Designer.class);
		if (designer != null) {
			Design currentDesign;
			if (currentPage == null) {
				currentDesign = null;
			} else {
				String currentDesignKey = REQ_ATTR_PREFIX
						+ currentPage.getPath();
				Object cachedCurrentDesign = request
						.getAttribute(currentDesignKey);
				if (cachedCurrentDesign != null) {
					currentDesign = (Design) cachedCurrentDesign;
				} else {
					currentDesign = designer.getDesign(currentPage);
					request.setAttribute(currentDesignKey, currentDesign);
				}
			}
			Design resourceDesign;
			if (resourcePage == null) {
				resourceDesign = null;
			} else {
				String resourceDesignkey = REQ_ATTR_PREFIX
						+ resourcePage.getPath();
				Object cachedresourceDesign = request
						.getAttribute(resourceDesignkey);
				if (cachedresourceDesign != null) {
					resourceDesign = (Design) cachedresourceDesign;
				} else {
					resourceDesign = designer.getDesign(resourcePage);
					request.setAttribute(resourceDesignkey, resourceDesign);
				}
			}
			Style currentStyle = currentDesign != null
					&& componentContext != null ? currentDesign
					.getStyle(componentContext.getCell()) : null;
			variables.put(CQVariables.DESIGNER, designer);
			variables.put(CQVariables.CURRENT_DESIGN, currentDesign);
			variables.put(CQVariables.RESOURCE_DESIGN, resourceDesign);
			variables.put(CQVariables.CURRENT_STYLE, currentStyle);
		}
		variables.put(CQVariables.XSS_API, xssAPI);
		variables.put(CQVariables.COMPONENT_CONTEXT, componentContext);
		variables.put(CQVariables.EDIT_CONTEXT, editContext);
		variables.put(CQVariables.PROPERTIES, properties);
		variables.put(CQVariables.PAGE_MANAGER, pageManager);
		variables.put(CQVariables.CURRENT_PAGE, currentPage);
		variables.put(CQVariables.RESOURCE_PAGE, resourcePage);
		variables.put(CQVariables.PAGE_PROPERTIES, pageProperties);
		variables.put(CQVariables.COMPONENT, component);
		variables.put(CQVariables.SESSION, resource.getResourceResolver()
				.adaptTo(Session.class));
		return variables;
	}
937690
@Override
    public SSLContext getSSLContextInstance(final SSLConfig config) throws SSLException {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            Tr.entry(tc, "getSSLContextInstance");

        if (config == null) {
            throw new IllegalArgumentException("SSL configuration is not specified.");
        }

        // now generate a new SSLContext
        final String ctxtProvider = config.getProperty(Constants.SSLPROP_CONTEXT_PROVIDER);
        final String protocol = config.getProperty(Constants.SSLPROP_PROTOCOL);
        final String alias = config.getProperty(Constants.SSLPROP_ALIAS);
        final String configURL = config.getProperty(Constants.SSLPROP_CONFIGURL_LOADED_FROM);

        SSLContext sslContext = null;

        if (protocol == null) {
            throw new IllegalArgumentException("Protocol is not specified.");
        }

        try {
            sslContext = AccessController.doPrivileged(new PrivilegedExceptionAction<SSLContext>() {
                @Override
                public SSLContext run() throws NoSuchAlgorithmException, NoSuchProviderException {
                    if (ctxtProvider != null)
                        return SSLContext.getInstance(protocol, ctxtProvider);
                    return SSLContext.getInstance(protocol);
                }
            });
        } catch (PrivilegedActionException e) {
            Exception ex = e.getException();
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                Tr.debug(tc, "Exception occurred getting SSL context.", new Object[] { ex });

            if (ex instanceof NoSuchAlgorithmException) {
                String message = TraceNLSHelper.getInstance().getFormattedMessage("ssl.no.such.algorithm.CWPKI0028E",
                                                                                  new Object[] { protocol, alias, configURL, ex.getMessage() },
                                                                                  "CWPKI0028E: SSL handshake protocol " + protocol
                                                                                                                                                + " is not valid.  This protocol is specified in the SSL configuration alias "
                                                                                                                                                + alias
                                                                                                                                                + " loaded from SSL configuration file "
                                                                                                                                                + configURL
                                                                                                                                                + ".  The extended error message is: "
                                                                                                                                                + ex.getMessage() + ".");
                Tr.error(tc, "ssl.no.such.algorithm.CWPKI0028E",
                         new Object[] { protocol, alias, configURL, ex.getMessage() });
                throw new SSLException(message, ex);
            } else if (ex instanceof NoSuchProviderException) {
                String message = TraceNLSHelper.getInstance().getFormattedMessage("ssl.invalid.context.provider.CWPKI0029E",
                                                                                  new Object[] { Constants.IBMJSSE2_NAME, alias, configURL, ex.getMessage() },
                                                                                  "CWPKI0029E: SSL context provider " + Constants.IBMJSSE2_NAME
                                                                                                                                                               + " is not valid.  This provider is specified in the SSL configuration alias "
                                                                                                                                                               + alias
                                                                                                                                                               + " loaded from SSL configuration file "
                                                                                                                                                               + configURL
                                                                                                                                                               + ".  The extended error message is: "
                                                                                                                                                               + ex.getMessage()
                                                                                                                                                               + ".");
                Tr.error(tc, "ssl.invalid.context.provider.CWPKI0029E",
                         new Object[] { Constants.IBMJSSE2_NAME, alias, configURL, ex.getMessage() });
                throw new SSLException(message, ex);
            } else {
                throw new SSLException(ex);
            }
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            Tr.exit(tc, "getSSLContextInstance");
        return sslContext;
    }
541793
@Override
  public GeneratedCode generate(ClassTemplateSpec templateSpec) {

    String code;
    TSProperties TSProperties = globalConfig.lookupTSProperties(templateSpec);
    if (TSProperties.omit) return null;

    TSSyntax syntax = new TSSyntax(TSProperties);
    try {
      if (templateSpec instanceof RecordTemplateSpec) {
        code = engine.render("rythm-ts/record.txt", syntax.new TSRecordSyntax((RecordTemplateSpec) templateSpec));
      } else if (templateSpec instanceof EnumTemplateSpec) {
        code = engine.render("rythm-ts/enum.txt", syntax.new TSEnumSyntax((EnumTemplateSpec) templateSpec));
      } else if (templateSpec instanceof UnionTemplateSpec) {
        code = engine.render("rythm-ts/union.txt", syntax.new TSUnionSyntax((UnionTemplateSpec) templateSpec));
      } else if (templateSpec instanceof TyperefTemplateSpec) {
        TyperefTemplateSpec typerefSpec = (TyperefTemplateSpec) templateSpec;
        code = engine.render("rythm-ts/typeref.txt", syntax.TSTyperefSyntaxCreate(typerefSpec));
      } else if (templateSpec instanceof FixedTemplateSpec) {
        code = engine.render("rythm-ts/fixed.txt", syntax.TSFixedSyntaxCreate((FixedTemplateSpec) templateSpec));
      } else {
        return null; // Indicates that we are declining to generate code for the type (e.g. map or array)
      }
    } catch (RythmException e) {
      throw new RuntimeException(
        "Internal error in generator while processing " + templateSpec.getFullName(), e);
    }
    TSCompilationUnit compilationUnit =
        new TSCompilationUnit(
            templateSpec.getFullName(), "");
    code = formatter.format(code);
    return new GeneratedCode(compilationUnit, code);
  }
765746
@Override
    public LazyData createGenotypeMap(String str, List<Allele> alleles, String chr, int pos) {
        if (genotypeParts == null) {
            genotypeParts = new String[header.getColumnCount() - NUM_STANDARD_FIELDS];
        }

        int nParts = ParsingUtils.split(str, genotypeParts, VCFConstants.FIELD_SEPARATOR_CHAR);
        if (nParts != genotypeParts.length) {
            generateException("there are " + (nParts - 1)
                    + " genotypes while the header requires that " + (genotypeParts.length - 1)
                    + " genotypes be present for all records at " + chr + ":" + pos, lineNo);
        }

        ArrayList<Genotype> genotypes = new ArrayList<>(nParts);
        // get the format keys
        List<String> genotypeKeys = ParsingUtils.split(genotypeParts[0], VCFConstants.GENOTYPE_FIELD_SEPARATOR_CHAR);

        // cycle through the sample names
        Iterator<String> sampleNameIterator = header.getGenotypeSamples().iterator();

        // clear out our allele mapping
        alleleMap.clear();

        // cycle through the genotype strings
        for (int genotypeOffset = 1; genotypeOffset < nParts; genotypeOffset++) {
            List<String> genotypeValues = ParsingUtils.split(genotypeParts[genotypeOffset], VCFConstants.GENOTYPE_FIELD_SEPARATOR_CHAR);

            final String sampleName = sampleNameIterator.next();
            final GenotypeBuilder gb = new GenotypeBuilder(sampleName);

            // check to see if the value list is longer than the key list, which is a problem
            if (genotypeKeys.size() < genotypeValues.size()) {
                generateException("There are too many keys for the sample " + sampleName + ", "
                        + "keys = " + parts[8] + ", "
                        + "values = " + parts[genotypeOffset]);
            }

            int genotypeAlleleLocation = -1;
            if (!genotypeKeys.isEmpty()) {
                gb.maxAttributes(genotypeKeys.size() - 1);


                for (int i = 0; i < genotypeKeys.size(); i++) {
                    final String gtKey = genotypeKeys.get(i);
                    boolean missing = i >= genotypeValues.size();

                    // todo -- all of these on the fly parsing of the missing value should be static constants
                    if (gtKey.equals(VCFConstants.GENOTYPE_KEY)) {
                        genotypeAlleleLocation = i;
                        // opencb modification: add ALL the fields to the attributes. null for missing values!
                        gb.attribute(gtKey, genotypeValues.get(i));
                    } else if (missing) {
                        // if its truly missing (there no provided value) skip adding it to the attributes
                        // opencb modification: add ALL the fields to the attributes. null for missing values!
                        gb.attribute(gtKey, null);
                    } else if (gtKey.equals(VCFConstants.GENOTYPE_FILTER_KEY)) {
                        final List<String> filters = parseFilters(getCachedString(genotypeValues.get(i)));
                        if (filters != null) {
                            gb.filters(filters);
                        }
                        // opencb modification: add ALL the fields to the attributes. null for missing values!
                        gb.attribute(gtKey, filters);
                    } else if (genotypeValues.get(i).equals(VCFConstants.MISSING_VALUE_v4)) {
                        // don't add missing values to the map
                        // opencb modification: add ALL the fields to the attributes. null for missing values!
                        gb.attribute(gtKey, null);
                    } else {
                        if (gtKey.equals(VCFConstants.GENOTYPE_QUALITY_KEY)) {
                            if (genotypeValues.get(i).equals(VCFConstants.MISSING_GENOTYPE_QUALITY_v3)) {
                                gb.noGQ();
                            } else {
                                gb.GQ((int)Math.round(Double.valueOf(genotypeValues.get(i))));
                            }
                        } else if (gtKey.equals(VCFConstants.GENOTYPE_ALLELE_DEPTHS)) {
                            gb.AD(decodeInts(genotypeValues.get(i)));
                        } else if (gtKey.equals(VCFConstants.GENOTYPE_PL_KEY)) {
                            gb.PL(decodeInts(genotypeValues.get(i)));
                        } else if (gtKey.equals(VCFConstants.GENOTYPE_LIKELIHOODS_KEY)) {
                            gb.PL(GenotypeLikelihoods.fromGLField(genotypeValues.get(i)).getAsPLs());
                        } else if (gtKey.equals(VCFConstants.DEPTH_KEY)) {
                            gb.DP(Integer.valueOf(genotypeValues.get(i)));
                        }
                        // opencb modification: add ALL the fields to the attributes. null for missing values!
                        gb.attribute(gtKey, genotypeValues.get(i));
                    }
                }
            }

            // check to make sure we found a genotype field if our version is less than 4.1 file
            if (!version.isAtLeastAsRecentAs(VCFHeaderVersion.VCF4_1) && genotypeAlleleLocation == -1) {
                generateException("Unable to find the GT field for the record; the GT field is required before VCF4.1");
            }
            if (genotypeAlleleLocation > 0) {
                generateException("Saw GT field at position "
                        + genotypeAlleleLocation + ", but it must be at the first position for genotypes when present");
            }

            final List<Allele> gTalleles = (genotypeAlleleLocation == -1
                    ? new ArrayList<>(0)
                    : parseGenotypeAlleles(genotypeValues.get(genotypeAlleleLocation), alleles, alleleMap));
            gb.alleles(gTalleles);
            gb.phased(genotypeAlleleLocation != -1
                    && genotypeValues.get(genotypeAlleleLocation).indexOf(VCFConstants.PHASED) != -1);

            // add it to the list
            try {
                genotypes.add(gb.make());
            } catch (TribbleException e) {
                throw new TribbleException.InternalCodecException(e.getMessage() + ", at position " + chr + ":" + pos);
            }
        }

        return new LazyGenotypesContext.LazyData(genotypes, header.getSampleNamesInOrder(), header.getSampleNameToOffset());
    }
427165
private void populate(final Element subroot,
                        final Object o,
                        final Collection<Object> col,
                        final Class cl) throws Throwable {
    String name = subroot.getNodeName();

    Method meth = null;

    Class elClass = null;

    if (col == null) {
      /* We must have a setter */
      meth = findSetter(o, name);

      if (meth == null) {
        error("No setter for " + name);

        return;
      }

      /* We require a single parameter */

      Class[] parClasses = meth.getParameterTypes();
      if (parClasses.length != 1) {
        error("Invalid setter method " + name);
        throw new ConfigException("Invalid setter method " + name);
      }

      elClass = parClasses[0];
    } else {
      elClass = cl;
    }

    if (!XmlUtil.hasChildren(subroot)) {
      /* A primitive value for which we should have a setter */

      Object val = simpleValue(elClass, subroot, name);
      if (val != null) {
        assign(val, col, o, meth);
      }

      return;
    }

    /* There are children to this element. It either represents a complex type
     * or a collection.
     */

    if (Collection.class.isAssignableFrom(elClass)) {
      Collection<Object> colVal = null;

      if (elClass.getName().equals("java.util.Set")) {
        colVal = new TreeSet<Object>();
      } else if (elClass.getName().equals("java.util.List")) {
        colVal = new ArrayList<Object>();
      } else {
        error("Unsupported element class " + elClass +
              " for field " + name);
        return;
      }

      assign(colVal, col, o, meth);

      // Figure out the class of the elements
      /* I thought I might be able toextract it from the generic info -
       * Doesn't appear to be the case.
       *
      Type gft = elClass;

      if (!(gft instanceof ParameterizedType)) {
        error("Unsupported type " + elClass +
              " with name " + name);
        return;
      }

      Type[] fieldArgTypes = ((ParameterizedType)gft).getActualTypeArguments();

      if (fieldArgTypes.length != 1) {
        error("Unsupported type " + elClass +
              " with name " + name);
        return;
      }

      Class colElType = (Class)fieldArgTypes[0];
      */
      ConfInfo ci = meth.getAnnotation(ConfInfo.class);

      String colElTypeName;

      if (ci == null) {
        colElTypeName = "java.lang.String";
      } else {
        colElTypeName = ci.elementType();
      }

      for (Element el: XmlUtil.getElementsArray(subroot)) {
        populate(el, o, colVal, Class.forName(colElTypeName));
      }

      return;
    }

    /* Asssume a complex type */

    Object val = getObject(subroot, elClass);

    assign(val, col, o, meth);

    for (Element el: XmlUtil.getElementsArray(subroot)) {
      populate(el, val, null, null);
    }
  }
673372
public static StringBuilder createStackTrace(StringBuilder s, Throwable t, boolean includeCause) {
		s.append(t.getClass().getName());
		s.append(": ");
		s.append(t.getMessage());
		createStackTrace(s, t.getStackTrace());
		if (includeCause) {
			Throwable cause = t.getCause();
			if (cause != null && cause != t) {
				s.append("\nCaused by: ");
				createStackTrace(s, cause, true);
			}
		}
		return s;
	}
285305
private void doSubstitutions(NodeTraversal t, Config config, Node n) {
    if (n.isTaggedTemplateLit()) {
      // This is currently not supported, since tagged template literals have a different calling
      // convention than ordinary functions, so it's unclear which arguments are expected to be
      // replaced. Specifically, there are no direct string arguments, and for arbitrary tag
      // functions it's not clear that it's safe to inline any constant placeholders.
      compiler.report(JSError.make(n, STRING_REPLACEMENT_TAGGED_TEMPLATE));
      return;
    }
    checkState(n.isNew() || n.isCall());

    if (!config.isReplaceAll()) {
      // Note: the first child is the function, but the parameter id is 1 based.
      for (int parameter : config.parameters) {
        Node arg = n.getChildAtIndex(parameter);
        if (arg != null) {
          replaceExpression(t, arg, n);
        }
      }
    } else {
      // Replace all parameters.
      Node firstParam = n.getSecondChild();
      for (Node arg = firstParam; arg != null; arg = arg.getNext()) {
        arg = replaceExpression(t, arg, n);
      }
    }
  }
496274
@Override
    public FacesConfig getMetaInfServicesFacesConfig(ExternalContext ectx)
    {
        try
        {
            org.apache.myfaces.config.impl.digester.elements.FacesConfigImpl facesConfig
                    = new org.apache.myfaces.config.impl.digester.elements.FacesConfigImpl();
            org.apache.myfaces.config.impl.digester.elements.FactoryImpl factory
                    = new org.apache.myfaces.config.impl.digester.elements.FactoryImpl();
            
            facesConfig.addFactory(factory);
            
            for (String factoryName : FACTORY_NAMES)
            {
                List<String> classList = ServiceProviderFinderFactory.getServiceProviderFinder(ectx)
                        .getServiceProviderList(factoryName);
                
                for (String className : classList)
                {
                    if (log.isLoggable(Level.INFO))
                    {
                        log.info("Found " + factoryName + " factory implementation: " + className);
                    }

                    if (factoryName.equals(FactoryFinder.APPLICATION_FACTORY))
                    {
                        factory.addApplicationFactory(className);
                    } 
                    else if(factoryName.equals(FactoryFinder.EXCEPTION_HANDLER_FACTORY)) 
                    {
                        factory.addExceptionHandlerFactory(className);
                    } 
                    else if (factoryName.equals(FactoryFinder.EXTERNAL_CONTEXT_FACTORY))
                    {
                        factory.addExternalContextFactory(className);
                    } 
                    else if (factoryName.equals(FactoryFinder.FACES_CONTEXT_FACTORY))
                    {
                        factory.addFacesContextFactory(className);
                    } 
                    else if (factoryName.equals(FactoryFinder.LIFECYCLE_FACTORY))
                    {
                        factory.addLifecycleFactory(className);
                    } 
                    else if (factoryName.equals(FactoryFinder.RENDER_KIT_FACTORY))
                    {
                        factory.addRenderkitFactory(className);
                    } 
                    else if(factoryName.equals(FactoryFinder.TAG_HANDLER_DELEGATE_FACTORY)) 
                    {
                        factory.addTagHandlerDelegateFactory(className);
                    } 
                    else if (factoryName.equals(FactoryFinder.PARTIAL_VIEW_CONTEXT_FACTORY))
                    {
                        factory.addPartialViewContextFactory(className);
                    } 
                    else if(factoryName.equals(FactoryFinder.VISIT_CONTEXT_FACTORY)) 
                    {
                        factory.addVisitContextFactory(className);
                    } 
                    else if(factoryName.equals(FactoryFinder.VIEW_DECLARATION_LANGUAGE_FACTORY)) 
                    {
                        factory.addViewDeclarationLanguageFactory(className);
                    }
                    else if(factoryName.equals(FactoryFinder.FLASH_FACTORY)) 
                    {
                        factory.addFlashFactory(className);
                    }
                    else if(factoryName.equals(FactoryFinder.FLOW_HANDLER_FACTORY)) 
                    {
                        factory.addFlowHandlerFactory(className);
                    }
                    else if(factoryName.equals(FactoryFinder.CLIENT_WINDOW_FACTORY)) 
                    {
                        factory.addClientWindowFactory(className);
                    }
                    else if(factoryName.equals(FactoryFinder.FACELET_CACHE_FACTORY)) 
                    {
                        factory.addFaceletCacheFactory(className);
                    }
                    else
                    {
                        throw new IllegalStateException("Unexpected factory name " + factoryName);
                    }
                }
            }
            return facesConfig;
        }
        catch (Throwable e)
        {
            throw new FacesException(e);
        }
    }
284092
public final void makeTableSqlFromXml(final TableSql pTableSql,
    final Class<?> pClazz) throws Exception {
    pTableSql.setVersionAlgorithm(Integer.parseInt(this.mngSettings
      .lazClsSts(pClazz).get("versionAlgorithm")));
    pTableSql.setIdColumnsNames(this.mngSettings.lazClsSts(pClazz)
      .get("idColumnsNames").split(","));
    pTableSql.setIdFieldName(this.mngSettings.lazClsSts(pClazz)
      .get("idFieldName"));
    if (pTableSql.getIdFieldName() == null) {
      throw new ExceptionWithCode(ExceptionWithCode.CONFIGURATION_MISTAKE,
        "Where is no field ID name for class: " + pClazz.getSimpleName());
    }
    pTableSql.setOwnerFieldName(this.mngSettings.lazClsSts(pClazz)
      .get("ownerFieldName"));
    Field[] fields = getUtlReflection().retrieveFields(pClazz);
    for (Field field : fields) {
      Map<String, String> fldSts = this.mngSettings
        .lazFldSts(pClazz, field.getName());
      if (fldSts != null) {
        FieldSql fieldSql = new FieldSql();
        String definition = fldSts.get("definition");
        if (definition != null) {
          String isNullableStr = fldSts.get("isNullable");
          if (!Boolean.valueOf(isNullableStr)
            && !definition.contains("not null")) {
            definition += " not null";
          }
        }
        fieldSql.setDefinition(definition);
        pTableSql.getFieldsMap().put(field.getName(), fieldSql);
      }
    }
  }
756354
private final void parseGlobalSettings (final Element root) {

        final NodeList globalConfiguration = root.getElementsByTagName(ELEMENT_GLOBAL);

        final ResultFunctionFactory resultFunctionFactory = new ResultFunctionFactory();
        Node parameter;
        NodeList parameters;
        NamedNodeMap attributes;
        SettingEntry key;
        for (int i = 0; i < globalConfiguration.getLength(); i++) {
            parameters = globalConfiguration.item(i).getChildNodes();

            for (int j = 0; j < parameters.getLength(); j++) {
                parameter = parameters.item(j);

                if (parameter.getNodeType() == Node.ELEMENT_NODE) {
                    attributes = parameter.getAttributes();

                    key = new SettingEntry();
                    key.setScope(attributes.getNamedItem(ATTRIBUTE_SCOPE).getNodeValue());
                    key.setResult(resultFunctionFactory.create(attributes.getNamedItem(ATTRIBUTE_RESULT).getNodeValue()));
                    // key.setSender(attributes.getNamedItem(ATTRIBUTE_SENDER).getNodeValue
                    // ());
                    key.setValue(parameter.getTextContent());

                    synchronized (globalConfig) {
                        globalConfig.put(OperationalTextKey.valueOfEx(parameter.getNodeName()), key);
                    }
                }
            }
        }
    }
531597
public static GenericObjectPoolConfig standardConfig() {
    GenericObjectPoolConfig config = new GenericObjectPoolConfig();
    config.setTestOnBorrow(true);
    config.setMinIdle(0);
    config.setMaxIdle(8);
    config.setMaxTotal(8);

    config.setMinEvictableIdleTimeMillis(TimeUnit.MINUTES.toMillis(5));
    config.setTimeBetweenEvictionRunsMillis(10000);


    config.setMaxWaitMillis(10000);
    return config;
  }
1294763
private <T, U> T[] locateAll(final ClassLocator locator, final Class<T> clazz, final Consumer<T> bootstrapper) {
        Set<Class<? extends T>> set = locator.subtypeOf(clazz);
        if (!set.isEmpty()) {
            
            @SuppressWarnings("unchecked")
            T[] all =   (T[]) Array.newInstance(clazz, set.size());
            int index = 0;
            
            Iterator<Class<? extends T>> iterator = set.iterator();
            while (iterator.hasNext()) {
                Class<? extends T> c = iterator.next();
                
                try {
                    T locatedImplementation = DynamicClassFactory.createInstance(c, clazz);
                    bootstrapper.accept(locatedImplementation);
                    logger.debug("Loaded configuration from: " + c);
                    all[index++] = locatedImplementation;
                    
                } catch (IllegalArgumentException e) {
                    throw e;
                } catch (Exception e) {
                    logger.debug("Error reading custom configuration. Going with built in defaults. The error was: " + getCauseMessage(e));
                }
            }
            return all;
        } else {
            logger.debug("Did not find custom configuration for {}. Going with built in defaults ", clazz);
        }
        return null;
    }
536136
@Override
    public void init(org.apache.commons.configuration.Configuration phoneNumberProvisioningConfiguration,
            org.apache.commons.configuration.Configuration telestaxProxyConfiguration, ContainerConfiguration
            containerConfiguration) {
        this.containerConfiguration = containerConfiguration;
        telestaxProxyEnabled = telestaxProxyConfiguration.getBoolean("enabled", false);
        if (telestaxProxyEnabled) {
            uri = telestaxProxyConfiguration.getString("uri");
            username = telestaxProxyConfiguration.getString("login");
            password = telestaxProxyConfiguration.getString("password");
            accountId = telestaxProxyConfiguration.getString("endpoint");
            siteId = telestaxProxyConfiguration.getString("siteId");
            activeConfiguration = telestaxProxyConfiguration;
        } else {
            Configuration bandwidthConfiguration = phoneNumberProvisioningConfiguration.subset("bandwidth");
            uri = bandwidthConfiguration.getString("uri");
            username = bandwidthConfiguration.getString("username");
            password = bandwidthConfiguration.getString("password");
            accountId = bandwidthConfiguration.getString("accountId");
            siteId = bandwidthConfiguration.getString("siteId");
            activeConfiguration = bandwidthConfiguration;
        }
        httpClient = new DefaultHttpClient();
        Credentials credentials = new UsernamePasswordCredentials(username, password);
        httpClient.getCredentialsProvider().setCredentials(AuthScope.ANY, credentials);
    }
289929
function (tplCtxt, cfg, options) {
            var binding, bindings, id, type;

            /**
             * Array of objects which are either a section (recognizable through its _type property = TYPE_SECTION) or
             * the following structure: {_type: TYPE_BEHAVIOR, behavior: behavior, id: id }
             * @protected
             * @type Array
             */
            this._content = [];

            /**
             * Section which contains this section, or null if this section has no parent (either it has not been
             * included in the template section tree yet, or it is the root of a template section tree)
             * @type aria.templates.Section
             */
            this.parent = null;

            /**
             * The following variable is set to true when init has been done.
             * @protected
             * @type Boolean
             */
            this._initWidgetsDone = false;

            /**
             * HTML content of the section. Maybe null for subsections.
             * @type String
             */
            this.html = null;

            /**
             * List of bindings done for this section
             * @protected
             * @type Array
             */
            this._bindings = [];

            /**
             * Binding between processing indicator and this section
             * @protected
             * @type Object
             */
            this._processing = null;

            /**
             * Overlay id, in case a processing indicator is linked to this section.
             * @protected
             * @type String
             */
            this._overlayId = null;

            /**
             * Array of delegateIds
             * @type Array
             */
            this.delegateIds = [];

            /**
             * Configuration has gone OK
             * @type Boolean
             */
            this.cfgOk = true;

            /**
             * Template context of this section
             * @type aria.templates.TemplateCtxt
             */
            this.tplCtxt = tplCtxt;

            /**
             * List of callback for on statements in this section
             * @type Array
             */
            this.delegateCallbacks = [];

            /**
             * Specificies that this section is a root section (content of a template, without name of id)
             * @type Boolean
             */
            this.isRoot = (options && options.isRoot === true);

            /**
             * Id map of the section. It is only present on root sections and on sections which have been added to the
             * root section. Sub-sections reuse the idMap of their parent section.
             * @type Object
             */
            this.idMap = (options && options.ownIdMap) ? {} : null;

            /**
             * The widget configuration, as declared in the template.
             * @protected
             * @type Object
             */
            this._cfg = cfg;

            this._normalizeCallbacks();

            /**
             * Id for event delegation (used for keyboard navigation and events specified in section configuration)
             * @type String
             */
            this.delegateId = ariaUtilsDelegate.add({
                fn : this._onDomEvent,
                scope : this
            });

            // stop here for root context
            if (this.isRoot) {
                return;
            }

            // normalize configuration
            this.cfgOk = ariaCoreJsonValidator.validateCfg("aria.templates.CfgBeans." + this.$class + "Cfg", cfg, {
                msg : this.INVALID_CONFIGURATION,
                params : [this.tplCtxt.tplClasspath, cfg.id]
            });
            if (!this.cfgOk) {
                return;
            }

            type = cfg.type;
            bindings = cfg.bindRefreshTo;
            id = cfg.id;

            var domId;
            if (id) {
                if (!regexpForId.test(id)) {
                    this.$logError(this.INVALID_SECTION_ID, [this.tplCtxt.tplClasspath, id]);
                    this.cfgOk = false;
                    return;
                }

                if (id.indexOf('+') > -1) {
                    if (Aria.testMode) {
                        domId = this.tplCtxt.$getAutoId(id);
                    }
                    // From the application's point of view, an id with a '+' inside it is equivalent to no id at all.
                    // We only use the id with a '+' inside it to generate the id used in the DOM
                    delete cfg.id;
                    id = null;
                }

            }

            /**
             * DOM type for this section
             * @type String
             */
            this.domType = type;

            /**
             * Specify the DomId for the section
             * @type String
             */
            this._domId = domId || (id ? this.tplCtxt.$getId(id) : this._createDynamicId());

            /**
             * Id of the section
             * @type String
             */
            this.id = id || "_gen_" + this._domId;

            /**
             * Whether waiAria should be activated or not
             * @type Boolean
             */
            this.waiAria = cfg.waiAria;

            /**
             * When waiAria is activated and processingLabel is defined, specifies the interval at which this label is read
             * @type Number
             */
            this.waiAriaProcessingLabelReadInterval = cfg.waiAriaProcessingLabelReadInterval;

            /**
            When waiAria is activated and processingLabel is defined, specifies if this label should be read once first (without having to wait for the first interval occurrence).
             * @type Boolean
             */
            this.waiAriaProcessingLabelReadOnceFirst = cfg.waiAriaProcessingLabelReadOnceFirst;

            /**
             * Configuration for keyboard shortcuts
             * @type Object
             */
            this.keyMap = cfg.keyMap;

            /**
             * Configuration for table navigation
             * @type Object
             */
            this.tableNav = cfg.tableNav;

            /**
             * Processing label of this section
             * @type String
             */
            this.processingLabel = cfg.processingLabel;

            /**
             * Don't change the processing indicator. Flag to avoid updating the datamodel more than once
             * @type Boolean
             * @private
             */
            this.__skipProcessingChange = false;

            /**
             * Macro to use when refreshing the section.
             * @type aria.templates.CfgBeans:MacroCfg
             */
            this.macro = cfg.macro ? tplCtxt.checkMacro(cfg.macro) : null;

            /**
             * SectionWrapper object
             * @type aria.templates.SectionWrapper
             */
            this.wrapper = null;

            // register binding on this section
            for (var i = 0; binding = bindings[i]; i++) {
                this.registerBinding(binding, this._notifyDataChange);
            }

            // register binding to the processing indicator
            this.registerProcessing(cfg.bindProcessingTo);

            /**
             * TODOC
             * @type Object
             * @protected
             */
            this._refreshMgrInfo = null;

            /**
             * Html attributes of the section
             * @type aria.templates.CfgBeans:HtmlAttribute
             */
            this.attributes = cfg.attributes;

            /**
             * Attributes binding configuration
             * @type aria.templates.CfgBeans:BindingConfiguration
             */
            this._attributesBinding = null;

            /**
             * Listener added to the data model bound to the section attributes
             * @type aria.core.CfgBeans:Callback
             */
            this._attributesChangeListener = null;

            // register binding for attributes
            var attributeBind = (cfg.bind && cfg.bind.attributes) ? cfg.bind.attributes : null;
            this._attributesBinding = attributeBind;
            if (attributeBind) {
                this.attributes = this.__json.copy(attributeBind.inside[attributeBind.to]);
                this._attributesChangeListener = this.registerBinding(attributeBind, this._notifyAttributeChange);
            }

            // register binding for animation
            var animationBind = (cfg.bind && cfg.bind.animation) ? cfg.bind.animation : null;
            if (animationBind) {
                cfg.animation = animationBind.inside[animationBind.to];
                this._animationChangeListener = this.registerBinding(animationBind,this._notifyAnimationChange);
            }

        }