/*
///////////////////////////////////////////////////
Internal methods, loading input data
///////////////////////////////////////////////////
178017
protected boolean ensureLoaded(int minimum)
        throws IOException
    {
        /* Let's assume here buffer has enough room -- this will always
         * be true for the limited used this method gets
         */
        int gotten = (mInputEnd - mInputPtr);
        while (gotten < minimum) {
            int count = (mIn == null) ? -1 : mIn.read(mByteBuffer, mInputEnd, mByteBuffer.length - mInputEnd);
            if (count < 1) {
                return false;
            }
            mInputEnd += count;
            gotten += count;
        }
        return true;
    }
180874
@Override
    public void readExternal(ObjectInput input) throws IOException, ClassNotFoundException {

        // recreate the local header storage
        int len = input.readInt();
        if (SERIALIZATION_V2 == len) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "Deserializing a V2 object");
            }
            this.deserializationVersion = SERIALIZATION_V2;
            len = input.readInt();
        }
        this.storage = new HashMap<Integer, HeaderElement>();

        // now read all of the headers
        int number = input.readInt();
        if (SERIALIZATION_V2 == this.deserializationVersion) {
            // this is the new format
            for (int i = 0; i < number; i++) {
                appendHeader(readByteArray(input), readByteArray(input));
            }
        } else {
            // this is the old format
            for (int i = 0; i < number; i++) {
                appendHeader((String) input.readObject(), (String) input.readObject());
            }
        }
    }
644354
@SuppressWarnings("unchecked")  // Generic array assignment
  public void readFields(DataInput in) throws IOException {
    int card = WritableUtils.readVInt(in);
    if (splits == null || splits.length != card) {
      splits = new InputSplit[card];
    }
    Class<? extends InputSplit>[] cls = new Class[card];
    try {
      for (int i = 0; i < card; ++i) {
        cls[i] =
          Class.forName(Text.readString(in)).asSubclass(InputSplit.class);
      }
      for (int i = 0; i < card; ++i) {
        splits[i] = ReflectionUtils.newInstance(cls[i], null);
        splits[i].readFields(in);
      }
    } catch (ClassNotFoundException e) {
      throw (IOException)new IOException("Failed split init").initCause(e);
    }
  }
1034323
@SuppressWarnings("unchecked")
	private void initInputReaders() throws Exception {
		int numGates = 0;
		//  ---------------- create the input readers ---------------------
		// in case where a logical input unions multiple physical inputs, create a union reader
		final int groupSize = this.config.getGroupSize(0);
		numGates += groupSize;
		if (groupSize == 1) {
			// non-union case
			inputReader = new MutableRecordReader<DeserializationDelegate<IT>>(
					getEnvironment().getInputGate(0),
					getEnvironment().getTaskManagerInfo().getTmpDirectories());
		} else if (groupSize > 1){
			// union case
			inputReader = new MutableRecordReader<IOReadableWritable>(
					new UnionInputGate(getEnvironment().getAllInputGates()),
					getEnvironment().getTaskManagerInfo().getTmpDirectories());
		} else {
			throw new Exception("Illegal input group size in task configuration: " + groupSize);
		}
		
		this.inputTypeSerializerFactory = this.config.getInputSerializer(0, getUserCodeClassLoader());
		@SuppressWarnings({ "rawtypes" })
		final MutableObjectIterator<?> iter = new ReaderIterator(inputReader, this.inputTypeSerializerFactory.getSerializer());
		this.reader = (MutableObjectIterator<IT>)iter;

		// final sanity check
		if (numGates != this.config.getNumInputs()) {
			throw new Exception("Illegal configuration: Number of input gates and group sizes are not consistent.");
		}
	}
400498
public void readData(DataInput din) throws IOException {
        // skip all following bytes
        int length = getDataLength();
        for (int i = 0; i < length; i++) {
            din.readByte();
        }
    }
1309210
public function load_data($input = null) {
        $data = null;
        $file = null;

        if (is_null($input)) {
            $file = $this->file;
        } elseif (\strlen($input) <= PHP_MAXPATHLEN && file_exists($input)) {
            $file = $input;
        } else {
            $data = $input;
        }

        if (!empty($data) || $data = $this->_rfile($file)) {
            if ($this->file != $file) {
                $this->file = $file;
            }

            if (preg_match('/\.php$/i', $file) && preg_match('/<\?.*?\?>(.*)/ms', $data, $strip)) {
                $data = ltrim($strip[1]);
            }

            if (strpos($data, "\xef\xbb\xbf") === 0) {
                // strip off BOM (UTF-8)
                $data = substr($data, 3);
                $this->encoding('UTF-8');
            } elseif (strpos($data, "\xff\xfe") === 0) {
                // strip off BOM (UTF-16 little endian)
                $data = substr($data, 2);
                $this->encoding("UCS-2LE");
            } elseif (strpos($data, "\xfe\xff") === 0) {
                // strip off BOM (UTF-16 big endian)
                $data = substr($data, 2);
                $this->encoding("UTF-16");
            }

            if ($this->convert_encoding && $this->input_encoding !== $this->output_encoding) {
                $data = $this->use_mb_convert_encoding ?
                    mb_convert_encoding($data, $this->output_encoding, $this->input_encoding) :
                    iconv($this->input_encoding, $this->output_encoding, $data);
            }

            if (substr($data, -1) != "\n") {
                $data .= "\n";
            }

            $this->file_data = &$data;
            return true;
        }

        return false;
    }
368683
private void init() {
        if (databasePath.toFile().exists()) {
            // we have to initialize chunk size and the map of chunks
            // and return
            initChunkMap();
            int chunkSize = readChunkSize();
            assert(this.chunkSize == chunkSize);
            if (chunkSize == -1) {
                throw new InternalError("Impossible to read chunk size from the database '" + databasePath + "'");
            }
            this.chunkSize = chunkSize;
            logger.debug("Database was initialized previously. Nothing to do.");
            return;
        }

        Statement stmt = null;
        Connection connection = null;

        try {
            Class.forName("org.sqlite.JDBC");
            connection = DriverManager.getConnection("jdbc:sqlite:" + databasePath);

            // Create tables
            stmt = connection.createStatement();
            String sql = "CREATE TABLE chunk "
                    + "(id INTEGER PRIMARY KEY AUTOINCREMENT,"
                    + "chunk_id VARCHAR NOT NULL,"
                    + "chromosome VARCHAR NOT NULL, "
                    + "start INTEGER NOT NULL, "
                    + "end INTEGER NOT NULL); "
                    + "CREATE UNIQUE INDEX chunk_id_idx ON chunk (chunk_id);"
                    + "CREATE INDEX chrom_start_end_idx ON chunk (chromosome, start, end);";
            stmt.executeUpdate(sql);

            sql = "CREATE TABLE info "
                    + "(id INTEGER PRIMARY KEY AUTOINCREMENT,"
                    + "name VARCHAR NOT NULL,"
                    + "value VARCHAR NOT NULL);"
                    + "CREATE UNIQUE INDEX name_idx ON info (name);";
            stmt.executeUpdate(sql);

            sql = "insert into info (name, value) values ('chunkSize', '" + chunkSize + "');";
            stmt.executeUpdate(sql);

            sql = "CREATE TABLE file "
                    + "(id INTEGER PRIMARY KEY AUTOINCREMENT,"
                    + "path VARCHAR NOT NULL,"
                    + "name VARCHAR NOT NULL);"
                    + "CREATE UNIQUE INDEX path_idx ON file (path);";
            stmt.executeUpdate(sql);

            sql = "CREATE TABLE mean_coverage "
                    + "(chunk_id INTEGER,"
                    + "file_id INTEGER,"
                    + "v1 INTEGER, "
                    + "v2 INTEGER, "
                    + "v3 INTEGER, "
                    + "v4 INTEGER, "
                    + "v5 INTEGER, "
                    + "v6 INTEGER, "
                    + "v7 INTEGER, "
                    + "v8 INTEGER,"
                    + "PRIMARY KEY(chunk_id, file_id));";
            stmt.executeUpdate(sql);

            // close both resources
            stmt.close();
            connection.close();
        } catch (SQLException e) {
            logger.error(e.getClass().getName() + ": " + e.getMessage());
            cleanConnectionClose(connection, stmt);
        } catch (ClassNotFoundException e) {
            logger.error(e.getClass().getName() + ": " + e.getMessage());
            e.printStackTrace();
        }

        logger.debug("Initialized database successfully");
    }
618173
function computeInputData(manager, input) {
  var session = manager.session;
  var pointers = input.pointers;
  var pointersLength = pointers.length;

  // store the first input to calculate the distance and direction
  if (!session.firstInput) {
    session.firstInput = simpleCloneInputData(input);
  }

  // to compute scale and rotation we need to store the multiple touches
  if (pointersLength > 1 && !session.firstMultiple) {
    session.firstMultiple = simpleCloneInputData(input);
  } else if (pointersLength === 1) {
    session.firstMultiple = false;
  }

  var firstInput = session.firstInput;
  var firstMultiple = session.firstMultiple;
  var offsetCenter = firstMultiple ? firstMultiple.center : firstInput.center;

  var center = input.center = getCenter(pointers);
  input.timeStamp = now();
  input.deltaTime = input.timeStamp - firstInput.timeStamp;

  input.angle = getAngle(offsetCenter, center);
  input.distance = getDistance(offsetCenter, center);

  computeDeltaXY(session, input);
  input.offsetDirection = getDirection(input.deltaX, input.deltaY);

  input.scale = firstMultiple ? getScale(firstMultiple.pointers, pointers) : 1;
  input.rotation = firstMultiple ? getRotation(firstMultiple.pointers, pointers) : 0;

  computeIntervalInputData(session, input);

  // find the correct target
  var target = manager.element;
  if (hasParent(input.srcEvent.target, target)) {
    target = input.srcEvent.target;
  }
  input.target = target;
}
521935
protected Data init(Data data) {
	if (JSON_ARRAY == null) JSON_ARRAY = getFLF(data, "_literalArray");
	if (JSON_STRUCT == null) JSON_STRUCT = getFLF(data, "_literalStruct");
	if (GET_STATIC_SCOPE == null) GET_STATIC_SCOPE = getFLF(data, "_getStaticScope");
	if (GET_SUPER_STATIC_SCOPE == null) GET_SUPER_STATIC_SCOPE = getFLF(data, "_getSuperStaticScope");
	return data;
    }
409891
@POST
	@Path("/upload")
	@Consumes("multipart/form-data")
	@AllowSecurityBypassedByToken
	public void upload(MultipartFormDataInput input) throws IOException {
		Map<String, List<InputPart>> formDataMap = input.getFormDataMap();
		List<InputPart> inputParts = formDataMap.get("uploadedFile");

		for (InputPart inputPart : inputParts) {
			String fileName = getFileName(inputPart.getHeaders());
			InputStream inputStream = inputPart.getBody(InputStream.class, null);
			File file = File.createTempFile(HomeWS.class.getSimpleName(), ".tmp");
			IOUtils.copy(inputStream, new FileOutputStream(file));
			uploadedFiles.put(fileName, file);
		}
	}
729316
function load_data ($input = null) {
		$data = null;
		$file = null;
		if ( $input === null ) {
			$file = $this->file;
		} elseif ( file_exists($input) ) {
			$file = $input;
		} else {
			$data = $input;
		}
		if ( !empty($data) || $data = $this->_rfile($file) ) {
			if ( $this->file != $file ) $this->file = $file;
			if ( preg_match('/\.php$/i', $file) && preg_match('/<\?.*?\?>(.*)/ims', $data, $strip) ) {
				$data = ltrim($strip[1]);
			}
			if ( $this->convert_encoding ) $data = iconv($this->input_encoding, $this->output_encoding, $data);
			if ( substr($data, -1) != "\n" ) $data .= "\n";
			$this->file_data = &$data;
			return true;
		}
		return false;
	}
575447
private void convertCharset(final File inputFile) {
        if (inputFile.isDirectory()) {
            final File[] files = inputFile.listFiles();
            if (files != null) {
                for (final File file : files) {
                    convertCharset(file);
                }
            }
        } else if (FileUtils.isHTMLFile(inputFile.getName())||
                FileUtils.isHHCFile(inputFile.getName())||
                FileUtils.isHHKFile(inputFile.getName())) {

            final String fileName = inputFile.getAbsolutePath();
            final File outputFile = new File(fileName + FILE_EXTENSION_TEMP);
            log("Processing " + fileName, Project.MSG_INFO);
            BufferedReader reader = null;
            Writer writer = null;
            try {
                //prepare for the input and output
                final FileInputStream inputStream = new FileInputStream(inputFile);
                final InputStreamReader streamReader = new InputStreamReader(inputStream, UTF8);
                reader = new BufferedReader(streamReader);

                final FileOutputStream outputStream = new FileOutputStream(outputFile);
                final OutputStreamWriter streamWriter = new OutputStreamWriter(outputStream, UTF8);
                writer = new BufferedWriter(streamWriter);

                String value = reader.readLine();
                while(value != null) {
                    //meta tag contains charset found
                    if (value.contains("<meta http-equiv") && value.contains("charset")) {
                        final int insertPoint = value.indexOf("charset=") + "charset=".length();
                        final String subString = value.substring(0, insertPoint);
                        final int remainIndex = value.indexOf(UTF8) + UTF8.length();
                        final String remainString = value.substring(remainIndex);
                        //change the charset
                        final String newValue = (FileUtils.isHHCFile(inputFile.getName()) || FileUtils.isHHKFile(inputFile.getName()) ?
                                                 subString + charsetMap.get(ATTRIBUTE_FORMAT_VALUE_WINDOWS) + remainString :
                                                 subString + charsetMap.get(ATTRIBUTE_FORMAT_VALUE_HTML) + remainString);
                        //write into the output file
                        writer.write(newValue);
                        //add line break
                        writer.write(LINE_SEPARATOR);
                    } else {
                        if (value.contains(tag1)) {
                            value = replaceXmlTag(value, tag1);
                        } else if (value.contains(tag2)) {
                            value = replaceXmlTag(value, tag2);
                        } else if (value.contains(tag3)) {
                            value = replaceXmlTag(value, tag3);
                        }

                        //other values
                        writer.write(value);
                        writer.write(LINE_SEPARATOR);
                    }
                    value = reader.readLine();
                }
            } catch (final FileNotFoundException e) {
                logger.error(e.getMessage(), e) ;
            } catch (final UnsupportedEncodingException e) {
                throw new RuntimeException(e);
            } catch (final IOException e) {
                logger.error(e.getMessage(), e) ;
            } finally {
                if (reader != null) {
                    try {
                        reader.close();
                    } catch (final IOException e) {
                        logger.error("Failed to close input stream: " + e.getMessage());
                    }
                }
                if (writer != null) {
                    try {
                        writer.close();
                    } catch (final IOException e) {
                        logger.error("Failed to close output stream: " + e.getMessage());
                    }
                }
            }
            try {
                deleteQuietly(inputFile);
                moveFile(outputFile, inputFile);
            } catch (final Exception e) {
                logger.error("Failed to replace " + inputFile + ": " + e.getMessage());
            }
        }
    }
1327832
public void setInput(final String input)
		throws DecodingException
	{

		boolean zipFlag = input.charAt(0) == '_';
		if (zipFlag) {
			r = new BitReader(inflateInput(
					Base64.decodeBase64(input.substring(1)), 0));
		}
		else {
			byte[] data = Base64.decodeBase64(input);
			if (data == null) {

				for (int i = 0; i < input.length(); i++) {
					System.err.println(i + ": " + (int) input.charAt(i)
							+ " <> " + input.charAt(i));
				}

				throw new DecodingException("BASE 64 DECODING FAILED: " + input);
			}
			r = new BitReader(data);
		}
	}
604172
public void readData(DataInput din) throws IOException {
        function = din.readUnsignedShort();
        data = (short)(din.readShort() & 0xFFFF);
    }
914369
@SuppressWarnings("resource")
    private static BerDataValue readDataValue(InputStream input)
            throws BerDataValueFormatException {
        RecordingInputStream in = new RecordingInputStream(input);

        try {
            int firstIdentifierByte = in.read();
            if (firstIdentifierByte == -1) {
                // End of input
                return null;
            }
            int tagNumber = readTagNumber(in, firstIdentifierByte);

            int firstLengthByte = in.read();
            if (firstLengthByte == -1) {
                throw new BerDataValueFormatException("Missing length");
            }

            boolean constructed = BerEncoding.isConstructed((byte) firstIdentifierByte);
            int contentsLength;
            int contentsOffsetInDataValue;
            if ((firstLengthByte & 0x80) == 0) {
                // short form length
                contentsLength = readShortFormLength(firstLengthByte);
                contentsOffsetInDataValue = in.getReadByteCount();
                skipDefiniteLengthContents(in, contentsLength);
            } else if ((firstLengthByte & 0xff) != 0x80) {
                // long form length
                contentsLength = readLongFormLength(in, firstLengthByte);
                contentsOffsetInDataValue = in.getReadByteCount();
                skipDefiniteLengthContents(in, contentsLength);
            } else {
                // indefinite length
                contentsOffsetInDataValue = in.getReadByteCount();
                contentsLength =
                        constructed
                                ? skipConstructedIndefiniteLengthContents(in)
                                : skipPrimitiveIndefiniteLengthContents(in);
            }

            byte[] encoded = in.getReadBytes();
            ByteBuffer encodedContents =
                    ByteBuffer.wrap(encoded, contentsOffsetInDataValue, contentsLength);
            return new BerDataValue(
                    ByteBuffer.wrap(encoded),
                    encodedContents,
                    BerEncoding.getTagClass((byte) firstIdentifierByte),
                    constructed,
                    tagNumber);
        } catch (IOException e) {
            throw new BerDataValueFormatException("Failed to read data value", e);
        }
    }
1091166
@Override
    public Optional<TemplateContentData> load(String responseTemplateName, Input input) throws TemplateLoaderException {
        TemplateEnumerator templateEnumerator = templateEnumeratorSupplier.apply(responseTemplateName, input);
        while (templateEnumerator.hasNext()) {
            String templateName = (String) templateEnumerator.next();
            String templatePath = buildCompletePath(templateName);
            try {
                URI templateUri = getResourceURI(templatePath);
                if (templateUri != null) {
                    String templateIdentifier = templateUri.toString();
                    TemplateContentData templateContentData = templateCache.get(templateIdentifier);
                    if (templateContentData == null) {
                        try (InputStream inputStream = getTemplateAsStream(templatePath)) {
                            byte[] templateByteArray = new byte[inputStream.available()];
                            inputStream.read(templateByteArray);
                            templateContentData = TemplateContentData.builder()
                                    .withIdentifier(templateIdentifier)
                                    .withTemplateContent(templateByteArray)
                                    .withTemplateBaseDir(directoryPath)
                                    .build();
                        } catch (IOException e) {
                            String message = String.format("Fail to read template file: %s with error: %s", templatePath, e.getMessage());
                            LOGGER.error(message);
                            throw new TemplateLoaderException(message);
                        }
                        templateCache.put(templateIdentifier, templateContentData);
                    }
                    return Optional.of(templateContentData);
                }
            } catch (URISyntaxException e) {
                String message = String.format("Cannot get valid URI for template file path: %s with error: %s", templatePath, e.getMessage());
                LOGGER.error(message);
                throw new TemplateLoaderException(message);
            }
        }
        String message = String.format("Cannot find template file: %s given directory path: %s and file extension: %s, returning empty.",
                responseTemplateName, directoryPath, fileExtension);
        LOGGER.warn(message);
        return Optional.empty();
    }
807702
public void setInputDataConfig(java.util.Collection<Channel> inputDataConfig) {
        if (inputDataConfig == null) {
            this.inputDataConfig = null;
            return;
        }

        this.inputDataConfig = new java.util.ArrayList<Channel>(inputDataConfig);
    }