You are viewing a plain text version of this content. The canonical link for it is here.
Posted to wsrf-dev@ws.apache.org by ip...@apache.org on 2004/12/14 18:21:49 UTC
svn commit: r111843 - /incubator/apollo/trunk/src/java/org/apache/ws/util/XmlBeanUtils.java /incubator/apollo/trunk/src/java/org/apache/ws/util/i18n/Keys.java
Author: ips
Date: Tue Dec 14 09:21:48 2004
New Revision: 111843
URL: http://svn.apache.org/viewcvs?view=rev&rev=111843
Log:
javadoc
Modified:
incubator/apollo/trunk/src/java/org/apache/ws/util/XmlBeanUtils.java
incubator/apollo/trunk/src/java/org/apache/ws/util/i18n/Keys.java
Modified: incubator/apollo/trunk/src/java/org/apache/ws/util/XmlBeanUtils.java
Url: http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/java/org/apache/ws/util/XmlBeanUtils.java?view=diff&rev=111843&p1=incubator/apollo/trunk/src/java/org/apache/ws/util/XmlBeanUtils.java&r1=111842&p2=incubator/apollo/trunk/src/java/org/apache/ws/util/XmlBeanUtils.java&r2=111843
==============================================================================
--- incubator/apollo/trunk/src/java/org/apache/ws/util/XmlBeanUtils.java (original)
+++ incubator/apollo/trunk/src/java/org/apache/ws/util/XmlBeanUtils.java Tue Dec 14 09:21:48 2004
@@ -15,8 +15,6 @@
*=============================================================================*/
package org.apache.ws.util;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.apache.ws.util.i18n.Keys;
import org.apache.ws.util.i18n.Messages;
import org.apache.ws.util.i18n.MessagesImpl;
@@ -48,8 +46,7 @@
*/
public abstract class XmlBeanUtils
{
- private static final Log LOG = LogFactory.getLog( XmlBeanUtils.class );
- public static final Messages MSG = MessagesImpl.getInstance();
+ private static final Messages MSG = MessagesImpl.getInstance();
/**
* TODO
@@ -72,7 +69,6 @@
foundElems.add( xCursor.getObject() );
}
}
-
xCursor.dispose();
return (XmlObject[]) foundElems.toArray( new XmlObject[0] );
}
@@ -133,7 +129,6 @@
name = getName( xCursor );
xCursor.dispose();
}
- LOG.debug( MSG.getMessage( Keys.QNAME_OF_XMLOBJ, name.toString() ) );
return name;
}
@@ -161,11 +156,13 @@
}
/**
- * DOCUMENT_ME
+ * Returns the root element of the specified document XMLBean. If the specified XMLBean is not a document, the
+ * XMLBean itself is returned.
*
- * @param docXBean DOCUMENT_ME
+ * @param docXBean a document XMLBean
*
- * @return DOCUMENT_ME
+ * @return the root element of the specified document XMLBean, or, if the specified XMLBean is not a document, the
+ * XMLBean itself
*/
public static XmlObject getRootElement( XmlObject docXBean )
{
@@ -175,11 +172,11 @@
XmlCursor xCursor = docXBean.newCursor();
if ( xCursor.toFirstChild() )
{
- rootElemXBean = xCursor.getObject();
+ rootElemXBean = xCursor.getObject();
}
else
{
- rootElemXBean = null;
+ rootElemXBean = null;
}
xCursor.dispose();
}
@@ -197,10 +194,6 @@
public static void setValue( XmlObject xBean,
String value )
{
- if ( LOG.isDebugEnabled() )
- {
- LOG.debug( MSG.getMessage( Keys.SET_VAL_ON_XMLOBJ, value, xBean.toString() ) );
- }
XmlCursor xCursor = xBean.newCursor();
if ( xCursor.isStartdoc() )
{
@@ -298,12 +291,11 @@
}
/**
- * TODO
+ * Removes all child elements, with the specified name, from the specified XMLBean.
*
- * @param xBean
- * @param name
+ * @param xBean an XMLBean
*
- * @return
+ * @return true if all child elements, with the specified name, were successfully removed
*/
public static boolean removeChildElements( XmlObject xBean,
QName name )
@@ -313,17 +305,28 @@
XmlCursor xCursor = xBean.newCursor();
for ( boolean hasNext = xCursor.toFirstChild(); hasNext; hasNext = xCursor.toNextSibling() )
{
- if ( getName( xCursor ).equals( name ) )
+ if ( name == null || getName( xCursor ).equals( name ) )
{
succeeded = succeeded && xCursor.removeXml();
}
}
-
xCursor.dispose();
return succeeded;
}
/**
+ * Removes all child elements of the specified XMLBean.
+ *
+ * @param xBean an XMLBean
+ *
+ * @return true if all child elements were successfully removed
+ */
+ public static boolean removeChildElements( XmlObject xBean )
+ {
+ return removeChildElements( xBean, null );
+ }
+
+ /**
* @param xBean
*
* @return
@@ -333,15 +336,9 @@
public static SOAPElement toSOAPElement( XmlObject xBean )
throws Exception
{
- if ( LOG.isDebugEnabled() )
- {
- LOG.debug( MSG.getMessage( Keys.CONVERT_XMLOBJ_TO_SOAPELEM, xBean.toString() ) );
- }
- XmlOptions xBeanSaveOptions =
- new XmlOptions().setSavePrettyPrint().setSavePrettyPrintIndent( 2 ).setSaveOuter();
- Node domNode = xBean.newDomNode( xBeanSaveOptions );
+ XmlOptions xSaveOpts = new XmlOptions().setSaveOuter().setSavePrettyPrint().setSavePrettyPrintIndent( 2 );
+ Node domNode = xBean.newDomNode( xSaveOpts );
Element domElem = null;
-
if ( domNode instanceof Document )
{
domElem = ( (Document) domNode ).getDocumentElement();
@@ -349,18 +346,15 @@
else if ( domNode instanceof DocumentFragment )
{
NodeList childNodes = domNode.getChildNodes();
-
for ( int i = 0; i < childNodes.getLength(); i++ )
{
if ( childNodes.item( i ).getNodeType() == Node.ELEMENT_NODE )
{
domElem = (Element) childNodes.item( i );
-
break;
}
}
}
-
return SaajUtils.toSOAPElement( domElem );
}
Modified: incubator/apollo/trunk/src/java/org/apache/ws/util/i18n/Keys.java
Url: http://svn.apache.org/viewcvs/incubator/apollo/trunk/src/java/org/apache/ws/util/i18n/Keys.java?view=diff&rev=111843&p1=incubator/apollo/trunk/src/java/org/apache/ws/util/i18n/Keys.java&r1=111842&p2=incubator/apollo/trunk/src/java/org/apache/ws/util/i18n/Keys.java&r2=111843
==============================================================================
--- incubator/apollo/trunk/src/java/org/apache/ws/util/i18n/Keys.java (original)
+++ incubator/apollo/trunk/src/java/org/apache/ws/util/i18n/Keys.java Tue Dec 14 09:21:48 2004
@@ -32,18 +32,6 @@
*/
String NULL_PARAM_NOT_ALLOWED = "NULL_PARAM_NOT_ALLOWED";
/**
- * @msg The QName of the XmlObject is: {0}
- */
- String QNAME_OF_XMLOBJ = "QNAME_OF_XMLOBJ";
- /**
- * @msg Setting the value: {1} on the XmlObject: {1}
- */
- String SET_VAL_ON_XMLOBJ = "SET_VAL_ON_XMLOBJ";
- /**
- * @msg Converting an XmlObject to a SOAPElement: {0}
- */
- String CONVERT_XMLOBJ_TO_SOAPELEM = "CONVERT_XMLOBJ_TO_SOAPELEM";
- /**
* @msg Parameter must be an instance of one of the following types: XmlObject, Node, String, InputStream, Reader, File, or URL
*/
String PARAM_MUST_BE_TYPE = "PARAM_MUST_BE_TYPE";
---------------------------------------------------------------------
To unsubscribe, e-mail: apollo-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: apollo-dev-help@ws.apache.org