FileDocCategorySizeDatePackage
MakeCldc1_0.javaAPI DocphoneME MR2 API (J2ME)6563Wed May 02 18:00:34 BST 2007com.sun.j2mews.sg

MakeCldc1_0

public class MakeCldc1_0 extends Object implements ProcessorAction
MakeCldc1_0 will take the internal data structures and coerce them to be CLDC 1.0 compliant (float and double become String).

Fields Summary
protected com.sun.xml.rpc.processor.util.ProcessorEnvironment
env
private Map
originalTypes
protected LocalizableMessageFactory
messageFactory
Constructors Summary
public MakeCldc1_0(Map originalTypes)

        messageFactory = new LocalizableMessageFactory("com.sun.j2mews.sg.stubgenerator");
        this.originalTypes = originalTypes;
    
Methods Summary
protected LocalizablegetMessage(java.lang.String key, java.lang.String arg)

        return messageFactory.getMessage(key, new Object[] {arg});
    
protected LocalizablegetMessage(java.lang.String key, java.lang.String arg1, java.lang.String arg2)

        return messageFactory.getMessage(key, new Object[] {arg1, arg2});
    
protected java.lang.StringjavaTypeToString(JavaType type, Port port)

        if (type == null)
            return null;
        String result;
        if (type.isHolder())
            result = env.getNames().holderClassName(port, type);
        else
            result = env.getNames().typeClassName(type);
        return result;
    
public voidmungeTo1_0(com.sun.xml.rpc.processor.model.Service service)

        for (Iterator it = service.getPorts(); it.hasNext(); ) {
            Port port = (Port) it.next();
            mungeTo1_0(port);
        }
    
protected voidmungeTo1_0(Port port)

        for (Iterator operations = port.getOperations(); operations.hasNext(); ) {
            Operation operation = (Operation) operations.next();
            mungeTo1_0(operation, port);
        }
    
protected voidmungeTo1_0(Operation operation, Port port)

        JavaMethod method = operation.getJavaMethod();
        //System.out.println("mungeTo1_0: method.getName="+method.getName());
        JavaType returnType = method.getReturnType();
        mungeTo1_0(returnType, port);
        for (Iterator parameters = method.getParameters(); parameters.hasNext(); ) {
            JavaParameter parameter = (JavaParameter) parameters.next();
            JavaType parameterType = parameter.getType();
            mungeTo1_0(parameterType, port);
        }
        for (Iterator faults = operation.getFaults(); faults.hasNext(); ) {
            Fault fault = (Fault) faults.next();
            Block faultBlock = fault.getBlock();
            JavaException jexcep = fault.getJavaException();
            mungeTo1_0(jexcep, port);
        }
    
protected voidmungeTo1_0(JavaType type, Port port)

        //System.out.println("mungeTo1_0: type="+type);
        if (type == null)
            return;
        if (type instanceof JavaSimpleType) {
            String typeName = javaTypeToString(type, port).intern();
            //System.out.println("typeName="+typeName);
            if (typeName == "float" || typeName == "Float" ||
                typeName == "java.lang.Float" || typeName == "double" ||
                typeName == "Double" || typeName == "java.lang.Double") {
                //System.out.println("Found odd type: "+typeName+" name="+type.getName());
                originalTypes.put(type, typeName);
                type.doSetName("java.lang.String");
            }
        } else if (type instanceof JavaStructureType) {
            JavaStructureType jst = (JavaStructureType) type;
            for (Iterator members = jst.getMembers(); members.hasNext(); ) {
                JavaStructureMember jsm = (JavaStructureMember) members.next();
                JavaType memberType = jsm.getType();
                mungeTo1_0(memberType, port);
            }
        } else if (type instanceof JavaArrayType) {
            JavaArrayType jat = (JavaArrayType) type;
            JavaType elementType = jat.getElementType();
            mungeTo1_0(elementType, port);
            if (originalTypes.containsKey(elementType)) {
                String typeName = javaTypeToString(type, port);
                //System.out.println("Changing array type, was: "+typeName);
                originalTypes.put(type, typeName);
                jat.doSetName(elementType.getName()+"[]");
            }
        } else if (type instanceof JavaEnumerationType) {
            JavaEnumerationType jet = (JavaEnumerationType) type;
            JavaType baseType = jet.getBaseType();
            mungeTo1_0(baseType, port);
        } else {
            onWarning(getMessage("stubgenerator.unknownType", "mungeTo1_0", type.toString()));
        }
    
protected voidonWarning(Localizable msg)

        //System.err.println("Warning: "+msg);
        env.warn(msg);
    
public voidperform(com.sun.xml.rpc.processor.model.Model model, com.sun.xml.rpc.processor.config.Configuration config, java.util.Properties options)

        //env = config.getEnvironment();
        for (Iterator it = model.getServices(); it.hasNext(); ) {
            Service service = (Service) it.next();
            mungeTo1_0(service);
        }
    
public voidsetEnvironment(com.sun.xml.rpc.processor.util.ProcessorEnvironment e)

        env = e;