[prev in list] [next in list] [prev in thread] [next in thread]
List: xerces-cvs
Subject: svn commit: r699922 -
From: mrglavas () apache ! org
Date: 2008-09-28 23:36:38
Message-ID: 20080928233638.CB84923889FC () eris ! apache ! org
[Download RAW message or body]
Author: mrglavas
Date: Sun Sep 28 16:36:38 2008
New Revision: 699922
URL: http://svn.apache.org/viewvc?rev=699922&view=rev
Log:
Factored out DOMException handling to eliminate a lot of duplicate code.
Modified:
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/dom/DOMConfigurationImpl.java
Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/dom/DOMConfigurationImpl.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/dom/DOMConfigurationImpl.java?rev=699922&r1=699921&r2=699922&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/dom/DOMConfigurationImpl.java \
(original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/dom/DOMConfigurationImpl.java \
Sun Sep 28 16:36:38 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
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic