lucenenet-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [lucenenet] NightOwl888 opened a new issue #362: API: Lucene.Net.Documents.Document: Add overloads that accept string format and IFormatProvider
Date Tue, 06 Oct 2020 14:53:40 GMT

NightOwl888 opened a new issue #362:
URL: https://github.com/apache/lucenenet/issues/362


   The [`Document`](https://github.com/apache/lucenenet/blob/f0930a5f8df377cccc428dcfeba02ea4098a6dee/src/Lucene.Net/Document/Document.cs)
type has members that get values from fields, but has no way to specify the culture to format
culture-sensitive field types into. We simply need to add overloads that accept format and
`IFormatProvider` and cascade this info to the `GetStringValue()` method overloads to remedy.
   
   ## Current API
   
   ```c#
   namespace Lucene.Net.Index
   {
       public interface IIndexableField
       {
       }
   }
   namespace Lucene.Net.Documents
   {
       public sealed class Document : IEnumerable<IIndexableField>
       {
           public string[] GetValues(string name);
           public string Get(string name);
           public override string ToString();
       }
       public partial class Field : IIndexableField
       {
           public override string ToString();
       }
   }
   ```
   
   ## Proposed API
   
   ```c#
   namespace Lucene.Net.Index
   {
       public interface IIndexableField
       {
           string ToString(IFormatProvider provider);
       }
   }
   namespace Lucene.Net.Documents
   {
       public sealed class Document : IEnumerable<IIndexableField>
       {
           public string[] GetValues(string name);
           public string[] GetValues(string name, string format);
           public string[] GetValues(string name, IFormatProvider provider);
           public string[] GetValues(string name, string format, IFormatProvider provider);
           public string Get(string name);
           public string Get(string name, string format);
           public string Get(string name, IFormatProvider provider);
           public string Get(string name, string format, IFormatProvider provider);
           public override string ToString();
           public virtual string ToString(IFormatProvider provider);
       }
       public partial class Field : IIndexableField
       {
           public override string ToString();
           public virtual string ToString(IFormatProvider provider);
       }
   }
   ```
   
   Note that the `GetStringValue()` method is being called twice in both `Get()` and `GetValue()`.
Performance can be improved by altering the code to only call it once.
   
   Tests should also be added to verify the functionality.
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



Mime
View raw message