FileDocCategorySizeDatePackage
Util.javaAPI DocJava SE 6 API5277Tue Jun 10 00:22:32 BST 2008com.sun.org.apache.xalan.internal.xsltc.compiler.util

Util

public final class Util extends Object
author
Jacek Ambroziak
author
Santiago Pericas-Geertsen

Fields Summary
private static char
filesep
Constructors Summary
Methods Summary
public static voidTRACE1()

	System.out.println("TRACE1");
    
public static voidTRACE2()

	System.out.println("TRACE2");
    
public static voidTRACE3()

	System.out.println("TRACE3");
    
public static java.lang.StringbaseName(java.lang.String name)
Search for both slashes in order to support URLs and files.

	int index = name.lastIndexOf('\\");
	if (index < 0) {
	    index = name.lastIndexOf('/");
	}
	
	if (index >= 0)
	    return name.substring(index + 1);
	else {
	    int lastColonIndex = name.lastIndexOf(':");
	    if (lastColonIndex > 0)
	    	return name.substring(lastColonIndex + 1);
	    else
	    	return name;
	}
    
public static java.lang.Stringescape(java.lang.String input)
Replace occurances of '.', '-', '/' and ':'

	return replace(input, ".-/:", 
	    new String[] { "$dot$", "$dash$", "$slash$", "$colon$" });
    
public static com.sun.org.apache.bcel.internal.generic.TypegetJCRefType(java.lang.String signature)

	return Type.getType(signature);
    
public static java.lang.StringgetLocalName(java.lang.String qname)

	final int index = qname.lastIndexOf(":");
	return (index > 0) ? qname.substring(index + 1) : qname;
    
public static java.lang.StringgetPrefix(java.lang.String qname)

	final int index = qname.lastIndexOf(":");
	return (index > 0) ? qname.substring(0, index) : 
	    Constants.EMPTYSTRING;
    
public static java.lang.StringinternalName(java.lang.String cname)

	return cname.replace('.", filesep);
    
public static booleanisLiteral(java.lang.String str)
Checks if the string is a literal (i.e. not an AVT) or not.

        final int length = str.length();
        for (int i = 0; i < length - 1; i++) {
            if (str.charAt(i) == '{" && str.charAt(i + 1) != '{") {
        	return false;
            }
        }
        return true;
    
public static booleanisValidQNames(java.lang.String str)
Checks if the string is valid list of qnames

        if ((str != null) && (!str.equals(Constants.EMPTYSTRING))) {
            final StringTokenizer tokens = new StringTokenizer(str);
            while (tokens.hasMoreTokens()) {
                if (!XML11Char.isXML11ValidQName(tokens.nextToken())) {
                    return false;
                }
            }
        }
        return true;
    
public static java.lang.StringnoExtName(java.lang.String name)

	String temp = System.getProperty("file.separator", "/");
	filesep = temp.charAt(0);
    
	final int index = name.lastIndexOf('.");
	return name.substring(0, index >= 0 ? index : name.length());
    
public static java.lang.StringpathName(java.lang.String name)
Search for both slashes in order to support URLs and files.

	int index = name.lastIndexOf('/");
	if (index < 0) {
	    index = name.lastIndexOf('\\");
	}
	return name.substring(0, index + 1);
    
public static voidprintln(java.lang.String s)

	System.out.println(s);
    
public static voidprintln(char ch)

	System.out.println(ch);
    
public static java.lang.Stringreplace(java.lang.String base, char ch, java.lang.String str)
Replace a certain character in a string with a new substring.

	return (base.indexOf(ch) < 0) ? base : 
	    replace(base, String.valueOf(ch), new String[] { str });
    
public static java.lang.Stringreplace(java.lang.String base, java.lang.String delim, java.lang.String[] str)

	final int len = base.length();
	final StringBuffer result = new StringBuffer();

	for (int i = 0; i < len; i++) {
	    final char ch = base.charAt(i);
	    final int k = delim.indexOf(ch);

	    if (k >= 0) {
		result.append(str[k]);
	    }
	    else {
		result.append(ch);
	    }
	}
	return result.toString();
    
public static java.lang.StringtoJavaName(java.lang.String name)
Replace all illegal Java chars by '_'.

	if (name.length() > 0) {
	    final StringBuffer result = new StringBuffer();

	    char ch = name.charAt(0);
	    result.append(Character.isJavaIdentifierStart(ch) ? ch : '_");

	    final int n = name.length();
	    for (int i = 1; i < n; i++) {
		ch = name.charAt(i);
		result.append(Character.isJavaIdentifierPart(ch)  ? ch : '_");
	    }
	    return result.toString();
	}
	return name;