Author: epbernard
Date: 2006-11-01 00:46:08 -0500 (Wed, 01 Nov 2006)
New Revision: 10672
Added:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/String2FieldBridgeAdaptor.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/String2IdFieldBridgeAdaptor.java
Removed:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/String2FieldBridgeAdaptor.java
Modified:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/BridgeFactory.java
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/DateBridge.java
Log:
ANN-468 split of IdFieldBridge vs FieldBridge
Modified:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/BridgeFactory.java
===================================================================
---
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/BridgeFactory.java 2006-11-01
04:27:26 UTC (rev 10671)
+++
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/BridgeFactory.java 2006-11-01
05:46:08 UTC (rev 10672)
@@ -20,19 +20,19 @@
private static Map<String, FieldBridge> builtInBridges = new HashMap<String,
FieldBridge>();
private BridgeFactory() {}
- public static final FieldBridge DOUBLE = new String2FieldBridgeAdaptor( new
DoubleBridge() );
+ public static final IdFieldBridge DOUBLE = new String2IdFieldBridgeAdaptor( new
DoubleBridge() );
- public static final FieldBridge FLOAT = new String2FieldBridgeAdaptor( new FloatBridge()
);
+ public static final IdFieldBridge FLOAT = new String2IdFieldBridgeAdaptor( new
FloatBridge() );
- public static final FieldBridge INTEGER = new String2FieldBridgeAdaptor( new
IntegerBridge() );
+ public static final IdFieldBridge INTEGER = new String2IdFieldBridgeAdaptor( new
IntegerBridge() );
- public static final FieldBridge LONG = new String2FieldBridgeAdaptor( new LongBridge()
);
+ public static final IdFieldBridge LONG = new String2IdFieldBridgeAdaptor( new
LongBridge() );
- public static final FieldBridge BIG_INTEGER = new String2FieldBridgeAdaptor( new
BigIntegerBridge() );
+ public static final IdFieldBridge BIG_INTEGER = new String2IdFieldBridgeAdaptor( new
BigIntegerBridge() );
- public static final FieldBridge BIG_DECIMAL = new String2FieldBridgeAdaptor( new
BigDecimalBridge() );
+ public static final IdFieldBridge BIG_DECIMAL = new String2IdFieldBridgeAdaptor( new
BigDecimalBridge() );
- public static final FieldBridge STRING = new String2FieldBridgeAdaptor( new
StringImplBridge() );
+ public static final IdFieldBridge STRING = new String2IdFieldBridgeAdaptor( new
StringImplBridge() );
public static final FieldBridge DATE_YEAR;
public static final FieldBridge DATE_MONTH;
@@ -40,7 +40,7 @@
public static final FieldBridge DATE_HOUR;
public static final FieldBridge DATE_MINUTE;
public static final FieldBridge DATE_SECOND;
- public static final FieldBridge DATE_MILLISECOND;
+ public static final IdFieldBridge DATE_MILLISECOND;
static {
builtInBridges.put( Double.class.getName(), DOUBLE );
@@ -76,7 +76,7 @@
bridge = (FieldBridge) instance;
}
else if ( StringBridge.class.isAssignableFrom( impl ) ) {
- bridge = new String2FieldBridgeAdaptor( (StringBridge) instance );
+ bridge = new String2IdFieldBridgeAdaptor( (StringBridge) instance );
}
if ( bridgeAnn.params().length > 0 &&
ParameterizedBridge.class.isAssignableFrom( impl ) ) {
Map params = new HashMap( bridgeAnn.params().length );
Modified:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/DateBridge.java
===================================================================
---
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/DateBridge.java 2006-11-01
04:27:26 UTC (rev 10671)
+++
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/DateBridge.java 2006-11-01
05:46:08 UTC (rev 10672)
@@ -34,7 +34,7 @@
public static final String2FieldBridgeAdaptor DATE_HOUR = new String2FieldBridgeAdaptor(
new DateBridge( Resolution.HOUR ) );
public static final String2FieldBridgeAdaptor DATE_MINUTE = new
String2FieldBridgeAdaptor( new DateBridge( Resolution.MINUTE ) );
public static final String2FieldBridgeAdaptor DATE_SECOND = new
String2FieldBridgeAdaptor( new DateBridge( Resolution.SECOND ) );
- public static final String2FieldBridgeAdaptor DATE_MILLISECOND = new
String2FieldBridgeAdaptor( new DateBridge( Resolution.MILLISECOND ) );
+ public static final String2IdFieldBridgeAdaptor DATE_MILLISECOND = new
String2IdFieldBridgeAdaptor( new DateBridge( Resolution.MILLISECOND ) );
DateTools.Resolution resolution;
Deleted:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/String2FieldBridgeAdaptor.java
===================================================================
---
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/String2FieldBridgeAdaptor.java 2006-11-01
04:27:26 UTC (rev 10671)
+++
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/String2FieldBridgeAdaptor.java 2006-11-01
05:46:08 UTC (rev 10672)
@@ -1,41 +0,0 @@
-//$Id: $
-package org.hibernate.lucene.bridge;
-
-import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
-import org.hibernate.util.StringHelper;
-
-/**
- * Bridge to use a Java2String as a Java2Field
- *
- * @author Emmanuel Bernard
- */
-//FIXME all String2FieldBridgeAdaptor are not IdFieldBridge
-public class String2FieldBridgeAdaptor implements FieldBridge, IdFieldBridge {
-
- private StringBridge stringBridge;
-
- public String2FieldBridgeAdaptor(StringBridge stringBridge) {
- this.stringBridge = stringBridge;
- }
- public Object get(String name, Document document) {
- Field field = document.getField( name );
- return stringBridge.stringToObject( field.stringValue() );
- }
-
- public String objectToString(Object object) {
- return stringBridge.objectToString( object );
- }
-
- public void set(String name, Object value, Document document, Field.Store store,
Field.Index index, Float boost) {
- String indexedString = stringBridge.objectToString(value);
- //Do not add fields on empty strings, seems a sensible default in most
situations
- if ( StringHelper.isNotEmpty( indexedString ) ) {
- Field field = new Field(name, indexedString, store, index);
- if (boost != null) field.setBoost( boost );
- document.add( field );
- }
- }
-
-
-}
Added:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/String2FieldBridgeAdaptor.java
===================================================================
---
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/String2FieldBridgeAdaptor.java 2006-11-01
04:27:26 UTC (rev 10671)
+++
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/String2FieldBridgeAdaptor.java 2006-11-01
05:46:08 UTC (rev 10672)
@@ -0,0 +1,30 @@
+//$Id: $
+package org.hibernate.lucene.bridge;
+
+import org.apache.lucene.document.Document;
+import org.apache.lucene.document.Field;
+import org.hibernate.util.StringHelper;
+
+/**
+ * Bridge to use a StringBridge as a FieldBridge
+ *
+ * @author Emmanuel Bernard
+ */
+public class String2FieldBridgeAdaptor implements FieldBridge {
+ protected StringBridge stringBridge;
+
+ public String2FieldBridgeAdaptor(StringBridge stringBridge) {
+ this.stringBridge = stringBridge;
+ }
+
+ public void set(String name, Object value, Document document, Field.Store store,
Field.Index index, Float boost) {
+ String indexedString = stringBridge.objectToString( value );
+ //Do not add fields on empty strings, seems a sensible default in most situations
+ if ( StringHelper.isNotEmpty( indexedString ) ) {
+ Field field = new Field( name, indexedString, store, index );
+ if ( boost != null ) field.setBoost( boost );
+ document.add( field );
+ }
+ }
+
+}
Copied:
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/String2IdFieldBridgeAdaptor.java
(from rev 10611,
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/String2FieldBridgeAdaptor.java)
===================================================================
---
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/String2FieldBridgeAdaptor.java 2006-10-18
22:09:34 UTC (rev 10611)
+++
branches/Lucene_Integration/HibernateExt/metadata/src/java/org/hibernate/lucene/bridge/String2IdFieldBridgeAdaptor.java 2006-11-01
05:46:08 UTC (rev 10672)
@@ -0,0 +1,27 @@
+//$Id: $
+package org.hibernate.lucene.bridge;
+
+import org.apache.lucene.document.Document;
+import org.apache.lucene.document.Field;
+import org.hibernate.util.StringHelper;
+
+/**
+ * Bridge to use a StringBridge as a IdFieldBridge
+ *
+ * @author Emmanuel Bernard
+ */
+public class String2IdFieldBridgeAdaptor extends String2FieldBridgeAdaptor implements
IdFieldBridge {
+
+ public String2IdFieldBridgeAdaptor(StringBridge stringBridge) {
+ super(stringBridge);
+ }
+
+ public String objectToString(Object object) {
+ return stringBridge.objectToString( object );
+ }
+
+ public Object get(String name, Document document) {
+ Field field = document.getField( name );
+ return stringBridge.stringToObject( field.stringValue() );
+ }
+}
Show replies by date