Beispiel #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private void readField(util.BytesRef type, index.FieldInfo fieldInfo, index.StoredFieldVisitor visitor) throws java.io.IOException
        private void readField(BytesRef type, FieldInfo fieldInfo, StoredFieldVisitor visitor)
        {
            readLine();
            Debug.Assert(StringHelper.StartsWith(scratch, VALUE));
            if (type == TYPE_STRING)
            {
                visitor.stringField(fieldInfo, new string(scratch.bytes, scratch.offset + VALUE.length, scratch.length - VALUE.length, StandardCharsets.UTF_8));
            }
            else if (type == TYPE_BINARY)
            {
                sbyte[] copy = new sbyte[scratch.length - VALUE.length];
                Array.Copy(scratch.bytes, scratch.offset + VALUE.length, copy, 0, copy.Length);
                visitor.binaryField(fieldInfo, copy);
            }
            else if (type == TYPE_INT)
            {
                UnicodeUtil.UTF8toUTF16(scratch.bytes, scratch.offset + VALUE.length, scratch.length - VALUE.length, scratchUTF16);
                visitor.intField(fieldInfo, Convert.ToInt32(scratchUTF16.ToString()));
            }
            else if (type == TYPE_LONG)
            {
                UnicodeUtil.UTF8toUTF16(scratch.bytes, scratch.offset + VALUE.length, scratch.length - VALUE.length, scratchUTF16);
                visitor.longField(fieldInfo, Convert.ToInt64(scratchUTF16.ToString()));
            }
            else if (type == TYPE_FLOAT)
            {
                UnicodeUtil.UTF8toUTF16(scratch.bytes, scratch.offset + VALUE.length, scratch.length - VALUE.length, scratchUTF16);
                visitor.floatField(fieldInfo, Convert.ToSingle(scratchUTF16.ToString()));
            }
            else if (type == TYPE_DOUBLE)
            {
                UnicodeUtil.UTF8toUTF16(scratch.bytes, scratch.offset + VALUE.length, scratch.length - VALUE.length, scratchUTF16);
                visitor.doubleField(fieldInfo, Convert.ToDouble(scratchUTF16.ToString()));
            }
        }
Beispiel #2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void document(int docID, org.apache.lucene.index.StoredFieldVisitor visitor) throws java.io.IOException
        public override void Document(int docID, StoredFieldVisitor visitor)
        {
            visitor.stringField(_dummyFieldInfo, docID.ToString().GetBytes(Encoding.UTF8));
        }