Methods Summary |
---|
protected static java.lang.String | baseName(java.lang.String fullName)This will return a name from @param fullName where everything upto
and including the last '.' is removed.
eg: "java.lang.String[]" -> "String[]"
"java.util.ArrayList" -> "ArrayList"
int pos = fullName.lastIndexOf('.");
if (pos == -1)
return fullName;
return fullName.substring(pos+1, fullName.length());
|
public void | generate(com.sun.xml.rpc.processor.model.Service service)
for (Iterator it = service.getPorts(); it.hasNext(); ) {
port = (Port) it.next();
setFullClassName(getFullClassName());
generate();
}
|
protected void | generate()At this point, the service and port variables are set.
jw = new JavaWriter();
jw.comment("This class was generated by 172 StubGenerator.");
jw.comment("Contents subject to change without notice.");
jw.comment("@generated");
jw.cr();
jw.writePackage(packageName);
jw.cr();
writeImports();
generateClass();
writeOutGeneratedFile();
|
protected abstract void | generateClass()
|
protected java.util.List | getExpandedParametersList(JavaMethod method)
List parameterList = method.getParametersList();
if (parameterList.size() == 1 && expandArguments) {
JavaParameter parameter = (JavaParameter) parameterList.iterator().next();
Parameter p = parameter.getParameter();
JavaType parameterType = parameter.getType();
Block parameterBlock = p.getBlock();
boolean isNillable = parameterBlock.getType().isNillable();
if (parameterType instanceof JavaStructureType && !isNillable) {
JavaStructureType jst = (JavaStructureType) parameterType;
parameterList = new ArrayList(jst.getMembersCount());
for (Iterator members = jst.getMembers(); members.hasNext(); ) {
JavaStructureMember jsm = (JavaStructureMember) members.next();
String memberName = jsm.getName();
JavaType memberType = jsm.getType();
parameter = new JavaParameter(memberName, memberType, p);
parameterList.add(parameter);
}
}
}
return parameterList;
|
protected JavaType | getExpandedReturnType(JavaMethod method)
JavaType returnType = method.getReturnType();
if (returnType == null || "void".equals(javaTypeToString(returnType)))
return returnType;
boolean isNillable = false;
if (expandArguments && !isNillable &&
returnType instanceof JavaStructureType) {
JavaStructureType jst = (JavaStructureType) returnType;
if (jst.getMembersCount() == 1) {
returnType = ((JavaStructureMember)jst.getMembers().next()).getType();
}
}
return returnType;
|
protected abstract java.lang.String | getFullClassName()The port and env variables will be set correctly before
calling this method.
|
protected Localizable | getMessage(java.lang.String key)
return messageFactory.getMessage(key);
|
protected Localizable | getMessage(java.lang.String key, java.lang.String arg)
return messageFactory.getMessage(key, new Object[] {arg});
|
protected Localizable | getMessage(java.lang.String key, java.lang.String arg1, java.lang.String arg2)
return messageFactory.getMessage(key, new Object[] {arg1, arg2});
|
protected Localizable | getMessage(java.lang.String key, java.lang.String arg1, java.lang.String arg2, java.lang.String arg3)
return messageFactory.getMessage(key, new Object[] {arg1, arg2, arg3});
|
protected Localizable | getMessage(java.lang.String key, Localizable l)
return messageFactory.getMessage(key, new Object[] {l});
|
protected Localizable | getMessage(java.lang.String key, java.lang.Object[] args)
return messageFactory.getMessage(key, args);
|
protected abstract java.io.File | getSourceFile()The port and env variables will be set correctly before
calling this method.
This is the File that gets written to.
|
protected abstract java.lang.String | getSourceFileType()
|
protected java.lang.String | instanceOf(JavaType type, java.lang.String suffix, java.util.Map usedNames)
String name = type.getName();
return instanceOf(name, suffix, usedNames);
|
protected java.lang.String | instanceOf(JavaType type, java.util.Map usedNames)
return instanceOf(type, null, usedNames);
|
protected java.lang.String | instanceOf(javax.xml.namespace.QName name, java.lang.String suffix, java.util.Map usedNames)
return instanceOf(name.getLocalPart(), suffix, usedNames);
|
protected java.lang.String | instanceOf(java.lang.String name, java.lang.String suffix, java.util.Map usedNames)Make a variable name valid and unique.
int pos;
// Remove everything before the .
pos = name.lastIndexOf('.");
if (pos > 0)
name = name.substring(pos+1, name.length());
// Get rid of any trailing []
int arrayDimensions = 0;
while (name.endsWith("[]")) {
name = name.substring(0, name.length()-2);
++arrayDimensions;
}
for (int i = 0; i < arrayDimensions; ++i)
name += "Array";
if (JavaUtil.isPrimitiveType(name))
name = "a_"+name;
if (suffix != null)
name += suffix;
/*
// make first char lowercase
name = java.beans.Introspector.decapitalize(name);
*/
name = env.getNames().validJavaMemberName(name);
return makeUniq(name, usedNames);
|
public static boolean | isValidType(java.lang.String type)Is @param type valid for MIDP?
This assumes CLDC 1.1 (where float and double are okay).
if (type == null) // "void" type
return true;
type = type.intern();
if (type == "java.math.BigDecimal" || type == "java.math.BigInteger")
return false;
return true;
|
protected java.lang.String | javaTypeToString(JavaType type)
if (type == null)
return null;
String result;
if (type.isHolder())
result = env.getNames().holderClassName(port, type);
else
result = env.getNames().typeClassName(type);
return result;
|
protected java.lang.String | localize(Localizable msg)
return localizer.localize(msg);
|
protected void | log(java.lang.String msg)
if (env.verbose()) {
System.out.println("["+env.getNames().stripQualifier(this.getClass().getName())+": "+msg+"]");
}
|
protected java.lang.String | makeUniq(java.lang.String name, java.util.Map usedNames)Make a variable name unique.
Puts the name into usedNames.
if (usedNames.containsKey(name) || env.getNames().isJavaReservedWord(name)) {
String baseName = name;
for (int count = optimize ? 0 : 2; usedNames.containsKey(name); ++count)
name = baseName + (optimize ? Integer.toString(count, Character.MAX_RADIX) : ""+count);
}
usedNames.put(name, null);
return name;
|
protected java.lang.String | makeVarName(javax.xml.namespace.QName name, java.lang.String prefix, java.util.Map usedNames)Try to get a unique and somewhat nice looking name.
String result = prefix+name.getLocalPart();
result = result.replace('.", '_");
result = result.replace('/", '_");
result = result.replace(':", '_");
if (usedNames != null && usedNames.containsKey(result)) {
String abbrevNamespace = name.getNamespaceURI();
if (abbrevNamespace != null) {
int pos = abbrevNamespace.lastIndexOf('/");
if (pos >= 0)
abbrevNamespace = abbrevNamespace.substring(pos+1, abbrevNamespace.length());
abbrevNamespace = abbrevNamespace.replace('.", '_");
abbrevNamespace = abbrevNamespace.replace(':", '_");
abbrevNamespace = abbrevNamespace.replace('/", '_");
abbrevNamespace = abbrevNamespace.replace('%", '_");
result = prefix+abbrevNamespace+"_"+name.getLocalPart();
}
result = makeUniq(result, usedNames);
}
return result;
|
protected void | onError(Localizable msg)
//System.err.println("Error: "+msg);
env.error(msg);
|
protected void | onInfo(Localizable msg)
//System.err.println("Info: "+msg);
env.info(msg);
|
protected void | onWarning(Localizable msg)
//System.err.println("Warning: "+msg);
env.warn(msg);
|
public void | perform(com.sun.xml.rpc.processor.model.Model model, com.sun.xml.rpc.processor.config.Configuration config, java.util.Properties options)
//env = config.getEnvironment();
sourceDir = new File(options.getProperty(ProcessorOptions.SOURCE_DIRECTORY_PROPERTY));
if ("true".equals(options.getProperty(EXPAND_ARGUMENTS)))
expandArguments = true;
else
expandArguments = false;
if ("true".equals(options.getProperty(SHOW_ALL_CLDC1_0_INFO)))
showCldc1_0Info = true;
else
showCldc1_0Info = false;
if ("true".equals(options.getProperty(OPTIMIZE)))
optimize = true;
else
optimize = false;
try {
for (Iterator it = model.getServices(); it.hasNext(); ) {
service = (Service) it.next();
generate(service);
}
} catch (IOException e) {
throw new RuntimeException(e);
}
|
public void | setEnvironment(com.sun.xml.rpc.processor.util.ProcessorEnvironment e)
env = e;
|
protected void | setFullClassName(java.lang.String name)Sets the internal state of fullClassName, className, & packageName.
fullClassName = name;
int pos = fullClassName.lastIndexOf('.");
if (pos >= 0) {
packageName = fullClassName.substring(0, pos);
className = fullClassName.substring(pos+1, fullClassName.length());
} else {
packageName = null;
className = fullClassName;
}
|
public void | setLocalizer(Localizer l)
localizer = l;
|
protected void | writeImports()Here's your chance to import anything.
|
protected void | writeOutGeneratedFile()
File srcFile = getSourceFile();
log("Generating Java class for: "+srcFile.getName());
OutputStream out = new FileOutputStream(srcFile);
jw.writeTo(out);
out.close();
GeneratedFileInfo fi = new GeneratedFileInfo();
fi.setFile(srcFile);
fi.setType(getSourceFileType());
env.addGeneratedFile(fi);
|