Class 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 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()
      • 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:
        itemInfo -
        prefix -
        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,
                                                                                       org.apache.ws.commons.schema.XmlSchema currentSchema)
        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)