cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r630381 [3/8] - in /incubator/cxf/trunk/rt: bindings/corba/src/main/java/org/apache/cxf/binding/corba/utils/ core/src/main/java/org/apache/cxf/databinding/source/mime/ core/src/main/java/org/apache/cxf/interceptor/ core/src/main/java/org/ap...
Date Sat, 23 Feb 2008 02:56:00 GMT
Modified: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/BasicNameManager.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/BasicNameManager.java?rev=630381&r1=630380&r2=630381&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/BasicNameManager.java (original)
+++ incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/BasicNameManager.java Fri Feb 22 18:55:53 2008
@@ -1,147 +1,147 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.cxf.javascript;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import javax.xml.namespace.QName;
-
-import org.apache.cxf.endpoint.Endpoint;
-import org.apache.cxf.feature.AbstractFeature;
-import org.apache.cxf.service.model.SchemaInfo;
-import org.apache.cxf.service.model.ServiceInfo;
-import org.apache.ws.commons.schema.XmlSchemaComplexType;
-import org.apache.ws.commons.schema.utils.NamespacePrefixList;
-
-/**
- * Generate JavaScript names for QNames. 
- * This might belong on the CXF bus. 
- */
-public class BasicNameManager implements NameManager {
-    
-    private Map<String, String> nsPrefixMap;
-    
-    /**
-     * For unit testing, we allow a very meaningless version.
-     * Real uses use the factory methods.
-     */
-    BasicNameManager() {
-    }
-    
-    /**
-     * Factory that just takes a service. Used in tools and unit tests.
-     * @param service
-     * @return
-     */
-    public static BasicNameManager newNameManager(ServiceInfo service) {
-        BasicNameManager nameManager = new BasicNameManager();
-        nameManager.initialize(service, null);
-        return nameManager;
-    }
-    
-    /**
-     * 
-     * @param service
-     * @param endpoint
-     * @return
-     */
-    public static BasicNameManager newNameManager(ServiceInfo service, Endpoint endpoint) {
-        BasicNameManager nameManager = new BasicNameManager();
-        nameManager.initialize(service, endpoint);
-        return nameManager;
-    }
-
-    private void initialize(ServiceInfo service, Endpoint endpoint) {
-        nsPrefixMap = new HashMap<String, String>();
-        if (endpoint != null) {
-            JavascriptOptionsFeature options = getOptions(endpoint);
-            if (options.getNamespacePrefixMap() != null) {
-                nsPrefixMap.putAll(options.getNamespacePrefixMap());
-            }
-        }
-        
-        Set<String> poorPrefixURIs = new HashSet<String>();
-        for (SchemaInfo schemaInfo : service.getSchemas()) {
-            NamespacePrefixList schemaPrefixList = schemaInfo.getSchema().getNamespaceContext();
-            for (String declaredPrefix : schemaPrefixList.getDeclaredPrefixes()) {
-                String uri = schemaPrefixList.getNamespaceURI(declaredPrefix);
-                
-                if (!nsPrefixMap.containsKey(uri)) { // first schema to define a prefix wins.
-                    if (declaredPrefix.startsWith("ns") || "tns".equals(declaredPrefix)) {
-                        poorPrefixURIs.add(uri);
-                    } else { 
-                        nsPrefixMap.put(uri, declaredPrefix.toUpperCase());
-                    }
-                }
-            }
-        }
-        
-        for (String uri : poorPrefixURIs) {
-            defineFallbackPrefix(uri);
-        }
-    }
-
-    private JavascriptOptionsFeature getOptions(Endpoint endpoint) {
-        if (endpoint != null) {
-            for (AbstractFeature feature : endpoint.getActiveFeatures()) {
-                if (feature instanceof JavascriptOptionsFeature) {
-                    return (JavascriptOptionsFeature) feature;
-                }
-            }
-        }
-        return new JavascriptOptionsFeature(); // save work and return a default set of options.
-    }
-
-    /**
-     * Take a URI and turn it into a JavaScript name prefix.
-     * @param uri input URI.
-     * @return output prefix.
-     */
-    protected String transformURI(String uri) {
-        return uri.replaceAll("http:/*", "").replace("uri:", "").replaceAll("[\\.:/-]", "_");
-    }
-
-    private String defineFallbackPrefix(String uri) {
-        // this needs more work later. We are bound to annoy someone somehow in this area.
-        String jsPrefix = transformURI(uri);
-        nsPrefixMap.put(uri, jsPrefix);
-        return jsPrefix;
-    }
-
-    /** {@inheritDoc}*/
-    public String getJavascriptName(XmlSchemaComplexType schemaType) {
-        QName typeQName = schemaType.getQName();
-        return getJavascriptName(typeQName);
-    }
-
-    public String getJavascriptName(QName qname) {
-        String nsprefix = nsPrefixMap.get(qname.getNamespaceURI());
-        // nsprefix will be null if there is no prefix.
-        if (nsprefix == null) {
-            nsprefix = defineFallbackPrefix(qname.getNamespaceURI());
-        }
-        return nsprefix 
-               + "_"
-               + qname.getLocalPart();
-    }
-}
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.javascript;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import javax.xml.namespace.QName;
+
+import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.feature.AbstractFeature;
+import org.apache.cxf.service.model.SchemaInfo;
+import org.apache.cxf.service.model.ServiceInfo;
+import org.apache.ws.commons.schema.XmlSchemaComplexType;
+import org.apache.ws.commons.schema.utils.NamespacePrefixList;
+
+/**
+ * Generate JavaScript names for QNames. 
+ * This might belong on the CXF bus. 
+ */
+public class BasicNameManager implements NameManager {
+    
+    private Map<String, String> nsPrefixMap;
+    
+    /**
+     * For unit testing, we allow a very meaningless version.
+     * Real uses use the factory methods.
+     */
+    BasicNameManager() {
+    }
+    
+    /**
+     * Factory that just takes a service. Used in tools and unit tests.
+     * @param service
+     * @return
+     */
+    public static BasicNameManager newNameManager(ServiceInfo service) {
+        BasicNameManager nameManager = new BasicNameManager();
+        nameManager.initialize(service, null);
+        return nameManager;
+    }
+    
+    /**
+     * 
+     * @param service
+     * @param endpoint
+     * @return
+     */
+    public static BasicNameManager newNameManager(ServiceInfo service, Endpoint endpoint) {
+        BasicNameManager nameManager = new BasicNameManager();
+        nameManager.initialize(service, endpoint);
+        return nameManager;
+    }
+
+    private void initialize(ServiceInfo service, Endpoint endpoint) {
+        nsPrefixMap = new HashMap<String, String>();
+        if (endpoint != null) {
+            JavascriptOptionsFeature options = getOptions(endpoint);
+            if (options.getNamespacePrefixMap() != null) {
+                nsPrefixMap.putAll(options.getNamespacePrefixMap());
+            }
+        }
+        
+        Set<String> poorPrefixURIs = new HashSet<String>();
+        for (SchemaInfo schemaInfo : service.getSchemas()) {
+            NamespacePrefixList schemaPrefixList = schemaInfo.getSchema().getNamespaceContext();
+            for (String declaredPrefix : schemaPrefixList.getDeclaredPrefixes()) {
+                String uri = schemaPrefixList.getNamespaceURI(declaredPrefix);
+                
+                if (!nsPrefixMap.containsKey(uri)) { // first schema to define a prefix wins.
+                    if (declaredPrefix.startsWith("ns") || "tns".equals(declaredPrefix)) {
+                        poorPrefixURIs.add(uri);
+                    } else { 
+                        nsPrefixMap.put(uri, declaredPrefix.toUpperCase());
+                    }
+                }
+            }
+        }
+        
+        for (String uri : poorPrefixURIs) {
+            defineFallbackPrefix(uri);
+        }
+    }
+
+    private JavascriptOptionsFeature getOptions(Endpoint endpoint) {
+        if (endpoint != null) {
+            for (AbstractFeature feature : endpoint.getActiveFeatures()) {
+                if (feature instanceof JavascriptOptionsFeature) {
+                    return (JavascriptOptionsFeature) feature;
+                }
+            }
+        }
+        return new JavascriptOptionsFeature(); // save work and return a default set of options.
+    }
+
+    /**
+     * Take a URI and turn it into a JavaScript name prefix.
+     * @param uri input URI.
+     * @return output prefix.
+     */
+    protected String transformURI(String uri) {
+        return uri.replaceAll("http:/*", "").replace("uri:", "").replaceAll("[\\.:/-]", "_");
+    }
+
+    private String defineFallbackPrefix(String uri) {
+        // this needs more work later. We are bound to annoy someone somehow in this area.
+        String jsPrefix = transformURI(uri);
+        nsPrefixMap.put(uri, jsPrefix);
+        return jsPrefix;
+    }
+
+    /** {@inheritDoc}*/
+    public String getJavascriptName(XmlSchemaComplexType schemaType) {
+        QName typeQName = schemaType.getQName();
+        return getJavascriptName(typeQName);
+    }
+
+    public String getJavascriptName(QName qname) {
+        String nsprefix = nsPrefixMap.get(qname.getNamespaceURI());
+        // nsprefix will be null if there is no prefix.
+        if (nsprefix == null) {
+            nsprefix = defineFallbackPrefix(qname.getNamespaceURI());
+        }
+        return nsprefix 
+               + "_"
+               + qname.getLocalPart();
+    }
+}

Propchange: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/BasicNameManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/BasicNameManager.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/JavascriptOptionsFeature.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/JavascriptOptionsFeature.java?rev=630381&r1=630380&r2=630381&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/JavascriptOptionsFeature.java (original)
+++ incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/JavascriptOptionsFeature.java Fri Feb 22 18:55:53 2008
@@ -1,66 +1,66 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.cxf.javascript;
-
-import java.util.Map;
-
-import org.apache.cxf.Bus;
-import org.apache.cxf.endpoint.Server;
-import org.apache.cxf.feature.AbstractFeature;
-
-/**
- * This class provides configuration options to the JavaScript client generator.
- * Attach this feature to control namespace mapping and other options. 
- * <pre>
- * <![CDATA[
-    <jaxws:endpoint ...>
-      <jaxws:features>
-       <bean class="org.apache.cxf.javascript.JavascriptOptionsFeature">
-       </bean>
-      </jaxws:features>
-    </jaxws:endpoint>
-  ]]>
-  </pre>
-  * At this time, there is no corresponding WSDL extension for this information.
- */
-public class JavascriptOptionsFeature extends AbstractFeature {
-    private Map<String, String> namespacePrefixMap;
-
-    /**
-     * Retrieve the map from namespace URI strings to JavaScript function prefixes.
-     * @return the map
-     */
-    public Map<String, String> getNamespacePrefixMap() {
-        return namespacePrefixMap;
-    }
-
-    /**
-     * Set the map from namespace URI strings to Javascript function prefixes.
-     * @param namespacePrefixMap the map from namespace URI strings to JavaScript function prefixes.
-     */
-    public void setNamespacePrefixMap(Map<String, String> namespacePrefixMap) {
-        this.namespacePrefixMap = namespacePrefixMap;
-    }
-
-    @Override
-    public void initialize(Server server, Bus bus) {
-      //  server.getEndpoint().getActiveFeatures().add(this);
-    }
-}
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.javascript;
+
+import java.util.Map;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.feature.AbstractFeature;
+
+/**
+ * This class provides configuration options to the JavaScript client generator.
+ * Attach this feature to control namespace mapping and other options. 
+ * <pre>
+ * <![CDATA[
+    <jaxws:endpoint ...>
+      <jaxws:features>
+       <bean class="org.apache.cxf.javascript.JavascriptOptionsFeature">
+       </bean>
+      </jaxws:features>
+    </jaxws:endpoint>
+  ]]>
+  </pre>
+  * At this time, there is no corresponding WSDL extension for this information.
+ */
+public class JavascriptOptionsFeature extends AbstractFeature {
+    private Map<String, String> namespacePrefixMap;
+
+    /**
+     * Retrieve the map from namespace URI strings to JavaScript function prefixes.
+     * @return the map
+     */
+    public Map<String, String> getNamespacePrefixMap() {
+        return namespacePrefixMap;
+    }
+
+    /**
+     * Set the map from namespace URI strings to Javascript function prefixes.
+     * @param namespacePrefixMap the map from namespace URI strings to JavaScript function prefixes.
+     */
+    public void setNamespacePrefixMap(Map<String, String> namespacePrefixMap) {
+        this.namespacePrefixMap = namespacePrefixMap;
+    }
+
+    @Override
+    public void initialize(Server server, Bus bus) {
+      //  server.getEndpoint().getActiveFeatures().add(this);
+    }
+}

Propchange: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/JavascriptOptionsFeature.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/JavascriptOptionsFeature.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/JavascriptPrefix.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/JavascriptPrefix.java?rev=630381&r1=630380&r2=630381&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/JavascriptPrefix.java (original)
+++ incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/JavascriptPrefix.java Fri Feb 22 18:55:53 2008
@@ -1,43 +1,43 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.cxf.javascript;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-
-/**
- * This annotation specifies the string prefix for names of JavaScript objects derived from a particular
- * namespace. It is used with {@link JavascriptPrefixes}. 
- */
-@Retention(RetentionPolicy.RUNTIME) 
-@Target({ })
-public @interface JavascriptPrefix {
-    /**
-     * The namespace URI of the namespace.
-     */ 
-    String namespace();
-    /**
-     * The prefix for JavaScript object names.
-     */
-    String prefix();
-
-}
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.javascript;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+
+/**
+ * This annotation specifies the string prefix for names of JavaScript objects derived from a particular
+ * namespace. It is used with {@link JavascriptPrefixes}. 
+ */
+@Retention(RetentionPolicy.RUNTIME) 
+@Target({ })
+public @interface JavascriptPrefix {
+    /**
+     * The namespace URI of the namespace.
+     */ 
+    String namespace();
+    /**
+     * The prefix for JavaScript object names.
+     */
+    String prefix();
+
+}

Propchange: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/JavascriptPrefix.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/JavascriptPrefix.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/JavascriptPrefixes.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/JavascriptPrefixes.java?rev=630381&r1=630380&r2=630381&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/JavascriptPrefixes.java (original)
+++ incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/JavascriptPrefixes.java Fri Feb 22 18:55:53 2008
@@ -1,37 +1,37 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.cxf.javascript;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Use this annotation to control the names of JavaScript objects associated with this package.
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.TYPE)
-public @interface JavascriptPrefixes {
-    /**
-     * An array of namespaceURI/prefix pairs, specified as JavascriptPrefix annotations.
-     */
-    JavascriptPrefix[] prefixes() default { };
-}
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.javascript;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Use this annotation to control the names of JavaScript objects associated with this package.
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.TYPE)
+public @interface JavascriptPrefixes {
+    /**
+     * An array of namespaceURI/prefix pairs, specified as JavascriptPrefix annotations.
+     */
+    JavascriptPrefix[] prefixes() default { };
+}

Propchange: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/JavascriptPrefixes.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/JavascriptPrefixes.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/JavascriptQueryHandler.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/JavascriptQueryHandler.java?rev=630381&r1=630380&r2=630381&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/JavascriptQueryHandler.java (original)
+++ incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/JavascriptQueryHandler.java Fri Feb 22 18:55:53 2008
@@ -1,157 +1,157 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.cxf.javascript;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.net.URI;
-import java.nio.charset.Charset;
-import java.util.Collection;
-import java.util.Map;
-import java.util.logging.Logger;
-
-import org.apache.cxf.Bus;
-import org.apache.cxf.common.i18n.UncheckedException;
-import org.apache.cxf.common.logging.LogUtils;
-import org.apache.cxf.endpoint.Endpoint;
-import org.apache.cxf.endpoint.Server;
-import org.apache.cxf.endpoint.ServerRegistry;
-import org.apache.cxf.javascript.service.ServiceJavascriptBuilder;
-import org.apache.cxf.javascript.types.SchemaJavascriptBuilder;
-import org.apache.cxf.service.model.EndpointInfo;
-import org.apache.cxf.service.model.SchemaInfo;
-import org.apache.cxf.service.model.ServiceInfo;
-import org.apache.cxf.transport.DestinationWithEndpoint;
-import org.apache.cxf.transport.http.UrlUtilities;
-import org.apache.cxf.transports.http.StemMatchingQueryHandler;
-
-public class JavascriptQueryHandler implements StemMatchingQueryHandler {
-    private static final String JS_UTILS_PATH = "/org/apache/cxf/javascript/cxf-utils.js";
-    private static final Logger LOG = LogUtils.getL7dLogger(JavascriptQueryHandler.class);
-    private static final Charset UTF8 = Charset.forName("utf-8");
-    private static final String NO_UTILS_QUERY_KEY = "nojsutils";
-    private static final String CODE_QUERY_KEY = "js";
-    private Bus bus;
-
-    public JavascriptQueryHandler(Bus b) {
-        bus = b;
-        LOG.finest("Bus " + bus);
-    }
-
-    public String getResponseContentType(String fullQueryString, String ctx) {
-        URI uri = URI.create(fullQueryString);
-        Map<String, String> map = UrlUtilities.parseQueryString(uri.getQuery());
-        if (map.containsKey(CODE_QUERY_KEY)) {
-            return "application/javascript;charset=UTF-8";
-        }
-        return null;
-    }
-
-    public boolean isRecognizedQuery(String baseUri, String ctx, EndpointInfo endpointInfo,
-                                     boolean contextMatchExact) {
-        if (baseUri == null) {
-            return false;
-        }
-        URI uri = URI.create(baseUri);
-        Map<String, String> map = UrlUtilities.parseQueryString(uri.getQuery());
-        if (map.containsKey(CODE_QUERY_KEY)) {
-            return endpointInfo.getAddress().contains(UrlUtilities.getStem(uri.getSchemeSpecificPart()));
-        }
-        return false;
-    }
-    
-    public static void writeUtilsToResponseStream(Class<?> referenceClass, OutputStream outputStream) {
-        InputStream utils = referenceClass.getResourceAsStream(JS_UTILS_PATH);
-        if (utils == null) {
-            throw new RuntimeException("Unable to get stream for " + JS_UTILS_PATH);
-        }
-        // it's amazing that this still has to be coded up.
-        byte buffer[] = new byte[1024];
-        int count;
-        try {
-            while ((count = utils.read(buffer, 0, 1024)) > 0) {
-                outputStream.write(buffer, 0, count);
-            }
-            outputStream.flush();
-        } catch (IOException e) {
-            throw new RuntimeException("Failed to write javascript utils to HTTP response.", e);
-        }
-    }
-    
-    private Endpoint findEndpoint(EndpointInfo endpointInfo) {
-        ServerRegistry serverRegistry = bus.getExtension(ServerRegistry.class);
-        for (Server server : serverRegistry.getServers()) {
-            // Hypothetically, not all destinations have an endpoint.
-            // There has to be a better way to do this.
-            if (server.getDestination() instanceof DestinationWithEndpoint
-                &&
-                endpointInfo.
-                    equals(((DestinationWithEndpoint)server.getDestination()).getEndpointInfo())) {
-                return server.getEndpoint();
-            }
-        }
-        return null;
-    }
-
-    public void writeResponse(String fullQueryString, String ctx, EndpointInfo endpoint, OutputStream os) {
-        URI uri = URI.create(fullQueryString);
-        String query = uri.getQuery();
-        Map<String, String> map = UrlUtilities.parseQueryString(query);
-        OutputStreamWriter writer = new OutputStreamWriter(os, UTF8);
-        if (!map.containsKey(NO_UTILS_QUERY_KEY)) {
-            writeUtilsToResponseStream(JavascriptQueryHandler.class, os);
-        } 
-        if (map.containsKey(CODE_QUERY_KEY)) {
-            ServiceInfo serviceInfo = endpoint.getService();
-            Collection<SchemaInfo> schemata = serviceInfo.getSchemas();
-            Endpoint serverEndpoint = findEndpoint(endpoint);
-            // we need to move this to the bus.
-            BasicNameManager nameManager = BasicNameManager.newNameManager(serviceInfo, serverEndpoint);
-            NamespacePrefixAccumulator prefixManager = new NamespacePrefixAccumulator(serviceInfo
-                .getXmlSchemaCollection());
-            try {
-                for (SchemaInfo schema : schemata) {
-                    SchemaJavascriptBuilder builder = new SchemaJavascriptBuilder(serviceInfo
-                        .getXmlSchemaCollection(), prefixManager, nameManager);
-                    String allThatJavascript = builder.generateCodeForSchema(schema);
-                    writer.append(allThatJavascript);
-                }
-
-                ServiceJavascriptBuilder serviceBuilder = new ServiceJavascriptBuilder(serviceInfo,
-                                                                                       prefixManager,
-                                                                                       nameManager);
-                serviceBuilder.walk();
-                String serviceJavascript = serviceBuilder.getCode();
-                writer.append(serviceJavascript);
-                writer.flush();
-            } catch (IOException e) {
-                throw new UncheckedException(e);
-            }
-        } else {
-            throw new RuntimeException("Invalid query " + fullQueryString);
-        }
-    }
-
-    public boolean isRecognizedQuery(String fullQueryString, String ctx, EndpointInfo endpoint) {
-        return isRecognizedQuery(fullQueryString, ctx, endpoint, false);
-    }
-}
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.javascript;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.net.URI;
+import java.nio.charset.Charset;
+import java.util.Collection;
+import java.util.Map;
+import java.util.logging.Logger;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.common.i18n.UncheckedException;
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.endpoint.ServerRegistry;
+import org.apache.cxf.javascript.service.ServiceJavascriptBuilder;
+import org.apache.cxf.javascript.types.SchemaJavascriptBuilder;
+import org.apache.cxf.service.model.EndpointInfo;
+import org.apache.cxf.service.model.SchemaInfo;
+import org.apache.cxf.service.model.ServiceInfo;
+import org.apache.cxf.transport.DestinationWithEndpoint;
+import org.apache.cxf.transport.http.UrlUtilities;
+import org.apache.cxf.transports.http.StemMatchingQueryHandler;
+
+public class JavascriptQueryHandler implements StemMatchingQueryHandler {
+    private static final String JS_UTILS_PATH = "/org/apache/cxf/javascript/cxf-utils.js";
+    private static final Logger LOG = LogUtils.getL7dLogger(JavascriptQueryHandler.class);
+    private static final Charset UTF8 = Charset.forName("utf-8");
+    private static final String NO_UTILS_QUERY_KEY = "nojsutils";
+    private static final String CODE_QUERY_KEY = "js";
+    private Bus bus;
+
+    public JavascriptQueryHandler(Bus b) {
+        bus = b;
+        LOG.finest("Bus " + bus);
+    }
+
+    public String getResponseContentType(String fullQueryString, String ctx) {
+        URI uri = URI.create(fullQueryString);
+        Map<String, String> map = UrlUtilities.parseQueryString(uri.getQuery());
+        if (map.containsKey(CODE_QUERY_KEY)) {
+            return "application/javascript;charset=UTF-8";
+        }
+        return null;
+    }
+
+    public boolean isRecognizedQuery(String baseUri, String ctx, EndpointInfo endpointInfo,
+                                     boolean contextMatchExact) {
+        if (baseUri == null) {
+            return false;
+        }
+        URI uri = URI.create(baseUri);
+        Map<String, String> map = UrlUtilities.parseQueryString(uri.getQuery());
+        if (map.containsKey(CODE_QUERY_KEY)) {
+            return endpointInfo.getAddress().contains(UrlUtilities.getStem(uri.getSchemeSpecificPart()));
+        }
+        return false;
+    }
+    
+    public static void writeUtilsToResponseStream(Class<?> referenceClass, OutputStream outputStream) {
+        InputStream utils = referenceClass.getResourceAsStream(JS_UTILS_PATH);
+        if (utils == null) {
+            throw new RuntimeException("Unable to get stream for " + JS_UTILS_PATH);
+        }
+        // it's amazing that this still has to be coded up.
+        byte buffer[] = new byte[1024];
+        int count;
+        try {
+            while ((count = utils.read(buffer, 0, 1024)) > 0) {
+                outputStream.write(buffer, 0, count);
+            }
+            outputStream.flush();
+        } catch (IOException e) {
+            throw new RuntimeException("Failed to write javascript utils to HTTP response.", e);
+        }
+    }
+    
+    private Endpoint findEndpoint(EndpointInfo endpointInfo) {
+        ServerRegistry serverRegistry = bus.getExtension(ServerRegistry.class);
+        for (Server server : serverRegistry.getServers()) {
+            // Hypothetically, not all destinations have an endpoint.
+            // There has to be a better way to do this.
+            if (server.getDestination() instanceof DestinationWithEndpoint
+                &&
+                endpointInfo.
+                    equals(((DestinationWithEndpoint)server.getDestination()).getEndpointInfo())) {
+                return server.getEndpoint();
+            }
+        }
+        return null;
+    }
+
+    public void writeResponse(String fullQueryString, String ctx, EndpointInfo endpoint, OutputStream os) {
+        URI uri = URI.create(fullQueryString);
+        String query = uri.getQuery();
+        Map<String, String> map = UrlUtilities.parseQueryString(query);
+        OutputStreamWriter writer = new OutputStreamWriter(os, UTF8);
+        if (!map.containsKey(NO_UTILS_QUERY_KEY)) {
+            writeUtilsToResponseStream(JavascriptQueryHandler.class, os);
+        } 
+        if (map.containsKey(CODE_QUERY_KEY)) {
+            ServiceInfo serviceInfo = endpoint.getService();
+            Collection<SchemaInfo> schemata = serviceInfo.getSchemas();
+            Endpoint serverEndpoint = findEndpoint(endpoint);
+            // we need to move this to the bus.
+            BasicNameManager nameManager = BasicNameManager.newNameManager(serviceInfo, serverEndpoint);
+            NamespacePrefixAccumulator prefixManager = new NamespacePrefixAccumulator(serviceInfo
+                .getXmlSchemaCollection());
+            try {
+                for (SchemaInfo schema : schemata) {
+                    SchemaJavascriptBuilder builder = new SchemaJavascriptBuilder(serviceInfo
+                        .getXmlSchemaCollection(), prefixManager, nameManager);
+                    String allThatJavascript = builder.generateCodeForSchema(schema);
+                    writer.append(allThatJavascript);
+                }
+
+                ServiceJavascriptBuilder serviceBuilder = new ServiceJavascriptBuilder(serviceInfo,
+                                                                                       prefixManager,
+                                                                                       nameManager);
+                serviceBuilder.walk();
+                String serviceJavascript = serviceBuilder.getCode();
+                writer.append(serviceJavascript);
+                writer.flush();
+            } catch (IOException e) {
+                throw new UncheckedException(e);
+            }
+        } else {
+            throw new RuntimeException("Invalid query " + fullQueryString);
+        }
+    }
+
+    public boolean isRecognizedQuery(String fullQueryString, String ctx, EndpointInfo endpoint) {
+        return isRecognizedQuery(fullQueryString, ctx, endpoint, false);
+    }
+}

Propchange: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/JavascriptQueryHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/JavascriptQueryHandler.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/JavascriptQueryHandlerRegistry.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/JavascriptQueryHandlerRegistry.java?rev=630381&r1=630380&r2=630381&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/JavascriptQueryHandlerRegistry.java (original)
+++ incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/JavascriptQueryHandlerRegistry.java Fri Feb 22 18:55:53 2008
@@ -1,48 +1,48 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.cxf.javascript;
-
-import org.apache.cxf.Bus;
-import org.apache.cxf.transports.http.QueryHandlerRegistry;
-
-/**
- * 
- */
-public class JavascriptQueryHandlerRegistry {
-    private Bus bus;
-    
-    
-    public JavascriptQueryHandlerRegistry() {
-    }
-    
-    public JavascriptQueryHandlerRegistry(Bus b) {
-        bus = b;
-    }
-    
-    
-    public void register() {
-        if (bus != null) {
-            QueryHandlerRegistry registry = bus.getExtension(QueryHandlerRegistry.class);
-            if (registry != null) {
-                registry.registerHandler(new JavascriptQueryHandler(bus));
-            }
-        }
-    }
-}
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.javascript;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.transports.http.QueryHandlerRegistry;
+
+/**
+ * 
+ */
+public class JavascriptQueryHandlerRegistry {
+    private Bus bus;
+    
+    
+    public JavascriptQueryHandlerRegistry() {
+    }
+    
+    public JavascriptQueryHandlerRegistry(Bus b) {
+        bus = b;
+    }
+    
+    
+    public void register() {
+        if (bus != null) {
+            QueryHandlerRegistry registry = bus.getExtension(QueryHandlerRegistry.class);
+            if (registry != null) {
+                registry.registerHandler(new JavascriptQueryHandler(bus));
+            }
+        }
+    }
+}

Propchange: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/JavascriptQueryHandlerRegistry.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/JavascriptQueryHandlerRegistry.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/Messages.properties
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/Messages.properties?rev=630381&r1=630380&r2=630381&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/Messages.properties (original)
+++ incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/Messages.properties Fri Feb 22 18:55:53 2008
@@ -1,30 +1,30 @@
-#
-#
-#    Licensed to the Apache Software Foundation (ASF) under one
-#    or more contributor license agreements. See the NOTICE file
-#    distributed with this work for additional information
-#    regarding copyright ownership. The ASF licenses this file
-#    to you under the Apache License, Version 2.0 (the
-#    "License"); you may not use this file except in compliance
-#    with the License. You may obtain a copy of the License at
-#
-#    http://www.apache.org/licenses/LICENSE-2.0
-#
-#    Unless required by applicable law or agreed to in writing,
-#    software distributed under the License is distributed on an
-#    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-#    KIND, either express or implied. See the License for the
-#    specific language governing permissions and limitations
-#    under the License.
-#
-#
-NON_SEQUENCE_PARTICLE=JavaScript limitation: Type {0} is not defined as a sequence. {1}
-NON_ELEMENT_CHILD=JavaScript limitation: Non-Element sequence member {0} of {1}. {2}
-NON_PARTICLE_CHILD=JavaScript limitation: Non-particle sequence member {0} of {1}. {2}
-GROUP_CHILD=JavaScript limitation: unsupported xs:group {0} found in {1}. {2}
-ABSTRACT_ELEMENT=JavaScript limitation: Abstract element {0} of {1}. {2}
-ELEMENT_HAS_NO_TYPE=Element {0} has no type in the schema. {1}
-ELEMENT_TYPE_MISSING=Element {0} references type {1} which is not defined.
-ELEMENT_SCHEMA_MISSING=Element {0} contained in missing schema.
-IMPOSSIBLE_GLOBAL_ITEM= JavaScript limitation: Element or xs:any at {0} used in a context that requires a global name, but it, and its type, are anonymous.
-MISSING_TYPE=Type {0} is missing from the WSDL schema for element {1}. {2}
+#
+#
+#    Licensed to the Apache Software Foundation (ASF) under one
+#    or more contributor license agreements. See the NOTICE file
+#    distributed with this work for additional information
+#    regarding copyright ownership. The ASF licenses this file
+#    to you under the Apache License, Version 2.0 (the
+#    "License"); you may not use this file except in compliance
+#    with the License. You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing,
+#    software distributed under the License is distributed on an
+#    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+#    KIND, either express or implied. See the License for the
+#    specific language governing permissions and limitations
+#    under the License.
+#
+#
+NON_SEQUENCE_PARTICLE=JavaScript limitation: Type {0} is not defined as a sequence. {1}
+NON_ELEMENT_CHILD=JavaScript limitation: Non-Element sequence member {0} of {1}. {2}
+NON_PARTICLE_CHILD=JavaScript limitation: Non-particle sequence member {0} of {1}. {2}
+GROUP_CHILD=JavaScript limitation: unsupported xs:group {0} found in {1}. {2}
+ABSTRACT_ELEMENT=JavaScript limitation: Abstract element {0} of {1}. {2}
+ELEMENT_HAS_NO_TYPE=Element {0} has no type in the schema. {1}
+ELEMENT_TYPE_MISSING=Element {0} references type {1} which is not defined.
+ELEMENT_SCHEMA_MISSING=Element {0} contained in missing schema.
+IMPOSSIBLE_GLOBAL_ITEM= JavaScript limitation: Element or xs:any at {0} used in a context that requires a global name, but it, and its type, are anonymous.
+MISSING_TYPE=Type {0} is missing from the WSDL schema for element {1}. {2}

Propchange: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/Messages.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/Messages.properties
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/Messages.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/NameManager.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/NameManager.java?rev=630381&r1=630380&r2=630381&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/NameManager.java (original)
+++ incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/NameManager.java Fri Feb 22 18:55:53 2008
@@ -1,26 +1,26 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.cxf.javascript;
-
-import javax.xml.namespace.QName;
-
-public interface NameManager {
-    String getJavascriptName(QName qname);
-}
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.javascript;
+
+import javax.xml.namespace.QName;
+
+public interface NameManager {
+    String getJavascriptName(QName qname);
+}

Propchange: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/NameManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/NameManager.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/NamespacePrefixAccumulator.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/NamespacePrefixAccumulator.java?rev=630381&r1=630380&r2=630381&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/NamespacePrefixAccumulator.java (original)
+++ incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/NamespacePrefixAccumulator.java Fri Feb 22 18:55:53 2008
@@ -1,102 +1,102 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.cxf.javascript;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import javax.xml.namespace.QName;
-
-import org.apache.cxf.common.xmlschema.SchemaCollection;
-import org.apache.ws.commons.schema.XmlSchemaElement;
-
-public class NamespacePrefixAccumulator {
-    private StringBuffer attributes;
-    private Set<String> prefixes;
-    private Map<String, String> fallbackNamespacePrefixMap;
-    private int nsCounter;
-    private SchemaCollection schemaCollection;
-
-    public NamespacePrefixAccumulator(SchemaCollection schemaCollection) {
-        attributes = new StringBuffer();
-        prefixes = new HashSet<String>();
-        fallbackNamespacePrefixMap = new HashMap<String, String>();
-        nsCounter = 0;
-        this.schemaCollection = schemaCollection;
-    }
-    
-    public void collect(String prefix, String uri) {
-        if (!("".equals(uri)) && !prefixes.contains(prefix)) {
-            attributes.append("xmlns:" + prefix + "='" + uri + "' ");
-            prefixes.add(prefix);
-        }
-    }
-    
-    public String getAttributes() {
-        return attributes.toString();
-    }
-    
-    private String getPrefix(String namespaceURI) {
-        if ("".equals(namespaceURI)) {
-            throw new RuntimeException("Prefix requested for default namespace.");
-        }
-        String schemaPrefix = schemaCollection.getNamespaceContext().getPrefix(namespaceURI);
-        // there could also be a namespace context on an individual schema info.
-        // perhaps SchemaCollection should be enforcing some discipline there.
-        if (schemaPrefix == null || "tns".equals(schemaPrefix)) {
-            schemaPrefix = fallbackNamespacePrefixMap.get(namespaceURI);
-            if (schemaPrefix == null) {
-                schemaPrefix = "jns" + nsCounter;
-                nsCounter++;
-                fallbackNamespacePrefixMap.put(namespaceURI, schemaPrefix);
-            }
-        }
-        return schemaPrefix;
-    }
-    
-    /**
-     * This function obtains a name, perhaps namespace-qualified, for an element.
-     * @param element the element.
-     * @param qualified whether to qualify.
-     * @return
-     */
-    public String xmlElementString(XmlSchemaElement element, boolean qualified) {
-        if (qualified) {
-            // What if there were a prefix in the element's qname? This is not apparently 
-            // something that happens in this environment.
-            String prefix = getPrefix(element.getQName().getNamespaceURI());
-            collect(prefix, element.getQName().getNamespaceURI());
-            return prefix + ":" + element.getName();
-        }
-        return element.getName(); // use the non-qualified name.
-    }
-    
-    public String xmlElementString(QName name) { // used with part concrete names
-        if ("".equals(name.getNamespaceURI())) {
-            return name.getLocalPart();
-        }
-
-        String prefix = getPrefix(name.getNamespaceURI());
-        collect(prefix, name.getNamespaceURI());
-        return prefix + ":" + name.getLocalPart();
-    }
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.javascript;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import javax.xml.namespace.QName;
+
+import org.apache.cxf.common.xmlschema.SchemaCollection;
+import org.apache.ws.commons.schema.XmlSchemaElement;
+
+public class NamespacePrefixAccumulator {
+    private StringBuffer attributes;
+    private Set<String> prefixes;
+    private Map<String, String> fallbackNamespacePrefixMap;
+    private int nsCounter;
+    private SchemaCollection schemaCollection;
+
+    public NamespacePrefixAccumulator(SchemaCollection schemaCollection) {
+        attributes = new StringBuffer();
+        prefixes = new HashSet<String>();
+        fallbackNamespacePrefixMap = new HashMap<String, String>();
+        nsCounter = 0;
+        this.schemaCollection = schemaCollection;
+    }
+    
+    public void collect(String prefix, String uri) {
+        if (!("".equals(uri)) && !prefixes.contains(prefix)) {
+            attributes.append("xmlns:" + prefix + "='" + uri + "' ");
+            prefixes.add(prefix);
+        }
+    }
+    
+    public String getAttributes() {
+        return attributes.toString();
+    }
+    
+    private String getPrefix(String namespaceURI) {
+        if ("".equals(namespaceURI)) {
+            throw new RuntimeException("Prefix requested for default namespace.");
+        }
+        String schemaPrefix = schemaCollection.getNamespaceContext().getPrefix(namespaceURI);
+        // there could also be a namespace context on an individual schema info.
+        // perhaps SchemaCollection should be enforcing some discipline there.
+        if (schemaPrefix == null || "tns".equals(schemaPrefix)) {
+            schemaPrefix = fallbackNamespacePrefixMap.get(namespaceURI);
+            if (schemaPrefix == null) {
+                schemaPrefix = "jns" + nsCounter;
+                nsCounter++;
+                fallbackNamespacePrefixMap.put(namespaceURI, schemaPrefix);
+            }
+        }
+        return schemaPrefix;
+    }
+    
+    /**
+     * This function obtains a name, perhaps namespace-qualified, for an element.
+     * @param element the element.
+     * @param qualified whether to qualify.
+     * @return
+     */
+    public String xmlElementString(XmlSchemaElement element, boolean qualified) {
+        if (qualified) {
+            // What if there were a prefix in the element's qname? This is not apparently 
+            // something that happens in this environment.
+            String prefix = getPrefix(element.getQName().getNamespaceURI());
+            collect(prefix, element.getQName().getNamespaceURI());
+            return prefix + ":" + element.getName();
+        }
+        return element.getName(); // use the non-qualified name.
+    }
+    
+    public String xmlElementString(QName name) { // used with part concrete names
+        if ("".equals(name.getNamespaceURI())) {
+            return name.getLocalPart();
+        }
+
+        String prefix = getPrefix(name.getNamespaceURI());
+        collect(prefix, name.getNamespaceURI());
+        return prefix + ":" + name.getLocalPart();
+    }
 }

Propchange: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/NamespacePrefixAccumulator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/NamespacePrefixAccumulator.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/ParticleInfo.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/ParticleInfo.java?rev=630381&r1=630380&r2=630381&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/ParticleInfo.java (original)
+++ incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/ParticleInfo.java Fri Feb 22 18:55:53 2008
@@ -1,347 +1,347 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.cxf.javascript;
-
-import java.util.logging.Logger;
-
-import javax.xml.namespace.QName;
-
-import org.apache.cxf.common.i18n.Message;
-import org.apache.cxf.common.logging.LogUtils;
-import org.apache.cxf.common.xmlschema.SchemaCollection;
-import org.apache.cxf.common.xmlschema.XmlSchemaConstants;
-import org.apache.ws.commons.schema.XmlSchema;
-import org.apache.ws.commons.schema.XmlSchemaElement;
-import org.apache.ws.commons.schema.XmlSchemaObject;
-import org.apache.ws.commons.schema.XmlSchemaParticle;
-import org.apache.ws.commons.schema.XmlSchemaType;
-
-/**
- * All the information needed to create the JavaScript for an Xml Schema element
- * or xs:any.
- */
-public final class ParticleInfo {
-    private static final Logger LOG = LogUtils.getL7dLogger(ParticleInfo.class);
-    private XmlSchemaParticle particle;
-    private String javascriptName;
-    private String xmlName;
-    private XmlSchemaType containingType;
-    // in the RPC case, we can have a type and no element.
-    private XmlSchemaType type;
-    private boolean empty;
-    // These are exactly the same values as we find in the XmlSchemaElement.
-    // there is no rationalization. But the accessors take care of business.
-    private long minOccurs;
-    private long maxOccurs;
-    private boolean nillable;
-    private boolean any;
-    private boolean anyType;
-    private String defaultValue;
-    private boolean global;
-
-    private ParticleInfo() {
-    }
-
-    /**
-     * Create an elementInfo that stores information about a global, named,
-     * element.
-     * 
-     * @param element the element
-     * @param currentSchema the schema it came from.
-     * @param schemaCollection the collection of all schemas.
-     * @param prefixAccumulator the accumulator that assigns prefixes.
-     * @return
-     */
-    public static ParticleInfo forGlobalElement(XmlSchemaElement element, XmlSchema currentSchema,
-                                                SchemaCollection schemaCollection,
-                                                NamespacePrefixAccumulator prefixAccumulator) {
-        ParticleInfo elementInfo = new ParticleInfo();
-        elementInfo.particle = element;
-        elementInfo.minOccurs = element.getMinOccurs();
-        elementInfo.maxOccurs = element.getMaxOccurs();
-        elementInfo.nillable = element.isNillable();
-        elementInfo.global = true;
-
-        factoryCommon(element, currentSchema, schemaCollection, prefixAccumulator, elementInfo);
-        return elementInfo;
-    }
-
-    /**
-     * Create element information for a part element. For a part, the JavaScript
-     * and Element names are calculated in advance, and the element itself might
-     * be null! In that case, the minOccurs and maxOccurs are conventional. Note
-     * that in some cases the code in ServiceJavascriptBuilder uses a local
-     * element (or xa:any) from inside the part element, instead of the part
-     * element itself.
-     * 
-     * @param element the element, or null
-     * @param schemaCollection the schema collection, for resolving types.
-     * @param javascriptName javascript variable name
-     * @param xmlElementName xml element string
-     * @return
-     */
-    public static ParticleInfo forPartElement(XmlSchemaElement element, SchemaCollection schemaCollection,
-                                              String javascriptName, String xmlElementName) {
-        ParticleInfo elementInfo = new ParticleInfo();
-        elementInfo.particle = element;
-        if (element == null) {
-            elementInfo.minOccurs = 1;
-            elementInfo.maxOccurs = 1;
-        } else {
-            elementInfo.minOccurs = element.getMinOccurs();
-            elementInfo.maxOccurs = element.getMaxOccurs();
-            elementInfo.nillable = element.isNillable();
-            factorySetupType(element, schemaCollection, elementInfo);
-        }
-        elementInfo.javascriptName = javascriptName;
-        elementInfo.xmlName = xmlElementName;
-        elementInfo.global = true;
-
-        return elementInfo;
-    }
-
-    /**
-     * Fill in an ElementInfo for an element or xs:any from a sequence.
-     * 
-     * @param sequenceElement
-     * @param currentSchema
-     * @param schemaCollection
-     * @param prefixAccumulator
-     * @return
-     */
-    public static ParticleInfo forLocalItem(XmlSchemaObject sequenceObject, XmlSchema currentSchema,
-                                            SchemaCollection schemaCollection,
-                                            NamespacePrefixAccumulator prefixAccumulator, QName contextName) {
-        XmlSchemaParticle sequenceParticle = XmlSchemaUtils.getObjectParticle(sequenceObject, contextName);
-        ParticleInfo elementInfo = new ParticleInfo();
-        XmlSchemaParticle realParticle = sequenceParticle;
-
-        if (sequenceParticle instanceof XmlSchemaElement) {
-            XmlSchemaElement sequenceElement = (XmlSchemaElement)sequenceParticle;
-
-            if (sequenceElement.getRefName() != null) {
-                XmlSchemaElement refElement = schemaCollection
-                    .getElementByQName(sequenceElement.getRefName());
-                if (refElement == null) {
-                    Message message = new Message("ELEMENT_DANGLING_REFERENCE", LOG, sequenceElement
-                        .getQName(), sequenceElement.getRefName());
-                    throw new UnsupportedConstruct(message.toString());
-                }
-                realParticle = refElement;
-                elementInfo.global = true;
-            }
-            elementInfo.nillable = ((XmlSchemaElement)realParticle).isNillable();
-        }
-
-        elementInfo.minOccurs = sequenceParticle.getMinOccurs();
-        elementInfo.maxOccurs = sequenceParticle.getMaxOccurs();
-
-        factoryCommon(realParticle, currentSchema, schemaCollection, prefixAccumulator, elementInfo);
-
-        elementInfo.particle = realParticle;
-
-        return elementInfo;
-    }
-
-    private static void factoryCommon(XmlSchemaParticle particle, XmlSchema currentSchema,
-                                      SchemaCollection schemaCollection,
-                                      NamespacePrefixAccumulator prefixAccumulator, 
-                                      ParticleInfo elementInfo) {
-
-        if (particle instanceof XmlSchemaElement) {
-            XmlSchemaElement element = (XmlSchemaElement)particle;
-            String elementNamespaceURI = element.getQName().getNamespaceURI();
-            boolean elementNoNamespace = "".equals(elementNamespaceURI);
-
-            XmlSchema elementSchema = null;
-            if (!elementNoNamespace) {
-                elementSchema = schemaCollection.getSchemaByTargetNamespace(elementNamespaceURI);
-                if (elementSchema == null) {
-                    throw new RuntimeException("Missing schema " + elementNamespaceURI);
-                }
-            }
-
-            boolean qualified = !elementNoNamespace
-                                && XmlSchemaUtils.isElementQualified(element, true, currentSchema,
-                                                                     elementSchema);
-            elementInfo.xmlName = prefixAccumulator.xmlElementString(element, qualified);
-            // we are assuming here that we are not dealing, in close proximity,
-            // with elements with identical local names and different
-            // namespaces.
-            elementInfo.javascriptName = element.getQName().getLocalPart();
-            elementInfo.defaultValue = element.getDefaultValue();
-            factorySetupType(element, schemaCollection, elementInfo);
-        } else { // any
-            elementInfo.any = true;
-            elementInfo.xmlName = null; // unknown until runtime.
-            // TODO: multiple 'any'
-            elementInfo.javascriptName = "any";
-            elementInfo.type = null; // runtime for any.
-
-        }
-    }
-
-    private static void factorySetupType(XmlSchemaElement element, SchemaCollection schemaCollection,
-                                         ParticleInfo elementInfo) {
-        elementInfo.type = element.getSchemaType();
-        if (elementInfo.type == null) {
-            if (element.getSchemaTypeName().equals(XmlSchemaConstants.ANY_TYPE_QNAME)) {
-                elementInfo.anyType = true;
-            } else {
-                elementInfo.type = schemaCollection.getTypeByQName(element.getSchemaTypeName());
-                if (elementInfo.type == null 
-                    && !element.getSchemaTypeName()
-                            .getNamespaceURI().equals(XmlSchemaConstants.XSD_NAMESPACE_URI)) {
-                    XmlSchemaUtils.unsupportedConstruct("MISSING_TYPE", element.getSchemaTypeName()
-                            .toString(), element.getQName(), element);
-                }
-            }
-        }
-    }
-
-    /**
-     * As a general rule, the JavaScript code is organized by types. The
-     * exception is global elements that have anonymous types. In those cases,
-     * the JavaScript code has its functions named according to the element.
-     * This method returns the QName for the type or element, accordingly. If a
-     * schema has a local element with an anonymous, complex, type, this will
-     * throw. This will need to be fixed.
-     * 
-     * @return the qname.
-     */
-    public QName getControllingName() {
-        if (type != null && type.getQName() != null) {
-            return type.getQName();
-        } else if (particle instanceof XmlSchemaElement) {
-            XmlSchemaElement element = (XmlSchemaElement)particle;
-            if (element.getQName() != null) {
-                return element.getQName();
-            }
-        }
-        Message message = new Message("IMPOSSIBLE_GLOBAL_ITEM", LOG, XmlSchemaUtils
-            .cleanedUpSchemaSource(particle));
-        LOG.severe(message.toString());
-        throw new UnsupportedConstruct(message);
-    }
-
-    public XmlSchemaParticle getParticle() {
-        return particle;
-    }
-
-    public String getJavascriptName() {
-        return javascriptName;
-    }
-
-    public void setJavascriptName(String name) {
-        javascriptName = name;
-    }
-
-    public String getXmlName() {
-        return xmlName;
-    }
-
-    public void setXmlName(String elementXmlName) {
-        this.xmlName = elementXmlName;
-    }
-
-    public XmlSchemaType getContainingType() {
-        return containingType;
-    }
-
-    public void setContainingType(XmlSchemaType containingType) {
-        this.containingType = containingType;
-    }
-
-    public XmlSchemaType getType() {
-        return type;
-    }
-
-    public void setType(XmlSchemaType type) {
-        this.type = type;
-    }
-
-    public boolean isEmpty() {
-        return empty;
-    }
-
-    public void setEmpty(boolean empty) {
-        this.empty = empty;
-    }
-
-    public long getMinOccurs() {
-        return minOccurs;
-    }
-
-    public long getMaxOccurs() {
-        return maxOccurs;
-    }
-
-    public boolean isArray() {
-        return maxOccurs > 1;
-    }
-
-    public boolean isOptional() {
-        return minOccurs == 0 && maxOccurs == 1;
-    }
-
-    /**
-     * @return Returns the nillable flag for the element. False for 'xs:any'
-     */
-    public boolean isNillable() {
-        return nillable;
-    }
-
-    public boolean isAny() {
-        return any;
-    }
-
-    public boolean isAnyType() {
-        return anyType;
-    }
-
-    /**
-     * *
-     * 
-     * @return Returns the defaultValue.
-     */
-    public String getDefaultValue() {
-        if (isOptional()) {
-            return "null";
-        } else {
-            return defaultValue;
-        }
-    }
-
-    /**
-     * @param defaultValue The defaultValue to set.
-     */
-    public void setDefaultValue(String defaultValue) {
-        this.defaultValue = defaultValue;
-    }
-
-    /**
-     * True if this describes a global, named, element.
-     * 
-     * @return
-     */
-    public boolean isGlobal() {
-        return global;
-    }
-}
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.javascript;
+
+import java.util.logging.Logger;
+
+import javax.xml.namespace.QName;
+
+import org.apache.cxf.common.i18n.Message;
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.common.xmlschema.SchemaCollection;
+import org.apache.cxf.common.xmlschema.XmlSchemaConstants;
+import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaElement;
+import org.apache.ws.commons.schema.XmlSchemaObject;
+import org.apache.ws.commons.schema.XmlSchemaParticle;
+import org.apache.ws.commons.schema.XmlSchemaType;
+
+/**
+ * All the information needed to create the JavaScript for an Xml Schema element
+ * or xs:any.
+ */
+public final class ParticleInfo {
+    private static final Logger LOG = LogUtils.getL7dLogger(ParticleInfo.class);
+    private XmlSchemaParticle particle;
+    private String javascriptName;
+    private String xmlName;
+    private XmlSchemaType containingType;
+    // in the RPC case, we can have a type and no element.
+    private XmlSchemaType type;
+    private boolean empty;
+    // These are exactly the same values as we find in the XmlSchemaElement.
+    // there is no rationalization. But the accessors take care of business.
+    private long minOccurs;
+    private long maxOccurs;
+    private boolean nillable;
+    private boolean any;
+    private boolean anyType;
+    private String defaultValue;
+    private boolean global;
+
+    private ParticleInfo() {
+    }
+
+    /**
+     * Create an elementInfo that stores information about a global, named,
+     * element.
+     * 
+     * @param element the element
+     * @param currentSchema the schema it came from.
+     * @param schemaCollection the collection of all schemas.
+     * @param prefixAccumulator the accumulator that assigns prefixes.
+     * @return
+     */
+    public static ParticleInfo forGlobalElement(XmlSchemaElement element, XmlSchema currentSchema,
+                                                SchemaCollection schemaCollection,
+                                                NamespacePrefixAccumulator prefixAccumulator) {
+        ParticleInfo elementInfo = new ParticleInfo();
+        elementInfo.particle = element;
+        elementInfo.minOccurs = element.getMinOccurs();
+        elementInfo.maxOccurs = element.getMaxOccurs();
+        elementInfo.nillable = element.isNillable();
+        elementInfo.global = true;
+
+        factoryCommon(element, currentSchema, schemaCollection, prefixAccumulator, elementInfo);
+        return elementInfo;
+    }
+
+    /**
+     * Create element information for a part element. For a part, the JavaScript
+     * and Element names are calculated in advance, and the element itself might
+     * be null! In that case, the minOccurs and maxOccurs are conventional. Note
+     * that in some cases the code in ServiceJavascriptBuilder uses a local
+     * element (or xa:any) from inside the part element, instead of the part
+     * element itself.
+     * 
+     * @param element the element, or null
+     * @param schemaCollection the schema collection, for resolving types.
+     * @param javascriptName javascript variable name
+     * @param xmlElementName xml element string
+     * @return
+     */
+    public static ParticleInfo forPartElement(XmlSchemaElement element, SchemaCollection schemaCollection,
+                                              String javascriptName, String xmlElementName) {
+        ParticleInfo elementInfo = new ParticleInfo();
+        elementInfo.particle = element;
+        if (element == null) {
+            elementInfo.minOccurs = 1;
+            elementInfo.maxOccurs = 1;
+        } else {
+            elementInfo.minOccurs = element.getMinOccurs();
+            elementInfo.maxOccurs = element.getMaxOccurs();
+            elementInfo.nillable = element.isNillable();
+            factorySetupType(element, schemaCollection, elementInfo);
+        }
+        elementInfo.javascriptName = javascriptName;
+        elementInfo.xmlName = xmlElementName;
+        elementInfo.global = true;
+
+        return elementInfo;
+    }
+
+    /**
+     * Fill in an ElementInfo for an element or xs:any from a sequence.
+     * 
+     * @param sequenceElement
+     * @param currentSchema
+     * @param schemaCollection
+     * @param prefixAccumulator
+     * @return
+     */
+    public static ParticleInfo forLocalItem(XmlSchemaObject sequenceObject, XmlSchema currentSchema,
+                                            SchemaCollection schemaCollection,
+                                            NamespacePrefixAccumulator prefixAccumulator, QName contextName) {
+        XmlSchemaParticle sequenceParticle = XmlSchemaUtils.getObjectParticle(sequenceObject, contextName);
+        ParticleInfo elementInfo = new ParticleInfo();
+        XmlSchemaParticle realParticle = sequenceParticle;
+
+        if (sequenceParticle instanceof XmlSchemaElement) {
+            XmlSchemaElement sequenceElement = (XmlSchemaElement)sequenceParticle;
+
+            if (sequenceElement.getRefName() != null) {
+                XmlSchemaElement refElement = schemaCollection
+                    .getElementByQName(sequenceElement.getRefName());
+                if (refElement == null) {
+                    Message message = new Message("ELEMENT_DANGLING_REFERENCE", LOG, sequenceElement
+                        .getQName(), sequenceElement.getRefName());
+                    throw new UnsupportedConstruct(message.toString());
+                }
+                realParticle = refElement;
+                elementInfo.global = true;
+            }
+            elementInfo.nillable = ((XmlSchemaElement)realParticle).isNillable();
+        }
+
+        elementInfo.minOccurs = sequenceParticle.getMinOccurs();
+        elementInfo.maxOccurs = sequenceParticle.getMaxOccurs();
+
+        factoryCommon(realParticle, currentSchema, schemaCollection, prefixAccumulator, elementInfo);
+
+        elementInfo.particle = realParticle;
+
+        return elementInfo;
+    }
+
+    private static void factoryCommon(XmlSchemaParticle particle, XmlSchema currentSchema,
+                                      SchemaCollection schemaCollection,
+                                      NamespacePrefixAccumulator prefixAccumulator, 
+                                      ParticleInfo elementInfo) {
+
+        if (particle instanceof XmlSchemaElement) {
+            XmlSchemaElement element = (XmlSchemaElement)particle;
+            String elementNamespaceURI = element.getQName().getNamespaceURI();
+            boolean elementNoNamespace = "".equals(elementNamespaceURI);
+
+            XmlSchema elementSchema = null;
+            if (!elementNoNamespace) {
+                elementSchema = schemaCollection.getSchemaByTargetNamespace(elementNamespaceURI);
+                if (elementSchema == null) {
+                    throw new RuntimeException("Missing schema " + elementNamespaceURI);
+                }
+            }
+
+            boolean qualified = !elementNoNamespace
+                                && XmlSchemaUtils.isElementQualified(element, true, currentSchema,
+                                                                     elementSchema);
+            elementInfo.xmlName = prefixAccumulator.xmlElementString(element, qualified);
+            // we are assuming here that we are not dealing, in close proximity,
+            // with elements with identical local names and different
+            // namespaces.
+            elementInfo.javascriptName = element.getQName().getLocalPart();
+            elementInfo.defaultValue = element.getDefaultValue();
+            factorySetupType(element, schemaCollection, elementInfo);
+        } else { // any
+            elementInfo.any = true;
+            elementInfo.xmlName = null; // unknown until runtime.
+            // TODO: multiple 'any'
+            elementInfo.javascriptName = "any";
+            elementInfo.type = null; // runtime for any.
+
+        }
+    }
+
+    private static void factorySetupType(XmlSchemaElement element, SchemaCollection schemaCollection,
+                                         ParticleInfo elementInfo) {
+        elementInfo.type = element.getSchemaType();
+        if (elementInfo.type == null) {
+            if (element.getSchemaTypeName().equals(XmlSchemaConstants.ANY_TYPE_QNAME)) {
+                elementInfo.anyType = true;
+            } else {
+                elementInfo.type = schemaCollection.getTypeByQName(element.getSchemaTypeName());
+                if (elementInfo.type == null 
+                    && !element.getSchemaTypeName()
+                            .getNamespaceURI().equals(XmlSchemaConstants.XSD_NAMESPACE_URI)) {
+                    XmlSchemaUtils.unsupportedConstruct("MISSING_TYPE", element.getSchemaTypeName()
+                            .toString(), element.getQName(), element);
+                }
+            }
+        }
+    }
+
+    /**
+     * As a general rule, the JavaScript code is organized by types. The
+     * exception is global elements that have anonymous types. In those cases,
+     * the JavaScript code has its functions named according to the element.
+     * This method returns the QName for the type or element, accordingly. If a
+     * schema has a local element with an anonymous, complex, type, this will
+     * throw. This will need to be fixed.
+     * 
+     * @return the qname.
+     */
+    public QName getControllingName() {
+        if (type != null && type.getQName() != null) {
+            return type.getQName();
+        } else if (particle instanceof XmlSchemaElement) {
+            XmlSchemaElement element = (XmlSchemaElement)particle;
+            if (element.getQName() != null) {
+                return element.getQName();
+            }
+        }
+        Message message = new Message("IMPOSSIBLE_GLOBAL_ITEM", LOG, XmlSchemaUtils
+            .cleanedUpSchemaSource(particle));
+        LOG.severe(message.toString());
+        throw new UnsupportedConstruct(message);
+    }
+
+    public XmlSchemaParticle getParticle() {
+        return particle;
+    }
+
+    public String getJavascriptName() {
+        return javascriptName;
+    }
+
+    public void setJavascriptName(String name) {
+        javascriptName = name;
+    }
+
+    public String getXmlName() {
+        return xmlName;
+    }
+
+    public void setXmlName(String elementXmlName) {
+        this.xmlName = elementXmlName;
+    }
+
+    public XmlSchemaType getContainingType() {
+        return containingType;
+    }
+
+    public void setContainingType(XmlSchemaType containingType) {
+        this.containingType = containingType;
+    }
+
+    public XmlSchemaType getType() {
+        return type;
+    }
+
+    public void setType(XmlSchemaType type) {
+        this.type = type;
+    }
+
+    public boolean isEmpty() {
+        return empty;
+    }
+
+    public void setEmpty(boolean empty) {
+        this.empty = empty;
+    }
+
+    public long getMinOccurs() {
+        return minOccurs;
+    }
+
+    public long getMaxOccurs() {
+        return maxOccurs;
+    }
+
+    public boolean isArray() {
+        return maxOccurs > 1;
+    }
+
+    public boolean isOptional() {
+        return minOccurs == 0 && maxOccurs == 1;
+    }
+
+    /**
+     * @return Returns the nillable flag for the element. False for 'xs:any'
+     */
+    public boolean isNillable() {
+        return nillable;
+    }
+
+    public boolean isAny() {
+        return any;
+    }
+
+    public boolean isAnyType() {
+        return anyType;
+    }
+
+    /**
+     * *
+     * 
+     * @return Returns the defaultValue.
+     */
+    public String getDefaultValue() {
+        if (isOptional()) {
+            return "null";
+        } else {
+            return defaultValue;
+        }
+    }
+
+    /**
+     * @param defaultValue The defaultValue to set.
+     */
+    public void setDefaultValue(String defaultValue) {
+        this.defaultValue = defaultValue;
+    }
+
+    /**
+     * True if this describes a global, named, element.
+     * 
+     * @return
+     */
+    public boolean isGlobal() {
+        return global;
+    }
+}

Propchange: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/ParticleInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/ParticleInfo.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/XmlSchemaUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/XmlSchemaUtils.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date



Mime
View raw message