Skip to content

Commit

Permalink
HSEARCH-834 Applying code style and replacing System.out calls with l…
Browse files Browse the repository at this point in the history
…og.debug
  • Loading branch information
hferentschik committed Aug 25, 2011
1 parent 6fc2334 commit 9a6faed
Show file tree
Hide file tree
Showing 2 changed files with 114 additions and 88 deletions.
Expand Up @@ -89,7 +89,11 @@ public void addOptimizeAll() {

@Override
public void addPurgeAllLuceneWork(String entityClassName) {
Class<?> entityClass = ClassLoaderHelper.classForName( entityClassName, LuceneWorkHydrator.class, "entity class" );
Class<?> entityClass = ClassLoaderHelper.classForName(
entityClassName,
LuceneWorkHydrator.class,
"entity class"
);
results.add( new PurgeAllLuceneWork( entityClass ) );
}

Expand All @@ -105,10 +109,14 @@ public void addId(Serializable id) {

@Override
public void addDeleteLuceneWork(String entityClassName) {
Class<?> entityClass = ClassLoaderHelper.classForName( entityClassName, LuceneWorkHydrator.class, "entity class" );
Class<?> entityClass = ClassLoaderHelper.classForName(
entityClassName,
LuceneWorkHydrator.class,
"entity class"
);
LuceneWork result = new DeleteLuceneWork(
id,
objectIdInString(entityClass, id),
objectIdInString( entityClass, id ),
entityClass
);
results.add( result );
Expand All @@ -117,10 +125,14 @@ public void addDeleteLuceneWork(String entityClassName) {

@Override
public void addAddLuceneWork(String entityClassName, Map<String, String> fieldToAnalyzerMap) {
Class<?> entityClass = ClassLoaderHelper.classForName( entityClassName, LuceneWorkHydrator.class, "entity class" );
Class<?> entityClass = ClassLoaderHelper.classForName(
entityClassName,
LuceneWorkHydrator.class,
"entity class"
);
LuceneWork result = new AddLuceneWork(
id,
objectIdInString(entityClass, id),
objectIdInString( entityClass, id ),
entityClass,
getLuceneDocument(),
fieldToAnalyzerMap
Expand All @@ -131,15 +143,15 @@ public void addAddLuceneWork(String entityClassName, Map<String, String> fieldTo
}

@Override
public void addUpdateLuceneWork(String entityClassName, Map<String, String> fieldToAnalyzerMap) {
public void addUpdateLuceneWork(String entityClassName, Map<String, String> fieldToAnalyzerMap) {
Class<?> entityClass = ClassLoaderHelper.classForName(
entityClassName,
LuceneWorkHydrator.class,
"entity class"
);
LuceneWork result = new UpdateLuceneWork(
id,
objectIdInString(entityClass, id),
objectIdInString( entityClass, id ),
entityClass,
getLuceneDocument(),
fieldToAnalyzerMap
Expand All @@ -160,7 +172,7 @@ public void defineDocument(float boost) {

@Override
public void addFieldable(byte[] instanceAsByte) {
getLuceneDocument().add( ( Fieldable ) toSerializable( instanceAsByte, loader ) );
getLuceneDocument().add( (Fieldable) toSerializable( instanceAsByte, loader ) );
}

@Override
Expand All @@ -170,7 +182,8 @@ public void addIntNumericField(int value, String name, int precisionStep, Serial
precisionStep,
store,
indexed,
boost, omitNorms,
boost,
omitNorms,
omitTermFreqAndPositions
);
numField.setIntValue( value );
Expand All @@ -184,7 +197,8 @@ public void addLongNumericField(long value, String name, int precisionStep, Seri
precisionStep,
store,
indexed,
boost, omitNorms,
boost,
omitNorms,
omitTermFreqAndPositions
);
numField.setLongValue( value );
Expand All @@ -198,7 +212,8 @@ public void addFloatNumericField(float value, String name, int precisionStep, Se
precisionStep,
store,
indexed,
boost, omitNorms,
boost,
omitNorms,
omitTermFreqAndPositions
);
numField.setFloatValue( value );
Expand All @@ -207,10 +222,11 @@ public void addFloatNumericField(float value, String name, int precisionStep, Se

private NumericField buildNumericField(String name, int precisionStep, SerializableStore store, boolean indexed, float boost, boolean omitNorms, boolean omitTermFreqAndPositions) {
NumericField numField = new NumericField(
name,
precisionStep,
getStore( store ),
indexed);
name,
precisionStep,
getStore( store ),
indexed
);
numField.setBoost( boost );
numField.setOmitNorms( omitNorms );
numField.setOmitTermFreqAndPositions( omitTermFreqAndPositions );
Expand All @@ -234,7 +250,7 @@ public void addDoubleNumericField(double value, String name, int precisionStep,

@Override
public void addFieldWithBinaryData(String name, byte[] value, int offset, int length, float boost, boolean omitNorms, boolean omitTermFreqAndPositions) {
Field luceneField = new Field(name, value, offset, length);
Field luceneField = new Field( name, value, offset, length );
setCommonFieldAttributesAddAddToDocument( boost, omitNorms, omitTermFreqAndPositions, luceneField );
}

Expand All @@ -253,13 +269,13 @@ public void addFieldWithStringData(String name, String value, SerializableStore

@Override
public void addFieldWithTokenStreamData(String name, SerializableTermVector termVector, float boost, boolean omitNorms, boolean omitTermFreqAndPositions) {
Field luceneField = new Field( name, new CopyTokenStream(tokens), getTermVector( termVector ) );
Field luceneField = new Field( name, new CopyTokenStream( tokens ), getTermVector( termVector ) );
setCommonFieldAttributesAddAddToDocument( boost, omitNorms, omitTermFreqAndPositions, luceneField );
clearTokens();
}

private void clearTokens() {
tokens = new ArrayList<List<AttributeImpl>>( );
tokens = new ArrayList<List<AttributeImpl>>();
}

@Override
Expand All @@ -271,7 +287,7 @@ public void addFieldWithSerializableReaderData(String name, byte[] valueAsByte,

@Override
public void addSerializedAttribute(byte[] bytes) {
getAttributes().add( ( AttributeImpl ) toSerializable( bytes, loader ) );
getAttributes().add( (AttributeImpl) toSerializable( bytes, loader ) );
}

@Override
Expand All @@ -284,7 +300,7 @@ public void addTokenTrackingAttribute(List<Integer> positions) {
AnalysisRequestHandlerBase.TokenTrackingAttributeImpl attr = new AnalysisRequestHandlerBase.TokenTrackingAttributeImpl();
int size = positions.size() - 1;
int[] basePosition = new int[size];
for(int index = 0 ; index < size ; index++) {
for ( int index = 0; index < size; index++ ) {
basePosition[index] = positions.get( index );
}
attr.reset( basePosition, positions.get( size ) );
Expand All @@ -296,7 +312,7 @@ public void addCharTermAttribute(CharSequence sequence) {
AttributeImpl attr = AttributeSource.AttributeFactory
.DEFAULT_ATTRIBUTE_FACTORY
.createAttributeInstance( CharTermAttribute.class );
( (CharTermAttribute) attr).append( sequence );
( (CharTermAttribute) attr ).append( sequence );
getAttributes().add( attr );
}

Expand All @@ -305,7 +321,7 @@ public void addPayloadAttribute(byte[] payloads) {
AttributeImpl attr = AttributeSource.AttributeFactory
.DEFAULT_ATTRIBUTE_FACTORY
.createAttributeInstance( PayloadAttribute.class );
( (PayloadAttribute) attr).setPayload( new Payload( payloads ) );
( (PayloadAttribute) attr ).setPayload( new Payload( payloads ) );
getAttributes().add( attr );
}

Expand All @@ -314,7 +330,7 @@ public void addKeywordAttribute(boolean isKeyword) {
AttributeImpl attr = AttributeSource.AttributeFactory
.DEFAULT_ATTRIBUTE_FACTORY
.createAttributeInstance( KeywordAttribute.class );
( (KeywordAttribute) attr).setKeyword( isKeyword );
( (KeywordAttribute) attr ).setKeyword( isKeyword );
getAttributes().add( attr );
}

Expand All @@ -323,7 +339,7 @@ public void addPositionIncrementAttribute(int positionIncrement) {
AttributeImpl attr = AttributeSource.AttributeFactory
.DEFAULT_ATTRIBUTE_FACTORY
.createAttributeInstance( PositionIncrementAttribute.class );
( (PositionIncrementAttribute) attr).setPositionIncrement( positionIncrement );
( (PositionIncrementAttribute) attr ).setPositionIncrement( positionIncrement );
getAttributes().add( attr );
}

Expand All @@ -332,7 +348,7 @@ public void addFlagsAttribute(int flags) {
AttributeImpl attr = AttributeSource.AttributeFactory
.DEFAULT_ATTRIBUTE_FACTORY
.createAttributeInstance( FlagsAttribute.class );
( (FlagsAttribute) attr).setFlags( flags );
( (FlagsAttribute) attr ).setFlags( flags );
getAttributes().add( attr );
}

Expand All @@ -341,7 +357,7 @@ public void addTypeAttribute(String type) {
AttributeImpl attr = AttributeSource.AttributeFactory
.DEFAULT_ATTRIBUTE_FACTORY
.createAttributeInstance( TypeAttribute.class );
( (TypeAttribute) attr).setType( type );
( (TypeAttribute) attr ).setType( type );
getAttributes().add( attr );
}

Expand All @@ -350,7 +366,7 @@ public void addOffsetAttribute(int startOffset, int endOffset) {
AttributeImpl attr = AttributeSource.AttributeFactory
.DEFAULT_ATTRIBUTE_FACTORY
.createAttributeInstance( OffsetAttribute.class );
( (OffsetAttribute) attr).setOffset( startOffset, endOffset );
( (OffsetAttribute) attr ).setOffset( startOffset, endOffset );
getAttributes().add( attr );
}

Expand All @@ -361,19 +377,19 @@ public void addToken() {
}

private void clearAttributes() {
attributes = new ArrayList<AttributeImpl>( );
attributes = new ArrayList<AttributeImpl>();
}

private Document getLuceneDocument() {
if (luceneDocument == null) {
if ( luceneDocument == null ) {
luceneDocument = new Document();
}
return luceneDocument;
}

private String objectIdInString(Class<?> entityClass, Serializable id) {
EntityIndexBinder<?> indexBindingForEntity = searchFactory.getIndexBindingForEntity( entityClass );
if (indexBindingForEntity == null) {
if ( indexBindingForEntity == null ) {
throw new SearchException( "Unable to find entity type metadata while deserializing: " + entityClass );
}
DocumentBuilderIndexedEntity<?> documentBuilder = indexBindingForEntity.getDocumentBuilder();
Expand All @@ -392,7 +408,7 @@ private static Field.TermVector getTermVector(SerializableTermVector termVector)
return Field.TermVector.WITH_POSITIONS_OFFSETS;
case YES:
return Field.TermVector.YES;
default:
default:
throw new SearchException( "Unable to convert serializable TermVector to Lucene TermVector: " + termVector );
}
}
Expand Down Expand Up @@ -426,15 +442,15 @@ private static Field.Store getStore(SerializableStore store) {
}

public List<AttributeImpl> getAttributes() {
if (attributes == null) {
if ( attributes == null ) {
attributes = new ArrayList<AttributeImpl>();
}
return attributes;
}

public List<List<AttributeImpl>> getTokens() {
if (tokens == null) {
tokens = new ArrayList<List<AttributeImpl>>( );
if ( tokens == null ) {
tokens = new ArrayList<List<AttributeImpl>>();
}
return tokens;
}
Expand Down

0 comments on commit 9a6faed

Please sign in to comment.