Permalink
Browse files

Javadoc

  • Loading branch information...
1 parent d8dea90 commit 0e1ffb79446498c4fc5c48ccf376d152f0df4266 @samstokes samstokes committed May 24, 2012
@@ -2,6 +2,9 @@
import com.sun.jna.Native;
+/**
+ * Thrown if a native libwbxml2 function returns an error code.
+ */
@SuppressWarnings("serial")
public class JawboneException extends RuntimeException {
static {
@@ -29,10 +32,23 @@ public String getMessage() {
private native String wbxml_errors_string(int ret);
+ /**
+ * Check that a native function returned 0.
+ *
+ * @param ret return code of the native function.
+ * @throws JawboneException if return code is not 0.
+ */
public static void check(int ret) {
check(DEFAULT_PREFIX, ret);
}
+ /**
+ * Check that a native function returned 0.
+ *
+ * @param prefix prepended to the error message (e.g. function name).
+ * @param ret return code of the native function.
+ * @throws JawboneException if return code is not 0.
+ */
public static void check(String prefix, int ret) {
if (ret != 0) {
throw new JawboneException(prefix, ret);
@@ -8,6 +8,10 @@
import com.sun.jna.ptr.LongByReference;
import com.sun.jna.ptr.PointerByReference;
+
+/**
+ * Converts WBXML into XML.
+ */
public class WbxmlToXml {
static {
Native.register("wbxml2");
@@ -39,6 +43,12 @@ public void enablePreserveWhitespaces() {
wbxml_conv_wbxml2xml_enable_preserve_whitespaces(conv);
}
+ /**
+ * Convert WBXML into XML.
+ *
+ * @param wbxml bytes containing WBXML.
+ * @return bytes containing XML.
+ */
public byte[] run(byte[] wbxml) {
PointerByReference xmlPtr = new PointerByReference();
LongByReference xmlLength = new LongByReference();
@@ -8,6 +8,10 @@
import com.sun.jna.ptr.LongByReference;
import com.sun.jna.ptr.PointerByReference;
+
+/**
+ * Converts XML into WBXML.
+ */
public class XmlToWbxml {
static {
Native.register("wbxml2");
@@ -33,6 +37,12 @@ public void disablePublicId() {
wbxml_conv_xml2wbxml_disable_public_id(conv);
}
+ /**
+ * Convert XML into WBXML.
+ *
+ * @param xml bytes containing XML.
+ * @return bytes containing WBXML.
+ */
public byte[] run(byte[] xml) {
PointerByReference wbxmlPtr = new PointerByReference();
LongByReference wbxmlLength = new LongByReference();
@@ -0,0 +1,9 @@
+<body>
+ <p>
+ <em>JaWB</em>one is a <em>Ja</em>va binding for lib<em>WB</em>XML.
+ </p>
+ <p>
+ Currently the only functionality supported is for converting XML
+ documents into WBXML documents, and vice versa.
+ </p>
+</body>

0 comments on commit 0e1ffb7

Please sign in to comment.