Apache CXF API

org.apache.cxf.javascript
Class JavascriptUtils

java.lang.Object
  extended by org.apache.cxf.javascript.JavascriptUtils

public class JavascriptUtils
extends Object

A set of functions that assist in JavaScript generation. This includes functions for appending strings of JavaScript to a buffer as well as some type utilities.


Constructor Summary
JavascriptUtils(StringBuilder code)
           
 
Method Summary
 void appendElse()
           
 void appendExpression(String value)
           
 void appendLine(String line)
           
 void appendString(String value)
          emit javascript to append a value to the accumulator.
 void endBlock()
           
 String escapeStringQuotes(String data)
           
 void generateCodeToSerializeAny(ParticleInfo itemInfo, String prefix, SchemaCollection schemaCollection)
          Generate code to serialize an xs:any.
 void generateCodeToSerializeElement(ParticleInfo elementInfo, String referencePrefix, SchemaCollection schemaCollection)
          Given an element, generate the serialization code.
 String getDefaultValueForSimpleType(org.apache.ws.commons.schema.XmlSchemaType type)
           
 boolean isStringSimpleType(QName typeName)
           
static String javaScriptNameToken(String token)
           
 String javascriptParseExpression(org.apache.ws.commons.schema.XmlSchemaType type, String value)
           
static boolean mtomCandidateType(org.apache.ws.commons.schema.XmlSchemaType type)
          Return true for xsd:base64Binary or simple restrictions of it, as in the xmime stock type.
static boolean notVeryComplexType(org.apache.ws.commons.schema.XmlSchemaType type)
          We don't want to generate Javascript overhead for complex types with simple content models, at least until or unless we decide to cope with attributes in a general way.
static String protectSingleQuotes(String value)
           
 void setXmlStringAccumulator(String variableName)
           
 void startBlock()
           
 void startDo()
           
 void startFor(String start, String test, String increment)
           
 void startForIn(String var, String collection)
           
 void startIf(String test)
           
 void startWhile(String test)
           
 void startXmlStringAccumulator(String variableName)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JavascriptUtils

public JavascriptUtils(StringBuilder code)
Method Detail

getDefaultValueForSimpleType

public String getDefaultValueForSimpleType(org.apache.ws.commons.schema.XmlSchemaType type)

isStringSimpleType

public boolean isStringSimpleType(QName typeName)

setXmlStringAccumulator

public void setXmlStringAccumulator(String variableName)

startXmlStringAccumulator

public void startXmlStringAccumulator(String variableName)

protectSingleQuotes

public static String protectSingleQuotes(String value)

escapeStringQuotes

public String escapeStringQuotes(String data)

appendString

public void appendString(String value)
emit javascript to append a value to the accumulator.

Parameters:
value -

appendExpression

public void appendExpression(String value)

appendLine

public void appendLine(String line)

startIf

public void startIf(String test)

startBlock

public void startBlock()

appendElse

public void appendElse()

endBlock

public void endBlock()

startFor

public void startFor(String start,
                     String test,
                     String increment)

startForIn

public void startForIn(String var,
                       String collection)

startWhile

public void startWhile(String test)

startDo

public void startDo()

javascriptParseExpression

public String javascriptParseExpression(org.apache.ws.commons.schema.XmlSchemaType type,
                                        String value)

javaScriptNameToken

public static String javaScriptNameToken(String token)

notVeryComplexType

public static boolean notVeryComplexType(org.apache.ws.commons.schema.XmlSchemaType type)
We don't want to generate Javascript overhead for complex types with simple content models, at least until or unless we decide to cope with attributes in a general way.

Parameters:
type -
Returns:

mtomCandidateType

public static boolean mtomCandidateType(org.apache.ws.commons.schema.XmlSchemaType type)
Return true for xsd:base64Binary or simple restrictions of it, as in the xmime stock type.

Parameters:
type -
Returns:

generateCodeToSerializeElement

public void generateCodeToSerializeElement(ParticleInfo elementInfo,
                                           String referencePrefix,
                                           SchemaCollection schemaCollection)
Given an element, generate the serialization code.

Parameters:
elementInfo - description of the element we are serializing
referencePrefix - prefix to the Javascript variable. Nothing for args, this._ for members.
schemaCollection - caller's schema collection.

generateCodeToSerializeAny

public void generateCodeToSerializeAny(ParticleInfo itemInfo,
                                       String prefix,
                                       SchemaCollection schemaCollection)
Generate code to serialize an xs:any. There is too much duplicate code with the element serializer; fix that some day.

Parameters:
elementInfo -
schemaCollection -

Apache CXF API

Apache CXF