1 /* 2 * Copyright 2011 Werner Guttmann 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 * 16 */ 17 package org.exolab.castor.builder.info.nature; 18 19 import org.castor.core.nature.BaseNature; 20 import org.exolab.castor.builder.info.FieldInfo; 21 22 /** 23 * A SOLRJ specific view of a {@link FieldInfo}. Implementation based on 24 * property access on {@link FieldInfo}. 25 * 26 * @author Werner Guttmann 27 * @since 1.3.3 28 */ 29 public final class SolrjFieldInfoNature extends BaseNature { 30 31 /** 32 * Constant for the property name for the of the solrj field name. 33 */ 34 private static final String FIELD_NAME = "name"; 35 36 /** 37 * Indicates whether the solrj annotation indicates an Id field. 38 */ 39 private static final String ID_DEFINITION = "idDefinition"; 40 41 /** 42 * Constructor taking a {@link FieldInfo}. 43 * 44 * @param fieldInfo 45 * in focus. 46 */ 47 public SolrjFieldInfoNature(final FieldInfo fieldInfo) { 48 super(fieldInfo); 49 } 50 51 /** 52 * Returns the fully qualified class name of the nature. 53 * 54 * @return the nature id. 55 * @see org.exolab.castor.builder.info.nature.Nature#getId() 56 */ 57 public String getId() { 58 return getClass().getName(); 59 } 60 61 /** 62 * Retrieves the solrj field name. 63 * 64 * @return name of field. 65 */ 66 public String getFieldName() { 67 return (String) this.getProperty(FIELD_NAME); 68 } 69 70 /** 71 * Sets the solrj field name. 72 * 73 * @param fieldName 74 * name of the field. 75 */ 76 public void setFieldName(final String fieldName) { 77 this.setProperty(FIELD_NAME, fieldName); 78 } 79 80 /** 81 * Returns true if the solrj annotation is of type @Id. 82 * 83 * @return true if the solrj annotation is of type @Id. 84 */ 85 public boolean isIdDefinition() { 86 return getBooleanPropertyDefaultFalse(ID_DEFINITION); 87 } 88 89 /** 90 * Sets whether or not the annotated solrj field is of type @Id. 91 * 92 * @param elementDef 93 * The flag indicating whether or not the annotated solrj field 94 * is of type @Id. 95 */ 96 public void setIdDefinition(final boolean idDefinition) { 97 this.setProperty(ID_DEFINITION, new Boolean(idDefinition)); 98 } 99 100 }