private void NextFile() { if (curFileNum != list.Length) { try { Console.WriteLine("Switching to input file: " + list[curFileNum].Name); if (defaultEncoding != null) { using (var fs = list[curFileNum++].OpenRead()) { curFileReader = new MarcPermissiveStreamReader(fs, permissive, convertToUTF8, defaultEncoding); } } else { using (var fs = list[curFileNum++].OpenRead()) { curFileReader = new MarcPermissiveStreamReader(fs, permissive, convertToUTF8); } } } catch (FileNotFoundException e) { NextFile(); } } else { curFileReader = null; } }
public MarcTranslatedReader(IMarcReader r, String unicodeNormalizeStr) { reader = r; convert = new AnselToUnicode(); if (unicodeNormalizeStr.Equals("KC")) { unicodeNormalize = NormalizationForm.FormKC; } else if (unicodeNormalizeStr.Equals("KD")) { unicodeNormalize = NormalizationForm.FormKD; } else if (unicodeNormalizeStr.Equals("C")) { unicodeNormalize = NormalizationForm.FormC; } else if (unicodeNormalizeStr.Equals("D")) { unicodeNormalize = NormalizationForm.FormD; } else { unicodeNormalize = NormalizationForm.FormC; } }
/// <summary> /// Initialize logging category /// </summary> /// <param name="r"></param> /// <param name="unicodeNormalizeBool"></param> public MarcTranslatedReader(IMarcReader r, bool unicodeNormalizeBool) { reader = r; convert = new AnselToUnicode(); if (unicodeNormalizeBool) { this.unicodeNormalize = NormalizationForm.FormC; } }
/// <summary> /// Constructor for a "combining" Marc reader, that looks ahead at the Marc file to determine /// when the next record is a continuation of the currently read record. /// </summary> /// <param name="reader">The Lower level MarcReader that returns Marc4J.Net Record objects that are read from a Marc file.</param> /// <param name="idsToMerge">string representing a regular expression matching those fields to be merged for continuation records.</param> /// <param name="leftControlField">string representing a control field in the current record to use for matching purposes (null to default to 001).</param> /// <param name="rightControlField">string representing a control field in the next record to use for matching purposes (null to default to 001).</param> public MarcCombiningReader(IMarcReader reader, String idsToMerge, String leftControlField, String rightControlField) { this._reader = reader; this._idsToMerge = idsToMerge; this._leftControlField = leftControlField; this._rightControlField = rightControlField; this._nextErrors = null; this._currentErrors = null; }
/// <summary> /// Constructs an instance that traverses the directory specified in the parameter. /// Takes the values passed in for permissive and convertToUTF8 and passes them on /// to each of the MarcPermissiveStreamReader that it creates. /// </summary> /// <param name="dir">The path of the directory from which to read all of the .mrc files</param> /// <param name="permissive">Set to true to specify that reader should try to handle and recover from errors in the input.</param> /// <param name="convertToUTF8">Set to true to specify that reader should convert the records being read to UTF-8 encoding as they are being read.</param> /// <param name="defaultEncoding">Specifies the character encoding that the records being read are presumed to be in..</param> public MarcDirStreamReader(DirectoryInfo dir, bool permissive, bool convertToUTF8, string defaultEncoding) { this.permissive = permissive; this.convertToUTF8 = convertToUTF8; this.defaultEncoding = defaultEncoding; list = dir.GetFiles("*.mrc"); Array.Sort <FileInfo>(list); curFileNum = 0; curFileReader = null; }
public void Dispose() { if (list != null) { Array.Clear(list, 0, list.Length); list = null; } if (curFileReader != null) { curFileReader.Dispose(); curFileReader = null; } defaultEncoding = null; GC.SuppressFinalize(this); }
public MarcTranslatedReader(IMarcReader r, NormalizationForm unicodeNormalize) { reader = r; convert = new AnselToUnicode(); this.unicodeNormalize = unicodeNormalize; }