| Package: MachII.util |
| Inherits from: util.Exception |
| Encapsulates XML validation exception information. |
<!--- License: Copyright 2006 Mach-II Corporation Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Copyright: Mach-II Corporation Author: Ben Edwards (ben@ben-edwards.com) $Id: XmlValidationException.cfc $ Created version: 1.1.0 ---> |
| Method Summary | |
|---|---|
| public string | getDtdPath() |
| public array | getErrors() |
| public array | getFatalErrors() |
| public string |
getFormattedMessage()
Gets a message from the errors/warnings for display. |
| public array | getWarnings() |
| public string | getXmlPath() |
| public void | setDtdPath([string dtdPath]) |
| public void | setErrors([array errors]) |
| public void | setFatalErrors([array fatalErrors]) |
| public void | setWarnings([array warnings]) |
| public void | setXmlPath([string xmlPath]) |
| public XmlValidationException |
wrapValidationResult(struct validationResult, [string xmlPath=""], [string dtdPath=""])
Wraps the result of a failed XML validation. |
| Methods inherited from util.Exception: init , wrapException , setDetail , getDetail , setTagContext , getCaughtException , getType , getExtendedInfo , getErrorCode , setErrorCode , setType , setCaughtException , setMessage , getMessage , getTagContext , setExtendedInfo |
|---|
| Method Detail |
|---|
| getDtdPath |
|---|
public string getDtdPath( )
Parameters:
Code:
<cffunction name="getDtdPath" access="public" returntype="string" output="false"> <cfreturn variables.dtdPath /> </cffunction>
| getErrors |
|---|
public array getErrors( )
Parameters:
Code:
<cffunction name="getErrors" access="public" returntype="array" output="false"> <cfreturn variables.errors /> </cffunction>
| getFatalErrors |
|---|
public array getFatalErrors( )
Parameters:
Code:
<cffunction name="getFatalErrors" access="public" returntype="array" output="false"> <cfreturn variables.fatalErrors /> </cffunction>
| getFormattedMessage |
|---|
public string getFormattedMessage( )
Gets a message from the errors/warnings for display.
Parameters:
Code:
<cffunction name="getFormattedMessage" access="public" returntype="string" output="false" hint="Gets a message from the errors/warnings for display."> <cfset var rawMessage = "" /> <cfset var formattedMessage = "" /> <cfif ArrayLen(variables.fatalErrors) GT 0> <cfset rawMessage = variables.fatalErrors[1] /> <cfelseif ArrayLen(variables.errors) GT 0> <cfset rawMessage = variables.errors[1] /> <cfelseif ArrayLen(variables.warnings) GT 0> <cfset rawMessage = variables.warnings[1] /> <cfelse> <cfthrow type="MachII.framework.NoMessagesDefined" message="There are no XML validation error messages defined. Cannot display a formatted message." /> </cfif> <cfset formattedMessage = "Error validating XML file: " /> <cfif getXmlPath() NEQ ''> <cfset formattedMessage = formattedMessage & getXmlPath() & ": " /> </cfif> <cfset formattedMessage = formattedMessage & "Line " & ListGetAt(rawMessage,2,':') & ", " /> <cfset formattedMessage = formattedMessage & "Column " & ListGetAt(rawMessage,3,':') & ": " /> <cfset formattedMessage = formattedMessage & ListGetAt(rawMessage,4,':') /> <cfif ListLen(rawMessage, ":") GTE 5> <cfset formattedMessage = formattedMessage & " - " & ListGetAt(rawMessage,5,':') /> </cfif> <cfreturn formattedMessage /> </cffunction>
| getWarnings |
|---|
public array getWarnings( )
Parameters:
Code:
<cffunction name="getWarnings" access="public" returntype="array" output="false"> <cfreturn variables.warnings /> </cffunction>
| getXmlPath |
|---|
public string getXmlPath( )
Parameters:
Code:
<cffunction name="getXmlPath" access="public" returntype="string" output="false"> <cfreturn variables.xmlPath /> </cffunction>
| setDtdPath |
|---|
public void setDtdPath( [string dtdPath] )
Parameters:
| [string dtdPath] |
Code:
<cffunction name="setDtdPath" access="public" returntype="void" output="false"> <cfargument name="dtdPath" type="string" required="false" /> <cfset variables.dtdPath = arguments.dtdPath /> </cffunction>
| setErrors |
|---|
public void setErrors( [array errors] )
Parameters:
| [array errors] |
Code:
<cffunction name="setErrors" access="public" returntype="void" output="false"> <cfargument name="errors" type="array" required="false" /> <cfset variables.errors = arguments.errors /> </cffunction>
| setFatalErrors |
|---|
public void setFatalErrors( [array fatalErrors] )
Parameters:
| [array fatalErrors] |
Code:
<cffunction name="setFatalErrors" access="public" returntype="void" output="false"> <cfargument name="fatalErrors" type="array" required="false" /> <cfset variables.fatalErrors = arguments.fatalErrors /> </cffunction>
| setWarnings |
|---|
public void setWarnings( [array warnings] )
Parameters:
| [array warnings] |
Code:
<cffunction name="setWarnings" access="public" returntype="void" output="false"> <cfargument name="warnings" type="array" required="false" /> <cfset variables.warnings = arguments.warnings /> </cffunction>
| setXmlPath |
|---|
public void setXmlPath( [string xmlPath] )
Parameters:
| [string xmlPath] |
Code:
<cffunction name="setXmlPath" access="public" returntype="void" output="false"> <cfargument name="xmlPath" type="string" required="false" /> <cfset variables.xmlPath = arguments.xmlPath /> </cffunction>
| wrapValidationResult |
|---|
public XmlValidationException wrapValidationResult( struct validationResult, [string xmlPath=""], [string dtdPath=""] )
Wraps the result of a failed XML validation.
Parameters:
| struct validationResult |
| [string xmlPath=""] |
| [string dtdPath=""] |
Code:
<cffunction name="wrapValidationResult" access="public" returntype="XmlValidationException" output="false" hint="Wraps the result of a failed XML validation."> <cfargument name="validationResult" type="struct" required="true" hint="A struct in the format returned by XmlValidate()." /> <cfargument name="xmlPath" type="string" required="false" default="" hint="The full path the XML file that was validated." /> <cfargument name="dtdPath" type="string" required="false" default="" hint="The full path the DTD file used for validation." /> <cfset setFatalErrors(arguments.validationResult.fatalErrors) /> <cfset setErrors(arguments.validationResult.errors) /> <cfset setWarnings(arguments.validationResult.warnings) /> <cfset setXmlPath(arguments.xmlPath) /> <cfset setDtdPath(arguments.dtdPath) /> <cfreturn this /> </cffunction>