本文整理汇总了Java中org.springframework.beans.PropertyAccessorUtils.getLastNestedPropertySeparatorIndex方法的典型用法代码示例。如果您正苦于以下问题:Java PropertyAccessorUtils.getLastNestedPropertySeparatorIndex方法的具体用法?Java PropertyAccessorUtils.getLastNestedPropertySeparatorIndex怎么用?Java PropertyAccessorUtils.getLastNestedPropertySeparatorIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.beans.PropertyAccessorUtils
的用法示例。
在下文中一共展示了PropertyAccessorUtils.getLastNestedPropertySeparatorIndex方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: linkAddedLine
import org.springframework.beans.PropertyAccessorUtils; //导入方法依赖的package包/类
/**
* Set the parent for bi-directional relationships when adding a line to a collection.
*
* @param model the view data
* @param collectionPath the path to the collection being linked
* @param addedIndex the index of the added line
* @return whether the linked line needs further processing
*/
protected boolean linkAddedLine(Object model, String collectionPath, int addedIndex) {
int lastSepIndex = PropertyAccessorUtils.getLastNestedPropertySeparatorIndex(collectionPath);
if (lastSepIndex != -1) {
String collectionParentPath = collectionPath.substring(0, lastSepIndex);
Object parent = ObjectPropertyUtils.getPropertyValue(model, collectionParentPath);
if (parent != null && getDataObjectService().supports(parent.getClass())) {
DataObjectWrapper<?> wrappedParent = getDataObjectService().wrap(parent);
String collectionName = collectionPath.substring(lastSepIndex + 1);
wrappedParent.linkChanges(Sets.newHashSet(collectionName + "[" + addedIndex + "]"));
}
// check if its edit line in dialog line action, and if it is we want to set the collection as
// the dialog's parent and do not want further processing of the dialog object
if (collectionParentPath.equalsIgnoreCase(UifPropertyPaths.DIALOG_DATA_OBJECT)) {
((UifFormBase) model).setDialogDataObject(parent);
return false;
}
}
return true;
}
示例2: isPersonProperty
import org.springframework.beans.PropertyAccessorUtils; //导入方法依赖的package包/类
private boolean isPersonProperty(Object bo, String propertyName) {
try {
if (PropertyAccessorUtils.isNestedOrIndexedProperty( propertyName ) // is a nested property
&& !StringUtils.contains(propertyName, "add.") ) {// exclude add line properties (due to path parsing problems in PropertyUtils.getPropertyType)
int lastIndex = PropertyAccessorUtils.getLastNestedPropertySeparatorIndex(propertyName);
String propertyTypeName = lastIndex != -1 ? StringUtils.substring(propertyName, 0, lastIndex) : StringUtils.EMPTY;
Class<?> type = PropertyUtils.getPropertyType(bo, propertyTypeName);
// property type indicates a Person object
if ( type != null ) {
return Person.class.isAssignableFrom(type);
}
LOG.warn( "Unable to determine type of nested property: " + bo.getClass().getName() + " / " + propertyName );
}
} catch (Exception ex) {
if ( LOG.isDebugEnabled() ) {
LOG.debug("Unable to determine if property on " + bo.getClass().getName() + " to a person object: " + propertyName, ex );
}
}
return false;
}
示例3: PropertyPath
import org.springframework.beans.PropertyAccessorUtils; //导入方法依赖的package包/类
/**
* <p>Constructor for PropertyPath.</p>
*
* @param nestedPath a {@link java.lang.String} object.
*/
public PropertyPath(String nestedPath) {
String canonicalPath = PropertyAccessorUtils.canonicalPropertyName(nestedPath);
int lastIndex = PropertyAccessorUtils.getLastNestedPropertySeparatorIndex(canonicalPath);
if (lastIndex < 0) {
propertyName = PropertyAccessorUtils.getPropertyName(canonicalPath);
key = computeKey(canonicalPath);
}
else {
parent = new PropertyPath(canonicalPath.substring(0, lastIndex));
String lastProperty = canonicalPath.substring(lastIndex+1);
propertyName = PropertyAccessorUtils.getPropertyName(lastProperty);
key = computeKey(lastProperty);
}
}
示例4: getNestedAttributePrefix
import org.springframework.beans.PropertyAccessorUtils; //导入方法依赖的package包/类
/**
* Returns the prefix of a nested attribute name, or the empty string if the attribute name is not nested.
*
* @param attributeName
* @return everything BEFORE the last "." character in attributeName
*/
public static String getNestedAttributePrefix(String attributeName) {
int lastIndex = PropertyAccessorUtils.getLastNestedPropertySeparatorIndex(attributeName);
return lastIndex != -1 ? StringUtils.substring(attributeName, 0, lastIndex) : StringUtils.EMPTY;
}
示例5: getNestedAttributePrimitive
import org.springframework.beans.PropertyAccessorUtils; //导入方法依赖的package包/类
/**
* Returns the primitive part of an attribute name string.
*
* @param attributeName
* @return everything AFTER the last "." character in attributeName
*/
public static String getNestedAttributePrimitive(String attributeName) {
int lastIndex = PropertyAccessorUtils.getLastNestedPropertySeparatorIndex(attributeName);
return lastIndex != -1 ? StringUtils.substring(attributeName, lastIndex + 1) : attributeName;
}