⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wcsexceptionparser.java

📁 esri的ArcGIS Server超级学习模板程序(for java)
💻 JAVA
字号:
/**
 * 
 */
package com.esri.solutions.jitk.datasources.ogc.wcs.parsing.version100;

import java.io.InputStream;

import org.xml.sax.Attributes;
import org.xml.sax.SAXException;

import com.esri.solutions.jitk.datasources.exceptions.ResponseParsingException;
import com.esri.solutions.jitk.datasources.ogc.wcs.Val;
import com.esri.solutions.jitk.datasources.ogc.wcs.info.WCSExceptionInfo;
import com.esri.solutions.jitk.datasources.ogc.wcs.parsing.WCSParserBase;

/**
 * @author vlad2928
 *
 */
public class WCSExceptionParser extends WCSParserBase {

	private boolean _doServiceExceptionReport;
	private boolean _doServiceException;	
	private WCSExceptionInfo _exception;
	private String _exceptionCode;
	private String _exceptionCodeDescription;
	
	public WCSExceptionParser() {
		version = "";
	}
	
	public WCSExceptionInfo parse(InputStream is) throws ResponseParsingException {
		super.parse(is, this);
		return _exception;
	}
	
	@Override
	public void startDocument() throws SAXException {
		_doServiceExceptionReport = _doServiceException = false;
		_exception = null;	
		_characters = null;
	}

	@Override
	public void startElement(String uri, String localName, String name, Attributes atts) throws SAXException {
		
		if(_doServiceExceptionReport) {
			doServiceExceptionReport(name, atts);
		}
		
		if(name.equalsIgnoreCase("ServiceExceptionReport")) {
			_doServiceExceptionReport = true;
			_exception = new WCSExceptionInfo();
		}
	}

	private void doServiceExceptionReport(String name, Attributes atts) {
		
		_characters = new StringBuffer();
		
		if(name.equalsIgnoreCase("ServiceException")) {
			_exceptionCode = Val.chkStr(atts.getValue("code"));
			_exceptionCodeDescription = "";
			
			if(_exceptionCode.length() > 0) {
				
				if(_exceptionCode.equalsIgnoreCase("InvalidFormat")) {
					_exceptionCodeDescription = "Request contains a Format not offered by the service instance.";
					
				} else if(_exceptionCode.equalsIgnoreCase("CoverageNotDefined")) {
					_exceptionCodeDescription = "Request is for a Coverage not offered by the service instance.";
					
				} else if(_exceptionCode.equalsIgnoreCase("CurrentUpdateSequence")) {
					_exceptionCodeDescription = "Value of (optional) UpdateSequence parameter in GetCapabilities request is equal to current value of Capabilities XML update sequence number.";
					
				} else if(_exceptionCode.equalsIgnoreCase("InvalidUpdateSequence")) {
					_exceptionCodeDescription = "Value of (optional) UpdateSequence parameter in GetCapabilities request is greater than current value of Capabilities XML update sequence number.";
					
				} else if(_exceptionCode.equalsIgnoreCase("MissingParameterValue")) {
					_exceptionCodeDescription = "Request does not include a parameter value, and the service instance did not declare a default value for that parameter.";
					
				} else if(_exceptionCode.equalsIgnoreCase("InvalidParameterValue")) {
					_exceptionCodeDescription = "Request contains an invalid parameter value.";
					
				} else {
					_exceptionCodeDescription = "Unknown exception code.";
				}
			}
			
			_doServiceException = true;
		}
	}
	
	@Override
	public void endElement(String uri, String localName, String name) throws SAXException {
		
		if(_doServiceException) {
			if(name.equalsIgnoreCase("ServiceException")) {
				
				StringBuffer message = new StringBuffer();
				
				if(_exceptionCode.length() > 0) {
					message.append("WCS ").append(_exceptionCode).append(" exception: ").append(_exceptionCodeDescription).append("\n");
				}
				message.append(_characters.toString());
				
				_exception.addMessage(message.toString());
				_doServiceException = false;
			}
			
		} else if(name.equalsIgnoreCase("ServiceExceptionReport")) {
			_doServiceExceptionReport = false;
		}
	}

	
	@Override
	public void endDocument() throws SAXException {
		if(_exception == null) {
			_exception = new WCSExceptionInfo();
			_exception.addMessage("WCS unknown exception.");
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -