org.opencms.xml.content
Class CmsXmlContentErrorHandler

java.lang.Object
  extended by org.opencms.xml.content.CmsXmlContentErrorHandler

public class CmsXmlContentErrorHandler
extends java.lang.Object

Handler for issues found during XML content validation.

Since:
6.0.0
Version:
$Revision: 1.17 $
Author:
Alexander Kandzior

Constructor Summary
CmsXmlContentErrorHandler()
          Create a new instance of the validation handler.
 
Method Summary
 void addError(I_CmsXmlContentValue value, java.lang.String message)
          Adds an error message to the internal list of errors, also raised the "has errors" flag.
 void addWarning(I_CmsXmlContentValue value, java.lang.String message)
          Adds an warning message to the internal list of errors, also raised the "has warning" flag.
 java.util.Map<java.util.Locale,java.util.Map<java.lang.String,java.lang.String>> getErrors()
          Returns the map of validation errors.
 java.util.Map<java.lang.String,java.lang.String> getErrors(java.util.Locale locale)
          Returns the Map of errors for the selected locale.
 java.util.Map<java.util.Locale,java.util.Map<java.lang.String,java.lang.String>> getWarnings()
          Returns the map of validation warnings.
 java.util.Map<java.lang.String,java.lang.String> getWarnings(java.util.Locale locale)
          Returns the Map of warnings for the selected locale.
 boolean hasErrors()
          Returns true if the validated content had errors.
 boolean hasErrors(java.util.Locale locale)
          Returns true if there is at last one error in the selected locale.
 boolean hasWarnings()
          Returns true if the validated content has warnings.
 boolean hasWarnings(java.util.Locale locale)
          Returns true if there is at last one warning in the selected locale.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CmsXmlContentErrorHandler

public CmsXmlContentErrorHandler()
Create a new instance of the validation handler.

Method Detail

addError

public void addError(I_CmsXmlContentValue value,
                     java.lang.String message)
Adds an error message to the internal list of errors, also raised the "has errors" flag.

Parameters:
value - the value that contains the error
message - the error message to add

addWarning

public void addWarning(I_CmsXmlContentValue value,
                       java.lang.String message)
Adds an warning message to the internal list of errors, also raised the "has warning" flag.

Parameters:
value - the value that contians the warning
message - the warning message to add

getErrors

public java.util.Map<java.util.Locale,java.util.Map<java.lang.String,java.lang.String>> getErrors()
Returns the map of validation errors.

The map contains further maps. The key of the "first" map is the Locale of the language where issues where found. The key of the "second" map is a mapping from the element node name obtained with I_CmsXmlContentValue.getPath() to the error message which is a String.

Returns:
the map of validation errors

getErrors

public java.util.Map<java.lang.String,java.lang.String> getErrors(java.util.Locale locale)
Returns the Map of errors for the selected locale.

Parameters:
locale - the locale to get the errors for
Returns:
the Map of errors for the selected locale

getWarnings

public java.util.Map<java.util.Locale,java.util.Map<java.lang.String,java.lang.String>> getWarnings()
Returns the map of validation warnings.

The map contains further maps. The key of the "first" map is the Locale of the language where issues where found. The key of the "second" map is a mapping from the element node name obtained with I_CmsXmlContentValue.getPath() to the error message which is a String.

Returns:
the map of validation warnings

getWarnings

public java.util.Map<java.lang.String,java.lang.String> getWarnings(java.util.Locale locale)
Returns the Map of warnings for the selected locale.

Parameters:
locale - the locale to get the warnings for
Returns:
the Map of warnings for the selected locale

hasErrors

public boolean hasErrors()
Returns true if the validated content had errors.

Returns:
true if the validated content had errors

hasErrors

public boolean hasErrors(java.util.Locale locale)
Returns true if there is at last one error in the selected locale.

Parameters:
locale - the locale to check
Returns:
true if there is at last one error in the selected locale

hasWarnings

public boolean hasWarnings()
Returns true if the validated content has warnings.

Returns:
true if the validated content had warnings

hasWarnings

public boolean hasWarnings(java.util.Locale locale)
Returns true if there is at last one warning in the selected locale.

Parameters:
locale - the locale to check
Returns:
true if there is at last one warning in the selected locale