@Override public long externalToLong(String extVal) { return TrieField.dateField.parseMath(null, extVal).getTime(); } }
public String toInternal(Date val) { return formatDate(val); }
public SortField getSortField(SchemaField field,boolean reverse) { return getStringSort(field,reverse); }
public Date toObject(String indexedForm) throws java.text.ParseException { return parseDate(indexedToReadable(indexedForm)); }
public String toInternal(String val) { return toInternal(parseMath(null, val)); }
@Override public Date toObject(Fieldable f) { try { return parseDate( toExternal(f) ); } catch( ParseException ex ) { throw new RuntimeException( ex ); } }
final Date start; try { start = ft.parseMath(NOW, startS); } catch (SolrException e) { throw new SolrException end = ft.parseMath(NOW, endS); } catch (SolrException e) { throw new SolrException while (low.before(end)) { dmp.setNow(low); String label = ft.toExternal(low);
@Override public String indexedToReadable(String indexedForm) { return super.toExternal( new Date(NumericUtils.prefixCodedToLong(indexedForm)) ); }
public Date getDate(FunctionQParser fp, String arg) { if (arg==null) return null; if (arg.startsWith("NOW") || (arg.length()>0 && Character.isDigit(arg.charAt(0)))) { return df.parseMathLenient(null, arg, fp.req); } return null; }
public String toExternal(Fieldable f) { return indexedToReadable(f.stringValue()); }
protected int rangeCount(SchemaField sf, Date low, Date high, boolean iLow, boolean iHigh) throws IOException { Query rangeQ = ((DateField)(sf.getType())).getRangeQuery(null, sf,low,high,iLow,iHigh); return searcher.numDocs(rangeQ ,base); }
try { p.setNow(parseDate(val.substring(0,zz+1))); } catch (ParseException e) { throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,
try { p.setNow(parseDateLenient(val.substring(0,zz+1), req)); } catch (ParseException e) { throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,
public void write(TextResponseWriter writer, String name, Fieldable f) throws IOException { writer.writeDate(name, toExternal(f)); }
@Override public Query getRangeQuery(QParser parser, SchemaField field, String min, String max, boolean minInclusive, boolean maxInclusive) { return getRangeQuery(parser, field, min==null ? null : super.parseMath(null,min), max==null ? null : super.parseMath(null,max), minInclusive, maxInclusive); }
public void write(XMLWriter xmlWriter, String name, Fieldable f) throws IOException { xmlWriter.writeDate(name, toExternal(f)); }
@Override public String indexedToReadable(String indexedForm) { switch (type) { case INTEGER: return Integer.toString( NumericUtils.prefixCodedToInt(indexedForm) ); case FLOAT: return Float.toString( NumericUtils.sortableIntToFloat(NumericUtils.prefixCodedToInt(indexedForm)) ); case LONG: return Long.toString( NumericUtils.prefixCodedToLong(indexedForm) ); case DOUBLE: return Double.toString( NumericUtils.sortableLongToDouble(NumericUtils.prefixCodedToLong(indexedForm)) ); case DATE: return dateField.formatDate( new Date(NumericUtils.prefixCodedToLong(indexedForm)) ); default: throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Unknown type for trie field: " + type); } }
@Override public Long parse(final Reader input) throws IOException { // Readers received for datatype should always be ReusableCharArrayReader if (!(input instanceof ReusableCharArrayReader)) { throw new IllegalArgumentException("ReusableCharArrayReader expected"); } // not very nice, but necessary to create a string for the date parser // The string is created by reusing the char array buffer of the reader. final String value = ((ReusableCharArrayReader) input).toString(); return dateField.parseMath(null, value).getTime(); }
@Override public String toExternal(Fieldable f) { byte[] arr = f.binaryValue(); if (arr==null) return TrieField.badFieldString(f); return super.toExternal(new Date(TrieField.toLong(arr))); }
@Override public String toExternal(Fieldable f) { byte[] arr = f.binaryValue(); if (arr==null) return badFieldString(f); switch (type) { case INTEGER: return Integer.toString(toInt(arr)); case FLOAT: return Float.toString(toFloat(arr)); case LONG: return Long.toString(toLong(arr)); case DOUBLE: return Double.toString(toDouble(arr)); case DATE: return dateField.formatDate(new Date(toLong(arr))); default: throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Unknown type for trie field: " + f.name()); } }