check and remove leading zeros when writing IntField: SOLR-394

git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@594185 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yonik Seeley 2007-11-12 15:34:45 +00:00
parent 2d3ddfeadc
commit 8e339464dc

View File

@ -47,7 +47,15 @@ public class IntField extends FieldType {
}
public void write(TextResponseWriter writer, String name, Fieldable f) throws IOException {
writer.writeInt(name, f.stringValue());
String s = f.stringValue();
int len = s.length();
if (len>=2) {
char ch = s.charAt(0);
if ((ch=='0') || (ch=='-' && s.charAt(1)=='0')) {
s = Integer.toString(Integer.parseInt(s));
}
}
writer.writeInt(name, s);
}
@Override