[sword-svn] r425 - trunk/clucene/src/CLucene/document
chrislit at crosswire.org
chrislit at crosswire.org
Thu Jun 1 13:48:52 MST 2006
Author: chrislit
Date: 2006-06-01 13:48:47 -0700 (Thu, 01 Jun 2006)
New Revision: 425
Added:
trunk/clucene/src/CLucene/document/DateField.h
Log:
CLucene update to 0.9.11 (with a couple of BCB-related fixes)
Added: trunk/clucene/src/CLucene/document/DateField.h
===================================================================
--- trunk/clucene/src/CLucene/document/DateField.h 2006-06-01 04:55:56 UTC (rev 424)
+++ trunk/clucene/src/CLucene/document/DateField.h 2006-06-01 20:48:47 UTC (rev 425)
@@ -0,0 +1,68 @@
+/**
+ * Copyright 2003-2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef _lucene_document_DateField_
+#define _lucene_document_DateField_
+
+#if defined(_LUCENE_PRAGMA_ONCE)
+# pragma once
+#endif
+
+CL_NS_DEF(document)
+
+//here are some constants used throughout clucene
+//make date strings long enough to last a millenium
+#define DATEFIELD_DATE_MAX _ILONGLONG(31536000000000) //1000L*365*24*60*60*1000
+
+#define DATEFIELD_DATE_LEN 9 ////Long.toString(DATEFIELD_DATE_MAX, Character.MAX_RADIX).length()
+
+ /**
+ * Provides support for converting dates to strings and vice-versa.
+ * The strings are structured so that lexicographic sorting orders by date,
+ * which makes them suitable for use as field values and search terms.
+ *
+ * <P>
+ * Note that you do not have to use this class, you can just save your
+ * dates as strings if lexicographic sorting orders them by date. This is
+ * the case for example for dates like <code>yyyy-mm-dd hh:mm:ss</code>
+ * (of course you can leave out the delimiter characters to save some space).
+ * The advantage with using such a format is that you can easily save dates
+ * with the required granularity, e.g. leaving out seconds. This saves memory
+ * when searching with a RangeQuery or PrefixQuery, as Lucene
+ * expands these queries to a BooleanQuery with potentially very many terms.
+ *
+ * <P>
+ * Note: dates before 1970 cannot be used, and therefore cannot be
+ * indexed when using this class.
+ */
+ class DateField :LUCENE_BASE {
+ private:
+ static void initDS();
+ public:
+ ~DateField();
+
+ /**
+ * Converts a millisecond time to a string suitable for indexing.
+ * @throws RuntimeException if the time specified in the
+ * method argument is negative, that is, before 1970
+ */
+ static TCHAR* timeToString(const int64_t time);
+
+ /** Converts a string-encoded date into a millisecond time. */
+ static int64_t stringToTime(const TCHAR* s);
+
+ };
+CL_NS_END
+#endif
More information about the sword-cvs
mailing list