Package org.hibernate.search.bridge

Examples of org.hibernate.search.bridge.FieldBridge


   */

  public static TwoWayFieldBridge extractTwoWayType(org.hibernate.search.annotations.FieldBridge fieldBridge,
                            XClass appliedOnType,
                            ReflectionManager reflectionManager) {
    FieldBridge fb = extractType( fieldBridge, appliedOnType, reflectionManager );
    if ( fb instanceof TwoWayFieldBridge ) {
      return (TwoWayFieldBridge) fb;
    }
    else {
      throw new SearchException( "FieldBridge passed in is not an instance of " + TwoWayFieldBridge.class.getSimpleName() );
View Full Code Here


   * @return FieldBridge
   */
  public static FieldBridge extractType(org.hibernate.search.annotations.FieldBridge fieldBridgeAnnotation,
                      XClass appliedOnType,
                      ReflectionManager reflectionManager) {
    FieldBridge bridge = null;

    if ( fieldBridgeAnnotation != null ) {
      bridge = doExtractType( fieldBridgeAnnotation, appliedOnType.getName(), reflectionManager.toClass( appliedOnType ) );
    }

View Full Code Here

    if ( PropertiesMetadata.Container.OBJECT == container ) {
      return new NullEncodingFieldBridge( NULL_EMBEDDED_STRING_BRIDGE, indexNullAs );
    }
    else {
      NumericField numericField = member.getAnnotation( NumericField.class );
      FieldBridge fieldBridge = BridgeFactory.guessType( null, numericField, member, reflectionManager );
      if ( fieldBridge instanceof StringBridge ) {
        fieldBridge = new NullEncodingFieldBridge( (StringBridge) fieldBridge, indexNullAs );
      }
      return fieldBridge;
    }
View Full Code Here

    else if ( indexNullAs.equals( org.hibernate.search.annotations.Field.DEFAULT_NULL_TOKEN ) ) {
      indexNullAs = context.getDefaultNullToken();
    }
    propertiesMetadata.fieldNullTokens.add( indexNullAs );

    FieldBridge fieldBridge = BridgeFactory.guessType( fieldAnn, numericFieldAnn, member, reflectionManager );
    if ( indexNullAs != null && fieldBridge instanceof TwoWayFieldBridge ) {
      fieldBridge = new NullEncodingTwoWayFieldBridge( (TwoWayFieldBridge) fieldBridge, indexNullAs );
    }
    propertiesMetadata.fieldBridges.add( fieldBridge );
View Full Code Here

  }

  public Query createQuery(FieldContext fieldContext) {
    final Query perFieldQuery;
    final DocumentBuilderIndexedEntity<?> documentBuilder = Helper.getDocumentBuilder( queryContext );
    FieldBridge fieldBridge = documentBuilder.getBridge( fieldContext.getField() );
    if ( fieldBridge instanceof NumericFieldBridge ) {
      return NumericFieldUtils.createExactMatchQuery( fieldContext.getField(), value );
    }

    String searchTerm = buildSearchTerm( fieldContext, documentBuilder );
View Full Code Here

        if ( idAnnotation instanceof DocumentId ) {
          explicitDocumentId = true;
        }
        idKeywordName = prefix + attributeName;

        FieldBridge fieldBridge = BridgeFactory.guessType( null, numericFieldAnn, member, reflectionManager );
        if ( fieldBridge instanceof TwoWayFieldBridge ) {
          idBridge = (TwoWayFieldBridge) fieldBridge;
        }
        else {
          throw new SearchException(
View Full Code Here

    // needed for field access: I cannot work in the proxied version
    Object unproxiedInstance = unproxy( instance, objectInitializer );

    // process the class bridges
    for ( int i = 0; i < propertiesMetadata.classBridges.size(); i++ ) {
      FieldBridge fb = propertiesMetadata.classBridges.get( i );
      final String fieldName = propertiesMetadata.classNames.get( i );
      contextualBridge
          .setFieldBridge( fb )
          .setFieldName( fieldName )
          .set(
              fieldName, unproxiedInstance,
              doc, propertiesMetadata.getClassLuceneOptions( i )
          );
    }

    // process the indexed fields
    XMember previousMember = null;
    Object currentFieldValue = null;
    for ( int i = 0; i < propertiesMetadata.fieldNames.size(); i++ ) {
      XMember member = propertiesMetadata.fieldGetters.get( i );
      if ( previousMember != member ) {
        currentFieldValue = ReflectionHelper.getMemberValue( unproxiedInstance, member );
        previousMember = member;
      }

      final FieldBridge fieldBridge = propertiesMetadata.fieldBridges.get( i );
      final String fieldName = propertiesMetadata.fieldNames.get( i );
      contextualBridge
          .setFieldBridge( fieldBridge )
          .pushMethod( member )
          .setFieldName( fieldName )
View Full Code Here

    final String fieldName = fieldContext.getField();
    final Analyzer queryAnalyzer = queryContext.getQueryAnalyzer();

    final DocumentBuilderIndexedEntity<?> documentBuilder = Helper.getDocumentBuilder( queryContext );

    FieldBridge fieldBridge = documentBuilder.getBridge(fieldContext.getField());


    final Object fromObject = rangeContext.getFrom();
    final Object toObject = rangeContext.getTo();

    if (fieldBridge!=null && NumericFieldBridge.class.isAssignableFrom(fieldBridge.getClass())) {
      perFieldQuery = NumericFieldUtils.createNumericRangeQuery(
          fieldName,
          fromObject,
          toObject,
          !rangeContext.isExcludeTo(),
View Full Code Here

  private void processEmbeddedNullValue(Document doc, PropertiesMetadata propertiesMetadata, ContextualExceptionBridge contextualBridge, int i, XMember member, Object value) {
    final String nullMarker = propertiesMetadata.embeddedNullTokens.get( i );
    if ( nullMarker != null ) {
      String fieldName = propertiesMetadata.embeddedNullFields.get( i );
      FieldBridge fieldBridge = propertiesMetadata.embeddedNullFieldBridges.get( i );
      contextualBridge
        .setFieldBridge( fieldBridge )
        .pushMethod( member )
        .setFieldName( fieldName )
        .set( fieldName, value, doc, NULL_EMBEDDED_MARKER_OPTIONS );
View Full Code Here

    }
    if ( fieldName.equals( idKeywordName ) ) {
      return objectToString( idBridge, idKeywordName, value );
    }
    else {
      FieldBridge bridge = getBridge( getMetadata(), fieldName );
      if ( bridge != null ) {
        final Class<? extends FieldBridge> bridgeClass = bridge.getClass();
        if ( TwoWayFieldBridge.class.isAssignableFrom( bridgeClass ) ) {
          return objectToString( (TwoWayFieldBridge) bridge, fieldName, value );
        }
        else if ( StringBridge.class.isAssignableFrom( bridgeClass ) ) {
          return objectToString( (StringBridge) bridge, fieldName, value );
View Full Code Here

TOP

Related Classes of org.hibernate.search.bridge.FieldBridge

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.