Author: lischke
Date: Tue Mar 1 05:47:22 2005
New Revision: 155778
URL: http://svn.apache.org/viewcvs?view=rev&rev=155778
Log:
added parser and fixed bug in Topic.addTopic
Added:
incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/util/TopicSpaceParser.java
Modified:
incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/impl/TopicImpl.java
Modified:
incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/impl/TopicImpl.java
URL:
http://svn.apache.org/viewcvs/incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/impl/TopicImpl.java?view=diff&r1=155777&r2=155778
==============================================================================
---
incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/impl/TopicImpl.java
(original)
+++
incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/impl/TopicImpl.java
Tue Mar 1 05:47:22 2005
@@ -54,7 +54,8 @@
List topicPath = new LinkedList();
- topicPath.addAll( m_topicPath );
+ if(m_topicPath!=null)
+ topicPath.addAll( m_topicPath );
topicPath.add( topic.getName() );
topic.setTopicPath( topicPath );
@@ -214,5 +215,9 @@
public Topic getParent()
{
return null; //To change body of implemented methods use File |
Settings | File Templates.
+ }
+
+ public String toString(){
+ return getName();
}
}
Added:
incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/util/TopicSpaceParser.java
URL:
http://svn.apache.org/viewcvs/incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/util/TopicSpaceParser.java?view=auto&rev=155778
==============================================================================
---
incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/util/TopicSpaceParser.java
(added)
+++
incubator/hermes/trunk/src/java/org/apache/ws/notification/topics/util/TopicSpaceParser.java
Tue Mar 1 05:47:22 2005
@@ -0,0 +1,83 @@
+/*
+ * TopicSpaceParser.java
+ *
+ * Created on 1. MÃrz 2005, 12:54
+ */
+
+package org.apache.ws.notification.topics.util;
+import org.apache.ws.notification.topics.*;
+import org.apache.ws.notification.topics.impl.TopicSpaceImpl;
+import org.apache.ws.notification.topics.impl.TopicImpl;
+import java.io.InputStream;
+import javax.xml.parsers.*;
+import org.xml.sax.*;
+import org.xml.sax.helpers.DefaultHandler;
+/**
+ *
+ * @author Stefan Lischke
+ */
+public class TopicSpaceParser extends DefaultHandler{
+ private static TopicSpace m_topicSpace;
+ private static java.util.Stack stack;
+ private int depth=0;
+ private String tns;
+
+ public static TopicSpace parse(InputStream is){
+ // Use an instance of ourselves as the SAX event handler
+ DefaultHandler handler = new TopicSpaceParser();
+ // Parse the input with the default (non-validating) parser
+ stack= new java.util.Stack();
+ try{
+ SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser();
+ //System.out.println("start parsing");
+ saxParser.parse( is, handler );
+ //System.out.println("end parsing");
+
+ }catch(Exception e){
+ e.printStackTrace();
+ }
+ return m_topicSpace;
+ }
+
+ public void startElement( String namespaceURI,
+ String localName, // local name
+ String qName, // qualified name
+ Attributes attrs ) throws SAXException {
+ try{
+ //System.out.println("start element "+qName);
+ if(qName.endsWith("topicSpace")){
+ tns=attrs.getValue("targetNamespace");
+ m_topicSpace=new TopicSpaceImpl(tns);
+ //System.out.println("topicspace "+tns);
+ }
+ if(qName.endsWith("topic")){
+ Topic t=new TopicImpl(attrs.getValue("name"));
+ if(depth==0){
+ m_topicSpace.addTopic(t);
+ stack.push(t);
+ }else{
+ Topic in = (Topic)stack.peek();
+ in.addTopic(t);
+ stack.push(t);
+ }
+ //System.out.println(depth+" : "+attrs.getValue("name"));
+ depth++;
+ }
+ }catch(Exception e){
+ e.printStackTrace();
+ }
+ }
+
+ public void endElement( String namespaceURI,
+ String localName, // local name
+ String qName ) // qualified name
+ throws SAXException {
+ if(qName.endsWith("topic")){
+ if(depth>0){
+ depth--;
+ stack.pop();
+ }
+
+ }
+ }
+}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]