Examples of IClass


Examples of org.jibx.util.IClass

            m_usage = vctx.getParentElement().getDefaultStyle();
        }
       
        // handle basic lookups and checks
        ContainerElementBase parent = vctx.getParentContainer();
        IClass cobj = parent.getChildObjectType();
        String dtype = null;
        String gtype = null;
        String stype = null;
        boolean err = false;
        m_isImplicit = true;
        if (m_fieldName != null) {
           
            // field means this is real (not implicit)
            m_isImplicit = false;
            if (vctx.isLookupSupported()) {
               
                // look up the field information
                m_fieldItem = cobj.getField(m_fieldName);
                if (m_fieldItem == null) {
                    vctx.addFatal("Nonstatic field " + m_fieldName +
                        " not found in class " + cobj.getName());
                    err = true;
                } else {
                    dtype = gtype = stype = m_fieldItem.getTypeName();
                }
               
            }
        }
        if (m_testName != null) {
           
            // make sure only used with optional
            if (m_usage == REQUIRED_USAGE) {
                vctx.addError("test-method can only be used with optional property");
            } else if (vctx.isLookupSupported()) {
               
                // look up the method information
                m_testItem = cobj.getMethod(m_testName, TEST_METHOD_SIGNATURES);
                if (m_testItem == null) {
                    vctx.addError("Nonstatic test-method " + m_testName +
                        " not found in class " + cobj.getName());
                }
               
            }
        }
        if (m_flagName != null) {
           
            // flag-method means this is real (not implicit)
            m_isImplicit = false;
            stype = "java.lang.Object";
            if (m_testName != null) {
                gtype = stype;
            }
            if (vctx.isLookupSupported()) {
               
                // look up the method information
                m_flagItem = cobj.getMethod(m_flagName, FLAG_METHOD_SIGNATURES);
                if (m_flagItem == null) {
                    vctx.addError("Nonstatic flag-method " + m_flagName +
                        " not found in class " + cobj.getName());
                }
               
            }
        }
        if (m_getName != null) {
           
            // get-method means this is real (not implicit)
            m_isImplicit = false;
            if (vctx.isLookupSupported()) {
               
                // look up the get method by name (no overload possible)
                m_getItem = cobj.getMethod(m_getName, GET_METHOD_SIGNATURES);
                if (m_getItem == null) {
                    vctx.addFatal("Nonstatic get-method " + m_getName +
                        " not found in class " + cobj.getName());
                    err = true;
                } else {
                    gtype = m_getItem.getTypeName();
                    if (dtype == null) {
                        dtype = gtype;
                    }
                }
               
            }
           
            // check for only get-method supplied when both directions needed
            if (vctx.isInBinding() && m_fieldName == null &&
                m_setName == null) {
                vctx.addError("Need field or set-method for input handling");
            }
        }
        if (m_setName != null) {
           
            // set-method means this is real (not implicit)
            m_isImplicit = false;
            if (vctx.isLookupSupported()) {
               
                // need to handle overloads, so generate possible signatures
                ArrayList sigs = new ArrayList();
                if (m_getItem != null) {
                    String psig = ClassUtils.getSignature(gtype);
                    sigs.add("(" + psig +
                        "Lorg/jibx/runtime/IUnmarshallingContext;" + ")V");
                    sigs.add("(" + psig + ")V");
                }
                if (m_declaredType != null) {
                    String psig = ClassUtils.getSignature(m_declaredType);
                    sigs.add("(" + psig +
                        "Lorg/jibx/runtime/IUnmarshallingContext;" + ")V");
                    sigs.add("(" + psig + ")V");
                }
                if (m_fieldItem != null) {
                    String psig = m_fieldItem.getSignature();
                    sigs.add("(" + psig +
                        "Lorg/jibx/runtime/IUnmarshallingContext;" + ")V");
                    sigs.add("(" + psig + ")V");
                }
                sigs.add
                    ("(Ljava/lang/Object;Lorg/jibx/runtime/IUnmarshallingContext;)V");
                sigs.add("(Ljava/lang/Object;)V");
               
                // match any of the possible signatures
                m_setItem = cobj.getMethod(m_setName,
                    (String[])sigs.toArray(new String[0]));
                if (m_setItem == null) {
                   
                    // nothing known about signature, try anything by name
                    m_setItem = cobj.getMethod(m_setName, "");
                    if (m_setItem != null) {
                        if (!m_setItem.getTypeName().equals("void") ||
                            m_setItem.getArgumentCount() > 2) {
                            m_setItem = null;
                        } else if (m_setItem.getArgumentCount() == 2) {
                            String xtype = m_setItem.getArgumentType(1);
                            if (!"org.jibx.runtime.IUnmarshallingContext".equals(xtype)) {
                                m_setItem = null;
                            }
                        }
                    }
                    if (m_setItem != null) {
                       
                        // make sure resulting type is compatible
                        String type = m_setItem.getArgumentType(0);
                        if (m_declaredType != null &&
                            !ClassUtils.isAssignable(m_declaredType, type, vctx)) {
                            m_setItem = null;
                        } else if (dtype != null &&
                            !ClassUtils.isAssignable(type, dtype, vctx)) {
                            m_setItem = null;
                        } else if (gtype != null &&
                            !ClassUtils.isAssignable(type, gtype, vctx)) {
                            m_setItem = null;
                        }
                        if (m_setItem != null) {
                            dtype = type;
                        }
                    }
                }
               
                // check set-method found
                if (m_setItem == null) {
                    vctx.addFatal("Nonstatic set-method " + m_setName +
                        " with argument of appropriate type not found in class " +
                        cobj.getName());
                    err = true;
                } else {
                    stype = m_setItem.getArgumentType(0);
                    if (dtype == null) {
                        dtype = stype;
                    }
                }
            }
           
            // check for only set-method supplied when both directions needed
            if (vctx.isOutBinding() && m_fieldName == null &&
                m_getName == null) {
                vctx.addError("Need field or get-method for output handling");
            }
        }
       
        // set the property type information
        String tname = m_declaredType;
        if (tname == null) {
            tname = dtype;
            if (tname == null) {
                tname = cobj.getName();
            }
        } else if (dtype == null) {
            dtype = gtype = stype = tname;
        }
        m_type = vctx.getClassInfo(tname);
View Full Code Here

Examples of org.jibx.util.IClass

   
    // get the class containing the method
    int split = name.lastIndexOf('.');
    String cname = name.substring(0, split);
    String mname = name.substring(split+1);
    IClass iclas = vctx.getClassInfo(cname);
        if (iclas != null) {
           
            // find the method in class or superclass
            for (int i = 0; i < sigs.length; i++) {
                IClassItem method = iclas.getMethod(mname, sigs[i]);
                if (method != null) {
                    return method;
                }
            }
        }
View Full Code Here

Examples of org.jibx.util.IClass

    // get the class containing the method
    int split = name.lastIndexOf('.');
    if (split > 0) {
        String cname = name.substring(0, split);
        String mname = name.substring(split+1);
        IClass iclas = vctx.getClassInfo(cname);
            if (iclas != null) {
               
                // find the method in class or superclass
                for (int i = 0; i < sigs.length; i++) {
                    IClassItem method = iclas.getStaticMethod(mname, sigs[i]);
                    if (method != null) {
                        return method;
                    }
                }
            }
View Full Code Here

Examples of org.jibx.util.IClass

   */
  public static String[] getSignatureVariants(String name,
        ValidationContext vctx) {
    Object obj = s_variantMap.get(name);
    if (obj == null) {
      IClass iclas = vctx.getRequiredClassInfo(name);
      return iclas.getInstanceSigs();
    } else {
      return (String[])obj;
    }
  }
View Full Code Here

Examples of org.jibx.util.IClass

      Object fobj = s_variantMap.get(from);
      Object tobj = s_variantMap.get(to);
      if (fobj == null && tobj == null) {
       
        // find the actual class information
        IClass fclas = vctx.getRequiredClassInfo(from);
                IClass tclas = vctx.getRequiredClassInfo(to);
               
                // assignable if from type has to as a possible signature
                String[] sigs = fclas.getInstanceSigs();
                String match = tclas.getSignature();
                for (int i = 0; i < sigs.length; i++) {
                    if (match.equals(sigs[i])) {
                        return true;
                    }
                }
View Full Code Here

Examples of org.jibx.util.IClass

     *
     * @param comp
     * @return qualified type name, <code>null</code> if inline definition needed
     */
    private QName getSimpleTypeQName(IComponent comp) {
        IClass type = comp.getType();
        String tname = comp.getType().getName();
        QName qname = Types.schemaType(tname);
        if (qname == null) {
            qname = (QName)m_classSimpletypes.get(tname);
            if (qname == null) {
                ClassCustom custom = m_custom.getClassCustomization(type.getName());
                if (custom != null && custom.isSimpleValue()) {
                    qname = Types.STRING_QNAME;
                } else if (!type.isSuperclass("java.lang.Enum")) {
                    m_context.addWarning("No schema equivalent known for type - treating as string", comp);
                    qname = Types.STRING_QNAME;
                }
            }
        }
View Full Code Here

Examples of org.jibx.util.IClass

     * @param detail
     */
    private void addMapping(MappingDetail detail) {
       
        // get the documentation to be used for type
        IClass info = null;
        if (m_locator != null) {
            info = m_locator.getClassInfo(detail.getMapping().getClassName());
        }
       
        // start by generating group/attributeGroup schema components
View Full Code Here

Examples of org.jibx.util.IClass

     *
     * @param name fully-qualified name of class to be found
     * @return class information
     */
    public IClass getRequiredClassInfo(String name) {
        IClass iclas = m_locator.getClassInfo(name);
        if (iclas == null) {
            throw new IllegalStateException("Internal error: class " + name +
                " cannot be found");
        } else {
            return iclas;
View Full Code Here

Examples of org.jibx.util.IClass

        } else if (smeth == null) {
            type = gmeth.getTypeName();
        } else {
            String gtype = gmeth.getTypeName();
            String stype = smeth.getArgumentType(0);
            IClass gclas = icl.getRequiredClassInfo(gtype);
            if (gclas.isSuperclass(stype) || gclas.isImplements(stype)) {
                type = gtype;
            } else {
                type = stype;
            }
        }
View Full Code Here

Examples of org.jibx.util.IClass

     * @see org.jibx.binding.model.AttributeBase#prevalidate(org.jibx.binding.model.ValidationContext)
     */
    public void prevalidate(ValidationContext vctx) {
       
        // first check for actual object association
        IClass iclas;
        ElementBase element = vctx.getParentElement(0);
        if (element instanceof StructureElementBase) {
            if (!((StructureElementBase)element).hasObject()) {
                if (m_factoryName != null) {
                    vctx.addWarning("No object for structure; factory attribute ignored");
                    m_factoryName = null;
                }
                if (m_preSetName != null) {
                    vctx.addWarning("No object for structure; pre-set attribute ignored");
                    m_preSetName = null;
                }
                if (m_preGetName != null) {
                    vctx.addWarning("No object for structure; pre-get attribute ignored");
                    m_preGetName = null;
                }
                if (m_postSetName != null) {
                    vctx.addWarning("No object for structure; post-set attribute ignored");
                    m_postSetName = null;
                }
                if (m_marshallerName != null) {
                    vctx.addWarning("No object for structure; marshaller attribute ignored");
                    m_marshallerName = null;
                }
                if (m_unmarshallerName != null) {
                    vctx.addWarning("No object for structure; unmarshaller attribute ignored");
                    m_unmarshallerName = null;
                }
                if (m_createType != null) {
                    vctx.addWarning("No object for structure; create-type attribute ignored");
                    m_createType = null;
                }
                if (m_isNillable) {
                    vctx.addError("No object for structure; nillable attribute forbidden");
                    m_isNillable = false;
                }
                return;
            } else {
                iclas = ((StructureElementBase)element).getType();
            }
        } else if (element instanceof MappingElementBase) {
            iclas = ((MappingElementBase)element).getHandledClass();
        } else {
            throw new IllegalStateException
                ("Unknown element for object attributes");
        }
        String type = iclas.getName();
       
        // first check for marshaller and unmarshaller classes
        if (m_marshallerName != null) {
            if (vctx.isOutBinding()) {
                IClass mclas = vctx.getClassInfo(m_marshallerName);
                if (mclas == null) {
                    vctx.addError("Marshaller class " + m_marshallerName + " not found");
                } else if (vctx.isLookupSupported() && !mclas.isImplements(MARSHALLER_INTERFACETYPE)) {
                    vctx.addError("Marshaller class " + m_marshallerName + " does not implement interface " + MARSHALLER_INTERFACE);
                } else {
                    m_marshallerClass = mclas;
                }
            } else {
                vctx.addWarning("marshaller attribute ignored for input-only binding");
            }
        }
        if (m_unmarshallerName != null) {
            if (vctx.isInBinding()) {
               
                // get the unmarshaller information
                IClass uclas = vctx.getClassInfo(m_unmarshallerName);
                if (uclas == null) {
                    vctx.addError("Unmarshaller class " + m_unmarshallerName + " not found");
                } else if (vctx.isLookupSupported() && !uclas.isImplements(UNMARSHALLER_INTERFACETYPE)) {
                    vctx.addError("Unmarshaller class " + m_unmarshallerName + " does not implement interface " + UNMARSHALLER_INTERFACE);
                } else {
                    m_unmarshallerClass = uclas;
                }
               
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.