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.
static org.apache.ws.commons.schema.XmlSchemaAll getAll(org.apache.ws.commons.schema.XmlSchemaComplexType type)
           
static org.apache.ws.commons.schema.XmlSchemaChoice getChoice(org.apache.ws.commons.schema.XmlSchemaComplexType type)
           
static List<org.apache.ws.commons.schema.XmlSchemaObject> getContentElements(org.apache.ws.commons.schema.XmlSchemaComplexType type, SchemaCollection collection)
           
static org.apache.ws.commons.schema.XmlSchemaSequence getContentSequence(org.apache.ws.commons.schema.XmlSchemaComplexType type)
           
 String getDefaultValueForSimpleType(org.apache.ws.commons.schema.XmlSchemaType type)
           
static org.apache.ws.commons.schema.XmlSchemaAnnotated getObjectAnnotated(org.apache.ws.commons.schema.XmlSchemaObject object, QName contextName)
          If the object is an attribute or an anyAttribute, return the 'Annotated'.
static org.apache.ws.commons.schema.XmlSchemaParticle getObjectParticle(org.apache.ws.commons.schema.XmlSchemaObject object, QName contextName)
          If the object is an element or an any, return the particle.
static org.apache.ws.commons.schema.XmlSchemaSequence getSequence(org.apache.ws.commons.schema.XmlSchemaComplexType 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 -

getObjectAnnotated

public static org.apache.ws.commons.schema.XmlSchemaAnnotated getObjectAnnotated(org.apache.ws.commons.schema.XmlSchemaObject object,
                                                                                 QName contextName)
If the object is an attribute or an anyAttribute, return the 'Annotated'. If it's not one of those, or it's a group, throw. We're not ready for groups yet.

Parameters:
object -

getObjectParticle

public static org.apache.ws.commons.schema.XmlSchemaParticle getObjectParticle(org.apache.ws.commons.schema.XmlSchemaObject object,
                                                                               QName contextName)
If the object is an element or an any, return the particle. If it's not a particle, or it's a group, throw. We're not ready for groups yet.

Parameters:
object -

getSequence

public static org.apache.ws.commons.schema.XmlSchemaSequence getSequence(org.apache.ws.commons.schema.XmlSchemaComplexType type)

getChoice

public static org.apache.ws.commons.schema.XmlSchemaChoice getChoice(org.apache.ws.commons.schema.XmlSchemaComplexType type)

getAll

public static org.apache.ws.commons.schema.XmlSchemaAll getAll(org.apache.ws.commons.schema.XmlSchemaComplexType type)

getContentElements

public static List<org.apache.ws.commons.schema.XmlSchemaObject> getContentElements(org.apache.ws.commons.schema.XmlSchemaComplexType type,
                                                                                    SchemaCollection collection)

getContentSequence

public static org.apache.ws.commons.schema.XmlSchemaSequence getContentSequence(org.apache.ws.commons.schema.XmlSchemaComplexType type)

Apache CXF API

Apache CXF