📄 tableproperties.java
字号:
* Getter for the <code>PROPERTY_STRING_EXPORTBANNER_SEPARATOR</code> property.
* @return String
*/
public String getExportBannerSeparator()
{
return getProperty(PROPERTY_STRING_EXPORTBANNER_SEPARATOR);
}
/**
* Getter for the <code>PROPERTY_BOOLEAN_SHOWHEADER</code> property.
* @return boolean
*/
public boolean getShowHeader()
{
return getBooleanProperty(PROPERTY_BOOLEAN_SHOWHEADER);
}
/**
* Getter for the <code>PROPERTY_STRING_EMPTYLIST_MESSAGE</code> property.
* @return String
*/
public String getEmptyListMessage()
{
return getProperty(PROPERTY_STRING_EMPTYLIST_MESSAGE);
}
/**
* Getter for the <code>PROPERTY_STRING_EMPTYLISTROW_MESSAGE</code> property.
* @return String
*/
public String getEmptyListRowMessage()
{
return getProperty(PROPERTY_STRING_EMPTYLISTROW_MESSAGE);
}
/**
* Getter for the <code>PROPERTY_BOOLEAN_EMPTYLIST_SHOWTABLE</code> property.
* @return boolean <code>true</code> if table should be displayed also if no items are found
*/
public boolean getEmptyListShowTable()
{
return getBooleanProperty(PROPERTY_BOOLEAN_EMPTYLIST_SHOWTABLE);
}
/**
* Getter for the <code>PROPERTY_STRING_EXPORTAMOUNT</code> property.
* @return boolean <code>true</code> if <code>export.amount</code> is <code>list</code>
*/
public boolean getExportFullList()
{
return "list".equals(getProperty(PROPERTY_STRING_EXPORTAMOUNT)); //$NON-NLS-1$
}
/**
* Getter for the <code>PROPERTY_STRING_SORTAMOUNT</code> property.
* @return boolean <code>true</code> if <code>sort.amount</code> is <code>list</code>
*/
public boolean getSortFullList()
{
return "list".equals(getProperty(PROPERTY_STRING_SORTAMOUNT)); //$NON-NLS-1$
}
/**
* Should paging banner be added before the table?
* @return boolean
*/
public boolean getAddPagingBannerTop()
{
String placement = getProperty(PROPERTY_STRING_BANNER_PLACEMENT);
return "top".equals(placement) || "both".equals(placement); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* Should paging banner be added after the table?
* @return boolean
*/
public boolean getAddPagingBannerBottom()
{
String placement = getProperty(PROPERTY_STRING_BANNER_PLACEMENT);
return "bottom".equals(placement) || "both".equals(placement); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
* Returns the appropriate css class for a table row.
* @param rowNumber row number
* @return the value of <code>PROPERTY_CSS_TR_EVEN</code> if rowNumber is even or <code>PROPERTY_CSS_TR_ODD</code>
* if rowNumber is odd.
*/
public String getCssRow(int rowNumber)
{
return getProperty((rowNumber % 2 == 0) ? PROPERTY_CSS_TR_ODD : PROPERTY_CSS_TR_EVEN);
}
/**
* Returns the appropriate css class for a sorted column header.
* @param ascending <code>true</code> if column is sorded in ascending order.
* @return the value of <code>PROPERTY_CSS_TH_SORTED_ASCENDING</code> if column is sorded in ascending order or
* <code>PROPERTY_CSS_TH_SORTED_DESCENDING</code> if column is sorded in descending order.
*/
public String getCssOrder(boolean ascending)
{
return getProperty(ascending ? PROPERTY_CSS_TH_SORTED_ASCENDING : PROPERTY_CSS_TH_SORTED_DESCENDING);
}
/**
* Returns the configured css class for a sorted column header.
* @return the value of <code>PROPERTY_CSS_TH_SORTED</code>
*/
public String getCssSorted()
{
return getProperty(PROPERTY_CSS_TH_SORTED);
}
/**
* Returns the configured css class for the main table tag.
* @return the value of <code>PROPERTY_CSS_TABLE</code>
*/
public String getCssTable()
{
return getProperty(PROPERTY_CSS_TABLE);
}
/**
* Returns the configured css class for a sortable column header.
* @return the value of <code>PROPERTY_CSS_TH_SORTABLE</code>
*/
public String getCssSortable()
{
return getProperty(PROPERTY_CSS_TH_SORTABLE);
}
/**
* Returns the configured list of media.
* @return the value of <code>PROPERTY_EXPORTTYPES</code>
*/
public String[] getExportTypes()
{
String list = getProperty(PROPERTY_EXPORTTYPES);
if (list == null)
{
return new String[0];
}
return StringUtils.split(list);
}
/**
* Returns the class responsible for the given export.
* @param exportName export name
* @return String classname
*/
public String getExportClass(String exportName)
{
return getProperty(PROPERTY_EXPORT_PREFIX + SEP + exportName + SEP + EXPORTPROPERTY_STRING_CLASS);
}
/**
* Returns an instance of configured requestHelperFactory.
* @return RequestHelperFactory instance.
* @throws FactoryInstantiationException if unable to load or instantiate the configurated class.
*/
public RequestHelperFactory getRequestHelperFactoryInstance() throws FactoryInstantiationException
{
Object loadedObject = getClassPropertyInstance(PROPERTY_CLASS_REQUESTHELPERFACTORY);
// should not be null, but avoid errors just in case... see DISPL-148
if (loadedObject == null)
{
return new DefaultRequestHelperFactory();
}
try
{
return (RequestHelperFactory) loadedObject;
}
catch (ClassCastException e)
{
throw new FactoryInstantiationException(getClass(), PROPERTY_CLASS_REQUESTHELPERFACTORY, loadedObject
.getClass()
.getName(), e);
}
}
/**
* Returns an instance of configured DecoratorFactory.
* @return DecoratorFactory instance.
* @throws FactoryInstantiationException if unable to load or instantiate the configurated class.
*/
public DecoratorFactory getDecoratorFactoryInstance() throws FactoryInstantiationException
{
Object loadedObject = getClassPropertyInstance(PROPERTY_CLASS_DECORATORFACTORY);
if (loadedObject == null)
{
return new DefaultDecoratorFactory();
}
try
{
return (DecoratorFactory) loadedObject;
}
catch (ClassCastException e)
{
throw new FactoryInstantiationException(getClass(), PROPERTY_CLASS_DECORATORFACTORY, loadedObject
.getClass()
.getName(), e);
}
}
public String getPaginationSortParam()
{
String result = getProperty(PROPERTY_STRING_PAGINATION_SORT_PARAM);
if (result == null)
{
result = "sort";
}
return result;
}
public String getPaginationPageNumberParam()
{
String result = getProperty(PROPERTY_STRING_PAGINATION_PAGE_NUMBER_PARAM);
if (result == null)
{
result = "page";
}
return result;
}
public String getPaginationSortDirectionParam()
{
String result = getProperty(PROPERTY_STRING_PAGINATION_SORT_DIRECTION_PARAM);
if (result == null)
{
result = "dir";
}
return result;
}
public String getPaginationSearchIdParam()
{
String result = getProperty(PROPERTY_STRING_PAGINATION_SEARCH_ID_PARAM);
if (result == null)
{
result = "searchId";
}
return result;
}
public String getPaginationAscValue()
{
String result = getProperty(PROPERTY_STRING_PAGINATION_ASC_VALUE);
if (result == null)
{
result = "asc";
}
return result;
}
public String getPaginationDescValue()
{
String result = getProperty(PROPERTY_STRING_PAGINATION_DESC_VALUE);
if (result == null)
{
result = "desc";
}
return result;
}
public boolean getPaginationSkipPageNumberInSort()
{
String s = getProperty(PROPERTY_BOOLEAN_PAGINATION_SKIP_PAGE_NUMBER_IN_SORT);
if (s == null)
{
return true;
}
else
{
return getBooleanProperty(PROPERTY_BOOLEAN_PAGINATION_SKIP_PAGE_NUMBER_IN_SORT);
}
}
// </JBN>
/**
* Returns the configured resource provider instance. If necessary instantiate the resource provider from config and
* then keep a cached instance.
* @return I18nResourceProvider instance.
* @see I18nResourceProvider
*/
public I18nResourceProvider geResourceProvider()
{
String className = getProperty(PROPERTY_CLASS_LOCALEPROVIDER);
if (resourceProvider == null)
{
if (className != null)
{
try
{
Class classProperty = ReflectHelper.classForName(className);
resourceProvider = (I18nResourceProvider) classProperty.newInstance();
log.info(Messages.getString("TableProperties.classinitializedto", //$NON-NLS-1$
new Object[]{ClassUtils.getShortClassName(I18nResourceProvider.class), className}));
}
catch (Throwable e)
{
log.warn(Messages.getString("TableProperties.errorloading", //$NON-NLS-1$
new Object[]{
ClassUtils.getShortClassName(I18nResourceProvider.class),
e.getClass().getName(),
e.getMessage()}));
}
}
else
{
log.info(Messages.getString("TableProperties.noconfigured", //$NON-NLS-1$
new Object[]{ClassUtils.getShortClassName(I18nResourceProvider.class)}));
}
// still null?
if (resourceProvider == null)
{
// fallback provider, no i18n
resourceProvider = new I18nResourceProvider()
{
// Always returns null
public String getResource(String titleKey, String property, Tag tag, PageContext context)
{
return null;
}
};
}
}
return resourceProvider;
}
/**
* Reads a String property.
* @param key property name
* @return property value or <code>null</code> if property is not found
*/
private String getProperty(String key)
{
return this.properties.getProperty(key);
}
/**
* Sets a property.
* @param key property name
* @param value property value
*/
public void setProperty(String key, String value)
{
this.properties.setProperty(key, value);
}
/**
* Reads a boolean property.
* @param key property name
* @return boolean <code>true</code> if the property value is "true", <code>false</code> for any other value.
*/
private boolean getBooleanProperty(String key)
{
return Boolean.TRUE.toString().equals(getProperty(key));
}
/**
* Returns an instance of a configured Class. Returns a configured Class instantiated
* callingClass.forName([configuration value]).
* @param key configuration key
* @return instance of configured class
* @throws FactoryInstantiationException if unable to load or instantiate the configurated class.
*/
private Object getClassPropertyInstance(String key) throws FactoryInstantiationException
{
Object instance = objectCache.get(key);
if (instance != null)
{
return instance;
}
String className = getProperty(key);
// shouldn't be null, but better check it
if (className == null)
{
return null;
}
try
{
Class classProperty = ReflectHelper.classForName(className);
instance = classProperty.newInstance();
objectCache.put(key, instance);
return instance;
}
catch (Exception e)
{
throw new FactoryInstantiationException(getClass(), key, className, e);
}
}
/**
* Reads an int property.
* @param key property name
* @param defaultValue default value returned if property is not found or not a valid int value
* @return property value
*/
private int getIntProperty(String key, int defaultValue)
{
try
{
return Integer.parseInt(getProperty(key));
}
catch (NumberFormatException e)
{
// Don't care, use default
log.warn(Messages.getString("TableProperties.invalidvalue", //$NON-NLS-1$
new Object[]{key, getProperty(key), new Integer(defaultValue)}));
}
return defaultValue;
}
/**
* Obtain the name of the decorator configured for a given media type.
* @param thatEnum A media type
* @return The name of the decorator configured for a given media type.
*/
public String getExportDecoratorName(MediaTypeEnum thatEnum)
{
return getProperty(PROPERTY_EXPORT_PREFIX + SEP + thatEnum + SEP + PROPERTY_EXPORT_DECORATOR_SUFFIX);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -