本文整理汇总了Java中org.springframework.util.AutoPopulatingList类的典型用法代码示例。如果您正苦于以下问题:Java AutoPopulatingList类的具体用法?Java AutoPopulatingList怎么用?Java AutoPopulatingList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AutoPopulatingList类属于org.springframework.util包,在下文中一共展示了AutoPopulatingList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: showErrorMap
import org.springframework.util.AutoPopulatingList; //导入依赖的package包/类
/**
* This method is used during debugging to dump the contents of the error map, including the key names. It is not
* used by the
* application in normal circumstances at all.
*/
protected void showErrorMap() {
if (GlobalVariables.getMessageMap().hasNoErrors()) {
return;
}
for (Iterator i = GlobalVariables.getMessageMap().getAllPropertiesAndErrors().iterator(); i.hasNext(); ) {
Map.Entry e = (Map.Entry) i.next();
AutoPopulatingList errorList = (AutoPopulatingList) e.getValue();
for (Iterator j = errorList.iterator(); j.hasNext(); ) {
ErrorMessage em = (ErrorMessage) j.next();
if (em.getMessageParameters() == null) {
LOG.error(e.getKey().toString() + " = " + em.getErrorKey());
} else {
LOG.error(e.getKey().toString() + " = " + em.getErrorKey() + " : " +
Arrays.toString(em.getMessageParameters()));
}
}
}
}
示例2: showErrorMap
import org.springframework.util.AutoPopulatingList; //导入依赖的package包/类
/**
* This method is used during debugging to dump the contents of the error map, including the key names. It is not
* used by the
* application in normal circumstances at all.
*/
protected void showErrorMap() {
if (GlobalVariables.getMessageMap().hasNoErrors()) {
return;
}
for (Iterator i = GlobalVariables.getMessageMap().getAllPropertiesAndErrors().iterator(); i.hasNext(); ) {
Map.Entry e = (Map.Entry) i.next();
AutoPopulatingList errorList = (AutoPopulatingList) e.getValue();
for (Iterator j = errorList.iterator(); j.hasNext(); ) {
ErrorMessage em = (ErrorMessage) j.next();
if (em.getMessageParameters() == null) {
LOG.error(e.getKey().toString() + " = " + em.getErrorKey());
} else {
LOG.error(e.getKey().toString() + " = " + em.getErrorKey() + " : " +
Arrays.toString(em.getMessageParameters()));
}
}
}
}
示例3: copyAllMessagesHelper
import org.springframework.util.AutoPopulatingList; //导入依赖的package包/类
private void copyAllMessagesHelper(Map<String, AutoPopulatingList<ErrorMessage>> sourceMessages, String type, MessageMap destMap) {
for (String key : sourceMessages.keySet()) {
AutoPopulatingList<ErrorMessage> messages = sourceMessages.get(key);
if (messages != null) {
for (Object o : messages) {
ErrorMessage message = (ErrorMessage) o;
if ("info".equals(type)) {
destMap.putInfoWithoutFullErrorPath(key, message.getErrorKey(), message.getMessageParameters());
}
else if ("warning".equals(type)) {
destMap.putWarningWithoutFullErrorPath(key, message.getErrorKey(), message.getMessageParameters());
}
else if ("error".equals(type)) {
destMap.putErrorWithoutFullErrorPath(key, message.getErrorKey(), message.getMessageParameters());
}
else {
throw new IllegalArgumentException();
}
}
}
}
}
示例4: processContactValidation
import org.springframework.util.AutoPopulatingList; //导入依赖的package包/类
/**
* A stub method as placeholder for future Contact Validation
*
* @param document MaintenanceDocument instance
* @return boolean false or true
*/
private boolean processContactValidation(MaintenanceDocument document) {
boolean valid = true;
int i = 0;
for (VendorContact contact : newVendor.getVendorContacts()) {
String errorPath = MAINTAINABLE_ERROR_PREFIX + VendorPropertyConstants.VENDOR_CONTACT + "[" + i + "]";
GlobalVariables.getMessageMap().addToErrorPath(errorPath);
this.getDictionaryValidationService().validateBusinessObject(contact);
Map<String, AutoPopulatingList<ErrorMessage>> errors = GlobalVariables.getMessageMap().getErrorMessages();
if ((errors != null ) && (!errors.isEmpty())) {
valid = false;
}
i++;
GlobalVariables.getMessageMap().clearErrorPath();
}
return valid;
}
示例5: showMessageMap
import org.springframework.util.AutoPopulatingList; //导入依赖的package包/类
/**
*
* This method is used during debugging to dump the contents of the error map, including the key names. It is not used by the
* application in normal circumstances at all.
*
*/
private void showMessageMap() {
if (GlobalVariables.getMessageMap().hasErrors()) {
return;
}
Set<String> errorMapKeys = ((Map<String, String>) GlobalVariables.getMessageMap()).keySet();
AutoPopulatingList<ErrorMessage> errorMapEntry;
for (String errorMapKey : errorMapKeys) {
errorMapEntry = (AutoPopulatingList<ErrorMessage>) (GlobalVariables.getMessageMap()).getMessages(errorMapKey);
for (ErrorMessage errorMessage : errorMapEntry) {
if (errorMessage.getMessageParameters() == null) {
LOG.error("[" + errorMapKey + "] " + errorMessage.getErrorKey());
}
else {
LOG.error("[" + errorMapKey + "] " + errorMessage.getErrorKey() + " == " + parseStringArray(errorMessage.getMessageParameters()));
}
}
}
}
示例6: showErrorMap
import org.springframework.util.AutoPopulatingList; //导入依赖的package包/类
/**
* This method is used during debugging to dump the contents of the error map, including the key names. It is not
* used by the
* application in normal circumstances at all.
*/
protected void showErrorMap() {
if (GlobalVariables.getMessageMap().hasNoErrors()) {
return;
}
for (Iterator i = GlobalVariables.getMessageMap().getAllPropertiesAndErrors().iterator(); i.hasNext(); ) {
Map.Entry e = (Map.Entry) i.next();
AutoPopulatingList errorList = (AutoPopulatingList) e.getValue();
for (Iterator j = errorList.iterator(); j.hasNext(); ) {
ErrorMessage em = (ErrorMessage) j.next();
if (em.getMessageParameters() == null) {
LOG.error(e.getKey().toString() + " = " + em.getErrorKey());
} else {
LOG.error(e.getKey().toString() + " = " + em.getErrorKey() + " : " +
em.getMessageParameters().toString());
}
}
}
}
示例7: SerializerServiceBase
import org.springframework.util.AutoPopulatingList; //导入依赖的package包/类
public SerializerServiceBase() {
serializationStates = new ThreadLocal<SerializationState>();
evaluators = new ThreadLocal<PropertySerializabilityEvaluator>();
xstream = new XStream(new ProxyAndStateAwareJavaReflectionProvider());
xstream.registerConverter(new ProxyConverter(xstream.getMapper(), xstream.getReflectionProvider() ));
try {
Class<?> objListProxyClass = Class.forName("org.apache.ojb.broker.core.proxy.ListProxyDefaultImpl");
xstream.addDefaultImplementation(ArrayList.class, objListProxyClass);
xstream.addDefaultImplementation(AutoPopulatingList.class, objListProxyClass);
} catch ( Exception ex ) {
// Do nothing - this will blow if the OJB class does not exist, which it won't in some installs
}
xstream.registerConverter(new AutoPopulatingListConverter(xstream.getMapper()));
xstream.registerConverter(new DateTimeConverter());
}
示例8: showErrorMap
import org.springframework.util.AutoPopulatingList; //导入依赖的package包/类
/**
* This method is used during debugging to dump the contents of the error map, including the key names. It is not
* used by the
* application in normal circumstances at all.
*/
protected void showErrorMap() {
if (GlobalVariables.getMessageMap().hasNoErrors()) {
return;
}
for (Iterator i = GlobalVariables.getMessageMap().getAllPropertiesAndErrors().iterator(); i.hasNext(); ) {
Map.Entry e = (Map.Entry) i.next();
AutoPopulatingList errorList = (AutoPopulatingList) e.getValue();
for (Iterator j = errorList.iterator(); j.hasNext(); ) {
ErrorMessage em = (ErrorMessage) j.next();
if (em.getMessageParameters() == null) {
LOG.error(e.getKey().toString() + " = " + em.getErrorKey());
} else {
LOG.error(e.getKey().toString() + " = " + em.getErrorKey() + " : " +
em.getMessageParameters().toString());
}
}
}
}
示例9: testRetrieveMessage_namespaceKey
import org.springframework.util.AutoPopulatingList; //导入依赖的package包/类
/**
* Test that message text is correctly retrieved for a validation message specified by namespace and
* message key
*/
@Test
public void testRetrieveMessage_namespaceKey() throws Exception {
ErrorMessage errorMessage = new ErrorMessage();
errorMessage.setNamespaceCode("KR-NS");
errorMessage.setErrorKey("testErrorKey");
messageMap.putError("field1", errorMessage);
AutoPopulatingList<ErrorMessage> fieldErrors = messageMap.getErrorMessagesForProperty("field1");
assertEquals("Incorrect number of messages for field1", 1, fieldErrors.size());
ErrorMessage message = fieldErrors.get(0);
String messageText = KRADUtils.getMessageText(message, true);
assertEquals("Message for field1 is not correct", "Error on field1", messageText);
}
示例10: testRetrieveMessage_componentKey
import org.springframework.util.AutoPopulatingList; //导入依赖的package包/类
/**
* Test that message text is correctly retrieved for a validation message specified by namespace,
* component, and message key
*/
@Test
public void testRetrieveMessage_componentKey() throws Exception {
ErrorMessage errorMessage = new ErrorMessage();
errorMessage.setNamespaceCode("KR-NS");
errorMessage.setComponentCode("GeneralGroup");
errorMessage.setErrorKey("testErrorKey");
messageMap.putError("field1", errorMessage);
AutoPopulatingList<ErrorMessage> fieldErrors = messageMap.getErrorMessagesForProperty("field1");
assertEquals("Incorrect number of messages for field1", 1, fieldErrors.size());
ErrorMessage message = fieldErrors.get(0);
String messageText = KRADUtils.getMessageText(message, true);
assertEquals("Message for field1 is not correct", "Error on field1", messageText);
}
示例11: getMessages
import org.springframework.util.AutoPopulatingList; //导入依赖的package包/类
/**
* Gets all the messages from the list of lists passed in (which are
* lists of ErrorMessages associated to the key) and uses the configuration
* service to get the message String associated. This will also combine
* error messages per a field if that option is turned on. If
* displayFieldLabelWithMessages is turned on, it will also find the label
* by key passed in.
*
* @param view
* @param key
* @param lists
* @return
*/
private List<String> getMessages(View view, String key, List<AutoPopulatingList<ErrorMessage>> lists) {
List<String> result = new ArrayList<String>();
for (List<ErrorMessage> errorList : lists) {
if (errorList != null && StringUtils.isNotBlank(key)) {
for (ErrorMessage e : errorList) {
String message = KRADUtils.getMessageText(e, true);
message = MessageStructureUtils.translateStringMessage(message);
result.add(message);
}
}
}
return result;
}
示例12: merge
import org.springframework.util.AutoPopulatingList; //导入依赖的package包/类
/**
* Takes one message map and merges it into another. Makes sure there are no duplicates.
*
* @param messagesFrom
* @param messagesTo
*/
public void merge(Map<String, AutoPopulatingList<ErrorMessage>> messagesFrom,
Map<String, AutoPopulatingList<ErrorMessage>> messagesTo) {
for (String key : messagesFrom.keySet()) {
if (messagesTo.containsKey(key)) {
// now we need to merge the messages
AutoPopulatingList<ErrorMessage> tal = messagesFrom.get(key);
AutoPopulatingList<ErrorMessage> parentList = messagesTo.get(key);
for (Object o : tal) {
if (!parentList.contains(o)) {
parentList.add((ErrorMessage) o);
}
}
} else {
messagesTo.put(key, messagesFrom.get(key));
}
}
}
示例13: containsMessageKey
import org.springframework.util.AutoPopulatingList; //导入依赖的package包/类
/**
* @return true if the given messageKey is associated with some property in this ErrorMap
*/
public boolean containsMessageKey(String messageKey) {
ErrorMessage foundMessage = null;
if (!hasNoErrors()) {
for (Iterator<Map.Entry<String, AutoPopulatingList<ErrorMessage>>> i =
getAllPropertiesAndErrors().iterator(); (foundMessage == null) && i.hasNext(); ) {
Map.Entry<String, AutoPopulatingList<ErrorMessage>> e = i.next();
AutoPopulatingList<ErrorMessage> entryErrorList = e.getValue();
for (Iterator<ErrorMessage> j = entryErrorList.iterator(); j.hasNext(); ) {
ErrorMessage em = j.next();
if (messageKey.equals(em.getErrorKey())) {
foundMessage = em;
}
}
}
}
return (foundMessage != null);
}
示例14: getErrorMessagesForProperty
import org.springframework.util.AutoPopulatingList; //导入依赖的package包/类
/**
* Gets a list of lists that represent errors that matched by the
* propertyName passed in (multiple lists because the wildcard can match
* multiple keys). If wildcard is true, the propertyName ends with a
* wildcard character. Otherwise, it will only match on the single key and
* return a list with one list
*
* @param propertyName
* @param allowWildcard
* @return
*/
public List<AutoPopulatingList<ErrorMessage>> getErrorMessagesForProperty(String propertyName,
boolean allowWildcard) {
List<AutoPopulatingList<ErrorMessage>> foundMessages = new ArrayList<AutoPopulatingList<ErrorMessage>>();
if (allowWildcard) {
boolean wildcard = false;
if (propertyName.endsWith("*")) {
wildcard = true;
propertyName = propertyName.substring(0, propertyName.length() - 1);
}
for (Iterator<String> keys = errorMessages.keySet().iterator(); keys.hasNext(); ) {
String key = keys.next();
if (!wildcard && propertyName.equals(key)) {
foundMessages.add(errorMessages.get(key));
break;
} else if (wildcard && key.startsWith(propertyName)) {
foundMessages.add(errorMessages.get(key));
}
}
} else {
foundMessages.add(getErrorMessagesForProperty(propertyName));
}
return foundMessages;
}
示例15: getWarningMessagesForProperty
import org.springframework.util.AutoPopulatingList; //导入依赖的package包/类
/**
* Gets a list of lists that represent warnings that matched by the
* propertyName passed in (multiple lists because the wildcard can match
* multiple keys). If wildcard is true, the propertyName ends with a
* wildcard character. Otherwise, it will only match on the single key and
* return a list with one list.
*
* @param propertyName
* @param allowWildcard
* @return
*/
public List<AutoPopulatingList<ErrorMessage>> getWarningMessagesForProperty(String propertyName,
boolean allowWildcard) {
List<AutoPopulatingList<ErrorMessage>> foundMessages = new ArrayList<AutoPopulatingList<ErrorMessage>>();
if (allowWildcard) {
boolean wildcard = false;
if (propertyName.endsWith("*")) {
wildcard = true;
propertyName = propertyName.substring(0, propertyName.length() - 1);
}
for (Iterator<String> keys = warningMessages.keySet().iterator(); keys.hasNext(); ) {
String key = keys.next();
if (!wildcard && propertyName.equals(key)) {
foundMessages.add(warningMessages.get(key));
break;
} else if (wildcard && key.startsWith(propertyName)) {
foundMessages.add(warningMessages.get(key));
}
}
} else {
foundMessages.add(getWarningMessagesForProperty(propertyName));
}
return foundMessages;
}