You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by mr...@apache.org on 2008/09/29 01:36:09 UTC
svn commit: r699921 -
/xerces/java/trunk/src/org/apache/xerces/dom/DOMConfigurationImpl.java
Author: mrglavas
Date: Sun Sep 28 16:36:09 2008
New Revision: 699921
URL: http://svn.apache.org/viewvc?rev=699921&view=rev
Log:
Factored out DOMException handling to eliminate a lot of duplicate code.
Modified:
xerces/java/trunk/src/org/apache/xerces/dom/DOMConfigurationImpl.java
Modified: xerces/java/trunk/src/org/apache/xerces/dom/DOMConfigurationImpl.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/dom/DOMConfigurationImpl.java?rev=699921&r1=699920&r2=699921&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/dom/DOMConfigurationImpl.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/dom/DOMConfigurationImpl.java Sun Sep 28 16:36:09 2008
@@ -680,22 +680,12 @@
|| name.equalsIgnoreCase(Constants.DOM_CHECK_CHAR_NORMALIZATION)
) {
if (state) { // true is not supported
- String msg =
- DOMMessageFormatter.formatMessage(
- DOMMessageFormatter.DOM_DOMAIN,
- "FEATURE_NOT_SUPPORTED",
- new Object[] { name });
- throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
+ throw newFeatureNotSupportedError(name);
}
}
else if ( name.equalsIgnoreCase(Constants.DOM_ELEMENT_CONTENT_WHITESPACE)) {
if (!state) { // false is not supported
- String msg =
- DOMMessageFormatter.formatMessage(
- DOMMessageFormatter.DOM_DOMAIN,
- "FEATURE_NOT_SUPPORTED",
- new Object[] { name });
- throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
+ throw newFeatureNotSupportedError(name);
}
}
else if (name.equalsIgnoreCase(SEND_PSVI) ){
@@ -703,12 +693,7 @@
// because in this case we won't be able to retrieve element
// default value.
if (!state) { // false is not supported
- String msg =
- DOMMessageFormatter.formatMessage(
- DOMMessageFormatter.DOM_DOMAIN,
- "FEATURE_NOT_SUPPORTED",
- new Object[] { name });
- throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
+ throw newFeatureNotSupportedError(name);
}
}
else if (name.equalsIgnoreCase(Constants.DOM_PSVI)){
@@ -736,15 +721,8 @@
fErrorHandlerWrapper.setErrorHandler((DOMErrorHandler)value);
setErrorHandler(fErrorHandlerWrapper);
}
-
else {
- // REVISIT: type mismatch
- String msg =
- DOMMessageFormatter.formatMessage(
- DOMMessageFormatter.DOM_DOMAIN,
- "TYPE_MISMATCH_ERR",
- new Object[] { name });
- throw new DOMException(DOMException.TYPE_MISMATCH_ERR, msg);
+ throw newTypeMismatchError(name);
}
}
else if (name.equalsIgnoreCase(Constants.DOM_RESOURCE_RESOLVER)) {
@@ -755,15 +733,8 @@
catch (XMLConfigurationException e) {}
}
else {
- // REVISIT: type mismatch
- String msg =
- DOMMessageFormatter.formatMessage(
- DOMMessageFormatter.DOM_DOMAIN,
- "TYPE_MISMATCH_ERR",
- new Object[] { name });
- throw new DOMException(DOMException.TYPE_MISMATCH_ERR, msg);
+ throw newTypeMismatchError(name);
}
-
}
else if (name.equalsIgnoreCase(Constants.DOM_SCHEMA_LOCATION)) {
if (value instanceof String || value == null) {
@@ -799,15 +770,8 @@
catch (XMLConfigurationException e) {}
}
else {
- // REVISIT: type mismatch
- String msg =
- DOMMessageFormatter.formatMessage(
- DOMMessageFormatter.DOM_DOMAIN,
- "TYPE_MISMATCH_ERR",
- new Object[] { name });
- throw new DOMException(DOMException.TYPE_MISMATCH_ERR, msg);
+ throw newTypeMismatchError(name);
}
-
}
else if (name.equalsIgnoreCase(Constants.DOM_SCHEMA_TYPE)) {
if (value instanceof String || value == null) {
@@ -832,14 +796,8 @@
catch (XMLConfigurationException e) {}
}
else {
- String msg =
- DOMMessageFormatter.formatMessage(
- DOMMessageFormatter.DOM_DOMAIN,
- "TYPE_MISMATCH_ERR",
- new Object[] { name });
- throw new DOMException(DOMException.TYPE_MISMATCH_ERR, msg);
+ throw newTypeMismatchError(name);
}
-
}
else if (name.equalsIgnoreCase(ENTITY_RESOLVER)) {
if (value instanceof XMLEntityResolver || value == null) {
@@ -849,12 +807,7 @@
catch (XMLConfigurationException e) {}
}
else {
- String msg =
- DOMMessageFormatter.formatMessage(
- DOMMessageFormatter.DOM_DOMAIN,
- "TYPE_MISMATCH_ERR",
- new Object[] { name });
- throw new DOMException(DOMException.TYPE_MISMATCH_ERR, msg);
+ throw newTypeMismatchError(name);
}
}
else if (name.equalsIgnoreCase(SYMBOL_TABLE)) {
@@ -863,13 +816,7 @@
setProperty(SYMBOL_TABLE, value);
}
else {
- // REVISIT: type mismatch
- String msg =
- DOMMessageFormatter.formatMessage(
- DOMMessageFormatter.DOM_DOMAIN,
- "TYPE_MISMATCH_ERR",
- new Object[] { name });
- throw new DOMException(DOMException.TYPE_MISMATCH_ERR, msg);
+ throw newTypeMismatchError(name);
}
}
else if (name.equalsIgnoreCase (GRAMMAR_POOL)) {
@@ -877,13 +824,7 @@
setProperty(GRAMMAR_POOL, value);
}
else {
- // REVISIT: type mismatch
- String msg =
- DOMMessageFormatter.formatMessage(
- DOMMessageFormatter.DOM_DOMAIN,
- "TYPE_MISMATCH_ERR",
- new Object[] { name });
- throw new DOMException(DOMException.TYPE_MISMATCH_ERR, msg);
+ throw newTypeMismatchError(name);
}
}
else if (name.equalsIgnoreCase (SECURITY_MANAGER)) {
@@ -891,27 +832,15 @@
setProperty(SECURITY_MANAGER, value);
}
else {
- // REVISIT: type mismatch
- String msg =
- DOMMessageFormatter.formatMessage(
- DOMMessageFormatter.DOM_DOMAIN,
- "TYPE_MISMATCH_ERR",
- new Object[] { name });
- throw new DOMException(DOMException.TYPE_MISMATCH_ERR, msg);
+ throw newTypeMismatchError(name);
}
}
else {
// REVISIT: check if this is a boolean parameter -- type mismatch should be thrown.
//parameter is not recognized
- String msg =
- DOMMessageFormatter.formatMessage(
- DOMMessageFormatter.DOM_DOMAIN,
- "FEATURE_NOT_FOUND",
- new Object[] { name });
- throw new DOMException(DOMException.NOT_FOUND_ERR, msg);
+ throw newFeatureNotFoundError(name);
}
}
-
}
@@ -1000,14 +929,8 @@
return getProperty(SECURITY_MANAGER);
}
else {
- String msg =
- DOMMessageFormatter.formatMessage(
- DOMMessageFormatter.DOM_DOMAIN,
- "FEATURE_NOT_FOUND",
- new Object[] { name });
- throw new DOMException(DOMException.NOT_FOUND_ERR, msg);
+ throw newFeatureNotFoundError(name);
}
-
}
/**
@@ -1251,5 +1174,32 @@
setProperty(DTD_VALIDATOR_FACTORY_PROPERTY, fCurrentDVFactory);
}
}
+
+ private static DOMException newFeatureNotSupportedError(String name) {
+ String msg =
+ DOMMessageFormatter.formatMessage(
+ DOMMessageFormatter.DOM_DOMAIN,
+ "FEATURE_NOT_SUPPORTED",
+ new Object[] { name });
+ throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
+ }
+
+ private static DOMException newFeatureNotFoundError(String name) {
+ String msg =
+ DOMMessageFormatter.formatMessage(
+ DOMMessageFormatter.DOM_DOMAIN,
+ "FEATURE_NOT_FOUND",
+ new Object[] { name });
+ throw new DOMException(DOMException.NOT_FOUND_ERR, msg);
+ }
+
+ private static DOMException newTypeMismatchError(String name) {
+ String msg =
+ DOMMessageFormatter.formatMessage(
+ DOMMessageFormatter.DOM_DOMAIN,
+ "TYPE_MISMATCH_ERR",
+ new Object[] { name });
+ return new DOMException(DOMException.TYPE_MISMATCH_ERR, msg);
+ }
-} // class XMLParser
+} // class DOMConfigurationImpl
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org