Examples of BindXml


Examples of org.exolab.castor.mapping.xml.BindXml

            // -- fieldType
            fieldMap.setType(fieldType.getName());

            // -- handle XML Specific information
            fieldMap.setBindXml(new BindXml());
            fieldMap.getBindXml().setName(((XMLFieldDescriptor) fdesc).getXMLName());
            fieldMap.getBindXml().setNode(
                    BindXmlNodeType.valueOf(((XMLFieldDescriptor) fields[i]).getNodeType()
                            .toString()));
            if (classMap.getClassChoice() == null) {
View Full Code Here

Examples of org.exolab.castor.mapping.xml.BindXml

                                if (relFieldName == null) {
                                    relFieldName = relFields[n].getName();
                                }
                                String relFullName = relTable + "." + relFieldName;

                                BindXml relFieldXml = relFields[n].getBindXml();
                                String node = "element";
                                if (relFieldXml != null) {
                                    node = relFieldXml.getNode().toString();
                                }

                                if (!relFieldName.equals(foreKey)) {
                                    expr.addColumn(relTable, relFieldName);
                                    _cols.put(relTable + "." + relFieldName,
                                            new Integer(++_lastCol));

                                    if (node.equalsIgnoreCase("attribute")) {
                                        relDesc.addAttr(relFullName, relField);
                                    } else if (node.equalsIgnoreCase("element")) {
                                        relDesc.addSimpleElement(relFullName, relField);
                                    } else if (node.equalsIgnoreCase("text")) {
                                        relDesc.setTextCol(relFullName, relField);
                                    }
                                }
                                if (relField.getName().equals(relMapping.getIdentity(0))) {
                                    _ids.add(relTable + "." + relFieldName);
                                    desc.addContained(relTable + "." + relFieldName, relMapping);
                                    _classes.put(relTable + "." + relFieldName, relDesc);
                                }
                            }
                        }
                    }
                }

            } else {

                String fieldName = fieldSql.getName()[0];
                if (fieldName == null) {
                    fieldName = fields[i].getName();
                }
                String fullName = table + "." + fieldName;

                BindXml fieldXml = field.getBindXml();
                String node = "element";
                if (fieldXml != null) {
                     node = fieldXml.getNode().toString();
                }

                if (node.equalsIgnoreCase("attribute")) {
                    desc.addAttr(fullName, field);
                } else if (node.equalsIgnoreCase("element")) {
View Full Code Here

Examples of org.exolab.castor.mapping.xml.BindXml

        }

        // Create an XML field descriptor
        fieldDesc = super.createFieldDesc( javaClass, fieldMap );

        BindXml xml = fieldMap.getBindXml();

        boolean deriveNameByClass = false;

        if (xml != null) {
            //-- xml name
            xmlName = xml.getName();

            //-- node type
            if ( xml.getNode() != null )
                nodeType = NodeType.getNodeType( xml.getNode().toString() );

            //-- matches
            match = xml.getMatches();

            //-- reference
            isReference = xml.getReference();

            //-- XML transient
            isXMLTransient = xml.getTransient();

            //-- autonaming
            BindXmlAutoNamingType autoName = xml.getAutoNaming();
            if (autoName != null) {
                deriveNameByClass = (autoName == BindXmlAutoNamingType.DERIVEBYCLASS);
            }

        }

        //-- transient
        //-- XXXX -> if it's transient we probably shouldn't do all
        //-- XXXX -> the unecessary work
        isXMLTransient = isXMLTransient || fieldDesc.isTransient();

        //--

        //-- handle QName for xmlName
        String namespace = null;
        if ((xmlName != null) && (xmlName.length() > 0)){
            if (xmlName.charAt(0) == '{') {
                int idx = xmlName.indexOf('}');
                if (idx < 0) {
                    throw new MappingException("Invalid QName: " + xmlName);
                }
                namespace = xmlName.substring(1, idx);
                xmlName = xmlName.substring(idx+1);
            }
            else if (xmlName.startsWith(XML_PREFIX)) {
                namespace = Namespaces.XML_NAMESPACE;
                xmlName = xmlName.substring(4);
            }
        }

        if (nodeType == null) {
            if (isPrimitive(javaClass))
                nodeType = getInternalContext().getPrimitiveNodeType();
            else
                nodeType = NodeType.Element;
        }

        //-- Create XML name if necessary. Note if name is to be derived
        //-- by class..we just make sure we set the name to null...
        //-- the Marshaller does this during runtime. This allows
        //-- Collections to be handled properly.
        if ((!deriveNameByClass) && ((xmlName == null) && (match == null)))
        {
            xmlName = getInternalContext().getXMLNaming().toXMLName( fieldDesc.getFieldName() );
            match = xmlName + ' ' + fieldDesc.getFieldName();
        }

        xmlDesc = new XMLFieldDescriptorImpl( fieldDesc, xmlName, nodeType, getInternalContext().getPrimitiveNodeType() );
       
        if (xmlDesc.getHandler() != null && xmlDesc.getHandler() instanceof AbstractFieldHandler) {
            AbstractFieldHandler handler = (AbstractFieldHandler) xmlDesc.getHandler();
            handler.setFieldDescriptor(xmlDesc);
        }

        //-- transient?
        xmlDesc.setTransient(isXMLTransient);

        //--set a default fieldValidator
        xmlDesc.setValidator(new FieldValidator());

        //-- enable use parent namespace if explicit one doesn't exist
        xmlDesc.setUseParentsNamespace(true);

        //-- If deriveNameByClass we need to reset the name to
        //-- null because XMLFieldDescriptorImpl tries to be smart
        //-- and automatically creates the name.
        if (deriveNameByClass) {
            xmlDesc.setXMLName(null);
        }

        //-- namespace
        if (namespace != null) {
            xmlDesc.setNameSpaceURI(namespace);
        }

        //-- matches
        if (match != null) {
            xmlDesc.setMatches(match);
            //-- special fix for xml-name since XMLFieldDescriptorImpl
            //-- will create a default name based off the field name
            if (xmlName == null) xmlDesc.setXMLName(null);
        }

        //-- reference
        xmlDesc.setReference(isReference);
        if (isReference) {
          if (colType == null) {
            FieldValidator fieldValidator = new FieldValidator();
            fieldValidator.setValidator(new IdRefValidator());
            xmlDesc.setValidator(fieldValidator);
          } else {
            // TODO handle other cases
          }
        }

        xmlDesc.setContainer(fieldMap.getContainer());
       
        xmlDesc.setNillable(fieldMap.isNillable());

        if (xml != null) {

            //-- has class descriptor for type specified
            if (xml.getClassMapping() != null) {
                ClassDescriptor cd = createClassDescriptor(xml.getClassMapping());
                xmlDesc.setClassDescriptor(cd);
            }

            //-- has location path?
            if (xml.getLocation() != null) {
                xmlDesc.setLocationPath(xml.getLocation());
            }
            //is the value type needs specific handling
            //such as QName or NCName support?
            String xmlType = xml.getType();
            xmlDesc.setSchemaType(xmlType);
            xmlDesc.setQNamePrefix(xml.getQNamePrefix());
            TypeValidator validator = null;
            if (NCNAME.equals(xmlType)) {
                validator = new NameValidator(XMLConstants.NAME_TYPE_NCNAME);
                xmlDesc.setValidator(new FieldValidator(validator));
            }

            //-- special properties?
            Property[] props = xml.getProperty();
            if ((props != null) && (props.length > 0)) {
                for (int pIdx = 0; pIdx < props.length; pIdx++) {
                    Property prop = props[pIdx];
                    xmlDesc.setXMLProperty(prop.getName(), prop.getValue());
                }
View Full Code Here

Examples of org.exolab.castor.mapping.xml.BindXml

        if (className.equals("byte[]")) {
            className = "bytes";
        }
        fieldMap.setType(className);

        BindXml bindXml = new BindXml();
        fieldMap.setBindXml(bindXml);

        String nodeName = xmlNature.getNodeName();
        if ((nodeName != null) && (!isText)) {
            bindXml.setName(nodeName);
        }

        if (isAttribute) {
            bindXml.setNode(BindXmlNodeType.ATTRIBUTE);
        } else if (isText) {
            bindXml.setNode(BindXmlNodeType.TEXT);
        } else {
            bindXml.setNode(BindXmlNodeType.ELEMENT);
        }

        switch (xsType.getType()) {
            case XSType.IDREF_TYPE :
                bindXml.setReference(true);
                break;
            case XSType.ID_TYPE :
                classMapping.addIdentity(member.getName());
                break;
            case XSType.QNAME_TYPE :
                bindXml.setType("QName");
            default:
                break;
        }

        //-- set any user-specified field handler
        fieldMap.setHandler(member.getXMLFieldHandler());

        //-- container
        if (member.isContainer()) {
            fieldMap.setContainer(true);
        }

        // Handle namespaces.  FieldInfo namespace has higher priority than ClassInfo namespace.
        // TODO Need to add better namespace support to bind-xml element,
        //      it's not very good at the moment
//      nsURI = member.getNamespaceURI();
//      if (nsURI != null) {
//          jsc.add("desc.setNameSpaceURI(\"");
//          jsc.append(nsURI);
//          jsc.append("\");");
//      }
//
//      if (any && member.getNamespaceURI() == null) {
//          nsURI = null;
//      }

        // required
        if (xmlNature.isRequired()) {
            fieldMap.setRequired(true);
        }

        // nillable
        if (member.isNillable()) {
            // TODO Mapping file needs nillable support!
        }

        // if any it can match all the names
        if (any) {
            bindXml.setMatches("*");
        }

        // Add Validation Code
        // TODO mapping file has no validation support so users need to use xsi:schemaLocation
        // in their XML instances and enable schema validation on the parser
View Full Code Here

Examples of org.exolab.castor.mapping.xml.BindXml

        }

        // Create an XML field descriptor
        fieldDesc = super.createFieldDesc( javaClass, fieldMap );

        BindXml xml = fieldMap.getBindXml();

        boolean deriveNameByClass = false;

        if (xml != null) {
            //-- xml name
            xmlName = xml.getName();

            //-- node type
            if ( xml.getNode() != null )
                nodeType = NodeType.getNodeType( xml.getNode().toString() );

            //-- matches
            match = xml.getMatches();

            //-- reference
            isReference = xml.getReference();

            //-- XML transient
            isXMLTransient = xml.getTransient();

            //-- autonaming
            BindXmlAutoNamingType autoName = xml.getAutoNaming();
            if (autoName != null) {
                deriveNameByClass = (autoName == BindXmlAutoNamingType.DERIVEBYCLASS);
            }

        }
       
        //-- transient
        //-- XXXX -> if it's transient we probably shouldn't do all
        //-- XXXX -> the unecessary work
        isXMLTransient = isXMLTransient || fieldDesc.isTransient();
       
        //--

        //-- handle QName for xmlName
        String namespace = null;
        if ((xmlName != null) && (xmlName.length() > 0)){
            if (xmlName.charAt(0) == '{') {
                int idx = xmlName.indexOf('}');
                if (idx < 0) {
                    throw new MappingException("Invalid QName: " + xmlName);
                }
                namespace = xmlName.substring(1, idx);
                xmlName = xmlName.substring(idx+1);
            }
            else if (xmlName.startsWith(XML_PREFIX)) {
                namespace = Namespaces.XML_NAMESPACE;
                xmlName = xmlName.substring(4);
            }
        }

        if (nodeType == null) {
            if (isPrimitive(javaClass))
                nodeType = _primitiveNodeType;
            else
                nodeType = NodeType.Element;
        }

        //-- Create XML name if necessary. Note if name is to be derived
        //-- by class..we just make sure we set the name to null...
        //-- the Marshaller does this during runtime. This allows
        //-- Collections to be handled properly.
        if ((!deriveNameByClass) && ((xmlName == null) && (match == null)))
        {
            xmlName = _naming.toXMLName( fieldDesc.getFieldName() );
            match = xmlName + ' ' + fieldDesc.getFieldName();
        }

        xmlDesc = new XMLFieldDescriptorImpl( fieldDesc, xmlName, nodeType, _primitiveNodeType );

        //-- transient?
        xmlDesc.setTransient(isXMLTransient);

        //--set a default fieldValidator
        xmlDesc.setValidator(new FieldValidator());
       
        //-- enable use parent namespace if explicit one doesn't exist
        xmlDesc.setUseParentsNamespace(true);

        //-- If deriveNameByClass we need to reset the name to
        //-- null because XMLFieldDescriptorImpl tries to be smart
        //-- and automatically creates the name.
        if (deriveNameByClass) {
            xmlDesc.setXMLName(null);
        }

        //-- namespace
        if (namespace != null) {
            xmlDesc.setNameSpaceURI(namespace);
        }

        //-- matches
        if (match != null) {
            xmlDesc.setMatches(match);
            //-- special fix for xml-name since XMLFieldDescriptorImpl
            //-- will create a default name based off the field name
            if (xmlName == null) xmlDesc.setXMLName(null);
        }

        //-- reference
        xmlDesc.setReference(isReference);

        xmlDesc.setContainer(fieldMap.getContainer());

        if (xml != null) {
           
            //-- has class descriptor for type specified
            if (xml.getClassMapping() != null) {
                ClassDescriptor cd = createDescriptor(xml.getClassMapping());
                xmlDesc.setClassDescriptor((XMLClassDescriptor)cd);
            }
           
            //-- has location path?
            if (xml.getLocation() != null) {
                xmlDesc.setLocationPath(xml.getLocation());
            }
            //is the value type needs specific handling
            //such as QName or NCName support?
            String xmlType = xml.getType();
            xmlDesc.setSchemaType(xmlType);
            xmlDesc.setQNamePrefix(xml.getQNamePrefix());
            TypeValidator validator = null;
            if (NCNAME.equals(xmlType)) {
                validator = new NameValidator(NameValidator.NCNAME);
                xmlDesc.setValidator(new FieldValidator(validator));
            }
           
            //-- special properties?
            Property[] props = xml.getProperty();
            if ((props != null) && (props.length > 0)) {
                for (int pIdx = 0; pIdx < props.length; pIdx++) {
                    Property prop = props[pIdx];
                    xmlDesc.setProperty(prop.getName(), prop.getValue());
                }
View Full Code Here

Examples of org.exolab.castor.mapping.xml.BindXml

            //-- fieldType
            fieldMap.setType( fieldType.getName() );
           
               
            //-- handle XML Specific information
            fieldMap.setBindXml( new BindXml() );
            fieldMap.getBindXml().setName( ( (XMLFieldDescriptor) fdesc ).getXMLName() );
            fieldMap.getBindXml().setNode( BindXmlNodeType.valueOf( ((XMLFieldDescriptor) fields[ i ]).getNodeType().toString() ) );
            classMap.addFieldMapping( fieldMap );
           
            if (deep) {
View Full Code Here

Examples of org.exolab.castor.mapping.xml.BindXml

            //-- fieldType
            fieldMap.setType( fieldType.getName() );
           
               
            //-- handle XML Specific information
            fieldMap.setBindXml( new BindXml() );
            fieldMap.getBindXml().setName( ( (XMLFieldDescriptor) fdesc ).getXMLName() );
            fieldMap.getBindXml().setNode( BindXmlNodeType.valueOf( ((XMLFieldDescriptor) fields[ i ]).getNodeType().toString() ) );
            classMap.addFieldMapping( fieldMap );
           
            if (deep) {
View Full Code Here

Examples of org.exolab.castor.mapping.xml.BindXml

        if (relFieldName == null) {
            relFieldName = relFields[n].getName();
        }
        String relFullName = relTable + "." + relFieldName;

        BindXml relFieldXml = relFields[n].getBindXml();
        String node = "element";
        if (relFieldXml != null) {
            node = relFieldXml.getNode().toString();
        }

        if (!relFieldName.equals(foreKey)) {
            expr.addColumn(relTable, relFieldName);
            _cols.put(relTable + "." + relFieldName, new Integer(++_lastCol));

            if (node.equalsIgnoreCase("attribute")) {
          relDesc.addAttr(relFullName, relField);
            } else if (node.equalsIgnoreCase("element")) {
          relDesc.addSimpleElement(relFullName, relField);
            } else if (node.equalsIgnoreCase("text")) {
          relDesc.setTextCol(relFullName, relField);
            }
        }
        if (relField.getName().equals(relMapping.getIdentity())) {
            _ids.add(relTable + "." + relFieldName);
            desc.addContained(relTable + "." + relFieldName, relMapping);
            _classes.put(relTable + "." + relFieldName, relDesc);
        }
          }
      }
                    }
                }

      } else {

    String fieldName = fieldSql.getName()[0];
    if (fieldName == null) {
        fieldName = fields[i].getName();
    }
    String fullName = table + "." + fieldName;

    BindXml fieldXml = field.getBindXml();
    String node = "element";
    if (fieldXml != null) {
         node = fieldXml.getNode().toString();
    }

    if (node.equalsIgnoreCase("attribute")) {
        desc.addAttr(fullName, field);
    } else if (node.equalsIgnoreCase("element")) {
View Full Code Here

Examples of org.exolab.castor.mapping.xml.BindXml

        // Create an XML field descriptor

        fieldDesc = super.createFieldDesc( javaClass, fieldMap );

        BindXml xml = fieldMap.getBindXml();

        boolean deriveNameByClass = false;

        if (xml != null) {
            //-- xml name
            xmlName = xml.getName();

            //-- node type
            if ( xml.getNode() != null )
                nodeType = NodeType.getNodeType( xml.getNode().toString() );

            //-- matches
            match = xml.getMatches();

            //-- reference
            isReference = xml.getReference();

            //-- XML transient
            isXMLTransient = xml.getTransient();

            //-- autonaming
            BindXmlAutoNamingType autoName = xml.getAutoNaming();
            if (autoName != null) {
                deriveNameByClass = (autoName == BindXmlAutoNamingType.DERIVEBYCLASS);
            }

        }
       
        //-- transient
        //-- XXXX -> if it's transient we probably shouldn't do all
        //-- XXXX -> the unecessary work
        isXMLTransient = isXMLTransient || fieldDesc.isTransient();
       
        //--

        //-- handle QName for xmlName
        String namespace = null;
        if ((xmlName != null) && (xmlName.length() > 0)){
            if (xmlName.charAt(0) == '{') {
                int idx = xmlName.indexOf('}');
                if (idx < 0) {
                    throw new MappingException("Invalid QName: " + xmlName);
                }
                namespace = xmlName.substring(1, idx);
                xmlName = xmlName.substring(idx+1);
            }
        }

        if (nodeType == null) {
            if (isPrimitive(javaClass))
                nodeType = _primitiveNodeType;
            else
                nodeType = NodeType.Element;
        }

        //-- Create XML name if necessary. Note if name is to be derived
        //-- by class..we just make sure we set the name to null...
        //-- the Marshaller does this during runtime. This allows
        //-- Collections to be handled properly.
        if ((!deriveNameByClass) && ((xmlName == null) && (match == null)))
        {
            xmlName = _naming.toXMLName( fieldDesc.getFieldName() );
            match = xmlName + ' ' + fieldDesc.getFieldName();
        }

        xmlDesc = new XMLFieldDescriptorImpl( fieldDesc, xmlName, nodeType, _primitiveNodeType );

        //-- transient?
        xmlDesc.setTransient(isXMLTransient);

        //--set a default fieldValidator
        xmlDesc.setValidator(new FieldValidator());

        //-- If deriveNameByClass we need to reset the name to
        //-- null because XMLFieldDescriptorImpl tries to be smart
        //-- and automatically creates the name.
        if (deriveNameByClass) {
            xmlDesc.setXMLName(null);
        }

        //-- namespace
        if (namespace != null) {
            xmlDesc.setNameSpaceURI(namespace);
        }

        //-- matches
        if (match != null) {
            xmlDesc.setMatches(match);
            //-- special fix for xml-name since XMLFieldDescriptorImpl
            //-- will create a default name based off the field name
            if (xmlName == null) xmlDesc.setXMLName(null);
        }

        //-- reference
        xmlDesc.setReference(isReference);

        xmlDesc.setContainer(fieldMap.getContainer());

        if (xml != null) {
           
            //-- has location path?
            if (xml.getLocation() != null) {
                xmlDesc.setLocationPath(xml.getLocation());
            }
            //is the value type needs specific handling
            //such as QName or NCName support?
            String xmlType = xml.getType();
            xmlDesc.setSchemaType(xmlType);
            xmlDesc.setQNamePrefix(xml.getQNamePrefix());
            TypeValidator validator = null;
            if (NCNAME.equals(xmlType)) {
                validator = new NameValidator(NameValidator.NCNAME);
                xmlDesc.setValidator(new FieldValidator(validator));
            }
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.