You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by ch...@apache.org on 2006/02/22 00:40:29 UTC
svn commit: r379627 [11/34] - in /incubator/servicemix/trunk: ./ etc/
sandbox/servicemix-wsn-1.2/src/sa/META-INF/
sandbox/servicemix-wsn-1.2/src/su/META-INF/ servicemix-assembly/
servicemix-assembly/src/main/assembly/ servicemix-assembly/src/main/relea...
Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/AdminCommandsServiceMBean.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/AdminCommandsServiceMBean.java?rev=379627&r1=379626&r2=379627&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/AdminCommandsServiceMBean.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/AdminCommandsServiceMBean.java Tue Feb 21 15:40:05 2006
@@ -1,62 +1,62 @@
-/*
- * Copyright 2005-2006 The 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.servicemix.jbi.framework;
-
-import javax.jbi.management.LifeCycleMBean;
-import java.util.Properties;
-/**
- * Provides a simple interface to access ServiceMix administration commands.
- *
- * @version $Revision: 657 $
- */
-public interface AdminCommandsServiceMBean extends LifeCycleMBean{
- String installComponent(String file) throws Exception;
-
- String installComponent(String file,Properties properties) throws Exception;
-
- String uninstallComponent(String name) throws Exception;
-
- String installSharedLibrary(String file) throws Exception;
-
- String uninstallSharedLibrary(String name) throws Exception;
-
- String startComponent(String name) throws Exception;
-
- String stopComponent(String name) throws Exception;
-
- String shutdownComponent(String name) throws Exception;
-
- String deployServiceAssembly(String file) throws Exception;
-
- String undeployServiceAssembly(String name) throws Exception;
-
- String startServiceAssembly(String name) throws Exception;
-
- String stopServiceAssembly(String name) throws Exception;
-
- String shutdownServiceAssembly(String name) throws Exception;
-
- String installArchive(String location) throws Exception;
-
- String listComponents(boolean serviceEngines,boolean bindingComponents,String state,String sharedLibraryName,
- String serviceAssemblyName) throws Exception;
-
- String listJBIComponents(boolean serviceEngines,boolean bindingComponents,String state,String sharedLibraryName,
- String serviceAssemblyName) throws Exception;
-
- String listPojoComponents() throws Exception;
-
- String listSharedLibraries(String componentName,String sharedLibraryName) throws Exception;
-
- String listServiceAssemblies(String state,String componentName,String serviceAssemblyName) throws Exception;
-}
+/*
+ * Copyright 2005-2006 The 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.servicemix.jbi.framework;
+
+import javax.jbi.management.LifeCycleMBean;
+import java.util.Properties;
+/**
+ * Provides a simple interface to access ServiceMix administration commands.
+ *
+ * @version $Revision: 657 $
+ */
+public interface AdminCommandsServiceMBean extends LifeCycleMBean{
+ String installComponent(String file) throws Exception;
+
+ String installComponent(String file,Properties properties) throws Exception;
+
+ String uninstallComponent(String name) throws Exception;
+
+ String installSharedLibrary(String file) throws Exception;
+
+ String uninstallSharedLibrary(String name) throws Exception;
+
+ String startComponent(String name) throws Exception;
+
+ String stopComponent(String name) throws Exception;
+
+ String shutdownComponent(String name) throws Exception;
+
+ String deployServiceAssembly(String file) throws Exception;
+
+ String undeployServiceAssembly(String name) throws Exception;
+
+ String startServiceAssembly(String name) throws Exception;
+
+ String stopServiceAssembly(String name) throws Exception;
+
+ String shutdownServiceAssembly(String name) throws Exception;
+
+ String installArchive(String location) throws Exception;
+
+ String listComponents(boolean serviceEngines,boolean bindingComponents,String state,String sharedLibraryName,
+ String serviceAssemblyName) throws Exception;
+
+ String listJBIComponents(boolean serviceEngines,boolean bindingComponents,String state,String sharedLibraryName,
+ String serviceAssemblyName) throws Exception;
+
+ String listPojoComponents() throws Exception;
+
+ String listSharedLibraries(String componentName,String sharedLibraryName) throws Exception;
+
+ String listServiceAssemblies(String state,String componentName,String serviceAssemblyName) throws Exception;
+}
Propchange: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/AdminCommandsServiceMBean.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/AutoDeploymentServiceMBean.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/AutoDeploymentServiceMBean.java?rev=379627&r1=379626&r2=379627&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/AutoDeploymentServiceMBean.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/AutoDeploymentServiceMBean.java Tue Feb 21 15:40:05 2006
@@ -1,22 +1,22 @@
-/*
- * Copyright 2005-2006 The 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.servicemix.jbi.framework;
-
-import javax.jbi.management.LifeCycleMBean;
-
-public interface AutoDeploymentServiceMBean extends LifeCycleMBean {
-
-}
+/*
+ * Copyright 2005-2006 The 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.servicemix.jbi.framework;
+
+import javax.jbi.management.LifeCycleMBean;
+
+public interface AutoDeploymentServiceMBean extends LifeCycleMBean {
+
+}
Propchange: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/AutoDeploymentServiceMBean.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ClassLoaderUtil.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ClassLoaderUtil.java?rev=379627&r1=379626&r2=379627&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ClassLoaderUtil.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ClassLoaderUtil.java Tue Feb 21 15:40:05 2006
@@ -1,90 +1,90 @@
-/*
- * Copyright 2005-2006 The 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.servicemix.jbi.framework;
-
-import java.util.Map;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.ObjectStreamClass;
-
-/**
- * Utility methods for class loader manipulation in a server environment.
- *
- * @author Dain Sundstrom
- * @version $Id$
- * @since 2.0
- *
- * TODO: this has been copied from xbean-server
- */
-public final class ClassLoaderUtil {
- private ClassLoaderUtil() {
- }
-
- /**
- * Cleans well known class loader leaks in VMs and libraries. There is a lot of bad code out there and this method
- * will clear up the know problems. This method should only be called when the class loader will no longer be used.
- * It this method is called two often it can have a serious impact on preformance.
- * @param classLoader the class loader to destroy
- */
- public static void destroy(ClassLoader classLoader) {
- releaseCommonsLoggingCache(classLoader);
- clearSunSoftCache(ObjectInputStream.class, "subclassAudits");
- clearSunSoftCache(ObjectOutputStream.class, "subclassAudits");
- clearSunSoftCache(ObjectStreamClass.class, "localDescs");
- clearSunSoftCache(ObjectStreamClass.class, "reflectors");
- }
-
- /**
- * Clears the caches maintained by the SunVM object stream implementation. This method uses reflection and
- * setAccessable to obtain access to the Sun cache. The cache is locked with a synchronize monitor and cleared.
- * This method completely clears the class loader cache which will impact preformance of object serialization.
- * @param clazz the name of the class containing the cache field
- * @param fieldName the name of the cache field
- */
- public static void clearSunSoftCache(Class clazz, String fieldName) {
- Map cache = null;
- try {
- Field field = clazz.getDeclaredField(fieldName);
- field.setAccessible(true);
- cache = (Map) field.get(null);
- } catch (Throwable ignored) {
- // there is nothing a user could do about this anyway
- }
-
- if (cache != null) {
- synchronized (cache) {
- cache.clear();
- }
- }
- }
-
- /**
- * Releases the specified classloader from the Apache Jakarta Commons Logging class loader cache using reflection.
- * @param classLoader the class loader to release
- */
- public static void releaseCommonsLoggingCache(ClassLoader classLoader) {
- try {
- Class logFactory = classLoader.loadClass("org.apache.commons.logging.LogFactory");
- Method release = logFactory.getMethod("release", new Class[] {ClassLoader.class});
- release.invoke(null, new Object[] {classLoader});
- } catch (Throwable ignored) {
- // there is nothing a user could do about this anyway
- }
- }
-
-}
+/*
+ * Copyright 2005-2006 The 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.servicemix.jbi.framework;
+
+import java.util.Map;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.ObjectStreamClass;
+
+/**
+ * Utility methods for class loader manipulation in a server environment.
+ *
+ * @author Dain Sundstrom
+ * @version $Id$
+ * @since 2.0
+ *
+ * TODO: this has been copied from xbean-server
+ */
+public final class ClassLoaderUtil {
+ private ClassLoaderUtil() {
+ }
+
+ /**
+ * Cleans well known class loader leaks in VMs and libraries. There is a lot of bad code out there and this method
+ * will clear up the know problems. This method should only be called when the class loader will no longer be used.
+ * It this method is called two often it can have a serious impact on preformance.
+ * @param classLoader the class loader to destroy
+ */
+ public static void destroy(ClassLoader classLoader) {
+ releaseCommonsLoggingCache(classLoader);
+ clearSunSoftCache(ObjectInputStream.class, "subclassAudits");
+ clearSunSoftCache(ObjectOutputStream.class, "subclassAudits");
+ clearSunSoftCache(ObjectStreamClass.class, "localDescs");
+ clearSunSoftCache(ObjectStreamClass.class, "reflectors");
+ }
+
+ /**
+ * Clears the caches maintained by the SunVM object stream implementation. This method uses reflection and
+ * setAccessable to obtain access to the Sun cache. The cache is locked with a synchronize monitor and cleared.
+ * This method completely clears the class loader cache which will impact preformance of object serialization.
+ * @param clazz the name of the class containing the cache field
+ * @param fieldName the name of the cache field
+ */
+ public static void clearSunSoftCache(Class clazz, String fieldName) {
+ Map cache = null;
+ try {
+ Field field = clazz.getDeclaredField(fieldName);
+ field.setAccessible(true);
+ cache = (Map) field.get(null);
+ } catch (Throwable ignored) {
+ // there is nothing a user could do about this anyway
+ }
+
+ if (cache != null) {
+ synchronized (cache) {
+ cache.clear();
+ }
+ }
+ }
+
+ /**
+ * Releases the specified classloader from the Apache Jakarta Commons Logging class loader cache using reflection.
+ * @param classLoader the class loader to release
+ */
+ public static void releaseCommonsLoggingCache(ClassLoader classLoader) {
+ try {
+ Class logFactory = classLoader.loadClass("org.apache.commons.logging.LogFactory");
+ Method release = logFactory.getMethod("release", new Class[] {ClassLoader.class});
+ release.invoke(null, new Object[] {classLoader});
+ } catch (Throwable ignored) {
+ // there is nothing a user could do about this anyway
+ }
+ }
+
+}
Propchange: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ClassLoaderUtil.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ComponentStatsMBean.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ComponentStatsMBeanImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/RegistryMBean.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/RegistryMBean.java?rev=379627&r1=379626&r2=379627&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/RegistryMBean.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/RegistryMBean.java Tue Feb 21 15:40:05 2006
@@ -1,22 +1,22 @@
-/*
- * Copyright 2005-2006 The 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.servicemix.jbi.framework;
-
-import javax.jbi.management.LifeCycleMBean;
-
-public interface RegistryMBean extends LifeCycleMBean {
-
-}
+/*
+ * Copyright 2005-2006 The 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.servicemix.jbi.framework;
+
+import javax.jbi.management.LifeCycleMBean;
+
+public interface RegistryMBean extends LifeCycleMBean {
+
+}
Propchange: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/RegistryMBean.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/jaxp/DOMStreamReader.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/jaxp/DOMStreamReader.java?rev=379627&r1=379626&r2=379627&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/jaxp/DOMStreamReader.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/jaxp/DOMStreamReader.java Tue Feb 21 15:40:05 2006
@@ -1,260 +1,260 @@
-/*
- * Copyright 2005-2006 The 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.servicemix.jbi.jaxp;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.xml.stream.Location;
-import javax.xml.stream.XMLStreamConstants;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-
-import org.apache.servicemix.jbi.util.FastStack;
-
-/**
- * Abstract logic for creating XMLStreamReader from DOM documents.
- * Its works using adapters for Element, Node and Attribute ( @see ElementAdapter }
- *
- * @author <a href="mailto:tsztelak@gmail.com">Tomasz Sztelak</a>
- */
-public abstract class DOMStreamReader implements XMLStreamReader {
- public Map properties = new HashMap();
-
- private FastStack frames = new FastStack();
-
- private ElementFrame frame;
-
- private int currentEvent = XMLStreamConstants.START_DOCUMENT;
-
- /**
- *
- */
- public static class ElementFrame {
- public ElementFrame(Object element) {
- this.element = element;
- }
-
- Object element;
-
- boolean started = false;
-
- boolean ended = false;
-
- int currentChild = -1;
-
- int currentAttribute = -1;
-
- int currentNamespace = -1;
-
- List uris;
-
- List prefixes;
-
- List attributes;
- }
-
- /**
- * @param element
- */
- public DOMStreamReader(ElementFrame frame) {
- this.frame = frame;
- frames.push(this.frame);
- newFrame(frame);
- }
-
- protected ElementFrame getCurrentFrame() {
- return frame;
- }
-
- /* (non-Javadoc)
- * @see javax.xml.stream.XMLStreamReader#getProperty(java.lang.String)
- */
- public Object getProperty(String key) throws IllegalArgumentException {
- return properties.get(key);
- }
-
- /* (non-Javadoc)
- * @see javax.xml.stream.XMLStreamReader#next()
- */
- public int next() throws XMLStreamException {
-
- if (frame.ended) {
- frames.pop();
- if (!frames.isEmpty()) {
- frame = (ElementFrame) frames.peek();
- } else {
- currentEvent = END_DOCUMENT;
- return currentEvent;
- }
- }
-
- if (!frame.started) {
- frame.started = true;
- currentEvent = START_ELEMENT;
- } else if (frame.currentAttribute < getAttributeCount() - 1) {
- frame.currentAttribute++;
- currentEvent = ATTRIBUTE;
- } else if (frame.currentNamespace < getNamespaceCount() - 1) {
- frame.currentNamespace++;
- currentEvent = NAMESPACE;
- } else if (frame.currentChild < getChildCount() - 1) {
- frame.currentChild++;
-
- currentEvent = moveToChild(frame.currentChild);
-
- if (currentEvent == START_ELEMENT) {
- ElementFrame newFrame = getChildFrame(frame.currentChild);
- newFrame.started = true;
- frame = newFrame;
- frames.push(this.frame);
- currentEvent = START_ELEMENT;
-
- newFrame(newFrame);
- }
- } else {
- frame.ended = true;
- currentEvent = END_ELEMENT;
- endElement();
- }
- return currentEvent;
- }
-
- protected void newFrame(ElementFrame newFrame) {
- }
-
- protected void endElement() {
- }
-
- protected abstract int moveToChild(int currentChild);
-
- protected abstract ElementFrame getChildFrame(int currentChild);
-
- protected abstract int getChildCount();
-
- /* (non-Javadoc)
- * @see javax.xml.stream.XMLStreamReader#require(int, java.lang.String, java.lang.String)
- */
- public void require(int arg0, String arg1, String arg2)
- throws XMLStreamException {
- throw new UnsupportedOperationException();
- }
-
- /* (non-Javadoc)
- * @see javax.xml.stream.XMLStreamReader#getElementText()
- */
- public abstract String getElementText() throws XMLStreamException;
-
- /* (non-Javadoc)
- * @see javax.xml.stream.XMLStreamReader#nextTag()
- */
- public int nextTag() throws XMLStreamException {
- while (hasNext()) {
- if (START_ELEMENT == next()) {
- return START_ELEMENT;
- }
- }
- return currentEvent;
- }
-
- /* (non-Javadoc)
- * @see javax.xml.stream.XMLStreamReader#hasNext()
- */
- public boolean hasNext() throws XMLStreamException {
- return !(frames.size() == 0 && frame.ended);
- }
-
- /* (non-Javadoc)
- * @see javax.xml.stream.XMLStreamReader#close()
- */
- public void close() throws XMLStreamException {
- }
-
- /* (non-Javadoc)
- * @see javax.xml.stream.XMLStreamReader#getNamespaceURI(java.lang.String)
- */
- public abstract String getNamespaceURI(String prefix);
-
- /* (non-Javadoc)
- * @see javax.xml.stream.XMLStreamReader#isStartElement()
- */
- public boolean isStartElement() {
- return (currentEvent == START_ELEMENT);
- }
-
- /* (non-Javadoc)
- * @see javax.xml.stream.XMLStreamReader#isEndElement()
- */
- public boolean isEndElement() {
- return (currentEvent == END_ELEMENT);
- }
-
- /* (non-Javadoc)
- * @see javax.xml.stream.XMLStreamReader#isCharacters()
- */
- public boolean isCharacters() {
- return (currentEvent == CHARACTERS);
- }
-
- /* (non-Javadoc)
- * @see javax.xml.stream.XMLStreamReader#isWhiteSpace()
- */
- public boolean isWhiteSpace() {
- return (currentEvent == SPACE);
- }
-
- public int getEventType() {
- return currentEvent;
- }
-
- public int getTextCharacters(int sourceStart, char[] target,
- int targetStart, int length) throws XMLStreamException {
- throw new UnsupportedOperationException();
- }
-
- public boolean hasText() {
- return (currentEvent == CHARACTERS || currentEvent == DTD
- || currentEvent == ENTITY_REFERENCE || currentEvent == COMMENT
- || currentEvent == SPACE);
- }
-
- public Location getLocation() {
- return null;
- }
-
- public boolean hasName() {
- return (currentEvent == START_ELEMENT || currentEvent == END_ELEMENT);
- }
-
- public String getVersion() {
- return null;
- }
-
- public boolean isStandalone() {
- return false;
- }
-
- public boolean standaloneSet() {
- // TODO Auto-generated method stub
- return false;
- }
-
- public String getCharacterEncodingScheme() {
- // TODO Auto-generated method stub
- return null;
- }
-}
+/*
+ * Copyright 2005-2006 The 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.servicemix.jbi.jaxp;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.stream.Location;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.servicemix.jbi.util.FastStack;
+
+/**
+ * Abstract logic for creating XMLStreamReader from DOM documents.
+ * Its works using adapters for Element, Node and Attribute ( @see ElementAdapter }
+ *
+ * @author <a href="mailto:tsztelak@gmail.com">Tomasz Sztelak</a>
+ */
+public abstract class DOMStreamReader implements XMLStreamReader {
+ public Map properties = new HashMap();
+
+ private FastStack frames = new FastStack();
+
+ private ElementFrame frame;
+
+ private int currentEvent = XMLStreamConstants.START_DOCUMENT;
+
+ /**
+ *
+ */
+ public static class ElementFrame {
+ public ElementFrame(Object element) {
+ this.element = element;
+ }
+
+ Object element;
+
+ boolean started = false;
+
+ boolean ended = false;
+
+ int currentChild = -1;
+
+ int currentAttribute = -1;
+
+ int currentNamespace = -1;
+
+ List uris;
+
+ List prefixes;
+
+ List attributes;
+ }
+
+ /**
+ * @param element
+ */
+ public DOMStreamReader(ElementFrame frame) {
+ this.frame = frame;
+ frames.push(this.frame);
+ newFrame(frame);
+ }
+
+ protected ElementFrame getCurrentFrame() {
+ return frame;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.xml.stream.XMLStreamReader#getProperty(java.lang.String)
+ */
+ public Object getProperty(String key) throws IllegalArgumentException {
+ return properties.get(key);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.xml.stream.XMLStreamReader#next()
+ */
+ public int next() throws XMLStreamException {
+
+ if (frame.ended) {
+ frames.pop();
+ if (!frames.isEmpty()) {
+ frame = (ElementFrame) frames.peek();
+ } else {
+ currentEvent = END_DOCUMENT;
+ return currentEvent;
+ }
+ }
+
+ if (!frame.started) {
+ frame.started = true;
+ currentEvent = START_ELEMENT;
+ } else if (frame.currentAttribute < getAttributeCount() - 1) {
+ frame.currentAttribute++;
+ currentEvent = ATTRIBUTE;
+ } else if (frame.currentNamespace < getNamespaceCount() - 1) {
+ frame.currentNamespace++;
+ currentEvent = NAMESPACE;
+ } else if (frame.currentChild < getChildCount() - 1) {
+ frame.currentChild++;
+
+ currentEvent = moveToChild(frame.currentChild);
+
+ if (currentEvent == START_ELEMENT) {
+ ElementFrame newFrame = getChildFrame(frame.currentChild);
+ newFrame.started = true;
+ frame = newFrame;
+ frames.push(this.frame);
+ currentEvent = START_ELEMENT;
+
+ newFrame(newFrame);
+ }
+ } else {
+ frame.ended = true;
+ currentEvent = END_ELEMENT;
+ endElement();
+ }
+ return currentEvent;
+ }
+
+ protected void newFrame(ElementFrame newFrame) {
+ }
+
+ protected void endElement() {
+ }
+
+ protected abstract int moveToChild(int currentChild);
+
+ protected abstract ElementFrame getChildFrame(int currentChild);
+
+ protected abstract int getChildCount();
+
+ /* (non-Javadoc)
+ * @see javax.xml.stream.XMLStreamReader#require(int, java.lang.String, java.lang.String)
+ */
+ public void require(int arg0, String arg1, String arg2)
+ throws XMLStreamException {
+ throw new UnsupportedOperationException();
+ }
+
+ /* (non-Javadoc)
+ * @see javax.xml.stream.XMLStreamReader#getElementText()
+ */
+ public abstract String getElementText() throws XMLStreamException;
+
+ /* (non-Javadoc)
+ * @see javax.xml.stream.XMLStreamReader#nextTag()
+ */
+ public int nextTag() throws XMLStreamException {
+ while (hasNext()) {
+ if (START_ELEMENT == next()) {
+ return START_ELEMENT;
+ }
+ }
+ return currentEvent;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.xml.stream.XMLStreamReader#hasNext()
+ */
+ public boolean hasNext() throws XMLStreamException {
+ return !(frames.size() == 0 && frame.ended);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.xml.stream.XMLStreamReader#close()
+ */
+ public void close() throws XMLStreamException {
+ }
+
+ /* (non-Javadoc)
+ * @see javax.xml.stream.XMLStreamReader#getNamespaceURI(java.lang.String)
+ */
+ public abstract String getNamespaceURI(String prefix);
+
+ /* (non-Javadoc)
+ * @see javax.xml.stream.XMLStreamReader#isStartElement()
+ */
+ public boolean isStartElement() {
+ return (currentEvent == START_ELEMENT);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.xml.stream.XMLStreamReader#isEndElement()
+ */
+ public boolean isEndElement() {
+ return (currentEvent == END_ELEMENT);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.xml.stream.XMLStreamReader#isCharacters()
+ */
+ public boolean isCharacters() {
+ return (currentEvent == CHARACTERS);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.xml.stream.XMLStreamReader#isWhiteSpace()
+ */
+ public boolean isWhiteSpace() {
+ return (currentEvent == SPACE);
+ }
+
+ public int getEventType() {
+ return currentEvent;
+ }
+
+ public int getTextCharacters(int sourceStart, char[] target,
+ int targetStart, int length) throws XMLStreamException {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean hasText() {
+ return (currentEvent == CHARACTERS || currentEvent == DTD
+ || currentEvent == ENTITY_REFERENCE || currentEvent == COMMENT
+ || currentEvent == SPACE);
+ }
+
+ public Location getLocation() {
+ return null;
+ }
+
+ public boolean hasName() {
+ return (currentEvent == START_ELEMENT || currentEvent == END_ELEMENT);
+ }
+
+ public String getVersion() {
+ return null;
+ }
+
+ public boolean isStandalone() {
+ return false;
+ }
+
+ public boolean standaloneSet() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public String getCharacterEncodingScheme() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+}
Propchange: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/jaxp/DOMStreamReader.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/jaxp/ExtendedNamespaceContext.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/jaxp/ExtendedNamespaceContext.java?rev=379627&r1=379626&r2=379627&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/jaxp/ExtendedNamespaceContext.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/jaxp/ExtendedNamespaceContext.java Tue Feb 21 15:40:05 2006
@@ -1,31 +1,31 @@
-/*
- * Copyright 2005-2006 The 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.servicemix.jbi.jaxp;
-
-import java.util.Iterator;
-
-import javax.xml.namespace.NamespaceContext;
-
-public interface ExtendedNamespaceContext extends NamespaceContext {
-
- /**
- * Returns an {@link Iterator} of all namespace prefixes in scope within this
- * context, including those inherited from ancestor contexts.
- *
- * @return An {@link Iterator} of prefix {@link String}s.
- */
- public Iterator getPrefixes();
-}
+/*
+ * Copyright 2005-2006 The 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.servicemix.jbi.jaxp;
+
+import java.util.Iterator;
+
+import javax.xml.namespace.NamespaceContext;
+
+public interface ExtendedNamespaceContext extends NamespaceContext {
+
+ /**
+ * Returns an {@link Iterator} of all namespace prefixes in scope within this
+ * context, including those inherited from ancestor contexts.
+ *
+ * @return An {@link Iterator} of prefix {@link String}s.
+ */
+ public Iterator getPrefixes();
+}
Propchange: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/jaxp/ExtendedNamespaceContext.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/jaxp/ExtendedXMLStreamReader.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/jaxp/ExtendedXMLStreamReader.java?rev=379627&r1=379626&r2=379627&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/jaxp/ExtendedXMLStreamReader.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/jaxp/ExtendedXMLStreamReader.java Tue Feb 21 15:40:05 2006
@@ -1,138 +1,138 @@
-/*
- * Copyright 2005-2006 The 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.servicemix.jbi.jaxp;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-
-import javax.xml.namespace.NamespaceContext;
-import javax.xml.stream.XMLStreamConstants;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-import javax.xml.stream.util.StreamReaderDelegate;
-
-public class ExtendedXMLStreamReader extends StreamReaderDelegate {
-
- private SimpleNamespaceContext context = new SimpleNamespaceContext();
-
- public ExtendedXMLStreamReader(XMLStreamReader delegate) {
- super(delegate);
- }
-
- public NamespaceContext getNamespaceContext() {
- return context;
- }
-
- public int nextTag() throws XMLStreamException {
- int eventType = next();
- while((eventType == XMLStreamConstants.CHARACTERS && isWhiteSpace()) // skip whitespace
- || (eventType == XMLStreamConstants.CDATA && isWhiteSpace())
- // skip whitespace
- || eventType == XMLStreamConstants.SPACE
- || eventType == XMLStreamConstants.PROCESSING_INSTRUCTION
- || eventType == XMLStreamConstants.COMMENT
- ) {
- eventType = next();
- }
- if (eventType != XMLStreamConstants.START_ELEMENT && eventType != XMLStreamConstants.END_ELEMENT) {
- throw new XMLStreamException("expected start or end tag", getLocation());
- }
- return eventType;
- }
-
- public int next() throws XMLStreamException {
- int next = super.next();
- if (next == START_ELEMENT) {
- context = new SimpleNamespaceContext(context, getNamespaces());
- } else if (next == END_ELEMENT) {
- context = context.getParent();
- }
- return next;
- }
-
- private Map getNamespaces() {
- Map ns = new HashMap();
- for (int i = 0; i < getNamespaceCount(); i++) {
- ns.put(getNamespacePrefix(i), getNamespaceURI(i));
- }
- return ns;
- }
-
- public static class SimpleNamespaceContext implements ExtendedNamespaceContext {
-
- private SimpleNamespaceContext parent;
- private Map namespaces;
-
- public SimpleNamespaceContext() {
- namespaces = new HashMap();
- }
-
- public SimpleNamespaceContext(SimpleNamespaceContext parent, Map namespaces) {
- this.parent = parent;
- this.namespaces = namespaces;
- }
-
- public SimpleNamespaceContext getParent() {
- return parent;
- }
-
- public Iterator getPrefixes() {
- HashSet prefixes = new HashSet();
- for (SimpleNamespaceContext context = this; context != null; context = context.parent) {
- prefixes.addAll(context.namespaces.keySet());
- }
- return prefixes.iterator();
- }
-
- public String getNamespaceURI(String prefix) {
- String uri = (String) namespaces.get(prefix);
- if (uri == null) {
- uri = parent.getNamespaceURI(prefix);
- }
- return uri;
- }
-
- public String getPrefix(String namespaceURI) {
- for (SimpleNamespaceContext context = this; context != null; context = context.parent) {
- for (Iterator it = context.namespaces.keySet().iterator(); it.hasNext();) {
- Map.Entry entry = (Map.Entry) it.next();
- if (entry.getValue().equals(namespaceURI)) {
- return (String) entry.getKey();
- }
- }
- }
- return null;
- }
-
- public Iterator getPrefixes(String namespaceURI) {
- HashSet prefixes = new HashSet();
- for (SimpleNamespaceContext context = this; context != null; context = context.parent) {
- for (Iterator it = context.namespaces.keySet().iterator(); it.hasNext();) {
- Map.Entry entry = (Map.Entry) it.next();
- if (entry.getValue().equals(namespaceURI)) {
- prefixes.add(entry.getKey());
- }
- }
- }
- return prefixes.iterator();
- }
-
- }
-
-
-}
+/*
+ * Copyright 2005-2006 The 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.servicemix.jbi.jaxp;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.util.StreamReaderDelegate;
+
+public class ExtendedXMLStreamReader extends StreamReaderDelegate {
+
+ private SimpleNamespaceContext context = new SimpleNamespaceContext();
+
+ public ExtendedXMLStreamReader(XMLStreamReader delegate) {
+ super(delegate);
+ }
+
+ public NamespaceContext getNamespaceContext() {
+ return context;
+ }
+
+ public int nextTag() throws XMLStreamException {
+ int eventType = next();
+ while((eventType == XMLStreamConstants.CHARACTERS && isWhiteSpace()) // skip whitespace
+ || (eventType == XMLStreamConstants.CDATA && isWhiteSpace())
+ // skip whitespace
+ || eventType == XMLStreamConstants.SPACE
+ || eventType == XMLStreamConstants.PROCESSING_INSTRUCTION
+ || eventType == XMLStreamConstants.COMMENT
+ ) {
+ eventType = next();
+ }
+ if (eventType != XMLStreamConstants.START_ELEMENT && eventType != XMLStreamConstants.END_ELEMENT) {
+ throw new XMLStreamException("expected start or end tag", getLocation());
+ }
+ return eventType;
+ }
+
+ public int next() throws XMLStreamException {
+ int next = super.next();
+ if (next == START_ELEMENT) {
+ context = new SimpleNamespaceContext(context, getNamespaces());
+ } else if (next == END_ELEMENT) {
+ context = context.getParent();
+ }
+ return next;
+ }
+
+ private Map getNamespaces() {
+ Map ns = new HashMap();
+ for (int i = 0; i < getNamespaceCount(); i++) {
+ ns.put(getNamespacePrefix(i), getNamespaceURI(i));
+ }
+ return ns;
+ }
+
+ public static class SimpleNamespaceContext implements ExtendedNamespaceContext {
+
+ private SimpleNamespaceContext parent;
+ private Map namespaces;
+
+ public SimpleNamespaceContext() {
+ namespaces = new HashMap();
+ }
+
+ public SimpleNamespaceContext(SimpleNamespaceContext parent, Map namespaces) {
+ this.parent = parent;
+ this.namespaces = namespaces;
+ }
+
+ public SimpleNamespaceContext getParent() {
+ return parent;
+ }
+
+ public Iterator getPrefixes() {
+ HashSet prefixes = new HashSet();
+ for (SimpleNamespaceContext context = this; context != null; context = context.parent) {
+ prefixes.addAll(context.namespaces.keySet());
+ }
+ return prefixes.iterator();
+ }
+
+ public String getNamespaceURI(String prefix) {
+ String uri = (String) namespaces.get(prefix);
+ if (uri == null) {
+ uri = parent.getNamespaceURI(prefix);
+ }
+ return uri;
+ }
+
+ public String getPrefix(String namespaceURI) {
+ for (SimpleNamespaceContext context = this; context != null; context = context.parent) {
+ for (Iterator it = context.namespaces.keySet().iterator(); it.hasNext();) {
+ Map.Entry entry = (Map.Entry) it.next();
+ if (entry.getValue().equals(namespaceURI)) {
+ return (String) entry.getKey();
+ }
+ }
+ }
+ return null;
+ }
+
+ public Iterator getPrefixes(String namespaceURI) {
+ HashSet prefixes = new HashSet();
+ for (SimpleNamespaceContext context = this; context != null; context = context.parent) {
+ for (Iterator it = context.namespaces.keySet().iterator(); it.hasNext();) {
+ Map.Entry entry = (Map.Entry) it.next();
+ if (entry.getValue().equals(namespaceURI)) {
+ prefixes.add(entry.getKey());
+ }
+ }
+ }
+ return prefixes.iterator();
+ }
+
+ }
+
+
+}
Propchange: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/jaxp/ExtendedXMLStreamReader.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/jaxp/FragmentStreamReader.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/jaxp/FragmentStreamReader.java?rev=379627&r1=379626&r2=379627&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/jaxp/FragmentStreamReader.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/jaxp/FragmentStreamReader.java Tue Feb 21 15:40:05 2006
@@ -1,139 +1,139 @@
-/*
- * Copyright 2005-2006 The 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.servicemix.jbi.jaxp;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.xml.namespace.NamespaceContext;
-import javax.xml.stream.XMLStreamConstants;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-import javax.xml.stream.util.StreamReaderDelegate;
-
-public class FragmentStreamReader extends StreamReaderDelegate implements XMLStreamReader {
-
- private static final int STATE_START_DOC = 0;
- private static final int STATE_FIRST_ELEM = 1;
- private static final int STATE_FIRST_RUN = 2;
- private static final int STATE_RUN = 3;
- private static final int STATE_END_DOC = 4;
-
- private int depth;
- private int state = STATE_START_DOC;
- private int event = START_DOCUMENT;
- private List rootPrefixes;
-
- public FragmentStreamReader(XMLStreamReader parent) {
- super(parent);
- rootPrefixes = new ArrayList();
- NamespaceContext ctx = getParent().getNamespaceContext();
- if (ctx instanceof ExtendedNamespaceContext) {
- Iterator it = ((ExtendedNamespaceContext) ctx).getPrefixes();
- while (it.hasNext()) {
- String prefix = it.next().toString();
- rootPrefixes.add(prefix);
- }
- }
- }
-
- public int getEventType() {
- return event;
- }
-
- public int next() throws XMLStreamException {
- switch (state) {
- case STATE_START_DOC:
- state = STATE_FIRST_ELEM;
- event = START_DOCUMENT;
- break;
- case STATE_FIRST_ELEM:
- state = STATE_FIRST_RUN;
- depth++;
- event = START_ELEMENT;
- break;
- case STATE_FIRST_RUN:
- state = STATE_RUN;
- // do not break
- case STATE_RUN:
- event = getParent().next();
- if (event == START_ELEMENT) {
- depth++;
- } else if (event == END_ELEMENT) {
- depth--;
- if (depth == 0) {
- state = STATE_END_DOC;
- }
- }
- break;
- case STATE_END_DOC:
- event = END_DOCUMENT;
- break;
- default:
- throw new IllegalStateException();
- }
- return event;
- }
-
- public int nextTag() throws XMLStreamException {
- int eventType = next();
- while((eventType == XMLStreamConstants.CHARACTERS && isWhiteSpace()) // skip whitespace
- || (eventType == XMLStreamConstants.CDATA && isWhiteSpace()) // skip whitespace
- || eventType == XMLStreamConstants.SPACE
- || eventType == XMLStreamConstants.PROCESSING_INSTRUCTION
- || eventType == XMLStreamConstants.COMMENT) {
- eventType = next();
- }
- if (eventType != XMLStreamConstants.START_ELEMENT && eventType != XMLStreamConstants.END_ELEMENT) {
- throw new XMLStreamException("expected start or end tag", getLocation());
- }
- return eventType;
- }
-
- public int getNamespaceCount() {
- if (state == STATE_FIRST_RUN) {
- return rootPrefixes.size();
- } else {
- return getParent().getNamespaceCount();
- }
- }
-
- public String getNamespacePrefix(int i) {
- if (state == STATE_FIRST_RUN) {
- return (String) rootPrefixes.get(i);
- } else {
- return getParent().getNamespacePrefix(i);
- }
- }
-
- public String getNamespaceURI(int i) {
- if (state == STATE_FIRST_RUN) {
- return getParent().getNamespaceContext().getNamespaceURI((String) rootPrefixes.get(i));
- } else {
- return getParent().getNamespaceURI(i);
- }
- }
-
- public String getNamespaceURI(String prefix) {
- if (state == STATE_FIRST_RUN) {
- return getParent().getNamespaceContext().getNamespaceURI(prefix);
- } else {
- return getParent().getNamespaceURI(prefix);
- }
- }
-
-}
+/*
+ * Copyright 2005-2006 The 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.servicemix.jbi.jaxp;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.util.StreamReaderDelegate;
+
+public class FragmentStreamReader extends StreamReaderDelegate implements XMLStreamReader {
+
+ private static final int STATE_START_DOC = 0;
+ private static final int STATE_FIRST_ELEM = 1;
+ private static final int STATE_FIRST_RUN = 2;
+ private static final int STATE_RUN = 3;
+ private static final int STATE_END_DOC = 4;
+
+ private int depth;
+ private int state = STATE_START_DOC;
+ private int event = START_DOCUMENT;
+ private List rootPrefixes;
+
+ public FragmentStreamReader(XMLStreamReader parent) {
+ super(parent);
+ rootPrefixes = new ArrayList();
+ NamespaceContext ctx = getParent().getNamespaceContext();
+ if (ctx instanceof ExtendedNamespaceContext) {
+ Iterator it = ((ExtendedNamespaceContext) ctx).getPrefixes();
+ while (it.hasNext()) {
+ String prefix = it.next().toString();
+ rootPrefixes.add(prefix);
+ }
+ }
+ }
+
+ public int getEventType() {
+ return event;
+ }
+
+ public int next() throws XMLStreamException {
+ switch (state) {
+ case STATE_START_DOC:
+ state = STATE_FIRST_ELEM;
+ event = START_DOCUMENT;
+ break;
+ case STATE_FIRST_ELEM:
+ state = STATE_FIRST_RUN;
+ depth++;
+ event = START_ELEMENT;
+ break;
+ case STATE_FIRST_RUN:
+ state = STATE_RUN;
+ // do not break
+ case STATE_RUN:
+ event = getParent().next();
+ if (event == START_ELEMENT) {
+ depth++;
+ } else if (event == END_ELEMENT) {
+ depth--;
+ if (depth == 0) {
+ state = STATE_END_DOC;
+ }
+ }
+ break;
+ case STATE_END_DOC:
+ event = END_DOCUMENT;
+ break;
+ default:
+ throw new IllegalStateException();
+ }
+ return event;
+ }
+
+ public int nextTag() throws XMLStreamException {
+ int eventType = next();
+ while((eventType == XMLStreamConstants.CHARACTERS && isWhiteSpace()) // skip whitespace
+ || (eventType == XMLStreamConstants.CDATA && isWhiteSpace()) // skip whitespace
+ || eventType == XMLStreamConstants.SPACE
+ || eventType == XMLStreamConstants.PROCESSING_INSTRUCTION
+ || eventType == XMLStreamConstants.COMMENT) {
+ eventType = next();
+ }
+ if (eventType != XMLStreamConstants.START_ELEMENT && eventType != XMLStreamConstants.END_ELEMENT) {
+ throw new XMLStreamException("expected start or end tag", getLocation());
+ }
+ return eventType;
+ }
+
+ public int getNamespaceCount() {
+ if (state == STATE_FIRST_RUN) {
+ return rootPrefixes.size();
+ } else {
+ return getParent().getNamespaceCount();
+ }
+ }
+
+ public String getNamespacePrefix(int i) {
+ if (state == STATE_FIRST_RUN) {
+ return (String) rootPrefixes.get(i);
+ } else {
+ return getParent().getNamespacePrefix(i);
+ }
+ }
+
+ public String getNamespaceURI(int i) {
+ if (state == STATE_FIRST_RUN) {
+ return getParent().getNamespaceContext().getNamespaceURI((String) rootPrefixes.get(i));
+ } else {
+ return getParent().getNamespaceURI(i);
+ }
+ }
+
+ public String getNamespaceURI(String prefix) {
+ if (state == STATE_FIRST_RUN) {
+ return getParent().getNamespaceContext().getNamespaceURI(prefix);
+ } else {
+ return getParent().getNamespaceURI(prefix);
+ }
+ }
+
+}
Propchange: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/jaxp/FragmentStreamReader.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/jaxp/QNameHelper.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/jaxp/QNameHelper.java?rev=379627&r1=379626&r2=379627&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/jaxp/QNameHelper.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/jaxp/QNameHelper.java Tue Feb 21 15:40:05 2006
@@ -1,50 +1,50 @@
-/*
- * Copyright 2005-2006 The 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.servicemix.jbi.jaxp;
-
-import javax.xml.namespace.NamespaceContext;
-import javax.xml.namespace.QName;
-
-/**
- * @version $Revision: 1.1 $
- */
-public class QNameHelper {
-
- public static String getQualifiedName(QName qname) {
- String prefix = qname.getPrefix();
- String localPart = qname.getLocalPart();
- if (prefix != null && prefix.length() > 0) {
- return prefix + ":" + localPart;
- }
- return localPart;
- }
-
- /**
- * Turns the given String into a QName using the current namespace context
- */
- public static QName asQName(NamespaceContext context, String text) {
- int idx = text.indexOf(':');
- if (idx >= 0) {
- String prefix = text.substring(0, idx);
- String localPart = text.substring(idx + 1);
- String uri = context.getNamespaceURI(prefix);
- return new QName(uri, localPart, prefix);
- }
- else {
- return new QName(text);
- }
- }
-}
+/*
+ * Copyright 2005-2006 The 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.servicemix.jbi.jaxp;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+
+/**
+ * @version $Revision: 1.1 $
+ */
+public class QNameHelper {
+
+ public static String getQualifiedName(QName qname) {
+ String prefix = qname.getPrefix();
+ String localPart = qname.getLocalPart();
+ if (prefix != null && prefix.length() > 0) {
+ return prefix + ":" + localPart;
+ }
+ return localPart;
+ }
+
+ /**
+ * Turns the given String into a QName using the current namespace context
+ */
+ public static QName asQName(NamespaceContext context, String text) {
+ int idx = text.indexOf(':');
+ if (idx >= 0) {
+ String prefix = text.substring(0, idx);
+ String localPart = text.substring(idx + 1);
+ String uri = context.getNamespaceURI(prefix);
+ return new QName(uri, localPart, prefix);
+ }
+ else {
+ return new QName(text);
+ }
+ }
+}
Propchange: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/jaxp/QNameHelper.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/jaxp/StaxSource.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/jaxp/StaxSource.java?rev=379627&r1=379626&r2=379627&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/jaxp/StaxSource.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/jaxp/StaxSource.java Tue Feb 21 15:40:05 2006
@@ -1,217 +1,217 @@
-/*
- * Copyright 2005-2006 The 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.servicemix.jbi.jaxp;
-
-import javax.xml.XMLConstants;
-import javax.xml.stream.XMLStreamConstants;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-import javax.xml.transform.sax.SAXSource;
-
-import org.xml.sax.Attributes;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.DTDHandler;
-import org.xml.sax.EntityResolver;
-import org.xml.sax.ErrorHandler;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXNotRecognizedException;
-import org.xml.sax.SAXNotSupportedException;
-import org.xml.sax.SAXParseException;
-import org.xml.sax.XMLReader;
-import org.xml.sax.helpers.AttributesImpl;
-
-public class StaxSource extends SAXSource implements XMLReader {
-
- private XMLStreamReader streamReader;
-
- private ContentHandler contentHandler;
-
- private char[] chars = new char[1024];
-
- public StaxSource(XMLStreamReader streamReader) {
- this.streamReader = streamReader;
- setInputSource(new InputSource());
- }
-
- public XMLReader getXMLReader() {
- return this;
- }
-
- protected void parse() throws SAXException {
- try {
- contentHandler.startDocument();
- while (true) {
- switch (streamReader.getEventType()) {
- case XMLStreamConstants.ATTRIBUTE:
- case XMLStreamConstants.CDATA:
- break;
- case XMLStreamConstants.CHARACTERS:
- if (!streamReader.isWhiteSpace()) {
- for (int textLength = streamReader.getTextLength(); textLength > 0; textLength -= chars.length) {
- int l = Math.min(textLength, chars.length);
- streamReader.getTextCharacters(0, chars, 0, l);
- contentHandler.characters(chars, 0, l);
- }
- }
- break;
- case XMLStreamConstants.COMMENT:
- case XMLStreamConstants.DTD:
- break;
- case XMLStreamConstants.END_DOCUMENT:
- contentHandler.endDocument();
- return;
- case XMLStreamConstants.END_ELEMENT: {
- String uri = streamReader.getNamespaceURI();
- String localName = streamReader.getLocalName();
- String prefix = streamReader.getPrefix();
- String qname = prefix != null && prefix.length() > 0 ? prefix + ":" + localName : localName;
- contentHandler.endElement(uri, localName, qname);
- for (int i = 0; i < streamReader.getNamespaceCount(); i++) {
- //contentHandler.endPrefixMapping(streamReader.getNamespaceURI(i));
- }
- break;
- }
- case XMLStreamConstants.ENTITY_DECLARATION:
- case XMLStreamConstants.ENTITY_REFERENCE:
- case XMLStreamConstants.NAMESPACE:
- case XMLStreamConstants.NOTATION_DECLARATION:
- case XMLStreamConstants.PROCESSING_INSTRUCTION:
- case XMLStreamConstants.SPACE:
- case XMLStreamConstants.START_DOCUMENT:
- break;
- case XMLStreamConstants.START_ELEMENT: {
- for (int i = 0; i < streamReader.getNamespaceCount(); i++) {
- //contentHandler.startPrefixMapping(streamReader.getNamespacePrefix(i),
- // streamReader.getNamespaceURI(i));
- }
- String uri = streamReader.getNamespaceURI();
- String localName = streamReader.getLocalName();
- String prefix = streamReader.getPrefix();
- String qname = prefix != null && prefix.length() > 0 ? prefix + ":" + localName : localName;
- contentHandler.startElement(uri, localName, qname, getAttributes());
- break;
- }
- }
- streamReader.next();
- }
- } catch (XMLStreamException e) {
- throw new SAXParseException(e.getMessage(), null, null, e.getLocation().getLineNumber(), e.getLocation()
- .getColumnNumber(), e);
- }
- }
-
- protected String getQualifiedName() {
- String prefix = streamReader.getPrefix();
- if (prefix != null && prefix.length() > 0) {
- return prefix + ":" + streamReader.getLocalName();
- } else {
- return streamReader.getLocalName();
- }
- }
-
- protected Attributes getAttributes() {
- AttributesImpl attrs = new AttributesImpl();
- // Adding namespace declaration as attributes is necessary because
- // the xalan implementation that ships with SUN JDK 1.4 is bugged
- // and does not handle the startPrefixMapping method
- for (int i = 0; i < streamReader.getNamespaceCount(); i++) {
- String prefix = streamReader.getNamespacePrefix(i);
- String uri = streamReader.getNamespaceURI(i);
- // Default namespace
- if (prefix == null || prefix.length() == 0) {
- attrs.addAttribute(null,
- null,
- XMLConstants.XMLNS_ATTRIBUTE,
- "CDATA",
- uri);
- } else {
- attrs.addAttribute(XMLConstants.XMLNS_ATTRIBUTE_NS_URI,
- prefix,
- XMLConstants.XMLNS_ATTRIBUTE + ":" + prefix,
- "CDATA",
- uri);
- }
- }
- for (int i = 0; i < streamReader.getAttributeCount(); i++) {
- String uri = streamReader.getAttributeNamespace(i);
- String localName = streamReader.getAttributeLocalName(i);
- String prefix = streamReader.getAttributePrefix(i);
- String qName;
- if (prefix != null && prefix.length() > 0) {
- qName = prefix + ':' + localName;
- } else {
- qName = localName;
- }
- String type = streamReader.getAttributeType(i);
- String value = streamReader.getAttributeValue(i);
- attrs.addAttribute(uri, localName, qName, type, value);
- }
- return attrs;
- }
-
- public boolean getFeature(String name) throws SAXNotRecognizedException, SAXNotSupportedException {
- return false;
- }
-
- public void setFeature(String name, boolean value) throws SAXNotRecognizedException, SAXNotSupportedException {
- }
-
- public Object getProperty(String name) throws SAXNotRecognizedException, SAXNotSupportedException {
- return null;
- }
-
- public void setProperty(String name, Object value) throws SAXNotRecognizedException, SAXNotSupportedException {
- }
-
- public void setEntityResolver(EntityResolver resolver) {
- }
-
- public EntityResolver getEntityResolver() {
- return null;
- }
-
- public void setDTDHandler(DTDHandler handler) {
- }
-
- public DTDHandler getDTDHandler() {
- return null;
- }
-
- public void setContentHandler(ContentHandler handler) {
- this.contentHandler = handler;
- }
-
- public ContentHandler getContentHandler() {
- return this.contentHandler;
- }
-
- public void setErrorHandler(ErrorHandler handler) {
- }
-
- public ErrorHandler getErrorHandler() {
- return null;
- }
-
- public void parse(InputSource input) throws SAXException {
- StaxSource.this.parse();
- }
-
- public void parse(String systemId) throws SAXException {
- StaxSource.this.parse();
- }
-
-}
+/*
+ * Copyright 2005-2006 The 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.servicemix.jbi.jaxp;
+
+import javax.xml.XMLConstants;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.transform.sax.SAXSource;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.DTDHandler;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXNotRecognizedException;
+import org.xml.sax.SAXNotSupportedException;
+import org.xml.sax.SAXParseException;
+import org.xml.sax.XMLReader;
+import org.xml.sax.helpers.AttributesImpl;
+
+public class StaxSource extends SAXSource implements XMLReader {
+
+ private XMLStreamReader streamReader;
+
+ private ContentHandler contentHandler;
+
+ private char[] chars = new char[1024];
+
+ public StaxSource(XMLStreamReader streamReader) {
+ this.streamReader = streamReader;
+ setInputSource(new InputSource());
+ }
+
+ public XMLReader getXMLReader() {
+ return this;
+ }
+
+ protected void parse() throws SAXException {
+ try {
+ contentHandler.startDocument();
+ while (true) {
+ switch (streamReader.getEventType()) {
+ case XMLStreamConstants.ATTRIBUTE:
+ case XMLStreamConstants.CDATA:
+ break;
+ case XMLStreamConstants.CHARACTERS:
+ if (!streamReader.isWhiteSpace()) {
+ for (int textLength = streamReader.getTextLength(); textLength > 0; textLength -= chars.length) {
+ int l = Math.min(textLength, chars.length);
+ streamReader.getTextCharacters(0, chars, 0, l);
+ contentHandler.characters(chars, 0, l);
+ }
+ }
+ break;
+ case XMLStreamConstants.COMMENT:
+ case XMLStreamConstants.DTD:
+ break;
+ case XMLStreamConstants.END_DOCUMENT:
+ contentHandler.endDocument();
+ return;
+ case XMLStreamConstants.END_ELEMENT: {
+ String uri = streamReader.getNamespaceURI();
+ String localName = streamReader.getLocalName();
+ String prefix = streamReader.getPrefix();
+ String qname = prefix != null && prefix.length() > 0 ? prefix + ":" + localName : localName;
+ contentHandler.endElement(uri, localName, qname);
+ for (int i = 0; i < streamReader.getNamespaceCount(); i++) {
+ //contentHandler.endPrefixMapping(streamReader.getNamespaceURI(i));
+ }
+ break;
+ }
+ case XMLStreamConstants.ENTITY_DECLARATION:
+ case XMLStreamConstants.ENTITY_REFERENCE:
+ case XMLStreamConstants.NAMESPACE:
+ case XMLStreamConstants.NOTATION_DECLARATION:
+ case XMLStreamConstants.PROCESSING_INSTRUCTION:
+ case XMLStreamConstants.SPACE:
+ case XMLStreamConstants.START_DOCUMENT:
+ break;
+ case XMLStreamConstants.START_ELEMENT: {
+ for (int i = 0; i < streamReader.getNamespaceCount(); i++) {
+ //contentHandler.startPrefixMapping(streamReader.getNamespacePrefix(i),
+ // streamReader.getNamespaceURI(i));
+ }
+ String uri = streamReader.getNamespaceURI();
+ String localName = streamReader.getLocalName();
+ String prefix = streamReader.getPrefix();
+ String qname = prefix != null && prefix.length() > 0 ? prefix + ":" + localName : localName;
+ contentHandler.startElement(uri, localName, qname, getAttributes());
+ break;
+ }
+ }
+ streamReader.next();
+ }
+ } catch (XMLStreamException e) {
+ throw new SAXParseException(e.getMessage(), null, null, e.getLocation().getLineNumber(), e.getLocation()
+ .getColumnNumber(), e);
+ }
+ }
+
+ protected String getQualifiedName() {
+ String prefix = streamReader.getPrefix();
+ if (prefix != null && prefix.length() > 0) {
+ return prefix + ":" + streamReader.getLocalName();
+ } else {
+ return streamReader.getLocalName();
+ }
+ }
+
+ protected Attributes getAttributes() {
+ AttributesImpl attrs = new AttributesImpl();
+ // Adding namespace declaration as attributes is necessary because
+ // the xalan implementation that ships with SUN JDK 1.4 is bugged
+ // and does not handle the startPrefixMapping method
+ for (int i = 0; i < streamReader.getNamespaceCount(); i++) {
+ String prefix = streamReader.getNamespacePrefix(i);
+ String uri = streamReader.getNamespaceURI(i);
+ // Default namespace
+ if (prefix == null || prefix.length() == 0) {
+ attrs.addAttribute(null,
+ null,
+ XMLConstants.XMLNS_ATTRIBUTE,
+ "CDATA",
+ uri);
+ } else {
+ attrs.addAttribute(XMLConstants.XMLNS_ATTRIBUTE_NS_URI,
+ prefix,
+ XMLConstants.XMLNS_ATTRIBUTE + ":" + prefix,
+ "CDATA",
+ uri);
+ }
+ }
+ for (int i = 0; i < streamReader.getAttributeCount(); i++) {
+ String uri = streamReader.getAttributeNamespace(i);
+ String localName = streamReader.getAttributeLocalName(i);
+ String prefix = streamReader.getAttributePrefix(i);
+ String qName;
+ if (prefix != null && prefix.length() > 0) {
+ qName = prefix + ':' + localName;
+ } else {
+ qName = localName;
+ }
+ String type = streamReader.getAttributeType(i);
+ String value = streamReader.getAttributeValue(i);
+ attrs.addAttribute(uri, localName, qName, type, value);
+ }
+ return attrs;
+ }
+
+ public boolean getFeature(String name) throws SAXNotRecognizedException, SAXNotSupportedException {
+ return false;
+ }
+
+ public void setFeature(String name, boolean value) throws SAXNotRecognizedException, SAXNotSupportedException {
+ }
+
+ public Object getProperty(String name) throws SAXNotRecognizedException, SAXNotSupportedException {
+ return null;
+ }
+
+ public void setProperty(String name, Object value) throws SAXNotRecognizedException, SAXNotSupportedException {
+ }
+
+ public void setEntityResolver(EntityResolver resolver) {
+ }
+
+ public EntityResolver getEntityResolver() {
+ return null;
+ }
+
+ public void setDTDHandler(DTDHandler handler) {
+ }
+
+ public DTDHandler getDTDHandler() {
+ return null;
+ }
+
+ public void setContentHandler(ContentHandler handler) {
+ this.contentHandler = handler;
+ }
+
+ public ContentHandler getContentHandler() {
+ return this.contentHandler;
+ }
+
+ public void setErrorHandler(ErrorHandler handler) {
+ }
+
+ public ErrorHandler getErrorHandler() {
+ return null;
+ }
+
+ public void parse(InputSource input) throws SAXException {
+ StaxSource.this.parse();
+ }
+
+ public void parse(String systemId) throws SAXException {
+ StaxSource.this.parse();
+ }
+
+}
Propchange: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/jaxp/StaxSource.java
------------------------------------------------------------------------------
svn:eol-style = native