Examples of IClass


Examples of org.jibx.util.IClass

        if (m_extendsName == null) {
            if (vctx.isLookupSupported() && !m_isAbstract) {
               
                // first check ancestor classes for ones with specific mappings
                DefinitionContext defc = vctx.getCurrentDefinitions();
                IClass sclass = getHandledClass().getSuperClass();
                if (sclass != null) {
                    TemplateElementBase stmpl =
                        defc.getSpecificTemplate(sclass.getName());
                    if (stmpl != null) {
                        if (stmpl instanceof MappingElementBase) {
                            MappingElementBase smap = (MappingElementBase)stmpl;
                            if (smap.getExtensionTypes().size() > 0) {
                                vctx.addWarning("Class " + getClassName() +
View Full Code Here

Examples of org.jibx.util.IClass

     *
     * @param type
     * @return item type, <code>null</code> if not a collection type
     */
    private boolean isCollection(String type, IClassLocator icl) {
        IClass info = icl.getRequiredClassInfo(type);
        return info.isImplements("Ljava/util/Collection;");
    }
View Full Code Here

Examples of org.jibx.util.IClass

                    case SignatureParser.TYPE_EVENT:
                        String type = parse.getType();
                        String itype = null;
                        if (parse.isParameterized()) {
                            String ptype = parameterType(parse);
                            IClass info = icl.getRequiredClassInfo(type);
                            if (info.isImplements("Ljava/util/Collection;")) {
                                itype = ptype;
                            }
                        }
                        if (inparms) {
                            ptypes[index] = type;
View Full Code Here

Examples of org.jibx.util.IClass

     * @param type constructed object type
     */
    protected void verifyConstruction(ValidationContext vctx, IClass type) {
        if (vctx.isInBinding() && getFactory() == null &&
            getUnmarshaller() == null) {
            IClass create = getCreateClass();
            if (create != null) {
                if (create.isAssignable(type)) {
                    type = create;
                } else {
                    vctx.addError("Specified create-type '" + create.getName() +
                        "' is not compatible with type '" +
                        type.getName() + '\'');
                }
            }
            if (type.isAbstract()) {
                vctx.addError("factory-method needed for abstract type '" +
                    type.getName() + '\'');
            } else if (!type.getName().endsWith("[]") &&
                type.getInitializerMethod("()V") == null &&
                !"java.lang.Enum".equals(type.getSuperClass().getName())) {
                BindingElement binding = vctx.getBindingRoot();
                if (binding.isAddConstructors()) {
                    if (!type.isModifiable()) {
                        vctx.addError("Need no-argument constructor or " +
                            "factory method for unmodifiable class " +
                            type.getName());
                    } else {
                        IClass suptype = type;
                        while ((suptype = suptype.getSuperClass()) != null) {
                            IClassItem cons = suptype.getInitializerMethod("()V");
                            if ((cons == null || !type.isAccessible(cons)) &&
                                !suptype.isModifiable()) {
                                vctx.addError("Need accessible no-argument constructor for unmodifiable class " +
                                    suptype.getName() + " (superclass of " + type.getName() + ')');
                            }
                        }
                    }
                } else {
                    vctx.addError("Need no-argument constructor or " +
View Full Code Here

Examples of org.jibx.util.IClass

        for (int i = 0; i < children.size(); i++) {
            ElementBase child = (ElementBase)children.get(i);
            boolean expand = true;
            if (child instanceof IComponent && !vctx.isSkipped(child)) {
                IComponent comp = (IComponent)child;
                IClass ctype = comp.getType();
                if (comp instanceof ContainerElementBase) {
                    ContainerElementBase contain = (ContainerElementBase)comp;
                    expand = !contain.hasObject();
                }
                if (comp.isImplicit()) {
                    if (!type.isAssignable(ctype)) {
                        vctx.addFatal
                            ("References to structure object must have " +
                            "compatible types: " + type.getName() +
                            " cannot be used as " + ctype.getName(), child);
                    }
                }
            }
            if (expand && child instanceof NestingElementBase) {
                checkCompatibleChildren(vctx, type,
View Full Code Here

Examples of org.jibx.util.IClass

            m_elementName = getParent().convertName(simple);
        }
        if (m_faultName == null) {
            m_faultName = m_elementName + "Fault";
        }
        IClass clas = icl.getRequiredClassInfo(m_exceptionType);
        if (m_fieldName == null) {
            IClassItem[] fields = clas.getFields();
            for (int i = 0; i < fields.length; i++) {
                IClassItem item = fields[i];
                String type = item.getTypeName();
                if (!Types.isSimpleValue(type)) {
                    IClass info = icl.getRequiredClassInfo(type);
                    if (info.isModifiable()) {
                        m_fieldName = item.getName();
                        m_dataType = type;
                        break;
                    }
                }
View Full Code Here

Examples of org.jibx.util.IClass

            }
           
            // process ID classification
            if (m_identIndex == DEF_IDENT/* || m_identIndex == AUTO_IDENT*/) {
                boolean valid = false;
                IClass gclas = m_propertyAttrs.getGetType();
                if (gclas != null) {
                    String gtype = gclas.getName();
                    if (gtype.equals("java.lang.String")) {
                        vctx.getContextObject().setIdChild(this, vctx);
                        valid = true;
                    }
                }
View Full Code Here

Examples of org.jibx.util.IClass

                }
            }
           
            // check for a Java 5 enumeration
            boolean isenum = false;
            IClass sclas = m_typeClass;
            while ((sclas = sclas.getSuperClass()) != null) {
                if (sclas.getName().equals("java.lang.Enum")) {
                    isenum = true;
                    break;
                }
            }
           
            // find the enum value method, if specified
            if (m_enumValueName != null) {
                if (isenum) {
                    if (m_serializerName == null &&
                        m_deserializerName == null) {
                        m_enumValueItem = m_typeClass.getMethod(m_enumValueName,
                            ENUM_VALUE_METHOD_SIGNATURE);
                        if (m_enumValueItem == null) {
                            vctx.addError("Nonstatic 'enum-value-method' " +
                                m_enumValueName + " not found in class " +
                                m_typeClass.getName());
                        }
                    } else {
                        vctx.addError("'enum-value-method' cannot be used with 'serializer' or 'deserializer'");
                    }
                } else {
                    vctx.addError("'enum-value-method' may only be used with Java 5 enum classes");
                }
            }
           
            // check specified serializer and deserializer
            String tname = m_typeClass.getName();
            if (vctx.isOutBinding()) {
                if (m_serializerName == null) {
                    if (m_enumValueItem == null) {
                       
                        // try to find an inherited serializer
                        FormatElement ances = m_baseFormat;
                        while (ances != null) {
                            m_serializerItem = ances.getSerializer();
                            if (m_serializerItem == null) {
                                ances = ances.getBaseFormat();
                            } else {
                                break;
                            }
                        }
                        if (m_serializerItem == null) {
                            IClassItem item = m_typeClass.getMethod("toString",
                                "()Ljava/lang/String;");
                            if (item == null) {
                                vctx.addError("toString method not found");
                            }
                        }
                       
                    }
                } else {
               
                    // build all possible signature variations
                    String[] tsigs = ClassUtils.
                        getSignatureVariants(tname, vctx);
                    int vcnt = SERIALIZER_SIGNATURE_VARIANTS.length;
                    String[] msigs = new String[tsigs.length * vcnt];
                    for (int i = 0; i < tsigs.length; i++) {
                        for (int j = 0; j < vcnt; j++) {
                            msigs[i*vcnt + j] = "(" + tsigs[i] +
                                SERIALIZER_SIGNATURE_VARIANTS[j] +
                                ")Ljava/lang/String;";
                        }
                    }
               
                    // find a matching static method
                    m_serializerItem = ClassUtils.
                        findStaticMethod(m_serializerName, msigs, vctx);
                    if (m_serializerItem == null) {
                        if (m_serializerName.indexOf('.') > 0) {
                            vctx.addError("Static serializer method " + m_serializerName + " not found");
                        } else {
                            vctx.addError("Need class name for static method " + m_serializerName);
                        }
                    }
                   
                }
            }
            if (vctx.isInBinding() || m_defaultText != null) {
                if (m_deserializerName == null) {
                    if (isenum) {
                        if (m_enumValueItem == null) {
                            m_deserializerItem = m_typeClass.
                            getMethod("valueOf", "(Ljava/lang/String;)");
                        }
                    } else {
                       
                        // try to find an inherited deserializer
                        FormatElement ances = m_baseFormat;
                        while (ances != null) {
                            m_deserializerItem = ances.getDeserializer();
                            if (m_deserializerItem == null) {
                                ances = ances.getBaseFormat();
                            } else {
                                break;
                            }
                        }
                        if (m_deserializerItem == null) {
                           
                            // try to find constructor from string as last resort
                            m_deserializerItem = m_typeClass.
                                getInitializerMethod(STRING_CONSTRUCTOR_SIGNATURE);
                            if (m_deserializerItem == null) {
                               
                                // error unless predefined formats
                                if (vctx.getNestingDepth() > 0) {
                                    StringBuffer buff = new StringBuffer();
                                    buff.append("Need deserializer or constructor from string");
                                    if (!vctx.isInBinding()) {
                                        buff.append(" for default value of type ");
                                        buff.append(tname);
                                    } else {
                                        buff.append(" for type ");
                                        buff.append(tname);
                                    }
                                    vctx.addError(buff.toString());
                                }
                               
                            }
                        }
                    }
                } else {
               
                    // find a matching static method
                    m_deserializerItem = ClassUtils.
                        findStaticMethod(m_deserializerName,
                            DESERIALIZER_SIGNATURES, vctx);
                    if (m_deserializerItem == null) {
                        if (m_deserializerName.indexOf('.') > 0) {
                            vctx.addError("Static deserializer method " + m_deserializerName + " not found");
                        } else {
                            vctx.addError("Need class name for static method " + m_deserializerName);
                        }
                    } else {
                        String result = m_deserializerItem.getTypeName();
                        if (!ClassUtils.isAssignable(result, tname, vctx)) {
                            vctx.addError("Static deserializer method " +
                                m_deserializerName +
                                " has incompatible result type");
                        }
                    }
                   
                }
            }
           
            // check for default value to be converted
            if (m_defaultText != null && m_deserializerItem != null) {
               
                // first load the class to handle conversion
                IClass iclas = m_deserializerItem.getOwningClass();
                Class clas = iclas.loadClass();
                Exception ex = null;
                boolean construct = false;
                try {
                    if (clas == null) {
                        vctx.addError("Unable to load class " +
                            iclas.getName() +
                            " for converting default value of type " + tname);
                    } else if (m_deserializerItem.isInitializer()) {
                       
                        // invoke constructor to process default value
                        construct = true;
View Full Code Here

Examples of org.jibx.util.IClass

                        if ((vctx.isInBinding() && getUnmarshallerName() == null) ||
                            (vctx.isOutBinding() && getMarshallerName() == null)) {
                            if (getUsing() == null) {
                               
                                // check for specific type known
                                IClass type = getType();
                                if (type == null) {
                                    vctx.addError("Internal error - null type");
                                } else if (!"java.lang.Object".equals(type.getName())) {
                                    setMappingReference(vctx, dctx, type);
                                }
                            }
                        }
                    }
                   
                } else {
                   
                    // find mapping by type name or class name
                    TemplateElementBase base =
                        dctx.getNamedTemplate(m_mapAsQName.toString());
                    if (base == null) {
                        base = dctx.getSpecificTemplate(m_mapAsName);
                        if (base == null) {
                            vctx.addFatal("No mapping with type name " +
                                m_mapAsQName.toString());
                        }
                    }
                    if (base != null) {
                       
                        // make sure type is compatible
                        IClass type = getType();
                        if (vctx.isLookupSupported() && type != null) {
                            if (!type.isAssignable(base.getHandledClass()) &&
                                !base.getHandledClass().isAssignable(type)) {
                                vctx.addError("Object type " + type.getName() +
                                    " is incompatible with binding for class " +
                                    base.getClassName());
                            }
                        }
                        m_effectiveMapping = base;
View Full Code Here

Examples of org.jibx.util.IClass

     */
    public void validate(ValidationContext vctx) {
       
        // set up child components and effective mapping
        classifyComponents(vctx);
        IClass type = getType();
        if (type != null) {
           
            // check each child component for compatible type
            ArrayList children = children();
            if (hasProperty() || getDeclaredType() != null) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.