/*
///////////////////////////////////////////////////////////
Internal/helper methods
///////////////////////////////////////////////////////////
196070
@Override
    protected QName createQName(String nsURI, String localName) {
        return new QName(nsURI, localName);
    }
1249473
@Override
  public V putIfAbsentFailure(K key, V value, StoreAccessException e) {
    cleanup(key, e);
    return null;
  }
282467
@Override
	protected StringBuffer doPostProcessBundle(BundleProcessingStatus status, StringBuffer bundleData)
			throws IOException {

		Matcher matcher = CHARSET_DECLARATION.matcher(bundleData.toString());
		StringBuffer sb = new StringBuffer();
		String currentCharset = null;
		boolean charsetDefinedAtBegining = false;
		while (matcher.find()) {
			if (matcher.start() == 0) {
				currentCharset = matcher.group(1);
				charsetDefinedAtBegining = true;
			} else {
				if (currentCharset != null) {
					if (!currentCharset.equalsIgnoreCase(matcher.group(1))) {
						LOGGER.warn("The bundle '" + status.getCurrentBundle().getId()
								+ "' contains CSS with different charset declaration.");
					}
				} else {
					currentCharset = matcher.group(1);
					LOGGER.warn("For the bundle '" + status.getCurrentBundle().getId()
							+ "', the charset declaration is not defined at the top. The charset which will be set is '"
							+ currentCharset + "'.");
				}

				matcher.appendReplacement(sb, "");
			}
		}
		matcher.appendTail(sb);

		// Put the declaration on top
		if (currentCharset != null && !charsetDefinedAtBegining) {
			sb = new StringBuffer(
					CHARSET_DECLARATION_PREFIX + currentCharset + CHARSET_DECLARATION_SUFFIX + "\n" + sb.toString());
		}
		return sb;
	}
1210792
function(init) {
  var fulfillCallbacks = new Backlog();
  var rejectCallbacks = new Backlog();
  var value;
  var error;
  var state = "pending";

  if (underTest) {
    Object.defineProperties(this, {
      _value: _readOnlyProperty(function() { return value; }),
      _error: _readOnlyProperty(function() { return error; }),
      _state: _readOnlyProperty(function() { return state; }),
    });
  }

  Object.defineProperties(this, {
    _addAcceptCallback: _pseudoPrivate(
      function(cb) {
        // console.log("adding fulfill callback:", cb);
        fulfillCallbacks.push(cb);
        if (state == "fulfilled") {
          fulfillCallbacks.pump(value);
        }
      }
    ),
    _addRejectCallback: _pseudoPrivate(
      function(cb) {
        // console.log("adding reject callback:", cb);
        rejectCallbacks.push(cb);
        if (state == "rejected") {
          rejectCallbacks.pump(error);
        }
      }
    ),
  });
  var r = new Resolver(this,
                       fulfillCallbacks, rejectCallbacks,
                       function(v) { value = v; },
                       function(e) { error = e; },
                       function(s) { state = s; })
  try {
    if (init) { init(r); }
  } catch(e) {
    r.reject(e);
  }
}
722438
public static void main(final String[] args) throws Exception
    {
        if (args.length == 0)
        {
            System.err.format("Usage: %s <filenames>...%n", SbeTool.class.getName());
            System.exit(-1);
        }

        for (final String fileName : args)
        {
            final Ir ir;
            if (fileName.endsWith(".xml"))
            {
                final String xsdFilename = System.getProperty(SbeTool.VALIDATION_XSD);
                if (xsdFilename != null)
                {
                    validateAgainstSchema(fileName, xsdFilename);
                }

                ir = new IrGenerator().generate(parseSchema(fileName), System.getProperty(TARGET_NAMESPACE));
            }
            else if (fileName.endsWith(".sbeir"))
            {
                ir = new IrDecoder(fileName).decode();
            }
            else
            {
                System.err.println("Input file format not supported: " + fileName);
                System.exit(-1);
                return;
            }

            final String outputDirName = System.getProperty(OUTPUT_DIR, ".");
            if (Boolean.parseBoolean(System.getProperty(GENERATE_STUBS, "true")))
            {
                final String targetLanguage = System.getProperty(TARGET_LANGUAGE, "Java");

                generate(ir, outputDirName, targetLanguage);
            }

            if (Boolean.parseBoolean(System.getProperty(GENERATE_IR, "false")))
            {
                final File inputFile = new File(fileName);
                final String inputFilename = inputFile.getName();
                final int nameEnd = inputFilename.lastIndexOf('.');
                final String namePart = inputFilename.substring(0, nameEnd);
                final File fullPath = new File(outputDirName, namePart + ".sbeir");

                try (IrEncoder irEncoder = new IrEncoder(fullPath.getAbsolutePath(), ir))
                {
                    irEncoder.encode();
                }
            }
        }
    }
935708
function unhandledErrorListener(err, namespace) {
  console.error('[distribucache] (%s) error from an unhandled ' +
    '`error` event:\n', namespace, err && err.stack || err);
}
913510
private void init(JSONTokener x) {
		if (x.nextClean() != '[') {
			throw x.syntaxError("A JSONArray text must start with '['");
		}
		if (x.nextClean() != ']') {
			x.back();
			for (;;) {
				if (x.nextClean() == ',') {
					x.back();
					this.rawList.add(JSONNull.NULL);
				} else {
					x.back();
					this.rawList.add(x.nextValue());
				}
				switch (x.nextClean()) {
				case ',':
					if (x.nextClean() == ']') {
						return;
					}
					x.back();
					break;
				case ']':
					return;
				default:
					throw x.syntaxError("Expected a ',' or ']'");
				}
			}
		}
	}
127920
public void setHelp(String appVersion, String usageExample) {

		helpAppVersion = StringUtils.trimToNull(appVersion);
		helpAppExample = StringUtils.trimToNull(usageExample);
	}
621687
@SuppressWarnings({"unchecked", "rawtypes"})
    @Override
    protected void initWorkplaceRequestValues(CmsWorkplaceSettings settings, HttpServletRequest request) {

        super.initWorkplaceRequestValues(settings, request);
        Map dialogMap = (Map)getDialogObject();
        if (dialogMap != null) {
            dialogMap.put(PARAM_SEARCH_PARAMS, m_searchParams);
            dialogMap.put(PARAM_SEARCH_OBJECT, m_search);
        }
    }
1280089
function (mode, code, tokens, flags, scope, parseMode) {
    var index = code.index,
        length = code.length;

    if ( /* <!-- */
        code.codePointAt(index) === 0x003c &&
        code.codePointAt(++index) === 0x0021 &&
        code.codePointAt(++index) === 0x002d &&
        code.codePointAt(++index) === 0x002d
    ) {
        index++;

        for (; index < length; index++) {
            if ( /* --> */
                code.codePointAt(index) === 0x002d &&
                code.codePointAt(index + 1) === 0x002d &&
                code.codePointAt(index + 2) === 0x003e
            ) {
                index += 3;
                code.index = index;

                return true;
            }
        }

        throw code.makeError(
            code.index, code.index + 4,
            'Unclosed Comment: Expected "-->" to fallow "<!--".'
        );
    }

    return null;
}
175690
@Override
    public void contextInitialized(ServletContextEvent evt) {
        File usersDir = new File(SetupOptions.getBaseConfigDirectory(), "users");
        if (!usersDir.isDirectory()) {
            return;
        }
        DocumentBuilder domBuilder = null;
        try {
            domBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
        } catch (ParserConfigurationException e) {
            LOGR.warning(e.getMessage());
            return;
        }
        DOMImplementationLS lsFactory = buildDOM3LoadAndSaveFactory();
        LSSerializer serializer = lsFactory.createLSSerializer();
        serializer.getDomConfig().setParameter(Constants.DOM_XMLDECL, Boolean.FALSE);
        serializer.getDomConfig().setParameter(Constants.DOM_FORMAT_PRETTY_PRINT, Boolean.TRUE);
        LSOutput output = lsFactory.createLSOutput();
        output.setEncoding("UTF-8");
        for (File userDir : usersDir.listFiles()) {
            File userFile = new File(userDir, "user.xml");
            if (!userFile.isFile()) {
                continue;
            }
            try {
                Document doc = domBuilder.parse(userFile);
                Node pwNode = doc.getElementsByTagName("password").item(0);
                if (null == pwNode) {
                    continue;
                }
                String password = pwNode.getTextContent();
                if (password.split(":").length == 5) {
                    break;
                }
                pwNode.setTextContent(PasswordStorage.createHash(password));
                // overwrite contents of file
                // Fortify Mod: Make sure that the output stream is closed
                // output.setByteStream(new FileOutputStream(userFile, false));
                FileOutputStream os = new FileOutputStream(userFile, false);
                output.setByteStream(os);
                serializer.write(doc, output);
                os.close();
            } catch (Exception e) {
                LOGR.info(e.getMessage());
                continue;
            }
        }
    }
126459
void initInputsByIdMap() {
    inputsById.clear();
    for (CompilerInput input : externs) {
      InputId id = input.getInputId();
      CompilerInput previous = putCompilerInput(id, input);
      if (previous != null) {
        report(JSError.make(DUPLICATE_EXTERN_INPUT, input.getName()));
      }
    }
    for (CompilerInput input : moduleGraph.getAllInputs()) {
      InputId id = input.getInputId();
      CompilerInput previous = putCompilerInput(id, input);
      if (previous != null) {
        report(JSError.make(DUPLICATE_INPUT, input.getName()));
      }
    }
  }
1029195
function(options)
{
    if ('undefined' === typeof options) {
        throw new Error('No options defined');
    }

    this.path    = options.path || null;
    this.default = options.default || {};
    this.values  = options.values || {};

    if (options.default && options.values) {
        this.merge(options.values);
    }

    if (this.path) {
        this.load();
    }
}
368085
public static void main(final String... args) throws Exception {

        final StorageConfiguration config = new StorageConfiguration(new File(args[0]));
        Storage.createStorage(config);
        final IStorage storage = Storage.openStorage(new File(args[0]));

        Injector injector =
            Guice.createInjector(new ModuleSetter().setDataFacClass(TreeNodeFactory.class).setMetaFacClass(
                NodeMetaPageFactory.class).createModule());
        IBackendFactory backend = injector.getInstance(IBackendFactory.class);
        IRevisioning revision = injector.getInstance(IRevisioning.class);
        Properties props = new Properties();
        props.setProperty(ConstructorProps.STORAGEPATH, storage.getLocation().getAbsolutePath());
        props.setProperty(ConstructorProps.RESOURCE, "shredded");
        storage.createResource(new ResourceConfiguration(props, backend, revision, new TreeNodeFactory(),
            new NodeMetaPageFactory()));
        final ISession session =
            storage.getSession(new SessionConfiguration("shredded", StandardSettings.KEY));

        final DefaultHandler defHandler = new DefaultHandler();

        final SAXSerializer serializer = new SAXSerializer(session, defHandler);
        serializer.call();

        session.close();
    }
362265
function init(o){
	
	opts.outputPath = dfault( o.outputPath, opts.outputPath );

	opts.consoleOutput = dfault(o.consoleOutput, opts.consoleOutput );
	opts.consoleOutputLevel = dfault(o.consoleOutputLevel, opts.consoleOutputLevel );
	
	opts.fileOutput = dfault(o.fileOutput, opts.fileOutput);
	opts.fileOutputLevel= dfault(o.fileOutputLevel, opts.fileOutputLevel);
	
	opts.dateTimeFormat = dfault(o.dateTimeFormat, opts.dateTimeFormat );
	opts.fileNamePrefix = dfault(o.fileNamePrefix, opts.fileNamePrefix );
	opts.fileNameSuffix = dfault(o.fileNameSuffix, opts.fileNameSuffix );
	opts.fileNameDateFormat = dfault(o.fileNameDateFormat, opts.fileNameDateFormat  );
	
	opts.verbose = dfault(o.verbose, opts.verbose ); // verbose option is currently useless
	opts.customIntro = dfault(o.customIntro, opts.customIntro );
	
	if(typeof opts.customIntro ==='function') 
		opts.customIntro(require('../../package.json')); 
	else if(opts.customIntro != null &&  opts.customIntro != false);
		//introduce(require('../../package.json'));

	opts.filename = opts.outputPath + opts.fileNamePrefix + now().format(opts.fileNameDateFormat) + opts.fileNameSuffix +".log";

	whenTheDayEnds(); /** recursive function that calls itself on each new day, use it for your conveninience */
	
    mkdirSync(opts.outputPath);
	initialized =true;
	return self;
}
476781
@Override
    int command_inout_asynch_i(final String c, final boolean fgt, final boolean fwd, final int rid) throws DevFailed {
	synchronized (this) {
	    final Iterator it = elements.iterator();
	    while (it.hasNext()) {
		final GroupElement e = (GroupElement) it.next();
		if (e instanceof GroupDeviceElement || fwd) {
		    e.command_inout_asynch_i(c, fgt, fwd, rid);
		}
	    }
	    return rid;
	}
    }
617225
public void setHandler(String contextId, Runnable action) {

        if (contextId != null) {
            m_createFunctions.put(contextId, action);
        }
    }