Search
このインスタンス・メソッドでは、OracleBFileの現行のインスタンスのバイナリ・パターンを検索します。
宣言
// C# public int Search(byte[] val, Int64 offset, Int64 nth);
パラメータ
-
val検索対象のバイナリ・パターン
-
offsetOracleBFileの検索が開始される0ベース・オフセット(バイト) -
nthオフセットが戻される特定の一致の状態(
1ベース)
戻り値
一致のnth回目の出現に対して、一致パターン(バイト表示)の起点の絶対offsetを戻します。それ以外の場合は、0を戻します。
例外
ObjectDisposedException - オブジェクトはすでに処理されています。
InvalidOperationException - OracleConnectionがオープンされていないか、またはオブジェクトの存続中にクローズされています。
ArgumentOutOfRangeException - offsetが0未満の場合、nthが0以下の場合、val.Lengthが16383より大きい場合、nthがOracleBFile.MaxSize以上の場合またはoffsetがOracleBFile.MaxSize以上の場合のいずれか。
備考
検索パターンの制限は16383バイトです。
例
// Database Setup, if you have not done so yet.
/* Log on as DBA (SYS or SYSTEM) that has CREATE ANY DIRECTORY privilege.
CREATE OR REPLACE DIRECTORY MYDIR AS 'C:\TEMP';
*/
// C#
using System;
using Oracle.DataAccess.Client;
using Oracle.DataAccess.Types;
class SearchSample
{
static void Main()
{
// Create MYDIR directory object as indicated previously and create a file
// MyFile.txt with the text ABCDABC under C:\TEMP directory.
// Note that the byte representation of the ABCDABC is 65666768656667
string constr = "User Id=scott;Password=tiger;Data Source=oracle";
OracleConnection con = new OracleConnection(constr);
con.Open();
OracleBFile bFile = new OracleBFile(con, "MYDIR", "MyFile.txt");
// Open the OracleBFile
bFile.OpenFile();
// Search for the 2nd occurrence of a byte pattern {66,67}
// starting from byte offset 1 in the OracleBFile
byte[] pattern = new byte[2] {66, 67};
long posFound = bFile.Search(pattern, 1, 2);
// Prints "posFound = 6"
Console.WriteLine("posFound = " + posFound);
// Close the OracleBFile
bFile.CloseFile();
bFile.Close();
bFile.Dispose();
con.Close();
con.Dispose();
}
}