kxml2-2.3.0/0000775000175000017500000000000011402717262010701 5ustar neoneokxml2-2.3.0/bin/0000755000175000017500000000000011402717307011447 5ustar neoneokxml2-2.3.0/bin/sample.xml0000644000175000017500000000035607551371104013457 0ustar neoneo bar This is in a new namespace kxml2-2.3.0/bin/META-INF/0000755000175000017500000000000010436614134012607 5ustar neoneokxml2-2.3.0/bin/META-INF/services/0000755000175000017500000000000010436614134014432 5ustar neoneokxml2-2.3.0/bin/META-INF/services/org.xmlpull.v1.XmlPullParserFactory0000644000175000017500000000007007534172772023277 0ustar neoneoorg.kxml2.io.KXmlParser,org.kxml2.io.KXmlSerializer kxml2-2.3.0/bin/bogdan.xml0000644000175000017500000000052310063647170013425 0ustar neoneo bar This is in a new namespace (06/15/2004 00:31) <HTML><BODY bgcolor="#ffffff"><FONT LANG="0">hiho</FONT></BODY></HTML> kxml2-2.3.0/bin/simple.xml0000644000175000017500000000036307551371104013465 0ustar neoneo simple test without namespaces! This is in a test text namespace kxml2-2.3.0/bin/org/0000755000175000017500000000000010436614134012236 5ustar neoneokxml2-2.3.0/bin/org/kxml2/0000755000175000017500000000000010436614134013273 5ustar neoneokxml2-2.3.0/bin/org/kxml2/kdom/0000755000175000017500000000000011402717307014225 5ustar neoneokxml2-2.3.0/bin/org/kxml2/io/0000755000175000017500000000000011402717307013702 5ustar neoneokxml2-2.3.0/bin/org/kxml2/wap/0000755000175000017500000000000011402717307014062 5ustar neoneokxml2-2.3.0/bin/org/kxml2/wap/wml/0000755000175000017500000000000011402717307014661 5ustar neoneokxml2-2.3.0/bin/org/kxml2/wap/syncml/0000755000175000017500000000000011402717307015367 5ustar neoneokxml2-2.3.0/bin/org/kxml2/wap/wv/0000755000175000017500000000000011402717307014516 5ustar neoneokxml2-2.3.0/www/0000755000175000017500000000000010435016414011517 5ustar neoneokxml2-2.3.0/www/index.shtml0000644000175000017500000000450510344653454013715 0ustar neoneo kXML News

kXML News

2005-12-04 kXML 2 release 2.2.2: Maintenance release (also fixed links to IBM tutorial below and on the kxml2 page)
2005-03-10 kXML 2 release 2.2.1: Bugfix for a getPositionDescription() problem if setReader was not called (1093859); thanks to Joe Chenbug.
2004-05-15 kXML 2 release 2.1.9: Relaxed mode improvements.
2003-09-01 New article about kXML 2 written by Naveen Balani published at IBM Developer Works
2003-04-04 New article about kXML 1 written by Robert Cadenaat published at DevX
2002-03-25 New article about kXML and WBXML comprssion written by Eric Giguere available at the SUN developer connection
2002-03-07 New artikle about kXML 1 written by Jonathan Knudsen available at the SUN developer connection
2002-02-20 kXML 1.21 available
2001-07-25 New article about kXML 1 written by Eric Giguere available at the SUN developer connection
2001-07-25 Release of kXML 1.0
2001-02-01 With availability of version 0.81, kXML had moved to enhydra.org
2000-07-25 Initial Public Release of kXML 1
1999-12-25 Initial Release of <XP>, a pull wrapper for SAX parsers
kxml2-2.3.0/www/favicon.ico0000644000175000017500000000047610215013664013647 0ustar neoneo(( HHüŠŒä®¬ģžœŌĘÄō–”Ō¾¼Ü¶“즤ĢĪĢü’”H1†ƒ(‚ˆ@8`ˆVˆ@831ˆdˆ h‚C1(2@Hƒˆ$kxml2-2.3.0/www/epilog.shtml0000644000175000017500000000002210212712670014041 0ustar neoneokxml2-2.3.0/www/about.shtml0000644000175000017500000000736210214606512013711 0ustar neoneo About kXML

About kXML

kXML is a small XML pull parser, specially designed for constrained environments such as Applets, Personal Java or MIDP devices. In contrast to kXML 1, kXML 2 is based on the common XML pull API.

Pull based XML parsing combines some of the advantages of SAX and DOM:

kXML History and Versions

XP XP was the predecessor of kXML, a simple wrapper that turned a given SAX parser into a pull parser. XP was originally implemented to simplify message (de)serialization in the Infolayer project, which is quite cumbersome with push parsers (SAX).
kXML1 To use the pull parser on embedded devices, it was necessary to get rid of the SAX dependency. kXML1 is a simple pull parser, based on event objects. kXML1 is now deprecated, please use kXML2 instead. kXML1 is archieved at kxml.objectweb.org.
kXML2 The current version of kXML. In contrast to kXML1, it features cursor API instead of event objects, leading to a reduced footprint and less object creation overhead. kXML 2 is released under the BSD license.
kXML3 kXML 3 will split the parser and API support available in versions for both, XmlPull and StAX

Special Features

kXML has two "special" features that are intended to simplify developers' life in constrained environments:

XML Conformance

In order to keep kXML as small as possible, no efforts are made to recognize certain well-formedness errors that would require additional detection code, such as

Thus, kXML will accept some XML documents that should actually be rejected. Of course, an XML parser should detect all syntax errors to discourage the creation of bogous documents that work with one parser and do not work with another. Thus, if you are not limited by memory constraints, please use MXP, which is also faster than kXML.

(C) 1999-2005 Stefan Haustein

kxml2-2.3.0/www/upload.txt0000644000175000017500000000017510340206334013544 0ustar neoneo# upload with the following command # (from this directory): scp -r * shell.sourceforge.net:/home/groups/k/kx/kxml/htdocs/ kxml2-2.3.0/www/prolog.shtml0000644000175000017500000000400210214634052014065 0ustar neoneo
kXML
News
About
kXML 2
kXML 3
Development
Links
SF Logo
    kxml2-2.3.0/www/kxml2/0000755000175000017500000000000010446737140012564 5ustar neoneokxml2-2.3.0/www/kxml2/samples.shtml0000644000175000017500000000140210214143346015266 0ustar neoneo kXML 1 Samples

kXML 1 Samples

Some small code snippets illustrating basic parsing operations can be examined via viewcvs:

There are also some nice open source projects built on kXML that illustrate how to use the parser:

  • RSS Reader - a MIDP RSS reader using kXML 2.1.7
  • Azure - a free blog client for your phone and PDA
kxml2-2.3.0/www/kxml2/index.shtml0000644000175000017500000000522210344653020014734 0ustar neoneo kXML 2

kXML 2

kXML 2 implements the XmlPull API. Please find general information about XmlPull parsers including the interface documentation at xmlpull.org.

kXML 2 is licensed under the BSD license.

Naveen Balani has written a nice introduction to kxml 2 for IBM Developer Works.

Recommended Calling Conventions

When handing an XMLpull parser to subroutines, it is recommended that the current position is on a start tag (allowing the subroutine to analyze the attributes). The post condition should usually be that the current position is the matching end tag.

Parsing Element-Only and Text-Only Content

General XML content can be parsed with the XML pull API using a loop advanving to the next event and a switch statement that depends on the event type. However, when using XML for data transfer (in contrast to text documents), most XML elements contain either only text or only other elements (possibly with further sub-elements). For those common cases, the parsing process can be simplified significantly by using the XmlPull API methods nextTag and nextText. Additionally, the method require() may optionally be used to assert a certain parser state. The following sample illustrates both situations and methods. The outer element elements has element-only content; the contained text-elements have text-only content:

<elements>
  <text>text1</text>
  <text>text2</text>
</elements>  

Parsing Code

parser.nextTag();
parser.require(XmlPullParser.START_TAG, null, "elements");

while(parser.nextTag() == XmlPullParser.START_TAG) {
  parser.require(XmlPullParser.START_TAG, null, "text");

   // handle element content
   System.out.println("text content: "+ parser.nextText());

  parser.require(XmlPullParser.END_TAG, null, "text");
}

parser.require(XmlPullParser.END_TAG, null, "elements");

nextTag() advances to the next start or end tag, skipping insignificant events such as white space, comments and PIs. nextText() requires that the current position is a start tag. It returns the text content of the corresponding element. The post condition is that the current position is an end tag. Please note that the calls require() are optional assertions, they may be left out completely.

kxml2-2.3.0/www/kxml2/javadoc/0000755000175000017500000000000010446737142014175 5ustar neoneokxml2-2.3.0/www/kxml2/javadoc/overview-summary.html0000644000175000017500000001400710446737142020426 0ustar neoneo Overview (kxml API)

kxml API

Packages
org.kxml2.io  
org.kxml2.kdom  
org.kxml2.wap  
org.kxml2.wap.syncml  
org.kxml2.wap.wml  
org.kxml2.wap.wv  

 



kxml2-2.3.0/www/kxml2/javadoc/allclasses-frame.html0000644000175000017500000000336710446737142020312 0ustar neoneo All Classes (kxml API) All Classes
Document
Element
KXmlParser
KXmlSerializer
Node
SyncML
Wbxml
WbxmlParser
WbxmlSerializer
Wml
WV
kxml2-2.3.0/www/kxml2/javadoc/stylesheet.css0000644000175000017500000000226210446737142017102 0ustar neoneo/* Javadoc style sheet */ /* Define colors, fonts and other style attributes here to override the defaults */ /* Page background color */ body { background-color: #FFFFFF } /* Headings */ h1 { font-size: 145% } /* Table colors */ .TableHeadingColor { background: #CCCCFF } /* Dark mauve */ .TableSubHeadingColor { background: #EEEEFF } /* Light mauve */ .TableRowColor { background: #FFFFFF } /* White */ /* Font used in left-hand frame lists */ .FrameTitleFont { font-size: 100%; font-family: Helvetica, Arial, sans-serif } .FrameHeadingFont { font-size: 90%; font-family: Helvetica, Arial, sans-serif } .FrameItemFont { font-size: 90%; font-family: Helvetica, Arial, sans-serif } /* Navigation bar fonts and colors */ .NavBarCell1 { background-color:#EEEEFF;} /* Light mauve */ .NavBarCell1Rev { background-color:#00008B;} /* Dark Blue */ .NavBarFont1 { font-family: Arial, Helvetica, sans-serif; color:#000000;} .NavBarFont1Rev { font-family: Arial, Helvetica, sans-serif; color:#FFFFFF;} .NavBarCell2 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF;} .NavBarCell3 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF;} kxml2-2.3.0/www/kxml2/javadoc/deprecated-list.html0000644000175000017500000001156710446737142020146 0ustar neoneo Deprecated List (kxml API)

Deprecated API


Contents


kxml2-2.3.0/www/kxml2/javadoc/overview-frame.html0000644000175000017500000000311110446737142020015 0ustar neoneo Overview (kxml API)
All Classes

Packages
org.kxml2.io
org.kxml2.kdom
org.kxml2.wap
org.kxml2.wap.syncml
org.kxml2.wap.wml
org.kxml2.wap.wv

  kxml2-2.3.0/www/kxml2/javadoc/resources/0000755000175000017500000000000010446737142016207 5ustar neoneokxml2-2.3.0/www/kxml2/javadoc/resources/inherit.gif0000644000175000017500000000007110446737142020336 0ustar neoneoGIF89a€’’’,„ ”½®DršjńԐ;߀Q@–¦…N;kxml2-2.3.0/www/kxml2/javadoc/overview-tree.html0000644000175000017500000001561110446737142017672 0ustar neoneo Class Hierarchy (kxml API)


Hierarchy For All Packages

Package Hierarchies:
org.kxml2.io, org.kxml2.kdom, org.kxml2.wap, org.kxml2.wap.syncml, org.kxml2.wap.wml, org.kxml2.wap.wv

Class Hierarchy

  • java.lang.Object
    • org.kxml2.io.KXmlParser (implements org.xmlpull.v1.XmlPullParser)
    • org.kxml2.io.KXmlSerializer (implements org.xmlpull.v1.XmlSerializer)
    • org.kxml2.kdom.Node
    • org.kxml2.wap.syncml.SyncML
    • org.kxml2.wap.WbxmlParser (implements org.xmlpull.v1.XmlPullParser)
    • org.kxml2.wap.WbxmlSerializer (implements org.xmlpull.v1.XmlSerializer)
    • org.kxml2.wap.wml.Wml
    • org.kxml2.wap.wv.WV

Interface Hierarchy



kxml2-2.3.0/www/kxml2/javadoc/index-all.html0000644000175000017500000021120710446737142016743 0ustar neoneo Index (kxml API)
A C D E F G I K L N O P R S T W

A

addChild(int, int, Object) - Method in class org.kxml2.kdom.Document
Adds a child at the given index position.
addChild(int, int, Object) - Method in class org.kxml2.kdom.Node
inserts the given child object of the given type at the given index.
addChild(int, Object) - Method in class org.kxml2.kdom.Node
convenience method for addChild (getChildCount (), child)
ATTR_START_TABLE - Static variable in class org.kxml2.wap.wml.Wml
 
ATTR_VALUE_TABLE - Static variable in class org.kxml2.wap.wml.Wml
 
attribute(String, String, String) - Method in class org.kxml2.io.KXmlSerializer
 
attribute(String, String, String) - Method in class org.kxml2.wap.WbxmlSerializer
 
attrStartTable - Static variable in class org.kxml2.wap.wv.WV
 
attrValueTable - Static variable in class org.kxml2.wap.wv.WV
 

C

cdsect(String) - Method in class org.kxml2.io.KXmlSerializer
 
CDSECT - Static variable in class org.kxml2.kdom.Node
 
cdsect(String) - Method in class org.kxml2.wap.WbxmlSerializer
 
checkPending(boolean) - Method in class org.kxml2.wap.WbxmlSerializer
 
clear() - Method in class org.kxml2.kdom.Element
removes all children and attributes
comment(String) - Method in class org.kxml2.io.KXmlSerializer
 
COMMENT - Static variable in class org.kxml2.kdom.Node
 
comment(String) - Method in class org.kxml2.wap.WbxmlSerializer
 
createDMParser() - Static method in class org.kxml2.wap.syncml.SyncML
 
createDMSerializer() - Static method in class org.kxml2.wap.syncml.SyncML
 
createElement(String, String) - Method in class org.kxml2.kdom.Element
Forwards creation request to parent if any, otherwise calls super.createElement.
createElement(String, String) - Method in class org.kxml2.kdom.Node
Builds a default element with the given properties.
createParser() - Static method in class org.kxml2.wap.syncml.SyncML
 
createParser() - Static method in class org.kxml2.wap.wml.Wml
Creates a WbxmlParser with the WML code pages set
createParser() - Static method in class org.kxml2.wap.wv.WV
 
createSerializer() - Static method in class org.kxml2.wap.syncml.SyncML
 
createSerializer() - Static method in class org.kxml2.wap.wml.Wml
 

D

defineEntityReplacementText(String, String) - Method in class org.kxml2.io.KXmlParser
 
defineEntityReplacementText(String, String) - Method in class org.kxml2.wap.WbxmlParser
 
docdecl(String) - Method in class org.kxml2.io.KXmlSerializer
 
DOCDECL - Static variable in class org.kxml2.kdom.Node
 
docdecl(String) - Method in class org.kxml2.wap.WbxmlSerializer
 
Document - Class in org.kxml2.kdom
The document consists of some legacy events and a single root element.
Document() - Constructor for class org.kxml2.kdom.Document
 
DOCUMENT - Static variable in class org.kxml2.kdom.Node
 

E

Element - Class in org.kxml2.kdom
In order to create an element, please use the createElement method instead of invoking the constructor directly.
Element() - Constructor for class org.kxml2.kdom.Element
 
ELEMENT - Static variable in class org.kxml2.kdom.Node
 
END - Static variable in interface org.kxml2.wap.Wbxml
 
endDocument() - Method in class org.kxml2.io.KXmlSerializer
 
endDocument() - Method in class org.kxml2.wap.WbxmlSerializer
 
endTag(String, String) - Method in class org.kxml2.io.KXmlSerializer
 
endTag(String, String) - Method in class org.kxml2.wap.WbxmlSerializer
 
ENTITY - Static variable in interface org.kxml2.wap.Wbxml
 
ENTITY_REF - Static variable in class org.kxml2.kdom.Node
 
entityRef(String) - Method in class org.kxml2.io.KXmlSerializer
 
entityRef(String) - Method in class org.kxml2.wap.WbxmlSerializer
 
EXT_0 - Static variable in interface org.kxml2.wap.Wbxml
 
EXT_1 - Static variable in interface org.kxml2.wap.Wbxml
 
EXT_2 - Static variable in interface org.kxml2.wap.Wbxml
 
EXT_I_0 - Static variable in interface org.kxml2.wap.Wbxml
 
EXT_I_1 - Static variable in interface org.kxml2.wap.Wbxml
 
EXT_I_2 - Static variable in interface org.kxml2.wap.Wbxml
 
EXT_T_0 - Static variable in interface org.kxml2.wap.Wbxml
 
EXT_T_1 - Static variable in interface org.kxml2.wap.Wbxml
 
EXT_T_2 - Static variable in interface org.kxml2.wap.Wbxml
 

F

flush() - Method in class org.kxml2.io.KXmlSerializer
 
flush() - Method in class org.kxml2.wap.WbxmlSerializer
ATTENTION: flush cannot work since Wbxml documents require buffering.

G

getAttributeCount() - Method in class org.kxml2.io.KXmlParser
 
getAttributeCount() - Method in class org.kxml2.kdom.Element
Returns the number of attributes of this element.
getAttributeCount() - Method in class org.kxml2.wap.WbxmlParser
 
getAttributeName(int) - Method in class org.kxml2.io.KXmlParser
 
getAttributeName(int) - Method in class org.kxml2.kdom.Element
 
getAttributeName(int) - Method in class org.kxml2.wap.WbxmlParser
 
getAttributeNamespace(int) - Method in class org.kxml2.io.KXmlParser
 
getAttributeNamespace(int) - Method in class org.kxml2.kdom.Element
 
getAttributeNamespace(int) - Method in class org.kxml2.wap.WbxmlParser
 
getAttributePrefix(int) - Method in class org.kxml2.io.KXmlParser
 
getAttributePrefix(int) - Method in class org.kxml2.wap.WbxmlParser
 
getAttributeType(int) - Method in class org.kxml2.io.KXmlParser
 
getAttributeType(int) - Method in class org.kxml2.wap.WbxmlParser
 
getAttributeValue(int) - Method in class org.kxml2.io.KXmlParser
 
getAttributeValue(String, String) - Method in class org.kxml2.io.KXmlParser
 
getAttributeValue(int) - Method in class org.kxml2.kdom.Element
 
getAttributeValue(String, String) - Method in class org.kxml2.kdom.Element
 
getAttributeValue(int) - Method in class org.kxml2.wap.WbxmlParser
 
getAttributeValue(String, String) - Method in class org.kxml2.wap.WbxmlParser
 
getChild(int) - Method in class org.kxml2.kdom.Node
Returns the child object at the given index.
getChildCount() - Method in class org.kxml2.kdom.Node
Returns the number of child objects
getColumnNumber() - Method in class org.kxml2.io.KXmlParser
 
getColumnNumber() - Method in class org.kxml2.wap.WbxmlParser
 
getDepth() - Method in class org.kxml2.io.KXmlParser
 
getDepth() - Method in class org.kxml2.io.KXmlSerializer
 
getDepth() - Method in class org.kxml2.wap.WbxmlParser
 
getDepth() - Method in class org.kxml2.wap.WbxmlSerializer
 
getElement(int) - Method in class org.kxml2.kdom.Node
returns the element at the given index.
getElement(String, String) - Method in class org.kxml2.kdom.Node
Returns the element with the given namespace and name.
getEncoding() - Method in class org.kxml2.kdom.Document
returns "#document"
getEventType() - Method in class org.kxml2.io.KXmlParser
 
getEventType() - Method in class org.kxml2.wap.WbxmlParser
 
getFeature(String) - Method in class org.kxml2.io.KXmlParser
 
getFeature(String) - Method in class org.kxml2.io.KXmlSerializer
 
getFeature(String) - Method in class org.kxml2.wap.WbxmlParser
 
getFeature(String) - Method in class org.kxml2.wap.WbxmlSerializer
 
getInputEncoding() - Method in class org.kxml2.io.KXmlParser
 
getInputEncoding() - Method in class org.kxml2.wap.WbxmlParser
 
getLineNumber() - Method in class org.kxml2.io.KXmlParser
 
getLineNumber() - Method in class org.kxml2.wap.WbxmlParser
 
getName() - Method in class org.kxml2.io.KXmlParser
 
getName() - Method in class org.kxml2.io.KXmlSerializer
 
getName() - Method in class org.kxml2.kdom.Document
 
getName() - Method in class org.kxml2.kdom.Element
returns the (local) name of the element
getName() - Method in class org.kxml2.wap.WbxmlParser
 
getName() - Method in class org.kxml2.wap.WbxmlSerializer
 
getNamespace(String) - Method in class org.kxml2.io.KXmlParser
 
getNamespace() - Method in class org.kxml2.io.KXmlParser
 
getNamespace() - Method in class org.kxml2.io.KXmlSerializer
 
getNamespace() - Method in class org.kxml2.kdom.Element
returns the namespace of the element
getNamespace(String) - Method in class org.kxml2.wap.WbxmlParser
 
getNamespace() - Method in class org.kxml2.wap.WbxmlParser
 
getNamespace() - Method in class org.kxml2.wap.WbxmlSerializer
 
getNamespaceCount(int) - Method in class org.kxml2.io.KXmlParser
 
getNamespaceCount() - Method in class org.kxml2.kdom.Element
returns the number of declared namespaces, NOT including parent elements
getNamespaceCount(int) - Method in class org.kxml2.wap.WbxmlParser
 
getNamespacePrefix(int) - Method in class org.kxml2.io.KXmlParser
 
getNamespacePrefix(int) - Method in class org.kxml2.kdom.Element
 
getNamespacePrefix(int) - Method in class org.kxml2.wap.WbxmlParser
 
getNamespaceUri(int) - Method in class org.kxml2.io.KXmlParser
 
getNamespaceUri(String) - Method in class org.kxml2.kdom.Element
returns the namespace for the given prefix
getNamespaceUri(int) - Method in class org.kxml2.kdom.Element
 
getNamespaceUri(int) - Method in class org.kxml2.wap.WbxmlParser
 
getParent() - Method in class org.kxml2.kdom.Element
Returns the parent node of this element
getPositionDescription() - Method in class org.kxml2.io.KXmlParser
 
getPositionDescription() - Method in class org.kxml2.wap.WbxmlParser
 
getPrefix() - Method in class org.kxml2.io.KXmlParser
 
getPrefix(String, boolean) - Method in class org.kxml2.io.KXmlSerializer
 
getPrefix() - Method in class org.kxml2.wap.WbxmlParser
 
getPrefix(String, boolean) - Method in class org.kxml2.wap.WbxmlSerializer
 
getProperty(String) - Method in class org.kxml2.io.KXmlParser
 
getProperty(String) - Method in class org.kxml2.io.KXmlSerializer
 
getProperty(String) - Method in class org.kxml2.wap.WbxmlParser
 
getProperty(String) - Method in class org.kxml2.wap.WbxmlSerializer
 
getRoot() - Method in class org.kxml2.kdom.Element
Returns the root node, determined by ascending to the all parents un of the root element.
getRootElement() - Method in class org.kxml2.kdom.Document
returns the root element of this document.
getStandalone() - Method in class org.kxml2.kdom.Document
 
getText() - Method in class org.kxml2.io.KXmlParser
 
getText(int) - Method in class org.kxml2.kdom.Node
Returns the text node with the given index or null if the node with the given index is not a text node.
getText() - Method in class org.kxml2.wap.WbxmlParser
 
getTextCharacters(int[]) - Method in class org.kxml2.io.KXmlParser
 
getTextCharacters(int[]) - Method in class org.kxml2.wap.WbxmlParser
 
getType(int) - Method in class org.kxml2.kdom.Node
Returns the type of the child at the given index.
getWapCode() - Method in class org.kxml2.wap.WbxmlParser
Returns the token ID for start tags or the event type for wap proprietary events such as OPAQUE.
getWapExtensionData() - Method in class org.kxml2.wap.WbxmlParser
 

I

IGNORABLE_WHITESPACE - Static variable in class org.kxml2.kdom.Node
 
ignorableWhitespace(String) - Method in class org.kxml2.io.KXmlSerializer
 
ignorableWhitespace(String) - Method in class org.kxml2.wap.WbxmlSerializer
 
indexOf(String, String, int) - Method in class org.kxml2.kdom.Node
Performs search for an element with the given namespace and name, starting at the given start index.
init() - Method in class org.kxml2.kdom.Element
called when all properties are set, but before children are parsed.
isAttributeDefault(int) - Method in class org.kxml2.io.KXmlParser
 
isAttributeDefault(int) - Method in class org.kxml2.wap.WbxmlParser
 
isEmptyElementTag() - Method in class org.kxml2.io.KXmlParser
 
isEmptyElementTag() - Method in class org.kxml2.wap.WbxmlParser
 
isText(int) - Method in class org.kxml2.kdom.Node
 
isWhitespace() - Method in class org.kxml2.io.KXmlParser
 
isWhitespace() - Method in class org.kxml2.wap.WbxmlParser
 

K

KXmlParser - Class in org.kxml2.io
A simple, pull based XML parser.
KXmlParser() - Constructor for class org.kxml2.io.KXmlParser
 
KXmlSerializer - Class in org.kxml2.io
 
KXmlSerializer() - Constructor for class org.kxml2.io.KXmlSerializer
 

L

LITERAL - Static variable in interface org.kxml2.wap.Wbxml
 
LITERAL_A - Static variable in interface org.kxml2.wap.Wbxml
 
LITERAL_AC - Static variable in interface org.kxml2.wap.Wbxml
 
LITERAL_C - Static variable in interface org.kxml2.wap.Wbxml
 

N

next() - Method in class org.kxml2.io.KXmlParser
 
next() - Method in class org.kxml2.wap.WbxmlParser
 
nextTag() - Method in class org.kxml2.io.KXmlParser
 
nextTag() - Method in class org.kxml2.wap.WbxmlParser
 
nextText() - Method in class org.kxml2.io.KXmlParser
 
nextText() - Method in class org.kxml2.wap.WbxmlParser
 
nextToken() - Method in class org.kxml2.io.KXmlParser
 
nextToken() - Method in class org.kxml2.wap.WbxmlParser
 
Node - Class in org.kxml2.kdom
A common base class for Document and Element, also used for storing XML fragments.
Node() - Constructor for class org.kxml2.kdom.Node
 

O

OPAQUE - Static variable in interface org.kxml2.wap.Wbxml
 
org.kxml2.io - package org.kxml2.io
 
org.kxml2.kdom - package org.kxml2.kdom
 
org.kxml2.wap - package org.kxml2.wap
 
org.kxml2.wap.syncml - package org.kxml2.wap.syncml
 
org.kxml2.wap.wml - package org.kxml2.wap.wml
 
org.kxml2.wap.wv - package org.kxml2.wap.wv
 

P

parse(XmlPullParser) - Method in class org.kxml2.kdom.Document
reads the document and checks if the last event is END_DOCUMENT.
parse(XmlPullParser) - Method in class org.kxml2.kdom.Element
Builds the child elements from the given Parser.
parse(XmlPullParser) - Method in class org.kxml2.kdom.Node
Recursively builds the child elements from the given parser until an end tag or end document is found.
parseWapExtension(int) - Method in class org.kxml2.wap.WbxmlParser
Overwrite this method to intercept all wap events
PI - Static variable in interface org.kxml2.wap.Wbxml
 
PROCESSING_INSTRUCTION - Static variable in class org.kxml2.kdom.Node
 
processingInstruction(String) - Method in class org.kxml2.io.KXmlSerializer
 
processingInstruction(String) - Method in class org.kxml2.wap.WbxmlSerializer
 

R

readAttr() - Method in class org.kxml2.wap.WbxmlParser
 
removeChild(int) - Method in class org.kxml2.kdom.Document
 
removeChild(int) - Method in class org.kxml2.kdom.Node
Removes the child object at the given index
require(int, String, String) - Method in class org.kxml2.io.KXmlParser
 
require(int, String, String) - Method in class org.kxml2.wap.WbxmlParser
 

S

setAttribute(String, String, String) - Method in class org.kxml2.kdom.Element
Sets the given attribute; a value of null removes the attribute
setAttrStartTable(int, String[]) - Method in class org.kxml2.wap.WbxmlParser
Sets the attribute start Table for a given page.
setAttrStartTable(int, String[]) - Method in class org.kxml2.wap.WbxmlSerializer
Sets the attribute start Table for a given page.
setAttrValueTable(int, String[]) - Method in class org.kxml2.wap.WbxmlParser
Sets the attribute value Table for a given page.
setAttrValueTable(int, String[]) - Method in class org.kxml2.wap.WbxmlSerializer
Sets the attribute value Table for a given page.
setEncoding(String) - Method in class org.kxml2.kdom.Document
 
setFeature(String, boolean) - Method in class org.kxml2.io.KXmlParser
 
setFeature(String, boolean) - Method in class org.kxml2.io.KXmlSerializer
 
setFeature(String, boolean) - Method in class org.kxml2.wap.WbxmlParser
 
setFeature(String, boolean) - Method in class org.kxml2.wap.WbxmlSerializer
 
setInput(Reader) - Method in class org.kxml2.io.KXmlParser
 
setInput(InputStream, String) - Method in class org.kxml2.io.KXmlParser
 
setInput(Reader) - Method in class org.kxml2.wap.WbxmlParser
 
setInput(InputStream, String) - Method in class org.kxml2.wap.WbxmlParser
 
setName(String) - Method in class org.kxml2.kdom.Element
sets the name of the element
setNamespace(String) - Method in class org.kxml2.kdom.Element
sets the namespace of the element.
setOutput(Writer) - Method in class org.kxml2.io.KXmlSerializer
 
setOutput(OutputStream, String) - Method in class org.kxml2.io.KXmlSerializer
 
setOutput(Writer) - Method in class org.kxml2.wap.WbxmlSerializer
 
setOutput(OutputStream, String) - Method in class org.kxml2.wap.WbxmlSerializer
 
setPrefix(String, String) - Method in class org.kxml2.io.KXmlSerializer
 
setPrefix(String, String) - Method in class org.kxml2.kdom.Element
Sets the given prefix; a namespace value of null removess the prefix
setPrefix(String, String) - Method in class org.kxml2.wap.WbxmlSerializer
 
setProperty(String, Object) - Method in class org.kxml2.io.KXmlParser
 
setProperty(String, Object) - Method in class org.kxml2.io.KXmlSerializer
 
setProperty(String, Object) - Method in class org.kxml2.wap.WbxmlParser
 
setProperty(String, Object) - Method in class org.kxml2.wap.WbxmlSerializer
 
setStandalone(Boolean) - Method in class org.kxml2.kdom.Document
 
setTagTable(int, String[]) - Method in class org.kxml2.wap.WbxmlParser
Sets the tag table for a given page.
setTagTable(int, String[]) - Method in class org.kxml2.wap.WbxmlSerializer
Sets the tag table for a given page.
skipSubTree() - Method in class org.kxml2.io.KXmlParser
Skip sub tree that is currently porser positioned on.
startDocument(String, Boolean) - Method in class org.kxml2.io.KXmlSerializer
 
startDocument(String, Boolean) - Method in class org.kxml2.wap.WbxmlSerializer
 
startTag(String, String) - Method in class org.kxml2.io.KXmlSerializer
 
startTag(String, String) - Method in class org.kxml2.wap.WbxmlSerializer
 
STR_I - Static variable in interface org.kxml2.wap.Wbxml
 
STR_T - Static variable in interface org.kxml2.wap.Wbxml
 
SWITCH_PAGE - Static variable in interface org.kxml2.wap.Wbxml
 
SyncML - Class in org.kxml2.wap.syncml
 
SyncML() - Constructor for class org.kxml2.wap.syncml.SyncML
 

T

TAG_TABLE - Static variable in class org.kxml2.wap.wml.Wml
 
TAG_TABLE_0 - Static variable in class org.kxml2.wap.syncml.SyncML
 
TAG_TABLE_1 - Static variable in class org.kxml2.wap.syncml.SyncML
 
TAG_TABLE_2_DM - Static variable in class org.kxml2.wap.syncml.SyncML
 
tagTablePage0 - Static variable in class org.kxml2.wap.wv.WV
 
tagTablePage1 - Static variable in class org.kxml2.wap.wv.WV
 
tagTablePage2 - Static variable in class org.kxml2.wap.wv.WV
 
tagTablePage3 - Static variable in class org.kxml2.wap.wv.WV
 
tagTablePage4 - Static variable in class org.kxml2.wap.wv.WV
 
tagTablePage5 - Static variable in class org.kxml2.wap.wv.WV
 
tagTablePage6 - Static variable in class org.kxml2.wap.wv.WV
 
tagTablePage7 - Static variable in class org.kxml2.wap.wv.WV
 
tagTablePage8 - Static variable in class org.kxml2.wap.wv.WV
 
tagTablePage9 - Static variable in class org.kxml2.wap.wv.WV
 
tagTablePageA - Static variable in class org.kxml2.wap.wv.WV
 
text(String) - Method in class org.kxml2.io.KXmlSerializer
 
text(char[], int, int) - Method in class org.kxml2.io.KXmlSerializer
 
TEXT - Static variable in class org.kxml2.kdom.Node
 
text(char[], int, int) - Method in class org.kxml2.wap.WbxmlSerializer
 
text(String) - Method in class org.kxml2.wap.WbxmlSerializer
 

W

WAP_EXTENSION - Static variable in class org.kxml2.wap.WbxmlParser
Parser event type for Wbxml-specific events.
Wbxml - Interface in org.kxml2.wap
contains the WBXML constants
WbxmlParser - Class in org.kxml2.wap
 
WbxmlParser() - Constructor for class org.kxml2.wap.WbxmlParser
 
WbxmlSerializer - Class in org.kxml2.wap
A class for writing WBXML.
WbxmlSerializer() - Constructor for class org.kxml2.wap.WbxmlSerializer
 
Wml - Class in org.kxml2.wap.wml
This class contains the wml coding tables for elements and attributes needed by the WmlParser.
Wml() - Constructor for class org.kxml2.wap.wml.Wml
 
write(XmlSerializer) - Method in class org.kxml2.kdom.Document
Writes this node to the given XmlWriter.
write(XmlSerializer) - Method in class org.kxml2.kdom.Element
Writes this element and all children to the given XmlWriter.
write(XmlSerializer) - Method in class org.kxml2.kdom.Node
Writes this node to the given XmlWriter.
writeChildren(XmlSerializer) - Method in class org.kxml2.kdom.Node
Writes the children of this node to the given XmlWriter.
writeWapExtension(int, Object) - Method in class org.kxml2.wap.WbxmlSerializer
 
WV - Class in org.kxml2.wap.wv
Wireless Village CSP 1.1 ("OMA-WV-CSP-V1_1-20021001-A.pdf") Wireless Village CSP 1.2 ("OMA-IMPS-WV-CSP_WBXML-v1_2-20030221-C.PDF") There are some bugs in the 1.2 spec but this is Ok.
WV() - Constructor for class org.kxml2.wap.wv.WV
 

A C D E F G I K L N O P R S T W

kxml2-2.3.0/www/kxml2/javadoc/org/0000755000175000017500000000000010446737140014762 5ustar neoneokxml2-2.3.0/www/kxml2/javadoc/org/kxml2/0000755000175000017500000000000010446737142016021 5ustar neoneokxml2-2.3.0/www/kxml2/javadoc/org/kxml2/kdom/0000755000175000017500000000000010446737142016753 5ustar neoneokxml2-2.3.0/www/kxml2/javadoc/org/kxml2/kdom/class-use/0000755000175000017500000000000010446737142020652 5ustar neoneokxml2-2.3.0/www/kxml2/javadoc/org/kxml2/kdom/class-use/Element.html0000644000175000017500000002252710446737142023141 0ustar neoneo Uses of Class org.kxml2.kdom.Element (kxml API)

Uses of Class
org.kxml2.kdom.Element

Packages that use Element
org.kxml2.kdom   
 

Uses of Element in org.kxml2.kdom
 

Methods in org.kxml2.kdom that return Element
 Element Node.createElement(java.lang.String namespace, java.lang.String name)
          Builds a default element with the given properties.
 Element Element.createElement(java.lang.String namespace, java.lang.String name)
          Forwards creation request to parent if any, otherwise calls super.createElement.
 Element Node.getElement(int index)
          returns the element at the given index.
 Element Node.getElement(java.lang.String namespace, java.lang.String name)
          Returns the element with the given namespace and name.
 Element Document.getRootElement()
          returns the root element of this document.
 



kxml2-2.3.0/www/kxml2/javadoc/org/kxml2/kdom/class-use/Node.html0000644000175000017500000002142610446737142022432 0ustar neoneo Uses of Class org.kxml2.kdom.Node (kxml API)

Uses of Class
org.kxml2.kdom.Node

Packages that use Node
org.kxml2.kdom   
 

Uses of Node in org.kxml2.kdom
 

Subclasses of Node in org.kxml2.kdom
 class Document
          The document consists of some legacy events and a single root element.
 class Element
          In order to create an element, please use the createElement method instead of invoking the constructor directly.
 

Methods in org.kxml2.kdom that return Node
 Node Element.getParent()
          Returns the parent node of this element
 Node Element.getRoot()
          Returns the root node, determined by ascending to the all parents un of the root element.
 



kxml2-2.3.0/www/kxml2/javadoc/org/kxml2/kdom/class-use/Document.html0000644000175000017500000001275410446737142023327 0ustar neoneo Uses of Class org.kxml2.kdom.Document (kxml API)

Uses of Class
org.kxml2.kdom.Document

No usage of org.kxml2.kdom.Document



kxml2-2.3.0/www/kxml2/javadoc/org/kxml2/kdom/Element.html0000644000175000017500000006722110446737142021242 0ustar neoneo Element (kxml API)

org.kxml2.kdom
Class Element

java.lang.Object
  extended by org.kxml2.kdom.Node
      extended by org.kxml2.kdom.Element

public class Element
extends Node

In order to create an element, please use the createElement method instead of invoking the constructor directly. The right place to add user defined initialization code is the init method.


Field Summary
 
Fields inherited from class org.kxml2.kdom.Node
CDSECT, COMMENT, DOCDECL, DOCUMENT, ELEMENT, ENTITY_REF, IGNORABLE_WHITESPACE, PROCESSING_INSTRUCTION, TEXT
 
Constructor Summary
Element()
           
 
Method Summary
 void clear()
          removes all children and attributes
 Element createElement(java.lang.String namespace, java.lang.String name)
          Forwards creation request to parent if any, otherwise calls super.createElement.
 int getAttributeCount()
          Returns the number of attributes of this element.
 java.lang.String getAttributeName(int index)
           
 java.lang.String getAttributeNamespace(int index)
           
 java.lang.String getAttributeValue(int index)
           
 java.lang.String getAttributeValue(java.lang.String namespace, java.lang.String name)
           
 java.lang.String getName()
          returns the (local) name of the element
 java.lang.String getNamespace()
          returns the namespace of the element
 int getNamespaceCount()
          returns the number of declared namespaces, NOT including parent elements
 java.lang.String getNamespacePrefix(int i)
           
 java.lang.String getNamespaceUri(int i)
           
 java.lang.String getNamespaceUri(java.lang.String prefix)
          returns the namespace for the given prefix
 Node getParent()
          Returns the parent node of this element
 Node getRoot()
          Returns the root node, determined by ascending to the all parents un of the root element.
 void init()
          called when all properties are set, but before children are parsed.
 void parse(org.xmlpull.v1.XmlPullParser parser)
          Builds the child elements from the given Parser.
 void setAttribute(java.lang.String namespace, java.lang.String name, java.lang.String value)
          Sets the given attribute; a value of null removes the attribute
 void setName(java.lang.String name)
          sets the name of the element
 void setNamespace(java.lang.String namespace)
          sets the namespace of the element.
 void setPrefix(java.lang.String prefix, java.lang.String namespace)
          Sets the given prefix; a namespace value of null removess the prefix
 void write(org.xmlpull.v1.XmlSerializer writer)
          Writes this element and all children to the given XmlWriter.
 
Methods inherited from class org.kxml2.kdom.Node
addChild, addChild, getChild, getChildCount, getElement, getElement, getText, getType, indexOf, isText, removeChild, writeChildren
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Element

public Element()
Method Detail

init

public void init()
called when all properties are set, but before children are parsed. Please do not use setParent for initialization code any longer.


clear

public void clear()
removes all children and attributes


createElement

public Element createElement(java.lang.String namespace,
                             java.lang.String name)
Forwards creation request to parent if any, otherwise calls super.createElement.

Overrides:
createElement in class Node

getAttributeCount

public int getAttributeCount()
Returns the number of attributes of this element.


getAttributeNamespace

public java.lang.String getAttributeNamespace(int index)

getAttributeName

public java.lang.String getAttributeName(int index)

getAttributeValue

public java.lang.String getAttributeValue(int index)

getAttributeValue

public java.lang.String getAttributeValue(java.lang.String namespace,
                                          java.lang.String name)

getRoot

public Node getRoot()
Returns the root node, determined by ascending to the all parents un of the root element.


getName

public java.lang.String getName()
returns the (local) name of the element


getNamespace

public java.lang.String getNamespace()
returns the namespace of the element


getNamespaceUri

public java.lang.String getNamespaceUri(java.lang.String prefix)
returns the namespace for the given prefix


getNamespaceCount

public int getNamespaceCount()
returns the number of declared namespaces, NOT including parent elements


getNamespacePrefix

public java.lang.String getNamespacePrefix(int i)

getNamespaceUri

public java.lang.String getNamespaceUri(int i)

getParent

public Node getParent()
Returns the parent node of this element


parse

public void parse(org.xmlpull.v1.XmlPullParser parser)
           throws java.io.IOException,
                  org.xmlpull.v1.XmlPullParserException
Builds the child elements from the given Parser. By overwriting parse, an element can take complete control over parsing its subtree.

Overrides:
parse in class Node
Throws:
java.io.IOException
org.xmlpull.v1.XmlPullParserException

setAttribute

public void setAttribute(java.lang.String namespace,
                         java.lang.String name,
                         java.lang.String value)
Sets the given attribute; a value of null removes the attribute


setPrefix

public void setPrefix(java.lang.String prefix,
                      java.lang.String namespace)
Sets the given prefix; a namespace value of null removess the prefix


setName

public void setName(java.lang.String name)
sets the name of the element


setNamespace

public void setNamespace(java.lang.String namespace)
sets the namespace of the element. Please note: For no namespace, please use Xml.NO_NAMESPACE, null is not a legal value. Currently, null is converted to Xml.NO_NAMESPACE, but future versions may throw an exception.


write

public void write(org.xmlpull.v1.XmlSerializer writer)
           throws java.io.IOException
Writes this element and all children to the given XmlWriter.

Overrides:
write in class Node
Throws:
java.io.IOException


kxml2-2.3.0/www/kxml2/javadoc/org/kxml2/kdom/Node.html0000644000175000017500000006513510446737142020540 0ustar neoneo Node (kxml API)

org.kxml2.kdom
Class Node

java.lang.Object
  extended by org.kxml2.kdom.Node
Direct Known Subclasses:
Document, Element

public class Node
extends java.lang.Object

A common base class for Document and Element, also used for storing XML fragments.


Field Summary
static int CDSECT
           
static int COMMENT
           
static int DOCDECL
           
static int DOCUMENT
           
static int ELEMENT
           
static int ENTITY_REF
           
static int IGNORABLE_WHITESPACE
           
static int PROCESSING_INSTRUCTION
           
static int TEXT
           
 
Constructor Summary
Node()
           
 
Method Summary
 void addChild(int index, int type, java.lang.Object child)
          inserts the given child object of the given type at the given index.
 void addChild(int type, java.lang.Object child)
          convenience method for addChild (getChildCount (), child)
 Element createElement(java.lang.String namespace, java.lang.String name)
          Builds a default element with the given properties.
 java.lang.Object getChild(int index)
          Returns the child object at the given index.
 int getChildCount()
          Returns the number of child objects
 Element getElement(int index)
          returns the element at the given index.
 Element getElement(java.lang.String namespace, java.lang.String name)
          Returns the element with the given namespace and name.
 java.lang.String getText(int index)
          Returns the text node with the given index or null if the node with the given index is not a text node.
 int getType(int index)
          Returns the type of the child at the given index.
 int indexOf(java.lang.String namespace, java.lang.String name, int startIndex)
          Performs search for an element with the given namespace and name, starting at the given start index.
 boolean isText(int i)
           
 void parse(org.xmlpull.v1.XmlPullParser parser)
          Recursively builds the child elements from the given parser until an end tag or end document is found.
 void removeChild(int idx)
          Removes the child object at the given index
 void write(org.xmlpull.v1.XmlSerializer writer)
          Writes this node to the given XmlWriter.
 void writeChildren(org.xmlpull.v1.XmlSerializer writer)
          Writes the children of this node to the given XmlWriter.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DOCUMENT

public static final int DOCUMENT
See Also:
Constant Field Values

ELEMENT

public static final int ELEMENT
See Also:
Constant Field Values

TEXT

public static final int TEXT
See Also:
Constant Field Values

CDSECT

public static final int CDSECT
See Also:
Constant Field Values

ENTITY_REF

public static final int ENTITY_REF
See Also:
Constant Field Values

IGNORABLE_WHITESPACE

public static final int IGNORABLE_WHITESPACE
See Also:
Constant Field Values

PROCESSING_INSTRUCTION

public static final int PROCESSING_INSTRUCTION
See Also:
Constant Field Values

COMMENT

public static final int COMMENT
See Also:
Constant Field Values

DOCDECL

public static final int DOCDECL
See Also:
Constant Field Values
Constructor Detail

Node

public Node()
Method Detail

addChild

public void addChild(int index,
                     int type,
                     java.lang.Object child)
inserts the given child object of the given type at the given index.


addChild

public void addChild(int type,
                     java.lang.Object child)
convenience method for addChild (getChildCount (), child)


createElement

public Element createElement(java.lang.String namespace,
                             java.lang.String name)
Builds a default element with the given properties. Elements should always be created using this method instead of the constructor in order to enable construction of specialized subclasses by deriving custom Document classes. Please note: For no namespace, please use Xml.NO_NAMESPACE, null is not a legal value. Currently, null is converted to Xml.NO_NAMESPACE, but future versions may throw an exception.


getChild

public java.lang.Object getChild(int index)
Returns the child object at the given index. For child elements, an Element object is returned. For all other child types, a String is returned.


getChildCount

public int getChildCount()
Returns the number of child objects


getElement

public Element getElement(int index)
returns the element at the given index. If the node at the given index is a text node, null is returned


getElement

public Element getElement(java.lang.String namespace,
                          java.lang.String name)
Returns the element with the given namespace and name. If the element is not found, or more than one matching elements are found, an exception is thrown.


getText

public java.lang.String getText(int index)
Returns the text node with the given index or null if the node with the given index is not a text node.


getType

public int getType(int index)
Returns the type of the child at the given index. Possible types are ELEMENT, TEXT, COMMENT, and PROCESSING_INSTRUCTION


indexOf

public int indexOf(java.lang.String namespace,
                   java.lang.String name,
                   int startIndex)
Performs search for an element with the given namespace and name, starting at the given start index. A null namespace matches any namespace, please use Xml.NO_NAMESPACE for no namespace). returns -1 if no matching element was found.


isText

public boolean isText(int i)

parse

public void parse(org.xmlpull.v1.XmlPullParser parser)
           throws java.io.IOException,
                  org.xmlpull.v1.XmlPullParserException
Recursively builds the child elements from the given parser until an end tag or end document is found. The end tag is not consumed.

Throws:
java.io.IOException
org.xmlpull.v1.XmlPullParserException

removeChild

public void removeChild(int idx)
Removes the child object at the given index


write

public void write(org.xmlpull.v1.XmlSerializer writer)
           throws java.io.IOException
Writes this node to the given XmlWriter. For node and document, this method is identical to writeChildren, except that the stream is flushed automatically.

Throws:
java.io.IOException

writeChildren

public void writeChildren(org.xmlpull.v1.XmlSerializer writer)
                   throws java.io.IOException
Writes the children of this node to the given XmlWriter.

Throws:
java.io.IOException


kxml2-2.3.0/www/kxml2/javadoc/org/kxml2/kdom/package-use.html0000644000175000017500000001517710446737142022041 0ustar neoneo Uses of Package org.kxml2.kdom (kxml API)

Uses of Package
org.kxml2.kdom

Packages that use org.kxml2.kdom
org.kxml2.kdom   
 

Classes in org.kxml2.kdom used by org.kxml2.kdom
Element
          In order to create an element, please use the createElement method instead of invoking the constructor directly.
Node
          A common base class for Document and Element, also used for storing XML fragments.
 



kxml2-2.3.0/www/kxml2/javadoc/org/kxml2/kdom/package-frame.html0000644000175000017500000000202210446737142022320 0ustar neoneo org.kxml2.kdom (kxml API) org.kxml2.kdom
Classes 
Document
Element
Node
kxml2-2.3.0/www/kxml2/javadoc/org/kxml2/kdom/Document.html0000644000175000017500000004672310446737142021433 0ustar neoneo Document (kxml API)

org.kxml2.kdom
Class Document

java.lang.Object
  extended by org.kxml2.kdom.Node
      extended by org.kxml2.kdom.Document

public class Document
extends Node

The document consists of some legacy events and a single root element. This class basically adds some consistency checks to Node.


Field Summary
 
Fields inherited from class org.kxml2.kdom.Node
CDSECT, COMMENT, DOCDECL, DOCUMENT, ELEMENT, ENTITY_REF, IGNORABLE_WHITESPACE, PROCESSING_INSTRUCTION, TEXT
 
Constructor Summary
Document()
           
 
Method Summary
 void addChild(int index, int type, java.lang.Object child)
          Adds a child at the given index position.
 java.lang.String getEncoding()
          returns "#document"
 java.lang.String getName()
           
 Element getRootElement()
          returns the root element of this document.
 java.lang.Boolean getStandalone()
           
 void parse(org.xmlpull.v1.XmlPullParser parser)
          reads the document and checks if the last event is END_DOCUMENT.
 void removeChild(int index)
          Removes the child object at the given index
 void setEncoding(java.lang.String enc)
           
 void setStandalone(java.lang.Boolean standalone)
           
 void write(org.xmlpull.v1.XmlSerializer writer)
          Writes this node to the given XmlWriter.
 
Methods inherited from class org.kxml2.kdom.Node
addChild, createElement, getChild, getChildCount, getElement, getElement, getText, getType, indexOf, isText, writeChildren
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Document

public Document()
Method Detail

getEncoding

public java.lang.String getEncoding()
returns "#document"


setEncoding

public void setEncoding(java.lang.String enc)

setStandalone

public void setStandalone(java.lang.Boolean standalone)

getStandalone

public java.lang.Boolean getStandalone()

getName

public java.lang.String getName()

addChild

public void addChild(int index,
                     int type,
                     java.lang.Object child)
Adds a child at the given index position. Throws an exception when a second root element is added

Overrides:
addChild in class Node

parse

public void parse(org.xmlpull.v1.XmlPullParser parser)
           throws java.io.IOException,
                  org.xmlpull.v1.XmlPullParserException
reads the document and checks if the last event is END_DOCUMENT. If not, an exception is thrown. The end event is consumed. For parsing partial XML structures, consider using Node.parse ().

Overrides:
parse in class Node
Throws:
java.io.IOException
org.xmlpull.v1.XmlPullParserException

removeChild

public void removeChild(int index)
Description copied from class: Node
Removes the child object at the given index

Overrides:
removeChild in class Node

getRootElement

public Element getRootElement()
returns the root element of this document.


write

public void write(org.xmlpull.v1.XmlSerializer writer)
           throws java.io.IOException
Writes this node to the given XmlWriter. For node and document, this method is identical to writeChildren, except that the stream is flushed automatically.

Overrides:
write in class Node
Throws:
java.io.IOException


kxml2-2.3.0/www/kxml2/javadoc/org/kxml2/kdom/package-summary.html0000644000175000017500000001474510446737142022742 0ustar neoneo org.kxml2.kdom (kxml API)

Package org.kxml2.kdom

Class Summary
Document The document consists of some legacy events and a single root element.
Element In order to create an element, please use the createElement method instead of invoking the constructor directly.
Node A common base class for Document and Element, also used for storing XML fragments.
 



kxml2-2.3.0/www/kxml2/javadoc/org/kxml2/kdom/package-tree.html0000644000175000017500000001364410446737142022201 0ustar neoneo org.kxml2.kdom Class Hierarchy (kxml API)

Hierarchy For Package org.kxml2.kdom

Package Hierarchies:
All Packages

Class Hierarchy



kxml2-2.3.0/www/kxml2/javadoc/org/kxml2/io/0000755000175000017500000000000010446737142016430 5ustar neoneokxml2-2.3.0/www/kxml2/javadoc/org/kxml2/io/class-use/0000755000175000017500000000000010446737142020327 5ustar neoneokxml2-2.3.0/www/kxml2/javadoc/org/kxml2/io/class-use/KXmlSerializer.html0000644000175000017500000001302410446737142024122 0ustar neoneo Uses of Class org.kxml2.io.KXmlSerializer (kxml API)

Uses of Class
org.kxml2.io.KXmlSerializer

No usage of org.kxml2.io.KXmlSerializer



kxml2-2.3.0/www/kxml2/javadoc/org/kxml2/io/class-use/KXmlParser.html0000644000175000017500000001275410446737142023256 0ustar neoneo Uses of Class org.kxml2.io.KXmlParser (kxml API)

Uses of Class
org.kxml2.io.KXmlParser

No usage of org.kxml2.io.KXmlParser



kxml2-2.3.0/www/kxml2/javadoc/org/kxml2/io/KXmlSerializer.html0000644000175000017500000007037310446737142022235 0ustar neoneo KXmlSerializer (kxml API)

org.kxml2.io
Class KXmlSerializer

java.lang.Object
  extended by org.kxml2.io.KXmlSerializer
All Implemented Interfaces:
org.xmlpull.v1.XmlSerializer

public class KXmlSerializer
extends java.lang.Object
implements org.xmlpull.v1.XmlSerializer


Constructor Summary
KXmlSerializer()
           
 
Method Summary
 org.xmlpull.v1.XmlSerializer attribute(java.lang.String namespace, java.lang.String name, java.lang.String value)
           
 void cdsect(java.lang.String data)
           
 void comment(java.lang.String comment)
           
 void docdecl(java.lang.String dd)
           
 void endDocument()
           
 org.xmlpull.v1.XmlSerializer endTag(java.lang.String namespace, java.lang.String name)
           
 void entityRef(java.lang.String name)
           
 void flush()
           
 int getDepth()
           
 boolean getFeature(java.lang.String name)
           
 java.lang.String getName()
           
 java.lang.String getNamespace()
           
 java.lang.String getPrefix(java.lang.String namespace, boolean create)
           
 java.lang.Object getProperty(java.lang.String name)
           
 void ignorableWhitespace(java.lang.String s)
           
 void processingInstruction(java.lang.String pi)
           
 void setFeature(java.lang.String name, boolean value)
           
 void setOutput(java.io.OutputStream os, java.lang.String encoding)
           
 void setOutput(java.io.Writer writer)
           
 void setPrefix(java.lang.String prefix, java.lang.String namespace)
           
 void setProperty(java.lang.String name, java.lang.Object value)
           
 void startDocument(java.lang.String encoding, java.lang.Boolean standalone)
           
 org.xmlpull.v1.XmlSerializer startTag(java.lang.String namespace, java.lang.String name)
           
 org.xmlpull.v1.XmlSerializer text(char[] text, int start, int len)
           
 org.xmlpull.v1.XmlSerializer text(java.lang.String text)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KXmlSerializer

public KXmlSerializer()
Method Detail

docdecl

public void docdecl(java.lang.String dd)
             throws java.io.IOException
Specified by:
docdecl in interface org.xmlpull.v1.XmlSerializer
Throws:
java.io.IOException

endDocument

public void endDocument()
                 throws java.io.IOException
Specified by:
endDocument in interface org.xmlpull.v1.XmlSerializer
Throws:
java.io.IOException

entityRef

public void entityRef(java.lang.String name)
               throws java.io.IOException
Specified by:
entityRef in interface org.xmlpull.v1.XmlSerializer
Throws:
java.io.IOException

getFeature

public boolean getFeature(java.lang.String name)
Specified by:
getFeature in interface org.xmlpull.v1.XmlSerializer

getPrefix

public java.lang.String getPrefix(java.lang.String namespace,
                                  boolean create)
Specified by:
getPrefix in interface org.xmlpull.v1.XmlSerializer

getProperty

public java.lang.Object getProperty(java.lang.String name)
Specified by:
getProperty in interface org.xmlpull.v1.XmlSerializer

ignorableWhitespace

public void ignorableWhitespace(java.lang.String s)
                         throws java.io.IOException
Specified by:
ignorableWhitespace in interface org.xmlpull.v1.XmlSerializer
Throws:
java.io.IOException

setFeature

public void setFeature(java.lang.String name,
                       boolean value)
Specified by:
setFeature in interface org.xmlpull.v1.XmlSerializer

setProperty

public void setProperty(java.lang.String name,
                        java.lang.Object value)
Specified by:
setProperty in interface org.xmlpull.v1.XmlSerializer

setPrefix

public void setPrefix(java.lang.String prefix,
                      java.lang.String namespace)
               throws java.io.IOException
Specified by:
setPrefix in interface org.xmlpull.v1.XmlSerializer
Throws:
java.io.IOException

setOutput

public void setOutput(java.io.Writer writer)
Specified by:
setOutput in interface org.xmlpull.v1.XmlSerializer

setOutput

public void setOutput(java.io.OutputStream os,
                      java.lang.String encoding)
               throws java.io.IOException
Specified by:
setOutput in interface org.xmlpull.v1.XmlSerializer
Throws:
java.io.IOException

startDocument

public void startDocument(java.lang.String encoding,
                          java.lang.Boolean standalone)
                   throws java.io.IOException
Specified by:
startDocument in interface org.xmlpull.v1.XmlSerializer
Throws:
java.io.IOException

startTag

public org.xmlpull.v1.XmlSerializer startTag(java.lang.String namespace,
                                             java.lang.String name)
                                      throws java.io.IOException
Specified by:
startTag in interface org.xmlpull.v1.XmlSerializer
Throws:
java.io.IOException

attribute

public org.xmlpull.v1.XmlSerializer attribute(java.lang.String namespace,
                                              java.lang.String name,
                                              java.lang.String value)
                                       throws java.io.IOException
Specified by:
attribute in interface org.xmlpull.v1.XmlSerializer
Throws:
java.io.IOException

flush

public void flush()
           throws java.io.IOException
Specified by:
flush in interface org.xmlpull.v1.XmlSerializer
Throws:
java.io.IOException

endTag

public org.xmlpull.v1.XmlSerializer endTag(java.lang.String namespace,
                                           java.lang.String name)
                                    throws java.io.IOException
Specified by:
endTag in interface org.xmlpull.v1.XmlSerializer
Throws:
java.io.IOException

getNamespace

public java.lang.String getNamespace()
Specified by:
getNamespace in interface org.xmlpull.v1.XmlSerializer

getName

public java.lang.String getName()
Specified by:
getName in interface org.xmlpull.v1.XmlSerializer

getDepth

public int getDepth()
Specified by:
getDepth in interface org.xmlpull.v1.XmlSerializer

text

public org.xmlpull.v1.XmlSerializer text(java.lang.String text)
                                  throws java.io.IOException
Specified by:
text in interface org.xmlpull.v1.XmlSerializer
Throws:
java.io.IOException

text

public org.xmlpull.v1.XmlSerializer text(char[] text,
                                         int start,
                                         int len)
                                  throws java.io.IOException
Specified by:
text in interface org.xmlpull.v1.XmlSerializer
Throws:
java.io.IOException

cdsect

public void cdsect(java.lang.String data)
            throws java.io.IOException
Specified by:
cdsect in interface org.xmlpull.v1.XmlSerializer
Throws:
java.io.IOException

comment

public void comment(java.lang.String comment)
             throws java.io.IOException
Specified by:
comment in interface org.xmlpull.v1.XmlSerializer
Throws:
java.io.IOException

processingInstruction

public void processingInstruction(java.lang.String pi)
                           throws java.io.IOException
Specified by:
processingInstruction in interface org.xmlpull.v1.XmlSerializer
Throws:
java.io.IOException


kxml2-2.3.0/www/kxml2/javadoc/org/kxml2/io/KXmlParser.html0000644000175000017500000011236310446737142021354 0ustar neoneo KXmlParser (kxml API)

org.kxml2.io
Class KXmlParser

java.lang.Object
  extended by org.kxml2.io.KXmlParser
All Implemented Interfaces:
org.xmlpull.v1.XmlPullParser

public class KXmlParser
extends java.lang.Object
implements org.xmlpull.v1.XmlPullParser

A simple, pull based XML parser. This classe replaces the kXML 1 XmlParser class and the corresponding event classes.


Field Summary
 
Fields inherited from interface org.xmlpull.v1.XmlPullParser
CDSECT, COMMENT, DOCDECL, END_DOCUMENT, END_TAG, ENTITY_REF, FEATURE_PROCESS_DOCDECL, FEATURE_PROCESS_NAMESPACES, FEATURE_REPORT_NAMESPACE_ATTRIBUTES, FEATURE_VALIDATION, IGNORABLE_WHITESPACE, NO_NAMESPACE, PROCESSING_INSTRUCTION, START_DOCUMENT, START_TAG, TEXT, TYPES
 
Constructor Summary
KXmlParser()
           
 
Method Summary
 void defineEntityReplacementText(java.lang.String entity, java.lang.String value)
           
 int getAttributeCount()
           
 java.lang.String getAttributeName(int index)
           
 java.lang.String getAttributeNamespace(int index)
           
 java.lang.String getAttributePrefix(int index)
           
 java.lang.String getAttributeType(int index)
           
 java.lang.String getAttributeValue(int index)
           
 java.lang.String getAttributeValue(java.lang.String namespace, java.lang.String name)
           
 int getColumnNumber()
           
 int getDepth()
           
 int getEventType()
           
 boolean getFeature(java.lang.String feature)
           
 java.lang.String getInputEncoding()
           
 int getLineNumber()
           
 java.lang.String getName()
           
 java.lang.String getNamespace()
           
 java.lang.String getNamespace(java.lang.String prefix)
           
 int getNamespaceCount(int depth)
           
 java.lang.String getNamespacePrefix(int pos)
           
 java.lang.String getNamespaceUri(int pos)
           
 java.lang.String getPositionDescription()
           
 java.lang.String getPrefix()
           
 java.lang.Object getProperty(java.lang.String property)
           
 java.lang.String getText()
           
 char[] getTextCharacters(int[] poslen)
           
 boolean isAttributeDefault(int index)
           
 boolean isEmptyElementTag()
           
 boolean isWhitespace()
           
 int next()
           
 int nextTag()
           
 java.lang.String nextText()
           
 int nextToken()
           
 void require(int type, java.lang.String namespace, java.lang.String name)
           
 void setFeature(java.lang.String feature, boolean value)
           
 void setInput(java.io.InputStream is, java.lang.String _enc)
           
 void setInput(java.io.Reader reader)
           
 void setProperty(java.lang.String property, java.lang.Object value)
           
 void skipSubTree()
          Skip sub tree that is currently porser positioned on.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KXmlParser

public KXmlParser()
Method Detail

setInput

public void setInput(java.io.Reader reader)
              throws org.xmlpull.v1.XmlPullParserException
Specified by:
setInput in interface org.xmlpull.v1.XmlPullParser
Throws:
org.xmlpull.v1.XmlPullParserException

setInput

public void setInput(java.io.InputStream is,
                     java.lang.String _enc)
              throws org.xmlpull.v1.XmlPullParserException
Specified by:
setInput in interface org.xmlpull.v1.XmlPullParser
Throws:
org.xmlpull.v1.XmlPullParserException

getFeature

public boolean getFeature(java.lang.String feature)
Specified by:
getFeature in interface org.xmlpull.v1.XmlPullParser

getInputEncoding

public java.lang.String getInputEncoding()
Specified by:
getInputEncoding in interface org.xmlpull.v1.XmlPullParser

defineEntityReplacementText

public void defineEntityReplacementText(java.lang.String entity,
                                        java.lang.String value)
                                 throws org.xmlpull.v1.XmlPullParserException
Specified by:
defineEntityReplacementText in interface org.xmlpull.v1.XmlPullParser
Throws:
org.xmlpull.v1.XmlPullParserException

getProperty

public java.lang.Object getProperty(java.lang.String property)
Specified by:
getProperty in interface org.xmlpull.v1.XmlPullParser

getNamespaceCount

public int getNamespaceCount(int depth)
Specified by:
getNamespaceCount in interface org.xmlpull.v1.XmlPullParser

getNamespacePrefix

public java.lang.String getNamespacePrefix(int pos)
Specified by:
getNamespacePrefix in interface org.xmlpull.v1.XmlPullParser

getNamespaceUri

public java.lang.String getNamespaceUri(int pos)
Specified by:
getNamespaceUri in interface org.xmlpull.v1.XmlPullParser

getNamespace

public java.lang.String getNamespace(java.lang.String prefix)
Specified by:
getNamespace in interface org.xmlpull.v1.XmlPullParser

getDepth

public int getDepth()
Specified by:
getDepth in interface org.xmlpull.v1.XmlPullParser

getPositionDescription

public java.lang.String getPositionDescription()
Specified by:
getPositionDescription in interface org.xmlpull.v1.XmlPullParser

getLineNumber

public int getLineNumber()
Specified by:
getLineNumber in interface org.xmlpull.v1.XmlPullParser

getColumnNumber

public int getColumnNumber()
Specified by:
getColumnNumber in interface org.xmlpull.v1.XmlPullParser

isWhitespace

public boolean isWhitespace()
                     throws org.xmlpull.v1.XmlPullParserException
Specified by:
isWhitespace in interface org.xmlpull.v1.XmlPullParser
Throws:
org.xmlpull.v1.XmlPullParserException

getText

public java.lang.String getText()
Specified by:
getText in interface org.xmlpull.v1.XmlPullParser

getTextCharacters

public char[] getTextCharacters(int[] poslen)
Specified by:
getTextCharacters in interface org.xmlpull.v1.XmlPullParser

getNamespace

public java.lang.String getNamespace()
Specified by:
getNamespace in interface org.xmlpull.v1.XmlPullParser

getName

public java.lang.String getName()
Specified by:
getName in interface org.xmlpull.v1.XmlPullParser

getPrefix

public java.lang.String getPrefix()
Specified by:
getPrefix in interface org.xmlpull.v1.XmlPullParser

isEmptyElementTag

public boolean isEmptyElementTag()
                          throws org.xmlpull.v1.XmlPullParserException
Specified by:
isEmptyElementTag in interface org.xmlpull.v1.XmlPullParser
Throws:
org.xmlpull.v1.XmlPullParserException

getAttributeCount

public int getAttributeCount()
Specified by:
getAttributeCount in interface org.xmlpull.v1.XmlPullParser

getAttributeType

public java.lang.String getAttributeType(int index)
Specified by:
getAttributeType in interface org.xmlpull.v1.XmlPullParser

isAttributeDefault

public boolean isAttributeDefault(int index)
Specified by:
isAttributeDefault in interface org.xmlpull.v1.XmlPullParser

getAttributeNamespace

public java.lang.String getAttributeNamespace(int index)
Specified by:
getAttributeNamespace in interface org.xmlpull.v1.XmlPullParser

getAttributeName

public java.lang.String getAttributeName(int index)
Specified by:
getAttributeName in interface org.xmlpull.v1.XmlPullParser

getAttributePrefix

public java.lang.String getAttributePrefix(int index)
Specified by:
getAttributePrefix in interface org.xmlpull.v1.XmlPullParser

getAttributeValue

public java.lang.String getAttributeValue(int index)
Specified by:
getAttributeValue in interface org.xmlpull.v1.XmlPullParser

getAttributeValue

public java.lang.String getAttributeValue(java.lang.String namespace,
                                          java.lang.String name)
Specified by:
getAttributeValue in interface org.xmlpull.v1.XmlPullParser

getEventType

public int getEventType()
                 throws org.xmlpull.v1.XmlPullParserException
Specified by:
getEventType in interface org.xmlpull.v1.XmlPullParser
Throws:
org.xmlpull.v1.XmlPullParserException

next

public int next()
         throws org.xmlpull.v1.XmlPullParserException,
                java.io.IOException
Specified by:
next in interface org.xmlpull.v1.XmlPullParser
Throws:
org.xmlpull.v1.XmlPullParserException
java.io.IOException

nextToken

public int nextToken()
              throws org.xmlpull.v1.XmlPullParserException,
                     java.io.IOException
Specified by:
nextToken in interface org.xmlpull.v1.XmlPullParser
Throws:
org.xmlpull.v1.XmlPullParserException
java.io.IOException

nextTag

public int nextTag()
            throws org.xmlpull.v1.XmlPullParserException,
                   java.io.IOException
Specified by:
nextTag in interface org.xmlpull.v1.XmlPullParser
Throws:
org.xmlpull.v1.XmlPullParserException
java.io.IOException

require

public void require(int type,
                    java.lang.String namespace,
                    java.lang.String name)
             throws org.xmlpull.v1.XmlPullParserException,
                    java.io.IOException
Specified by:
require in interface org.xmlpull.v1.XmlPullParser
Throws:
org.xmlpull.v1.XmlPullParserException
java.io.IOException

nextText

public java.lang.String nextText()
                          throws org.xmlpull.v1.XmlPullParserException,
                                 java.io.IOException
Specified by:
nextText in interface org.xmlpull.v1.XmlPullParser
Throws:
org.xmlpull.v1.XmlPullParserException
java.io.IOException

setFeature

public void setFeature(java.lang.String feature,
                       boolean value)
                throws org.xmlpull.v1.XmlPullParserException
Specified by:
setFeature in interface org.xmlpull.v1.XmlPullParser
Throws:
org.xmlpull.v1.XmlPullParserException

setProperty

public void setProperty(java.lang.String property,
                        java.lang.Object value)
                 throws org.xmlpull.v1.XmlPullParserException
Specified by:
setProperty in interface org.xmlpull.v1.XmlPullParser
Throws:
org.xmlpull.v1.XmlPullParserException

skipSubTree

public void skipSubTree()
                 throws org.xmlpull.v1.XmlPullParserException,
                        java.io.IOException
Skip sub tree that is currently porser positioned on.
NOTE: parser must be on START_TAG and when funtion returns parser will be positioned on corresponding END_TAG.

Throws:
org.xmlpull.v1.XmlPullParserException
java.io.IOException


kxml2-2.3.0/www/kxml2/javadoc/org/kxml2/io/package-use.html0000644000175000017500000001230510446737142021504 0ustar neoneo Uses of Package org.kxml2.io (kxml API)

Uses of Package
org.kxml2.io

No usage of org.kxml2.io



kxml2-2.3.0/www/kxml2/javadoc/org/kxml2/io/package-frame.html0000644000175000017500000000170210446737142022001 0ustar neoneo org.kxml2.io (kxml API) org.kxml2.io
Classes 
KXmlParser
KXmlSerializer
kxml2-2.3.0/www/kxml2/javadoc/org/kxml2/io/package-summary.html0000644000175000017500000001371610446737142022414 0ustar neoneo org.kxml2.io (kxml API)

Package org.kxml2.io

Class Summary
KXmlParser A simple, pull based XML parser.
KXmlSerializer  
 



kxml2-2.3.0/www/kxml2/javadoc/org/kxml2/io/package-tree.html0000644000175000017500000001336710446737142021660 0ustar neoneo org.kxml2.io Class Hierarchy (kxml API)

Hierarchy For Package org.kxml2.io

Package Hierarchies:
All Packages

Class Hierarchy

  • java.lang.Object
    • org.kxml2.io.KXmlParser (implements org.xmlpull.v1.XmlPullParser)
    • org.kxml2.io.KXmlSerializer (implements org.xmlpull.v1.XmlSerializer)


kxml2-2.3.0/www/kxml2/javadoc/org/kxml2/wap/0000755000175000017500000000000010446737142016610 5ustar neoneokxml2-2.3.0/www/kxml2/javadoc/org/kxml2/wap/class-use/0000755000175000017500000000000010446737142020507 5ustar neoneokxml2-2.3.0/www/kxml2/javadoc/org/kxml2/wap/class-use/WbxmlParser.html0000644000175000017500000002471710446737142023656 0ustar neoneo Uses of Class org.kxml2.wap.WbxmlParser (kxml API)

Uses of Class
org.kxml2.wap.WbxmlParser

Packages that use WbxmlParser
org.kxml2.wap.syncml   
org.kxml2.wap.wml   
org.kxml2.wap.wv   
 

Uses of WbxmlParser in org.kxml2.wap.syncml
 

Methods in org.kxml2.wap.syncml that return WbxmlParser
static WbxmlParser SyncML.createDMParser()
           
static WbxmlParser SyncML.createParser()
           
 

Uses of WbxmlParser in org.kxml2.wap.wml
 

Methods in org.kxml2.wap.wml that return WbxmlParser
static WbxmlParser Wml.createParser()
          Creates a WbxmlParser with the WML code pages set
 

Uses of WbxmlParser in org.kxml2.wap.wv
 

Methods in org.kxml2.wap.wv that return WbxmlParser
static WbxmlParser WV.createParser()
           
 



kxml2-2.3.0/www/kxml2/javadoc/org/kxml2/wap/class-use/WbxmlSerializer.html0000644000175000017500000002223310446737142024522 0ustar neoneo Uses of Class org.kxml2.wap.WbxmlSerializer (kxml API)

Uses of Class
org.kxml2.wap.WbxmlSerializer

Packages that use WbxmlSerializer
org.kxml2.wap.syncml   
org.kxml2.wap.wml   
 

Uses of WbxmlSerializer in org.kxml2.wap.syncml
 

Methods in org.kxml2.wap.syncml that return WbxmlSerializer
static WbxmlSerializer SyncML.createDMSerializer()
           
static WbxmlSerializer SyncML.createSerializer()
           
 

Uses of WbxmlSerializer in org.kxml2.wap.wml
 

Methods in org.kxml2.wap.wml that return WbxmlSerializer
static WbxmlSerializer Wml.createSerializer()
           
 



kxml2-2.3.0/www/kxml2/javadoc/org/kxml2/wap/class-use/Wbxml.html0000644000175000017500000001273010446737142022471 0ustar neoneo Uses of Interface org.kxml2.wap.Wbxml (kxml API)

Uses of Interface
org.kxml2.wap.Wbxml

No usage of org.kxml2.wap.Wbxml



kxml2-2.3.0/www/kxml2/javadoc/org/kxml2/wap/wml/0000755000175000017500000000000010446737142017407 5ustar neoneokxml2-2.3.0/www/kxml2/javadoc/org/kxml2/wap/wml/Wml.html0000644000175000017500000003016310446737142021037 0ustar neoneo Wml (kxml API)

org.kxml2.wap.wml
Class Wml

java.lang.Object
  extended by org.kxml2.wap.wml.Wml

public abstract class Wml
extends java.lang.Object

This class contains the wml coding tables for elements and attributes needed by the WmlParser.


Field Summary
static java.lang.String[] ATTR_START_TABLE
           
static java.lang.String[] ATTR_VALUE_TABLE
           
static java.lang.String[] TAG_TABLE
           
 
Constructor Summary
Wml()
           
 
Method Summary
static WbxmlParser createParser()
          Creates a WbxmlParser with the WML code pages set
static WbxmlSerializer createSerializer()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TAG_TABLE

public static final java.lang.String[] TAG_TABLE

ATTR_START_TABLE

public static final java.lang.String[] ATTR_START_TABLE

ATTR_VALUE_TABLE

public static final java.lang.String[] ATTR_VALUE_TABLE
Constructor Detail

Wml

public Wml()
Method Detail

createParser

public static WbxmlParser createParser()
Creates a WbxmlParser with the WML code pages set


createSerializer

public static WbxmlSerializer createSerializer()


kxml2-2.3.0/www/kxml2/javadoc/org/kxml2/wap/wml/class-use/0000755000175000017500000000000010446737142021306 5ustar neoneokxml2-2.3.0/www/kxml2/javadoc/org/kxml2/wap/wml/class-use/Wml.html0000644000175000017500000001301310446737142022731 0ustar neoneo Uses of Class org.kxml2.wap.wml.Wml (kxml API)

Uses of Class
org.kxml2.wap.wml.Wml

No usage of org.kxml2.wap.wml.Wml



kxml2-2.3.0/www/kxml2/javadoc/org/kxml2/wap/wml/package-use.html0000644000175000017500000001242010446737142022461 0ustar neoneo Uses of Package org.kxml2.wap.wml (kxml API)

Uses of Package
org.kxml2.wap.wml

No usage of org.kxml2.wap.wml



kxml2-2.3.0/www/kxml2/javadoc/org/kxml2/wap/wml/package-frame.html0000644000175000017500000000155310446737142022764 0ustar neoneo org.kxml2.wap.wml (kxml API) org.kxml2.wap.wml
Classes 
Wml
kxml2-2.3.0/www/kxml2/javadoc/org/kxml2/wap/wml/package-summary.html0000644000175000017500000001406710446737142023373 0ustar neoneo org.kxml2.wap.wml (kxml API)

Package org.kxml2.wap.wml

Class Summary
Wml This class contains the wml coding tables for elements and attributes needed by the WmlParser.
 



kxml2-2.3.0/www/kxml2/javadoc/org/kxml2/wap/wml/package-tree.html0000644000175000017500000001337610446737142022637 0ustar neoneo org.kxml2.wap.wml Class Hierarchy (kxml API)

Hierarchy For Package org.kxml2.wap.wml

Package Hierarchies:
All Packages

Class Hierarchy

  • java.lang.Object
    • org.kxml2.wap.wml.Wml


kxml2-2.3.0/www/kxml2/javadoc/org/kxml2/wap/WbxmlParser.html0000644000175000017500000012606410446737142021755 0ustar neoneo WbxmlParser (kxml API)

org.kxml2.wap
Class WbxmlParser

java.lang.Object
  extended by org.kxml2.wap.WbxmlParser
All Implemented Interfaces:
org.xmlpull.v1.XmlPullParser

public class WbxmlParser
extends java.lang.Object
implements org.xmlpull.v1.XmlPullParser


Field Summary
static int WAP_EXTENSION
          Parser event type for Wbxml-specific events.
 
Fields inherited from interface org.xmlpull.v1.XmlPullParser
CDSECT, COMMENT, DOCDECL, END_DOCUMENT, END_TAG, ENTITY_REF, FEATURE_PROCESS_DOCDECL, FEATURE_PROCESS_NAMESPACES, FEATURE_REPORT_NAMESPACE_ATTRIBUTES, FEATURE_VALIDATION, IGNORABLE_WHITESPACE, NO_NAMESPACE, PROCESSING_INSTRUCTION, START_DOCUMENT, START_TAG, TEXT, TYPES
 
Constructor Summary
WbxmlParser()
           
 
Method Summary
 void defineEntityReplacementText(java.lang.String entity, java.lang.String value)
           
 int getAttributeCount()
           
 java.lang.String getAttributeName(int index)
           
 java.lang.String getAttributeNamespace(int index)
           
 java.lang.String getAttributePrefix(int index)
           
 java.lang.String getAttributeType(int index)
           
 java.lang.String getAttributeValue(int index)
           
 java.lang.String getAttributeValue(java.lang.String namespace, java.lang.String name)
           
 int getColumnNumber()
           
 int getDepth()
           
 int getEventType()
           
 boolean getFeature(java.lang.String feature)
           
 java.lang.String getInputEncoding()
           
 int getLineNumber()
           
 java.lang.String getName()
           
 java.lang.String getNamespace()
           
 java.lang.String getNamespace(java.lang.String prefix)
           
 int getNamespaceCount(int depth)
           
 java.lang.String getNamespacePrefix(int pos)
           
 java.lang.String getNamespaceUri(int pos)
           
 java.lang.String getPositionDescription()
           
 java.lang.String getPrefix()
           
 java.lang.Object getProperty(java.lang.String property)
           
 java.lang.String getText()
           
 char[] getTextCharacters(int[] poslen)
           
 int getWapCode()
          Returns the token ID for start tags or the event type for wap proprietary events such as OPAQUE.
 java.lang.Object getWapExtensionData()
           
 boolean isAttributeDefault(int index)
           
 boolean isEmptyElementTag()
           
 boolean isWhitespace()
           
 int next()
           
 int nextTag()
           
 java.lang.String nextText()
           
 int nextToken()
           
 java.lang.Object parseWapExtension(int id)
          Overwrite this method to intercept all wap events
 void readAttr()
           
 void require(int type, java.lang.String namespace, java.lang.String name)
           
 void setAttrStartTable(int page, java.lang.String[] table)
          Sets the attribute start Table for a given page.
 void setAttrValueTable(int page, java.lang.String[] table)
          Sets the attribute value Table for a given page.
 void setFeature(java.lang.String feature, boolean value)
           
 void setInput(java.io.InputStream in, java.lang.String enc)
           
 void setInput(java.io.Reader reader)
           
 void setProperty(java.lang.String property, java.lang.Object value)
           
 void setTagTable(int page, java.lang.String[] table)
          Sets the tag table for a given page.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WAP_EXTENSION

public static final int WAP_EXTENSION
Parser event type for Wbxml-specific events. The Wbxml event code can be accessed with getWapCode()

See Also:
Constant Field Values
Constructor Detail

WbxmlParser

public WbxmlParser()
Method Detail

getFeature

public boolean getFeature(java.lang.String feature)
Specified by:
getFeature in interface org.xmlpull.v1.XmlPullParser

getInputEncoding

public java.lang.String getInputEncoding()
Specified by:
getInputEncoding in interface org.xmlpull.v1.XmlPullParser

defineEntityReplacementText

public void defineEntityReplacementText(java.lang.String entity,
                                        java.lang.String value)
                                 throws org.xmlpull.v1.XmlPullParserException
Specified by:
defineEntityReplacementText in interface org.xmlpull.v1.XmlPullParser
Throws:
org.xmlpull.v1.XmlPullParserException

getProperty

public java.lang.Object getProperty(java.lang.String property)
Specified by:
getProperty in interface org.xmlpull.v1.XmlPullParser

getNamespaceCount

public int getNamespaceCount(int depth)
Specified by:
getNamespaceCount in interface org.xmlpull.v1.XmlPullParser

getNamespacePrefix

public java.lang.String getNamespacePrefix(int pos)
Specified by:
getNamespacePrefix in interface org.xmlpull.v1.XmlPullParser

getNamespaceUri

public java.lang.String getNamespaceUri(int pos)
Specified by:
getNamespaceUri in interface org.xmlpull.v1.XmlPullParser

getNamespace

public java.lang.String getNamespace(java.lang.String prefix)
Specified by:
getNamespace in interface org.xmlpull.v1.XmlPullParser

getDepth

public int getDepth()
Specified by:
getDepth in interface org.xmlpull.v1.XmlPullParser

getPositionDescription

public java.lang.String getPositionDescription()
Specified by:
getPositionDescription in interface org.xmlpull.v1.XmlPullParser

getLineNumber

public int getLineNumber()
Specified by:
getLineNumber in interface org.xmlpull.v1.XmlPullParser

getColumnNumber

public int getColumnNumber()
Specified by:
getColumnNumber in interface org.xmlpull.v1.XmlPullParser

isWhitespace

public boolean isWhitespace()
                     throws org.xmlpull.v1.XmlPullParserException
Specified by:
isWhitespace in interface org.xmlpull.v1.XmlPullParser
Throws:
org.xmlpull.v1.XmlPullParserException

getText

public java.lang.String getText()
Specified by:
getText in interface org.xmlpull.v1.XmlPullParser

getTextCharacters

public char[] getTextCharacters(int[] poslen)
Specified by:
getTextCharacters in interface org.xmlpull.v1.XmlPullParser

getNamespace

public java.lang.String getNamespace()
Specified by:
getNamespace in interface org.xmlpull.v1.XmlPullParser

getName

public java.lang.String getName()
Specified by:
getName in interface org.xmlpull.v1.XmlPullParser

getPrefix

public java.lang.String getPrefix()
Specified by:
getPrefix in interface org.xmlpull.v1.XmlPullParser

isEmptyElementTag

public boolean isEmptyElementTag()
                          throws org.xmlpull.v1.XmlPullParserException
Specified by:
isEmptyElementTag in interface org.xmlpull.v1.XmlPullParser
Throws:
org.xmlpull.v1.XmlPullParserException

getAttributeCount

public int getAttributeCount()
Specified by:
getAttributeCount in interface org.xmlpull.v1.XmlPullParser

getAttributeType

public java.lang.String getAttributeType(int index)
Specified by:
getAttributeType in interface org.xmlpull.v1.XmlPullParser

isAttributeDefault

public boolean isAttributeDefault(int index)
Specified by:
isAttributeDefault in interface org.xmlpull.v1.XmlPullParser

getAttributeNamespace

public java.lang.String getAttributeNamespace(int index)
Specified by:
getAttributeNamespace in interface org.xmlpull.v1.XmlPullParser

getAttributeName

public java.lang.String getAttributeName(int index)
Specified by:
getAttributeName in interface org.xmlpull.v1.XmlPullParser

getAttributePrefix

public java.lang.String getAttributePrefix(int index)
Specified by:
getAttributePrefix in interface org.xmlpull.v1.XmlPullParser

getAttributeValue

public java.lang.String getAttributeValue(int index)
Specified by:
getAttributeValue in interface org.xmlpull.v1.XmlPullParser

getAttributeValue

public java.lang.String getAttributeValue(java.lang.String namespace,
                                          java.lang.String name)
Specified by:
getAttributeValue in interface org.xmlpull.v1.XmlPullParser

getEventType

public int getEventType()
                 throws org.xmlpull.v1.XmlPullParserException
Specified by:
getEventType in interface org.xmlpull.v1.XmlPullParser
Throws:
org.xmlpull.v1.XmlPullParserException

next

public int next()
         throws org.xmlpull.v1.XmlPullParserException,
                java.io.IOException
Specified by:
next in interface org.xmlpull.v1.XmlPullParser
Throws:
org.xmlpull.v1.XmlPullParserException
java.io.IOException

nextToken

public int nextToken()
              throws org.xmlpull.v1.XmlPullParserException,
                     java.io.IOException
Specified by:
nextToken in interface org.xmlpull.v1.XmlPullParser
Throws:
org.xmlpull.v1.XmlPullParserException
java.io.IOException

nextTag

public int nextTag()
            throws org.xmlpull.v1.XmlPullParserException,
                   java.io.IOException
Specified by:
nextTag in interface org.xmlpull.v1.XmlPullParser
Throws:
org.xmlpull.v1.XmlPullParserException
java.io.IOException

nextText

public java.lang.String nextText()
                          throws org.xmlpull.v1.XmlPullParserException,
                                 java.io.IOException
Specified by:
nextText in interface org.xmlpull.v1.XmlPullParser
Throws:
org.xmlpull.v1.XmlPullParserException
java.io.IOException

require

public void require(int type,
                    java.lang.String namespace,
                    java.lang.String name)
             throws org.xmlpull.v1.XmlPullParserException,
                    java.io.IOException
Specified by:
require in interface org.xmlpull.v1.XmlPullParser
Throws:
org.xmlpull.v1.XmlPullParserException
java.io.IOException

setInput

public void setInput(java.io.Reader reader)
              throws org.xmlpull.v1.XmlPullParserException
Specified by:
setInput in interface org.xmlpull.v1.XmlPullParser
Throws:
org.xmlpull.v1.XmlPullParserException

setInput

public void setInput(java.io.InputStream in,
                     java.lang.String enc)
              throws org.xmlpull.v1.XmlPullParserException
Specified by:
setInput in interface org.xmlpull.v1.XmlPullParser
Throws:
org.xmlpull.v1.XmlPullParserException

setFeature

public void setFeature(java.lang.String feature,
                       boolean value)
                throws org.xmlpull.v1.XmlPullParserException
Specified by:
setFeature in interface org.xmlpull.v1.XmlPullParser
Throws:
org.xmlpull.v1.XmlPullParserException

setProperty

public void setProperty(java.lang.String property,
                        java.lang.Object value)
                 throws org.xmlpull.v1.XmlPullParserException
Specified by:
setProperty in interface org.xmlpull.v1.XmlPullParser
Throws:
org.xmlpull.v1.XmlPullParserException

parseWapExtension

public java.lang.Object parseWapExtension(int id)
                                   throws java.io.IOException,
                                          org.xmlpull.v1.XmlPullParserException
Overwrite this method to intercept all wap events

Throws:
java.io.IOException
org.xmlpull.v1.XmlPullParserException

readAttr

public void readAttr()
              throws java.io.IOException,
                     org.xmlpull.v1.XmlPullParserException
Throws:
java.io.IOException
org.xmlpull.v1.XmlPullParserException

setTagTable

public void setTagTable(int page,
                        java.lang.String[] table)
Sets the tag table for a given page. The first string in the array defines tag 5, the second tag 6 etc.


setAttrStartTable

public void setAttrStartTable(int page,
                              java.lang.String[] table)
Sets the attribute start Table for a given page. The first string in the array defines attribute 5, the second attribute 6 etc. Please use the character '=' (without quote!) as delimiter between the attribute name and the (start of the) value


setAttrValueTable

public void setAttrValueTable(int page,
                              java.lang.String[] table)
Sets the attribute value Table for a given page. The first string in the array defines attribute value 0x85, the second attribute value 0x86 etc.


getWapCode

public int getWapCode()
Returns the token ID for start tags or the event type for wap proprietary events such as OPAQUE.


getWapExtensionData

public java.lang.Object getWapExtensionData()


kxml2-2.3.0/www/kxml2/javadoc/org/kxml2/wap/WbxmlSerializer.html0000644000175000017500000007752010446737142022634 0ustar neoneo WbxmlSerializer (kxml API)

org.kxml2.wap
Class WbxmlSerializer

java.lang.Object
  extended by org.kxml2.wap.WbxmlSerializer
All Implemented Interfaces:
org.xmlpull.v1.XmlSerializer

public class WbxmlSerializer
extends java.lang.Object
implements org.xmlpull.v1.XmlSerializer

A class for writing WBXML.


Constructor Summary
WbxmlSerializer()
           
 
Method Summary
 org.xmlpull.v1.XmlSerializer attribute(java.lang.String namespace, java.lang.String name, java.lang.String value)
           
 void cdsect(java.lang.String cdsect)
           
 void checkPending(boolean degenerated)
           
 void comment(java.lang.String comment)
           
 void docdecl(java.lang.String docdecl)
           
 void endDocument()
           
 org.xmlpull.v1.XmlSerializer endTag(java.lang.String namespace, java.lang.String name)
           
 void entityRef(java.lang.String er)
           
 void flush()
          ATTENTION: flush cannot work since Wbxml documents require buffering.
 int getDepth()
           
 boolean getFeature(java.lang.String name)
           
 java.lang.String getName()
           
 java.lang.String getNamespace()
           
 java.lang.String getPrefix(java.lang.String nsp, boolean create)
           
 java.lang.Object getProperty(java.lang.String name)
           
 void ignorableWhitespace(java.lang.String sp)
           
 void processingInstruction(java.lang.String pi)
           
 void setAttrStartTable(int page, java.lang.String[] attrStartTable)
          Sets the attribute start Table for a given page.
 void setAttrValueTable(int page, java.lang.String[] attrValueTable)
          Sets the attribute value Table for a given page.
 void setFeature(java.lang.String name, boolean value)
           
 void setOutput(java.io.OutputStream out, java.lang.String encoding)
           
 void setOutput(java.io.Writer writer)
           
 void setPrefix(java.lang.String prefix, java.lang.String nsp)
           
 void setProperty(java.lang.String property, java.lang.Object value)
           
 void setTagTable(int page, java.lang.String[] tagTable)
          Sets the tag table for a given page.
 void startDocument(java.lang.String s, java.lang.Boolean b)
           
 org.xmlpull.v1.XmlSerializer startTag(java.lang.String namespace, java.lang.String name)
           
 org.xmlpull.v1.XmlSerializer text(char[] chars, int start, int len)
           
 org.xmlpull.v1.XmlSerializer text(java.lang.String text)
           
 void writeWapExtension(int type, java.lang.Object data)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WbxmlSerializer

public WbxmlSerializer()
Method Detail

attribute

public org.xmlpull.v1.XmlSerializer attribute(java.lang.String namespace,
                                              java.lang.String name,
                                              java.lang.String value)
Specified by:
attribute in interface org.xmlpull.v1.XmlSerializer

cdsect

public void cdsect(java.lang.String cdsect)
            throws java.io.IOException
Specified by:
cdsect in interface org.xmlpull.v1.XmlSerializer
Throws:
java.io.IOException

comment

public void comment(java.lang.String comment)
Specified by:
comment in interface org.xmlpull.v1.XmlSerializer

docdecl

public void docdecl(java.lang.String docdecl)
Specified by:
docdecl in interface org.xmlpull.v1.XmlSerializer

entityRef

public void entityRef(java.lang.String er)
Specified by:
entityRef in interface org.xmlpull.v1.XmlSerializer

getDepth

public int getDepth()
Specified by:
getDepth in interface org.xmlpull.v1.XmlSerializer

getFeature

public boolean getFeature(java.lang.String name)
Specified by:
getFeature in interface org.xmlpull.v1.XmlSerializer

getNamespace

public java.lang.String getNamespace()
Specified by:
getNamespace in interface org.xmlpull.v1.XmlSerializer

getName

public java.lang.String getName()
Specified by:
getName in interface org.xmlpull.v1.XmlSerializer

getPrefix

public java.lang.String getPrefix(java.lang.String nsp,
                                  boolean create)
Specified by:
getPrefix in interface org.xmlpull.v1.XmlSerializer

getProperty

public java.lang.Object getProperty(java.lang.String name)
Specified by:
getProperty in interface org.xmlpull.v1.XmlSerializer

ignorableWhitespace

public void ignorableWhitespace(java.lang.String sp)
Specified by:
ignorableWhitespace in interface org.xmlpull.v1.XmlSerializer

endDocument

public void endDocument()
                 throws java.io.IOException
Specified by:
endDocument in interface org.xmlpull.v1.XmlSerializer
Throws:
java.io.IOException

flush

public void flush()
ATTENTION: flush cannot work since Wbxml documents require buffering. Thus, this call does nothing.

Specified by:
flush in interface org.xmlpull.v1.XmlSerializer

checkPending

public void checkPending(boolean degenerated)
                  throws java.io.IOException
Throws:
java.io.IOException

processingInstruction

public void processingInstruction(java.lang.String pi)
Specified by:
processingInstruction in interface org.xmlpull.v1.XmlSerializer

setFeature

public void setFeature(java.lang.String name,
                       boolean value)
Specified by:
setFeature in interface org.xmlpull.v1.XmlSerializer

setOutput

public void setOutput(java.io.Writer writer)
Specified by:
setOutput in interface org.xmlpull.v1.XmlSerializer

setOutput

public void setOutput(java.io.OutputStream out,
                      java.lang.String encoding)
               throws java.io.IOException
Specified by:
setOutput in interface org.xmlpull.v1.XmlSerializer
Throws:
java.io.IOException

setPrefix

public void setPrefix(java.lang.String prefix,
                      java.lang.String nsp)
Specified by:
setPrefix in interface org.xmlpull.v1.XmlSerializer

setProperty

public void setProperty(java.lang.String property,
                        java.lang.Object value)
Specified by:
setProperty in interface org.xmlpull.v1.XmlSerializer

startDocument

public void startDocument(java.lang.String s,
                          java.lang.Boolean b)
                   throws java.io.IOException
Specified by:
startDocument in interface org.xmlpull.v1.XmlSerializer
Throws:
java.io.IOException

startTag

public org.xmlpull.v1.XmlSerializer startTag(java.lang.String namespace,
                                             java.lang.String name)
                                      throws java.io.IOException
Specified by:
startTag in interface org.xmlpull.v1.XmlSerializer
Throws:
java.io.IOException

text

public org.xmlpull.v1.XmlSerializer text(char[] chars,
                                         int start,
                                         int len)
                                  throws java.io.IOException
Specified by:
text in interface org.xmlpull.v1.XmlSerializer
Throws:
java.io.IOException

text

public org.xmlpull.v1.XmlSerializer text(java.lang.String text)
                                  throws java.io.IOException
Specified by:
text in interface org.xmlpull.v1.XmlSerializer
Throws:
java.io.IOException

endTag

public org.xmlpull.v1.XmlSerializer endTag(java.lang.String namespace,
                                           java.lang.String name)
                                    throws java.io.IOException
Specified by:
endTag in interface org.xmlpull.v1.XmlSerializer
Throws:
java.io.IOException

writeWapExtension

public void writeWapExtension(int type,
                              java.lang.Object data)
                       throws java.io.IOException
Throws:
java.io.IOException

setTagTable

public void setTagTable(int page,
                        java.lang.String[] tagTable)
Sets the tag table for a given page. The first string in the array defines tag 5, the second tag 6 etc.


setAttrStartTable

public void setAttrStartTable(int page,
                              java.lang.String[] attrStartTable)
Sets the attribute start Table for a given page. The first string in the array defines attribute 5, the second attribute 6 etc. Please use the character '=' (without quote!) as delimiter between the attribute name and the (start of the) value


setAttrValueTable

public void setAttrValueTable(int page,
                              java.lang.String[] attrValueTable)
Sets the attribute value Table for a given page. The first string in the array defines attribute value 0x85, the second attribute value 0x86 etc.



kxml2-2.3.0/www/kxml2/javadoc/org/kxml2/wap/syncml/0000755000175000017500000000000010446737142020115 5ustar neoneokxml2-2.3.0/www/kxml2/javadoc/org/kxml2/wap/syncml/class-use/0000755000175000017500000000000010446737142022014 5ustar neoneokxml2-2.3.0/www/kxml2/javadoc/org/kxml2/wap/syncml/class-use/SyncML.html0000644000175000017500000001310710446737142024051 0ustar neoneo Uses of Class org.kxml2.wap.syncml.SyncML (kxml API)

Uses of Class
org.kxml2.wap.syncml.SyncML

No usage of org.kxml2.wap.syncml.SyncML



kxml2-2.3.0/www/kxml2/javadoc/org/kxml2/wap/syncml/SyncML.html0000644000175000017500000003257410446737142022163 0ustar neoneo SyncML (kxml API)

org.kxml2.wap.syncml
Class SyncML

java.lang.Object
  extended by org.kxml2.wap.syncml.SyncML

public abstract class SyncML
extends java.lang.Object


Field Summary
static java.lang.String[] TAG_TABLE_0
           
static java.lang.String[] TAG_TABLE_1
           
static java.lang.String[] TAG_TABLE_2_DM
           
 
Constructor Summary
SyncML()
           
 
Method Summary
static WbxmlParser createDMParser()
           
static WbxmlSerializer createDMSerializer()
           
static WbxmlParser createParser()
           
static WbxmlSerializer createSerializer()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TAG_TABLE_0

public static final java.lang.String[] TAG_TABLE_0

TAG_TABLE_1

public static final java.lang.String[] TAG_TABLE_1

TAG_TABLE_2_DM

public static final java.lang.String[] TAG_TABLE_2_DM
Constructor Detail

SyncML

public SyncML()
Method Detail

createParser

public static WbxmlParser createParser()

createSerializer

public static WbxmlSerializer createSerializer()

createDMParser

public static WbxmlParser createDMParser()

createDMSerializer

public static WbxmlSerializer createDMSerializer()


kxml2-2.3.0/www/kxml2/javadoc/org/kxml2/wap/syncml/package-use.html0000644000175000017500000001244210446737142023173 0ustar neoneo Uses of Package org.kxml2.wap.syncml (kxml API)

Uses of Package
org.kxml2.wap.syncml

No usage of org.kxml2.wap.syncml



kxml2-2.3.0/www/kxml2/javadoc/org/kxml2/wap/syncml/package-frame.html0000644000175000017500000000160010446737142023463 0ustar neoneo org.kxml2.wap.syncml (kxml API) org.kxml2.wap.syncml
Classes 
SyncML
kxml2-2.3.0/www/kxml2/javadoc/org/kxml2/wap/syncml/package-summary.html0000644000175000017500000001375610446737142024105 0ustar neoneo org.kxml2.wap.syncml (kxml API)

Package org.kxml2.wap.syncml

Class Summary
SyncML  
 



kxml2-2.3.0/www/kxml2/javadoc/org/kxml2/wap/syncml/package-tree.html0000644000175000017500000001342010446737142023333 0ustar neoneo org.kxml2.wap.syncml Class Hierarchy (kxml API)

Hierarchy For Package org.kxml2.wap.syncml

Package Hierarchies:
All Packages

Class Hierarchy

  • java.lang.Object


kxml2-2.3.0/www/kxml2/javadoc/org/kxml2/wap/wv/0000755000175000017500000000000010446737142017244 5ustar neoneokxml2-2.3.0/www/kxml2/javadoc/org/kxml2/wap/wv/class-use/0000755000175000017500000000000010446737142021143 5ustar neoneokxml2-2.3.0/www/kxml2/javadoc/org/kxml2/wap/wv/class-use/WV.html0000644000175000017500000001276710446737142022402 0ustar neoneo Uses of Class org.kxml2.wap.wv.WV (kxml API)

Uses of Class
org.kxml2.wap.wv.WV

No usage of org.kxml2.wap.wv.WV



kxml2-2.3.0/www/kxml2/javadoc/org/kxml2/wap/wv/WV.html0000644000175000017500000004077410446737142020502 0ustar neoneo WV (kxml API)

org.kxml2.wap.wv
Class WV

java.lang.Object
  extended by org.kxml2.wap.wv.WV

public abstract class WV
extends java.lang.Object

Wireless Village CSP 1.1 ("OMA-WV-CSP-V1_1-20021001-A.pdf") Wireless Village CSP 1.2 ("OMA-IMPS-WV-CSP_WBXML-v1_2-20030221-C.PDF") There are some bugs in the 1.2 spec but this is Ok. 1.2 is candidate

Author:
Bogdan Onoiu

Field Summary
static java.lang.String[] attrStartTable
           
static java.lang.String[] attrValueTable
           
static java.lang.String[] tagTablePage0
           
static java.lang.String[] tagTablePage1
           
static java.lang.String[] tagTablePage2
           
static java.lang.String[] tagTablePage3
           
static java.lang.String[] tagTablePage4
           
static java.lang.String[] tagTablePage5
           
static java.lang.String[] tagTablePage6
           
static java.lang.String[] tagTablePage7
           
static java.lang.String[] tagTablePage8
           
static java.lang.String[] tagTablePage9
           
static java.lang.String[] tagTablePageA
           
 
Constructor Summary
WV()
           
 
Method Summary
static WbxmlParser createParser()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

tagTablePage0

public static final java.lang.String[] tagTablePage0

tagTablePage1

public static final java.lang.String[] tagTablePage1

tagTablePage2

public static final java.lang.String[] tagTablePage2

tagTablePage3

public static final java.lang.String[] tagTablePage3

tagTablePage4

public static final java.lang.String[] tagTablePage4

tagTablePage5

public static final java.lang.String[] tagTablePage5

tagTablePage6

public static final java.lang.String[] tagTablePage6

tagTablePage7

public static final java.lang.String[] tagTablePage7

tagTablePage8

public static final java.lang.String[] tagTablePage8

tagTablePage9

public static final java.lang.String[] tagTablePage9

tagTablePageA

public static final java.lang.String[] tagTablePageA

attrStartTable

public static final java.lang.String[] attrStartTable

attrValueTable

public static final java.lang.String[] attrValueTable
Constructor Detail

WV

public WV()
Method Detail

createParser

public static WbxmlParser createParser()
                                throws java.io.IOException
Throws:
java.io.IOException


kxml2-2.3.0/www/kxml2/javadoc/org/kxml2/wap/wv/package-use.html0000644000175000017500000001241210446737142022317 0ustar neoneo Uses of Package org.kxml2.wap.wv (kxml API)

Uses of Package
org.kxml2.wap.wv

No usage of org.kxml2.wap.wv



kxml2-2.3.0/www/kxml2/javadoc/org/kxml2/wap/wv/package-frame.html0000644000175000017500000000154410446737142022621 0ustar neoneo org.kxml2.wap.wv (kxml API) org.kxml2.wap.wv
Classes 
WV
kxml2-2.3.0/www/kxml2/javadoc/org/kxml2/wap/wv/package-summary.html0000644000175000017500000001376610446737142023235 0ustar neoneo org.kxml2.wap.wv (kxml API)

Package org.kxml2.wap.wv

Class Summary
WV Wireless Village CSP 1.1 ("OMA-WV-CSP-V1_1-20021001-A.pdf") Wireless Village CSP 1.2 ("OMA-IMPS-WV-CSP_WBXML-v1_2-20030221-C.PDF") There are some bugs in the 1.2 spec but this is Ok.
 



kxml2-2.3.0/www/kxml2/javadoc/org/kxml2/wap/wv/package-tree.html0000644000175000017500000001314610446737142022467 0ustar neoneo org.kxml2.wap.wv Class Hierarchy (kxml API)

Hierarchy For Package org.kxml2.wap.wv

Package Hierarchies:
All Packages

Class Hierarchy

  • java.lang.Object
    • org.kxml2.wap.wv.WV


kxml2-2.3.0/www/kxml2/javadoc/org/kxml2/wap/Wbxml.html0000644000175000017500000004317710446737142020603 0ustar neoneo Wbxml (kxml API)

org.kxml2.wap
Interface Wbxml


public interface Wbxml

contains the WBXML constants


Field Summary
static int END
           
static int ENTITY
           
static int EXT_0
           
static int EXT_1
           
static int EXT_2
           
static int EXT_I_0
           
static int EXT_I_1
           
static int EXT_I_2
           
static int EXT_T_0
           
static int EXT_T_1
           
static int EXT_T_2
           
static int LITERAL
           
static int LITERAL_A
           
static int LITERAL_AC
           
static int LITERAL_C
           
static int OPAQUE
           
static int PI
           
static int STR_I
           
static int STR_T
           
static int SWITCH_PAGE
           
 

Field Detail

SWITCH_PAGE

static final int SWITCH_PAGE
See Also:
Constant Field Values

END

static final int END
See Also:
Constant Field Values

ENTITY

static final int ENTITY
See Also:
Constant Field Values

STR_I

static final int STR_I
See Also:
Constant Field Values

LITERAL

static final int LITERAL
See Also:
Constant Field Values

EXT_I_0

static final int EXT_I_0
See Also:
Constant Field Values

EXT_I_1

static final int EXT_I_1
See Also:
Constant Field Values

EXT_I_2

static final int EXT_I_2
See Also:
Constant Field Values

PI

static final int PI
See Also:
Constant Field Values

LITERAL_C

static final int LITERAL_C
See Also:
Constant Field Values

EXT_T_0

static final int EXT_T_0
See Also:
Constant Field Values

EXT_T_1

static final int EXT_T_1
See Also:
Constant Field Values

EXT_T_2

static final int EXT_T_2
See Also:
Constant Field Values

STR_T

static final int STR_T
See Also:
Constant Field Values

LITERAL_A

static final int LITERAL_A
See Also:
Constant Field Values

EXT_0

static final int EXT_0
See Also:
Constant Field Values

EXT_1

static final int EXT_1
See Also:
Constant Field Values

EXT_2

static final int EXT_2
See Also:
Constant Field Values

OPAQUE

static final int OPAQUE
See Also:
Constant Field Values

LITERAL_AC

static final int LITERAL_AC
See Also:
Constant Field Values


kxml2-2.3.0/www/kxml2/javadoc/org/kxml2/wap/package-use.html0000644000175000017500000002052410446737142021666 0ustar neoneo Uses of Package org.kxml2.wap (kxml API)

Uses of Package
org.kxml2.wap

Packages that use org.kxml2.wap
org.kxml2.wap.syncml   
org.kxml2.wap.wml   
org.kxml2.wap.wv   
 

Classes in org.kxml2.wap used by org.kxml2.wap.syncml
WbxmlParser
           
WbxmlSerializer
          A class for writing WBXML.
 

Classes in org.kxml2.wap used by org.kxml2.wap.wml
WbxmlParser
           
WbxmlSerializer
          A class for writing WBXML.
 

Classes in org.kxml2.wap used by org.kxml2.wap.wv
WbxmlParser
           
 



kxml2-2.3.0/www/kxml2/javadoc/org/kxml2/wap/package-frame.html0000644000175000017500000000234510446737142022165 0ustar neoneo org.kxml2.wap (kxml API) org.kxml2.wap
Interfaces 
Wbxml
Classes 
WbxmlParser
WbxmlSerializer
kxml2-2.3.0/www/kxml2/javadoc/org/kxml2/wap/package-summary.html0000644000175000017500000001503510446737142022570 0ustar neoneo org.kxml2.wap (kxml API)

Package org.kxml2.wap

Interface Summary
Wbxml contains the WBXML constants
 

Class Summary
WbxmlParser  
WbxmlSerializer A class for writing WBXML.
 



kxml2-2.3.0/www/kxml2/javadoc/org/kxml2/wap/package-tree.html0000644000175000017500000001407110446737142022031 0ustar neoneo org.kxml2.wap Class Hierarchy (kxml API)

Hierarchy For Package org.kxml2.wap

Package Hierarchies:
All Packages

Class Hierarchy

  • java.lang.Object
    • org.kxml2.wap.WbxmlParser (implements org.xmlpull.v1.XmlPullParser)
    • org.kxml2.wap.WbxmlSerializer (implements org.xmlpull.v1.XmlSerializer)

Interface Hierarchy



kxml2-2.3.0/www/kxml2/javadoc/package-list0000644000175000017500000000014210446737142016461 0ustar neoneoorg.kxml2.io org.kxml2.kdom org.kxml2.wap org.kxml2.wap.syncml org.kxml2.wap.wml org.kxml2.wap.wv kxml2-2.3.0/www/kxml2/javadoc/allclasses-noframe.html0000644000175000017500000000303310446737142020635 0ustar neoneo All Classes (kxml API) All Classes
Document
Element
KXmlParser
KXmlSerializer
Node
SyncML
Wbxml
WbxmlParser
WbxmlSerializer
Wml
WV
kxml2-2.3.0/www/kxml2/javadoc/help-doc.html0000644000175000017500000002261510446737142016564 0ustar neoneo API Help (kxml API)

How This API Document Is Organized

This API (Application Programming Interface) document has pages corresponding to the items in the navigation bar, described as follows.

Overview

The Overview page is the front page of this API document and provides a list of all packages with a summary for each. This page can also contain an overall description of the set of packages.

Package

Each package has a page that contains a list of its classes and interfaces, with a summary for each. This page can contain four categories:

  • Interfaces (italic)
  • Classes
  • Enums
  • Exceptions
  • Errors
  • Annotation Types

Class/Interface

Each class, interface, nested class and nested interface has its own separate page. Each of these pages has three sections consisting of a class/interface description, summary tables, and detailed member descriptions:

  • Class inheritance diagram
  • Direct Subclasses
  • All Known Subinterfaces
  • All Known Implementing Classes
  • Class/interface declaration
  • Class/interface description

  • Nested Class Summary
  • Field Summary
  • Constructor Summary
  • Method Summary

  • Field Detail
  • Constructor Detail
  • Method Detail
Each summary entry contains the first sentence from the detailed description for that item. The summary entries are alphabetical, while the detailed descriptions are in the order they appear in the source code. This preserves the logical groupings established by the programmer.

Annotation Type

Each annotation type has its own separate page with the following sections:

  • Annotation Type declaration
  • Annotation Type description
  • Required Element Summary
  • Optional Element Summary
  • Element Detail

Enum

Each enum has its own separate page with the following sections:

  • Enum declaration
  • Enum description
  • Enum Constant Summary
  • Enum Constant Detail

Use

Each documented package, class and interface has its own Use page. This page describes what packages, classes, methods, constructors and fields use any part of the given class or package. Given a class or interface A, its Use page includes subclasses of A, fields declared as A, methods that return A, and methods and constructors with parameters of type A. You can access this page by first going to the package, class or interface, then clicking on the "Use" link in the navigation bar.

Tree (Class Hierarchy)

There is a Class Hierarchy page for all packages, plus a hierarchy for each package. Each hierarchy page contains a list of classes and a list of interfaces. The classes are organized by inheritance structure starting with java.lang.Object. The interfaces do not inherit from java.lang.Object.
  • When viewing the Overview page, clicking on "Tree" displays the hierarchy for all packages.
  • When viewing a particular package, class or interface page, clicking "Tree" displays the hierarchy for only that package.

Deprecated API

The Deprecated API page lists all of the API that have been deprecated. A deprecated API is not recommended for use, generally due to improvements, and a replacement API is usually given. Deprecated APIs may be removed in future implementations.

Index

The Index contains an alphabetic list of all classes, interfaces, constructors, methods, and fields.

Prev/Next

These links take you to the next or previous class, interface, package, or related page.

Frames/No Frames

These links show and hide the HTML frames. All pages are available with or without frames.

Serialized Form

Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to re-implementors, not to developers using the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking "Serialized Form" in the "See also" section of the class description.

Constant Field Values

The Constant Field Values page lists the static final fields and their values.

This help file applies to API documentation generated using the standard doclet.



kxml2-2.3.0/www/kxml2/javadoc/index.html0000644000175000017500000000244410446737142016176 0ustar neoneo kxml API <H2> Frame Alert</H2> <P> This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. <BR> Link to<A HREF="overview-summary.html">Non-frame version.</A> kxml2-2.3.0/www/kxml2/javadoc/constant-values.html0000644000175000017500000003732010446737142020216 0ustar neoneo Constant Field Values (kxml API)

Constant Field Values


Contents
org.kxml2.*

org.kxml2.kdom.Node
public static final int CDSECT 5
public static final int COMMENT 9
public static final int DOCDECL 10
public static final int DOCUMENT 0
public static final int ELEMENT 2
public static final int ENTITY_REF 6
public static final int IGNORABLE_WHITESPACE 7
public static final int PROCESSING_INSTRUCTION 8
public static final int TEXT 4

org.kxml2.wap.Wbxml
public static final int END 1
public static final int ENTITY 2
public static final int EXT_0 192
public static final int EXT_1 193
public static final int EXT_2 194
public static final int EXT_I_0 64
public static final int EXT_I_1 65
public static final int EXT_I_2 66
public static final int EXT_T_0 128
public static final int EXT_T_1 129
public static final int EXT_T_2 130
public static final int LITERAL 4
public static final int LITERAL_A 132
public static final int LITERAL_AC 196
public static final int LITERAL_C 68
public static final int OPAQUE 195
public static final int PI 67
public static final int STR_I 3
public static final int STR_T 131
public static final int SWITCH_PAGE 0

org.kxml2.wap.WbxmlParser
public static final int WAP_EXTENSION 64



kxml2-2.3.0/license.txt0000644000175000017500000000211007644577450013074 0ustar neoneoCopyright (c) 2002,2003, Stefan Haustein, Oberhausen, Rhld., Germany Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. kxml2-2.3.0/dist/0000755000175000017500000000000011402717307011642 5ustar neoneokxml2-2.3.0/samples_midp/0000755000175000017500000000000010435016414013350 5ustar neoneokxml2-2.3.0/samples_midp/Newsreader.java0000644000175000017500000000564607673365156016351 0ustar neoneoimport java.io.*; import java.util.Vector; import org.kxml2.io.*; import org.xmlpull.v1.*; import javax.microedition.midlet.*; import javax.microedition.lcdui.*; import javax.microedition.io.*; public class Newsreader extends MIDlet implements CommandListener { static final String URL = "http://www.newsforge.com/newsforge.xml"; static final String TITLE = "NewsForge"; Vector descriptions = new Vector(); List newsList = new List(TITLE, Choice.IMPLICIT); TextBox textBox = new TextBox("", "", 256, TextField.ANY); Display display; Command backCmd = new Command("Back", Command.BACK, 0); class ReadThread extends Thread { public void run() { try { HttpConnection httpConnection = (HttpConnection) Connector.open(URL); KXmlParser parser = new KXmlParser(); parser.setInput(new InputStreamReader(httpConnection.openInputStream())); // parser.relaxed = true; parser.nextTag(); parser.require(XmlPullParser.START_TAG, null, "backslash"); while (parser.nextTag () != XmlPullParser.END_TAG) readStory(parser); parser.require(XmlPullParser.END_TAG, null, "backslash"); parser.next(); parser.require(XmlPullParser.END_DOCUMENT, null, null); } catch (Exception e) { e.printStackTrace(); descriptions.addElement(e.toString()); newsList.append("Error", null); } } /** Read a story and append it to the list */ void readStory(KXmlParser parser) throws IOException, XmlPullParserException { parser.require(XmlPullParser.START_TAG, null, "story"); String title = null; String description = null; while (parser.nextTag() != XmlPullParser.END_TAG) { parser.require(XmlPullParser.START_TAG, null, null); String name = parser.getName(); String text = parser.nextText(); System.out.println ("<"+name+">"+text); if (name.equals("title")) title = text; else if (name.equals("description")) description = text; parser.require(XmlPullParser.END_TAG, null, name); } parser.require(XmlPullParser.END_TAG, null, "story"); if (title != null) { descriptions.addElement(""+description); newsList.append(title, null); } } } public void startApp() { display = Display.getDisplay(this); display.setCurrent(newsList); newsList.setCommandListener(this); textBox.setCommandListener(this); textBox.addCommand(backCmd); new ReadThread().start(); } public void pauseApp() { } public void commandAction(Command c, Displayable d) { if (c == List.SELECT_COMMAND) { String text = (String) descriptions.elementAt(newsList.getSelectedIndex()); if (textBox.getMaxSize() < text.length()) textBox.setMaxSize(text.length()); textBox.setString(text); display.setCurrent(textBox); } else if (c == backCmd) display.setCurrent(newsList); } public void destroyApp(boolean really) { } /* public static void main(String[] argv) { org.me4se.MIDletRunner.main (new String [] {"Newsreader"}); } */ }kxml2-2.3.0/samples/0000755000175000017500000000000010435016414012337 5ustar neoneokxml2-2.3.0/samples/LongStringTest.java0000644000175000017500000000176610340210644016136 0ustar neoneo import org.xmlpull.v1.XmlPullParser; import org.kxml2.io.KXmlParser; import java.io.ByteArrayInputStream; import java.io.InputStreamReader; // (C) Michael Walker, sun.com public class LongStringTest { public static void main(String[] args) { String xmlStr = "" + "" + "" + "" + "" + "" + "" + ""; System.out.println("xmlStr length: " + xmlStr.length()); ByteArrayInputStream bais = new ByteArrayInputStream(xmlStr.getBytes()); InputStreamReader isr = new InputStreamReader(bais); try { KXmlParser parser = new KXmlParser(); parser.setInput(isr); while (parser.next() != XmlPullParser.END_DOCUMENT) { if (parser.getEventType() == XmlPullParser.START_TAG) { System.out.println("start tag: " + parser.getName()); } } } catch (Exception ex) { ex.printStackTrace(); } } } kxml2-2.3.0/samples/KDomRoundtrip.java0000644000175000017500000000172007512530262015747 0ustar neoneoimport java.io.*; import org.xmlpull.v1.*; import org.kxml2.kdom.*; import org.kxml2.io.*; /** * @author Stefan Haustein * * To change this generated comment edit the template variable "typecomment": * Window>Preferences>Java>Templates. */ public class KDomRoundtrip { /** * Constructor for KDomRoundtrip. */ public static void main(String[] args) throws IOException, XmlPullParserException { if (args.length == 0) throw new RuntimeException ("input url expected"); for (int i = 0; i < args.length; i++) { System.out.println ("generating KDom from "+args[i]); KXmlParser parser = new KXmlParser (); parser.setInput (new FileReader (args [i])); parser.setFeature (XmlPullParser.FEATURE_PROCESS_NAMESPACES, true); Document doc = new Document (); doc.parse (parser); KXmlSerializer serializer = new KXmlSerializer (); serializer.setOutput (System.out, null); doc.write (serializer); serializer.flush (); } } } kxml2-2.3.0/samples/Roundtrip.java0000644000175000017500000001116110063647170015176 0ustar neoneo //package org.xmlpull.v1.samples; import java.io.*; import org.kxml2.io.*; import org.xmlpull.v1.*; public class Roundtrip { //private static final String FEATURE_XML_ROUNDTRIP= // "http://xmlpull.org/v1/doc/features.html#xml-roundtrip"; XmlPullParser parser; XmlSerializer serializer; public Roundtrip( XmlPullParser parser, XmlSerializer serializer) { this.parser = parser; this.serializer = serializer; } public void writeStartTag() throws XmlPullParserException, IOException { //check forcase when feature xml roundtrip is supported //if (parser.getFeature (FEATURE_XML_ROUNDTRIP)) { //TODO: how to do pass through string with actual start tag in getText() //return; //} if (!parser .getFeature( XmlPullParser .FEATURE_REPORT_NAMESPACE_ATTRIBUTES)) { for (int i = parser.getNamespaceCount(parser.getDepth() - 1); i < parser.getNamespaceCount(parser.getDepth()) - 1; i++) { serializer.setPrefix( parser.getNamespacePrefix(i), parser.getNamespaceUri(i)); } } serializer.startTag( parser.getNamespace(), parser.getName()); for (int i = 0; i < parser.getAttributeCount(); i++) { serializer.attribute( parser.getAttributeNamespace(i), parser.getAttributeName(i), parser.getAttributeValue(i)); } //serializer.closeStartTag(); } public void writeToken() throws XmlPullParserException, IOException { switch (parser.getEventType()) { case XmlPullParser.START_DOCUMENT : serializer.startDocument (null, null); break; case XmlPullParser.END_DOCUMENT : serializer.endDocument(); break; case XmlPullParser.START_TAG : writeStartTag(); break; case XmlPullParser.END_TAG : serializer.endTag( parser.getNamespace(), parser.getName()); break; case XmlPullParser.IGNORABLE_WHITESPACE : //comment it to remove ignorable whtespaces from XML infoset serializer.ignorableWhitespace(parser.getText()); break; case XmlPullParser.TEXT : if(parser.getText() == null) System.err.println("null text error at: "+parser.getPositionDescription()); else serializer.text(parser.getText()); break; case XmlPullParser.ENTITY_REF : if(parser.getText() != null) serializer.text(parser.getText()); else serializer.entityRef(parser.getName()); break; case XmlPullParser.CDSECT : serializer.cdsect(parser.getText()); break; case XmlPullParser.PROCESSING_INSTRUCTION : serializer.processingInstruction( parser.getText()); break; case XmlPullParser.COMMENT : serializer.comment(parser.getText()); break; case XmlPullParser.DOCDECL : serializer.docdecl(parser.getText()); break; default : throw new RuntimeException( "unrecognized event: " + parser.getEventType()); } } public void roundTrip() throws XmlPullParserException, IOException { while (parser.getEventType() != XmlPullParser.END_DOCUMENT) { writeToken(); serializer.flush(); parser.nextToken(); } writeToken(); } public static void main(String[] args) throws Exception { if (args.length == 0) throw new RuntimeException("input xml file name expected"); for (int i = 0; i < args.length; i++) { System.out.println("processing: " + args[i]); XmlPullParser pp = new KXmlParser(); pp.setFeature( XmlPullParser.FEATURE_PROCESS_NAMESPACES, true); XmlSerializer serializer = new KXmlSerializer(); pp.setInput(new FileReader(args[i])); serializer.setOutput(System.out, null); (new Roundtrip(pp, serializer)).roundTrip(); serializer.flush(); } } }kxml2-2.3.0/samples/sample.xml0000644000175000017500000000035607551371104014353 0ustar neoneo bar This is in a new namespace kxml2-2.3.0/samples/Weblogs.java0000644000175000017500000000427007617452244014624 0ustar neoneoimport org.xmlpull.v1.*; import java.util.*; import java.io.*; import java.net.*; /** * A simple example illustrationg some differences of the XmlPull API * and SAX. For the corresponding SAX based implementation, please refer to * http://www.cafeconleche.org/slides/sd2001east/xmlandjava/81.html ff. */ public class Weblogs { static List listChannels() throws IOException, XmlPullParserException { return listChannels("http://static.userland.com/weblogMonitor/logs.xml"); } static List listChannels(String uri) throws IOException, XmlPullParserException { Vector result = new Vector(); InputStream is = new URL(uri).openStream(); XmlPullParser parser = XmlPullParserFactory.newInstance().newPullParser(); parser.setInput(is, null); parser.nextTag(); parser.require(XmlPullParser.START_TAG, "", "weblogs"); while (parser.nextTag() == XmlPullParser.START_TAG) { String url = readSingle(parser); if (url != null) result.addElement(url); } parser.require(XmlPullParser.END_TAG, "", "weblogs"); parser.next(); parser.require(XmlPullParser.END_DOCUMENT, null, null); is.close (); parser.setInput (null); return result; } public static String readSingle(XmlPullParser parser) throws IOException, XmlPullParserException { String url = null; parser.require(XmlPullParser.START_TAG, "", "log"); while (parser.nextTag() == XmlPullParser.START_TAG) { String name = parser.getName(); String content = parser.nextText(); if (name.equals("url")) url = content; parser.require(XmlPullParser.END_TAG, "", name); } parser.require(XmlPullParser.END_TAG, "", "log"); return url; } public static void main(String[] args) throws IOException, XmlPullParserException { List urls = args.length > 0 ? listChannels(args[0]) : listChannels(); for (Iterator i = urls.iterator(); i.hasNext();) System.out.println(i.next()); } } kxml2-2.3.0/samples/bogdan.xml0000644000175000017500000000052310063647170014321 0ustar neoneo bar This is in a new namespace (06/15/2004 00:31) <HTML><BODY bgcolor="#ffffff"><FONT LANG="0">hiho</FONT></BODY></HTML> kxml2-2.3.0/samples/simple.xml0000644000175000017500000000036307551371104014361 0ustar neoneo simple test without namespaces! This is in a test text namespace kxml2-2.3.0/samples/YesNoGame.java0000644000175000017500000000536207617452244015054 0ustar neoneo/** * @author Stefan Haustein * * To change this generated comment edit the template variable "typecomment": * Window>Preferences>Java>Templates. */ import java.io.*; import org.xmlpull.v1.*; import org.kxml2.io.*; class Node { private String text; private Node yes; // if null, it's an answer private Node no; Node(String answer) { this.text = answer; } Node(String question, Node yes, Node no) { this.text = question; this.yes = yes; this.no = no; } void run () throws IOException { if (yes == null) System.out.println ("Answer: "+text); else { System.out.println (text+ " (y/n)"); while (true) { int i = System.in.read(); if (i == 'y' || i == 'Y') { yes.run(); break; } else if (i == 'n' || i == 'N') { no.run(); break; } } } } } public class YesNoGame { public static Node parseAnswer(XmlPullParser p) throws IOException, XmlPullParserException { p.require(XmlPullParser.START_TAG, "", "answer"); Node result = new Node (p.nextText()); p.require(XmlPullParser.END_TAG, "", "answer"); return result; } public static Node parseQuestion(XmlPullParser p) throws IOException, XmlPullParserException { p.require(XmlPullParser.START_TAG, "", "question"); String text = p.getAttributeValue("", "text"); Node yes = parseNode (p); Node no = parseNode (p); p.nextTag(); p.require(XmlPullParser.END_TAG, "", "question"); return new Node (text, yes, no); } public static Node parseNode (XmlPullParser p) throws IOException, XmlPullParserException { p.nextTag (); p.require(XmlPullParser.START_TAG, "", null); if (p.getName().equals("question")) return parseQuestion(p); else return parseAnswer(p); } public static void main(String[] args) throws IOException, XmlPullParserException { String sample = "\n" + " \n" + " It is the Sun!\n" + " It is a ball!\n" + " \n" + " I do not know!\n" + "\n"; XmlPullParser p = new KXmlParser(); p.setInput (new StringReader (sample)); Node game = parseNode (p); game.run(); } } kxml2-2.3.0/samples/WbxmlRoundtrip.java0000644000175000017500000000305410437016532016207 0ustar neoneoimport java.io.*; import org.kxml2.io.*; import org.kxml2.wap.*; import org.xmlpull.v1.*; /* * Created on 25.09.2003 * * To change the template for this generated file go to * Window>Preferences>Java>Code Generation>Code and Comments */ /** * @author haustein * * To change the template for this generated type comment go to * Window>Preferences>Java>Code Generation>Code and Comments */ public class WbxmlRoundtrip { public static void main(String[] argv) throws Exception { ByteArrayOutputStream bos = new ByteArrayOutputStream(); XmlPullParser xp = new KXmlParser(); xp.setInput(new FileInputStream(argv[0]), null); XmlSerializer xs = new WbxmlSerializer(); xs.setOutput(bos, null); new Roundtrip(xp, xs).roundTrip(); byte[] wbxml = bos.toByteArray(); System.out.println("********* WBXML size: "+wbxml.length+" ***********"); for(int i = 0; i < wbxml.length; i += 16){ for (int j = i; j < Math.min(i + 16, wbxml.length); j ++) { int b = ((int) wbxml[j]) & 0x0ff; System.out.print(Integer.toHexString(b / 16)); System.out.print(Integer.toHexString(b % 16)); System.out.print(' '); } for (int j = i; j < Math.min(i + 16, wbxml.length); j ++) { int b = wbxml[j]; System.out.print(b >= 32 && b <= 127 ? (char) b : '?'); } System.out.println(); } ByteArrayInputStream bis = new ByteArrayInputStream(wbxml); xp = new WbxmlParser(); xp.setInput(bis, null); xs = new KXmlSerializer(); xs.setOutput(System.out, null); new Roundtrip(xp, xs).roundTrip(); } } kxml2-2.3.0/samples/EventList.java0000644000175000017500000000117607507375504015142 0ustar neoneoimport java.io.*; import org.kxml2.io.*; import org.xmlpull.v1.*; public class EventList { public static void main(String[] args) throws IOException, XmlPullParserException { for (int i = 0; i < 2; i++) { XmlPullParser xr = new KXmlParser(); xr.setInput(new FileReader(args[0])); System.out.println(""); System.out.println( "*** next" + (i == 0 ? "Token" : "") + " () event list ***"); System.out.println(""); do { if (i == 0) xr.nextToken(); else xr.next(); System.out.println(xr.getPositionDescription()); } while (xr.getEventType() != XmlPullParser.END_DOCUMENT); } } }kxml2-2.3.0/src/0000755000175000017500000000000010435016414011462 5ustar neoneokxml2-2.3.0/src/META-INF/0000755000175000017500000000000010435016414012622 5ustar neoneokxml2-2.3.0/src/META-INF/services/0000755000175000017500000000000010435016414014445 5ustar neoneokxml2-2.3.0/src/META-INF/services/org.xmlpull.v1.XmlPullParserFactory0000644000175000017500000000007007534172772023316 0ustar neoneoorg.kxml2.io.KXmlParser,org.kxml2.io.KXmlSerializer kxml2-2.3.0/src/org/0000755000175000017500000000000010435016414012251 5ustar neoneokxml2-2.3.0/src/org/kxml2/0000755000175000017500000000000010435016414013306 5ustar neoneokxml2-2.3.0/src/org/kxml2/kdom/0000755000175000017500000000000010435016414014240 5ustar neoneokxml2-2.3.0/src/org/kxml2/kdom/Document.java0000644000175000017500000000764310043207504016670 0ustar neoneo/* Copyright (c) 2002,2003, Stefan Haustein, Oberhausen, Rhld., Germany * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or * sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS * IN THE SOFTWARE. */ package org.kxml2.kdom; import java.io.*; import org.xmlpull.v1.*; /** The document consists of some legacy events and a single root element. This class basically adds some consistency checks to Node. */ public class Document extends Node { protected int rootIndex = -1; String encoding; Boolean standalone; /** returns "#document" */ public String getEncoding () { return encoding; } public void setEncoding(String enc) { this.encoding = enc; } public void setStandalone (Boolean standalone) { this.standalone = standalone; } public Boolean getStandalone() { return standalone; } public String getName() { return "#document"; } /** Adds a child at the given index position. Throws an exception when a second root element is added */ public void addChild(int index, int type, Object child) { if (type == ELEMENT) { // if (rootIndex != -1) // throw new RuntimeException("Only one document root element allowed"); rootIndex = index; } else if (rootIndex >= index) rootIndex++; super.addChild(index, type, child); } /** reads the document and checks if the last event is END_DOCUMENT. If not, an exception is thrown. The end event is consumed. For parsing partial XML structures, consider using Node.parse (). */ public void parse(XmlPullParser parser) throws IOException, XmlPullParserException { parser.require(XmlPullParser.START_DOCUMENT, null, null); parser.nextToken (); encoding = parser.getInputEncoding(); standalone = (Boolean)parser.getProperty ("http://xmlpull.org/v1/doc/properties.html#xmldecl-standalone"); super.parse(parser); if (parser.getEventType() != XmlPullParser.END_DOCUMENT) throw new RuntimeException("Document end expected!"); } public void removeChild(int index) { if (index == rootIndex) rootIndex = -1; else if (index < rootIndex) rootIndex--; super.removeChild(index); } /** returns the root element of this document. */ public Element getRootElement() { if (rootIndex == -1) throw new RuntimeException("Document has no root element!"); return (Element) getChild(rootIndex); } /** Writes this node to the given XmlWriter. For node and document, this method is identical to writeChildren, except that the stream is flushed automatically. */ public void write(XmlSerializer writer) throws IOException { writer.startDocument(encoding, standalone); writeChildren(writer); writer.endDocument(); } }kxml2-2.3.0/src/org/kxml2/kdom/Node.java0000644000175000017500000002673010043207504015775 0ustar neoneo/* Copyright (c) 2002,2003, Stefan Haustein, Oberhausen, Rhld., Germany * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or * sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS * IN THE SOFTWARE. */ package org.kxml2.kdom; import java.util.*; import java.io.*; import org.xmlpull.v1.*; /** A common base class for Document and Element, also used for storing XML fragments. */ public class Node { //implements XmlIO{ public static final int DOCUMENT = 0; public static final int ELEMENT = 2; public static final int TEXT = 4; public static final int CDSECT = 5; public static final int ENTITY_REF = 6; public static final int IGNORABLE_WHITESPACE = 7; public static final int PROCESSING_INSTRUCTION = 8; public static final int COMMENT = 9; public static final int DOCDECL = 10; protected Vector children; protected StringBuffer types; /** inserts the given child object of the given type at the given index. */ public void addChild(int index, int type, Object child) { if (child == null) throw new NullPointerException(); if (children == null) { children = new Vector(); types = new StringBuffer(); } if (type == ELEMENT) { if (!(child instanceof Element)) throw new RuntimeException("Element obj expected)"); ((Element) child).setParent(this); } else if (!(child instanceof String)) throw new RuntimeException("String expected"); children.insertElementAt(child, index); types.insert(index, (char) type); } /** convenience method for addChild (getChildCount (), child) */ public void addChild(int type, Object child) { addChild(getChildCount(), type, child); } /** Builds a default element with the given properties. Elements should always be created using this method instead of the constructor in order to enable construction of specialized subclasses by deriving custom Document classes. Please note: For no namespace, please use Xml.NO_NAMESPACE, null is not a legal value. Currently, null is converted to Xml.NO_NAMESPACE, but future versions may throw an exception. */ public Element createElement(String namespace, String name) { Element e = new Element(); e.namespace = namespace == null ? "" : namespace; e.name = name; return e; } /** Returns the child object at the given index. For child elements, an Element object is returned. For all other child types, a String is returned. */ public Object getChild(int index) { return children.elementAt(index); } /** Returns the number of child objects */ public int getChildCount() { return children == null ? 0 : children.size(); } /** returns the element at the given index. If the node at the given index is a text node, null is returned */ public Element getElement(int index) { Object child = getChild(index); return (child instanceof Element) ? (Element) child : null; } /** Returns the element with the given namespace and name. If the element is not found, or more than one matching elements are found, an exception is thrown. */ public Element getElement(String namespace, String name) { int i = indexOf(namespace, name, 0); int j = indexOf(namespace, name, i + 1); if (i == -1 || j != -1) throw new RuntimeException( "Element {" + namespace + "}" + name + (i == -1 ? " not found in " : " more than once in ") + this); return getElement(i); } /* returns "#document-fragment". For elements, the element name is returned public String getName() { return "#document-fragment"; } /** Returns the namespace of the current element. For Node and Document, Xml.NO_NAMESPACE is returned. public String getNamespace() { return ""; } public int getNamespaceCount () { return 0; } /** returns the text content if the element has text-only content. Throws an exception for mixed content public String getText() { StringBuffer buf = new StringBuffer(); int len = getChildCount(); for (int i = 0; i < len; i++) { if (isText(i)) buf.append(getText(i)); else if (getType(i) == ELEMENT) throw new RuntimeException("not text-only content!"); } return buf.toString(); } */ /** Returns the text node with the given index or null if the node with the given index is not a text node. */ public String getText(int index) { return (isText(index)) ? (String) getChild(index) : null; } /** Returns the type of the child at the given index. Possible types are ELEMENT, TEXT, COMMENT, and PROCESSING_INSTRUCTION */ public int getType(int index) { return types.charAt(index); } /** Convenience method for indexOf (getNamespace (), name, startIndex). public int indexOf(String name, int startIndex) { return indexOf(getNamespace(), name, startIndex); } */ /** Performs search for an element with the given namespace and name, starting at the given start index. A null namespace matches any namespace, please use Xml.NO_NAMESPACE for no namespace). returns -1 if no matching element was found. */ public int indexOf(String namespace, String name, int startIndex) { int len = getChildCount(); for (int i = startIndex; i < len; i++) { Element child = getElement(i); if (child != null && name.equals(child.getName()) && (namespace == null || namespace.equals(child.getNamespace()))) return i; } return -1; } public boolean isText(int i) { int t = getType(i); return t == TEXT || t == IGNORABLE_WHITESPACE || t == CDSECT; } /** Recursively builds the child elements from the given parser until an end tag or end document is found. The end tag is not consumed. */ public void parse(XmlPullParser parser) throws IOException, XmlPullParserException { boolean leave = false; do { int type = parser.getEventType(); // System.out.println(parser.getPositionDescription()); switch (type) { case XmlPullParser.START_TAG : { Element child = createElement( parser.getNamespace(), parser.getName()); // child.setAttributes (event.getAttributes ()); addChild(ELEMENT, child); // order is important here since // setparent may perform some init code! child.parse(parser); break; } case XmlPullParser.END_DOCUMENT : case XmlPullParser.END_TAG : leave = true; break; default : if (parser.getText() != null) addChild( type == XmlPullParser.ENTITY_REF ? TEXT : type, parser.getText()); else if ( type == XmlPullParser.ENTITY_REF && parser.getName() != null) { addChild(ENTITY_REF, parser.getName()); } parser.nextToken(); } } while (!leave); } /** Removes the child object at the given index */ public void removeChild(int idx) { children.removeElementAt(idx); /*** Modification by HHS - start ***/ // types.deleteCharAt (index); /***/ int n = types.length() - 1; for (int i = idx; i < n; i++) types.setCharAt(i, types.charAt(i + 1)); types.setLength(n); /*** Modification by HHS - end ***/ } /* returns a valid XML representation of this Element including attributes and children. public String toString() { try { ByteArrayOutputStream bos = new ByteArrayOutputStream(); XmlWriter xw = new XmlWriter(new OutputStreamWriter(bos)); write(xw); xw.close(); return new String(bos.toByteArray()); } catch (IOException e) { throw new RuntimeException(e.toString()); } } */ /** Writes this node to the given XmlWriter. For node and document, this method is identical to writeChildren, except that the stream is flushed automatically. */ public void write(XmlSerializer writer) throws IOException { writeChildren(writer); writer.flush(); } /** Writes the children of this node to the given XmlWriter. */ public void writeChildren(XmlSerializer writer) throws IOException { if (children == null) return; int len = children.size(); for (int i = 0; i < len; i++) { int type = getType(i); Object child = children.elementAt(i); switch (type) { case ELEMENT : ((Element) child).write(writer); break; case TEXT : writer.text((String) child); break; case IGNORABLE_WHITESPACE : writer.ignorableWhitespace((String) child); break; case CDSECT : writer.cdsect((String) child); break; case COMMENT : writer.comment((String) child); break; case ENTITY_REF : writer.entityRef((String) child); break; case PROCESSING_INSTRUCTION : writer.processingInstruction((String) child); break; case DOCDECL : writer.docdecl((String) child); break; default : throw new RuntimeException("Illegal type: " + type); } } } } kxml2-2.3.0/src/org/kxml2/kdom/Element.java0000644000175000017500000002130510051643372016500 0ustar neoneo/* Copyright (c) 2002,2003, Stefan Haustein, Oberhausen, Rhld., Germany * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or * sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS * IN THE SOFTWARE. */ package org.kxml2.kdom; import java.io.*; import java.util.*; import org.xmlpull.v1.*; /** * In order to create an element, please use the createElement method * instead of invoking the constructor directly. The right place to * add user defined initialization code is the init method. */ public class Element extends Node { protected String namespace; protected String name; protected Vector attributes; protected Node parent; protected Vector prefixes; public Element() { } /** * called when all properties are set, but before children * are parsed. Please do not use setParent for initialization * code any longer. */ public void init() { } /** * removes all children and attributes */ public void clear() { attributes = null; children = null; } /** * Forwards creation request to parent if any, otherwise * calls super.createElement. */ public Element createElement( String namespace, String name) { return (this.parent == null) ? super.createElement(namespace, name) : this.parent.createElement(namespace, name); } /** * Returns the number of attributes of this element. */ public int getAttributeCount() { return attributes == null ? 0 : attributes.size (); } public String getAttributeNamespace (int index) { return ((String []) attributes.elementAt (index)) [0]; } /* public String getAttributePrefix (int index) { return ((String []) attributes.elementAt (index)) [1]; }*/ public String getAttributeName (int index) { return ((String []) attributes.elementAt (index)) [1]; } public String getAttributeValue (int index) { return ((String []) attributes.elementAt (index)) [2]; } public String getAttributeValue (String namespace, String name) { for (int i = 0; i < getAttributeCount (); i++) { if (name.equals (getAttributeName (i)) && (namespace == null || namespace.equals (getAttributeNamespace(i)))) { return getAttributeValue (i); } } return null; } /** * Returns the root node, determined by ascending to the * all parents un of the root element. */ public Node getRoot() { Element current = this; while (current.parent != null) { if (!(current.parent instanceof Element)) return current.parent; current = (Element) current.parent; } return current; } /** * returns the (local) name of the element */ public String getName() { return name; } /** * returns the namespace of the element */ public String getNamespace() { return namespace; } /** * returns the namespace for the given prefix */ public String getNamespaceUri (String prefix) { int cnt = getNamespaceCount (); for (int i = 0; i < cnt; i++) { if (prefix == getNamespacePrefix (i) || (prefix != null && prefix.equals (getNamespacePrefix (i)))) return getNamespaceUri (i); } return parent instanceof Element ? ((Element) parent).getNamespaceUri (prefix) : null; } /** * returns the number of declared namespaces, NOT including * parent elements */ public int getNamespaceCount () { return (prefixes == null ? 0 : prefixes.size ()); } public String getNamespacePrefix (int i) { return ((String []) prefixes.elementAt (i)) [0]; } public String getNamespaceUri (int i) { return ((String []) prefixes.elementAt (i)) [1]; } /** * Returns the parent node of this element */ public Node getParent() { return parent; } /* * Returns the parent element if available, null otherwise public Element getParentElement() { return (parent instanceof Element) ? ((Element) parent) : null; } */ /** * Builds the child elements from the given Parser. By overwriting * parse, an element can take complete control over parsing its * subtree. */ public void parse(XmlPullParser parser) throws IOException, XmlPullParserException { for (int i = parser.getNamespaceCount (parser.getDepth () - 1); i < parser.getNamespaceCount (parser.getDepth ()); i++) { setPrefix (parser.getNamespacePrefix (i), parser.getNamespaceUri(i)); } for (int i = 0; i < parser.getAttributeCount (); i++) setAttribute (parser.getAttributeNamespace (i), // parser.getAttributePrefix (i), parser.getAttributeName (i), parser.getAttributeValue (i)); // if (prefixMap == null) throw new RuntimeException ("!!"); init(); if (parser.isEmptyElementTag()) parser.nextToken (); else { parser.nextToken (); super.parse(parser); if (getChildCount() == 0) addChild(IGNORABLE_WHITESPACE, ""); } parser.require( XmlPullParser.END_TAG, getNamespace(), getName()); parser.nextToken (); } /** * Sets the given attribute; a value of null removes the attribute */ public void setAttribute (String namespace, String name, String value) { if (attributes == null) attributes = new Vector (); if (namespace == null) namespace = ""; for (int i = attributes.size()-1; i >=0; i--){ String[] attribut = (String[]) attributes.elementAt(i); if (attribut[0].equals(namespace) && attribut[1].equals(name)){ if (value == null) { attributes.removeElementAt(i); } else { attribut[2] = value; } return; } } attributes.addElement (new String [] {namespace, name, value}); } /** * Sets the given prefix; a namespace value of null removess the * prefix */ public void setPrefix (String prefix, String namespace) { if (prefixes == null) prefixes = new Vector (); prefixes.addElement (new String [] {prefix, namespace}); } /** * sets the name of the element */ public void setName(String name) { this.name = name; } /** * sets the namespace of the element. Please note: For no * namespace, please use Xml.NO_NAMESPACE, null is not a legal * value. Currently, null is converted to Xml.NO_NAMESPACE, but * future versions may throw an exception. */ public void setNamespace(String namespace) { if (namespace == null) throw new NullPointerException ("Use \"\" for empty namespace"); this.namespace = namespace; } /** * Sets the Parent of this element. Automatically called from the * add method. Please use with care, you can simply * create inconsitencies in the document tree structure using * this method! */ protected void setParent(Node parent) { this.parent = parent; } /** * Writes this element and all children to the given XmlWriter. */ public void write(XmlSerializer writer) throws IOException { if (prefixes != null) { for (int i = 0; i < prefixes.size (); i++) { writer.setPrefix (getNamespacePrefix (i), getNamespaceUri (i)); } } writer.startTag( getNamespace(), getName()); int len = getAttributeCount(); for (int i = 0; i < len; i++) { writer.attribute( getAttributeNamespace(i), getAttributeName(i), getAttributeValue(i)); } writeChildren(writer); writer.endTag(getNamespace (), getName ()); } } kxml2-2.3.0/src/org/kxml2/io/0000755000175000017500000000000010435016414013715 5ustar neoneokxml2-2.3.0/src/org/kxml2/io/KXmlSerializer.java0000644000175000017500000003633710045716430017503 0ustar neoneo/* Copyright (c) 2002,2003, Stefan Haustein, Oberhausen, Rhld., Germany * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or * sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS * IN THE SOFTWARE. */ package org.kxml2.io; import java.io.*; import org.xmlpull.v1.*; public class KXmlSerializer implements XmlSerializer { // static final String UNDEFINED = ":"; private Writer writer; private boolean pending; private int auto; private int depth; private String[] elementStack = new String[12]; //nsp/prefix/name private int[] nspCounts = new int[4]; private String[] nspStack = new String[8]; //prefix/nsp; both empty are "" private boolean[] indent = new boolean[4]; private boolean unicode; private String encoding; private final void check(boolean close) throws IOException { if (!pending) return; depth++; pending = false; if (indent.length <= depth) { boolean[] hlp = new boolean[depth + 4]; System.arraycopy(indent, 0, hlp, 0, depth); indent = hlp; } indent[depth] = indent[depth - 1]; for (int i = nspCounts[depth - 1]; i < nspCounts[depth]; i++) { writer.write(' '); writer.write("xmlns"); if (!"".equals(nspStack[i * 2])) { writer.write(':'); writer.write(nspStack[i * 2]); } else if ("".equals(getNamespace()) && !"".equals(nspStack[i * 2 + 1])) throw new IllegalStateException("Cannot set default namespace for elements in no namespace"); writer.write("=\""); writeEscaped(nspStack[i * 2 + 1], '"'); writer.write('"'); } if (nspCounts.length <= depth + 1) { int[] hlp = new int[depth + 8]; System.arraycopy(nspCounts, 0, hlp, 0, depth + 1); nspCounts = hlp; } nspCounts[depth + 1] = nspCounts[depth]; // nspCounts[depth + 2] = nspCounts[depth]; writer.write(close ? " />" : ">"); } private final void writeEscaped(String s, int quot) throws IOException { for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); switch (c) { case '\n': case '\r': case '\t': if(quot == -1) writer.write(c); else writer.write("&#"+((int) c)+';'); break; case '&' : writer.write("&"); break; case '>' : writer.write(">"); break; case '<' : writer.write("<"); break; case '"' : case '\'' : if (c == quot) { writer.write( c == '"' ? """ : "'"); break; } default : //if(c < ' ') // throw new IllegalArgumentException("Illegal control code:"+((int) c)); if (c >= ' ' && c !='@' && (c < 127 || unicode)) writer.write(c); else writer.write("&#" + ((int) c) + ";"); } } } /* private final void writeIndent() throws IOException { writer.write("\r\n"); for (int i = 0; i < depth; i++) writer.write(' '); }*/ public void docdecl(String dd) throws IOException { writer.write(""); } public void endDocument() throws IOException { while (depth > 0) { endTag( elementStack[depth * 3 - 3], elementStack[depth * 3 - 1]); } flush(); } public void entityRef(String name) throws IOException { check(false); writer.write('&'); writer.write(name); writer.write(';'); } public boolean getFeature(String name) { //return false; return ( "http://xmlpull.org/v1/doc/features.html#indent-output" .equals( name)) ? indent[depth] : false; } public String getPrefix(String namespace, boolean create) { try { return getPrefix(namespace, false, create); } catch (IOException e) { throw new RuntimeException(e.toString()); } } private final String getPrefix( String namespace, boolean includeDefault, boolean create) throws IOException { for (int i = nspCounts[depth + 1] * 2 - 2; i >= 0; i -= 2) { if (nspStack[i + 1].equals(namespace) && (includeDefault || !nspStack[i].equals(""))) { String cand = nspStack[i]; for (int j = i + 2; j < nspCounts[depth + 1] * 2; j++) { if (nspStack[j].equals(cand)) { cand = null; break; } } if (cand != null) return cand; } } if (!create) return null; String prefix; if ("".equals(namespace)) prefix = ""; else { do { prefix = "n" + (auto++); for (int i = nspCounts[depth + 1] * 2 - 2; i >= 0; i -= 2) { if (prefix.equals(nspStack[i])) { prefix = null; break; } } } while (prefix == null); } boolean p = pending; pending = false; setPrefix(prefix, namespace); pending = p; return prefix; } public Object getProperty(String name) { throw new RuntimeException("Unsupported property"); } public void ignorableWhitespace(String s) throws IOException { text(s); } public void setFeature(String name, boolean value) { if ("http://xmlpull.org/v1/doc/features.html#indent-output" .equals(name)) { indent[depth] = value; } else throw new RuntimeException("Unsupported Feature"); } public void setProperty(String name, Object value) { throw new RuntimeException( "Unsupported Property:" + value); } public void setPrefix(String prefix, String namespace) throws IOException { check(false); if (prefix == null) prefix = ""; if (namespace == null) namespace = ""; String defined = getPrefix(namespace, true, false); // boil out if already defined if (prefix.equals(defined)) return; int pos = (nspCounts[depth + 1]++) << 1; if (nspStack.length < pos + 1) { String[] hlp = new String[nspStack.length + 16]; System.arraycopy(nspStack, 0, hlp, 0, pos); nspStack = hlp; } nspStack[pos++] = prefix; nspStack[pos] = namespace; } public void setOutput(Writer writer) { this.writer = writer; // elementStack = new String[12]; //nsp/prefix/name //nspCounts = new int[4]; //nspStack = new String[8]; //prefix/nsp //indent = new boolean[4]; nspCounts[0] = 2; nspCounts[1] = 2; nspStack[0] = ""; nspStack[1] = ""; nspStack[2] = "xml"; nspStack[3] = "http://www.w3.org/XML/1998/namespace"; pending = false; auto = 0; depth = 0; unicode = false; } public void setOutput(OutputStream os, String encoding) throws IOException { if (os == null) throw new IllegalArgumentException(); setOutput( encoding == null ? new OutputStreamWriter(os) : new OutputStreamWriter(os, encoding)); this.encoding = encoding; if (encoding != null && encoding.toLowerCase().startsWith("utf")) unicode = true; } public void startDocument( String encoding, Boolean standalone) throws IOException { writer.write(""); } public XmlSerializer startTag(String namespace, String name) throws IOException { check(false); // if (namespace == null) // namespace = ""; if (indent[depth]) { writer.write("\r\n"); for (int i = 0; i < depth; i++) writer.write(" "); } int esp = depth * 3; if (elementStack.length < esp + 3) { String[] hlp = new String[elementStack.length + 12]; System.arraycopy(elementStack, 0, hlp, 0, esp); elementStack = hlp; } String prefix = namespace == null ? "" : getPrefix(namespace, true, true); if ("".equals(namespace)) { for (int i = nspCounts[depth]; i < nspCounts[depth + 1]; i++) { if ("".equals(nspStack[i * 2]) && !"".equals(nspStack[i * 2 + 1])) { throw new IllegalStateException("Cannot set default namespace for elements in no namespace"); } } } elementStack[esp++] = namespace; elementStack[esp++] = prefix; elementStack[esp] = name; writer.write('<'); if (!"".equals(prefix)) { writer.write(prefix); writer.write(':'); } writer.write(name); pending = true; return this; } public XmlSerializer attribute( String namespace, String name, String value) throws IOException { if (!pending) throw new IllegalStateException("illegal position for attribute"); // int cnt = nspCounts[depth]; if (namespace == null) namespace = ""; // depth--; // pending = false; String prefix = "".equals(namespace) ? "" : getPrefix(namespace, false, true); // pending = true; // depth++; /* if (cnt != nspCounts[depth]) { writer.write(' '); writer.write("xmlns"); if (nspStack[cnt * 2] != null) { writer.write(':'); writer.write(nspStack[cnt * 2]); } writer.write("=\""); writeEscaped(nspStack[cnt * 2 + 1], '"'); writer.write('"'); } */ writer.write(' '); if (!"".equals(prefix)) { writer.write(prefix); writer.write(':'); } writer.write(name); writer.write('='); char q = value.indexOf('"') == -1 ? '"' : '\''; writer.write(q); writeEscaped(value, q); writer.write(q); return this; } public void flush() throws IOException { check(false); writer.flush(); } /* public void close() throws IOException { check(); writer.close(); } */ public XmlSerializer endTag(String namespace, String name) throws IOException { if (!pending) depth--; // if (namespace == null) // namespace = ""; if ((namespace == null && elementStack[depth * 3] != null) || (namespace != null && !namespace.equals(elementStack[depth * 3])) || !elementStack[depth * 3 + 2].equals(name)) throw new IllegalArgumentException(" does not match start"); if (pending) { check(true); depth--; } else { if (indent[depth + 1]) { writer.write("\r\n"); for (int i = 0; i < depth; i++) writer.write(" "); } writer.write("'); } nspCounts[depth + 1] = nspCounts[depth]; return this; } public String getNamespace() { return getDepth() == 0 ? null : elementStack[getDepth() * 3 - 3]; } public String getName() { return getDepth() == 0 ? null : elementStack[getDepth() * 3 - 1]; } public int getDepth() { return pending ? depth + 1 : depth; } public XmlSerializer text(String text) throws IOException { check(false); indent[depth] = false; writeEscaped(text, -1); return this; } public XmlSerializer text(char[] text, int start, int len) throws IOException { text(new String(text, start, len)); return this; } public void cdsect(String data) throws IOException { check(false); writer.write(""); } public void comment(String comment) throws IOException { check(false); writer.write(""); } public void processingInstruction(String pi) throws IOException { check(false); writer.write(""); } } kxml2-2.3.0/src/org/kxml2/io/KXmlParser.java0000644000175000017500000011633110340202214016603 0ustar neoneo/* Copyright (c) 2002,2003, Stefan Haustein, Oberhausen, Rhld., Germany * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or * sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS * IN THE SOFTWARE. */ // Contributors: Paul Hackenberger (unterminated entity handling in relaxed mode) package org.kxml2.io; import java.io.*; import java.util.*; import org.xmlpull.v1.*; /** A simple, pull based XML parser. This classe replaces the kXML 1 XmlParser class and the corresponding event classes. */ public class KXmlParser implements XmlPullParser { private Object location; static final private String UNEXPECTED_EOF = "Unexpected EOF"; static final private String ILLEGAL_TYPE = "Wrong event type"; static final private int LEGACY = 999; static final private int XML_DECL = 998; // general private String version; private Boolean standalone; private boolean processNsp; private boolean relaxed; private Hashtable entityMap; private int depth; private String[] elementStack = new String[16]; private String[] nspStack = new String[8]; private int[] nspCounts = new int[4]; // source private Reader reader; private String encoding; private char[] srcBuf; private int srcPos; private int srcCount; private int line; private int column; // txtbuffer private char[] txtBuf = new char[128]; private int txtPos; // Event-related private int type; //private String text; private boolean isWhitespace; private String namespace; private String prefix; private String name; private boolean degenerated; private int attributeCount; private String[] attributes = new String[16]; private int stackMismatch = 0; private String error; /** * A separate peek buffer seems simpler than managing * wrap around in the first level read buffer */ private int[] peek = new int[2]; private int peekCount; private boolean wasCR; private boolean unresolved; private boolean token; public KXmlParser() { srcBuf = new char[Runtime.getRuntime().freeMemory() >= 1048576 ? 8192 : 128]; } private final boolean isProp(String n1, boolean prop, String n2) { if (!n1.startsWith("http://xmlpull.org/v1/doc/")) return false; if (prop) return n1.substring(42).equals(n2); else return n1.substring(40).equals(n2); } private final boolean adjustNsp() throws XmlPullParserException { boolean any = false; for (int i = 0; i < attributeCount << 2; i += 4) { // * 4 - 4; i >= 0; i -= 4) { String attrName = attributes[i + 2]; int cut = attrName.indexOf(':'); String prefix; if (cut != -1) { prefix = attrName.substring(0, cut); attrName = attrName.substring(cut + 1); } else if (attrName.equals("xmlns")) { prefix = attrName; attrName = null; } else continue; if (!prefix.equals("xmlns")) { any = true; } else { int j = (nspCounts[depth]++) << 1; nspStack = ensureCapacity(nspStack, j + 2); nspStack[j] = attrName; nspStack[j + 1] = attributes[i + 3]; if (attrName != null && attributes[i + 3].equals("")) error("illegal empty namespace"); // prefixMap = new PrefixMap (prefixMap, attrName, attr.getValue ()); //System.out.println (prefixMap); System.arraycopy( attributes, i + 4, attributes, i, ((--attributeCount) << 2) - i); i -= 4; } } if (any) { for (int i = (attributeCount << 2) - 4; i >= 0; i -= 4) { String attrName = attributes[i + 2]; int cut = attrName.indexOf(':'); if (cut == 0 && !relaxed) throw new RuntimeException( "illegal attribute name: " + attrName + " at " + this); else if (cut != -1) { String attrPrefix = attrName.substring(0, cut); attrName = attrName.substring(cut + 1); String attrNs = getNamespace(attrPrefix); if (attrNs == null && !relaxed) throw new RuntimeException( "Undefined Prefix: " + attrPrefix + " in " + this); attributes[i] = attrNs; attributes[i + 1] = attrPrefix; attributes[i + 2] = attrName; /* if (!relaxed) { for (int j = (attributeCount << 2) - 4; j > i; j -= 4) if (attrName.equals(attributes[j + 2]) && attrNs.equals(attributes[j])) exception( "Duplicate Attribute: {" + attrNs + "}" + attrName); } */ } } } int cut = name.indexOf(':'); if (cut == 0) error("illegal tag name: " + name); if (cut != -1) { prefix = name.substring(0, cut); name = name.substring(cut + 1); } this.namespace = getNamespace(prefix); if (this.namespace == null) { if (prefix != null) error("undefined prefix: " + prefix); this.namespace = NO_NAMESPACE; } return any; } private final String[] ensureCapacity(String[] arr, int required) { if (arr.length >= required) return arr; String[] bigger = new String[required + 16]; System.arraycopy(arr, 0, bigger, 0, arr.length); return bigger; } private final void error(String desc) throws XmlPullParserException { if (relaxed) { if (error == null) error = "ERR: " + desc; } else exception(desc); } private final void exception(String desc) throws XmlPullParserException { throw new XmlPullParserException( desc.length() < 100 ? desc : desc.substring(0, 100) + "\n", this, null); } /** * common base for next and nextToken. Clears the state, except from * txtPos and whitespace. Does not set the type variable */ private final void nextImpl() throws IOException, XmlPullParserException { if (reader == null) exception("No Input specified"); if (type == END_TAG) depth--; while (true) { attributeCount = -1; // degenerated needs to be handled before error because of possible // processor expectations(!) if (degenerated) { degenerated = false; type = END_TAG; return; } if (error != null) { for (int i = 0; i < error.length(); i++) push(error.charAt(i)); // text = error; error = null; type = COMMENT; return; } if (relaxed && (stackMismatch > 0 || (peek(0) == -1 && depth > 0))) { int sp = (depth - 1) << 2; type = END_TAG; namespace = elementStack[sp]; prefix = elementStack[sp + 1]; name = elementStack[sp + 2]; if (stackMismatch != 1) error = "missing end tag /" + name + " inserted"; if (stackMismatch > 0) stackMismatch--; return; } prefix = null; name = null; namespace = null; // text = null; type = peekType(); switch (type) { case ENTITY_REF : pushEntity(); return; case START_TAG : parseStartTag(false); return; case END_TAG : parseEndTag(); return; case END_DOCUMENT : return; case TEXT : pushText('<', !token); if (depth == 0) { if (isWhitespace) type = IGNORABLE_WHITESPACE; // make exception switchable for instances.chg... !!!! // else // exception ("text '"+getText ()+"' not allowed outside root element"); } return; default : type = parseLegacy(token); if (type != XML_DECL) return; } } } private final int parseLegacy(boolean push) throws IOException, XmlPullParserException { String req = ""; int term; int result; int prev = 0; read(); // < int c = read(); if (c == '?') { if ((peek(0) == 'x' || peek(0) == 'X') && (peek(1) == 'm' || peek(1) == 'M')) { if (push) { push(peek(0)); push(peek(1)); } read(); read(); if ((peek(0) == 'l' || peek(0) == 'L') && peek(1) <= ' ') { if (line != 1 || column > 4) error("PI must not start with xml"); parseStartTag(true); if (attributeCount < 1 || !"version".equals(attributes[2])) error("version expected"); version = attributes[3]; int pos = 1; if (pos < attributeCount && "encoding".equals(attributes[2 + 4])) { encoding = attributes[3 + 4]; pos++; } if (pos < attributeCount && "standalone".equals(attributes[4 * pos + 2])) { String st = attributes[3 + 4 * pos]; if ("yes".equals(st)) standalone = new Boolean(true); else if ("no".equals(st)) standalone = new Boolean(false); else error("illegal standalone value: " + st); pos++; } if (pos != attributeCount) error("illegal xmldecl"); isWhitespace = true; txtPos = 0; return XML_DECL; } } /* int c0 = read (); int c1 = read (); int */ term = '?'; result = PROCESSING_INSTRUCTION; } else if (c == '!') { if (peek(0) == '-') { result = COMMENT; req = "--"; term = '-'; } else if (peek(0) == '[') { result = CDSECT; req = "[CDATA["; term = ']'; push = true; } else { result = DOCDECL; req = "DOCTYPE"; term = -1; } } else { error("illegal: <" + c); return COMMENT; } for (int i = 0; i < req.length(); i++) read(req.charAt(i)); if (result == DOCDECL) parseDoctype(push); else { while (true) { c = read(); if (c == -1){ error(UNEXPECTED_EOF); return COMMENT; } if (push) push(c); if ((term == '?' || c == term) && peek(0) == term && peek(1) == '>') break; prev = c; } if (term == '-' && prev == '-') error("illegal comment delimiter: --->"); read(); read(); if (push && term != '?') txtPos--; } return result; } /** precondition: <! consumed */ private final void parseDoctype(boolean push) throws IOException, XmlPullParserException { int nesting = 1; boolean quoted = false; // read(); while (true) { int i = read(); switch (i) { case -1 : error(UNEXPECTED_EOF); return; case '\'' : quoted = !quoted; break; case '<' : if (!quoted) nesting++; break; case '>' : if (!quoted) { if ((--nesting) == 0) return; } break; } if (push) push(i); } } /* precondition: </ consumed */ private final void parseEndTag() throws IOException, XmlPullParserException { read(); // '<' read(); // '/' name = readName(); skip(); read('>'); int sp = (depth - 1) << 2; if (depth == 0) { error("element stack empty"); type = COMMENT; return; } if (!name.equals(elementStack[sp + 3])) { error("expected: /" + elementStack[sp + 3] + " read: " + name); // become case insensitive in relaxed mode int probe = sp; while (probe >= 0 && !name.toLowerCase().equals(elementStack[probe + 3].toLowerCase())) { stackMismatch++; probe -= 4; } if (probe < 0) { stackMismatch = 0; // text = "unexpected end tag ignored"; type = COMMENT; return; } } namespace = elementStack[sp]; prefix = elementStack[sp + 1]; name = elementStack[sp + 2]; } private final int peekType() throws IOException { switch (peek(0)) { case -1 : return END_DOCUMENT; case '&' : return ENTITY_REF; case '<' : switch (peek(1)) { case '/' : return END_TAG; case '?' : case '!' : return LEGACY; default : return START_TAG; } default : return TEXT; } } private final String get(int pos) { return new String(txtBuf, pos, txtPos - pos); } /* private final String pop (int pos) { String result = new String (txtBuf, pos, txtPos - pos); txtPos = pos; return result; } */ private final void push(int c) { isWhitespace &= c <= ' '; if (txtPos == txtBuf.length) { char[] bigger = new char[txtPos * 4 / 3 + 4]; System.arraycopy(txtBuf, 0, bigger, 0, txtPos); txtBuf = bigger; } txtBuf[txtPos++] = (char) c; } /** Sets name and attributes */ private final void parseStartTag(boolean xmldecl) throws IOException, XmlPullParserException { if (!xmldecl) read(); name = readName(); attributeCount = 0; while (true) { skip(); int c = peek(0); if (xmldecl) { if (c == '?') { read(); read('>'); return; } } else { if (c == '/') { degenerated = true; read(); skip(); read('>'); break; } if (c == '>' && !xmldecl) { read(); break; } } if (c == -1) { error(UNEXPECTED_EOF); //type = COMMENT; return; } String attrName = readName(); if (attrName.length() == 0) { error("attr name expected"); //type = COMMENT; break; } int i = (attributeCount++) << 2; attributes = ensureCapacity(attributes, i + 4); attributes[i++] = ""; attributes[i++] = null; attributes[i++] = attrName; skip(); if (peek(0) != '=') { error("Attr.value missing f. "+attrName); attributes[i] = "1"; } else { read('='); skip(); int delimiter = peek(0); if (delimiter != '\'' && delimiter != '"') { error("attr value delimiter missing!"); delimiter = ' '; } else read(); int p = txtPos; pushText(delimiter, true); attributes[i] = get(p); txtPos = p; if (delimiter != ' ') read(); // skip endquote } } int sp = depth++ << 2; elementStack = ensureCapacity(elementStack, sp + 4); elementStack[sp + 3] = name; if (depth >= nspCounts.length) { int[] bigger = new int[depth + 4]; System.arraycopy(nspCounts, 0, bigger, 0, nspCounts.length); nspCounts = bigger; } nspCounts[depth] = nspCounts[depth - 1]; /* if(!relaxed){ for (int i = attributeCount - 1; i > 0; i--) { for (int j = 0; j < i; j++) { if (getAttributeName(i).equals(getAttributeName(j))) exception("Duplicate Attribute: " + getAttributeName(i)); } } } */ if (processNsp) adjustNsp(); else namespace = ""; elementStack[sp] = namespace; elementStack[sp + 1] = prefix; elementStack[sp + 2] = name; } /** * result: isWhitespace; if the setName parameter is set, * the name of the entity is stored in "name" */ private final void pushEntity() throws IOException, XmlPullParserException { push(read()); // & int pos = txtPos; while (true) { int c = read(); if (c == ';') break; if (c < 128 && (c < '0' || c > '9') && (c < 'a' || c > 'z') && (c < 'A' || c > 'Z') && c != '_' && c != '-' && c != '#') { if(!relaxed){ error("unterminated entity ref"); } //; ends with:"+(char)c); if (c != -1) push(c); return; } push(c); } String code = get(pos); txtPos = pos - 1; if (token && type == ENTITY_REF){ name = code; } if (code.charAt(0) == '#') { int c = (code.charAt(1) == 'x' ? Integer.parseInt(code.substring(2), 16) : Integer.parseInt(code.substring(1))); push(c); return; } String result = (String) entityMap.get(code); unresolved = result == null; if (unresolved) { if (!token) error("unresolved: &" + code + ";"); } else { for (int i = 0; i < result.length(); i++) push(result.charAt(i)); } } /** types: '<': parse to any token (for nextToken ()) '"': parse to quote ' ': parse to whitespace or '>' */ private final void pushText(int delimiter, boolean resolveEntities) throws IOException, XmlPullParserException { int next = peek(0); int cbrCount = 0; while (next != -1 && next != delimiter) { // covers eof, '<', '"' if (delimiter == ' ') if (next <= ' ' || next == '>') break; if (next == '&') { if (!resolveEntities) break; pushEntity(); } else if (next == '\n' && type == START_TAG) { read(); push(' '); } else push(read()); if (next == '>' && cbrCount >= 2 && delimiter != ']') error("Illegal: ]]>"); if (next == ']') cbrCount++; else cbrCount = 0; next = peek(0); } } private final void read(char c) throws IOException, XmlPullParserException { int a = read(); if (a != c) error("expected: '" + c + "' actual: '" + ((char) a) + "'"); } private final int read() throws IOException { int result; if (peekCount == 0) result = peek(0); else { result = peek[0]; peek[0] = peek[1]; } // else { // result = peek[0]; // System.arraycopy (peek, 1, peek, 0, peekCount-1); // } peekCount--; column++; if (result == '\n') { line++; column = 1; } return result; } /** Does never read more than needed */ private final int peek(int pos) throws IOException { while (pos >= peekCount) { int nw; if (srcBuf.length <= 1) nw = reader.read(); else if (srcPos < srcCount) nw = srcBuf[srcPos++]; else { srcCount = reader.read(srcBuf, 0, srcBuf.length); if (srcCount <= 0) nw = -1; else nw = srcBuf[0]; srcPos = 1; } if (nw == '\r') { wasCR = true; peek[peekCount++] = '\n'; } else { if (nw == '\n') { if (!wasCR) peek[peekCount++] = '\n'; } else peek[peekCount++] = nw; wasCR = false; } } return peek[pos]; } private final String readName() throws IOException, XmlPullParserException { int pos = txtPos; int c = peek(0); if ((c < 'a' || c > 'z') && (c < 'A' || c > 'Z') && c != '_' && c != ':' && c < 0x0c0 && !relaxed) error("name expected"); do { push(read()); c = peek(0); } while ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '_' || c == '-' || c == ':' || c == '.' || c >= 0x0b7); String result = get(pos); txtPos = pos; return result; } private final void skip() throws IOException { while (true) { int c = peek(0); if (c > ' ' || c == -1) break; read(); } } // public part starts here... public void setInput(Reader reader) throws XmlPullParserException { this.reader = reader; line = 1; column = 0; type = START_DOCUMENT; name = null; namespace = null; degenerated = false; attributeCount = -1; encoding = null; version = null; standalone = null; if (reader == null) return; srcPos = 0; srcCount = 0; peekCount = 0; depth = 0; entityMap = new Hashtable(); entityMap.put("amp", "&"); entityMap.put("apos", "'"); entityMap.put("gt", ">"); entityMap.put("lt", "<"); entityMap.put("quot", "\""); } public void setInput(InputStream is, String _enc) throws XmlPullParserException { srcPos = 0; srcCount = 0; String enc = _enc; if (is == null) throw new IllegalArgumentException(); try { if (enc == null) { // read four bytes int chk = 0; while (srcCount < 4) { int i = is.read(); if (i == -1) break; chk = (chk << 8) | i; srcBuf[srcCount++] = (char) i; } if (srcCount == 4) { switch (chk) { case 0x00000FEFF : enc = "UTF-32BE"; srcCount = 0; break; case 0x0FFFE0000 : enc = "UTF-32LE"; srcCount = 0; break; case 0x03c : enc = "UTF-32BE"; srcBuf[0] = '<'; srcCount = 1; break; case 0x03c000000 : enc = "UTF-32LE"; srcBuf[0] = '<'; srcCount = 1; break; case 0x0003c003f : enc = "UTF-16BE"; srcBuf[0] = '<'; srcBuf[1] = '?'; srcCount = 2; break; case 0x03c003f00 : enc = "UTF-16LE"; srcBuf[0] = '<'; srcBuf[1] = '?'; srcCount = 2; break; case 0x03c3f786d : while (true) { int i = is.read(); if (i == -1) break; srcBuf[srcCount++] = (char) i; if (i == '>') { String s = new String(srcBuf, 0, srcCount); int i0 = s.indexOf("encoding"); if (i0 != -1) { while (s.charAt(i0) != '"' && s.charAt(i0) != '\'') i0++; char deli = s.charAt(i0++); int i1 = s.indexOf(deli, i0); enc = s.substring(i0, i1); } break; } } default : if ((chk & 0x0ffff0000) == 0x0FEFF0000) { enc = "UTF-16BE"; srcBuf[0] = (char) ((srcBuf[2] << 8) | srcBuf[3]); srcCount = 1; } else if ((chk & 0x0ffff0000) == 0x0fffe0000) { enc = "UTF-16LE"; srcBuf[0] = (char) ((srcBuf[3] << 8) | srcBuf[2]); srcCount = 1; } else if ((chk & 0x0ffffff00) == 0x0EFBBBF00) { enc = "UTF-8"; srcBuf[0] = srcBuf[3]; srcCount = 1; } } } } if (enc == null) enc = "UTF-8"; int sc = srcCount; setInput(new InputStreamReader(is, enc)); encoding = _enc; srcCount = sc; } catch (Exception e) { throw new XmlPullParserException( "Invalid stream or encoding: " + e.toString(), this, e); } } public boolean getFeature(String feature) { if (XmlPullParser.FEATURE_PROCESS_NAMESPACES.equals(feature)) return processNsp; else if (isProp(feature, false, "relaxed")) return relaxed; else return false; } public String getInputEncoding() { return encoding; } public void defineEntityReplacementText(String entity, String value) throws XmlPullParserException { if (entityMap == null) throw new RuntimeException("entity replacement text must be defined after setInput!"); entityMap.put(entity, value); } public Object getProperty(String property) { if (isProp(property, true, "xmldecl-version")) return version; if (isProp(property, true, "xmldecl-standalone")) return standalone; if (isProp(property, true, "location")) return location != null ? location : reader.toString(); return null; } public int getNamespaceCount(int depth) { if (depth > this.depth) throw new IndexOutOfBoundsException(); return nspCounts[depth]; } public String getNamespacePrefix(int pos) { return nspStack[pos << 1]; } public String getNamespaceUri(int pos) { return nspStack[(pos << 1) + 1]; } public String getNamespace(String prefix) { if ("xml".equals(prefix)) return "http://www.w3.org/XML/1998/namespace"; if ("xmlns".equals(prefix)) return "http://www.w3.org/2000/xmlns/"; for (int i = (getNamespaceCount(depth) << 1) - 2; i >= 0; i -= 2) { if (prefix == null) { if (nspStack[i] == null) return nspStack[i + 1]; } else if (prefix.equals(nspStack[i])) return nspStack[i + 1]; } return null; } public int getDepth() { return depth; } public String getPositionDescription() { StringBuffer buf = new StringBuffer(type < TYPES.length ? TYPES[type] : "unknown"); buf.append(' '); if (type == START_TAG || type == END_TAG) { if (degenerated) buf.append("(empty) "); buf.append('<'); if (type == END_TAG) buf.append('/'); if (prefix != null) buf.append("{" + namespace + "}" + prefix + ":"); buf.append(name); int cnt = attributeCount << 2; for (int i = 0; i < cnt; i += 4) { buf.append(' '); if (attributes[i + 1] != null) buf.append( "{" + attributes[i] + "}" + attributes[i + 1] + ":"); buf.append(attributes[i + 2] + "='" + attributes[i + 3] + "'"); } buf.append('>'); } else if (type == IGNORABLE_WHITESPACE); else if (type != TEXT) buf.append(getText()); else if (isWhitespace) buf.append("(whitespace)"); else { String text = getText(); if (text.length() > 16) text = text.substring(0, 16) + "..."; buf.append(text); } buf.append("@"+line + ":" + column); if(location != null){ buf.append(" in "); buf.append(location); } else if(reader != null){ buf.append(" in "); buf.append(reader.toString()); } return buf.toString(); } public int getLineNumber() { return line; } public int getColumnNumber() { return column; } public boolean isWhitespace() throws XmlPullParserException { if (type != TEXT && type != IGNORABLE_WHITESPACE && type != CDSECT) exception(ILLEGAL_TYPE); return isWhitespace; } public String getText() { return type < TEXT || (type == ENTITY_REF && unresolved) ? null : get(0); } public char[] getTextCharacters(int[] poslen) { if (type >= TEXT) { if (type == ENTITY_REF) { poslen[0] = 0; poslen[1] = name.length(); return name.toCharArray(); } poslen[0] = 0; poslen[1] = txtPos; return txtBuf; } poslen[0] = -1; poslen[1] = -1; return null; } public String getNamespace() { return namespace; } public String getName() { return name; } public String getPrefix() { return prefix; } public boolean isEmptyElementTag() throws XmlPullParserException { if (type != START_TAG) exception(ILLEGAL_TYPE); return degenerated; } public int getAttributeCount() { return attributeCount; } public String getAttributeType(int index) { return "CDATA"; } public boolean isAttributeDefault(int index) { return false; } public String getAttributeNamespace(int index) { if (index >= attributeCount) throw new IndexOutOfBoundsException(); return attributes[index << 2]; } public String getAttributeName(int index) { if (index >= attributeCount) throw new IndexOutOfBoundsException(); return attributes[(index << 2) + 2]; } public String getAttributePrefix(int index) { if (index >= attributeCount) throw new IndexOutOfBoundsException(); return attributes[(index << 2) + 1]; } public String getAttributeValue(int index) { if (index >= attributeCount) throw new IndexOutOfBoundsException(); return attributes[(index << 2) + 3]; } public String getAttributeValue(String namespace, String name) { for (int i = (attributeCount << 2) - 4; i >= 0; i -= 4) { if (attributes[i + 2].equals(name) && (namespace == null || attributes[i].equals(namespace))) return attributes[i + 3]; } return null; } public int getEventType() throws XmlPullParserException { return type; } public int next() throws XmlPullParserException, IOException { txtPos = 0; isWhitespace = true; int minType = 9999; token = false; do { nextImpl(); if (type < minType) minType = type; // if (curr <= TEXT) type = curr; } while (minType > ENTITY_REF // ignorable || (minType >= TEXT && peekType() >= TEXT)); type = minType; if (type > TEXT) type = TEXT; return type; } public int nextToken() throws XmlPullParserException, IOException { isWhitespace = true; txtPos = 0; token = true; nextImpl(); return type; } // // utility methods to make XML parsing easier ... public int nextTag() throws XmlPullParserException, IOException { next(); if (type == TEXT && isWhitespace) next(); if (type != END_TAG && type != START_TAG) exception("unexpected type"); return type; } public void require(int type, String namespace, String name) throws XmlPullParserException, IOException { if (type != this.type || (namespace != null && !namespace.equals(getNamespace())) || (name != null && !name.equals(getName()))) exception( "expected: " + TYPES[type] + " {" + namespace + "}" + name); } public String nextText() throws XmlPullParserException, IOException { if (type != START_TAG) exception("precondition: START_TAG"); next(); String result; if (type == TEXT) { result = getText(); next(); } else result = ""; if (type != END_TAG) exception("END_TAG expected"); return result; } public void setFeature(String feature, boolean value) throws XmlPullParserException { if (XmlPullParser.FEATURE_PROCESS_NAMESPACES.equals(feature)) processNsp = value; else if (isProp(feature, false, "relaxed")) relaxed = value; else exception("unsupported feature: " + feature); } public void setProperty(String property, Object value) throws XmlPullParserException { if(isProp(property, true, "location")) location = value; else throw new XmlPullParserException("unsupported property: " + property); } /** * Skip sub tree that is currently porser positioned on. *
NOTE: parser must be on START_TAG and when funtion returns * parser will be positioned on corresponding END_TAG. */ // Implementation copied from Alek's mail... public void skipSubTree() throws XmlPullParserException, IOException { require(START_TAG, null, null); int level = 1; while (level > 0) { int eventType = next(); if (eventType == END_TAG) { --level; } else if (eventType == START_TAG) { ++level; } } } } kxml2-2.3.0/src/org/kxml2/wap/0000755000175000017500000000000010446540272014103 5ustar neoneokxml2-2.3.0/src/org/kxml2/wap/wml/0000755000175000017500000000000010435016414014674 5ustar neoneokxml2-2.3.0/src/org/kxml2/wap/wml/Wml.java0000644000175000017500000000777007744601254016324 0ustar neoneopackage org.kxml2.wap.wml; import org.kxml2.wap.*; /** This class contains the wml coding tables for elements * and attributes needed by the WmlParser. */ public abstract class Wml { /** Creates a WbxmlParser with the WML code pages set */ public static WbxmlParser createParser() { WbxmlParser p = new WbxmlParser(); p.setTagTable(0, TAG_TABLE); p.setAttrStartTable(0, ATTR_START_TABLE); p.setAttrValueTable(0, ATTR_VALUE_TABLE); return p; } public static WbxmlSerializer createSerializer() { WbxmlSerializer s = new WbxmlSerializer(); s.setTagTable(0, TAG_TABLE); s.setAttrStartTable(0, ATTR_START_TABLE); s.setAttrValueTable(0, ATTR_VALUE_TABLE); return s; } public static final String [] TAG_TABLE = { null, // 05 null, // 06 null, // 07 null, // 08 null, // 09 null, // 0A null, // 0B null, // 0C null, // 0D null, // 0E null, // 0F null, // 10 null, // 11 null, // 12 null, // 13 null, // 14 null, // 15 null, // 16 null, // 17 null, // 18 null, // 19 null, // 1A null, // 1B "a", // 1C "td", // 1D "tr", // 1E "table", // 1F "p", // 20 "postfield", // 21 "anchor", // 22 "access", // 23 "b", // 24 "big", // 25 "br", // 26 "card", // 27 "do", // 28 "em", // 29 "fieldset", // 2A "go", // 2B "head", // 2C "i", // 2D "img", // 2E "input", // 2F "meta", // 30 "noop", // 31 "prev", // 32 "onevent", // 33 "optgroup", // 34 "option", // 35 "refresh", // 36 "select", // 37 "small", // 38 "strong", // 39 null, // 3A "template", // 3B "timer", // 3C "u", // 3D "setvar", // 3E "wml", // 3F }; public static final String [] ATTR_START_TABLE = { "accept-charset", // 05 "align=bottom", // 06 "align=center", // 07 "align=left", // 08 "align=middle", // 09 "align=right", // 0A "align=top", // 0B "alt", // 0C "content", // 0D null, // 0E "domain", // 0F "emptyok=false", // 10 "emptyok=true", // 11 "format", // 12 "height", // 13 "hspace", // 14 "ivalue", // 15 "iname", // 16 null, // 17 "label", // 18 "localsrc", // 19 "maxlength", // 1A "method=get", // 1B "method=post", // 1C "mode=nowrap", // 1D "mode=wrap", // 1E "multiple=false", // 1F "multiple=true", // 20 "name", // 21 "newcontext=false", // 22 "newcontext=true", // 23 "onpick", // 24 "onenterbackward", // 25 "onenterforward", // 26 "ontimer", // 27 "optimal=false", // 28 "optimal=true", // 29 "path", // 2A null, // 2B null, // 2C null, // 2D "scheme", // 2E "sendreferer=false", // 2F "sendreferer=true", // 30 "size", // 31 "src", // 32 "ordered=true", // 33 "ordered=false", // 34 "tabindex", // 35 "title", // 36 "type", // 37 "type=accept", // 38 "type=delete", // 39 "type=help", // 3A "type=password", // 3B "type=onpick", // 3C "type=onenterbackward", // 3D "type=onenterforward", // 3E "type=ontimer", // 3F null, // 40 null, // 41 null, // 42 null, // 43 null, // 44 "type=options", // 45 "type=prev", // 46 "type=reset", // 47 "type=text", // 48 "type=vnd.", // 49 "href", // 4A "href=http://", // 4B "href=https://", // 4C "value", // 4D "vspace", // 4E "width", // 4F "xml:lang", // 50 null, // 51 "align", // 52 "columns", // 53 "class", // 54 "id", // 55 "forua=false", // 56 "forua=true", // 57 "src=http://", // 58 "src=https://", // 59 "http-equiv", // 5A "http-equiv=Content-Type", // 5B "content=application/vnd.wap.wmlc;charset=", // 5C "http-equiv=Expires", // 5D null, // 5E null, // 5F }; public static final String [] ATTR_VALUE_TABLE = { ".com/", // 85 ".edu/", // 86 ".net/", // 87 ".org/", // 88 "accept", // 89 "bottom", // 8A "clear", // 8B "delete", // 8C "help", // 8D "http://", // 8E "http://www.", // 8F "https://", // 90 "https://www.", // 91 null, // 92 "middle", // 93 "nowrap", // 94 "onpick", // 95 "onenterbackward", // 96 "onenterforward", // 97 "ontimer", // 98 "options", // 99 "password", // 9A "reset", // 9B null, // 9C "text", // 9D "top", // 9E "unknown", // 9F "wrap", // A0 "www.", // A1 }; } kxml2-2.3.0/src/org/kxml2/wap/syncml/0000755000175000017500000000000010435016414015402 5ustar neoneokxml2-2.3.0/src/org/kxml2/wap/syncml/SyncML.java0000644000175000017500000001422010302343564017413 0ustar neoneopackage org.kxml2.wap.syncml; import org.kxml2.wap.*; public abstract class SyncML { // SyncML-Common (-//SYNCML//DTD SyncML 1.2//EN and -//SYNCML//DTD MetInf 1.2//EN) support public static WbxmlParser createParser() { WbxmlParser p = new WbxmlParser(); p.setTagTable(0, TAG_TABLE_0); p.setTagTable(1, TAG_TABLE_1); return p; } public static WbxmlSerializer createSerializer() { WbxmlSerializer s = new WbxmlSerializer(); s.setTagTable(0, TAG_TABLE_0); s.setTagTable(1, TAG_TABLE_1); return s; } // SyncML-Common + DMDDF (-//OMA//DTD-DM-DDF 1.2//EN) support public static WbxmlParser createDMParser() { WbxmlParser p = createParser(); p.setTagTable(2, TAG_TABLE_2_DM); return p; } public static WbxmlSerializer createDMSerializer() { WbxmlSerializer s = createSerializer(); s.setTagTable(2, TAG_TABLE_2_DM); return s; } // Tables public static final String [] TAG_TABLE_0 = { // -//SYNCML//DTD SyncML 1.2//EN "Add", // 0x05 "Alert", // 0x06 "Archive", // 0x07 "Atomic", // 0x08 "Chal", // 0x09 "Cmd", // 0x0a "CmdID", // 0x0b "CmdRef", // 0x0c "Copy", // 0x0d "Cred", // 0x0e "Data", // 0x0f "Delete", // 0x10 "Exec", // 0x11 "Final", // 0x12 "Get", // 0x13 "Item", // 0x14 "Lang", // 0x15 "LocName", // 0x16 "LocURI", // 0x17 "Map", // 0x18 "MapItem", // 0x19 "Meta", // 0x1a "MsgID", // 0x1b "MsgRef", // 0x1c "NoResp", // 0x1d "NoResults", // 0x1e "Put", // 0x1f "Replace", // 0x20 "RespURI", // 0x21 "Results", // 0x22 "Search", // 0x23 "Sequence", // 0x24 "SessionID", // 0x25 "SftDel", // 0x26 "Source", // 0x27 "SourceRef", // 0x28 "Status", // 0x29 "Sync", // 0x2a "SyncBody", // 0x2b "SyncHdr", // 0x2c "SyncML", // 0x2d "Target", // 0x2e "TargetRef", // 0x2f "Reserved for future use", // 0x30 "VerDTD", // 0x31 "VerProto", // 0x32 "NumberOfChanged",// 0x33 "MoreData", // 0x34 "Field", // 0x35 "Filter", // 0x36 "Record", // 0x37 "FilterType", // 0x38 "SourceParent", // 0x39 "TargetParent", // 0x3a "Move", // 0x3b "Correlator" // 0x3c }; public static final String [] TAG_TABLE_1 = { // -//SYNCML//DTD MetInf 1.2//EN "Anchor", // 0x05 "EMI", // 0x06 "Format", // 0x07 "FreeID", // 0x08 "FreeMem", // 0x09 "Last", // 0x0a "Mark", // 0x0b "MaxMsgSize", // 0x0c "Mem", // 0x0d "MetInf", // 0x0e "Next", // 0x0f "NextNonce", // 0x10 "SharedMem", // 0x11 "Size", // 0x12 "Type", // 0x13 "Version", // 0x14 "MaxObjSize", // 0x15 "FieldLevel" // 0x16 }; public static final String [] TAG_TABLE_2_DM = { // -//OMA//DTD-DM-DDF 1.2//EN "AccessType", // 0x05 "ACL", // 0x06 "Add", // 0x07 "b64", // 0x08 "bin", // 0x09 "bool", // 0x0a "chr", // 0x0b "CaseSense", // 0x0c "CIS", // 0x0d "Copy", // 0x0e "CS", // 0x0f "date", // 0x10 "DDFName", // 0x11 "DefaultValue", // 0x12 "Delete", // 0x13 "Description", // 0x14 "DDFFormat", // 0x15 "DFProperties", // 0x16 "DFTitle", // 0x17 "DFType", // 0x18 "Dynamic", // 0x19 "Exec", // 0x1a "float", // 0x1b "Format", // 0x1c "Get", // 0x1d "int", // 0x1e "Man", // 0x1f "MgmtTree", // 0x20 "MIME", // 0x21 "Mod", // 0x22 "Name", // 0x23 "Node", // 0x24 "node", // 0x25 "NodeName", // 0x26 "null", // 0x27 "Occurence", // 0x28 "One", // 0x29 "OneOrMore", // 0x2a "OneOrN", // 0x2b "Path", // 0x2c "Permanent", // 0x2d "Replace", // 0x2e "RTProperties", // 0x2f "Scope", // 0x30 "Size", // 0x31 "time", // 0x32 "Title", // 0x33 "TStamp", // 0x34 "Type", // 0x35 "Value", // 0x36 "VerDTD", // 0x37 "VerNo", // 0x38 "xml", // 0x39 "ZeroOrMore", // 0x3a "ZeroOrN", // 0x3b "ZeroOrOne" // 0x3c }; } kxml2-2.3.0/src/org/kxml2/wap/wv/0000755000175000017500000000000010435016414014531 5ustar neoneokxml2-2.3.0/src/org/kxml2/wap/wv/WV.java0000644000175000017500000007176310340206334015743 0ustar neoneopackage org.kxml2.wap.wv; import java.io.IOException; import org.kxml2.wap.*; /* * WV.java * * Created on 25 September 2003, 10:40 */ /** * Wireless Village CSP 1.1 ("OMA-WV-CSP-V1_1-20021001-A.pdf") * Wireless Village CSP 1.2 ("OMA-IMPS-WV-CSP_WBXML-v1_2-20030221-C.PDF") * There are some bugs in the 1.2 spec but this is Ok. 1.2 is candidate * * @author Bogdan Onoiu */ public abstract class WV { public static WbxmlParser createParser () throws IOException { WbxmlParser parser = new WbxmlParser(); parser.setTagTable (0, WV.tagTablePage0); parser.setTagTable (1, WV.tagTablePage1); parser.setTagTable (2, WV.tagTablePage2); parser.setTagTable (3, WV.tagTablePage3); parser.setTagTable (4, WV.tagTablePage4); parser.setTagTable (5, WV.tagTablePage5); parser.setTagTable (6, WV.tagTablePage6); parser.setTagTable (7, WV.tagTablePage7); parser.setTagTable (8, WV.tagTablePage8); parser.setTagTable (9, WV.tagTablePage9); parser.setTagTable (10, WV.tagTablePageA); parser.setAttrStartTable (0, WV.attrStartTable); parser.setAttrValueTable (0, WV.attrValueTable); return parser; } public static final String [] tagTablePage0 = { /* Common ... continue on Page 0x09 */ "Acceptance", //0x00, 0x05 "AddList", //0x00, 0x06 "AddNickList", //0x00, 0x07 "SName", //0x00, 0x08 "WV-CSP-Message", //0x00, 0x09 "ClientID", //0x00, 0x0A "Code", //0x00, 0x0B "ContactList", //0x00, 0x0C "ContentData", //0x00, 0x0D "ContentEncoding",//0x00, 0x0E "ContentSize", //0x00, 0x0F "ContentType", //0x00, 0x10 "DateTime", //0x00, 0x11 "Description", //0x00, 0x12 "DetailedResult", //0x00, 0x13 "EntityList", //0x00, 0x14 "Group", //0x00, 0x15 "GroupID", //0x00, 0x16 "GroupList", //0x00, 0x17 "InUse", //0x00, 0x18 "Logo", //0x00, 0x19 "MessageCount", //0x00, 0x1A "MessageID", //0x00, 0x1B "MessageURI", //0x00, 0x1C "MSISDN", //0x00, 0x1D "Name", //0x00, 0x1E "NickList", //0x00, 0x1F "NickName", //0x00, 0x20 "Poll", //0x00, 0x21 "Presence", //0x00, 0x22 "PresenceSubList",//0x00, 0x23 "PresenceValue", //0x00, 0x24 "Property", //0x00, 0x25 "Qualifier", //0x00, 0x26 "Recipient", //0x00, 0x27 "RemoveList", //0x00, 0x28 "RemoveNickList", //0x00, 0x29 "Result", //0x00, 0x2A "ScreenName", //0x00, 0x2B "Sender", //0x00, 0x2C "Session", //0x00, 0x2D "SessionDescriptor",//0x00, 0x2E "SessionID", //0x00, 0x2F "SessionType", //0x00, 0x30 "Status", //0x00, 0x31 "Transaction", //0x00, 0x32 "TransactionContent",//0x00, 0x33 "TransactionDescriptor",//0x00, 0x34 "TransactionID", //0x00, 0x35 "TransactionMode",//0x00, 0x36 "URL", //0x00, 0x37 "URLList", //0x00, 0x38 "User", //0x00, 0x39 "UserID", //0x00, 0x3A "UserList", //0x00, 0x3B "Validity", //0x00, 0x3C "Value", //0x00, 0x3D }; public static final String [] tagTablePage1 = { /* Access ... continue on Page 0x0A */ "AllFunctions", // 0x01, 0x05 "AllFunctionsRequest", // 0x01, 0x06 "CancelInvite-Request", // 0x01, 0x07 "CancelInviteUser-Request", // 0x01, 0x08 "Capability", // 0x01, 0x09 "CapabilityList", // 0x01, 0x0A "CapabilityRequest", // 0x01, 0x0B "ClientCapability-Request", // 0x01, 0x0C "ClientCapability-Response",// 0x01, 0x0D "DigestBytes", // 0x01, 0x0E "DigestSchema", // 0x01, 0x0F "Disconnect", // 0x01, 0x10 "Functions", // 0x01, 0x11 "GetSPInfo-Request", // 0x01, 0x12 "GetSPInfo-Response", // 0x01, 0x13 "InviteID", // 0x01, 0x14 "InviteNote", // 0x01, 0x15 "Invite-Request", // 0x01, 0x16 "Invite-Response", // 0x01, 0x17 "InviteType", // 0x01, 0x18 "InviteUser-Request", // 0x01, 0x19 "InviteUser-Response", // 0x01, 0x1A "KeepAlive-Request", // 0x01, 0x1B "KeepAliveTime", // 0x01, 0x1C "Login-Request", // 0x01, 0x1D "Login-Response", // 0x01, 0x1E "Logout-Request", // 0x01, 0x1F "Nonce", // 0x01, 0x20 "Password", // 0x01, 0x21 "Polling-Request", // 0x01, 0x22 "ResponseNote", // 0x01, 0x23 "SearchElement", // 0x01, 0x24 "SearchFindings", // 0x01, 0x25 "SearchID", // 0x01, 0x26 "SearchIndex", // 0x01, 0x27 "SearchLimit", // 0x01, 0x28 "KeepAlive-Response", // 0x01, 0x29 "SearchPairList", // 0x01, 0x2A "Search-Request", // 0x01, 0x2B "Search-Response", // 0x01, 0x2C "SearchResult", // 0x01, 0x2D "Service-Request", // 0x01, 0x2E "Service-Response", // 0x01, 0x2F "SessionCookie", // 0x01, 0x30 "StopSearch-Request", // 0x01, 0x31 "TimeToLive", // 0x01, 0x32 "SearchString", // 0x01, 0x33 "CompletionFlag", // 0x01, 0x34 null, // 0x01, 0x35 "ReceiveList", // 0x01, 0x36 /* WV 1.2 */ "VerifyID-Request", // 0x01, 0x37 /* WV 1.2 */ "Extended-Request", // 0x01, 0x38 /* WV 1.2 */ "Extended-Response", // 0x01, 0x39 /* WV 1.2 */ "AgreedCapabilityList", // 0x01, 0x3A /* WV 1.2 */ "Extended-Data", // 0x01, 0x3B /* WV 1.2 */ "OtherServer", // 0x01, 0x3C /* WV 1.2 */ "PresenceAttributeNSName",//0x01, 0x3D /* WV 1.2 */ "SessionNSName", // 0x01, 0x3E /* WV 1.2 */ "TransactionNSName", // 0x01, 0x3F /* WV 1.2 */ }; public static final String [] tagTablePage2 = { /* Service ... continue on Page 0x08 */ "ADDGM", // 0x02, 0x05 "AttListFunc", // 0x02, 0x06 "BLENT", // 0x02, 0x07 "CAAUT", // 0x02, 0x08 "CAINV", // 0x02, 0x09 "CALI", // 0x02, 0x0A "CCLI", // 0x02, 0x0B "ContListFunc", // 0x02, 0x0C "CREAG", // 0x02, 0x0D "DALI", // 0x02, 0x0E "DCLI", // 0x02, 0x0F "DELGR", // 0x02, 0x10 "FundamentalFeat",//0x02, 0x11 "FWMSG", // 0x02, 0x12 "GALS", // 0x02, 0x13 "GCLI", // 0x02, 0x14 "GETGM", // 0x02, 0x15 "GETGP", // 0x02, 0x16 "GETLM", // 0x02, 0x17 "GETM", // 0x02, 0x18 "GETPR", // 0x02, 0x19 "GETSPI", // 0x02, 0x1A "GETWL", // 0x02, 0x1B "GLBLU", // 0x02, 0x1C "GRCHN", // 0x02, 0x1D "GroupAuthFunc",// 0x02, 0x1E "GroupFeat", // 0x02, 0x1F "GroupMgmtFunc",// 0x02, 0x20 "GroupUseFunc", // 0x02, 0x21 "IMAuthFunc", // 0x02, 0x22 "IMFeat", // 0x02, 0x23 "IMReceiveFunc",// 0x02, 0x24 "IMSendFunc", // 0x02, 0x25 "INVIT", // 0x02, 0x26 "InviteFunc", // 0x02, 0x27 "MBRAC", // 0x02, 0x28 "MCLS", // 0x02, 0x29 "MDELIV", // 0x02, 0x2A "NEWM", // 0x02, 0x2B "NOTIF", // 0x02, 0x2C "PresenceAuthFunc",//0x02, 0x2D "PresenceDeliverFunc",//0x02, 0x2E "PresenceFeat", // 0x02, 0x2F "REACT", // 0x02, 0x30 "REJCM", // 0x02, 0x31 "REJEC", // 0x02, 0x32 "RMVGM", // 0x02, 0x33 "SearchFunc", // 0x02, 0x34 "ServiceFunc", // 0x02, 0x35 "SETD", // 0x02, 0x36 "SETGP", // 0x02, 0x37 "SRCH", // 0x02, 0x38 "STSRC", // 0x02, 0x39 "SUBGCN", // 0x02, 0x3A "UPDPR", // 0x02, 0x3B "WVCSPFeat", // 0x02, 0x3C "MF", // 0x02, 0x3D /* WV 1.2 */ "MG", // 0x02, 0x3E /* WV 1.2 */ "MM" // 0x02, 0x3F /* WV 1.2 */ }; public static final String [] tagTablePage3 = { /* Client Capability */ "AcceptedCharset", // 0x03, 0x05 "AcceptedContentLength", // 0x03, 0x06 "AcceptedContentType", // 0x03, 0x07 "AcceptedTransferEncoding", // 0x03, 0x08 "AnyContent", // 0x03, 0x09 "DefaultLanguage", // 0x03, 0x0A "InitialDeliveryMethod", // 0x03, 0x0B "MultiTrans", // 0x03, 0x0C "ParserSize", // 0x03, 0x0D "ServerPollMin", // 0x03, 0x0E "SupportedBearer", // 0x03, 0x0F "SupportedCIRMethod", // 0x03, 0x10 "TCPAddress", // 0x03, 0x11 "TCPPort", // 0x03, 0x12 "UDPPort" // 0x03, 0x13 }; public static final String [] tagTablePage4 = { /* Presence Primitive */ "CancelAuth-Request", // 0x04, 0x05 "ContactListProperties", // 0x04, 0x06 "CreateAttributeList-Request", // 0x04, 0x07 "CreateList-Request", // 0x04, 0x08 "DefaultAttributeList", // 0x04, 0x09 "DefaultContactList", // 0x04, 0x0A "DefaultList", // 0x04, 0x0B "DeleteAttributeList-Request", // 0x04, 0x0C "DeleteList-Request", // 0x04, 0x0D "GetAttributeList-Request", // 0x04, 0x0E "GetAttributeList-Response", // 0x04, 0x0F "GetList-Request", // 0x04, 0x10 "GetList-Response", // 0x04, 0x11 "GetPresence-Request", // 0x04, 0x12 "GetPresence-Response", // 0x04, 0x13 "GetWatcherList-Request", // 0x04, 0x14 "GetWatcherList-Response", // 0x04, 0x15 "ListManage-Request", // 0x04, 0x16 "ListManage-Response", // 0x04, 0x17 "UnsubscribePresence-Request", // 0x04, 0x18 "PresenceAuth-Request", // 0x04, 0x19 "PresenceAuth-User", // 0x04, 0x1A "PresenceNotification-Request", // 0x04, 0x1B "UpdatePresence-Request", // 0x04, 0x1C "SubscribePresence-Request", // 0x04, 0x1D "Auto-Subscribe", // 0x04, 0x1E /* WV 1.2 */ "GetReactiveAuthStatus-Request",// 0x04, 0x1F /* WV 1.2 */ "GetReactiveAuthStatus-Response",// 0x04, 0x20 /* WV 1.2 */ }; public static final String [] tagTablePage5 = { /* Presence Attribute */ "Accuracy", // 0x05, 0x05 "Address", // 0x05, 0x06 "AddrPref", // 0x05, 0x07 "Alias", // 0x05, 0x08 "Altitude", // 0x05, 0x09 "Building", // 0x05, 0x0A "Caddr", // 0x05, 0x0B "City", // 0x05, 0x0C "ClientInfo", // 0x05, 0x0D "ClientProducer", // 0x05, 0x0E "ClientType", // 0x05, 0x0F "ClientVersion", // 0x05, 0x10 "CommC", // 0x05, 0x11 "CommCap", // 0x05, 0x12 "ContactInfo", // 0x05, 0x13 "ContainedvCard", // 0x05, 0x14 "Country", // 0x05, 0x15 "Crossing1", // 0x05, 0x16 "Crossing2", // 0x05, 0x17 "DevManufacturer", // 0x05, 0x18 "DirectContent", // 0x05, 0x19 "FreeTextLocation", // 0x05, 0x1A "GeoLocation", // 0x05, 0x1B "Language", // 0x05, 0x1C "Latitude", // 0x05, 0x1D "Longitude", // 0x05, 0x1E "Model", // 0x05, 0x1F "NamedArea", // 0x05, 0x20 "OnlineStatus", // 0x05, 0x21 "PLMN", // 0x05, 0x22 "PrefC", // 0x05, 0x23 "PreferredContacts",// 0x05, 0x24 "PreferredLanguage",// 0x05, 0x25 "PreferredContent", // 0x05, 0x26 "PreferredvCard", // 0x05, 0x27 "Registration", // 0x05, 0x28 "StatusContent", // 0x05, 0x29 "StatusMood", // 0x05, 0x2A "StatusText", // 0x05, 0x2B "Street", // 0x05, 0x2C "TimeZone", // 0x05, 0x2D "UserAvailability", // 0x05, 0x2E "Cap", // 0x05, 0x2F "Cname", // 0x05, 0x30 "Contact", // 0x05, 0x31 "Cpriority", // 0x05, 0x32 "Cstatus", // 0x05, 0x33 "Note", // 0x05, 0x34 /* WV 1.2 */ "Zone", // 0x05, 0x35 null, "Inf_link", // 0x05, 0x37 /* WV 1.2 */ "InfoLink", // 0x05, 0x38 /* WV 1.2 */ "Link", // 0x05, 0x39 /* WV 1.2 */ "Text", // 0x05, 0x3A /* WV 1.2 */ }; public static final String [] tagTablePage6 = { /* Messaging */ "BlockList", // 0x06, 0x05 // "BlockUser-Request", // 0x06, 0x06 //This is a bug in the spec "BlockEntity-Request", // 0x06, 0x06 "DeliveryMethod", // 0x06, 0x07 "DeliveryReport", // 0x06, 0x08 "DeliveryReport-Request", // 0x06, 0x09 "ForwardMessage-Request", // 0x06, 0x0A "GetBlockedList-Request", // 0x06, 0x0B "GetBlockedList-Response", // 0x06, 0x0C "GetMessageList-Request", // 0x06, 0x0D "GetMessageList-Response", // 0x06, 0x0E "GetMessage-Request", // 0x06, 0x0F "GetMessage-Response", // 0x06, 0x10 "GrantList", // 0x06, 0x11 "MessageDelivered", // 0x06, 0x12 "MessageInfo", // 0x06, 0x13 "MessageNotification", // 0x06, 0x14 "NewMessage", // 0x06, 0x15 "RejectMessage-Request", // 0x06, 0x16 "SendMessage-Request", // 0x06, 0x17 "SendMessage-Response", // 0x06, 0x18 "SetDeliveryMethod-Request",// 0x06, 0x19 "DeliveryTime", // 0x06, 0x1A }; public static final String [] tagTablePage7 = { /* Group */ "AddGroupMembers-Request", // 0x07, 0x05 "Admin", // 0x07, 0x06 "CreateGroup-Request", // 0x07, 0x07 "DeleteGroup-Request", // 0x07, 0x08 "GetGroupMembers-Request", // 0x07, 0x09 "GetGroupMembers-Response", // 0x07, 0x0A "GetGroupProps-Request", // 0x07, 0x0B "GetGroupProps-Response", // 0x07, 0x0C "GroupChangeNotice", // 0x07, 0x0D "GroupProperties", // 0x07, 0x0E "Joined", // 0x07, 0x0F "JoinedRequest", // 0x07, 0x10 "JoinGroup-Request", // 0x07, 0x11 "JoinGroup-Response", // 0x07, 0x12 "LeaveGroup-Request", // 0x07, 0x13 "LeaveGroup-Response", // 0x07, 0x14 "Left", // 0x07, 0x15 "MemberAccess-Request", // 0x07, 0x16 "Mod", // 0x07, 0x17 "OwnProperties", // 0x07, 0x18 "RejectList-Request", // 0x07, 0x19 "RejectList-Response", // 0x07, 0x1A "RemoveGroupMembers-Request",// 0x07, 0x1B "SetGroupProps-Request", // 0x07, 0x1C "SubscribeGroupNotice-Request", // 0x07, 0x1D "SubscribeGroupNotice-Response",// 0x07, 0x1E "Users", // 0x07, 0x1F "WelcomeNote", // 0x07, 0x20 "JoinGroup", // 0x07, 0x21 "SubscribeNotification", // 0x07, 0x22 "SubscribeType", // 0x07, 0x23 "GetJoinedUsers-Request", // 0x07, 0x24 /* WV 1.2 */ "GetJoinedUsers-Response", // 0x07, 0x25 /* WV 1.2 */ "AdminMapList", // 0x07, 0x26 /* WV 1.2 */ "AdminMapping", // 0x07, 0x27 /* WV 1.2 */ "Mapping", // 0x07, 0x28 /* WV 1.2 */ "ModMapping", // 0x07, 0x29 /* WV 1.2 */ "UserMapList", // 0x07, 0x2A /* WV 1.2 */ "UserMapping", // 0x07, 0x2B /* WV 1.2 */ }; public static final String [] tagTablePage8 = { /* Service ... continued */ "MP", // 0x08, 0x05 /* WV 1.2 */ "GETAUT", // 0x08, 0x06 /* WV 1.2 */ "GETJU", // 0x08, 0x07 /* WV 1.2 */ "VRID", // 0x08, 0x08 /* WV 1.2 */ "VerifyIDFunc", // 0x08, 0x09 /* WV 1.2 */ }; public static final String [] tagTablePage9 = { /* Common ... continued */ "CIR", // 0x09, 0x05 /* WV 1.2 */ "Domain", // 0x09, 0x06 /* WV 1.2 */ "ExtBlock", // 0x09, 0x07 /* WV 1.2 */ "HistoryPeriod", // 0x09, 0x08 /* WV 1.2 */ "IDList", // 0x09, 0x09 /* WV 1.2 */ "MaxWatcherList", // 0x09, 0x0A /* WV 1.2 */ "ReactiveAuthState", // 0x09, 0x0B /* WV 1.2 */ "ReactiveAuthStatus", // 0x09, 0x0C /* WV 1.2 */ "ReactiveAuthStatusList", // 0x09, 0x0D /* WV 1.2 */ "Watcher", // 0x09, 0x0E /* WV 1.2 */ "WatcherStatus" // 0x09, 0x0F /* WV 1.2 */ }; public static final String [] tagTablePageA = { /* Access ... continued */ "WV-CSP-NSDiscovery-Request", //0x0A, 0x05 /* WV 1.2 */ "WV-CSP-NSDiscovery-Response", //0x0A, 0x06 /* WV 1.2 */ "VersionList" //0x0A, 0x07 /* WV 1.2 */ }; public static final String [] attrStartTable = { "xmlns=http://www.wireless-village.org/CSP",// 0x00, 0x05 "xmlns=http://www.wireless-village.org/PA", // 0x00, 0x06 "xmlns=http://www.wireless-village.org/TRC",// 0x00, 0x07 "xmlns=http://www.openmobilealliance.org/DTD/WV-CSP", // 0x00, 0x08 "xmlns=http://www.openmobilealliance.org/DTD/WV-PA", // 0x00, 0x09 "xmlns=http://www.openmobilealliance.org/DTD/WV-TRC", // 0x00, 0x0A }; public static final String [] attrValueTable = { "AccessType", // 0x00 /* Common value token */ "ActiveUsers", // 0x01 /* Common value token */ "Admin", // 0x02 /* Common value token */ "application/", // 0x03 /* Common value token */ "application/vnd.wap.mms-message", // 0x04 /* Common value token */ "application/x-sms", // 0x05 /* Common value token */ "AutoJoin", // 0x06 /* Common value token */ "BASE64", // 0x07 /* Common value token */ "Closed", // 0x08 /* Common value token */ "Default", // 0x09 /* Common value token */ "DisplayName", // 0x0a /* Common value token */ "F", // 0x0b /* Common value token */ "G", // 0x0c /* Common value token */ "GR", // 0x0d /* Common value token */ "http://", // 0x0e /* Common value token */ "https://", // 0x0f /* Common value token */ "image/", // 0x10 /* Common value token */ "Inband", // 0x11 /* Common value token */ "IM", // 0x12 /* Common value token */ "MaxActiveUsers", // 0x13 /* Common value token */ "Mod", // 0x14 /* Common value token */ "Name", // 0x15 /* Common value token */ "None", // 0x16 /* Common value token */ "N", // 0x17 /* Common value token */ "Open", // 0x18 /* Common value token */ "Outband", // 0x19 /* Common value token */ "PR", // 0x1a /* Common value token */ "Private", // 0x1b /* Common value token */ "PrivateMessaging", // 0x1c /* Common value token */ "PrivilegeLevel", // 0x1d /* Common value token */ "Public", // 0x1e /* Common value token */ "P", // 0x1f /* Common value token */ "Request", // 0x20 /* Common value token */ "Response", // 0x21 /* Common value token */ "Restricted", // 0x22 /* Common value token */ "ScreenName", // 0x23 /* Common value token */ "Searchable", // 0x24 /* Common value token */ "S", // 0x25 /* Common value token */ "SC", // 0x26 /* Common value token */ "text/", // 0x27 /* Common value token */ "text/plain", // 0x28 /* Common value token */ "text/x-vCalendar", // 0x29 /* Common value token */ "text/x-vCard", // 0x2a /* Common value token */ "Topic", // 0x2b /* Common value token */ "T", // 0x2c /* Common value token */ "Type", // 0x2d /* Common value token */ "U", // 0x2e /* Common value token */ "US", // 0x2f /* Common value token */ "www.wireless-village.org", // 0x30 /* Common value token */ "AutoDelete", // 0x31 /* Common value token */ /* WV 1.2 */ "GM", // 0x32 /* Common value token */ /* WV 1.2 */ "Validity", // 0x33 /* Common value token */ /* WV 1.2 */ "ShowID", // 0x34 /* Common value token */ /* WV 1.2 */ "GRANTED", // 0x35 /* Common value token */ /* WV 1.2 */ "PENDING", // 0x36 /* Common value token */ /* WV 1.2 */ null, // 0x37 null, // 0x38 null, // 0x39 null, // 0x3a null, // 0x3b null, // 0x3c "GROUP_ID", // 0x3d /* Access value token */ "GROUP_NAME", // 0x3e /* Access value token */ "GROUP_TOPIC", // 0x3f /* Access value token */ "GROUP_USER_ID_JOINED", // 0x40 /* Access value token */ "GROUP_USER_ID_OWNER", // 0x41 /* Access value token */ "HTTP", // 0x42 /* Access value token */ "SMS", // 0x43 /* Access value token */ "STCP", // 0x44 /* Access value token */ "SUDP", // 0x45 /* Access value token */ "USER_ALIAS", // 0x46 /* Access value token */ "USER_EMAIL_ADDRESS", // 0x47 /* Access value token */ "USER_FIRST_NAME", // 0x48 /* Access value token */ "USER_ID", // 0x49 /* Access value token */ "USER_LAST_NAME", // 0x4a /* Access value token */ "USER_MOBILE_NUMBER", // 0x4b /* Access value token */ "USER_ONLINE_STATUS", // 0x4c /* Access value token */ "WAPSMS", // 0x4d /* Access value token */ "WAPUDP", // 0x4e /* Access value token */ "WSP", // 0x4f /* Access value token */ "GROUP_USER_ID_AUTOJOIN", // 0x50 /* Access value token */ /* WV 1.2 */ null, // 0x51 null, // 0x52 null, // 0x53 null, // 0x54 null, // 0x55 null, // 0x56 null, // 0x57 null, // 0x58 null, // 0x59 null, // 0x5a "ANGRY", // 0x5b /* Presence value token */ "ANXIOUS", // 0x5c /* Presence value token */ "ASHAMED", // 0x5d /* Presence value token */ "AUDIO_CALL", // 0x5e /* Presence value token */ "AVAILABLE", // 0x5f /* Presence value token */ "BORED", // 0x60 /* Presence value token */ "CALL", // 0x61 /* Presence value token */ "CLI", // 0x62 /* Presence value token */ "COMPUTER", // 0x63 /* Presence value token */ "DISCREET", // 0x64 /* Presence value token */ "EMAIL", // 0x65 /* Presence value token */ "EXCITED", // 0x66 /* Presence value token */ "HAPPY", // 0x67 /* Presence value token */ "IM", // 0x68 /* Presence value token */ "IM_OFFLINE", // 0x69 /* Presence value token */ "IM_ONLINE", // 0x6a /* Presence value token */ "IN_LOVE", // 0x6b /* Presence value token */ "INVINCIBLE", // 0x6c /* Presence value token */ "JEALOUS", // 0x6d /* Presence value token */ "MMS", // 0x6e /* Presence value token */ "MOBILE_PHONE", // 0x6f /* Presence value token */ "NOT_AVAILABLE", // 0x70 /* Presence value token */ "OTHER", // 0x71 /* Presence value token */ "PDA", // 0x72 /* Presence value token */ "SAD", // 0x73 /* Presence value token */ "SLEEPY", // 0x74 /* Presence value token */ "SMS", // 0x75 /* Presence value token */ "VIDEO_CALL", // 0x76 /* Presence value token */ "VIDEO_STREAM", // 0x77 /* Presence value token */ }; }kxml2-2.3.0/src/org/kxml2/wap/Wbxml.java0000644000175000017500000000407207642406206016044 0ustar neoneo/* Copyright (c) 2002,2003, Stefan Haustein, Oberhausen, Rhld., Germany * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or * sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS * IN THE SOFTWARE. */ package org.kxml2.wap; /** contains the WBXML constants */ public interface Wbxml { static public final int SWITCH_PAGE = 0; static public final int END = 1; static public final int ENTITY = 2; static public final int STR_I = 3; static public final int LITERAL = 4; static public final int EXT_I_0 = 0x40; static public final int EXT_I_1 = 0x41; static public final int EXT_I_2 = 0x42; static public final int PI = 0x43; static public final int LITERAL_C = 0x44; static public final int EXT_T_0 = 0x80; static public final int EXT_T_1 = 0x81; static public final int EXT_T_2 = 0x82; static public final int STR_T = 0x83; static public final int LITERAL_A = 0x084; static public final int EXT_0 = 0x0c0; static public final int EXT_1 = 0x0c1; static public final int EXT_2 = 0x0c2; static public final int OPAQUE = 0x0c3; static public final int LITERAL_AC = 0x0c4; } kxml2-2.3.0/src/org/kxml2/wap/WbxmlSerializer.java0000644000175000017500000003355210446015040020067 0ustar neoneo/* Copyright (c) 2002,2003, Stefan Haustein, Oberhausen, Rhld., Germany * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or * sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS * IN THE SOFTWARE. */ //Contributors: Jonathan Cox, Bogdan Onoiu, Jerry Tian package org.kxml2.wap; import java.io.*; import java.util.*; import org.xmlpull.v1.*; // TODO: make some of the "direct" WBXML token writing methods public?? /** * A class for writing WBXML. * */ public class WbxmlSerializer implements XmlSerializer { Hashtable stringTable = new Hashtable(); OutputStream out; ByteArrayOutputStream buf = new ByteArrayOutputStream(); ByteArrayOutputStream stringTableBuf = new ByteArrayOutputStream(); String pending; int depth; String name; String namespace; Vector attributes = new Vector(); Hashtable attrStartTable = new Hashtable(); Hashtable attrValueTable = new Hashtable(); Hashtable tagTable = new Hashtable(); private int attrPage; private int tagPage; private String encoding; public XmlSerializer attribute(String namespace, String name, String value) { attributes.addElement(name); attributes.addElement(value); return this; } public void cdsect (String cdsect) throws IOException{ text (cdsect); } /* silently ignore comment */ public void comment (String comment) { } public void docdecl (String docdecl) { throw new RuntimeException ("Cannot write docdecl for WBXML"); } public void entityRef (String er) { throw new RuntimeException ("EntityReference not supported for WBXML"); } public int getDepth() { return depth; } public boolean getFeature (String name) { return false; } public String getNamespace() { throw new RuntimeException("NYI"); } public String getName() { throw new RuntimeException("NYI"); } public String getPrefix(String nsp, boolean create) { throw new RuntimeException ("NYI"); } public Object getProperty (String name) { return null; } public void ignorableWhitespace (String sp) { } public void endDocument() throws IOException { writeInt(out, stringTableBuf.size()); // write StringTable out.write(stringTableBuf.toByteArray()); // write buf out.write(buf.toByteArray()); // ready! out.flush(); } /** ATTENTION: flush cannot work since Wbxml documents require buffering. Thus, this call does nothing. */ public void flush() { } public void checkPending(boolean degenerated) throws IOException { if (pending == null) return; int len = attributes.size(); int[] idx = (int[]) tagTable.get(pending); // if no entry in known table, then add as literal if (idx == null) { buf.write( len == 0 ? (degenerated ? Wbxml.LITERAL : Wbxml.LITERAL_C) : (degenerated ? Wbxml.LITERAL_A : Wbxml.LITERAL_AC)); writeStrT(pending, false); } else { if(idx[0] != tagPage){ tagPage=idx[0]; buf.write(Wbxml.SWITCH_PAGE); buf.write(tagPage); } buf.write( len == 0 ? (degenerated ? idx[1] : idx[1] | 64) : (degenerated ? idx[1] | 128 : idx[1] | 192)); } for (int i = 0; i < len;) { idx = (int[]) attrStartTable.get(attributes.elementAt(i)); if (idx == null) { buf.write(Wbxml.LITERAL); writeStrT((String) attributes.elementAt(i), false); } else { if(idx[0] != attrPage){ attrPage = idx[0]; buf.write(0); buf.write(attrPage); } buf.write(idx[1]); } idx = (int[]) attrValueTable.get(attributes.elementAt(++i)); if (idx == null) { writeStr((String) attributes.elementAt(i)); } else { if(idx[0] != attrPage){ attrPage = idx[0]; buf.write(0); buf.write(attrPage); } buf.write(idx[1]); } ++i; } if (len > 0) buf.write(Wbxml.END); pending = null; attributes.removeAllElements(); } public void processingInstruction(String pi) { throw new RuntimeException ("PI NYI"); } public void setFeature(String name, boolean value) { throw new IllegalArgumentException ("unknown feature "+name); } public void setOutput (Writer writer) { throw new RuntimeException ("Wbxml requires an OutputStream!"); } public void setOutput (OutputStream out, String encoding) throws IOException { this.encoding = encoding == null ? "UTF-8" : encoding; this.out = out; buf = new ByteArrayOutputStream(); stringTableBuf = new ByteArrayOutputStream(); // ok, write header } public void setPrefix(String prefix, String nsp) { throw new RuntimeException("NYI"); } public void setProperty(String property, Object value) { throw new IllegalArgumentException ("unknown property "+property); } public void startDocument(String s, Boolean b) throws IOException{ out.write(0x03); // version 1.3 // http://www.openmobilealliance.org/tech/omna/omna-wbxml-public-docid.htm out.write(0x01); // unknown or missing public identifier // default encoding is UTF-8 if(s != null){ encoding = s; } if (encoding.toUpperCase().equals("UTF-8")){ out.write(106); }else if (encoding.toUpperCase().equals("ISO-8859-1")){ out.write(0x04); }else{ throw new UnsupportedEncodingException(s); } } public XmlSerializer startTag(String namespace, String name) throws IOException { if (namespace != null && !"".equals(namespace)) throw new RuntimeException ("NSP NYI"); //current = new State(current, prefixMap, name); checkPending(false); pending = name; depth++; return this; } public XmlSerializer text(char[] chars, int start, int len) throws IOException { checkPending(false); writeStr(new String(chars, start, len)); return this; } public XmlSerializer text(String text) throws IOException { checkPending(false); writeStr(text); return this; } /** Used in text() and attribute() to write text */ private void writeStr(String text) throws IOException{ int p0 = 0; int lastCut = 0; int len = text.length(); while(p0 < len){ while(p0 < len && text.charAt(p0) < 'A' ){ // skip interpunctation p0++; } int p1 = p0; while(p1 < len && text.charAt(p1) >= 'A'){ p1++; } if(p1 - p0 > 10) { if(p0 > lastCut && text.charAt(p0-1) == ' ' && stringTable.get(text.substring(p0, p1)) == null){ buf.write(Wbxml.STR_T); writeStrT(text.substring(lastCut, p1), false); } else { if(p0 > lastCut && text.charAt(p0-1) == ' '){ p0--; } if(p0 > lastCut){ buf.write(Wbxml.STR_T); writeStrT(text.substring(lastCut, p0), false); } buf.write(Wbxml.STR_T); writeStrT(text.substring(p0, p1), true); } lastCut = p1; } p0 = p1; } if(lastCut < len){ buf.write(Wbxml.STR_T); writeStrT(text.substring(lastCut, len), false); } } public XmlSerializer endTag(String namespace, String name) throws IOException { // current = current.prev; if (pending != null) checkPending(true); else buf.write(Wbxml.END); depth--; return this; } /** * @throws IOException */ public void writeWapExtension(int type, Object data) throws IOException { checkPending(false); buf.write(type); switch(type){ case Wbxml.EXT_0: case Wbxml.EXT_1: case Wbxml.EXT_2: break; case Wbxml.OPAQUE: byte[] bytes = (byte[]) data; writeInt(buf, bytes.length); buf.write(bytes); break; case Wbxml.EXT_I_0: case Wbxml.EXT_I_1: case Wbxml.EXT_I_2: writeStrI(buf, (String) data); break; case Wbxml.EXT_T_0: case Wbxml.EXT_T_1: case Wbxml.EXT_T_2: writeStrT((String) data, false); break; default: throw new IllegalArgumentException(); } } // ------------- internal methods -------------------------- static void writeInt(OutputStream out, int i) throws IOException { byte[] buf = new byte[5]; int idx = 0; do { buf[idx++] = (byte) (i & 0x7f); i = i >> 7; } while (i != 0); while (idx > 1) { out.write(buf[--idx] | 0x80); } out.write(buf[0]); } void writeStrI(OutputStream out, String s) throws IOException { byte[] data = s.getBytes(encoding); out.write(data); out.write(0); } private final void writeStrT(String s, boolean mayPrependSpace) throws IOException { Integer idx = (Integer) stringTable.get(s); if (idx != null) { writeInt(buf, idx.intValue()); } else{ int i = stringTableBuf.size(); if(s.charAt(0) >= '0' && mayPrependSpace){ s = ' ' + s; writeInt(buf, i+1); } else{ writeInt(buf, i); } stringTable.put(s, new Integer(i)); if(s.charAt(0) == ' '){ stringTable.put(s.substring(1), new Integer(i+1)); } int j = s.lastIndexOf(' '); if(j > 1){ stringTable.put(s.substring(j), new Integer(i+j)); stringTable.put(s.substring(j+1), new Integer(i+j+1)); } writeStrI(stringTableBuf, s); stringTableBuf.flush(); } } /** * Sets the tag table for a given page. * The first string in the array defines tag 5, the second tag 6 etc. */ public void setTagTable(int page, String[] tagTable) { // TODO: clear entries in tagTable? for (int i = 0; i < tagTable.length; i++) { if (tagTable[i] != null) { Object idx = new int[]{page, i+5}; this.tagTable.put(tagTable[i], idx); } } } /** * Sets the attribute start Table for a given page. * The first string in the array defines attribute * 5, the second attribute 6 etc. * Please use the * character '=' (without quote!) as delimiter * between the attribute name and the (start of the) value */ public void setAttrStartTable(int page, String[] attrStartTable) { for (int i = 0; i < attrStartTable.length; i++) { if (attrStartTable[i] != null) { Object idx = new int[] {page, i + 5}; this.attrStartTable.put(attrStartTable[i], idx); } } } /** * Sets the attribute value Table for a given page. * The first string in the array defines attribute value 0x85, * the second attribute value 0x86 etc. */ public void setAttrValueTable(int page, String[] attrValueTable) { // clear entries in this.table! for (int i = 0; i < attrValueTable.length; i++) { if (attrValueTable[i] != null) { Object idx = new int[]{page, i + 0x085}; this.attrValueTable.put(attrValueTable[i], idx); } } } } kxml2-2.3.0/src/org/kxml2/wap/WbxmlParser.java0000644000175000017500000007654610446011152017224 0ustar neoneo/* Copyright (c) 2002,2003,2004 Stefan Haustein, Oberhausen, Rhld., Germany * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or * sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS * IN THE SOFTWARE. */ // Contributors: Bjorn Aadland, Chris Bartley, Nicola Fankhauser, // Victor Havin, Christian Kurzke, Bogdan Onoiu, // Elias Ross, Jain Sanjay, David Santoro. package org.kxml2.wap; import java.io.*; import java.util.Vector; import java.util.Hashtable; import org.xmlpull.v1.*; public class WbxmlParser implements XmlPullParser { static final String HEX_DIGITS = "0123456789abcdef"; /** Parser event type for Wbxml-specific events. The Wbxml event code can be * accessed with getWapCode() */ public static final int WAP_EXTENSION = 64; static final private String UNEXPECTED_EOF = "Unexpected EOF"; static final private String ILLEGAL_TYPE = "Wrong event type"; private InputStream in; private int TAG_TABLE = 0; private int ATTR_START_TABLE = 1; private int ATTR_VALUE_TABLE = 2; private String[] attrStartTable; private String[] attrValueTable; private String[] tagTable; private byte[] stringTable; private Hashtable cacheStringTable = null; private boolean processNsp; private int depth; private String[] elementStack = new String[16]; private String[] nspStack = new String[8]; private int[] nspCounts = new int[4]; private int attributeCount; private String[] attributes = new String[16]; private int nextId = -2; private Vector tables = new Vector(); private int version; private int publicIdentifierId; // StartTag current; // ParseEvent next; private String prefix; private String namespace; private String name; private String text; private Object wapExtensionData; private int wapCode; private int type; private boolean degenerated; private boolean isWhitespace; private String encoding; public boolean getFeature(String feature) { if (XmlPullParser .FEATURE_PROCESS_NAMESPACES .equals(feature)) return processNsp; else return false; } public String getInputEncoding() { return encoding; } public void defineEntityReplacementText( String entity, String value) throws XmlPullParserException { // just ignore, has no effect } public Object getProperty(String property) { return null; } public int getNamespaceCount(int depth) { if (depth > this.depth) throw new IndexOutOfBoundsException(); return nspCounts[depth]; } public String getNamespacePrefix(int pos) { return nspStack[pos << 1]; } public String getNamespaceUri(int pos) { return nspStack[(pos << 1) + 1]; } public String getNamespace(String prefix) { if ("xml".equals(prefix)) return "http://www.w3.org/XML/1998/namespace"; if ("xmlns".equals(prefix)) return "http://www.w3.org/2000/xmlns/"; for (int i = (getNamespaceCount(depth) << 1) - 2; i >= 0; i -= 2) { if (prefix == null) { if (nspStack[i] == null) return nspStack[i + 1]; } else if (prefix.equals(nspStack[i])) return nspStack[i + 1]; } return null; } public int getDepth() { return depth; } public String getPositionDescription() { StringBuffer buf = new StringBuffer( type < TYPES.length ? TYPES[type] : "unknown"); buf.append(' '); if (type == START_TAG || type == END_TAG) { if (degenerated) buf.append("(empty) "); buf.append('<'); if (type == END_TAG) buf.append('/'); if (prefix != null) buf.append("{" + namespace + "}" + prefix + ":"); buf.append(name); int cnt = attributeCount << 2; for (int i = 0; i < cnt; i += 4) { buf.append(' '); if (attributes[i + 1] != null) buf.append( "{" + attributes[i] + "}" + attributes[i + 1] + ":"); buf.append( attributes[i + 2] + "='" + attributes[i + 3] + "'"); } buf.append('>'); } else if (type == IGNORABLE_WHITESPACE); else if (type != TEXT) buf.append(getText()); else if (isWhitespace) buf.append("(whitespace)"); else { String text = getText(); if (text.length() > 16) text = text.substring(0, 16) + "..."; buf.append(text); } return buf.toString(); } public int getLineNumber() { return -1; } public int getColumnNumber() { return -1; } public boolean isWhitespace() throws XmlPullParserException { if (type != TEXT && type != IGNORABLE_WHITESPACE && type != CDSECT) exception(ILLEGAL_TYPE); return isWhitespace; } public String getText() { return text; } public char[] getTextCharacters(int[] poslen) { if (type >= TEXT) { poslen[0] = 0; poslen[1] = text.length(); char[] buf = new char[text.length()]; text.getChars(0, text.length(), buf, 0); return buf; } poslen[0] = -1; poslen[1] = -1; return null; } public String getNamespace() { return namespace; } public String getName() { return name; } public String getPrefix() { return prefix; } public boolean isEmptyElementTag() throws XmlPullParserException { if (type != START_TAG) exception(ILLEGAL_TYPE); return degenerated; } public int getAttributeCount() { return attributeCount; } public String getAttributeType(int index) { return "CDATA"; } public boolean isAttributeDefault(int index) { return false; } public String getAttributeNamespace(int index) { if (index >= attributeCount) throw new IndexOutOfBoundsException(); return attributes[index << 2]; } public String getAttributeName(int index) { if (index >= attributeCount) throw new IndexOutOfBoundsException(); return attributes[(index << 2) + 2]; } public String getAttributePrefix(int index) { if (index >= attributeCount) throw new IndexOutOfBoundsException(); return attributes[(index << 2) + 1]; } public String getAttributeValue(int index) { if (index >= attributeCount) throw new IndexOutOfBoundsException(); return attributes[(index << 2) + 3]; } public String getAttributeValue( String namespace, String name) { for (int i = (attributeCount << 2) - 4; i >= 0; i -= 4) { if (attributes[i + 2].equals(name) && (namespace == null || attributes[i].equals(namespace))) return attributes[i + 3]; } return null; } public int getEventType() throws XmlPullParserException { return type; } // TODO: Reuse resolveWapExtension here? Raw Wap extensions would still be accessible // via nextToken(); ....? public int next() throws XmlPullParserException, IOException { isWhitespace = true; int minType = 9999; while (true) { String save = text; nextImpl(); if (type < minType) minType = type; if (minType > CDSECT) continue; // no "real" event so far if (minType >= TEXT) { // text, see if accumulate if (save != null) text = text == null ? save : save + text; switch(peekId()) { case Wbxml.ENTITY: case Wbxml.STR_I: case Wbxml.STR_T: case Wbxml.LITERAL: case Wbxml.LITERAL_C: case Wbxml.LITERAL_A: case Wbxml.LITERAL_AC: continue; } } break; } type = minType; if (type > TEXT) type = TEXT; return type; } public int nextToken() throws XmlPullParserException, IOException { isWhitespace = true; nextImpl(); return type; } public int nextTag() throws XmlPullParserException, IOException { next(); if (type == TEXT && isWhitespace) next(); if (type != END_TAG && type != START_TAG) exception("unexpected type"); return type; } public String nextText() throws XmlPullParserException, IOException { if (type != START_TAG) exception("precondition: START_TAG"); next(); String result; if (type == TEXT) { result = getText(); next(); } else result = ""; if (type != END_TAG) exception("END_TAG expected"); return result; } public void require(int type, String namespace, String name) throws XmlPullParserException, IOException { if (type != this.type || (namespace != null && !namespace.equals(getNamespace())) || (name != null && !name.equals(getName()))) exception( "expected: " + (type == WAP_EXTENSION ? "WAP Ext." : (TYPES[type] + " {" + namespace + "}" + name))); } public void setInput(Reader reader) throws XmlPullParserException { exception("InputStream required"); } public void setInput(InputStream in, String enc) throws XmlPullParserException { this.in = in; try { version = readByte(); publicIdentifierId = readInt(); if (publicIdentifierId == 0) readInt(); int charset = readInt(); // skip charset if (null == enc){ switch (charset){ case 4: encoding = "ISO-8859-1"; break; case 106: encoding = "UTF-8"; break; // add more if you need them // http://www.iana.org/assignments/character-sets // case MIBenum: encoding = Name break; default: throw new UnsupportedEncodingException(""+charset); } }else{ encoding = enc; } int strTabSize = readInt(); stringTable = new byte[strTabSize]; int ok = 0; while(ok < strTabSize){ int cnt = in.read(stringTable, ok, strTabSize - ok); if(cnt <= 0) break; ok += cnt; } selectPage(0, true); selectPage(0, false); } catch (IOException e) { exception("Illegal input format"); } } public void setFeature(String feature, boolean value) throws XmlPullParserException { if (XmlPullParser.FEATURE_PROCESS_NAMESPACES.equals(feature)) processNsp = value; else exception("unsupported feature: " + feature); } public void setProperty(String property, Object value) throws XmlPullParserException { throw new XmlPullParserException("unsupported property: " + property); } // ---------------------- private / internal methods private final boolean adjustNsp() throws XmlPullParserException { boolean any = false; for (int i = 0; i < attributeCount << 2; i += 4) { // * 4 - 4; i >= 0; i -= 4) { String attrName = attributes[i + 2]; int cut = attrName.indexOf(':'); String prefix; if (cut != -1) { prefix = attrName.substring(0, cut); attrName = attrName.substring(cut + 1); } else if (attrName.equals("xmlns")) { prefix = attrName; attrName = null; } else continue; if (!prefix.equals("xmlns")) { any = true; } else { int j = (nspCounts[depth]++) << 1; nspStack = ensureCapacity(nspStack, j + 2); nspStack[j] = attrName; nspStack[j + 1] = attributes[i + 3]; if (attrName != null && attributes[i + 3].equals("")) exception("illegal empty namespace"); // prefixMap = new PrefixMap (prefixMap, attrName, attr.getValue ()); //System.out.println (prefixMap); System.arraycopy( attributes, i + 4, attributes, i, ((--attributeCount) << 2) - i); i -= 4; } } if (any) { for (int i = (attributeCount << 2) - 4; i >= 0; i -= 4) { String attrName = attributes[i + 2]; int cut = attrName.indexOf(':'); if (cut == 0) throw new RuntimeException( "illegal attribute name: " + attrName + " at " + this); else if (cut != -1) { String attrPrefix = attrName.substring(0, cut); attrName = attrName.substring(cut + 1); String attrNs = getNamespace(attrPrefix); if (attrNs == null) throw new RuntimeException( "Undefined Prefix: " + attrPrefix + " in " + this); attributes[i] = attrNs; attributes[i + 1] = attrPrefix; attributes[i + 2] = attrName; for (int j = (attributeCount << 2) - 4; j > i; j -= 4) if (attrName.equals(attributes[j + 2]) && attrNs.equals(attributes[j])) exception( "Duplicate Attribute: {" + attrNs + "}" + attrName); } } } int cut = name.indexOf(':'); if (cut == 0) exception("illegal tag name: " + name); else if (cut != -1) { prefix = name.substring(0, cut); name = name.substring(cut + 1); } this.namespace = getNamespace(prefix); if (this.namespace == null) { if (prefix != null) exception("undefined prefix: " + prefix); this.namespace = NO_NAMESPACE; } return any; } private final void setTable(int page, int type, String[] table) { if(stringTable != null){ throw new RuntimeException("setXxxTable must be called before setInput!"); } while(tables.size() < 3*page +3){ tables.addElement(null); } tables.setElementAt(table, page*3+type); } private final void exception(String desc) throws XmlPullParserException { throw new XmlPullParserException(desc, this, null); } private void selectPage(int nr, boolean tags) throws XmlPullParserException{ if(tables.size() == 0 && nr == 0) return; if(nr*3 > tables.size()) exception("Code Page "+nr+" undefined!"); if(tags) tagTable = (String[]) tables.elementAt(nr * 3 + TAG_TABLE); else { attrStartTable = (String[]) tables.elementAt(nr * 3 + ATTR_START_TABLE); attrValueTable = (String[]) tables.elementAt(nr * 3 + ATTR_VALUE_TABLE); } } private final void nextImpl() throws IOException, XmlPullParserException { String s; if (type == END_TAG) { depth--; } if (degenerated) { type = XmlPullParser.END_TAG; degenerated = false; return; } text = null; prefix = null; name = null; int id = peekId (); while(id == Wbxml.SWITCH_PAGE){ nextId = -2; selectPage(readByte(), true); id = peekId(); } nextId = -2; switch (id) { case -1 : type = XmlPullParser.END_DOCUMENT; break; case Wbxml.END : { int sp = (depth - 1) << 2; type = END_TAG; namespace = elementStack[sp]; prefix = elementStack[sp + 1]; name = elementStack[sp + 2]; } break; case Wbxml.ENTITY : { type = ENTITY_REF; char c = (char) readInt(); text = "" + c; name = "#" + ((int) c); } break; case Wbxml.STR_I : type = TEXT; text = readStrI(); break; case Wbxml.EXT_I_0 : case Wbxml.EXT_I_1 : case Wbxml.EXT_I_2 : case Wbxml.EXT_T_0 : case Wbxml.EXT_T_1 : case Wbxml.EXT_T_2 : case Wbxml.EXT_0 : case Wbxml.EXT_1 : case Wbxml.EXT_2 : case Wbxml.OPAQUE : type = WAP_EXTENSION; wapCode = id; wapExtensionData = parseWapExtension(id); break; case Wbxml.PI : throw new RuntimeException("PI curr. not supp."); // readPI; // break; case Wbxml.STR_T : { type = TEXT; text = readStrT(); } break; default : parseElement(id); } // } // while (next == null); // return next; } /** Overwrite this method to intercept all wap events */ public Object parseWapExtension(int id) throws IOException, XmlPullParserException { switch (id) { case Wbxml.EXT_I_0 : case Wbxml.EXT_I_1 : case Wbxml.EXT_I_2 : return readStrI(); case Wbxml.EXT_T_0 : case Wbxml.EXT_T_1 : case Wbxml.EXT_T_2 : return new Integer(readInt()); case Wbxml.EXT_0 : case Wbxml.EXT_1 : case Wbxml.EXT_2 : return null; case Wbxml.OPAQUE : { int count = readInt(); byte[] buf = new byte[count]; while(count > 0){ count -= in.read(buf, buf.length-count, count); } return buf; } // case OPAQUE default: exception("illegal id: "+id); return null; // dead code } // SWITCH } public void readAttr() throws IOException, XmlPullParserException { int id = readByte(); int i = 0; while (id != 1) { while(id == Wbxml.SWITCH_PAGE){ selectPage(readByte(), false); id = readByte(); } String name = resolveId(attrStartTable, id); StringBuffer value; int cut = name.indexOf('='); if (cut == -1) value = new StringBuffer(); else { value = new StringBuffer(name.substring(cut + 1)); name = name.substring(0, cut); } id = readByte(); while (id > 128 || id == Wbxml.SWITCH_PAGE || id == Wbxml.ENTITY || id == Wbxml.STR_I || id == Wbxml.STR_T || (id >= Wbxml.EXT_I_0 && id <= Wbxml.EXT_I_2) || (id >= Wbxml.EXT_T_0 && id <= Wbxml.EXT_T_2)) { switch (id) { case Wbxml.SWITCH_PAGE : selectPage(readByte(), false); break; case Wbxml.ENTITY : value.append((char) readInt()); break; case Wbxml.STR_I : value.append(readStrI()); break; case Wbxml.EXT_I_0 : case Wbxml.EXT_I_1 : case Wbxml.EXT_I_2 : case Wbxml.EXT_T_0 : case Wbxml.EXT_T_1 : case Wbxml.EXT_T_2 : case Wbxml.EXT_0 : case Wbxml.EXT_1 : case Wbxml.EXT_2 : case Wbxml.OPAQUE : value.append(resolveWapExtension(id, parseWapExtension(id))); break; case Wbxml.STR_T : value.append(readStrT()); break; default : value.append( resolveId(attrValueTable, id)); } id = readByte(); } attributes = ensureCapacity(attributes, i + 4); attributes[i++] = ""; attributes[i++] = null; attributes[i++] = name; attributes[i++] = value.toString(); attributeCount++; } } private int peekId () throws IOException { if (nextId == -2) { nextId = in.read (); } return nextId; } /** overwrite for own WAP extension handling in attributes and high level parsing * (above nextToken() level) */ protected String resolveWapExtension(int id, Object data){ if(data instanceof byte[]){ StringBuffer sb = new StringBuffer(); byte[] b = (byte[]) data; for (int i = 0; i < b.length; i++) { sb.append(HEX_DIGITS.charAt((b[i] >> 4) & 0x0f)); sb.append(HEX_DIGITS.charAt(b[i] & 0x0f)); } return sb.toString(); } return "$("+data+")"; } String resolveId(String[] tab, int id) throws IOException { int idx = (id & 0x07f) - 5; if (idx == -1){ wapCode = -1; return readStrT(); } if (idx < 0 || tab == null || idx >= tab.length || tab[idx] == null) throw new IOException("id " + id + " undef."); wapCode = idx+5; return tab[idx]; } void parseElement(int id) throws IOException, XmlPullParserException { type = START_TAG; name = resolveId(tagTable, id & 0x03f); attributeCount = 0; if ((id & 128) != 0) { readAttr(); } degenerated = (id & 64) == 0; int sp = depth++ << 2; // transfer to element stack elementStack = ensureCapacity(elementStack, sp + 4); elementStack[sp + 3] = name; if (depth >= nspCounts.length) { int[] bigger = new int[depth + 4]; System.arraycopy(nspCounts, 0, bigger, 0, nspCounts.length); nspCounts = bigger; } nspCounts[depth] = nspCounts[depth - 1]; for (int i = attributeCount - 1; i > 0; i--) { for (int j = 0; j < i; j++) { if (getAttributeName(i) .equals(getAttributeName(j))) exception( "Duplicate Attribute: " + getAttributeName(i)); } } if (processNsp) adjustNsp(); else namespace = ""; elementStack[sp] = namespace; elementStack[sp + 1] = prefix; elementStack[sp + 2] = name; } private final String[] ensureCapacity( String[] arr, int required) { if (arr.length >= required) return arr; String[] bigger = new String[required + 16]; System.arraycopy(arr, 0, bigger, 0, arr.length); return bigger; } int readByte() throws IOException { int i = in.read(); if (i == -1) throw new IOException("Unexpected EOF"); return i; } int readInt() throws IOException { int result = 0; int i; do { i = readByte(); result = (result << 7) | (i & 0x7f); } while ((i & 0x80) != 0); return result; } String readStrI() throws IOException { ByteArrayOutputStream buf = new ByteArrayOutputStream(); boolean wsp = true; while (true){ int i = in.read(); if (i == 0){ break; } if (i == -1){ throw new IOException(UNEXPECTED_EOF); } if (i > 32){ wsp = false; } buf.write(i); } isWhitespace = wsp; String result = new String(buf.toByteArray(), encoding); buf.close(); return result; } String readStrT() throws IOException { int pos = readInt(); // As the main reason of stringTable is compression we build a cache of Strings // stringTable is supposed to help create Strings from parts which means some cache hit rate // This will help to minimize the Strings created when invoking readStrT() repeatedly if (cacheStringTable == null){ //Lazy init if device is not using StringTable but inline 0x03 strings cacheStringTable = new Hashtable(); } String forReturn = (String) cacheStringTable.get(new Integer(pos)); if (forReturn == null){ int end = pos; while(end < stringTable.length && stringTable[end] != '\0'){ end++; } forReturn = new String(stringTable, pos, end-pos, encoding); cacheStringTable.put(new Integer(pos), forReturn); } return forReturn; } /** * Sets the tag table for a given page. * The first string in the array defines tag 5, the second tag 6 etc. */ public void setTagTable(int page, String[] table) { setTable(page, TAG_TABLE, table); // this.tagTable = tagTable; // if (page != 0) // throw new RuntimeException("code pages curr. not supp."); } /** Sets the attribute start Table for a given page. * The first string in the array defines attribute * 5, the second attribute 6 etc. Please use the * character '=' (without quote!) as delimiter * between the attribute name and the (start of the) value */ public void setAttrStartTable( int page, String[] table) { setTable(page, ATTR_START_TABLE, table); } /** Sets the attribute value Table for a given page. * The first string in the array defines attribute value 0x85, * the second attribute value 0x86 etc. */ public void setAttrValueTable( int page, String[] table) { setTable(page, ATTR_VALUE_TABLE, table); } /** Returns the token ID for start tags or the event type for wap proprietary events * such as OPAQUE. */ public int getWapCode(){ return wapCode; } public Object getWapExtensionData(){ return wapExtensionData; } }kxml2-2.3.0/contrib/0000755000175000017500000000000010442014252012327 5ustar neoneokxml2-2.3.0/contrib/Wml.java0000644000175000017500000001102510437004350013732 0ustar neoneopackage org.kxml2.wap.wml; import org.kxml2.wap.*; /** This class contains the wml coding tables for elements * and attributes needed by the WmlParser. */ public abstract class Wml { /** Creates a WbxmlParser with the WML code pages set */ public static WbxmlParser createParser() { WbxmlParser p = new WbxmlParser(); p.setTagTable(0, TAG_TABLE); p.setAttrStartTable(0, ATTR_START_TABLE); p.setAttrValueTable(0, ATTR_VALUE_TABLE); return p; } public static WbxmlSerializer createSerializer() { WbxmlSerializer s = new WbxmlSerializer(); s.setTagTable(0, TAG_TABLE); s.setAttrStartTable(0, ATTR_START_TABLE); s.setAttrValueTable(0, ATTR_VALUE_TABLE); return s; } public static final String [] TAG_TABLE = { null, // 05 null, // 06 null, // 07 null, // 08 null, // 09 null, // 0A null, // 0B null, // 0C null, // 0D null, // 0E null, // 0F null, // 10 null, // 11 null, // 12 null, // 13 null, // 14 null, // 15 null, // 16 null, // 17 null, // 18 null, // 19 null, // 1A null, // 1B "a", // 1C "td", // 1D "tr", // 1E "table", // 1F "p", // 20 "postfield", // 21 "anchor", // 22 "access", // 23 "b", // 24 "big", // 25 "br", // 26 "card", // 27 "do", // 28 "em", // 29 "fieldset", // 2A "go", // 2B "head", // 2C "i", // 2D "img", // 2E "input", // 2F "meta", // 30 "noop", // 31 "prev", // 32 "onevent", // 33 "optgroup", // 34 "option", // 35 "refresh", // 36 "select", // 37 "small", // 38 "strong", // 39 null, // 3A "template", // 3B "timer", // 3C "u", // 3D "setvar", // 3E "wml", // 3F }; public static final String [] ATTR_START_TABLE = { "accept-charset", // 05 "align=bottom", // 06 "align=center", // 07 "align=left", // 08 "align=middle", // 09 "align=right", // 0A "align=top", // 0B "alt", // 0C "content", // 0D null, // 0E "domain", // 0F "emptyok=false", // 10 "emptyok=true", // 11 "format", // 12 "height", // 13 "hspace", // 14 "ivalue", // 15 "iname", // 16 null, // 17 "label", // 18 "localsrc", // 19 "maxlength", // 1A "method=get", // 1B "method=post", // 1C "mode=nowrap", // 1D "mode=wrap", // 1E "multiple=false", // 1F "multiple=true", // 20 "name", // 21 "newcontext=false", // 22 "newcontext=true", // 23 "onpick", // 24 "onenterbackward", // 25 "onenterforward", // 26 "ontimer", // 27 "optimal=false", // 28 "optimal=true", // 29 "path", // 2A null, // 2B null, // 2C null, // 2D "scheme", // 2E "sendreferer=false", // 2F "sendreferer=true", // 30 "size", // 31 "src", // 32 "ordered=true", // 33 "ordered=false", // 34 "tabindex", // 35 "title", // 36 "type", // 37 "type=accept", // 38 "type=delete", // 39 "type=help", // 3A "type=password", // 3B "type=onpick", // 3C "type=onenterbackward", // 3D "type=onenterforward", // 3E "type=ontimer", // 3F null, // 40 null, // 41 null, // 42 null, // 43 null, // 44 "type=options", // 45 "type=prev", // 46 "type=reset", // 47 "type=text", // 48 "type=vnd.", // 49 "href", // 4A "href=http://", // 4B "href=https://", // 4C "value", // 4D "vspace", // 4E "width", // 4F "xml:lang", // 50 null, // 51 "align", // 52 "columns", // 53 "class", // 54 "id", // 55 "forua=false", // 56 "forua=true", // 57 "src=http://", // 58 "src=https://", // 59 "http-equiv", // 5A "http-equiv=Content-Type", // 5B "content=application/vnd.wap.wmlc;charset=", // 5C "http-equiv=Expires", // 5D null, // 5E null, // 5F }; /* * 85 null is added, so need to add offset now. */ public static final String [] ATTR_VALUE_TABLE = { null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null, null,null,null,null,null,null,null,null,null,null, null,null,null,null,null, ".com/", // 85 ".edu/", // 86 ".net/", // 87 ".org/", // 88 "accept", // 89 "bottom", // 8A "clear", // 8B "delete", // 8C "help", // 8D "http://", // 8E "http://www.", // 8F "https://", // 90 "https://www.", // 91 null, // 92 "middle", // 93 "nowrap", // 94 "onpick", // 95 "onenterbackward", // 96 "onenterforward", // 97 "ontimer", // 98 "options", // 99 "password", // 9A "reset", // 9B null, // 9C "text", // 9D "top", // 9E "unknown", // 9F "wrap", // A0 "www.", // A1 }; } kxml2-2.3.0/contrib/WbxmlSerializer.java0000644000175000017500000003470610437004342016332 0ustar neoneo/* Copyright (c) 2002,2003, Stefan Haustein, Oberhausen, Rhld., Germany * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or * sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS * IN THE SOFTWARE. */ //Contributors: Bogdan Onoiu (Genderal character encoding abstraction and UTF-8 Support) package org.kxml2.wap; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStream; import java.io.UnsupportedEncodingException; import java.io.Writer; import java.util.HashMap; import java.util.Hashtable; import java.util.Iterator; import java.util.Vector; import org.xmlpull.v1.XmlSerializer; // TODO: make some of the "direct" WBXML token writing methods public?? /** * A class for writing WBXML. * */ @SuppressWarnings("unchecked") public class WbxmlSerializer implements XmlSerializer { public static final HashMap HEXMAP = new HashMap(); static { HEXMAP.put("0", new Integer(0)); HEXMAP.put("1", new Integer(1)); HEXMAP.put("2", new Integer(2)); HEXMAP.put("3", new Integer(3)); HEXMAP.put("4", new Integer(4)); HEXMAP.put("5", new Integer(5)); HEXMAP.put("6", new Integer(6)); HEXMAP.put("7", new Integer(7)); HEXMAP.put("8", new Integer(8)); HEXMAP.put("9", new Integer(9)); HEXMAP.put("A", new Integer(10)); HEXMAP.put("B", new Integer(11)); HEXMAP.put("C", new Integer(12)); HEXMAP.put("D", new Integer(13)); HEXMAP.put("E", new Integer(14)); HEXMAP.put("F", new Integer(15)); } Hashtable stringTable = new Hashtable(); OutputStream out; ByteArrayOutputStream buf = new ByteArrayOutputStream(); ByteArrayOutputStream stringTableBuf = new ByteArrayOutputStream(); String pending; int depth; String name; String namespace; Vector attributes = new Vector(); Hashtable attrStartTable = new Hashtable(); Hashtable attrValueTable = new Hashtable(); Hashtable tagTable = new Hashtable(); private int attrPage; private int tagPage; private String encoding = null; public XmlSerializer attribute(String namespace, String name, String value) { attributes.addElement(name); attributes.addElement(value); return this; } public void cdsect(String cdsect) throws IOException { text(cdsect); } /* silently ignore comment */ public void comment(String comment) { } public void docdecl(String docdecl) { throw new RuntimeException("Cannot write docdecl for WBXML"); } public void entityRef(String er) { throw new RuntimeException("EntityReference not supported for WBXML"); } public int getDepth() { return depth; } public boolean getFeature(String name) { return false; } public String getNamespace() { throw new RuntimeException("NYI"); } public String getName() { throw new RuntimeException("NYI"); } public String getPrefix(String nsp, boolean create) { throw new RuntimeException("NYI"); } public Object getProperty(String name) { return null; } public void ignorableWhitespace(String sp) { } public void endDocument() throws IOException { writeInt(out, stringTableBuf.size()); // write StringTable out.write(stringTableBuf.toByteArray()); // write buf out.write(buf.toByteArray()); // ready! out.flush(); } /** * ATTENTION: flush cannot work since Wbxml documents require need * buffering. Thus, this call does nothing. */ public void flush() { } public void checkPending(boolean degenerated) throws IOException { if (pending == null || pending.length() == 0) return; int len = attributes.size(); int[] idx = (int[]) this.tagTable.get(pending); // if no entry in known table, then add as literal if (idx == null) { buf.write(len == 0 ? (degenerated ? Wbxml.LITERAL : Wbxml.LITERAL_C) : (degenerated ? Wbxml.LITERAL_A : Wbxml.LITERAL_AC)); writeStrT(pending); } else { if (idx[0] != tagPage) { tagPage = idx[0]; buf.write(Wbxml.SWITCH_PAGE); buf.write(tagPage); } buf.write(len == 0 ? (degenerated ? idx[1] : idx[1] | 64) : (degenerated ? idx[1] | 128 : idx[1] | 192)); } // adding attributes if there are some. // the orignal processing is not suitable for WV att table, // this is a modified one, but i can not promise this will // be right. for (int i = 0; i < len;) { int start = i; boolean matchInWhole = false; // first try to match the attributes as a whole. String k = (String) attributes.elementAt(i); String v = (String) attributes.elementAt(++i); String attr = k + "=" + v; for (Iterator it = attrStartTable.keySet().iterator(); it.hasNext();) { String attrInTable = (String) it.next(); if (attr.toLowerCase().startsWith(attrInTable.toLowerCase())) { idx = (int[]) attrStartTable.get(attrInTable); // seems no need here, since we only have one // attrStartTable. // i don't know why the orignal author add this code // anywhere, // careless copy and paste? // if(idx[0] != attrPage){ // attrPage = idx[0]; // buf.write(0); // buf.write(attrPage); // } buf.write(idx[1]); // add in line string if needed if (attr.length() > attrInTable.length()) { String strInLine = attr.substring(attrInTable.length()); buf.write(Wbxml.STR_I); writeStrI(buf, strInLine); } ++i; matchInWhole = true; break; } } if (!matchInWhole) { i = start; idx = (int[]) attrStartTable.get(attributes.elementAt(i)); if (idx == null) { buf.write(Wbxml.LITERAL); writeStrT((String) attributes.elementAt(i)); } else { if (idx[0] != attrPage) { attrPage = idx[0]; buf.write(0); buf.write(attrPage); } buf.write(idx[1]); } idx = (int[]) attrValueTable.get(attributes.elementAt(++i)); if (idx == null) { buf.write(Wbxml.STR_I); writeStrI(buf, (String) attributes.elementAt(i)); } else { if (idx[0] != attrPage) { attrPage = idx[0]; buf.write(0); buf.write(attrPage); } buf.write(idx[1]); } ++i; } } if (len > 0) buf.write(Wbxml.END); pending = null; attributes.removeAllElements(); } public void processingInstruction(String pi) { throw new RuntimeException("PI NYI"); } public void setFeature(String name, boolean value) { throw new IllegalArgumentException("unknown feature " + name); } public void setOutput(Writer writer) { throw new RuntimeException("Wbxml requires an OutputStream!"); } public void setOutput(OutputStream out, String encoding) throws IOException { if (encoding != null) throw new IllegalArgumentException( "encoding not yet supported for WBXML"); this.out = out; buf = new ByteArrayOutputStream(); stringTableBuf = new ByteArrayOutputStream(); // ok, write header } public void setPrefix(String prefix, String nsp) { throw new RuntimeException("NYI"); } public void setProperty(String property, Object value) { throw new IllegalArgumentException("unknown property " + property); } public void startDocument(String s, Boolean b) throws IOException { out.write(0x03); // version 1.3 // http://www.openmobilealliance.org/tech/omna/omna-wbxml-public-docid.htm out.write(0x01); // unknown or missing public identifier // default encoding is UTF-8 String[] encodings = {"UTF-8", "ISO-8859-1"}; if (s == null || s.toUpperCase().equals(encodings[0])) { encoding = encodings[0]; out.write(106); } else if (true == s.toUpperCase().equals(encodings[1])) { encoding = encodings[1]; out.write(0x04); } else { throw new UnsupportedEncodingException(s); } } public XmlSerializer startTag(String namespace, String name) throws IOException { if (namespace != null && !"".equals(namespace)) throw new RuntimeException("NSP NYI"); // current = new State(current, prefixMap, name); checkPending(false); pending = name; depth++; return this; } public XmlSerializer text(char[] chars, int start, int len) throws IOException { checkPending(false); buf.write(Wbxml.STR_I); writeStrI(buf, new String(chars, start, len)); return this; } public XmlSerializer text(String text) throws IOException { checkPending(false); int[] idx = (int[]) this.attrValueTable.get(text); if (idx == null) { int value = -1; try { value = Integer.parseInt(text); } catch (NumberFormatException ex) { ; } byte[] stream = buf.toByteArray(); byte lastByte = stream[stream.length - 1]; int tag = lastByte & 63; if (value > -1 && ((tagPage == 0x00 && (tag == 0x0B || tag == 0x0F || tag == 0x3C)) || (tagPage == 0x01 && (tag == 0x32 || tag == 0x1C)))) { // "Code[0x00, 0x0B]", "ContentSize[0x00, 0x0F]", // *"DateTime[0x00, 0x11]", "Validity[0x00, 0x3C]", // "TimeToLive[0x01, 0x32]", "KeepAliveTime[0x01, 0x1C]" is // integer value and need to // be opaque encoded ("*DateTime" is not realized, it is // somewhat so complex and can be substitude with inline // string according to the conformance document). buf.write(Wbxml.OPAQUE); byte[] opaqued = opaqueEncode(text); buf.write(opaqued.length); buf.write(opaqueEncode(text)); } else { buf.write(Wbxml.STR_I); writeStrI(buf, text); } } else { buf.write(Wbxml.EXT_T_0); buf.write(idx[1]); } return this; } /** * since I only encode a int value here, so no need to determine the page * code and the tag code in the method. * * but if it is a full realization, this is a must. * * @param v * @return */ public byte[] opaqueEncode(String v) { String hexString = "00"; try { int iValue = Integer.parseInt(v); hexString = Integer.toHexString(iValue); } catch (NumberFormatException ex) { ; } if (hexString.length() % 2 != 0) hexString = "0" + hexString; ByteArrayOutputStream baos = new ByteArrayOutputStream(); for (int i = 0; i < hexString.length(); i = i + 2) { baos.write(hex2Byte(hexString.substring(i, i + 2))); } return baos.toByteArray(); } /** * hex is a string with the length of two and holds 2 hex digits(big * endian). * * @param hexStr * string holds two hex digits. * @return int value of the byte */ @SuppressWarnings("unchecked") public int hex2Byte(String hexStr) { if (hexStr.length() != 2) { throw new RuntimeException( "only two hex digits are valid, input unvalid"); } hexStr = hexStr.toUpperCase(); String hexH = hexStr.substring(0, 1); String hexL = hexStr.substring(1, 2); if (!HEXMAP.keySet().contains(hexH) || !HEXMAP.keySet().contains(hexL)) { throw new RuntimeException( "unvalid hex digits found, input unvalid"); } int high = ((Integer) HEXMAP.get(hexH)).intValue() << 4; int low = ((Integer) HEXMAP.get(hexL)).intValue(); return (high + low); } public XmlSerializer endTag(String namespace, String name) throws IOException { if (pending != null) checkPending(true); else buf.write(Wbxml.END); depth--; return this; } /** currently ignored! */ public void writeLegacy(int type, String data) { } // ------------- internal methods -------------------------- static void writeInt(OutputStream out, int i) throws IOException { byte[] buf = new byte[5]; int idx = 0; do { buf[idx++] = (byte) (i & 0x7f); i = i >> 7; } while (i != 0); while (idx > 1) { out.write(buf[--idx] | 0x80); } out.write(buf[0]); } void writeStrI(OutputStream out, String s) throws IOException { /* * below is the orginal implementation, * it totally ignores the character set, * but write the int unicode value of every * single character in the string, which * is not suitable here. for (int i = 0; i < s.length(); i++) { out.write((byte) s.charAt(i)); } */ byte[] bs = s.getBytes(encoding); out.write(bs); out.write(0x00); } void writeStrT(String s) throws IOException { Integer idx = (Integer) stringTable.get(s); if (idx == null) { idx = new Integer(stringTableBuf.size()); stringTable.put(s, idx); writeStrI(stringTableBuf, s); stringTableBuf.flush(); } writeInt(buf, idx.intValue()); } /** * Sets the tag table for a given page. The first string in the array * defines tag 5, the second tag 6 etc. */ @SuppressWarnings("unchecked") public void setTagTable(int page, String[] tagTable) { if (page < 0 || tagTable.length == 0) return; for (int i = 0; i < tagTable.length; i++) { if (tagTable[i] != null) { Object idx = new int[]{page, i + 5}; this.tagTable.put(tagTable[i], idx); } } } /** * Sets the attribute start Table for a given page. The first string in the * array defines attribute 5, the second attribute 6 etc. Please use the * character '=' (without quote!) as delimiter between the attribute name * and the (start of the) value */ @SuppressWarnings("unchecked") public void setAttrStartTable(int page, String[] attrStartTable) { for (int i = 0; i < attrStartTable.length; i++) { if (attrStartTable[i] != null) { Object idx = new int[]{page, i + 5}; this.attrStartTable.put(attrStartTable[i], idx); } } } /** * Sets the attribute value Table for a given page. The first string in the * array defines attribute value 0x85, the second attribute value 0x86 etc. * * !!!!! no need to add 0x85 to wml attrValueTable now, since I insert 85 * "null"s to the Wml attribute value table already, and by doing this, the * method is compatible with WV attrValueTable. */ @SuppressWarnings("unchecked") public void setAttrValueTable(int page, String[] attrValueTable) { // clear entries in this.table! for (int i = 0; i < attrValueTable.length; i++) { if (attrValueTable[i] != null) { Object idx = new int[]{page, i}; this.attrValueTable.put(attrValueTable[i], idx); } } } }kxml2-2.3.0/contrib/WbxmlParser.java0000644000175000017500000007647010437004354015464 0ustar neoneo/* Copyright (c) 2002,2003,2004 Stefan Haustein, Oberhausen, Rhld., Germany * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or * sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS * IN THE SOFTWARE. */ // Contributors: Bjorn Aadland, Chris Bartley, Nicola Fankhauser, // Victor Havin, Christian Kurzke, Bogdan Onoiu, // Jain Sanjay, David Santoro. package org.kxml2.wap; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.Reader; import java.io.UnsupportedEncodingException; import java.util.Hashtable; import java.util.Vector; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; public class WbxmlParser implements XmlPullParser { public static final int WAP_EXTENSION = 64; static final private String UNEXPECTED_EOF = "Unexpected EOF"; static final private String ILLEGAL_TYPE = "Wrong event type"; private InputStream in; private int TAG_TABLE = 0; private int ATTR_START_TABLE = 1; private int ATTR_VALUE_TABLE = 2; private String[] attrStartTable; private String[] attrValueTable; private String[] tagTable; private byte[] stringTable; private Hashtable cacheStringTable = null; private boolean processNsp; private int depth; private String[] elementStack = new String[16]; private String[] nspStack = new String[8]; private int[] nspCounts = new int[4]; private int attributeCount; private String[] attributes = new String[16]; private int nextId = -2; private Vector tables = new Vector(); int version; int publicIdentifierId; int charSet; // StartTag current; // ParseEvent next; private String prefix; private String namespace; private String name; private String text; //private String encoding; private Object wapExtensionData; private int wapExtensionCode; private int type; private int codePage; private boolean degenerated; private boolean isWhitespace; private String encoding = null; public boolean getFeature(String feature) { if (XmlPullParser .FEATURE_PROCESS_NAMESPACES .equals(feature)) return processNsp; else return false; } public String getInputEncoding() { // should return someting depending on charSet here!!!!! return encoding; } public void defineEntityReplacementText( String entity, String value) throws XmlPullParserException { // just ignore, has no effect } public Object getProperty(String property) { return null; } public int getNamespaceCount(int depth) { if (depth > this.depth) throw new IndexOutOfBoundsException(); return nspCounts[depth]; } public String getNamespacePrefix(int pos) { return nspStack[pos << 1]; } public String getNamespaceUri(int pos) { return nspStack[(pos << 1) + 1]; } public String getNamespace(String prefix) { if ("xml".equals(prefix)) return "http://www.w3.org/XML/1998/namespace"; if ("xmlns".equals(prefix)) return "http://www.w3.org/2000/xmlns/"; for (int i = (getNamespaceCount(depth) << 1) - 2; i >= 0; i -= 2) { if (prefix == null) { if (nspStack[i] == null) return nspStack[i + 1]; } else if (prefix.equals(nspStack[i])) return nspStack[i + 1]; } return null; } public int getDepth() { return depth; } public String getPositionDescription() { StringBuffer buf = new StringBuffer( type < TYPES.length ? TYPES[type] : "unknown"); buf.append(' '); if (type == START_TAG || type == END_TAG) { if (degenerated) buf.append("(empty) "); buf.append('<'); if (type == END_TAG) buf.append('/'); if (prefix != null) buf.append("{" + namespace + "}" + prefix + ":"); buf.append(name); int cnt = attributeCount << 2; for (int i = 0; i < cnt; i += 4) { buf.append(' '); if (attributes[i + 1] != null) buf.append( "{" + attributes[i] + "}" + attributes[i + 1] + ":"); buf.append( attributes[i + 2] + "='" + attributes[i + 3] + "'"); } buf.append('>'); } else if (type == IGNORABLE_WHITESPACE); else if (type != TEXT) buf.append(getText()); else if (isWhitespace) buf.append("(whitespace)"); else { String text = getText(); if (text.length() > 16) text = text.substring(0, 16) + "..."; buf.append(text); } return buf.toString(); } public int getLineNumber() { return -1; } public int getColumnNumber() { return -1; } public boolean isWhitespace() throws XmlPullParserException { if (type != TEXT && type != IGNORABLE_WHITESPACE && type != CDSECT) exception(ILLEGAL_TYPE); return isWhitespace; } public String getText() { return text; } public char[] getTextCharacters(int[] poslen) { if (type >= TEXT) { poslen[0] = 0; poslen[1] = text.length(); char[] buf = new char[text.length()]; text.getChars(0, text.length(), buf, 0); return buf; } poslen[0] = -1; poslen[1] = -1; return null; } public String getNamespace() { return namespace; } public String getName() { return name; } public String getPrefix() { return prefix; } public boolean isEmptyElementTag() throws XmlPullParserException { if (type != START_TAG) exception(ILLEGAL_TYPE); return degenerated; } public int getAttributeCount() { return attributeCount; } public String getAttributeType(int index) { return "CDATA"; } public boolean isAttributeDefault(int index) { return false; } public String getAttributeNamespace(int index) { if (index >= attributeCount) throw new IndexOutOfBoundsException(); return attributes[index << 2]; } public String getAttributeName(int index) { if (index >= attributeCount) throw new IndexOutOfBoundsException(); return attributes[(index << 2) + 2]; } public String getAttributePrefix(int index) { if (index >= attributeCount) throw new IndexOutOfBoundsException(); return attributes[(index << 2) + 1]; } public String getAttributeValue(int index) { if (index >= attributeCount) throw new IndexOutOfBoundsException(); return attributes[(index << 2) + 3]; } public String getAttributeValue( String namespace, String name) { for (int i = (attributeCount << 2) - 4; i >= 0; i -= 4) { if (attributes[i + 2].equals(name) && (namespace == null || attributes[i].equals(namespace))) return attributes[i + 3]; } return null; } public int getEventType() throws XmlPullParserException { return type; } public int next() throws XmlPullParserException, IOException { isWhitespace = true; int minType = 9999; while (true) { String save = text; nextImpl(); if (type < minType) minType = type; if (minType > CDSECT) continue; // no "real" event so far if (minType >= TEXT) { // text, see if accumulate if (save != null) text = text == null ? save : save + text; switch(peekId()) { case Wbxml.ENTITY: case Wbxml.STR_I: case Wbxml.LITERAL: case Wbxml.LITERAL_C: case Wbxml.LITERAL_A: case Wbxml.LITERAL_AC: continue; } } break; } type = minType; if (type > TEXT) type = TEXT; return type; } public int nextToken() throws XmlPullParserException, IOException { isWhitespace = true; nextImpl(); return type; } public int nextTag() throws XmlPullParserException, IOException { next(); if (type == TEXT && isWhitespace) next(); if (type != END_TAG && type != START_TAG) exception("unexpected type"); return type; } public String nextText() throws XmlPullParserException, IOException { if (type != START_TAG) exception("precondition: START_TAG"); next(); String result; if (type == TEXT) { result = getText(); next(); } else result = ""; if (type != END_TAG) exception("END_TAG expected"); return result; } public void require(int type, String namespace, String name) throws XmlPullParserException, IOException { if (type != this.type || (namespace != null && !namespace.equals(getNamespace())) || (name != null && !name.equals(getName()))) exception( "expected: " + TYPES[type] + " {" + namespace + "}" + name); } public void setInput(Reader reader) throws XmlPullParserException { exception("InputStream required"); } public void setInput(InputStream in, String enc) throws XmlPullParserException { this.in = in; try { version = readByte(); publicIdentifierId = readInt(); if (publicIdentifierId == 0) readInt(); int charset = readInt(); // skip charset if (null == enc){ switch (charset){ case 4: encoding = "ISO-8859-1"; break; case 106: encoding = "UTF-8"; break; // add more if you need them // http://www.iana.org/assignments/character-sets // case MIBenum: encoding = Name break; default: throw new UnsupportedEncodingException(""+charset); } }else{ encoding = enc; } int strTabSize = readInt(); stringTable = new byte[strTabSize]; int ok = 0; while(ok < strTabSize){ int cnt = in.read(stringTable, ok, strTabSize - ok); if(cnt <= 0) break; ok += cnt; } selectPage(0, true); selectPage(0, false); } catch (IOException e) { exception("Illegal input format"); } } public void setFeature(String feature, boolean value) throws XmlPullParserException { if (XmlPullParser.FEATURE_PROCESS_NAMESPACES.equals(feature)) processNsp = value; else exception("unsupported feature: " + feature); } public void setProperty(String property, Object value) throws XmlPullParserException { throw new XmlPullParserException("unsupported property: " + property); } // ---------------------- private / internal methods private final boolean adjustNsp() throws XmlPullParserException { boolean any = false; for (int i = 0; i < attributeCount << 2; i += 4) { // * 4 - 4; i >= 0; i -= 4) { String attrName = attributes[i + 2]; int cut = attrName.indexOf(':'); String prefix; if (cut != -1) { prefix = attrName.substring(0, cut); attrName = attrName.substring(cut + 1); } else if (attrName.equals("xmlns")) { prefix = attrName; attrName = null; } else continue; if (!prefix.equals("xmlns")) { any = true; } else { int j = (nspCounts[depth]++) << 1; nspStack = ensureCapacity(nspStack, j + 2); nspStack[j] = attrName; nspStack[j + 1] = attributes[i + 3]; if (attrName != null && attributes[i + 3].equals("")) exception("illegal empty namespace"); // prefixMap = new PrefixMap (prefixMap, attrName, attr.getValue ()); //System.out.println (prefixMap); System.arraycopy( attributes, i + 4, attributes, i, ((--attributeCount) << 2) - i); i -= 4; } } if (any) { for (int i = (attributeCount << 2) - 4; i >= 0; i -= 4) { String attrName = attributes[i + 2]; int cut = attrName.indexOf(':'); if (cut == 0) throw new RuntimeException( "illegal attribute name: " + attrName + " at " + this); else if (cut != -1) { String attrPrefix = attrName.substring(0, cut); attrName = attrName.substring(cut + 1); String attrNs = getNamespace(attrPrefix); if (attrNs == null) throw new RuntimeException( "Undefined Prefix: " + attrPrefix + " in " + this); attributes[i] = attrNs; attributes[i + 1] = attrPrefix; attributes[i + 2] = attrName; for (int j = (attributeCount << 2) - 4; j > i; j -= 4) if (attrName.equals(attributes[j + 2]) && attrNs.equals(attributes[j])) exception( "Duplicate Attribute: {" + attrNs + "}" + attrName); } } } int cut = name.indexOf(':'); if (cut == 0) exception("illegal tag name: " + name); else if (cut != -1) { prefix = name.substring(0, cut); name = name.substring(cut + 1); } this.namespace = getNamespace(prefix); if (this.namespace == null) { if (prefix != null) exception("undefined prefix: " + prefix); this.namespace = NO_NAMESPACE; } return any; } private final void setTable(int page, int type, String[] table) { if(stringTable != null){ throw new RuntimeException("setXxxTable must be called before setInput!"); } while(tables.size() < 3*page +3){ tables.addElement(null); } tables.setElementAt(table, page*3+type); } private final void exception(String desc) throws XmlPullParserException { throw new XmlPullParserException(desc, this, null); } private void selectPage(int nr, boolean tags) throws XmlPullParserException{ if(tables.size() == 0 && nr == 0) return; if(nr*3 > tables.size()) exception("Code Page "+nr+" undefined!"); if(tags) tagTable = (String[]) tables.elementAt(nr * 3 + TAG_TABLE); else { attrStartTable = (String[]) tables.elementAt(nr * 3 + ATTR_START_TABLE); attrValueTable = (String[]) tables.elementAt(nr * 3 + ATTR_VALUE_TABLE); } } private final void nextImpl() throws IOException, XmlPullParserException { if (type == END_TAG) { depth--; } if (degenerated) { type = XmlPullParser.END_TAG; degenerated = false; return; } text = null; prefix = null; name = null; int id = peekId (); while(id == Wbxml.SWITCH_PAGE){ nextId = -2; selectPage(readByte(), true); id = peekId(); } nextId = -2; switch (id) { case -1 : type = XmlPullParser.END_DOCUMENT; break; case Wbxml.END : { int sp = (depth - 1) << 2; type = END_TAG; namespace = elementStack[sp]; prefix = elementStack[sp + 1]; name = elementStack[sp + 2]; } break; case Wbxml.ENTITY : { type = ENTITY_REF; char c = (char) readInt(); text = "" + c; name = "#" + ((int) c); } break; case Wbxml.STR_I : type = TEXT; text = readStrI(); break; case Wbxml.EXT_I_0 : case Wbxml.EXT_I_1 : case Wbxml.EXT_I_2 : case Wbxml.EXT_T_0 : case Wbxml.EXT_T_1 : case Wbxml.EXT_T_2 : case Wbxml.EXT_0 : case Wbxml.EXT_1 : case Wbxml.EXT_2 : case Wbxml.OPAQUE : { parseWapExtension(id); if (this.wapExtensionData != null) { type = TEXT; text = (String) this.wapExtensionData; this.wapExtensionData = null; } break; } case Wbxml.PI : throw new RuntimeException("PI curr. not supp."); // readPI; // break; case Wbxml.STR_T : { type = TEXT; text = readStrT(); } break; default : parseElement(id); } // } // while (next == null); // return next; } public void parseWapExtension(int id) throws IOException, XmlPullParserException { type = WAP_EXTENSION; wapExtensionCode = id; switch (id) { case Wbxml.EXT_I_0 : case Wbxml.EXT_I_1 : case Wbxml.EXT_I_2 : wapExtensionData = readStrI(); break; case Wbxml.EXT_T_0 : case Wbxml.EXT_T_1 : case Wbxml.EXT_T_2 : int attId = readInt(); wapExtensionData = resolveAttributeId(attrValueTable, attId); break; case Wbxml.EXT_0 : case Wbxml.EXT_1 : case Wbxml.EXT_2 : break; case Wbxml.OPAQUE : { int len = readInt(); byte[] buf = new byte[len]; for (int i = 0; i < len; i++) {// enhance with blockread! buf[i] = (byte) readByte(); } int opData = this.parseOpaqueData(buf); wapExtensionData = new Integer(opData).toString(); //byte[] temp = {0x2, 0x58}; //logger.info("Op wapExtensionData: " + this.parseOpaqueData(temp)); } // case OPAQUE break; default: exception("illegal id: "+id); } // SWITCH } private int parseOpaqueData(byte[] in) { int result = 0; /* for (int i = 0 ; i < in.length; i++) { int right = 1; for (int j = 0; j < (in.length - i - 1); j++) { right *= 256; } result += in[i] * right; } */ for (int i = 0 ; i < in.length; i++) { result += in[i]; for (int j = 0; j < (in.length - i - 1); j++) { result = result << 8; } } return result; } public void readAttr() throws IOException, XmlPullParserException { int id = readByte(); int i = 0; while (id != 1) { while(id == Wbxml.SWITCH_PAGE){ selectPage(readByte(), false); id = readByte(); } String name = resolveId(attrStartTable, id); StringBuffer value; int cut = name.indexOf('='); if (cut == -1) value = new StringBuffer(); else { value = new StringBuffer(name.substring(cut + 1)); name = name.substring(0, cut); } id = readByte(); while (id > 128 || id == Wbxml.SWITCH_PAGE || id == Wbxml.ENTITY || id == Wbxml.STR_I || id == Wbxml.STR_T || (id >= Wbxml.EXT_I_0 && id <= Wbxml.EXT_I_2) || (id >= Wbxml.EXT_T_0 && id <= Wbxml.EXT_T_2)) { switch (id) { case Wbxml.SWITCH_PAGE : selectPage(readByte(), false); break; case Wbxml.ENTITY : value.append((char) readInt()); break; case Wbxml.STR_I : value.append(readStrI()); break; case Wbxml.EXT_I_0 : case Wbxml.EXT_I_1 : case Wbxml.EXT_I_2 : case Wbxml.EXT_T_0 : case Wbxml.EXT_T_1 : case Wbxml.EXT_T_2 : case Wbxml.EXT_0 : case Wbxml.EXT_1 : case Wbxml.EXT_2 : case Wbxml.OPAQUE : throw new RuntimeException("wap extension in attr not supported yet"); /* ParseEvent e = parseWapExtension(id); if (!(e.getType() != Xml.TEXT && e.getType() != Xml.WHITESPACE)) throw new RuntimeException("parse WapExtension must return Text Event in order to work inside Attributes!"); value.append(e.getText()); //value.append (handleExtension (id)); // skip EXT in ATTR //break; */ case Wbxml.STR_T : value.append(readStrT()); break; default : value.append( resolveId(attrValueTable, id)); } id = readByte(); } attributes = ensureCapacity(attributes, i + 4); attributes[i++] = ""; attributes[i++] = null; attributes[i++] = name; attributes[i++] = value.toString(); attributeCount++; } } private int peekId () throws IOException { if (nextId == -2) { nextId = in.read (); } return nextId; } String resolveId(String[] tab, int id) throws IOException { int idx = (id & 0x07f) - 5; if (idx == -1) return readStrT(); if (idx < 0 || tab == null || idx >= tab.length || tab[idx] == null) throw new IOException("id " + id + " undef."); return tab[idx]; } String resolveAttributeId(String[] attrTable, int id) { if (id > attrTable.length) return null; return attrTable[id]; } void parseElement(int id) throws IOException, XmlPullParserException { type = START_TAG; name = resolveId(tagTable, id & 0x03f); attributeCount = 0; if ((id & 128) != 0) { readAttr(); } degenerated = ((id & 64) == 0); int sp = depth++ << 2; // transfer to element stack elementStack = ensureCapacity(elementStack, sp + 4); elementStack[sp + 3] = name; if (depth >= nspCounts.length) { int[] bigger = new int[depth + 4]; System.arraycopy(nspCounts, 0, bigger, 0, nspCounts.length); nspCounts = bigger; } nspCounts[depth] = nspCounts[depth - 1]; for (int i = attributeCount - 1; i > 0; i--) { for (int j = 0; j < i; j++) { if (getAttributeName(i) .equals(getAttributeName(j))) exception( "Duplicate Attribute: " + getAttributeName(i)); } } if (processNsp) adjustNsp(); else namespace = ""; elementStack[sp] = namespace; elementStack[sp + 1] = prefix; elementStack[sp + 2] = name; } private final String[] ensureCapacity( String[] arr, int required) { if (arr.length >= required) return arr; String[] bigger = new String[required + 16]; System.arraycopy(arr, 0, bigger, 0, arr.length); return bigger; } int readByte() throws IOException { int i = in.read(); if (i == -1) throw new IOException("Unexpected EOF"); return i; } int readInt() throws IOException { int result = 0; int i; do { i = readByte(); result = (result << 7) | (i & 0x7f); } while ((i & 0x80) != 0); return result; } String readStrI() throws IOException { ByteArrayOutputStream buf = new ByteArrayOutputStream(); boolean wsp = true; while (true){ int i = in.read(); if (i == 0){ break; } if (i == -1){ throw new IOException(UNEXPECTED_EOF); } if (i > 32){ wsp = false; } buf.write(i); } isWhitespace = wsp; String result = new String(buf.toByteArray(), encoding); buf.close(); return formatString(result); } String formatString(String str) { String result = str.replaceAll("&", "&"); return result; } String readStrT() throws IOException { int pos = readInt(); // As the main reason of stringTable is compression we build a cache of Strings // stringTable is supposed to help create Strings from parts which means some cache hit rate // This will help to minimize the Strings created when invoking readStrT() repeatedly if (cacheStringTable == null){ //Lazy init if device is not using StringTable but inline 0x03 strings cacheStringTable = new Hashtable(); } String forReturn = (String) cacheStringTable.get(new Integer(pos)); if (forReturn == null){ int end = pos; while(end < stringTable.length && stringTable[end] != '\0'){ end++; } forReturn = new String(stringTable, pos, end-pos, encoding); cacheStringTable.put(new Integer(pos), forReturn); } return forReturn; } /** * Sets the tag table for a given page. * The first string in the array defines tag 5, the second tag 6 etc. */ public void setTagTable(int page, String[] table) { setTable(page, TAG_TABLE, table); // this.tagTable = tagTable; // if (page != 0) // throw new RuntimeException("code pages curr. not supp."); } /** Sets the attribute start Table for a given page. *The first string in the array defines attribute * 5, the second attribute 6 etc. Please use the * character '=' (without quote!) as delimiter * between the attribute name and the (start of the) value */ public void setAttrStartTable( int page, String[] table) { setTable(page, ATTR_START_TABLE, table); } /** Sets the attribute value Table for a given page. *The first string in the array defines attribute value 0x85, * the second attribute value 0x86 etc. */ public void setAttrValueTable( int page, String[] table) { setTable(page, ATTR_VALUE_TABLE, table); } }kxml2-2.3.0/build.xml0000644000175000017500000000402410446542716012527 0ustar neoneo kxml2-2.3.0/lib/0000755000175000017500000000000011402717307011445 5ustar neoneo