本文整理汇总了PHP中BufferedReader类的典型用法代码示例。如果您正苦于以下问题:PHP BufferedReader类的具体用法?PHP BufferedReader怎么用?PHP BufferedReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BufferedReader类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: parseFile
/**
*
*/
public function parseFile($xmlFile)
{
try {
$this->data = array();
try {
$fr = new FileReader($xmlFile);
} catch (Exception $e) {
$f = new PhingFile($xmlFile);
throw new BuildException("XML File not found: " . $f->getAbsolutePath());
}
$br = new BufferedReader($fr);
$this->parser = new ExpatParser($br);
$this->parser->parserSetOption(XML_OPTION_CASE_FOLDING, 0);
$this->parser->setHandler($this);
try {
$this->parser->parse();
} catch (Exception $e) {
print $e->getMessage() . "\n";
$br->close();
}
$br->close();
} catch (Exception $e) {
print $e->getMessage() . "\n";
print $e->getTraceAsString();
}
return $this->data;
}
开发者ID:DBezemer,项目名称:server,代码行数:30,代码来源:XmlToData.php
示例2: main
/**
* Does the work.
*
* @throws BuildException if someting goes wrong with the build
*/
public final function main()
{
if ($this->cvsRoot === null) {
throw new BuildException("cvsroot is required");
}
if ($this->password === null) {
throw new BuildException("password is required");
}
$this->log("cvsRoot: " . $this->cvsRoot, Project::MSG_DEBUG);
$this->log("password: " . $this->password, Project::MSG_DEBUG);
$this->log("passFile: " . $this->passFile->__toString(), Project::MSG_DEBUG);
$reader = null;
$writer = null;
try {
$buf = "";
if ($this->passFile->exists()) {
$reader = new BufferedReader(new FileReader($this->passFile));
$line = null;
while (($line = $reader->readLine()) !== null) {
if (!StringHelper::startsWith($this->cvsRoot, $line)) {
$buf .= $line . PHP_EOL;
}
}
}
$pwdfile = $buf . $this->cvsRoot . " A" . $this->mangle($this->password);
$this->log("Writing -> " . $pwdfile, Project::MSG_DEBUG);
$writer = new BufferedWriter(new FileWriter($this->passFile));
$writer->write($pwdfile);
$writer->newLine();
$writer->close();
if ($reader) {
$reader->close();
}
} catch (IOException $e) {
if ($reader) {
try {
$reader->close();
} catch (Exception $e) {
}
}
if ($writer) {
try {
$writer->close();
} catch (Exception $e) {
}
}
throw new BuildException($e);
}
}
开发者ID:TheTypoMaster,项目名称:SPHERE-Framework,代码行数:54,代码来源:CvsPassTask.php
示例3: parse
/**
* Creates the ExpatParser, sets root handler and kick off parsing
* process.
*
* @throws BuildException if there is any kind of execption during
* the parsing process
* @access private
*/
protected function parse()
{
try {
$reader = new BufferedReader(new FileReader($this->buildFile));
$reader->open();
$parser = new ExpatParser($reader);
$parser->parserSetOption(XML_OPTION_CASE_FOLDING, 0);
$parser->setHandler(new RootHandler($parser, $this));
$this->project->log("parsing buildfile " . $this->buildFile->getName(), PROJECT_MSG_VERBOSE);
$parser->parse();
$reader->close();
} catch (Exception $exc) {
throw new BuildException("Error reading project file", $exc);
}
}
开发者ID:jonphipps,项目名称:Metadata-Registry,代码行数:23,代码来源:ProjectConfigurator.php
示例4: setFile
/**
* set the text using a file
* @param file the file to use
* @throws BuildException if the file does not exist, or cannot be
* read
*/
public function setFile(PhingFile $file)
{
// non-existing files are not allowed
if (!$file->exists()) {
throw new BuildException("File " . $file . " does not exist.");
}
$reader = null;
try {
if ($this->encoding == null) {
$reader = new BufferedReader(new FileReader($file));
} else {
$reader = new BufferedReader(new InputStreamReader(new FileInputStream($file)));
}
$this->value = $reader->read();
} catch (IOException $ex) {
$reader->close();
throw new BuildException($ex);
}
$reader->close();
}
开发者ID:kenguest,项目名称:phing,代码行数:26,代码来源:TextElement.php
示例5: loadFromStream
public static function loadFromStream($filename, GenericList $classNotFoundExceptions)
{
if (is_null($filename)) {
throw new NullPointerException('InputStream');
}
$whitelistSer = new HashMap();
$whitelistDeser = new HashMap();
$typeIds = new HashMap();
$clientFields = new HashMap();
$br = new BufferedReader($filename);
$line = $br->readLine();
$lineNum = 1;
while (!is_null($line)) {
$line = trim($line);
if (mb_strlen($line) > 0) {
$components = explode(',', $line);
if ($components[0] === self::CLIENT_FIELDS_KEYWORD) {
/*
* Lines starting with '@ClientFields' list potentially serializable fields known to
* client code for classes that may be enhanced with additional fields on the server.
* If additional server fields are found, they will be serizalized separately from the
* normal RPC process and transmitted to the client as an opaque blob of data stored
* in a WeakMapping associated with the object instance.
*/
$binaryTypeName = trim($components[1]);
try {
$clazz = Classes::classOf($binaryTypeName);
$fieldNames = new HashSet();
for ($i = 2; $i < count($components); $i++) {
$fieldNames->add($components[$i]);
}
$clientFields->put($clazz, $fieldNames);
} catch (ClassNotFoundException $e) {
// Ignore the error, but add it to the list of errors if one was
// provided.
if (!is_null($classNotFoundExceptions)) {
$classNotFoundExceptions->add($e);
}
}
} else {
if (count($components) != 2 && count($components) != 7) {
throw new ParseException(self::FORMAT_ERROR_MESSAGE, $lineNum);
}
for ($i = 0; $i < count($components); $i++) {
$components[$i] = trim($components[$i]);
if (mb_strlen($components[$i]) == 0) {
throw new ParseException(self::FORMAT_ERROR_MESSAGE, $lineNum);
}
}
$binaryTypeName = trim($components[0]);
if (count($components) == 2) {
$fieldSer = $fieldDeser = true;
$instantSer = $instantDeser = Boolean::valueOf($components[1]);
$typeId = $binaryTypeName;
} else {
$idx = 1;
// TODO: Validate the instantiable string better
$fieldSer = Boolean::valueOf($components[$idx++]);
$instantSer = Boolean::valueOf($components[$idx++]);
$fieldDeser = Boolean::valueOf($components[$idx++]);
$instantDeser = Boolean::valueOf($components[$idx++]);
$typeId = $components[$idx++];
if (!$fieldSer && !$fieldDeser && TypeNameObfuscator::SERVICE_INTERFACE_ID != $typeId) {
throw new ParseException('Type ' . $binaryTypeName . ' is neither field serializable, field deserializable ' . 'nor the service interface : ', $lineNum);
}
}
try {
$clazz = Classes::classOf($binaryTypeName);
if ($fieldSer) {
$whitelistSer->put($clazz, $instantSer);
}
if ($fieldDeser) {
$whitelistDeser->put($clazz, $instantDeser);
}
$typeIds->put($clazz, $typeId);
} catch (ClassNotFoundException $e) {
// Ignore the error, but add it to the list of errors if one was
// provided.
if (!is_null($classNotFoundExceptions)) {
$classNotFoundExceptions->add($e);
}
}
}
}
$line = $br->readLine();
$lineNum++;
}
return new StandardSerializationPolicy($whitelistSer, $whitelistDeser, $typeIds, $clientFields);
}
开发者ID:google-code-backups,项目名称:gwtphp-derpc,代码行数:89,代码来源:SerializationPolicyLoader.php
示例6: runStatements
/**
* read in lines and execute them
* @param Reader $reader
* @param null $out
* @throws BuildException
*/
public function runStatements(Reader $reader, $out = null)
{
$sql = "";
$line = "";
$buffer = '';
if (is_array($this->filterChains) && !empty($this->filterChains)) {
$in = FileUtils::getChainedReader(new BufferedReader($reader), $this->filterChains, $this->getProject());
while (-1 !== ($read = $in->read())) {
// -1 indicates EOF
$buffer .= $read;
}
$lines = explode("\n", $buffer);
} else {
$in = new BufferedReader($reader);
while (($line = $in->readLine()) !== null) {
$lines[] = $line;
}
}
try {
foreach ($lines as $line) {
$line = trim($line);
$line = ProjectConfigurator::replaceProperties($this->project, $line, $this->project->getProperties());
if (StringHelper::startsWith("//", $line) || StringHelper::startsWith("--", $line) || StringHelper::startsWith("#", $line)) {
continue;
}
if (strlen($line) > 4 && strtoupper(substr($line, 0, 4)) == "REM ") {
continue;
}
$sql .= " " . $line;
$sql = trim($sql);
// SQL defines "--" as a comment to EOL
// and in Oracle it may contain a hint
// so we cannot just remove it, instead we must end it
if (strpos($line, "--") !== false) {
$sql .= "\n";
}
if ($this->delimiterType == self::DELIM_NORMAL && StringHelper::endsWith($this->delimiter, $sql) || $this->delimiterType == self::DELIM_ROW && $line == $this->delimiter) {
$this->log("SQL: " . $sql, Project::MSG_VERBOSE);
$this->execSQL(StringHelper::substring($sql, 0, strlen($sql) - strlen($this->delimiter)), $out);
$sql = "";
}
}
// Catch any statements not followed by ;
if ($sql !== "") {
$this->execSQL($sql, $out);
}
} catch (SQLException $e) {
throw new BuildException("Error running statements", $e);
}
}
开发者ID:nhallpot,项目名称:CSCrew2015-back,代码行数:56,代码来源:CreoleSQLExecTask.php
示例7: isSelected
/**
* The heart of the matter. This is where the selector gets to decide
* on the inclusion of a file in a particular fileset.
*
* @param PhingFile $basedir base directory the scan is being done from
* @param string $filename the name of the file to check
* @param PhingFile $file PhingFile object the selector can use
*
* @throws BuildException
*
* @return bool whether the file should be selected or not
*/
public function isSelected(PhingFile $basedir, $filename, PhingFile $file)
{
$this->validate();
if ($file->isDirectory()) {
return true;
}
if ($this->myRegExp === null) {
$this->myRegExp = new RegularExpression();
$this->myRegExp->setPattern($this->userProvidedExpression);
if (!$this->casesensitive) {
$this->myRegExp->setIgnoreCase(true);
}
$this->myExpression = $this->myRegExp->getRegexp($this->getProject());
}
$in = null;
try {
$in = new BufferedReader(new FileReader($file));
$teststr = $in->readLine();
while ($teststr !== null) {
if ($this->myExpression->matches($teststr)) {
return true;
}
$teststr = $in->readLine();
}
$in->close();
return false;
} catch (IOException $ioe) {
if ($in) {
$in->close();
}
throw new BuildException("Could not read file " . $filename);
}
}
开发者ID:xxspartan16,项目名称:BMS-Market,代码行数:45,代码来源:ContainsRegexpSelector.php
示例8: readListFile
/**
* Reads file names from a file and adds them to the files array.
*
* @param Project $p
*
* @throws BuildException
*/
private function readListFile(Project $p)
{
$listReader = null;
try {
// Get a FileReader
$listReader = new BufferedReader(new FileReader($this->listfile));
$line = $listReader->readLine();
while ($line !== null) {
if (!empty($line)) {
$line = $p->replaceProperties($line);
$this->filenames[] = trim($line);
}
$line = $listReader->readLine();
}
} catch (Exception $e) {
if ($listReader) {
$listReader->close();
}
throw new BuildException("An error occurred while reading from list file " . $this->listfile->__toString() . ": " . $e->getMessage());
}
$listReader->close();
}
开发者ID:tammyd,项目名称:phing,代码行数:29,代码来源:FileList.php
示例9: parseFile
/**
* Parses a XML input file and returns a newly created and
* populated AppData structure.
*
* @param string $xmlFile The input file to parse.
* @return AppData populated by <code>xmlFile</code>.
*/
public function parseFile($xmlFile)
{
// we don't want infinite recursion
if ($this->isAlreadyParsed($xmlFile)) {
return;
}
$domDocument = new DomDocument('1.0', 'UTF-8');
$domDocument->load($xmlFile);
// store current schema file path
$this->schemasTagsStack[$xmlFile] = array();
$this->currentXmlFile = $xmlFile;
try {
$fr = new FileReader($xmlFile);
} catch (Exception $e) {
$f = new PhingFile($xmlFile);
throw new Exception("XML File not found: " . $f->getAbsolutePath());
}
$br = new BufferedReader($fr);
$this->parser = new ExpatParser($br);
$this->parser->parserSetOption(XML_OPTION_CASE_FOLDING, 0);
$this->parser->setHandler($this);
try {
$this->parser->parse();
} catch (Exception $e) {
$br->close();
throw $e;
}
$br->close();
array_pop($this->schemasTagsStack);
return $this->app;
}
开发者ID:sensorsix,项目名称:app,代码行数:38,代码来源:XmlToAppData.php
示例10: isSelected
/**
* The heart of the matter. This is where the selector gets to decide
* on the inclusion of a file in a particular fileset.
*
* @param PhingFile $basedir
* @param string $filename
* @param PhingFile $file
*
* @throws BuildException
*
* @internal param the $basedir base directory the scan is being done from
* @internal param is $filename the name of the file to check
* @internal param a $file PhingFile object the selector can use
*
* @return bool whether the file should be selected or not
*/
public function isSelected(PhingFile $basedir, $filename, PhingFile $file)
{
$this->validate();
if ($file->isDirectory()) {
return true;
}
$userstr = $this->contains;
if (!$this->casesensitive) {
$userstr = strtolower($this->contains);
}
$in = null;
try {
$in = new BufferedReader(new FileReader($file));
$teststr = $in->readLine();
while ($teststr !== null) {
if (!$this->casesensitive) {
$teststr = strtolower($teststr);
}
if (strpos($teststr, $userstr) !== false) {
return true;
}
$teststr = $in->readLine();
}
$in->close();
return false;
} catch (IOException $ioe) {
if ($in) {
$in->close();
}
throw new BuildException("Could not read file " . $filename);
}
}
开发者ID:tammyd,项目名称:phing,代码行数:48,代码来源:ContainsSelector.php
示例11: transform
/**
* Transform the data dump input file into SQL and writes it to the output stream.
*
* @param PhingFile $xmlFile
* @param Writer $out
*/
public function transform(PhingFile $xmlFile, Writer $out)
{
$this->sqlWriter = $out;
// Reset some vars just in case this is being run multiple times.
$this->currTableName = $this->currBuilder = null;
$this->builderClazz = $this->generatorConfig->getBuilderClassname('datasql');
try {
$fr = new FileReader($xmlFile);
} catch (Exception $e) {
throw new BuildException("XML File not found: " . $xmlFile->getAbsolutePath());
}
$br = new BufferedReader($fr);
$this->parser = new ExpatParser($br);
$this->parser->parserSetOption(XML_OPTION_CASE_FOLDING, 0);
$this->parser->setHandler($this);
try {
$this->parser->parse();
} catch (Exception $e) {
print $e->getMessage() . "\n";
$br->close();
}
$br->close();
}
开发者ID:RafalFilipek,项目名称:Propel2,代码行数:29,代码来源:XmlToDataSQL.php
示例12: runStatements
/**
* Read the statements from the .sql file and execute them.
* Lines starting with '//', '--' or 'REM ' are ignored.
*
* Developer note: must be public in order to be called from
* sudo-"inner" class PropelSQLExecTransaction.
*
* @param Reader $reader
* @param $out Optional output stream.
* @throws SQLException
* @throws IOException
*/
public function runStatements(Reader $reader, $out = null)
{
$sql = "";
$line = "";
$sqlBacklog = "";
$hasQuery = false;
$in = new BufferedReader($reader);
try {
while (($line = $in->readLine()) !== null) {
$line = trim($line);
$line = ProjectConfigurator::replaceProperties($this->project, $line, $this->project->getProperties());
if (StringHelper::startsWith("//", $line) || StringHelper::startsWith("--", $line) || StringHelper::startsWith("#", $line)) {
continue;
}
if (strlen($line) > 4 && strtoupper(substr($line, 0, 4)) == "REM ") {
continue;
}
if ($sqlBacklog !== "") {
$sql = $sqlBacklog;
$sqlBacklog = "";
}
$sql .= " " . $line . "\n";
// SQL defines "--" as a comment to EOL
// and in Oracle it may contain a hint
// so we cannot just remove it, instead we must end it
if (strpos($line, "--") !== false) {
$sql .= "\n";
}
// DELIM_ROW doesn't need this (as far as i can tell)
if ($this->delimiterType == self::DELIM_NORMAL) {
$reg = "#((?:\"(?:\\\\.|[^\"])*\"?)+|'(?:\\\\.|[^'])*'?|" . preg_quote($this->delimiter) . ")#";
$sqlParts = preg_split($reg, $sql, 0, PREG_SPLIT_DELIM_CAPTURE);
$sqlBacklog = "";
foreach ($sqlParts as $sqlPart) {
// we always want to append, even if it's a delim (which will be stripped off later)
$sqlBacklog .= $sqlPart;
// we found a single (not enclosed by ' or ") delimiter, so we can use all stuff before the delim as the actual query
if ($sqlPart === $this->delimiter) {
$sql = $sqlBacklog;
$sqlBacklog = "";
$hasQuery = true;
}
}
}
if ($hasQuery || $this->delimiterType == self::DELIM_ROW && $line == $this->delimiter) {
// this assumes there is always a delimter on the end of the SQL statement.
$sql = StringHelper::substring($sql, 0, strlen($sql) - 1 - strlen($this->delimiter));
$this->log("SQL: " . $sql, PROJECT_MSG_VERBOSE);
$this->execSQL($sql, $out);
$sql = "";
$hasQuery = false;
}
}
// Catch any statements not followed by ;
if ($sql !== "") {
$this->execSQL($sql, $out);
}
} catch (SQLException $e) {
throw $e;
}
}
开发者ID:Daniel-Marynicz,项目名称:symfony1-legacy,代码行数:73,代码来源:PropelSQLExec.php
示例13: runStatements
/**
* Read the statements from the .sql file and execute them.
* Lines starting with '//', '--' or 'REM ' are ignored.
*
* Developer note: must be public in order to be called from
* sudo-"inner" class PropelSQLExecTransaction.
*
* @param Reader $reader
* @param $out Optional output stream.
* @throws PDOException
* @throws IOException
*/
public function runStatements(Reader $reader, $out = null)
{
$sql = "";
$line = "";
$sqlBacklog = "";
$hasQuery = false;
$in = new BufferedReader($reader);
$parser['pointer'] = 0;
$parser['isInString'] = false;
$parser['stringQuotes'] = "";
$parser['backslashCount'] = 0;
$parser['parsedString'] = "";
$sqlParts = array();
while (($line = $in->readLine()) !== null) {
$line = trim($line);
$line = ProjectConfigurator::replaceProperties($this->project, $line, $this->project->getProperties());
if (StringHelper::startsWith("//", $line) || StringHelper::startsWith("--", $line) || StringHelper::startsWith("#", $line)) {
continue;
}
if (strlen($line) > 4 && strtoupper(substr($line, 0, 4)) == "REM ") {
continue;
}
if ($sqlBacklog !== "") {
$sql = $sqlBacklog;
$sqlBacklog = "";
}
$sql .= " " . $line . PHP_EOL;
// SQL defines "--" as a comment to EOL
// and in Oracle it may contain a hint
// so we cannot just remove it, instead we must end it
if (strpos($line, "--") !== false) {
$sql .= PHP_EOL;
}
// DELIM_ROW doesn't need this (as far as i can tell)
if ($this->delimiterType == self::DELIM_NORMAL) {
// old regex, being replaced due to segfaults:
// See: http://propel.phpdb.org/trac/ticket/294
//$reg = "#((?:\"(?:\\\\.|[^\"])*\"?)+|'(?:\\\\.|[^'])*'?|" . preg_quote($this->delimiter) . ")#";
//$sqlParts = preg_split($reg, $sql, 0, PREG_SPLIT_DELIM_CAPTURE);
$i = $parser['pointer'];
$c = strlen($sql);
while ($i < $c) {
$char = $sql[$i];
switch ($char) {
case "\\":
$parser['backslashCount']++;
$this->log("c{$i}: found " . $parser['backslashCount'] . " backslash(es)", Project::MSG_VERBOSE);
break;
case "'":
case "\"":
if ($parser['isInString'] && $parser['stringQuotes'] == $char) {
if (($parser['backslashCount'] & 1) == 0) {
#$this->log("$i: out of string", Project::MSG_VERBOSE);
$parser['isInString'] = false;
} else {
$this->log("c{$i}: rejected quoted delimiter", Project::MSG_VERBOSE);
}
} elseif (!$parser['isInString']) {
$parser['stringQuotes'] = $char;
$parser['isInString'] = true;
#$this->log("$i: into string with $parser['stringQuotes']", Project::MSG_VERBOSE);
}
break;
}
if ($char == $this->delimiter && !$parser['isInString']) {
$this->log("c{$i}: valid end of command found!", Project::MSG_VERBOSE);
$sqlParts[] = $parser['parsedString'];
$sqlParts[] = $this->delimiter;
break;
}
$parser['parsedString'] .= $char;
if ($char !== "\\") {
if ($parser['backslashCount']) {
$this->log("{$i}: backslash reset", Project::MSG_VERBOSE);
}
$parser['backslashCount'] = 0;
}
$i++;
$parser['pointer']++;
}
$sqlBacklog = "";
foreach ($sqlParts as $sqlPart) {
// we always want to append, even if it's a delim (which will be stripped off later)
$sqlBacklog .= $sqlPart;
// we found a single (not enclosed by ' or ") delimiter, so we can use all stuff before the delim as the actual query
if ($sqlPart === $this->delimiter) {
$sql = $sqlBacklog;
$sqlBacklog = "";
//.........这里部分代码省略.........
开发者ID:cuongnv540,项目名称:jobeet,代码行数:101,代码来源:PropelSQLExec.php
示例14: _parse
/**
* @param PhingXMLContext $ctx
* @throws ExpatParseException
*/
protected function _parse(PhingXMLContext $ctx)
{
// push action onto global stack
$ctx->startConfigure($this);
$reader = new BufferedReader(new FileReader($this->buildFile));
$parser = new ExpatParser($reader);
$parser->parserSetOption(XML_OPTION_CASE_FOLDING, 0);
$parser->setHandler(new RootHandler($parser, $this, $ctx));
$this->project->log("parsing buildfile " . $this->buildFile->getName(), Project::MSG_VERBOSE);
$parser->parse();
$reader->close();
// mark parse phase as completed
$this->isParsing = false;
// execute delayed tasks
$this->parseEndTarget->main();
// pop this action from the global stack
$ctx->endConfigure();
}
开发者ID:xxspartan16,项目名称:BMS-Market,代码行数:22,代码来源:ProjectConfigurator.php
示例15: runStatements
/**
* read in lines and execute them
* @throws SQLException, IOException
*/
public function runStatements(Reader $reader, $out = null)
{
$sql = "";
$line = "";
$in = new BufferedReader($reader);
try {
while (($line = $in->readLine()) !== null) {
$line = trim($line);
$line = ProjectConfigurator::replaceProperties($this->project, $line, $this->project->getProperties());
if (StringHelper::startsWith("//", $line) || StringHelper::startsWith("--", $line) || StringHelper::startsWith("#", $line)) {
continue;
}
if (strlen($line) > 4 && strtoupper(substr($line, 0, 4)) == "REM ") {
continue;
}
$sql .= " " . $line;
$sql = trim($sql);
// SQL defines "--" as a comment to EOL
// and in Oracle it may contain a hint
// so we cannot just remove it, instead we must end it
if (strpos($line, "--") !== false) {
$sql .= "\n";
}
if ($this->delimiterType == self::DELIM_NORMAL && StringHelper::endsWith($this->delimiter, $sql) || $this->delimiterType == self::DELIM_ROW && $line == $this->delimiter) {
$this->log("SQL: " . $sql, PROJECT_MSG_VERBOSE);
$this->execSQL(StringHelper::substring($sql, 0, strlen($sql) - strlen($this->delimiter) - 1), $out);
$sql = "";
}
}
// Catch any statements not followed by ;
if ($sql !== "") {
$this->execSQL($sql, $out);
}
} catch (SQLException $e) {
throw new BuildException("Error running statements", $e);
}
}
开发者ID:Daniel-Marynicz,项目名称:symfony1-legacy,代码行数:41,代码来源:CreoleSQLExecTask.php
示例16: parse
/**
* Creates the ExpatParser, sets root handler and kick off parsing
* process.
*
* @throws BuildException if there is any kind of execption during
* the parsing process
* @access private
*/
protected function parse()
{
try {
// get parse context
$ctx = $this->project->getReference("phing.parsing.context");
if (null == $ctx) {
// make a new context and register it with project
$ctx = new PhingXMLContext($this->project);
$this->project->addReference("phing.parsing.context", $ctx);
}
//record this parse with context
$ctx->addImport($this->buildFile);
if (count($ctx->getImportStack()) > 1) {
// this is an imported file
// modify project tag parse behavior
$this->setIgnoreProjectTag(true);
}
// push action onto global stack
$ctx->startConfigure($this);
$reader = new BufferedReader(new FileReader($this->buildFile));
$parser = new ExpatParser($reader);
$parser->parserSetOption(XML_OPTION_CASE_FOLDING, 0);
$parser->setHandler(new RootHandler($parser, $this));
$this->project->log("parsing buildfile " . $this->buildFile->getName(), Project::MSG_VERBOSE);
$parser->parse();
$reader->close();
// mark parse phase as completed
$this->isParsing = false;
// execute delayed tasks
$this->parseEndTarget->main();
// pop this action from the global stack
$ctx->endConfigure();
} catch (Exception $exc) {
throw new BuildException("Error reading project file", $exc);
}
}
开发者ID:altesien,项目名称:FinalProject,代码行数:44,代码来源:ProjectConfigurator.php
示例17: readPatterns
/**
* Reads path matching patterns from a file and adds them to the
* includes or excludes list
*/
private function readPatterns(PhingFile $patternfile, &$patternlist, Project $p)
{
$patternReader = null;
try {
// Get a FileReader
$patternReader = new BufferedReader(new FileReader($patternfile));
// Create one NameEntry in the appropriate pattern list for each
// line in the file.
$line = $patternReader->readLine();
while ($line !== null) {
if (!empty($line)) {
$line = $p->replaceProperties($line);
$this->addPatternToList($patternlist)->setName($line);
}
$line = $patternReader->readLine();
}
} catch (IOException $ioe) {
$msg = "An error occured while reading from pattern file: " . $patternfile->__toString();
if ($patternReader) {
$patternReader->close();
}
throw new BuildException($msg, $ioe);
}
$patternReader->close();
}
开发者ID:namesco,项目名称:phing,代码行数:29,代码来源:PatternSet.php
示例18: read
/**
* Returns the next character in the filtered stream. If the desired
* number of lines have already been read, the resulting stream is
* effectively at an end. Otherwise, the next character from the
* underlying stream is read and returned.
*
* @param int $len
* @return int|string the next character in the resulting stream, or -1
* if the end of the resulting stream has been reached
*
* @throws IOException if the underlying stream throws an IOException
* during reading
* @throws BuildException
*/
public function read($len = 0)
{
// do the "singleton" initialization
if (!$this->getInitialized()) {
$this->initialize();
$this->setInitialized(true);
}
$ch = -1;
// The readers return -1 if they end. So simply read the "prepend"
// after that the "content" and at the end the "append" file.
if ($this->prependReader !== null) {
$ch = $this->prependReader->read();
if ($ch === -1) {
// I am the only one so I have to close the reader
$this->prependReader->close();
$this->prependReader = null;
}
}
if ($ch === -1) {
$ch = parent::read();
}
if ($ch === -1 && $this->appendReader !== null) {
$ch = $this->appendReader->read();
if ($ch === -1) {
// I am the only one so I have to close the reader
$this->appendReader->close();
$this->appendReader = null;
}
}
return $ch;
}
开发者ID:Ingewikkeld,项目名称:phing,代码行数:45,代码来源:ConcatFilter.php
注:本文中的BufferedReader类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论