001/** 002 * Copyright (C) 2007, Jens Lehmann 003 * 004 * This file is part of DL-Learner. 005 * 006 * DL-Learner is free software; you can redistribute it and/or modify 007 * it under the terms of the GNU General Public License as published by 008 * the Free Software Foundation; either version 3 of the License, or 009 * (at your option) any later version. 010 * 011 * DL-Learner is distributed in the hope that it will be useful, 012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 014 * GNU General Public License for more details. 015 * 016 * You should have received a copy of the GNU General Public License 017 * along with this program. If not, see <http://www.gnu.org/licenses/>. 018 * 019 */ 020package org.dllearner.cli; 021 022import org.dllearner.configuration.IConfigurationProperty; 023 024/** 025 * Programmatic representation of an option setting in a conf file: 026 * bean.property = value; 027 * 028 * @author Jens Lehmann 029 * 030 */ 031public class ConfFileOption implements IConfigurationProperty{ 032 033 // a boolean flag which indicates whether it is a reference to a bean (or set/list of beans) 034 private boolean isBeanRef; 035 036 private boolean isBeanReferenceCollection; 037 038 private String beanName; 039 040 private String propertyName; 041 042 private String propertyValue; 043 044 private Class<?> propertyType; 045 046 // the object should be either a primitive, a Collection<String> or a Map<String,String>, 047 // the actual mapping from Strings to datatypes is later done e.g. by property editors 048 private Object valueObject; 049 050 public ConfFileOption() { 051 052 } 053 054 public String getBeanName() { 055 return beanName; 056 } 057 058 public void setBeanName(String beanName) { 059 this.beanName = beanName; 060 } 061 062 public String getPropertyName() { 063 return propertyName; 064 } 065 066 public void setPropertyName(String propertyName) { 067 this.propertyName = propertyName; 068 } 069 070 public String getPropertyValue() { 071 return propertyValue; 072 } 073 074 public void setPropertyValue(String propertyValue) { 075 this.propertyValue = propertyValue; 076 } 077 078 public Class<?> getPropertyType() { 079 return propertyType; 080 } 081 082 public void setPropertyType(Class<?> propertyType) { 083 this.propertyType = propertyType; 084 } 085 086 public Object getValueObject() { 087 return valueObject; 088 } 089 090 public void setValueObject(Object valueObject) { 091 this.valueObject = valueObject; 092 } 093 094 public boolean isBeanRef() { 095 return isBeanRef; 096 } 097 098 public void setBeanRef(boolean isBeanRef) { 099 this.isBeanRef = isBeanRef; 100 } 101 102 @Override 103 public String getName() { 104 return getPropertyName(); 105 } 106 107 @Override 108 public Object getValue() { 109 return getValueObject(); 110 } 111 112 @Override 113 public boolean isBeanReference() { 114 return isBeanRef(); 115 } 116 117 @Override 118 public boolean isBeanReferenceCollection() { 119 return isBeanReferenceCollection; 120 } 121 122 public void setBeanReferenceCollection(boolean beanReferenceCollection) { 123 isBeanReferenceCollection = beanReferenceCollection; 124 } 125 126 /* (non-Javadoc) 127 * @see java.lang.Object#toString() 128 */ 129 @Override 130 public String toString() { 131 return beanName + "." + propertyName + ";type:" + propertyType.getSimpleName() + ";value:" + propertyValue; 132 } 133}