FileDocCategorySizeDatePackage
BackslashUtil.javaAPI DocApache Axis 1.43068Sat Apr 22 18:57:28 BST 2006org.apache.axis.wsdl.symbolTable

BackslashUtil

public class BackslashUtil extends Object implements Serializable
author
dbyrne Created in response to AXIS-2088. This class exposes a handful of static utility methods that are used to manipulate backslash chars w/in the context of QName objects.

Fields Summary
Constructors Summary
Methods Summary
public static java.lang.StringapplyBackslashes(java.lang.String string)
Slave method for getQNameWithBackslashedLocal()

		return transformBackslashes(string, false);
	
public static javax.xml.namespace.QNamegetQNameWithBackslashedLocal(javax.xml.namespace.QName suspectQName)

param
QName[local] which may contain unescaped backslashes
return
QName[local] w/ escaped backslashes

		String trustedString = null;

		// get a wsdl:service[@name] with safe backslashes
		trustedString = applyBackslashes(suspectQName.getLocalPart());
		return getQNameWithDifferentLocal(suspectQName, trustedString);
	
public static javax.xml.namespace.QNamegetQNameWithBackslashlessLocal(javax.xml.namespace.QName suspectQName)

param
QName[local] that may contain unescaped backslashes
return
QName[local] w/ no backslashes

		String trustedString = null;

		// get a wsdl:service[@name] that we can trust
		trustedString = stripBackslashes(suspectQName.getLocalPart());
		return getQNameWithDifferentLocal(suspectQName, trustedString);
	
public static javax.xml.namespace.QNamegetQNameWithDifferentLocal(javax.xml.namespace.QName qName, java.lang.String localName)
Creates a copy of the supplied QName w/ the supplied local name

		QName trustedQName = null;

		// recreate the QName, only w/ a local name we can trust.
		trustedQName = new QName(qName.getNamespaceURI(), localName, qName.getPrefix());
		return trustedQName;
	
public static java.lang.StringstripBackslashes(java.lang.String string)
Slave method for getQNameWithBackslashlessLocal

		return transformBackslashes(string, true);
	
public static java.lang.StringtransformBackslashes(java.lang.String string, boolean delete)
Slave method for applyBackslashes & stripBackslashes .

		byte[] suspectBytes = null;
		StringBuffer stringBuffer = null;
		
		suspectBytes = string.getBytes();
		stringBuffer = new StringBuffer(string);
		
		for (int b = suspectBytes.length - 1; b >= 0; b--) {
			if (suspectBytes[b] == 92) {
				if(delete){
					stringBuffer.delete(b, b + 1);
				}else{
					stringBuffer.insert(b, "\\");
				}
			}
		}
		return stringBuffer.toString();