You are viewing a plain text version of this content. The canonical link for it is here.
Posted to woden-dev@ws.apache.org by jk...@apache.org on 2005/12/06 05:10:59 UTC
svn commit: r354286 - in /incubator/woden/java/src/org/apache/woden:
internal/xml/ xml/
Author: jkaputin
Date: Mon Dec 5 20:10:39 2005
New Revision: 354286
URL: http://svn.apache.org/viewcvs?rev=354286&view=rev
Log:
code improvements and additions to Attr classes used
for extension attributes.
Added:
incubator/woden/java/src/org/apache/woden/internal/xml/BooleanAttrImpl.java
incubator/woden/java/src/org/apache/woden/xml/BooleanAttr.java
Modified:
incubator/woden/java/src/org/apache/woden/internal/xml/QNameAttrImpl.java
incubator/woden/java/src/org/apache/woden/internal/xml/QNameListAttrImpl.java
incubator/woden/java/src/org/apache/woden/internal/xml/StringAttrImpl.java
incubator/woden/java/src/org/apache/woden/internal/xml/URIAttrImpl.java
incubator/woden/java/src/org/apache/woden/internal/xml/XMLAttrImpl.java
incubator/woden/java/src/org/apache/woden/xml/QNameAttr.java
incubator/woden/java/src/org/apache/woden/xml/QNameListAttr.java
incubator/woden/java/src/org/apache/woden/xml/StringAttr.java
incubator/woden/java/src/org/apache/woden/xml/URIAttr.java
incubator/woden/java/src/org/apache/woden/xml/XMLAttr.java
Added: incubator/woden/java/src/org/apache/woden/internal/xml/BooleanAttrImpl.java
URL: http://svn.apache.org/viewcvs/incubator/woden/java/src/org/apache/woden/internal/xml/BooleanAttrImpl.java?rev=354286&view=auto
==============================================================================
--- incubator/woden/java/src/org/apache/woden/internal/xml/BooleanAttrImpl.java (added)
+++ incubator/woden/java/src/org/apache/woden/internal/xml/BooleanAttrImpl.java Mon Dec 5 20:10:39 2005
@@ -0,0 +1,82 @@
+/**
+ * Copyright 2005 Apache Software Foundation
+ *
+ * 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.
+ */
+package org.apache.woden.internal.xml;
+
+import org.apache.woden.ErrorReporter;
+import org.apache.woden.WSDLException;
+import org.apache.woden.internal.ErrorLocatorImpl;
+import org.apache.woden.xml.BooleanAttr;
+import org.w3c.dom.Element;
+
+
+/**
+ * This class represents XML attribute information items of type xs:boolean.
+ * If the attribute value is not "true" or "false" the Boolean content will
+ * be initialized to "false" by default, but the isValid() method will
+ * return "false".
+ *
+ * @author jkaputin@apache.org
+ */
+public class BooleanAttrImpl extends XMLAttrImpl implements BooleanAttr
+{
+ public BooleanAttrImpl() {}
+
+ /*
+ * TODO This ctor is not used for extension attributes, but may be useful if
+ * parsing of native WSDL attributes is changed to use the XMLAttr interface.
+ */
+ public BooleanAttrImpl(Element ownerEl, String attrValue, ErrorReporter errRpt)
+ throws WSDLException
+ {
+ super(ownerEl, attrValue, errRpt);
+ }
+
+ /* ************************************************************
+ * BooleanAttr interface declared methods
+ * ************************************************************/
+
+ public Boolean getBoolean() {
+ return (Boolean)getContent();
+ }
+
+ /* ************************************************************
+ * Non-API implementation methods
+ * ************************************************************/
+
+ /*
+ * Convert a string of type xs:boolean to a java.lang.Boolean.
+ * An empty string or a null argument will initialize the Boolean to false.
+ * Any conversion error will be reported and will initialize the Boolean to false.
+ * If the attrValue does not match the Boolean value the Attr is marked invalid.
+ */
+ protected Object convert(Element ownerEl, String attrValue) throws WSDLException
+ {
+ Boolean bool = Boolean.valueOf(attrValue);
+
+ if(attrValue == null || !attrValue.equals(bool.toString()) )
+ {
+ setValid(false);
+ getErrorReporter().reportError(
+ new ErrorLocatorImpl(), //TODO line&col nos.
+ "WSDL511",
+ new Object[] {attrValue},
+ ErrorReporter.SEVERITY_ERROR);
+ }
+
+ return bool;
+ }
+
+}
Modified: incubator/woden/java/src/org/apache/woden/internal/xml/QNameAttrImpl.java
URL: http://svn.apache.org/viewcvs/incubator/woden/java/src/org/apache/woden/internal/xml/QNameAttrImpl.java?rev=354286&r1=354285&r2=354286&view=diff
==============================================================================
--- incubator/woden/java/src/org/apache/woden/internal/xml/QNameAttrImpl.java (original)
+++ incubator/woden/java/src/org/apache/woden/internal/xml/QNameAttrImpl.java Mon Dec 5 20:10:39 2005
@@ -38,10 +38,10 @@
* TODO This ctor is not used for extension attributes, but may be useful if
* parsing of native WSDL attributes is changed to use the XMLAttr interface.
*/
- public QNameAttrImpl(Element ownerEl, String qnValue, ErrorReporter errRpt)
+ public QNameAttrImpl(Element ownerEl, String attrValue, ErrorReporter errRpt)
throws WSDLException
{
- super(ownerEl, qnValue, errRpt);
+ super(ownerEl, attrValue, errRpt);
}
/* ************************************************************
@@ -61,16 +61,16 @@
* A a null argument will return a null value.
* Any conversion error will be reported and a null value will be returned.
*/
- protected Object convert(Element ownerEl, String qnValue) throws WSDLException
+ protected Object convert(Element ownerEl, String attrValue) throws WSDLException
{
Exception ex = null;
QName qn = null;
- if(qnValue != null)
+ if(attrValue != null)
{
try
{
- qn = DOMUtils.getQName(qnValue, ownerEl);
+ qn = DOMUtils.getQName(attrValue, ownerEl);
}
catch (WSDLException e)
{
@@ -80,10 +80,11 @@
if(qn == null)
{
+ setValid(false);
getErrorReporter().reportError(
new ErrorLocatorImpl(), //TODO line&col nos.
"WSDL507",
- new Object[] {qnValue},
+ new Object[] {attrValue},
ErrorReporter.SEVERITY_ERROR,
ex);
}
Modified: incubator/woden/java/src/org/apache/woden/internal/xml/QNameListAttrImpl.java
URL: http://svn.apache.org/viewcvs/incubator/woden/java/src/org/apache/woden/internal/xml/QNameListAttrImpl.java?rev=354286&r1=354285&r2=354286&view=diff
==============================================================================
--- incubator/woden/java/src/org/apache/woden/internal/xml/QNameListAttrImpl.java (original)
+++ incubator/woden/java/src/org/apache/woden/internal/xml/QNameListAttrImpl.java Mon Dec 5 20:10:39 2005
@@ -43,10 +43,10 @@
* TODO This ctor is not used for extension attributes, but may be useful if
* parsing of native WSDL attributes is changed to use the XMLAttr interface.
*/
- public QNameListAttrImpl(Element ownerEl, String qnValue, ErrorReporter errRpt)
+ public QNameListAttrImpl(Element ownerEl, String attrValue, ErrorReporter errRpt)
throws WSDLException
{
- super(ownerEl, qnValue, errRpt);
+ super(ownerEl, attrValue, errRpt);
}
/* ************************************************************
@@ -69,19 +69,20 @@
* be converted, but the object will be marked invalid. If no QName strings can
* be converted, a null value will be returned.
*/
- protected Object convert(Element ownerEl, String qnamesString) throws WSDLException
+ protected Object convert(Element ownerEl, String attrValue) throws WSDLException
{
- if(qnamesString == null || "".equals(qnamesString))
+ if(attrValue == null || "".equals(attrValue))
{
+ setValid(false);
getErrorReporter().reportError(
new ErrorLocatorImpl(), //TODO line&col nos.
"WSDL509",
- new Object[] {qnamesString},
+ new Object[] {attrValue},
ErrorReporter.SEVERITY_ERROR);
return null;
}
- List qnStrings = StringUtils.parseNMTokens(qnamesString);
+ List qnStrings = StringUtils.parseNMTokens(attrValue);
Iterator i = qnStrings.iterator();
String qnString = null;
QName qname = null;
@@ -96,10 +97,11 @@
}
catch (WSDLException e)
{
+ setValid(false);
getErrorReporter().reportError(
new ErrorLocatorImpl(), //TODO line&col nos.
"WSDL510",
- new Object[] {qnString, qnamesString},
+ new Object[] {qnString, attrValue},
ErrorReporter.SEVERITY_ERROR,
e);
continue;
Modified: incubator/woden/java/src/org/apache/woden/internal/xml/StringAttrImpl.java
URL: http://svn.apache.org/viewcvs/incubator/woden/java/src/org/apache/woden/internal/xml/StringAttrImpl.java?rev=354286&r1=354285&r2=354286&view=diff
==============================================================================
--- incubator/woden/java/src/org/apache/woden/internal/xml/StringAttrImpl.java (original)
+++ incubator/woden/java/src/org/apache/woden/internal/xml/StringAttrImpl.java Mon Dec 5 20:10:39 2005
@@ -35,10 +35,10 @@
* TODO This ctor is not used for extension attributes, but may be useful if
* parsing of native WSDL attributes is changed to use the XMLAttr interface.
*/
- public StringAttrImpl(Element ownerEl, String strValue, ErrorReporter errRpt)
+ public StringAttrImpl(Element ownerEl, String attrValue, ErrorReporter errRpt)
throws WSDLException
{
- super(ownerEl, strValue, errRpt);
+ super(ownerEl, attrValue, errRpt);
}
/* ************************************************************
@@ -58,17 +58,18 @@
* A null argument will return a null value.
* Any conversion error will be reported and a null value will be returned.
*/
- protected Object convert(Element ownerEl, String strValue) throws WSDLException
+ protected Object convert(Element ownerEl, String attrValue) throws WSDLException
{
Exception ex = null;
- String str = strValue;
+ String str = attrValue;
if(str == null)
{
+ setValid(false);
getErrorReporter().reportError(
new ErrorLocatorImpl(), //TODO line&col nos.
"WSDL508",
- new Object[] {strValue},
+ new Object[] {attrValue},
ErrorReporter.SEVERITY_ERROR);
}
return str;
Modified: incubator/woden/java/src/org/apache/woden/internal/xml/URIAttrImpl.java
URL: http://svn.apache.org/viewcvs/incubator/woden/java/src/org/apache/woden/internal/xml/URIAttrImpl.java?rev=354286&r1=354285&r2=354286&view=diff
==============================================================================
--- incubator/woden/java/src/org/apache/woden/internal/xml/URIAttrImpl.java (original)
+++ incubator/woden/java/src/org/apache/woden/internal/xml/URIAttrImpl.java Mon Dec 5 20:10:39 2005
@@ -38,10 +38,10 @@
* TODO This ctor is not used for extension attributes, but may be useful if
* parsing of native WSDL attributes is changed to use the XMLAttr interface.
*/
- public URIAttrImpl(Element ownerEl, String uriValue, ErrorReporter errRpt)
+ public URIAttrImpl(Element ownerEl, String attrValue, ErrorReporter errRpt)
throws WSDLException
{
- super(ownerEl, uriValue, errRpt);
+ super(ownerEl, attrValue, errRpt);
}
/* ************************************************************
@@ -62,16 +62,16 @@
* A null argument will return a null value.
* Any conversion error will be reported and a null value will be returned.
*/
- protected Object convert(Element ownerEl, String uriValue) throws WSDLException
+ protected Object convert(Element ownerEl, String attrValue) throws WSDLException
{
Exception ex = null;
URI uri = null;
- if(uriValue != null)
+ if(attrValue != null)
{
try
{
- uri = new URI(uriValue);
+ uri = new URI(attrValue);
}
catch (URISyntaxException e)
{
@@ -81,10 +81,11 @@
if(uri == null)
{
+ setValid(false);
getErrorReporter().reportError(
new ErrorLocatorImpl(), //TODO line&col nos.
"WSDL506",
- new Object[] {uriValue},
+ new Object[] {attrValue},
ErrorReporter.SEVERITY_ERROR,
ex);
}
Modified: incubator/woden/java/src/org/apache/woden/internal/xml/XMLAttrImpl.java
URL: http://svn.apache.org/viewcvs/incubator/woden/java/src/org/apache/woden/internal/xml/XMLAttrImpl.java?rev=354286&r1=354285&r2=354286&view=diff
==============================================================================
--- incubator/woden/java/src/org/apache/woden/internal/xml/XMLAttrImpl.java (original)
+++ incubator/woden/java/src/org/apache/woden/internal/xml/XMLAttrImpl.java Mon Dec 5 20:10:39 2005
@@ -32,7 +32,7 @@
{
protected Object fContent = null;
protected String fExternalForm = null;
- protected boolean fValid = false;
+ protected boolean fValid = true;
private ErrorReporter fErrorReporter = null;
protected XMLAttrImpl() {}
Added: incubator/woden/java/src/org/apache/woden/xml/BooleanAttr.java
URL: http://svn.apache.org/viewcvs/incubator/woden/java/src/org/apache/woden/xml/BooleanAttr.java?rev=354286&view=auto
==============================================================================
--- incubator/woden/java/src/org/apache/woden/xml/BooleanAttr.java (added)
+++ incubator/woden/java/src/org/apache/woden/xml/BooleanAttr.java Mon Dec 5 20:10:39 2005
@@ -0,0 +1,30 @@
+/**
+ * Copyright 2005 Apache Software Foundation
+ *
+ * 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.
+ */
+package org.apache.woden.xml;
+
+
+/**
+ * This interface represents XML attribute information items of type xs:boolean.
+ * If the attribute value is not "true" or "false" the Boolean content will
+ * be initialized to "false" by default, but the isValid() method will
+ * return "false".
+ *
+ * @author jkaputin@apache.org
+ */
+public interface BooleanAttr extends XMLAttr
+{
+ public Boolean getBoolean();
+}
Modified: incubator/woden/java/src/org/apache/woden/xml/QNameAttr.java
URL: http://svn.apache.org/viewcvs/incubator/woden/java/src/org/apache/woden/xml/QNameAttr.java?rev=354286&r1=354285&r2=354286&view=diff
==============================================================================
--- incubator/woden/java/src/org/apache/woden/xml/QNameAttr.java (original)
+++ incubator/woden/java/src/org/apache/woden/xml/QNameAttr.java Mon Dec 5 20:10:39 2005
@@ -19,6 +19,9 @@
/**
* This interface represents XML attribute information items of type xs:QName.
+ * If the attribute's string value cannot be converted into a QName object the
+ * getContent() and getQName() methods will return null and isValid() will return
+ * false.
*
* @author jkaputin@apache.org
*/
Modified: incubator/woden/java/src/org/apache/woden/xml/QNameListAttr.java
URL: http://svn.apache.org/viewcvs/incubator/woden/java/src/org/apache/woden/xml/QNameListAttr.java?rev=354286&r1=354285&r2=354286&view=diff
==============================================================================
--- incubator/woden/java/src/org/apache/woden/xml/QNameListAttr.java (original)
+++ incubator/woden/java/src/org/apache/woden/xml/QNameListAttr.java Mon Dec 5 20:10:39 2005
@@ -19,7 +19,12 @@
/**
* This interface represents XML attribute information items of type
- * xs:list of QNames.
+ * xs:list of QNames. The string is converted into a collection of QNames,
+ * one for each valid name in the string. The QNames can be retrieved as an
+ * array of QName. If an error occurs converting a QName it will not be included
+ * in the array and the isValid() method will return false (even if there are
+ * some valid QNames in the list). If no qnames can be converted from the string,
+ * getContent() and getQNames() will return null and isValid() will return false.
*
* @author jkaputin@apache.org
*/
Modified: incubator/woden/java/src/org/apache/woden/xml/StringAttr.java
URL: http://svn.apache.org/viewcvs/incubator/woden/java/src/org/apache/woden/xml/StringAttr.java?rev=354286&r1=354285&r2=354286&view=diff
==============================================================================
--- incubator/woden/java/src/org/apache/woden/xml/StringAttr.java (original)
+++ incubator/woden/java/src/org/apache/woden/xml/StringAttr.java Mon Dec 5 20:10:39 2005
@@ -18,6 +18,8 @@
/**
* This interface represents XML attribute information items of type xs:string.
+ * If the object is initialized with a null value, the getContents() and getString()
+ * methods will return null and isValid() will return false.
*
* @author jkaputin@apache.org
*/
Modified: incubator/woden/java/src/org/apache/woden/xml/URIAttr.java
URL: http://svn.apache.org/viewcvs/incubator/woden/java/src/org/apache/woden/xml/URIAttr.java?rev=354286&r1=354285&r2=354286&view=diff
==============================================================================
--- incubator/woden/java/src/org/apache/woden/xml/URIAttr.java (original)
+++ incubator/woden/java/src/org/apache/woden/xml/URIAttr.java Mon Dec 5 20:10:39 2005
@@ -19,6 +19,8 @@
/**
* This interface represents XML attribute information items of type xs:anyURI.
+ * If the attribute value cannot be converted into a java.net.URI the getContent()
+ * and getURI() methods will return null and isValid() will return false.
*
* @author jkaputin@apache.org
*/
Modified: incubator/woden/java/src/org/apache/woden/xml/XMLAttr.java
URL: http://svn.apache.org/viewcvs/incubator/woden/java/src/org/apache/woden/xml/XMLAttr.java?rev=354286&r1=354285&r2=354286&view=diff
==============================================================================
--- incubator/woden/java/src/org/apache/woden/xml/XMLAttr.java (original)
+++ incubator/woden/java/src/org/apache/woden/xml/XMLAttr.java Mon Dec 5 20:10:39 2005
@@ -20,7 +20,13 @@
import org.w3c.dom.Element;
/**
- * This interface represents XML attribute information items.
+ * This interface represents an XML attribute information item. It can be initialized
+ * with the string value of an attribute and the implementation must convert the string into
+ * an object of the appropriate type. The getContent() method will return the converted
+ * Object and the caller must cast this to the appropriate type.
+ * If a conversion error occured because the string was not in the correct form,
+ * the isValid() method will return false. The toExternalForm() method will return the
+ * attribute's original string value.
*
* @author jkaputin@apache.org
*/
@@ -34,7 +40,7 @@
*
* @throws WSDLException if conversion errors occur
*/
- public void init(Element ownerEl, String attrString) throws WSDLException;
+ public void init(Element ownerEl, String attrValue) throws WSDLException;
public Object getContent();
---------------------------------------------------------------------
To unsubscribe, e-mail: woden-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: woden-dev-help@ws.apache.org