Author: oshani
Date: Sun Aug 20 07:04:25 2006
New Revision: 432970
URL: http://svn.apache.org/viewvc?rev=432970&view=rev
Log:
Removed deprecated getName method of OMNamespace, and also fixed some
trivial code warnings.
Modified:
incubator/woden/branches/WODEN-44/src/org/apache/woden/internal/OMElementSource.java
incubator/woden/branches/WODEN-44/src/org/apache/woden/internal/OMWSDLReader.java
incubator/woden/branches/WODEN-44/src/org/apache/woden/internal/util/om/OMQNameUtils.java
incubator/woden/branches/WODEN-44/src/org/apache/woden/internal/util/om/OMUtils.java
Modified:
incubator/woden/branches/WODEN-44/src/org/apache/woden/internal/OMElementSource.java
URL:
http://svn.apache.org/viewvc/incubator/woden/branches/WODEN-44/src/org/apache/woden/internal/OMElementSource.java?rev=432970&r1=432969&r2=432970&view=diff
==============================================================================
---
incubator/woden/branches/WODEN-44/src/org/apache/woden/internal/OMElementSource.java
(original)
+++
incubator/woden/branches/WODEN-44/src/org/apache/woden/internal/OMElementSource.java
Sun Aug 20 07:04:25 2006
@@ -90,7 +90,7 @@
String namespaceURI;
if (prefix != null){
- namespaceURI = elem.findNamespaceURI(prefix).getName();
+ namespaceURI = elem.findNamespaceURI(prefix).getNamespaceURI();
return new QName(namespaceURI,localPart,
prefix);
}
Modified:
incubator/woden/branches/WODEN-44/src/org/apache/woden/internal/OMWSDLReader.java
URL:
http://svn.apache.org/viewvc/incubator/woden/branches/WODEN-44/src/org/apache/woden/internal/OMWSDLReader.java?rev=432970&r1=432969&r2=432970&view=diff
==============================================================================
---
incubator/woden/branches/WODEN-44/src/org/apache/woden/internal/OMWSDLReader.java
(original)
+++
incubator/woden/branches/WODEN-44/src/org/apache/woden/internal/OMWSDLReader.java
Sun Aug 20 07:04:25 2006
@@ -77,7 +77,7 @@
public class OMWSDLReader extends BaseWSDLReader{
//A map of imported schema definitions keyed by schema location URI
- private Map fImportedSchemas = new Hashtable();
+ private Map<String,XmlSchema> fImportedSchemas = new Hashtable<String,
XmlSchema>();
public OMWSDLReader() throws WSDLException {
super();
@@ -95,20 +95,14 @@
throw new WSDLException(WSDLException.PARSER_ERROR, msg, e);
}
- //This is needed because StAXOMBuilder expects a URI to read a WSDL
- int index = wsdlURI.indexOf(':');
- String wsdlURL = (index != -1)
- ? wsdlURI
- : ("file://"+wsdlURI);
+ OMElement wsdlDescription = OMUtils.getElement(url.toString());
- OMElement wsdlDescription = OMUtils.getElement(wsdlURL);
-
- return parseDescription(wsdlURL, wsdlDescription, null);
+ return parseDescription(url.toString(), wsdlDescription, null);
}
private DescriptionElement parseDescription(String documentBaseURI,
OMElement omDescription,
- Map wsdlModules)
+ Map<String,DescriptionElement>
wsdlModules)
throws WSDLException {
checkElementName(omDescription,Constants.Q_ELEM_DESCRIPTION);
@@ -119,7 +113,7 @@
if(wsdlModules == null){
//This is the initial WSDL document. No imports or includes yet.
//TODO this might be the place to flag the initial Desc if
necessary.
- wsdlModules = new HashMap();
+ wsdlModules = new HashMap<String, DescriptionElement>();
}
if(getExtensionRegistry() != null){
@@ -142,7 +136,7 @@
while(namespaces.hasNext()){
OMNamespace namespace = (OMNamespace)namespaces.next();
String localPart = namespace.getPrefix();
- String value = namespace.getName();
+ String value = namespace.getNamespaceURI();
if (!(Constants.ATTR_XMLNS).equals(localPart)){
desc.addNamespace(localPart, getURI(value)); //a prefixed
namespace
@@ -379,7 +373,7 @@
binding.setName(new NCName(name));
}
- QName intfaceQN = null;
+ QName intfaceQN;
String intface = OMUtils.getAttribute(bindEl,
Constants.ATTR_INTERFACE);
if(intface != null){
try{
@@ -437,7 +431,7 @@
BindingOperationElement oper = desc.createBindingOperationElement();
oper.setParentElement(parent);
- QName refQN = null;
+ QName refQN;
String ref = OMUtils.getAttribute(bindOpEl, Constants.ATTR_REF);
if(ref != null){
try{
@@ -498,7 +492,7 @@
BindingFaultReferenceElement faultRef =
desc.createBindingFaultReferenceElement();
faultRef.setParentElement(parent);
- QName refQN = null;
+ QName refQN;
String ref = OMUtils.getAttribute(faultRefEl, Constants.ATTR_REF);
if(ref != null){
try{
@@ -621,7 +615,7 @@
BindingFaultElement fault = desc.createBindingFaultElement();
fault.setParentElement(parent);
- QName intFltQN = null;
+ QName intFltQN;
String ref = OMUtils.getAttribute(bindFaultEl, Constants.ATTR_REF);
if(ref != null){
try{
@@ -671,10 +665,9 @@
String styleDefault = OMUtils.getAttribute(interfaceEl,
Constants.ATTR_STYLE_DEFAULT);
if(styleDefault != null){
List stringList = StringUtils.parseNMTokens(styleDefault);
- String uriString = null;
- Iterator it = stringList.iterator();
- while(it.hasNext()){
- uriString = (String)it.next();
+ String uriString;
+ for (Object aStringList : stringList) {
+ uriString = (String) aStringList;
intface.addStyleDefaultURI(getURI(uriString));
}
}
@@ -682,10 +675,9 @@
String extendsAttr = OMUtils.getAttribute(interfaceEl,
Constants.ATTR_EXTENDS);
if(extendsAttr != null){
List stringList = StringUtils.parseNMTokens(extendsAttr);
- String qnString = null;
- Iterator it = stringList.iterator();
- while(it.hasNext()){
- qnString = (String)it.next();
+ String qnString;
+ for (Object aStringList : stringList) {
+ qnString = (String) aStringList;
intface.addExtendedInterfaceName(OMUtils.getQName(qnString,
interfaceEl));
}
}
@@ -737,10 +729,9 @@
String style = OMUtils.getAttribute(operEl, Constants.ATTR_STYLE);
if(style != null){
List stringList = StringUtils.parseNMTokens(style);
- String uriString = null;
- Iterator it = stringList.iterator();
- while(it.hasNext()){
- uriString = (String)it.next();
+ String uriString;
+ for (Object aStringList : stringList) {
+ uriString = (String) aStringList;
oper.addStyleURI(getURI(uriString));
}
}
@@ -1081,11 +1072,11 @@
//Now try to retrieve the schema import using schemaLocation
- OMElement importedSchemaDoc = null;
- OMElement schemaEl = null;
+ OMElement importedSchemaDoc;
+ OMElement schemaEl;
URI contextURI = null;
String schemaLoc = null;
- URL url = null;
+ URL url;
try{
contextURI = desc.getDocumentBaseURI();
@@ -1113,7 +1104,7 @@
String schemaURL = url.toString();
//If the schema has already been imported, reuse it.
- XmlSchema schemaDef = (XmlSchema)fImportedSchemas.get(schemaURL);
+ XmlSchema schemaDef = fImportedSchemas.get(schemaURL);
if(schemaDef == null){
//not previously imported, so retrieve it now.
@@ -1224,7 +1215,7 @@
}
String req = OMUtils.getAttribute(featEl, Constants.ATTR_REQUIRED);
- feature.setRequired(Constants.VALUE_TRUE.equals(req) ? true : false);
+ feature.setRequired(Constants.VALUE_TRUE.equals(req));
//TODO t.b.c. what if attr value is not 'true' or 'false'? (eg,
missing, mispelt or not lower case.
@@ -1258,7 +1249,7 @@
private ImportElement parseImport(OMElement importEl,
DescriptionElement desc,
- Map wsdlModules)
+ Map<String,DescriptionElement>
wsdlModules)
throws WSDLException{
ImportElement imp = desc.createImportElement();
@@ -1285,7 +1276,7 @@
private IncludeElement parseInclude(OMElement includeEl,
DescriptionElement desc,
- Map wsdlModules)
+ Map<String,DescriptionElement>
wsdlModules)
throws WSDLException{
IncludeElement include = desc.createIncludeElement();
@@ -1312,7 +1303,7 @@
throws WSDLException {
QName elementType = OMQNameUtils.newQName(el);
- String namespaceURI = el.getNamespace().getName();
+ String namespaceURI = el.getNamespace().getNamespaceURI();
try{
if (namespaceURI == null ||
namespaceURI.equals(Constants.NS_URI_WSDL20)){
getErrorReporter().reportError(
@@ -1441,7 +1432,7 @@
*/
private DescriptionElement getWSDLFromLocation(String locationURI,
DescriptionElement desc,
- Map wsdlModules)
+
Map<String,DescriptionElement> wsdlModules)
throws WSDLException{
DescriptionElement referencedDesc = null;
OMElement docEl;
@@ -1469,7 +1460,7 @@
String locationStr = locationURL.toString();
//Check if WSDL imported or included previously from this location.
- referencedDesc = (DescriptionElement)wsdlModules.get(locationStr);
+ referencedDesc = wsdlModules.get(locationStr);
if(referencedDesc == null){
//not previously imported or included, so retrieve the WSDL.
Modified:
incubator/woden/branches/WODEN-44/src/org/apache/woden/internal/util/om/OMQNameUtils.java
URL:
http://svn.apache.org/viewvc/incubator/woden/branches/WODEN-44/src/org/apache/woden/internal/util/om/OMQNameUtils.java?rev=432970&r1=432969&r2=432970&view=diff
==============================================================================
---
incubator/woden/branches/WODEN-44/src/org/apache/woden/internal/util/om/OMQNameUtils.java
(original)
+++
incubator/woden/branches/WODEN-44/src/org/apache/woden/internal/util/om/OMQNameUtils.java
Sun Aug 20 07:04:25 2006
@@ -41,7 +41,7 @@
public static QName newQName(OMElement element){
if (element != null){
OMNamespace namespace = element.getNamespace();
- return new QName(namespace.getName(), element.getLocalName());
+ return new QName(namespace.getNamespaceURI(), element.getLocalName());
}
else{
return null;
Modified:
incubator/woden/branches/WODEN-44/src/org/apache/woden/internal/util/om/OMUtils.java
URL:
http://svn.apache.org/viewvc/incubator/woden/branches/WODEN-44/src/org/apache/woden/internal/util/om/OMUtils.java?rev=432970&r1=432969&r2=432970&view=diff
==============================================================================
---
incubator/woden/branches/WODEN-44/src/org/apache/woden/internal/util/om/OMUtils.java
(original)
+++
incubator/woden/branches/WODEN-44/src/org/apache/woden/internal/util/om/OMUtils.java
Sun Aug 20 07:04:25 2006
@@ -42,8 +42,6 @@
*/
public class OMUtils {
- private static final String emptyString = "";
-
/**
* @param strUri The URI where the WSDL can be found
* @return A StAXOMBuilder which could be used in obtaining the document
object
@@ -74,8 +72,7 @@
*/
public static OMElement getElement(String uri){
StAXOMBuilder builder = OMUtils.getOMBuilder(uri);
- OMElement elem = builder.getDocumentElement();
- return elem;
+ return builder.getDocumentElement();
}
/**
@@ -103,21 +100,21 @@
*/
public static InputSource getInputSource(OMElement element){
- String elementString = null;
+ String elementString;
+ byte[] bytes = new byte[0];
//Obtain the String value of the OMElement after building the OM tree
try {
elementString = element.toStringWithConsume();
+ bytes= elementString.getBytes();
} catch (XMLStreamException e) {
e.printStackTrace();
}
- byte[] bytes = elementString.getBytes();
//Deserialize from a byte array
InputStream inputStream = new ByteArrayInputStream(bytes);
- InputSource inputSource = new InputSource(inputStream);
- return inputSource;
+ return new InputSource(inputStream);
}
/**
@@ -134,33 +131,27 @@
? prefixedValue.substring(0, index)
: null;
String localPart = prefixedValue.substring(index + 1);
- String namespaceURI = null;
+ String namespaceURI;
if (prefix != null){
- namespaceURI = contextEl.findNamespaceURI(prefix).getName();
+ namespaceURI =
contextEl.findNamespaceURI(prefix).getNamespaceURI();
//TODO investigate changing the registration of namespaces and
prefixes (i.e. namespace decls)
//so it can happen within any WSDL element, not just Description
(current behaviour is copied from WSDL4J)
//registerUniquePrefix(prefix, namespaceURI, desc);
//TODO when passing prefix to QName ctor, what if it was modified
by
//registerUniquePrefix because of a name clash (pass original or
modification)?
- return new QName(namespaceURI,
- localPart,
- prefix != null ? prefix : emptyString);
+ return new QName(namespaceURI, localPart, prefix);
}
else{
//TODO use ErrorReporter here or in callers to report the problem
- String faultCode = (prefix == null)
- ? WSDLException.NO_PREFIX_SPECIFIED
- : WSDLException.UNBOUND_PREFIX;
+ String faultCode = WSDLException.NO_PREFIX_SPECIFIED;
- WSDLException wsdlExc = new WSDLException(faultCode,
+ throw new WSDLException(faultCode,
"Unable to determine " +
"namespace of '" +
prefixedValue + "'.");
-
- throw wsdlExc;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]