Author: cziegeler
Date: Tue Aug 14 02:02:14 2007
New Revision: 565667
URL: http://svn.apache.org/viewvc?view=rev&rev=565667
Log:
Turn on namespace processing and simplify handler interface.
Modified:
felix/trunk/scr/src/main/java/org/apache/felix/scr/XmlHandler.java
felix/trunk/scr/src/main/java/org/apache/felix/scr/parser/KXml2SAXHandler.java
felix/trunk/scr/src/main/java/org/apache/felix/scr/parser/KXml2SAXParser.java
Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/XmlHandler.java
URL:
http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/XmlHandler.java?view=diff&rev=565667&r1=565666&r2=565667
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/XmlHandler.java
(original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/XmlHandler.java Tue Aug
14 02:02:14 2007
@@ -50,11 +50,10 @@
*
* @param uri
* @param localName
- * @param qName
* @param attrib
* @exception ParseException
**/
- public void startElement(String uri, String localName, String qName,
Properties attrib)
+ public void startElement(String uri, String localName, Properties attrib)
throws ParseException {
// we process elements in the default namespace and in the scr
namespace only
// TODO - To be 100% correct we should only listen to the scr namespace
@@ -172,10 +171,9 @@
*
* @param uri
* @param localName
- * @param qName
* @exception ParseException
*/
- public void endElement(String uri, String localName, String qName) throws
ParseException
+ public void endElement(String uri, String localName) throws ParseException
{
// we process elements in the default namespace and in the scr
namespace only
// TODO - To be 100% correct we should only listen to the scr namespace
@@ -204,30 +202,39 @@
return this.m_components;
}
- public void characters( char[] ch, int offset, int length ) throws
Exception
+ /**
+ * @see
org.apache.felix.scr.parser.KXml2SAXHandler#characters(java.lang.String)
+ */
+ public void characters( String text ) throws ParseException
{
// 112.4.5 If the value attribute is not specified, the body must
contain one or more values
if ( this.m_pendingProperty != null )
{
- this.m_pendingProperty.setValues( new String( ch, offset, length )
);
+ this.m_pendingProperty.setValues( text );
this.m_currentComponent.addProperty( this.m_pendingProperty );
this.m_pendingProperty = null;
}
}
- public void processingInstruction(String target, String data) throws
Exception {
+ /**
+ * @see
org.apache.felix.scr.parser.KXml2SAXHandler#processingInstruction(java.lang.String,
java.lang.String)
+ */
+ public void processingInstruction(String target, String data) throws
ParseException {
// Not used
-
}
+ /**
+ * @see org.apache.felix.scr.parser.KXml2SAXHandler#setLineNumber(int)
+ */
public void setLineNumber(int lineNumber) {
// Not used
-
}
+ /**
+ * @see org.apache.felix.scr.parser.KXml2SAXHandler#setColumnNumber(int)
+ */
public void setColumnNumber(int columnNumber) {
// Not used
-
}
}
Modified:
felix/trunk/scr/src/main/java/org/apache/felix/scr/parser/KXml2SAXHandler.java
URL:
http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/parser/KXml2SAXHandler.java?view=diff&rev=565667&r1=565666&r2=565667
==============================================================================
---
felix/trunk/scr/src/main/java/org/apache/felix/scr/parser/KXml2SAXHandler.java
(original)
+++
felix/trunk/scr/src/main/java/org/apache/felix/scr/parser/KXml2SAXHandler.java
Tue Aug 14 02:02:14 2007
@@ -1,4 +1,4 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -21,54 +21,49 @@
import java.util.Properties;
/**
- * Interface for SAX handler with kXML
+ * Interface for a SAX like handler with kXML
*/
public interface KXml2SAXHandler {
- /**
+ /**
* Method called when parsing text
*
- * @param ch
- * @param offset
- * @param length
- * @exception SAXException
+ * @param text
+ * @exception ParseException
*/
- public void characters(char[] ch, int offset, int length) throws
Exception;
+ void characters(String text) throws ParseException;
- /**
+ /**
* Method called when a tag opens
*
* @param uri
* @param localName
- * @param qName
* @param attrib
- * @exception SAXException
- **/
- public void startElement(
+ * @exception ParseException
+ */
+ void startElement(
String uri,
String localName,
- String qName,
Properties attrib)
- throws Exception;
- /**
+ throws ParseException;
+
+ /**
* Method called when a tag closes
*
* @param uri
* @param localName
- * @param qName
- * @exception SAXException
+ * @exception ParseException
*/
- public void endElement(
- java.lang.String uri,
- java.lang.String localName,
- java.lang.String qName)
- throws Exception;
+ void endElement(
+ String uri,
+ String localName)
+ throws ParseException;
- public void processingInstruction(String target,
+ void processingInstruction(String target,
String data)
throws Exception;
-
- public void setLineNumber(int lineNumber);
- public void setColumnNumber(int columnNumber);
+ void setLineNumber(int lineNumber);
+
+ void setColumnNumber(int columnNumber);
}
Modified:
felix/trunk/scr/src/main/java/org/apache/felix/scr/parser/KXml2SAXParser.java
URL:
http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/parser/KXml2SAXParser.java?view=diff&rev=565667&r1=565666&r2=565667
==============================================================================
---
felix/trunk/scr/src/main/java/org/apache/felix/scr/parser/KXml2SAXParser.java
(original)
+++
felix/trunk/scr/src/main/java/org/apache/felix/scr/parser/KXml2SAXParser.java
Tue Aug 14 02:02:14 2007
@@ -43,6 +43,7 @@
public KXml2SAXParser(Reader reader) throws XmlPullParserException {
super();
this.setInput(reader);
+ this.setFeature(FEATURE_PROCESS_NAMESPACES, true);
}
/**
@@ -65,13 +66,12 @@
handler.startElement(
this.getNamespace(),
this.getName(),
- this.getName(),
props);
} else if (this.getEventType() ==
XmlPullParser.END_TAG) {
- handler.endElement(this.getNamespace(),
this.getName(), this.getName());
+ handler.endElement(this.getNamespace(),
this.getName());
} else if (this.getEventType() == XmlPullParser.TEXT) {
String text = this.getText();
-
handler.characters(text.toCharArray(),0,text.length());
+ handler.characters(text);
} else if (this.getEventType() ==
XmlPullParser.PROCESSING_INSTRUCTION) {
// TODO extract the target from the
evt.getText()
handler.processingInstruction(null,this.getText());