org.marre.wap
Class WspUtil

java.lang.Object
  extended byorg.marre.wap.WspUtil

public final class WspUtil
extends java.lang.Object

Version:
$Id: WspUtil.java,v 1.2 2004/11/20 19:03:04 c95men Exp $
Author:
Markus Eriksson

Method Summary
static java.lang.String convertMultipartContentType(java.lang.String ct)
          Converts from a "multipart/" content type to "vnd.wap..." content type.
static int getHeaderType(java.lang.String headerName)
          Converts a header name to a header type (WapConstants.HEADER_*).
static int getParameterType(java.lang.String parameterName)
          Converts a parameter name to a parameter type (WapConstants.PARAMETER_*).
static int getWellKnownContentTypeId(byte wspEncodingVersion, java.lang.String contentType)
          Converts a content type to a WINA "well-known" content type id.
static int getWellKnownHeaderId(byte wspEncodingVersion, int headerType)
          Converts a header type (WapConstants.HEADER_*) to a well known header id.
static int getWellKnownParameterId(byte wspEncodingVersion, int parameterType)
          Converts a parameter type (WapConstants.PARAMETER_*) to a well known parameter id.
static int getWellKnownPushAppId(java.lang.String pushApp)
          Converts a push app to a WINA "well-known" push app id.
static int getWspParameterType(int wellKnownParameterId)
          Converts a parameter name to a parameter type (WapConstants.WSP_PARAMETER_TYPE_*).
static void writeContentType(byte wspEncodingVersion, java.io.OutputStream theOs, MimeHeader theContentType)
          Writes a wsp encoded content-type as specified in WAP-230-WSP-20010705-a.pdf.
static void writeContentType(byte wspEncodingVersion, java.io.OutputStream theOs, java.lang.String theContentType)
          Writes a wsp encoded content-type as specified in WAP-230-WSP-20010705-a.pdf.
static void writeExtensionMedia(java.io.OutputStream theOs, java.lang.String theStr)
          Writes an "extension media" in pdu format to the given output stream.
static void writeInteger(java.io.OutputStream theOs, long theValue)
          Writes an "integer" in wsp format to the given output stream.
static void writeLongInteger(java.io.OutputStream theOs, long theValue)
          Writes a "long integer" in wsp format to the given output stream.
static void writeParameter(byte wspEncodingVersion, java.io.OutputStream os, java.lang.String name, java.lang.String value)
           
static void writeQuotedString(java.io.OutputStream theOs, java.lang.String theStr)
           
static void writeShortInteger(java.io.OutputStream theOs, int theValue)
          Writes a "short integer" in wsp format to the given output stream.
static void writeTextString(java.io.OutputStream theOs, java.lang.String theStr)
           
static void writeTextValue(java.io.OutputStream theOs, java.lang.String theStr)
           
static void writeTokenText(java.io.OutputStream theOs, java.lang.String theStr)
           
static void writeTypedValue(byte wspEncodingVersion, java.io.OutputStream os, int wspParamType, java.lang.String value)
           
static void writeUint8(java.io.OutputStream theOs, int theValue)
          Writes a "uint8" in wsp format to the given output stream.
static void writeUintvar(java.io.OutputStream theOs, long theValue)
          Writes a "Uintvar" in wsp format to the given output stream.
static void writeValueLength(java.io.OutputStream theOs, long theValue)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getHeaderType

public static int getHeaderType(java.lang.String headerName)
Converts a header name to a header type (WapConstants.HEADER_*). The header name to be found must be in lower case (for performance reasons).

Parameters:
headerName - The name of the header.
Returns:
The header type, or -1 if not found.

getWellKnownHeaderId

public static int getWellKnownHeaderId(byte wspEncodingVersion,
                                       int headerType)
Converts a header type (WapConstants.HEADER_*) to a well known header id.

Parameters:
wspEncodingVersion - The requested wsp encoding version
headerType - The header type
Returns:
A well known header id or -1 if not found.

getWellKnownContentTypeId

public static int getWellKnownContentTypeId(byte wspEncodingVersion,
                                            java.lang.String contentType)
Converts a content type to a WINA "well-known" content type id. http://www.wapforum.org/wina/wsp-content-type.htm

Parameters:
wspEncodingVersion - The requested wsp encoding version
contentType - The content type
Returns:
A well known content type id or -1 if not found.

getParameterType

public static int getParameterType(java.lang.String parameterName)
Converts a parameter name to a parameter type (WapConstants.PARAMETER_*). The header name to be found must be in lower case (for performance reasons).

Parameters:
parameterName - The name of the parameter.
Returns:
The parameter type, or -1 if not found.

getWspParameterType

public static int getWspParameterType(int wellKnownParameterId)
Converts a parameter name to a parameter type (WapConstants.WSP_PARAMETER_TYPE_*).

Parameters:
wellKnownParameterId - The well known parameter id to lookup.
Returns:
The parameter type, or -1 if not found.

getWellKnownParameterId

public static int getWellKnownParameterId(byte wspEncodingVersion,
                                          int parameterType)
Converts a parameter type (WapConstants.PARAMETER_*) to a well known parameter id.

Parameters:
wspEncodingVersion - The requested wsp encoding version
parameterType - The header type
Returns:
A well known parameter id or -1 if not found.

getWellKnownPushAppId

public static int getWellKnownPushAppId(java.lang.String pushApp)
Converts a push app to a WINA "well-known" push app id. http://www.wapforum.org/wina/push-app-id.htm

Parameters:
pushApp - The push app
Returns:
A well known push app id or -1 if not found.

writeUint8

public static void writeUint8(java.io.OutputStream theOs,
                              int theValue)
                       throws java.io.IOException
Writes a "uint8" in wsp format to the given output stream.

Parameters:
theOs - Stream to write to
theValue - Value to write
Throws:
java.io.IOException

writeUintvar

public static void writeUintvar(java.io.OutputStream theOs,
                                long theValue)
                         throws java.io.IOException
Writes a "Uintvar" in wsp format to the given output stream.

Parameters:
theOs - Stream to write to
theValue - Value to write
Throws:
java.io.IOException

writeLongInteger

public static void writeLongInteger(java.io.OutputStream theOs,
                                    long theValue)
                             throws java.io.IOException
Writes a "long integer" in wsp format to the given output stream.

Parameters:
theOs - Stream to write to
theValue - Value to write
Throws:
java.io.IOException

writeInteger

public static void writeInteger(java.io.OutputStream theOs,
                                long theValue)
                         throws java.io.IOException
Writes an "integer" in wsp format to the given output stream.

Parameters:
theOs -
theValue -
Throws:
java.io.IOException

writeShortInteger

public static void writeShortInteger(java.io.OutputStream theOs,
                                     int theValue)
                              throws java.io.IOException
Writes a "short integer" in wsp format to the given output stream.

Parameters:
theOs - Stream to write to
theValue - Value to write
Throws:
java.io.IOException

writeValueLength

public static void writeValueLength(java.io.OutputStream theOs,
                                    long theValue)
                             throws java.io.IOException
Throws:
java.io.IOException

writeExtensionMedia

public static void writeExtensionMedia(java.io.OutputStream theOs,
                                       java.lang.String theStr)
                                throws java.io.IOException
Writes an "extension media" in pdu format to the given output stream. It currently only handles ASCII chars, but should be extended to work with other charsets.

Parameters:
theOs - Stream to write to
theStr - Text to write
Throws:
java.io.IOException

writeTextString

public static void writeTextString(java.io.OutputStream theOs,
                                   java.lang.String theStr)
                            throws java.io.IOException
Throws:
java.io.IOException

writeQuotedString

public static void writeQuotedString(java.io.OutputStream theOs,
                                     java.lang.String theStr)
                              throws java.io.IOException
Throws:
java.io.IOException

writeTokenText

public static void writeTokenText(java.io.OutputStream theOs,
                                  java.lang.String theStr)
                           throws java.io.IOException
Throws:
java.io.IOException

writeTextValue

public static void writeTextValue(java.io.OutputStream theOs,
                                  java.lang.String theStr)
                           throws java.io.IOException
Throws:
java.io.IOException

writeContentType

public static void writeContentType(byte wspEncodingVersion,
                                    java.io.OutputStream theOs,
                                    java.lang.String theContentType)
                             throws java.io.IOException
Writes a wsp encoded content-type as specified in WAP-230-WSP-20010705-a.pdf.

Uses the "constrained media" format.
Note! This method can only be used on simple content types (like "text/plain" or "image/gif"). If a more complex content-type is needed (like "image/gif; start=cid; parameter=value;") you must use the MimeContentType class.

Parameters:
theOs -
theContentType -
Throws:
java.io.IOException

writeContentType

public static void writeContentType(byte wspEncodingVersion,
                                    java.io.OutputStream theOs,
                                    MimeHeader theContentType)
                             throws java.io.IOException
Writes a wsp encoded content-type as specified in WAP-230-WSP-20010705-a.pdf.

This method automatically chooses the most compact way to represent the given content type.

Parameters:
theOs -
theContentType -
Throws:
java.io.IOException

writeTypedValue

public static void writeTypedValue(byte wspEncodingVersion,
                                   java.io.OutputStream os,
                                   int wspParamType,
                                   java.lang.String value)
                            throws java.io.IOException
Throws:
java.io.IOException

writeParameter

public static void writeParameter(byte wspEncodingVersion,
                                  java.io.OutputStream os,
                                  java.lang.String name,
                                  java.lang.String value)
                           throws java.io.IOException
Throws:
java.io.IOException

convertMultipartContentType

public static java.lang.String convertMultipartContentType(java.lang.String ct)
Converts from a "multipart/" content type to "vnd.wap..." content type.

Parameters:
ct -
Returns:


Copyright © 2002-2005 Markus Eriksson. All Rights Reserved.